.',
21 | el.rawAttrsMap['class']
22 | )
23 | }
24 | }
25 | if (staticClass) {
26 | el.staticClass = JSON.stringify(staticClass)
27 | }
28 | const classBinding = getBindingAttr(el, 'class', false /* getStatic */)
29 | if (classBinding) {
30 | el.classBinding = classBinding
31 | }
32 | }
33 |
34 | function genData (el: ASTElement): string {
35 | let data = ''
36 | if (el.staticClass) {
37 | data += `staticClass:${el.staticClass},`
38 | }
39 | if (el.classBinding) {
40 | data += `class:${el.classBinding},`
41 | }
42 | return data
43 | }
44 |
45 | export default {
46 | staticKeys: ['staticClass'],
47 | transformNode,
48 | genData
49 | }
50 |
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/src/platforms/weex/compiler/modules/recycle-list/recycle-list.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import { parseFor } from 'compiler/parser/index'
4 | import { getAndRemoveAttr, addRawAttr } from 'compiler/helpers'
5 |
6 | /**
7 | * Map the following syntax to corresponding attrs:
8 | *
9 | *
10 | * ...
11 | * ...
12 | *
13 | */
14 |
15 | export function preTransformRecycleList (
16 | el: ASTElement,
17 | options: WeexCompilerOptions
18 | ) {
19 | const exp = getAndRemoveAttr(el, 'for')
20 | if (!exp) {
21 | if (options.warn) {
22 | options.warn(`Invalid
syntax: missing "for" expression.`)
23 | }
24 | return
25 | }
26 |
27 | const res = parseFor(exp)
28 | if (!res) {
29 | if (options.warn) {
30 | options.warn(`Invalid syntax: ${exp}.`)
31 | }
32 | return
33 | }
34 |
35 | addRawAttr(el, ':list-data', res.for)
36 | addRawAttr(el, 'binding-expression', res.for)
37 | addRawAttr(el, 'alias', res.alias)
38 | if (res.iterator2) {
39 | // (item, key, index) for object iteration
40 | // is this even supported?
41 | addRawAttr(el, 'index', res.iterator2)
42 | } else if (res.iterator1) {
43 | addRawAttr(el, 'index', res.iterator1)
44 | }
45 |
46 | const switchKey = getAndRemoveAttr(el, 'switch')
47 | if (switchKey) {
48 | addRawAttr(el, 'switch', switchKey)
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/docs/.vuepress/theme/components/Sidebar.vue:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
27 |
28 |
65 |
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/src/compiler/codeframe.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | const range = 2
4 |
5 | export function generateCodeFrame (
6 | source: string,
7 | start: number = 0,
8 | end: number = source.length
9 | ): string {
10 | const lines = source.split(/\r?\n/)
11 | let count = 0
12 | const res = []
13 | for (let i = 0; i < lines.length; i++) {
14 | count += lines[i].length + 1
15 | if (count >= start) {
16 | for (let j = i - range; j <= i + range || end > count; j++) {
17 | if (j < 0 || j >= lines.length) continue
18 | res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`)
19 | const lineLength = lines[j].length
20 | if (j === i) {
21 | // push underline
22 | const pad = start - (count - lineLength) + 1
23 | const length = end > count ? lineLength - pad : end - start
24 | res.push(` | ` + repeat(` `, pad) + repeat(`^`, length))
25 | } else if (j > i) {
26 | if (end > count) {
27 | const length = Math.min(end - count, lineLength)
28 | res.push(` | ` + repeat(`^`, length))
29 | }
30 | count += lineLength + 1
31 | }
32 | }
33 | break
34 | }
35 | }
36 | return res.join('\n')
37 | }
38 |
39 | function repeat (str, n) {
40 | let result = ''
41 | if (n > 0) {
42 | while (true) { // eslint-disable-line
43 | if (n & 1) result += str
44 | n >>>= 1
45 | if (n <= 0) break
46 | str += str
47 | }
48 | }
49 | return result
50 | }
51 |
--------------------------------------------------------------------------------
/main/README.md:
--------------------------------------------------------------------------------
1 | # Vue 3 + TypeScript + Vite
2 |
3 | This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `
22 |
23 |
--------------------------------------------------------------------------------
/docs/.vuepress/theme/components/Footer.vue:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
22 |
23 |
--------------------------------------------------------------------------------
/docs/js/6.md:
--------------------------------------------------------------------------------
1 | # event-loop
2 |
3 | 宏任务,我们通常看到的回调,setTimeOut 和 setInterval 这些任务,都是宏任务,它们都通过 event loop 来执行。
4 |
5 |
6 | 使用宏任务的api
7 | - setTimeOut
8 | - setInterval
9 | - script 代码
10 | - I/O
11 | - UI 交互事件
12 | - UI渲染
13 |
14 | 微任务执行时机,当创建该微任务函数执行完,而且JavaScript执行栈为空,而且控制器还没有交给 event loop,如果有微任务,微任务将会被执行。
15 |
16 | 使用微任务实现的 api:
17 | - promise
18 | - Mutation Observer API
19 |
20 | 微任务的实现
21 |
22 | ```js
23 | if (typeof window.queueMicrotask !== "function") {
24 | window.queueMicrotask = function (callback) {
25 | Promise.resolve()
26 | .then(callback)
27 | .catch(e => setTimeout(() => { throw e; })); // report exceptions
28 | };
29 | }
30 | ```
31 |
32 | 啥时候使用微任务,比如保证调用顺序一致:
33 |
34 | ```js
35 | customElement.prototype.getData = url => {
36 | if (this.cache[url]) {
37 | queueMicrotask(() => {
38 | this.data = this.cache[url];
39 | this.dispatchEvent(new Event("load"));
40 | });
41 | } else {
42 | fetch(url).then(result => result.arrayBuffer()).then(data => {
43 | this.cache[url] = data;
44 | this.data = data;
45 | this.dispatchEvent(new Event("load"));
46 | });
47 | }
48 | };
49 | ```
50 |
51 |
52 | ### 参考
53 |
54 | - [Event Loop Spec](https://html.spec.whatwg.org/multipage/webappapis.html#event-loops)
55 | - [event loop](https://javascript.info/event-loop)
56 | - [queueMicrotask](https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/queueMicrotask)
57 | - [event-loop](https://javascript.info/event-loop)
58 | - [Microtask guide](https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide)
59 | - [自实现微任务](https://github.com/feross/queue-microtask)
60 | - [microtask guide in depth](https://developer.mozilla.org/en-US/docs/Web/API/HTML_DOM_API/Microtask_guide/In_depth)
61 | - [JavaScript 运行机制详解:再谈Event Loop](http://www.ruanyifeng.com/blog/2014/10/event-loop.html)
62 | - [Tasks, microtasks, queues 和 schedules](https://hongfanqie.github.io/tasks-microtasks-queues-and-schedules/)
63 | - [更快的异步函数和 Promise](https://v8.js.cn/blog/fast-async/)
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/src/platforms/weex/compiler/modules/recycle-list/index.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import { preTransformRecycleList } from './recycle-list'
4 | import { postTransformComponent } from './component'
5 | import { postTransformComponentRoot } from './component-root'
6 | import { postTransformText } from './text'
7 | import { preTransformVBind } from './v-bind'
8 | import { preTransformVIf } from './v-if'
9 | import { preTransformVFor } from './v-for'
10 | import { postTransformVOn } from './v-on'
11 | import { preTransformVOnce } from './v-once'
12 |
13 | let currentRecycleList = null
14 |
15 | function shouldCompile (el: ASTElement, options: WeexCompilerOptions) {
16 | return options.recyclable ||
17 | (currentRecycleList && el !== currentRecycleList)
18 | }
19 |
20 | function preTransformNode (el: ASTElement, options: WeexCompilerOptions) {
21 | if (el.tag === 'recycle-list') {
22 | preTransformRecycleList(el, options)
23 | currentRecycleList = el
24 | }
25 | if (shouldCompile(el, options)) {
26 | preTransformVBind(el)
27 | preTransformVIf(el, options) // also v-else-if and v-else
28 | preTransformVFor(el, options)
29 | preTransformVOnce(el)
30 | }
31 | }
32 |
33 | function transformNode (el: ASTElement, options: WeexCompilerOptions) {
34 | if (shouldCompile(el, options)) {
35 | // do nothing yet
36 | }
37 | }
38 |
39 | function postTransformNode (el: ASTElement, options: WeexCompilerOptions) {
40 | if (shouldCompile(el, options)) {
41 | // mark child component in parent template
42 | postTransformComponent(el, options)
43 | // mark root in child component template
44 | postTransformComponentRoot(el)
45 | // : transform children text into value attr
46 | if (el.tag === 'text') {
47 | postTransformText(el)
48 | }
49 | postTransformVOn(el)
50 | }
51 | if (el === currentRecycleList) {
52 | currentRecycleList = null
53 | }
54 | }
55 |
56 | export default {
57 | preTransformNode,
58 | transformNode,
59 | postTransformNode
60 | }
61 |
--------------------------------------------------------------------------------
/docs/.vuepress/theme/components/NavLink.vue:
--------------------------------------------------------------------------------
1 |
2 |
9 | {{ item.text }}
10 |
11 |
19 | {{ item.text }}
20 |
21 |
22 |
23 |
24 |
91 |
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/src/server/webpack-plugin/server.js:
--------------------------------------------------------------------------------
1 | import { validate, isJS, onEmit } from './util'
2 |
3 | export default class VueSSRServerPlugin {
4 | constructor (options = {}) {
5 | this.options = Object.assign({
6 | filename: 'vue-ssr-server-bundle.json'
7 | }, options)
8 | }
9 |
10 | apply (compiler) {
11 | validate(compiler)
12 |
13 | onEmit(compiler, 'vue-server-plugin', (compilation, cb) => {
14 | const stats = compilation.getStats().toJson()
15 | const entryName = Object.keys(stats.entrypoints)[0]
16 | const entryInfo = stats.entrypoints[entryName]
17 |
18 | if (!entryInfo) {
19 | // #5553
20 | return cb()
21 | }
22 |
23 | const entryAssets = entryInfo.assets.filter(isJS)
24 |
25 | if (entryAssets.length > 1) {
26 | throw new Error(
27 | `Server-side bundle should have one single entry file. ` +
28 | `Avoid using CommonsChunkPlugin in the server config.`
29 | )
30 | }
31 |
32 | const entry = entryAssets[0]
33 | if (!entry || typeof entry !== 'string') {
34 | throw new Error(
35 | `Entry "${entryName}" not found. Did you specify the correct entry option?`
36 | )
37 | }
38 |
39 | const bundle = {
40 | entry,
41 | files: {},
42 | maps: {}
43 | }
44 |
45 | stats.assets.forEach(asset => {
46 | if (isJS(asset.name)) {
47 | bundle.files[asset.name] = compilation.assets[asset.name].source()
48 | } else if (asset.name.match(/\.js\.map$/)) {
49 | bundle.maps[asset.name.replace(/\.map$/, '')] = JSON.parse(compilation.assets[asset.name].source())
50 | }
51 | // do not emit anything else for server
52 | delete compilation.assets[asset.name]
53 | })
54 |
55 | const json = JSON.stringify(bundle, null, 2)
56 | const filename = this.options.filename
57 |
58 | compilation.assets[filename] = {
59 | source: () => json,
60 | size: () => json.length
61 | }
62 |
63 | cb()
64 | })
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | lerna-debug.log*
8 |
9 | # Diagnostic reports (https://nodejs.org/api/report.html)
10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11 |
12 | # Runtime data
13 | pids
14 | *.pid
15 | *.seed
16 | *.pid.lock
17 |
18 | # Directory for instrumented libs generated by jscoverage/JSCover
19 | lib-cov
20 |
21 | # Coverage directory used by tools like istanbul
22 | coverage
23 | *.lcov
24 |
25 | # nyc test coverage
26 | .nyc_output
27 |
28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29 | .grunt
30 |
31 | # Bower dependency directory (https://bower.io/)
32 | bower_components
33 |
34 | # node-waf configuration
35 | .lock-wscript
36 |
37 | # Compiled binary addons (https://nodejs.org/api/addons.html)
38 | build/Release
39 |
40 | # Dependency directories
41 | node_modules/
42 | jspm_packages/
43 |
44 | # TypeScript v1 declaration files
45 | typings/
46 |
47 | # TypeScript cache
48 | *.tsbuildinfo
49 |
50 | # Optional npm cache directory
51 | .npm
52 |
53 | # Optional eslint cache
54 | .eslintcache
55 |
56 | # Microbundle cache
57 | .rpt2_cache/
58 | .rts2_cache_cjs/
59 | .rts2_cache_es/
60 | .rts2_cache_umd/
61 |
62 | # Optional REPL history
63 | .node_repl_history
64 |
65 | # Output of 'npm pack'
66 | *.tgz
67 |
68 | # Yarn Integrity file
69 | .yarn-integrity
70 |
71 | # dotenv environment variables file
72 | .env
73 | .env.test
74 |
75 | # parcel-bundler cache (https://parceljs.org/)
76 | .cache
77 |
78 | # Next.js build output
79 | .next
80 |
81 | # Nuxt.js build / generate output
82 | .nuxt
83 | dist
84 |
85 | # Gatsby files
86 | .cache/
87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js
88 | # https://nextjs.org/blog/next-9-1#public-directory-support
89 | # public
90 |
91 | # vuepress build output
92 | .vuepress/dist
93 |
94 | # Serverless directories
95 | .serverless/
96 |
97 | # FuseBox cache
98 | .fusebox/
99 |
100 | # DynamoDB Local files
101 | .dynamodb/
102 |
103 | # TernJS port file
104 | .tern-port
105 |
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/src/platforms/web/util/attrs.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import { makeMap } from 'shared/util'
4 |
5 | // these are reserved for web because they are directly compiled away
6 | // during template compilation
7 | export const isReservedAttr = makeMap('style,class')
8 |
9 | // attributes that should be using props for binding
10 | const acceptValue = makeMap('input,textarea,option,select,progress')
11 | export const mustUseProp = (tag: string, type: ?string, attr: string): boolean => {
12 | return (
13 | (attr === 'value' && acceptValue(tag)) && type !== 'button' ||
14 | (attr === 'selected' && tag === 'option') ||
15 | (attr === 'checked' && tag === 'input') ||
16 | (attr === 'muted' && tag === 'video')
17 | )
18 | }
19 |
20 | export const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck')
21 |
22 | const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only')
23 |
24 | export const convertEnumeratedValue = (key: string, value: any) => {
25 | return isFalsyAttrValue(value) || value === 'false'
26 | ? 'false'
27 | // allow arbitrary string value for contenteditable
28 | : key === 'contenteditable' && isValidContentEditableValue(value)
29 | ? value
30 | : 'true'
31 | }
32 |
33 | export const isBooleanAttr = makeMap(
34 | 'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
35 | 'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
36 | 'enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,' +
37 | 'muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,' +
38 | 'required,reversed,scoped,seamless,selected,sortable,translate,' +
39 | 'truespeed,typemustmatch,visible'
40 | )
41 |
42 | export const xlinkNS = 'http://www.w3.org/1999/xlink'
43 |
44 | export const isXlink = (name: string): boolean => {
45 | return name.charAt(5) === ':' && name.slice(0, 5) === 'xlink'
46 | }
47 |
48 | export const getXlinkProp = (name: string): string => {
49 | return isXlink(name) ? name.slice(6, name.length) : ''
50 | }
51 |
52 | export const isFalsyAttrValue = (val: any): boolean => {
53 | return val == null || val === false
54 | }
55 |
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/src/core/vdom/helpers/extract-props.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import {
4 | tip,
5 | hasOwn,
6 | isDef,
7 | isUndef,
8 | hyphenate,
9 | formatComponentName
10 | } from 'core/util/index'
11 |
12 | export function extractPropsFromVNodeData (
13 | data: VNodeData,
14 | Ctor: Class,
15 | tag?: string
16 | ): ?Object {
17 | // we are only extracting raw values here.
18 | // validation and default values are handled in the child
19 | // component itself.
20 | const propOptions = Ctor.options.props
21 | if (isUndef(propOptions)) {
22 | return
23 | }
24 | const res = {}
25 | const { attrs, props } = data
26 | if (isDef(attrs) || isDef(props)) {
27 | for (const key in propOptions) {
28 | const altKey = hyphenate(key)
29 | if (process.env.NODE_ENV !== 'production') {
30 | const keyInLowerCase = key.toLowerCase()
31 | if (
32 | key !== keyInLowerCase &&
33 | attrs && hasOwn(attrs, keyInLowerCase)
34 | ) {
35 | tip(
36 | `Prop "${keyInLowerCase}" is passed to component ` +
37 | `${formatComponentName(tag || Ctor)}, but the declared prop name is` +
38 | ` "${key}". ` +
39 | `Note that HTML attributes are case-insensitive and camelCased ` +
40 | `props need to use their kebab-case equivalents when using in-DOM ` +
41 | `templates. You should probably use "${altKey}" instead of "${key}".`
42 | )
43 | }
44 | }
45 | checkProp(res, props, key, altKey, true) ||
46 | checkProp(res, attrs, key, altKey, false)
47 | }
48 | }
49 | return res
50 | }
51 |
52 | function checkProp (
53 | res: Object,
54 | hash: ?Object,
55 | key: string,
56 | altKey: string,
57 | preserve: boolean
58 | ): boolean {
59 | if (isDef(hash)) {
60 | if (hasOwn(hash, key)) {
61 | res[key] = hash[key]
62 | if (!preserve) {
63 | delete hash[key]
64 | }
65 | return true
66 | } else if (hasOwn(hash, altKey)) {
67 | res[key] = hash[altKey]
68 | if (!preserve) {
69 | delete hash[altKey]
70 | }
71 | return true
72 | }
73 | }
74 | return false
75 | }
76 |
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/src/platforms/web/util/style.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import { cached, extend, toObject } from 'shared/util'
4 |
5 | export const parseStyleText = cached(function (cssText) {
6 | const res = {}
7 | const listDelimiter = /;(?![^(]*\))/g
8 | const propertyDelimiter = /:(.+)/
9 | cssText.split(listDelimiter).forEach(function (item) {
10 | if (item) {
11 | const tmp = item.split(propertyDelimiter)
12 | tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim())
13 | }
14 | })
15 | return res
16 | })
17 |
18 | // merge static and dynamic style data on the same vnode
19 | function normalizeStyleData (data: VNodeData): ?Object {
20 | const style = normalizeStyleBinding(data.style)
21 | // static style is pre-processed into an object during compilation
22 | // and is always a fresh object, so it's safe to merge into it
23 | return data.staticStyle
24 | ? extend(data.staticStyle, style)
25 | : style
26 | }
27 |
28 | // normalize possible array / string values into Object
29 | export function normalizeStyleBinding (bindingStyle: any): ?Object {
30 | if (Array.isArray(bindingStyle)) {
31 | return toObject(bindingStyle)
32 | }
33 | if (typeof bindingStyle === 'string') {
34 | return parseStyleText(bindingStyle)
35 | }
36 | return bindingStyle
37 | }
38 |
39 | /**
40 | * parent component style should be after child's
41 | * so that parent component's style could override it
42 | */
43 | export function getStyle (vnode: VNodeWithData, checkChild: boolean): Object {
44 | const res = {}
45 | let styleData
46 |
47 | if (checkChild) {
48 | let childNode = vnode
49 | while (childNode.componentInstance) {
50 | childNode = childNode.componentInstance._vnode
51 | if (
52 | childNode && childNode.data &&
53 | (styleData = normalizeStyleData(childNode.data))
54 | ) {
55 | extend(res, styleData)
56 | }
57 | }
58 | }
59 |
60 | if ((styleData = normalizeStyleData(vnode.data))) {
61 | extend(res, styleData)
62 | }
63 |
64 | let parentNode = vnode
65 | while ((parentNode = parentNode.parent)) {
66 | if (parentNode.data && (styleData = normalizeStyleData(parentNode.data))) {
67 | extend(res, styleData)
68 | }
69 | }
70 | return res
71 | }
72 |
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/src/platforms/weex/compiler/modules/class.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import { parseText } from 'compiler/parser/text-parser'
4 | import {
5 | getAndRemoveAttr,
6 | getBindingAttr,
7 | baseWarn
8 | } from 'compiler/helpers'
9 |
10 | type StaticClassResult = {
11 | dynamic: boolean,
12 | classResult: string
13 | };
14 |
15 | function transformNode (el: ASTElement, options: CompilerOptions) {
16 | const warn = options.warn || baseWarn
17 | const staticClass = getAndRemoveAttr(el, 'class')
18 | const { dynamic, classResult } = parseStaticClass(staticClass, options)
19 | if (process.env.NODE_ENV !== 'production' && dynamic && staticClass) {
20 | warn(
21 | `class="${staticClass}": ` +
22 | 'Interpolation inside attributes has been deprecated. ' +
23 | 'Use v-bind or the colon shorthand instead.',
24 | el.rawAttrsMap['class']
25 | )
26 | }
27 | if (!dynamic && classResult) {
28 | el.staticClass = classResult
29 | }
30 | const classBinding = getBindingAttr(el, 'class', false /* getStatic */)
31 | if (classBinding) {
32 | el.classBinding = classBinding
33 | } else if (dynamic) {
34 | el.classBinding = classResult
35 | }
36 | }
37 |
38 | function genData (el: ASTElement): string {
39 | let data = ''
40 | if (el.staticClass) {
41 | data += `staticClass:${el.staticClass},`
42 | }
43 | if (el.classBinding) {
44 | data += `class:${el.classBinding},`
45 | }
46 | return data
47 | }
48 |
49 | function parseStaticClass (staticClass: ?string, options: CompilerOptions): StaticClassResult {
50 | // "a b c" -> ["a", "b", "c"] => staticClass: ["a", "b", "c"]
51 | // "a {{x}} c" -> ["a", x, "c"] => classBinding: '["a", x, "c"]'
52 | let dynamic = false
53 | let classResult = ''
54 | if (staticClass) {
55 | const classList = staticClass.trim().split(' ').map(name => {
56 | const result = parseText(name, options.delimiters)
57 | if (result) {
58 | dynamic = true
59 | return result.expression
60 | }
61 | return JSON.stringify(name)
62 | })
63 | if (classList.length) {
64 | classResult = '[' + classList.join(',') + ']'
65 | }
66 | }
67 | return { dynamic, classResult }
68 | }
69 |
70 | export default {
71 | staticKeys: ['staticClass'],
72 | transformNode,
73 | genData
74 | }
75 |
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/src/server/template-renderer/template-stream.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | const Transform = require('stream').Transform
4 | import type TemplateRenderer from './index'
5 | import type { ParsedTemplate } from './parse-template'
6 |
7 | export default class TemplateStream extends Transform {
8 | started: boolean;
9 | renderer: TemplateRenderer;
10 | template: ParsedTemplate;
11 | context: Object;
12 | inject: boolean;
13 |
14 | constructor (
15 | renderer: TemplateRenderer,
16 | template: ParsedTemplate,
17 | context: Object
18 | ) {
19 | super()
20 | this.started = false
21 | this.renderer = renderer
22 | this.template = template
23 | this.context = context || {}
24 | this.inject = renderer.inject
25 | }
26 |
27 | _transform (data: Buffer | string, encoding: string, done: Function) {
28 | if (!this.started) {
29 | this.emit('beforeStart')
30 | this.start()
31 | }
32 | this.push(data)
33 | done()
34 | }
35 |
36 | start () {
37 | this.started = true
38 | this.push(this.template.head(this.context))
39 |
40 | if (this.inject) {
41 | // inline server-rendered head meta information
42 | if (this.context.head) {
43 | this.push(this.context.head)
44 | }
45 |
46 | // inline preload/prefetch directives for initial/async chunks
47 | const links = this.renderer.renderResourceHints(this.context)
48 | if (links) {
49 | this.push(links)
50 | }
51 |
52 | // CSS files and inline server-rendered CSS collected by vue-style-loader
53 | const styles = this.renderer.renderStyles(this.context)
54 | if (styles) {
55 | this.push(styles)
56 | }
57 | }
58 |
59 | this.push(this.template.neck(this.context))
60 | }
61 |
62 | _flush (done: Function) {
63 | this.emit('beforeEnd')
64 |
65 | if (this.inject) {
66 | // inline initial store state
67 | const state = this.renderer.renderState(this.context)
68 | if (state) {
69 | this.push(state)
70 | }
71 |
72 | // embed scripts needed
73 | const scripts = this.renderer.renderScripts(this.context)
74 | if (scripts) {
75 | this.push(scripts)
76 | }
77 | }
78 |
79 | this.push(this.template.tail(this.context))
80 | done()
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/types/umd.d.ts:
--------------------------------------------------------------------------------
1 | import * as V from "./index";
2 | import {
3 | DefaultData,
4 | DefaultProps,
5 | DefaultMethods,
6 | DefaultComputed,
7 | PropsDefinition
8 | } from "./options";
9 |
10 | // Expose some types for backword compatibility...
11 | declare namespace Vue {
12 | // vue.d.ts
13 | export type CreateElement = V.CreateElement;
14 | export type VueConstructor = V.VueConstructor;
15 |
16 | // options.d.ts
17 | export type Component, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = V.Component;
18 | export type AsyncComponent, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = V.AsyncComponent;
19 | export type ComponentOptions, Methods=DefaultMethods, Computed=DefaultComputed, PropsDef=PropsDefinition, Props=DefaultProps> = V.ComponentOptions;
20 | export type FunctionalComponentOptions> = V.FunctionalComponentOptions;
21 | export type RenderContext = V.RenderContext;
22 | export type PropType = V.PropType;
23 | export type PropOptions = V.PropOptions;
24 | export type ComputedOptions = V.ComputedOptions;
25 | export type WatchHandler = V.WatchHandler;
26 | export type WatchOptions = V.WatchOptions;
27 | export type WatchOptionsWithHandler = V.WatchOptionsWithHandler;
28 | export type DirectiveFunction = V.DirectiveFunction;
29 | export type DirectiveOptions = V.DirectiveOptions;
30 |
31 | // plugin.d.ts
32 | export type PluginFunction = V.PluginFunction;
33 | export type PluginObject = V.PluginObject;
34 |
35 | // vnode.d.ts
36 | export type VNodeChildren = V.VNodeChildren;
37 | export type VNodeChildrenArrayContents = V.VNodeChildrenArrayContents;
38 | export type VNode = V.VNode;
39 | export type VNodeComponentOptions = V.VNodeComponentOptions;
40 | export type VNodeData = V.VNodeData;
41 | export type VNodeDirective = V.VNodeDirective;
42 | }
43 |
44 | declare class Vue extends V.default {}
45 |
46 | export = Vue;
47 |
48 | export as namespace Vue;
49 |
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/src/platforms/weex/compiler/modules/recycle-list/v-if.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import { addIfCondition } from 'compiler/parser/index'
4 | import { getAndRemoveAttr, addRawAttr } from 'compiler/helpers'
5 |
6 | function hasConditionDirective (el: ASTElement): boolean {
7 | for (const attr in el.attrsMap) {
8 | if (/^v\-if|v\-else|v\-else\-if$/.test(attr)) {
9 | return true
10 | }
11 | }
12 | return false
13 | }
14 |
15 | function getPreviousConditions (el: ASTElement): Array {
16 | const conditions = []
17 | if (el.parent && el.parent.children) {
18 | for (let c = 0, n = el.parent.children.length; c < n; ++c) {
19 | // $flow-disable-line
20 | const ifConditions = el.parent.children[c].ifConditions
21 | if (ifConditions) {
22 | for (let i = 0, l = ifConditions.length; i < l; ++i) {
23 | const condition = ifConditions[i]
24 | if (condition && condition.exp) {
25 | conditions.push(condition.exp)
26 | }
27 | }
28 | }
29 | }
30 | }
31 | return conditions
32 | }
33 |
34 | export function preTransformVIf (el: ASTElement, options: WeexCompilerOptions) {
35 | if (hasConditionDirective(el)) {
36 | let exp
37 | const ifExp = getAndRemoveAttr(el, 'v-if', true /* remove from attrsMap */)
38 | const elseifExp = getAndRemoveAttr(el, 'v-else-if', true)
39 | // don't need the value, but remove it to avoid being generated as a
40 | // custom directive
41 | getAndRemoveAttr(el, 'v-else', true)
42 | if (ifExp) {
43 | exp = ifExp
44 | addIfCondition(el, { exp: ifExp, block: el })
45 | } else {
46 | elseifExp && addIfCondition(el, { exp: elseifExp, block: el })
47 | const prevConditions = getPreviousConditions(el)
48 | if (prevConditions.length) {
49 | const prevMatch = prevConditions.join(' || ')
50 | exp = elseifExp
51 | ? `!(${prevMatch}) && (${elseifExp})` // v-else-if
52 | : `!(${prevMatch})` // v-else
53 | } else if (process.env.NODE_ENV !== 'production' && options.warn) {
54 | options.warn(
55 | `v-${elseifExp ? ('else-if="' + elseifExp + '"') : 'else'} ` +
56 | `used on element <${el.tag}> without corresponding v-if.`
57 | )
58 | return
59 | }
60 | }
61 | addRawAttr(el, '[[match]]', exp)
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/docs/.vuepress/theme/components/MainCard.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
16 |
{{item.subtitle}}
17 |
{{item.des}}
18 |
19 |
20 |
21 |
22 |
23 |
24 |
42 |
43 |
92 |
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/src/platforms/web/util/class.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import { isDef, isObject } from 'shared/util'
4 |
5 | export function genClassForVnode (vnode: VNodeWithData): string {
6 | let data = vnode.data
7 | let parentNode = vnode
8 | let childNode = vnode
9 | while (isDef(childNode.componentInstance)) {
10 | childNode = childNode.componentInstance._vnode
11 | if (childNode && childNode.data) {
12 | data = mergeClassData(childNode.data, data)
13 | }
14 | }
15 | while (isDef(parentNode = parentNode.parent)) {
16 | if (parentNode && parentNode.data) {
17 | data = mergeClassData(data, parentNode.data)
18 | }
19 | }
20 | return renderClass(data.staticClass, data.class)
21 | }
22 |
23 | function mergeClassData (child: VNodeData, parent: VNodeData): {
24 | staticClass: string,
25 | class: any
26 | } {
27 | return {
28 | staticClass: concat(child.staticClass, parent.staticClass),
29 | class: isDef(child.class)
30 | ? [child.class, parent.class]
31 | : parent.class
32 | }
33 | }
34 |
35 | export function renderClass (
36 | staticClass: ?string,
37 | dynamicClass: any
38 | ): string {
39 | if (isDef(staticClass) || isDef(dynamicClass)) {
40 | return concat(staticClass, stringifyClass(dynamicClass))
41 | }
42 | /* istanbul ignore next */
43 | return ''
44 | }
45 |
46 | export function concat (a: ?string, b: ?string): string {
47 | return a ? b ? (a + ' ' + b) : a : (b || '')
48 | }
49 |
50 | export function stringifyClass (value: any): string {
51 | if (Array.isArray(value)) {
52 | return stringifyArray(value)
53 | }
54 | if (isObject(value)) {
55 | return stringifyObject(value)
56 | }
57 | if (typeof value === 'string') {
58 | return value
59 | }
60 | /* istanbul ignore next */
61 | return ''
62 | }
63 |
64 | function stringifyArray (value: Array): string {
65 | let res = ''
66 | let stringified
67 | for (let i = 0, l = value.length; i < l; i++) {
68 | if (isDef(stringified = stringifyClass(value[i])) && stringified !== '') {
69 | if (res) res += ' '
70 | res += stringified
71 | }
72 | }
73 | return res
74 | }
75 |
76 | function stringifyObject (value: Object): string {
77 | let res = ''
78 | for (const key in value) {
79 | if (value[key]) {
80 | if (res) res += ' '
81 | res += key
82 | }
83 | }
84 | return res
85 | }
86 |
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/src/platforms/weex/runtime/components/richtext.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | function getVNodeType (vnode: VNode): string {
4 | if (!vnode.tag) {
5 | return ''
6 | }
7 | return vnode.tag.replace(/vue\-component\-(\d+\-)?/, '')
8 | }
9 |
10 | function isSimpleSpan (vnode: VNode): boolean {
11 | return vnode.children &&
12 | vnode.children.length === 1 &&
13 | !vnode.children[0].tag
14 | }
15 |
16 | function parseStyle (vnode: VNode): Object | void {
17 | if (!vnode || !vnode.data) {
18 | return
19 | }
20 | const { staticStyle, staticClass } = vnode.data
21 | if (vnode.data.style || vnode.data.class || staticStyle || staticClass) {
22 | const styles = Object.assign({}, staticStyle, vnode.data.style)
23 | const cssMap = vnode.context.$options.style || {}
24 | const classList = [].concat(staticClass, vnode.data.class)
25 | classList.forEach(name => {
26 | if (name && cssMap[name]) {
27 | Object.assign(styles, cssMap[name])
28 | }
29 | })
30 | return styles
31 | }
32 | }
33 |
34 | function convertVNodeChildren (children: Array): Array | void {
35 | if (!children.length) {
36 | return
37 | }
38 |
39 | return children.map(vnode => {
40 | const type: string = getVNodeType(vnode)
41 | const props: Object = { type }
42 |
43 | // convert raw text node
44 | if (!type) {
45 | props.type = 'span'
46 | props.attr = {
47 | value: (vnode.text || '').trim()
48 | }
49 | } else {
50 | props.style = parseStyle(vnode)
51 | if (vnode.data) {
52 | props.attr = vnode.data.attrs
53 | if (vnode.data.on) {
54 | props.events = vnode.data.on
55 | }
56 | }
57 | if (type === 'span' && isSimpleSpan(vnode)) {
58 | props.attr = props.attr || {}
59 | props.attr.value = vnode.children[0].text.trim()
60 | return props
61 | }
62 | }
63 |
64 | if (vnode.children && vnode.children.length) {
65 | props.children = convertVNodeChildren(vnode.children)
66 | }
67 |
68 | return props
69 | })
70 | }
71 |
72 | export default {
73 | name: 'richtext',
74 | render (h: Function) {
75 | return h('weex:richtext', {
76 | on: this._events,
77 | attrs: {
78 | value: convertVNodeChildren(this.$options._renderChildren || [])
79 | }
80 | })
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/docs/vue/vue-2.6.0/src/platforms/weex/runtime/modules/class.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import { extend, isObject } from 'shared/util'
4 |
5 | function updateClass (oldVnode: VNodeWithData, vnode: VNodeWithData) {
6 | const el = vnode.elm
7 | const ctx = vnode.context
8 |
9 | const data: VNodeData = vnode.data
10 | const oldData: VNodeData = oldVnode.data
11 | if (!data.staticClass &&
12 | !data.class &&
13 | (!oldData || (!oldData.staticClass && !oldData.class))
14 | ) {
15 | return
16 | }
17 |
18 | const oldClassList = makeClassList(oldData)
19 | const classList = makeClassList(data)
20 |
21 | if (typeof el.setClassList === 'function') {
22 | el.setClassList(classList)
23 | } else {
24 | const style = getStyle(oldClassList, classList, ctx)
25 | if (typeof el.setStyles === 'function') {
26 | el.setStyles(style)
27 | } else {
28 | for (const key in style) {
29 | el.setStyle(key, style[key])
30 | }
31 | }
32 | }
33 | }
34 |
35 | function makeClassList (data: VNodeData): Array {
36 | const classList = []
37 | // unlike web, weex vnode staticClass is an Array
38 | const staticClass: any = data.staticClass
39 | const dataClass = data.class
40 | if (staticClass) {
41 | classList.push.apply(classList, staticClass)
42 | }
43 | if (Array.isArray(dataClass)) {
44 | classList.push.apply(classList, dataClass)
45 | } else if (isObject(dataClass)) {
46 | classList.push.apply(classList, Object.keys(dataClass).filter(className => dataClass[className]))
47 | } else if (typeof dataClass === 'string') {
48 | classList.push.apply(classList, dataClass.trim().split(/\s+/))
49 | }
50 | return classList
51 | }
52 |
53 | function getStyle (oldClassList: Array, classList: Array, ctx: Component): Object {
54 | // style is a weex-only injected object
55 | // compiled from