@nest-vue/vue-security-patched 2.7.16-patch.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +122 -0
  3. package/compiler-sfc/index.d.ts +1 -0
  4. package/compiler-sfc/index.js +1 -0
  5. package/compiler-sfc/index.mjs +1 -0
  6. package/compiler-sfc/package.json +5 -0
  7. package/dist/vue.common.js +5 -0
  8. package/dist/vue.runtime.common.js +5 -0
  9. package/dist/vue.runtime.mjs +76 -0
  10. package/package.json +136 -0
  11. package/packages/compiler-sfc/api-extractor.json +64 -0
  12. package/packages/compiler-sfc/dist/compiler-sfc.js +17146 -0
  13. package/packages/compiler-sfc/node_modules/.bin/lessc +17 -0
  14. package/packages/compiler-sfc/node_modules/.bin/parser +17 -0
  15. package/packages/compiler-sfc/node_modules/.bin/prettier +17 -0
  16. package/packages/compiler-sfc/node_modules/.bin/sass +17 -0
  17. package/packages/compiler-sfc/node_modules/.bin/stylus +17 -0
  18. package/packages/compiler-sfc/package.json +37 -0
  19. package/packages/compiler-sfc/src/babelUtils.ts +423 -0
  20. package/packages/compiler-sfc/src/compileScript.ts +1916 -0
  21. package/packages/compiler-sfc/src/compileStyle.ts +147 -0
  22. package/packages/compiler-sfc/src/compileTemplate.ts +205 -0
  23. package/packages/compiler-sfc/src/cssVars.ts +179 -0
  24. package/packages/compiler-sfc/src/index.ts +31 -0
  25. package/packages/compiler-sfc/src/parse.ts +129 -0
  26. package/packages/compiler-sfc/src/parseComponent.ts +220 -0
  27. package/packages/compiler-sfc/src/prefixIdentifiers.ts +82 -0
  28. package/packages/compiler-sfc/src/rewriteDefault.ts +121 -0
  29. package/packages/compiler-sfc/src/stylePlugins/scoped.ts +203 -0
  30. package/packages/compiler-sfc/src/stylePlugins/trim.ts +18 -0
  31. package/packages/compiler-sfc/src/stylePreprocessors.ts +135 -0
  32. package/packages/compiler-sfc/src/templateCompilerModules/assetUrl.ts +84 -0
  33. package/packages/compiler-sfc/src/templateCompilerModules/srcset.ts +76 -0
  34. package/packages/compiler-sfc/src/templateCompilerModules/utils.ts +86 -0
  35. package/packages/compiler-sfc/src/types.ts +69 -0
  36. package/packages/compiler-sfc/src/warn.ts +16 -0
  37. package/packages/compiler-sfc/test/__snapshots__/compileScript.spec.ts.snap +971 -0
  38. package/packages/compiler-sfc/test/__snapshots__/cssVars.spec.ts.snap +189 -0
  39. package/packages/compiler-sfc/test/compileScript.spec.ts +1635 -0
  40. package/packages/compiler-sfc/test/compileStyle.spec.ts +203 -0
  41. package/packages/compiler-sfc/test/compileTemplate.spec.ts +258 -0
  42. package/packages/compiler-sfc/test/cssVars.spec.ts +247 -0
  43. package/packages/compiler-sfc/test/parseComponent.spec.ts +269 -0
  44. package/packages/compiler-sfc/test/prefixIdentifiers.spec.ts +97 -0
  45. package/packages/compiler-sfc/test/rewriteDefault.spec.ts +311 -0
  46. package/packages/compiler-sfc/test/stylePluginScoped.spec.ts +137 -0
  47. package/packages/compiler-sfc/test/tsconfig.json +7 -0
  48. package/packages/compiler-sfc/test/util.ts +35 -0
  49. package/src/compiler/codeframe.ts +52 -0
  50. package/src/compiler/codegen/events.ts +170 -0
  51. package/src/compiler/codegen/index.ts +668 -0
  52. package/src/compiler/create-compiler.ts +83 -0
  53. package/src/compiler/directives/bind.ts +9 -0
  54. package/src/compiler/directives/index.ts +9 -0
  55. package/src/compiler/directives/model.ts +145 -0
  56. package/src/compiler/directives/on.ts +9 -0
  57. package/src/compiler/error-detector.ts +158 -0
  58. package/src/compiler/helpers.ts +243 -0
  59. package/src/compiler/index.ts +24 -0
  60. package/src/compiler/optimizer.ts +135 -0
  61. package/src/compiler/parser/entity-decoder.ts +9 -0
  62. package/src/compiler/parser/filter-parser.ts +116 -0
  63. package/src/compiler/parser/html-parser.ts +345 -0
  64. package/src/compiler/parser/index.ts +999 -0
  65. package/src/compiler/parser/text-parser.ts +52 -0
  66. package/src/compiler/to-function.ts +119 -0
  67. package/src/core/components/index.ts +5 -0
  68. package/src/core/components/keep-alive.ts +171 -0
  69. package/src/core/config.ts +128 -0
  70. package/src/core/global-api/assets.ts +35 -0
  71. package/src/core/global-api/extend.ts +94 -0
  72. package/src/core/global-api/index.ts +68 -0
  73. package/src/core/global-api/mixin.ts +9 -0
  74. package/src/core/global-api/use.ts +23 -0
  75. package/src/core/index.ts +27 -0
  76. package/src/core/instance/events.ts +160 -0
  77. package/src/core/instance/index.ts +27 -0
  78. package/src/core/instance/init.ts +143 -0
  79. package/src/core/instance/inject.ts +80 -0
  80. package/src/core/instance/lifecycle.ts +421 -0
  81. package/src/core/instance/proxy.ts +97 -0
  82. package/src/core/instance/render-helpers/bind-dynamic-keys.ts +36 -0
  83. package/src/core/instance/render-helpers/bind-object-listeners.ts +18 -0
  84. package/src/core/instance/render-helpers/bind-object-props.ts +59 -0
  85. package/src/core/instance/render-helpers/check-keycodes.ts +33 -0
  86. package/src/core/instance/render-helpers/index.ts +31 -0
  87. package/src/core/instance/render-helpers/render-list.ts +49 -0
  88. package/src/core/instance/render-helpers/render-slot.ts +39 -0
  89. package/src/core/instance/render-helpers/render-static.ts +57 -0
  90. package/src/core/instance/render-helpers/resolve-filter.ts +8 -0
  91. package/src/core/instance/render-helpers/resolve-scoped-slots.ts +30 -0
  92. package/src/core/instance/render-helpers/resolve-slots.ts +51 -0
  93. package/src/core/instance/render.ts +172 -0
  94. package/src/core/instance/state.ts +393 -0
  95. package/src/core/observer/array.ts +54 -0
  96. package/src/core/observer/dep.ts +108 -0
  97. package/src/core/observer/index.ts +339 -0
  98. package/src/core/observer/scheduler.ts +199 -0
  99. package/src/core/observer/traverse.ts +47 -0
  100. package/src/core/observer/watcher.ts +278 -0
  101. package/src/core/util/debug.ts +105 -0
  102. package/src/core/util/env.ts +93 -0
  103. package/src/core/util/error.ts +81 -0
  104. package/src/core/util/index.ts +9 -0
  105. package/src/core/util/lang.ts +45 -0
  106. package/src/core/util/next-tick.ts +117 -0
  107. package/src/core/util/options.ts +489 -0
  108. package/src/core/util/perf.ts +28 -0
  109. package/src/core/util/props.ts +254 -0
  110. package/src/core/vdom/create-component.ts +275 -0
  111. package/src/core/vdom/create-element.ts +172 -0
  112. package/src/core/vdom/create-functional-component.ts +180 -0
  113. package/src/core/vdom/helpers/extract-props.ts +75 -0
  114. package/src/core/vdom/helpers/get-first-component-child.ts +16 -0
  115. package/src/core/vdom/helpers/index.ts +7 -0
  116. package/src/core/vdom/helpers/is-async-placeholder.ts +6 -0
  117. package/src/core/vdom/helpers/merge-hook.ts +40 -0
  118. package/src/core/vdom/helpers/normalize-children.ts +99 -0
  119. package/src/core/vdom/helpers/normalize-scoped-slots.ts +97 -0
  120. package/src/core/vdom/helpers/resolve-async-component.ts +157 -0
  121. package/src/core/vdom/helpers/update-listeners.ts +101 -0
  122. package/src/core/vdom/modules/directives.ts +137 -0
  123. package/src/core/vdom/modules/index.ts +4 -0
  124. package/src/core/vdom/modules/template-ref.ts +94 -0
  125. package/src/core/vdom/patch.ts +907 -0
  126. package/src/core/vdom/vnode.ts +119 -0
  127. package/src/global.d.ts +17 -0
  128. package/src/platforms/web/compiler/directives/html.ts +8 -0
  129. package/src/platforms/web/compiler/directives/index.ts +9 -0
  130. package/src/platforms/web/compiler/directives/model.ts +181 -0
  131. package/src/platforms/web/compiler/directives/text.ts +8 -0
  132. package/src/platforms/web/compiler/index.ts +6 -0
  133. package/src/platforms/web/compiler/modules/class.ts +44 -0
  134. package/src/platforms/web/compiler/modules/index.ts +5 -0
  135. package/src/platforms/web/compiler/modules/model.ts +89 -0
  136. package/src/platforms/web/compiler/modules/style.ts +47 -0
  137. package/src/platforms/web/compiler/options.ts +25 -0
  138. package/src/platforms/web/compiler/util.ts +22 -0
  139. package/src/platforms/web/entry-compiler.ts +4 -0
  140. package/src/platforms/web/entry-runtime-esm.ts +5 -0
  141. package/src/platforms/web/entry-runtime-with-compiler-esm.ts +5 -0
  142. package/src/platforms/web/entry-runtime-with-compiler.ts +10 -0
  143. package/src/platforms/web/entry-runtime.ts +7 -0
  144. package/src/platforms/web/runtime/class-util.ts +61 -0
  145. package/src/platforms/web/runtime/components/index.ts +7 -0
  146. package/src/platforms/web/runtime/components/transition-group.ts +204 -0
  147. package/src/platforms/web/runtime/components/transition.ts +205 -0
  148. package/src/platforms/web/runtime/directives/index.ts +7 -0
  149. package/src/platforms/web/runtime/directives/model.ts +148 -0
  150. package/src/platforms/web/runtime/directives/show.ts +61 -0
  151. package/src/platforms/web/runtime/index.ts +75 -0
  152. package/src/platforms/web/runtime/modules/attrs.ts +115 -0
  153. package/src/platforms/web/runtime/modules/class.ts +37 -0
  154. package/src/platforms/web/runtime/modules/dom-props.ts +123 -0
  155. package/src/platforms/web/runtime/modules/events.ts +127 -0
  156. package/src/platforms/web/runtime/modules/index.ts +8 -0
  157. package/src/platforms/web/runtime/modules/style.ts +102 -0
  158. package/src/platforms/web/runtime/modules/transition.ts +341 -0
  159. package/src/platforms/web/runtime/node-ops.ts +66 -0
  160. package/src/platforms/web/runtime/patch.ts +10 -0
  161. package/src/platforms/web/runtime/transition-util.ts +215 -0
  162. package/src/platforms/web/runtime-with-compiler.ts +110 -0
  163. package/src/platforms/web/util/attrs.ts +58 -0
  164. package/src/platforms/web/util/class.ts +87 -0
  165. package/src/platforms/web/util/compat.ts +16 -0
  166. package/src/platforms/web/util/element.ts +76 -0
  167. package/src/platforms/web/util/index.ts +21 -0
  168. package/src/platforms/web/util/style.ts +71 -0
  169. package/src/shared/constants.ts +20 -0
  170. package/src/shared/util.ts +378 -0
  171. package/src/types/compiler.ts +207 -0
  172. package/src/types/component.ts +212 -0
  173. package/src/types/global-api.ts +37 -0
  174. package/src/types/modules.d.ts +15 -0
  175. package/src/types/options.ts +114 -0
  176. package/src/types/ssr.ts +27 -0
  177. package/src/types/utils.ts +3 -0
  178. package/src/types/vnode.ts +127 -0
  179. package/src/v3/apiAsyncComponent.ts +117 -0
  180. package/src/v3/apiInject.ts +71 -0
  181. package/src/v3/apiLifecycle.ts +68 -0
  182. package/src/v3/apiSetup.ts +246 -0
  183. package/src/v3/apiWatch.ts +353 -0
  184. package/src/v3/currentInstance.ts +23 -0
  185. package/src/v3/debug.ts +21 -0
  186. package/src/v3/h.ts +18 -0
  187. package/src/v3/index.ts +96 -0
  188. package/src/v3/reactivity/computed.ts +100 -0
  189. package/src/v3/reactivity/effect.ts +20 -0
  190. package/src/v3/reactivity/effectScope.ts +137 -0
  191. package/src/v3/reactivity/operations.ts +14 -0
  192. package/src/v3/reactivity/reactive.ts +137 -0
  193. package/src/v3/reactivity/readonly.ts +127 -0
  194. package/src/v3/reactivity/ref.ts +293 -0
  195. package/src/v3/sfc-helpers/useCssModule.ts +24 -0
  196. package/src/v3/sfc-helpers/useCssVars.ts +34 -0
  197. package/types/built-in-components.d.ts +63 -0
  198. package/types/common.d.ts +21 -0
  199. package/types/index.d.ts +81 -0
  200. package/types/jsx.d.ts +1353 -0
  201. package/types/options.d.ts +349 -0
  202. package/types/plugin.d.ts +8 -0
  203. package/types/umd.d.ts +68 -0
  204. package/types/v3-component-options.d.ts +252 -0
  205. package/types/v3-component-props.d.ts +99 -0
  206. package/types/v3-component-public-instance.d.ts +232 -0
  207. package/types/v3-define-async-component.d.ts +26 -0
  208. package/types/v3-define-component.d.ts +201 -0
  209. package/types/v3-directive.d.ts +29 -0
  210. package/types/v3-manual-apis.d.ts +10 -0
  211. package/types/v3-setup-context.d.ts +41 -0
  212. package/types/v3-setup-helpers.d.ts +154 -0
  213. package/types/vnode.d.ts +117 -0
  214. package/types/vue.d.ts +446 -0
@@ -0,0 +1,135 @@
1
+ import merge from 'merge-source-map'
2
+ import { RawSourceMap } from 'source-map'
3
+ import { isFunction } from 'shared/util'
4
+
5
+ export type StylePreprocessor = (
6
+ source: string,
7
+ map: RawSourceMap | undefined,
8
+ options: {
9
+ [key: string]: any
10
+ additionalData?: string | ((source: string, filename: string) => string)
11
+ filename: string
12
+ }
13
+ ) => StylePreprocessorResults
14
+
15
+ export interface StylePreprocessorResults {
16
+ code: string
17
+ map?: object
18
+ errors: Error[]
19
+ dependencies: string[]
20
+ }
21
+
22
+ // .scss/.sass processor
23
+ const scss: StylePreprocessor = (source, map, options) => {
24
+ const nodeSass = require('sass')
25
+ const finalOptions = {
26
+ ...options,
27
+ data: getSource(source, options.filename, options.additionalData),
28
+ file: options.filename,
29
+ outFile: options.filename,
30
+ sourceMap: !!map
31
+ }
32
+
33
+ try {
34
+ const result = nodeSass.renderSync(finalOptions)
35
+ const dependencies = result.stats.includedFiles
36
+ if (map) {
37
+ return {
38
+ code: result.css.toString(),
39
+ map: merge(map, JSON.parse(result.map.toString())),
40
+ errors: [],
41
+ dependencies
42
+ }
43
+ }
44
+
45
+ return { code: result.css.toString(), errors: [], dependencies }
46
+ } catch (e: any) {
47
+ return { code: '', errors: [e], dependencies: [] }
48
+ }
49
+ }
50
+
51
+ const sass: StylePreprocessor = (source, map, options) =>
52
+ scss(source, map, {
53
+ ...options,
54
+ indentedSyntax: true
55
+ })
56
+
57
+ // .less
58
+ const less: StylePreprocessor = (source, map, options) => {
59
+ const nodeLess = require('less')
60
+
61
+ let result: any
62
+ let error: Error | null = null
63
+ nodeLess.render(
64
+ getSource(source, options.filename, options.additionalData),
65
+ { ...options, syncImport: true },
66
+ (err: Error | null, output: any) => {
67
+ error = err
68
+ result = output
69
+ }
70
+ )
71
+
72
+ if (error) return { code: '', errors: [error], dependencies: [] }
73
+ const dependencies = result.imports
74
+ if (map) {
75
+ return {
76
+ code: result.css.toString(),
77
+ map: merge(map, result.map),
78
+ errors: [],
79
+ dependencies: dependencies
80
+ }
81
+ }
82
+
83
+ return {
84
+ code: result.css.toString(),
85
+ errors: [],
86
+ dependencies: dependencies
87
+ }
88
+ }
89
+
90
+ // .styl
91
+ const styl: StylePreprocessor = (source, map, options) => {
92
+ const nodeStylus = require('stylus')
93
+ try {
94
+ const ref = nodeStylus(source)
95
+ Object.keys(options).forEach(key => ref.set(key, options[key]))
96
+ if (map) ref.set('sourcemap', { inline: false, comment: false })
97
+
98
+ const result = ref.render()
99
+ const dependencies = ref.deps()
100
+ if (map) {
101
+ return {
102
+ code: result,
103
+ map: merge(map, ref.sourcemap),
104
+ errors: [],
105
+ dependencies
106
+ }
107
+ }
108
+
109
+ return { code: result, errors: [], dependencies }
110
+ } catch (e: any) {
111
+ return { code: '', errors: [e], dependencies: [] }
112
+ }
113
+ }
114
+
115
+ function getSource(
116
+ source: string,
117
+ filename: string,
118
+ additionalData?: string | ((source: string, filename: string) => string)
119
+ ) {
120
+ if (!additionalData) return source
121
+ if (isFunction(additionalData)) {
122
+ return additionalData(source, filename)
123
+ }
124
+ return additionalData + source
125
+ }
126
+
127
+ export type PreprocessLang = 'less' | 'sass' | 'scss' | 'styl' | 'stylus'
128
+
129
+ export const processors: Record<PreprocessLang, StylePreprocessor> = {
130
+ less,
131
+ sass,
132
+ scss,
133
+ styl,
134
+ stylus: styl
135
+ }
@@ -0,0 +1,84 @@
1
+ // vue compiler module for transforming `<tag>:<attribute>` to `require`
2
+
3
+ import { urlToRequire } from './utils'
4
+ import { ASTNode, ASTAttr } from 'types/compiler'
5
+
6
+ export interface AssetURLOptions {
7
+ [name: string]: string | string[]
8
+ }
9
+
10
+ export interface TransformAssetUrlsOptions {
11
+ /**
12
+ * If base is provided, instead of transforming relative asset urls into
13
+ * imports, they will be directly rewritten to absolute urls.
14
+ */
15
+ base?: string
16
+ /**
17
+ * If true, also processes absolute urls.
18
+ */
19
+ includeAbsolute?: boolean
20
+ }
21
+
22
+ const defaultOptions: AssetURLOptions = {
23
+ audio: 'src',
24
+ video: ['src', 'poster'],
25
+ source: 'src',
26
+ img: 'src',
27
+ image: ['xlink:href', 'href'],
28
+ use: ['xlink:href', 'href']
29
+ }
30
+
31
+ export default (
32
+ userOptions?: AssetURLOptions,
33
+ transformAssetUrlsOption?: TransformAssetUrlsOptions
34
+ ) => {
35
+ const options = userOptions
36
+ ? Object.assign({}, defaultOptions, userOptions)
37
+ : defaultOptions
38
+
39
+ return {
40
+ postTransformNode: (node: ASTNode) => {
41
+ transform(node, options, transformAssetUrlsOption)
42
+ }
43
+ }
44
+ }
45
+
46
+ function transform(
47
+ node: ASTNode,
48
+ options: AssetURLOptions,
49
+ transformAssetUrlsOption?: TransformAssetUrlsOptions
50
+ ) {
51
+ if (node.type !== 1 || !node.attrs) return
52
+ for (const tag in options) {
53
+ if (tag === '*' || node.tag === tag) {
54
+ const attributes = options[tag]
55
+ if (typeof attributes === 'string') {
56
+ node.attrs!.some(attr =>
57
+ rewrite(attr, attributes, transformAssetUrlsOption)
58
+ )
59
+ } else if (Array.isArray(attributes)) {
60
+ attributes.forEach(item =>
61
+ node.attrs!.some(attr =>
62
+ rewrite(attr, item, transformAssetUrlsOption)
63
+ )
64
+ )
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ function rewrite(
71
+ attr: ASTAttr,
72
+ name: string,
73
+ transformAssetUrlsOption?: TransformAssetUrlsOptions
74
+ ) {
75
+ if (attr.name === name) {
76
+ const value = attr.value
77
+ // only transform static URLs
78
+ if (value.charAt(0) === '"' && value.charAt(value.length - 1) === '"') {
79
+ attr.value = urlToRequire(value.slice(1, -1), transformAssetUrlsOption)
80
+ return true
81
+ }
82
+ }
83
+ return false
84
+ }
@@ -0,0 +1,76 @@
1
+ // vue compiler module for transforming `img:srcset` to a number of `require`s
2
+
3
+ import { urlToRequire } from './utils'
4
+ import { TransformAssetUrlsOptions } from './assetUrl'
5
+ import { ASTNode } from 'types/compiler'
6
+
7
+ interface ImageCandidate {
8
+ require: string
9
+ descriptor: string
10
+ }
11
+
12
+ export default (transformAssetUrlsOptions?: TransformAssetUrlsOptions) => ({
13
+ postTransformNode: (node: ASTNode) => {
14
+ transform(node, transformAssetUrlsOptions)
15
+ }
16
+ })
17
+
18
+ // http://w3c.github.io/html/semantics-embedded-content.html#ref-for-image-candidate-string-5
19
+ const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g
20
+
21
+ function transform(
22
+ node: ASTNode,
23
+ transformAssetUrlsOptions?: TransformAssetUrlsOptions
24
+ ) {
25
+ if (node.type !== 1 || !node.attrs) {
26
+ return
27
+ }
28
+
29
+ if (node.tag === 'img' || node.tag === 'source') {
30
+ node.attrs.forEach(attr => {
31
+ if (attr.name === 'srcset') {
32
+ // same logic as in transform-require.js
33
+ const value = attr.value
34
+ const isStatic =
35
+ value.charAt(0) === '"' && value.charAt(value.length - 1) === '"'
36
+ if (!isStatic) {
37
+ return
38
+ }
39
+
40
+ const imageCandidates: ImageCandidate[] = value
41
+ .slice(1, -1)
42
+ .split(',')
43
+ .map(s => {
44
+ // The attribute value arrives here with all whitespace, except
45
+ // normal spaces, represented by escape sequences
46
+ const [url, descriptor] = s
47
+ .replace(escapedSpaceCharacters, ' ')
48
+ .trim()
49
+ .split(' ', 2)
50
+ return {
51
+ require: urlToRequire(url, transformAssetUrlsOptions),
52
+ descriptor
53
+ }
54
+ })
55
+
56
+ // "require(url1)"
57
+ // "require(url1) 1x"
58
+ // "require(url1), require(url2)"
59
+ // "require(url1), require(url2) 2x"
60
+ // "require(url1) 1x, require(url2)"
61
+ // "require(url1) 1x, require(url2) 2x"
62
+ const code = imageCandidates
63
+ .map(
64
+ ({ require, descriptor }) =>
65
+ `${require} + "${descriptor ? ' ' + descriptor : ''}, " + `
66
+ )
67
+ .join('')
68
+ .slice(0, -6)
69
+ .concat('"')
70
+ .replace(/ \+ ""$/, '')
71
+
72
+ attr.value = code
73
+ }
74
+ })
75
+ }
76
+ }
@@ -0,0 +1,86 @@
1
+ import { TransformAssetUrlsOptions } from './assetUrl'
2
+ import { UrlWithStringQuery, parse as uriParse } from 'url'
3
+ import path from 'path'
4
+
5
+ export function urlToRequire(
6
+ url: string,
7
+ transformAssetUrlsOption: TransformAssetUrlsOptions = {}
8
+ ): string {
9
+ const returnValue = `"${url}"`
10
+ // same logic as in transform-require.js
11
+ const firstChar = url.charAt(0)
12
+ if (firstChar === '~') {
13
+ const secondChar = url.charAt(1)
14
+ url = url.slice(secondChar === '/' ? 2 : 1)
15
+ }
16
+
17
+ if (isExternalUrl(url) || isDataUrl(url) || firstChar === '#') {
18
+ return returnValue
19
+ }
20
+
21
+ const uriParts = parseUriParts(url)
22
+ if (transformAssetUrlsOption.base) {
23
+ // explicit base - directly rewrite the url into absolute url
24
+ // does not apply to absolute urls or urls that start with `@`
25
+ // since they are aliases
26
+ if (firstChar === '.' || firstChar === '~') {
27
+ // Allow for full hostnames provided in options.base
28
+ const base = parseUriParts(transformAssetUrlsOption.base)
29
+ const protocol = base.protocol || ''
30
+ const host = base.host ? protocol + '//' + base.host : ''
31
+ const basePath = base.path || '/'
32
+ // when packaged in the browser, path will be using the posix-
33
+ // only version provided by rollup-plugin-node-builtins.
34
+ return `"${host}${(path.posix || path).join(
35
+ basePath,
36
+ uriParts.path + (uriParts.hash || '')
37
+ )}"`
38
+ }
39
+ }
40
+
41
+ if (
42
+ transformAssetUrlsOption.includeAbsolute ||
43
+ firstChar === '.' ||
44
+ firstChar === '~' ||
45
+ firstChar === '@'
46
+ ) {
47
+ if (!uriParts.hash) {
48
+ return `require("${url}")`
49
+ } else {
50
+ // support uri fragment case by excluding it from
51
+ // the require and instead appending it as string;
52
+ // assuming that the path part is sufficient according to
53
+ // the above caseing(t.i. no protocol-auth-host parts expected)
54
+ return `require("${uriParts.path}") + "${uriParts.hash}"`
55
+ }
56
+ }
57
+ return returnValue
58
+ }
59
+
60
+ /**
61
+ * vuejs/component-compiler-utils#22 Support uri fragment in transformed require
62
+ * @param urlString an url as a string
63
+ */
64
+ function parseUriParts(urlString: string): UrlWithStringQuery {
65
+ // initialize return value
66
+ const returnValue: UrlWithStringQuery = uriParse('')
67
+ if (urlString) {
68
+ // A TypeError is thrown if urlString is not a string
69
+ // @see https://nodejs.org/api/url.html#url_url_parse_urlstring_parsequerystring_slashesdenotehost
70
+ if ('string' === typeof urlString) {
71
+ // check is an uri
72
+ return uriParse(urlString, false, true) // take apart the uri
73
+ }
74
+ }
75
+ return returnValue
76
+ }
77
+
78
+ const externalRE = /^(https?:)?\/\//
79
+ function isExternalUrl(url: string): boolean {
80
+ return externalRE.test(url)
81
+ }
82
+
83
+ const dataUrlRE = /^\s*data:/i
84
+ function isDataUrl(url: string): boolean {
85
+ return dataUrlRE.test(url)
86
+ }
@@ -0,0 +1,69 @@
1
+ import { CompilerOptions, CompiledResult } from 'types/compiler'
2
+ import { SFCDescriptor } from './parseComponent'
3
+
4
+ export interface StartOfSourceMap {
5
+ file?: string
6
+ sourceRoot?: string
7
+ }
8
+
9
+ export interface RawSourceMap extends StartOfSourceMap {
10
+ version: string
11
+ sources: string[]
12
+ names: string[]
13
+ sourcesContent?: string[]
14
+ mappings: string
15
+ }
16
+
17
+ export interface TemplateCompiler {
18
+ parseComponent(source: string, options?: any): SFCDescriptor
19
+ compile(template: string, options: CompilerOptions): CompiledResult
20
+ ssrCompile(template: string, options: CompilerOptions): CompiledResult
21
+ }
22
+
23
+ export const enum BindingTypes {
24
+ /**
25
+ * returned from data()
26
+ */
27
+ DATA = 'data',
28
+ /**
29
+ * declared as a prop
30
+ */
31
+ PROPS = 'props',
32
+ /**
33
+ * a local alias of a `<script setup>` destructured prop.
34
+ * the original is stored in __propsAliases of the bindingMetadata object.
35
+ */
36
+ PROPS_ALIASED = 'props-aliased',
37
+ /**
38
+ * a let binding (may or may not be a ref)
39
+ */
40
+ SETUP_LET = 'setup-let',
41
+ /**
42
+ * a const binding that can never be a ref.
43
+ * these bindings don't need `unref()` calls when processed in inlined
44
+ * template expressions.
45
+ */
46
+ SETUP_CONST = 'setup-const',
47
+ /**
48
+ * a const binding that does not need `unref()`, but may be mutated.
49
+ */
50
+ SETUP_REACTIVE_CONST = 'setup-reactive-const',
51
+ /**
52
+ * a const binding that may be a ref.
53
+ */
54
+ SETUP_MAYBE_REF = 'setup-maybe-ref',
55
+ /**
56
+ * bindings that are guaranteed to be refs
57
+ */
58
+ SETUP_REF = 'setup-ref',
59
+ /**
60
+ * declared by other options, e.g. computed, inject
61
+ */
62
+ OPTIONS = 'options'
63
+ }
64
+
65
+ export type BindingMetadata = {
66
+ [key: string]: BindingTypes | undefined
67
+ } & {
68
+ __isScriptSetup?: boolean
69
+ }
@@ -0,0 +1,16 @@
1
+ const hasWarned: Record<string, boolean> = {}
2
+
3
+ export function warnOnce(msg: string) {
4
+ const isNodeProd =
5
+ typeof process !== 'undefined' && process.env.NODE_ENV === 'production'
6
+ if (!isNodeProd && !hasWarned[msg]) {
7
+ hasWarned[msg] = true
8
+ warn(msg)
9
+ }
10
+ }
11
+
12
+ export function warn(msg: string) {
13
+ console.warn(
14
+ `\x1b[1m\x1b[33m[@vue/compiler-sfc]\x1b[0m\x1b[33m ${msg}\x1b[0m\n`
15
+ )
16
+ }