From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- .../lib/templateCompilerModules/assetUrl.ts.html | 222 +++++++++++++++++ .../lib/templateCompilerModules/index.html | 123 ++++++++++ .../lib/templateCompilerModules/srcset.ts.html | 267 +++++++++++++++++++++ .../lib/templateCompilerModules/utils.ts.html | 231 ++++++++++++++++++ 4 files changed, 843 insertions(+) create mode 100644 node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/assetUrl.ts.html create mode 100644 node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/index.html create mode 100644 node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/srcset.ts.html create mode 100644 node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/utils.ts.html (limited to 'node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules') diff --git a/node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/assetUrl.ts.html b/node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/assetUrl.ts.html new file mode 100644 index 00000000..31537c15 --- /dev/null +++ b/node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/assetUrl.ts.html @@ -0,0 +1,222 @@ + + + + Code coverage report for lib/templateCompilerModules/assetUrl.ts + + + + + + + +
+
+

+ All files / lib/templateCompilerModules assetUrl.ts +

+
+
+ 100% + Statements + 20/20 +
+
+ 88.24% + Branches + 15/17 +
+
+ 100% + Functions + 7/7 +
+
+ 100% + Lines + 17/17 +
+
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52  +  +  +  +  +  +  +  +1x +  +  +  +  +  +  +  +4x +  +  +  +4x +  +19x +  +  +  +  +  +19x +80x +14x +14x +13x +1x +2x +  +  +  +  +  +  +15x +14x +  +14x +14x +14x +  +  +1x +  + 
// vue compiler module for transforming `<tag>:<attribute>` to `require`
+ 
+import { urlToRequire, ASTNode, Attr } from './utils'
+ 
+export interface AssetURLOptions {
+  [name: string]: string | string[]
+}
+ 
+const defaultOptions: AssetURLOptions = {
+  video: ['src', 'poster'],
+  source: 'src',
+  img: 'src',
+  image: ['xlink:href', 'href']
+}
+ 
+export default (userOptions?: AssetURLOptions) => {
+  const options = userOptions
+    ? Object.assign({}, defaultOptions, userOptions)
+    : defaultOptions
+ 
+  return {
+    postTransformNode: (node: ASTNode) => {
+      transform(node, options)
+    }
+  }
+}
+ 
+function transform(node: ASTNode, options: AssetURLOptions) {
+  for (const tag in options) {
+    if ((tag === '*' || node.tag === tag) && node.attrs) {
+      const attributes = options[tag]
+      if (typeof attributes === 'string') {
+        node.attrs.some(attr => rewrite(attr, attributes))
+      } else Eif (Array.isArray(attributes)) {
+        attributes.forEach(item => node.attrs.some(attr => rewrite(attr, item)))
+      }
+    }
+  }
+}
+ 
+function rewrite(attr: Attr, name: string) {
+  if (attr.name === name) {
+    const value = attr.value
+    // only transform static URLs
+    Eif (value.charAt(0) === '"' && value.charAt(value.length - 1) === '"') {
+      attr.value = urlToRequire(value.slice(1, -1))
+      return true
+    }
+  }
+  return false
+}
+ 
+
+
+ + + + + + + + diff --git a/node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/index.html b/node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/index.html new file mode 100644 index 00000000..ba195dfd --- /dev/null +++ b/node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/index.html @@ -0,0 +1,123 @@ + + + + Code coverage report for lib/templateCompilerModules + + + + + + + +
+
+

+ All files lib/templateCompilerModules +

+
+
+ 96.23% + Statements + 51/53 +
+
+ 86.36% + Branches + 38/44 +
+
+ 100% + Functions + 15/15 +
+
+ 96% + Lines + 48/50 +
+
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
assetUrl.ts
100%20/2088.24%15/17100%7/7100%17/17
srcset.ts
94.12%16/1791.67%11/12100%6/694.12%16/17
utils.ts
93.75%15/1680%12/15100%2/293.75%15/16
+
+
+ + + + + + + + diff --git a/node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/srcset.ts.html b/node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/srcset.ts.html new file mode 100644 index 00000000..88febd8b --- /dev/null +++ b/node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/srcset.ts.html @@ -0,0 +1,267 @@ + + + + Code coverage report for lib/templateCompilerModules/srcset.ts + + + + + + + +
+
+

+ All files / lib/templateCompilerModules srcset.ts +

+
+
+ 94.12% + Statements + 16/17 +
+
+ 91.67% + Branches + 11/12 +
+
+ 100% + Functions + 6/6 +
+
+ 94.12% + Lines + 16/17 +
+
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67  +  +  +  +  +  +  +  +  +4x +  +19x +  +  +  +  +1x +  +  +19x +  +19x +11x +18x +  +7x +  +7x +7x +  +  +  +7x +  +  +  +  +  +13x +  +  +  +13x +  +  +  +  +  +  +  +  +7x +  +  +13x +  +  +  +  +  +  +7x +  +  +  +  + 
// vue compiler module for transforming `img:srcset` to a number of `require`s
+ 
+import { urlToRequire, ASTNode } from './utils'
+ 
+interface ImageCandidate {
+  require: string
+  descriptor: string
+}
+ 
+export default () => ({
+  postTransformNode: (node: ASTNode) => {
+    transform(node)
+  }
+})
+ 
+// http://w3c.github.io/html/semantics-embedded-content.html#ref-for-image-candidate-string-5
+const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g
+ 
+function transform(node: ASTNode) {
+  const tags = ['img', 'source']
+ 
+  if (tags.indexOf(node.tag) !== -1 && node.attrs) {
+    node.attrs.forEach(attr => {
+      if (attr.name === 'srcset') {
+        // same logic as in transform-require.js
+        const value = attr.value
+        const isStatic =
+          value.charAt(0) === '"' && value.charAt(value.length - 1) === '"'
+        Iif (!isStatic) {
+          return
+        }
+ 
+        const imageCandidates: ImageCandidate[] = value
+          .substr(1, value.length - 2)
+          .split(',')
+          .map(s => {
+            // The attribute value arrives here with all whitespace, except
+            // normal spaces, represented by escape sequences
+            const [url, descriptor] = s
+              .replace(escapedSpaceCharacters, ' ')
+              .trim()
+              .split(' ', 2)
+            return { require: urlToRequire(url), descriptor }
+          })
+ 
+        // "require(url1)"
+        // "require(url1) 1x"
+        // "require(url1), require(url2)"
+        // "require(url1), require(url2) 2x"
+        // "require(url1) 1x, require(url2)"
+        // "require(url1) 1x, require(url2) 2x"
+        const code = imageCandidates
+          .map(
+            ({ require, descriptor }) =>
+              `${require} + "${descriptor ? ' ' + descriptor : ''}, " + `
+          )
+          .join('')
+          .slice(0, -6)
+          .concat('"')
+          .replace(/ \+ ""$/, '')
+ 
+        attr.value = code
+      }
+    })
+  }
+}
+ 
+
+
+ + + + + + + + diff --git a/node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/utils.ts.html b/node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/utils.ts.html new file mode 100644 index 00000000..4ff7a3e1 --- /dev/null +++ b/node_modules/@vue/component-compiler-utils/coverage/lcov-report/lib/templateCompilerModules/utils.ts.html @@ -0,0 +1,231 @@ + + + + Code coverage report for lib/templateCompilerModules/utils.ts + + + + + + + +
+
+

+ All files / lib/templateCompilerModules utils.ts +

+
+
+ 93.75% + Statements + 15/16 +
+
+ 80% + Branches + 12/15 +
+
+ 100% + Functions + 2/2 +
+
+ 93.75% + Lines + 15/16 +
+
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+
+
+

+
+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55  +  +  +  +  +  +  +  +  +  +  +  +  +27x +  +27x +27x +27x +4x +4x +  +  +27x +  +27x +26x +  +  +  +  +  +1x +  +  +  +  +  +  +  +  +  +  +  +27x +27x +  +  +26x +  +26x +  +  +1x +  + 
export interface Attr {
+  name: string
+  value: string
+}
+ 
+export interface ASTNode {
+  tag: string
+  attrs: Attr[]
+}
+ 
+import { UrlWithStringQuery, parse as uriParse } from 'url'
+ 
+export function urlToRequire(url: string): string {
+  const returnValue = `"${url}"`
+  // same logic as in transform-require.js
+  const firstChar = url.charAt(0)
+  Eif (firstChar === '.' || firstChar === '~' || firstChar === '@') {
+    if (firstChar === '~') {
+      const secondChar = url.charAt(1)
+      url = url.slice(secondChar === '/' ? 2 : 1)
+    }
+ 
+    const uriParts = parseUriParts(url)
+ 
+    if (!uriParts.hash) {
+      return `require("${url}")`
+    } else {
+      // support uri fragment case by excluding it from
+      // the require and instead appending it as string;
+      // assuming that the path part is sufficient according to
+      // the above caseing(t.i. no protocol-auth-host parts expected)
+      return `require("${uriParts.path}") + "${uriParts.hash}"`
+    }
+  }
+  return returnValue
+}
+ 
+/**
+ * vuejs/component-compiler-utils#22 Support uri fragment in transformed require
+ * @param urlString an url as a string
+ */
+function parseUriParts(urlString: string): UrlWithStringQuery {
+  // initialize return value
+  const returnValue: UrlWithStringQuery = uriParse('')
+  if (urlString) {
+    // A TypeError is thrown if urlString is not a string
+    // @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
+    Eif ('string' === typeof urlString) {
+      // check is an uri
+      return uriParse(urlString) // take apart the uri
+    }
+  }
+  return returnValue
+}
+ 
+
+
+ + + + + + + + -- cgit v1.2.3