feat:node-modules
This commit is contained in:
50
node_modules/vue/src/compiler/codeframe.js
generated
vendored
Normal file
50
node_modules/vue/src/compiler/codeframe.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
/* @flow */
|
||||
|
||||
const range = 2
|
||||
|
||||
export function generateCodeFrame (
|
||||
source: string,
|
||||
start: number = 0,
|
||||
end: number = source.length
|
||||
): string {
|
||||
const lines = source.split(/\r?\n/)
|
||||
let count = 0
|
||||
const res = []
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
count += lines[i].length + 1
|
||||
if (count >= start) {
|
||||
for (let j = i - range; j <= i + range || end > count; j++) {
|
||||
if (j < 0 || j >= lines.length) continue
|
||||
res.push(`${j + 1}${repeat(` `, 3 - String(j + 1).length)}| ${lines[j]}`)
|
||||
const lineLength = lines[j].length
|
||||
if (j === i) {
|
||||
// push underline
|
||||
const pad = start - (count - lineLength) + 1
|
||||
const length = end > count ? lineLength - pad : end - start
|
||||
res.push(` | ` + repeat(` `, pad) + repeat(`^`, length))
|
||||
} else if (j > i) {
|
||||
if (end > count) {
|
||||
const length = Math.min(end - count, lineLength)
|
||||
res.push(` | ` + repeat(`^`, length))
|
||||
}
|
||||
count += lineLength + 1
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return res.join('\n')
|
||||
}
|
||||
|
||||
function repeat (str, n) {
|
||||
let result = ''
|
||||
if (n > 0) {
|
||||
while (true) { // eslint-disable-line
|
||||
if (n & 1) result += str
|
||||
n >>>= 1
|
||||
if (n <= 0) break
|
||||
str += str
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
190
node_modules/vue/src/compiler/codegen/events.js
generated
vendored
Normal file
190
node_modules/vue/src/compiler/codegen/events.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
619
node_modules/vue/src/compiler/codegen/index.js
generated
vendored
Normal file
619
node_modules/vue/src/compiler/codegen/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
75
node_modules/vue/src/compiler/create-compiler.js
generated
vendored
Normal file
75
node_modules/vue/src/compiler/create-compiler.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
/* @flow */
|
||||
|
||||
import { extend } from 'shared/util'
|
||||
import { detectErrors } from './error-detector'
|
||||
import { createCompileToFunctionFn } from './to-function'
|
||||
|
||||
export function createCompilerCreator (baseCompile: Function): Function {
|
||||
return function createCompiler (baseOptions: CompilerOptions) {
|
||||
function compile (
|
||||
template: string,
|
||||
options?: CompilerOptions
|
||||
): CompiledResult {
|
||||
const finalOptions = Object.create(baseOptions)
|
||||
const errors = []
|
||||
const tips = []
|
||||
|
||||
let warn = (msg, range, tip) => {
|
||||
(tip ? tips : errors).push(msg)
|
||||
}
|
||||
|
||||
if (options) {
|
||||
if (process.env.NODE_ENV !== 'production' && options.outputSourceRange) {
|
||||
// $flow-disable-line
|
||||
const leadingSpaceLength = template.match(/^\s*/)[0].length
|
||||
|
||||
warn = (msg, range, tip) => {
|
||||
const data: WarningMessage = { msg }
|
||||
if (range) {
|
||||
if (range.start != null) {
|
||||
data.start = range.start + leadingSpaceLength
|
||||
}
|
||||
if (range.end != null) {
|
||||
data.end = range.end + leadingSpaceLength
|
||||
}
|
||||
}
|
||||
(tip ? tips : errors).push(data)
|
||||
}
|
||||
}
|
||||
// merge custom modules
|
||||
if (options.modules) {
|
||||
finalOptions.modules =
|
||||
(baseOptions.modules || []).concat(options.modules)
|
||||
}
|
||||
// merge custom directives
|
||||
if (options.directives) {
|
||||
finalOptions.directives = extend(
|
||||
Object.create(baseOptions.directives || null),
|
||||
options.directives
|
||||
)
|
||||
}
|
||||
// copy other options
|
||||
for (const key in options) {
|
||||
if (key !== 'modules' && key !== 'directives') {
|
||||
finalOptions[key] = options[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
finalOptions.warn = warn
|
||||
|
||||
const compiled = baseCompile(template.trim(), finalOptions)
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
detectErrors(compiled.ast, warn)
|
||||
}
|
||||
compiled.errors = errors
|
||||
compiled.tips = tips
|
||||
return compiled
|
||||
}
|
||||
|
||||
return {
|
||||
compile,
|
||||
compileToFunctions: createCompileToFunctionFn(compile)
|
||||
}
|
||||
}
|
||||
}
|
||||
11
node_modules/vue/src/compiler/directives/bind.js
generated
vendored
Normal file
11
node_modules/vue/src/compiler/directives/bind.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/* @flow */
|
||||
|
||||
export default function bind (el: ASTElement, dir: ASTDirective) {
|
||||
el.wrapData = (code: string) => {
|
||||
return `_b(${code},'${el.tag}',${dir.value},${
|
||||
dir.modifiers && dir.modifiers.prop ? 'true' : 'false'
|
||||
}${
|
||||
dir.modifiers && dir.modifiers.sync ? ',true' : ''
|
||||
})`
|
||||
}
|
||||
}
|
||||
11
node_modules/vue/src/compiler/directives/index.js
generated
vendored
Normal file
11
node_modules/vue/src/compiler/directives/index.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
/* @flow */
|
||||
|
||||
import on from './on'
|
||||
import bind from './bind'
|
||||
import { noop } from 'shared/util'
|
||||
|
||||
export default {
|
||||
on,
|
||||
bind,
|
||||
cloak: noop
|
||||
}
|
||||
148
node_modules/vue/src/compiler/directives/model.js
generated
vendored
Normal file
148
node_modules/vue/src/compiler/directives/model.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
10
node_modules/vue/src/compiler/directives/on.js
generated
vendored
Normal file
10
node_modules/vue/src/compiler/directives/on.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/* @flow */
|
||||
|
||||
import { warn } from 'core/util/index'
|
||||
|
||||
export default function on (el: ASTElement, dir: ASTDirective) {
|
||||
if (process.env.NODE_ENV !== 'production' && dir.modifiers) {
|
||||
warn(`v-on without argument does not support modifiers.`)
|
||||
}
|
||||
el.wrapListeners = (code: string) => `_g(${code},${dir.value})`
|
||||
}
|
||||
128
node_modules/vue/src/compiler/error-detector.js
generated
vendored
Normal file
128
node_modules/vue/src/compiler/error-detector.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
231
node_modules/vue/src/compiler/helpers.js
generated
vendored
Normal file
231
node_modules/vue/src/compiler/helpers.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user