@dcloudio/uni-cli-shared 3.0.0-alpha-4070720250804001 → 3.0.0-alpha-4070620250731002

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 (163) hide show
  1. package/dist/easycom.d.ts +0 -1
  2. package/dist/easycom.js +13 -17
  3. package/dist/hbx/alias.js +10 -43
  4. package/dist/hbx/index.js +0 -10
  5. package/dist/hbx/log.js +1 -23
  6. package/dist/index.d.ts +1 -2
  7. package/dist/index.js +1 -3
  8. package/dist/json/index.d.ts +1 -1
  9. package/dist/json/index.js +1 -2
  10. package/dist/json/manifest.d.ts +0 -1
  11. package/dist/json/manifest.js +1 -11
  12. package/dist/json/mp/jsonFile.js +2 -4
  13. package/dist/json/mp/pages.js +0 -1
  14. package/dist/json/mp/types.d.ts +1 -4
  15. package/dist/json/uni-x/manifest.d.ts +0 -1
  16. package/dist/json/uni-x/manifest.js +1 -5
  17. package/dist/messages/zh_CN.js +0 -1
  18. package/dist/uni_modules.cloud.d.ts +4 -10
  19. package/dist/uni_modules.cloud.js +19 -58
  20. package/dist/uni_modules.d.ts +0 -2
  21. package/dist/uni_modules.js +2 -81
  22. package/dist/uts.js +0 -16
  23. package/dist/vite/autoImport.js +0 -2
  24. package/dist/vite/cloud.js +5 -51
  25. package/dist/vite/plugins/index.d.ts +0 -1
  26. package/dist/vite/plugins/index.js +1 -3
  27. package/dist/vite/plugins/inject.js +1 -3
  28. package/dist/vite/plugins/uts/uni_modules.d.ts +0 -1
  29. package/dist/vite/plugins/uts/uni_modules.js +14 -63
  30. package/dist/vite/plugins/uts/uvue.js +3 -17
  31. package/dist/vite/plugins/vitejs/plugins/css.js +5 -40
  32. package/dist/vue/transforms/transformUTSComponent.js +3 -8
  33. package/package.json +38 -38
  34. package/dist/vite/plugins/stats.d.ts +0 -2
  35. package/dist/vite/plugins/stats.js +0 -42
  36. package/dist/workers.d.ts +0 -14
  37. package/dist/workers.js +0 -187
  38. package/lib/vapor/@vitejs/plugin-vue/LICENSE +0 -21
  39. package/lib/vapor/@vitejs/plugin-vue/README.md +0 -278
  40. package/lib/vapor/@vitejs/plugin-vue/dist/index.cjs +0 -3105
  41. package/lib/vapor/@vitejs/plugin-vue/dist/index.d.cts +0 -113
  42. package/lib/vapor/@vitejs/plugin-vue/dist/index.d.mts +0 -111
  43. package/lib/vapor/@vitejs/plugin-vue/dist/index.d.ts +0 -113
  44. package/lib/vapor/@vitejs/plugin-vue/dist/index.mjs +0 -3090
  45. package/lib/vapor/@vitejs/plugin-vue/package.json +0 -50
  46. package/lib/vapor/@vue/compiler-core/LICENSE +0 -21
  47. package/lib/vapor/@vue/compiler-core/README.md +0 -1
  48. package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.js +0 -6902
  49. package/lib/vapor/@vue/compiler-core/dist/compiler-core.cjs.prod.js +0 -6779
  50. package/lib/vapor/@vue/compiler-core/dist/compiler-core.esm-bundler.js +0 -5870
  51. package/lib/vapor/@vue/compiler-core/index.js +0 -7
  52. package/lib/vapor/@vue/compiler-core/package.json +0 -58
  53. package/lib/vapor/@vue/compiler-dom/LICENSE +0 -21
  54. package/lib/vapor/@vue/compiler-dom/README.md +0 -1
  55. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.cjs.js +0 -936
  56. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +0 -856
  57. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-browser.js +0 -6682
  58. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-browser.prod.js +0 -14
  59. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.esm-bundler.js +0 -693
  60. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.global.js +0 -6855
  61. package/lib/vapor/@vue/compiler-dom/dist/compiler-dom.global.prod.js +0 -14
  62. package/lib/vapor/@vue/compiler-dom/index.js +0 -7
  63. package/lib/vapor/@vue/compiler-dom/package.json +0 -57
  64. package/lib/vapor/@vue/compiler-sfc/LICENSE +0 -21
  65. package/lib/vapor/@vue/compiler-sfc/README.md +0 -80
  66. package/lib/vapor/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +0 -21682
  67. package/lib/vapor/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js +0 -66272
  68. package/lib/vapor/@vue/compiler-sfc/package.json +0 -68
  69. package/lib/vapor/@vue/compiler-ssr/LICENSE +0 -21
  70. package/lib/vapor/@vue/compiler-ssr/README.md +0 -1
  71. package/lib/vapor/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +0 -1402
  72. package/lib/vapor/@vue/compiler-ssr/package.json +0 -34
  73. package/lib/vapor/@vue/compiler-vapor/LICENSE +0 -21
  74. package/lib/vapor/@vue/compiler-vapor/README.md +0 -1
  75. package/lib/vapor/@vue/compiler-vapor/dist/compiler-vapor.cjs.js +0 -4540
  76. package/lib/vapor/@vue/compiler-vapor/dist/compiler-vapor.esm-browser.js +0 -37020
  77. package/lib/vapor/@vue/compiler-vapor/package.json +0 -49
  78. package/lib/vapor/@vue/reactivity/LICENSE +0 -21
  79. package/lib/vapor/@vue/reactivity/README.md +0 -19
  80. package/lib/vapor/@vue/reactivity/dist/reactivity.cjs.js +0 -2033
  81. package/lib/vapor/@vue/reactivity/dist/reactivity.cjs.prod.js +0 -1841
  82. package/lib/vapor/@vue/reactivity/dist/reactivity.esm-browser.js +0 -2023
  83. package/lib/vapor/@vue/reactivity/dist/reactivity.esm-browser.prod.js +0 -5
  84. package/lib/vapor/@vue/reactivity/dist/reactivity.esm-bundler.js +0 -1992
  85. package/lib/vapor/@vue/reactivity/dist/reactivity.global.js +0 -2082
  86. package/lib/vapor/@vue/reactivity/dist/reactivity.global.prod.js +0 -5
  87. package/lib/vapor/@vue/reactivity/index.js +0 -7
  88. package/lib/vapor/@vue/reactivity/package.json +0 -55
  89. package/lib/vapor/@vue/runtime-core/LICENSE +0 -21
  90. package/lib/vapor/@vue/runtime-core/README.md +0 -28
  91. package/lib/vapor/@vue/runtime-core/dist/runtime-core.cjs.js +0 -8972
  92. package/lib/vapor/@vue/runtime-core/dist/runtime-core.cjs.prod.js +0 -7088
  93. package/lib/vapor/@vue/runtime-core/dist/runtime-core.esm-bundler.js +0 -8913
  94. package/lib/vapor/@vue/runtime-core/index.js +0 -7
  95. package/lib/vapor/@vue/runtime-core/package.json +0 -54
  96. package/lib/vapor/@vue/runtime-dom/LICENSE +0 -21
  97. package/lib/vapor/@vue/runtime-dom/README.md +0 -13
  98. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.cjs.js +0 -1797
  99. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +0 -1646
  100. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-browser.js +0 -12929
  101. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-browser.prod.js +0 -6
  102. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +0 -1838
  103. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.global.js +0 -13086
  104. package/lib/vapor/@vue/runtime-dom/dist/runtime-dom.global.prod.js +0 -6
  105. package/lib/vapor/@vue/runtime-dom/index.js +0 -7
  106. package/lib/vapor/@vue/runtime-dom/package.json +0 -60
  107. package/lib/vapor/@vue/runtime-vapor/LICENSE +0 -21
  108. package/lib/vapor/@vue/runtime-vapor/README.md +0 -8
  109. package/lib/vapor/@vue/runtime-vapor/dist/runtime-vapor.esm-bundler.js +0 -3242
  110. package/lib/vapor/@vue/runtime-vapor/package.json +0 -47
  111. package/lib/vapor/@vue/server-renderer/LICENSE +0 -21
  112. package/lib/vapor/@vue/server-renderer/README.md +0 -178
  113. package/lib/vapor/@vue/server-renderer/dist/server-renderer.cjs.js +0 -1144
  114. package/lib/vapor/@vue/server-renderer/dist/server-renderer.cjs.prod.js +0 -871
  115. package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-browser.js +0 -8756
  116. package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-browser.prod.js +0 -5
  117. package/lib/vapor/@vue/server-renderer/dist/server-renderer.esm-bundler.js +0 -1366
  118. package/lib/vapor/@vue/server-renderer/index.js +0 -7
  119. package/lib/vapor/@vue/server-renderer/package.json +0 -55
  120. package/lib/vapor/@vue/shared/LICENSE +0 -21
  121. package/lib/vapor/@vue/shared/README.md +0 -3
  122. package/lib/vapor/@vue/shared/dist/shared.cjs.js +0 -698
  123. package/lib/vapor/@vue/shared/dist/shared.cjs.prod.js +0 -690
  124. package/lib/vapor/@vue/shared/dist/shared.esm-bundler.js +0 -616
  125. package/lib/vapor/@vue/shared/index.js +0 -7
  126. package/lib/vapor/@vue/shared/package.json +0 -47
  127. package/lib/vapor/@vue/vue/LICENSE +0 -21
  128. package/lib/vapor/@vue/vue/README.md +0 -62
  129. package/lib/vapor/@vue/vue/compiler-sfc/index.browser.js +0 -1
  130. package/lib/vapor/@vue/vue/compiler-sfc/index.browser.mjs +0 -1
  131. package/lib/vapor/@vue/vue/compiler-sfc/index.d.mts +0 -1
  132. package/lib/vapor/@vue/vue/compiler-sfc/index.d.ts +0 -1
  133. package/lib/vapor/@vue/vue/compiler-sfc/index.js +0 -3
  134. package/lib/vapor/@vue/vue/compiler-sfc/index.mjs +0 -3
  135. package/lib/vapor/@vue/vue/compiler-sfc/package.json +0 -4
  136. package/lib/vapor/@vue/vue/compiler-sfc/register-ts.js +0 -3
  137. package/lib/vapor/@vue/vue/dist/vue.cjs.js +0 -80
  138. package/lib/vapor/@vue/vue/dist/vue.cjs.prod.js +0 -66
  139. package/lib/vapor/@vue/vue/dist/vue.esm-browser.js +0 -18840
  140. package/lib/vapor/@vue/vue/dist/vue.esm-browser.prod.js +0 -12
  141. package/lib/vapor/@vue/vue/dist/vue.esm-bundler.js +0 -72
  142. package/lib/vapor/@vue/vue/dist/vue.global.js +0 -18820
  143. package/lib/vapor/@vue/vue/dist/vue.global.prod.js +0 -12
  144. package/lib/vapor/@vue/vue/dist/vue.runtime-with-vapor.esm-browser.js +0 -15648
  145. package/lib/vapor/@vue/vue/dist/vue.runtime-with-vapor.esm-browser.prod.js +0 -9
  146. package/lib/vapor/@vue/vue/dist/vue.runtime.esm-browser.js +0 -12953
  147. package/lib/vapor/@vue/vue/dist/vue.runtime.esm-browser.prod.js +0 -6
  148. package/lib/vapor/@vue/vue/dist/vue.runtime.esm-bundler.js +0 -29
  149. package/lib/vapor/@vue/vue/dist/vue.runtime.global.js +0 -13111
  150. package/lib/vapor/@vue/vue/dist/vue.runtime.global.prod.js +0 -6
  151. package/lib/vapor/@vue/vue/index.js +0 -7
  152. package/lib/vapor/@vue/vue/index.mjs +0 -1
  153. package/lib/vapor/@vue/vue/jsx-runtime/index.d.ts +0 -25
  154. package/lib/vapor/@vue/vue/jsx-runtime/index.js +0 -15
  155. package/lib/vapor/@vue/vue/jsx-runtime/index.mjs +0 -12
  156. package/lib/vapor/@vue/vue/jsx-runtime/package.json +0 -5
  157. package/lib/vapor/@vue/vue/jsx.d.ts +0 -22
  158. package/lib/vapor/@vue/vue/package.json +0 -114
  159. package/lib/vapor/@vue/vue/server-renderer/index.d.mts +0 -1
  160. package/lib/vapor/@vue/vue/server-renderer/index.d.ts +0 -1
  161. package/lib/vapor/@vue/vue/server-renderer/index.js +0 -1
  162. package/lib/vapor/@vue/vue/server-renderer/index.mjs +0 -1
  163. package/lib/vapor/@vue/vue/server-renderer/package.json +0 -4
@@ -1,3105 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const fs = require('node:fs');
6
- const vite = require('vite');
7
- const vue = require('vue');
8
- const node_module = require('node:module');
9
- const path = require('node:path');
10
- const crypto = require('node:crypto');
11
- const require$$0 = require('tty');
12
- const require$$1 = require('util');
13
-
14
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
15
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
16
-
17
- const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
18
- const path__default = /*#__PURE__*/_interopDefaultCompat(path);
19
- const crypto__default = /*#__PURE__*/_interopDefaultCompat(crypto);
20
- const require$$0__default = /*#__PURE__*/_interopDefaultCompat(require$$0);
21
- const require$$1__default = /*#__PURE__*/_interopDefaultCompat(require$$1);
22
-
23
- const version = "5.2.4";
24
-
25
- function resolveCompiler(root) {
26
- const compiler = tryResolveCompiler(root) || tryResolveCompiler();
27
- if (!compiler) {
28
- throw new Error(
29
- `Failed to resolve vue/compiler-sfc.
30
- @vitejs/plugin-vue requires vue (>=3.2.25) to be present in the dependency tree.`
31
- );
32
- }
33
- return compiler;
34
- }
35
- function tryResolveCompiler(root) {
36
- const vueMeta = tryRequire("vue/package.json", root);
37
- if (vueMeta && vueMeta.version.split(".")[0] >= 3) {
38
- return tryRequire("vue/compiler-sfc", root);
39
- }
40
- }
41
- const _require = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
42
- function tryRequire(id, from) {
43
- try {
44
- return from ? _require(_require.resolve(id, { paths: [from] })) : _require(id);
45
- } catch (e) {
46
- }
47
- }
48
-
49
- function parseVueRequest(id) {
50
- const [filename, rawQuery] = id.split(`?`, 2);
51
- const query = Object.fromEntries(new URLSearchParams(rawQuery));
52
- if (query.vue != null) {
53
- query.vue = true;
54
- }
55
- if (query.index != null) {
56
- query.index = Number(query.index);
57
- }
58
- if (query.raw != null) {
59
- query.raw = true;
60
- }
61
- if (query.url != null) {
62
- query.url = true;
63
- }
64
- if (query.scoped != null) {
65
- query.scoped = true;
66
- }
67
- return {
68
- filename,
69
- query
70
- };
71
- }
72
-
73
- const cache = /* @__PURE__ */ new Map();
74
- const hmrCache = /* @__PURE__ */ new Map();
75
- const prevCache = /* @__PURE__ */ new Map();
76
- function createDescriptor(filename, source, {
77
- root,
78
- isProduction,
79
- sourceMap,
80
- compiler,
81
- template,
82
- features
83
- }, hmr = false) {
84
- const { descriptor, errors } = compiler.parse(source, {
85
- filename,
86
- sourceMap,
87
- templateParseOptions: template?.compilerOptions
88
- });
89
- const normalizedPath = vite.normalizePath(path__default.relative(root, filename));
90
- const componentIdGenerator = features?.componentIdGenerator;
91
- if (componentIdGenerator === "filepath") {
92
- descriptor.id = getHash(normalizedPath);
93
- } else if (componentIdGenerator === "filepath-source") {
94
- descriptor.id = getHash(normalizedPath + source);
95
- } else if (typeof componentIdGenerator === "function") {
96
- descriptor.id = componentIdGenerator(
97
- normalizedPath,
98
- source,
99
- isProduction,
100
- getHash
101
- );
102
- } else {
103
- descriptor.id = getHash(normalizedPath + (isProduction ? source : ""));
104
- }
105
- (hmr ? hmrCache : cache).set(filename, descriptor);
106
- return { descriptor, errors };
107
- }
108
- function getPrevDescriptor(filename) {
109
- return prevCache.get(filename);
110
- }
111
- function invalidateDescriptor(filename, hmr = false) {
112
- const _cache = hmr ? hmrCache : cache;
113
- const prev = _cache.get(filename);
114
- _cache.delete(filename);
115
- if (prev) {
116
- prevCache.set(filename, prev);
117
- }
118
- }
119
- function getDescriptor(filename, options, createIfNotFound = true, hmr = false, code) {
120
- const _cache = hmr ? hmrCache : cache;
121
- if (_cache.has(filename)) {
122
- return _cache.get(filename);
123
- }
124
- if (createIfNotFound) {
125
- const { descriptor, errors } = createDescriptor(
126
- filename,
127
- code ?? fs__default.readFileSync(filename, "utf-8"),
128
- options,
129
- hmr
130
- );
131
- if (errors.length && !hmr) {
132
- throw errors[0];
133
- }
134
- return descriptor;
135
- }
136
- }
137
- function getSrcDescriptor(filename, query) {
138
- if (query.scoped) {
139
- return cache.get(`${filename}?src=${query.src}`);
140
- }
141
- return cache.get(filename);
142
- }
143
- function getTempSrcDescriptor(filename, query) {
144
- return {
145
- filename,
146
- id: query.id || "",
147
- styles: [
148
- {
149
- scoped: query.scoped,
150
- loc: {
151
- start: { line: 0, column: 0 }
152
- }
153
- }
154
- ],
155
- isTemp: true
156
- };
157
- }
158
- function setSrcDescriptor(filename, entry, scoped) {
159
- if (scoped) {
160
- cache.set(`${filename}?src=${entry.id}`, entry);
161
- return;
162
- }
163
- cache.set(filename, entry);
164
- }
165
- const hash = (
166
- // eslint-disable-next-line n/no-unsupported-features/node-builtins -- crypto.hash is supported in Node 21.7.0+, 20.12.0+
167
- crypto__default.hash ?? ((algorithm, data, outputEncoding) => crypto__default.createHash(algorithm).update(data).digest(outputEncoding))
168
- );
169
- function getHash(text) {
170
- return hash("sha256", text, "hex").substring(0, 8);
171
- }
172
-
173
- function slash(path) {
174
- const isExtendedLengthPath = path.startsWith('\\\\?\\');
175
-
176
- if (isExtendedLengthPath) {
177
- return path;
178
- }
179
-
180
- return path.replace(/\\/g, '/');
181
- }
182
-
183
- function createRollupError(id, error) {
184
- const { message, name, stack } = error;
185
- const rollupError = {
186
- id,
187
- plugin: "vue",
188
- message,
189
- name,
190
- stack
191
- };
192
- if ("code" in error && error.loc) {
193
- rollupError.loc = {
194
- file: id,
195
- line: error.loc.start.line,
196
- column: error.loc.start.column
197
- };
198
- }
199
- return rollupError;
200
- }
201
-
202
- async function transformTemplateAsModule(code, descriptor, options, pluginContext, ssr, customElement) {
203
- const result = compile(
204
- code,
205
- descriptor,
206
- options,
207
- pluginContext,
208
- ssr,
209
- customElement
210
- );
211
- let returnCode = result.code;
212
- if (options.devServer && options.devServer.config.server.hmr !== false && !ssr && !options.isProduction) {
213
- returnCode += `
214
- import.meta.hot.accept(({ render }) => {
215
- __VUE_HMR_RUNTIME__.rerender(${JSON.stringify(descriptor.id)}, render)
216
- })`;
217
- }
218
- return {
219
- code: returnCode,
220
- map: result.map
221
- };
222
- }
223
- function transformTemplateInMain(code, descriptor, options, pluginContext, ssr, customElement) {
224
- const result = compile(
225
- code,
226
- descriptor,
227
- options,
228
- pluginContext,
229
- ssr,
230
- customElement
231
- );
232
- return {
233
- ...result,
234
- code: result.code.replace(
235
- /\nexport (function|const) (render|ssrRender)/,
236
- "\n$1 _sfc_$2"
237
- )
238
- };
239
- }
240
- function compile(code, descriptor, options, pluginContext, ssr, customElement) {
241
- const filename = descriptor.filename;
242
- resolveScript(descriptor, options, ssr, customElement);
243
- const result = options.compiler.compileTemplate({
244
- ...resolveTemplateCompilerOptions(descriptor, options, ssr),
245
- source: code
246
- });
247
- if (result.errors.length) {
248
- result.errors.forEach(
249
- (error) => pluginContext.error(
250
- typeof error === "string" ? { id: filename, message: error } : createRollupError(filename, error)
251
- )
252
- );
253
- }
254
- if (result.tips.length) {
255
- result.tips.forEach(
256
- (tip) => pluginContext.warn({
257
- id: filename,
258
- message: tip
259
- })
260
- );
261
- }
262
- return result;
263
- }
264
- function resolveTemplateCompilerOptions(descriptor, options, ssr) {
265
- const block = descriptor.template;
266
- if (!block) {
267
- return;
268
- }
269
- const resolvedScript = getResolvedScript(descriptor, ssr);
270
- const hasScoped = descriptor.styles.some((s) => s.scoped);
271
- const { id, filename, cssVars } = descriptor;
272
- let transformAssetUrls = options.template?.transformAssetUrls;
273
- let assetUrlOptions;
274
- if (transformAssetUrls === false) ; else if (options.devServer) {
275
- if (filename.startsWith(options.root)) {
276
- const devBase = options.devServer.config.base;
277
- assetUrlOptions = {
278
- base: (options.devServer.config.server?.origin ?? "") + devBase + slash(path__default.relative(options.root, path__default.dirname(filename))),
279
- includeAbsolute: !!devBase
280
- };
281
- }
282
- } else {
283
- assetUrlOptions = {
284
- includeAbsolute: true
285
- };
286
- }
287
- if (transformAssetUrls && typeof transformAssetUrls === "object") {
288
- if (Object.values(transformAssetUrls).some((val) => Array.isArray(val))) {
289
- transformAssetUrls = {
290
- ...assetUrlOptions,
291
- tags: transformAssetUrls
292
- };
293
- } else {
294
- transformAssetUrls = { ...assetUrlOptions, ...transformAssetUrls };
295
- }
296
- } else {
297
- transformAssetUrls = assetUrlOptions;
298
- }
299
- let preprocessOptions = block.lang && options.template?.preprocessOptions;
300
- if (block.lang === "pug") {
301
- preprocessOptions = {
302
- doctype: "html",
303
- ...preprocessOptions
304
- };
305
- }
306
- const expressionPlugins = options.template?.compilerOptions?.expressionPlugins || [];
307
- const lang = descriptor.scriptSetup?.lang || descriptor.script?.lang;
308
- if (lang && /tsx?$/.test(lang) && !expressionPlugins.includes("typescript")) {
309
- expressionPlugins.push("typescript");
310
- }
311
- return {
312
- ...options.template,
313
- // @ts-expect-error TODO remove when 3.6 is out
314
- vapor: descriptor.vapor,
315
- id,
316
- ast: canReuseAST(options.compiler.version) ? descriptor.template?.ast : void 0,
317
- filename,
318
- scoped: hasScoped,
319
- slotted: descriptor.slotted,
320
- isProd: options.isProduction,
321
- inMap: block.src ? void 0 : block.map,
322
- ssr,
323
- ssrCssVars: cssVars,
324
- transformAssetUrls,
325
- preprocessLang: block.lang === "html" ? void 0 : block.lang,
326
- preprocessOptions,
327
- compilerOptions: {
328
- ...options.template?.compilerOptions,
329
- scopeId: hasScoped ? `data-v-${id}` : void 0,
330
- bindingMetadata: resolvedScript ? resolvedScript.bindings : void 0,
331
- expressionPlugins,
332
- sourceMap: options.sourceMap
333
- }
334
- };
335
- }
336
- function canReuseAST(version) {
337
- if (version) {
338
- const [_, minor, patch] = version.split(".").map(Number);
339
- if (minor >= 4 && patch >= 3) {
340
- return true;
341
- }
342
- }
343
- return false;
344
- }
345
-
346
- let clientCache = /* @__PURE__ */ new WeakMap();
347
- let ssrCache = /* @__PURE__ */ new WeakMap();
348
- const typeDepToSFCMap = /* @__PURE__ */ new Map();
349
- function invalidateScript(filename) {
350
- const desc = cache.get(filename);
351
- if (desc) {
352
- clientCache.delete(desc);
353
- ssrCache.delete(desc);
354
- }
355
- }
356
- function getResolvedScript(descriptor, ssr) {
357
- return (ssr ? ssrCache : clientCache).get(descriptor);
358
- }
359
- function setResolvedScript(descriptor, script, ssr) {
360
- (ssr ? ssrCache : clientCache).set(descriptor, script);
361
- }
362
- function clearScriptCache() {
363
- clientCache = /* @__PURE__ */ new WeakMap();
364
- ssrCache = /* @__PURE__ */ new WeakMap();
365
- }
366
- function isUseInlineTemplate(descriptor, options) {
367
- return !options.devServer && !options.devToolsEnabled && !!descriptor.scriptSetup && !descriptor.template?.src;
368
- }
369
- const scriptIdentifier = `_sfc_main`;
370
- function resolveScript(descriptor, options, ssr, customElement) {
371
- if (!descriptor.script && !descriptor.scriptSetup) {
372
- return null;
373
- }
374
- const cached = getResolvedScript(descriptor, ssr);
375
- if (cached) {
376
- return cached;
377
- }
378
- const resolved = options.compiler.compileScript(descriptor, {
379
- ...options.script,
380
- id: descriptor.id,
381
- isProd: options.isProduction,
382
- inlineTemplate: isUseInlineTemplate(descriptor, options),
383
- templateOptions: resolveTemplateCompilerOptions(descriptor, options, ssr),
384
- sourceMap: options.sourceMap,
385
- genDefaultAs: canInlineMain(descriptor, options) ? scriptIdentifier : void 0,
386
- customElement,
387
- propsDestructure: options.features?.propsDestructure ?? options.script?.propsDestructure
388
- });
389
- if (!options.isProduction && resolved?.deps) {
390
- for (const [key, sfcs] of typeDepToSFCMap) {
391
- if (sfcs.has(descriptor.filename) && !resolved.deps.includes(key)) {
392
- sfcs.delete(descriptor.filename);
393
- }
394
- }
395
- for (const dep of resolved.deps) {
396
- const existingSet = typeDepToSFCMap.get(dep);
397
- if (!existingSet) {
398
- typeDepToSFCMap.set(dep, /* @__PURE__ */ new Set([descriptor.filename]));
399
- } else {
400
- existingSet.add(descriptor.filename);
401
- }
402
- }
403
- }
404
- setResolvedScript(descriptor, resolved, ssr);
405
- return resolved;
406
- }
407
- function canInlineMain(descriptor, options) {
408
- if (descriptor.script?.src || descriptor.scriptSetup?.src) {
409
- return false;
410
- }
411
- const lang = descriptor.script?.lang || descriptor.scriptSetup?.lang;
412
- if (!lang || lang === "js") {
413
- return true;
414
- }
415
- if (lang === "ts" && options.devServer) {
416
- return true;
417
- }
418
- return false;
419
- }
420
-
421
- const comma = ','.charCodeAt(0);
422
- const semicolon = ';'.charCodeAt(0);
423
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
424
- const intToChar = new Uint8Array(64); // 64 possible chars.
425
- const charToInt = new Uint8Array(128); // z is 122 in ASCII
426
- for (let i = 0; i < chars.length; i++) {
427
- const c = chars.charCodeAt(i);
428
- intToChar[i] = c;
429
- charToInt[c] = i;
430
- }
431
- function decodeInteger(reader, relative) {
432
- let value = 0;
433
- let shift = 0;
434
- let integer = 0;
435
- do {
436
- const c = reader.next();
437
- integer = charToInt[c];
438
- value |= (integer & 31) << shift;
439
- shift += 5;
440
- } while (integer & 32);
441
- const shouldNegate = value & 1;
442
- value >>>= 1;
443
- if (shouldNegate) {
444
- value = -2147483648 | -value;
445
- }
446
- return relative + value;
447
- }
448
- function encodeInteger(builder, num, relative) {
449
- let delta = num - relative;
450
- delta = delta < 0 ? (-delta << 1) | 1 : delta << 1;
451
- do {
452
- let clamped = delta & 0b011111;
453
- delta >>>= 5;
454
- if (delta > 0)
455
- clamped |= 0b100000;
456
- builder.write(intToChar[clamped]);
457
- } while (delta > 0);
458
- return num;
459
- }
460
- function hasMoreVlq(reader, max) {
461
- if (reader.pos >= max)
462
- return false;
463
- return reader.peek() !== comma;
464
- }
465
-
466
- const bufLength = 1024 * 16;
467
- // Provide a fallback for older environments.
468
- const td = typeof TextDecoder !== 'undefined'
469
- ? /* #__PURE__ */ new TextDecoder()
470
- : typeof Buffer !== 'undefined'
471
- ? {
472
- decode(buf) {
473
- const out = Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
474
- return out.toString();
475
- },
476
- }
477
- : {
478
- decode(buf) {
479
- let out = '';
480
- for (let i = 0; i < buf.length; i++) {
481
- out += String.fromCharCode(buf[i]);
482
- }
483
- return out;
484
- },
485
- };
486
- class StringWriter {
487
- constructor() {
488
- this.pos = 0;
489
- this.out = '';
490
- this.buffer = new Uint8Array(bufLength);
491
- }
492
- write(v) {
493
- const { buffer } = this;
494
- buffer[this.pos++] = v;
495
- if (this.pos === bufLength) {
496
- this.out += td.decode(buffer);
497
- this.pos = 0;
498
- }
499
- }
500
- flush() {
501
- const { buffer, out, pos } = this;
502
- return pos > 0 ? out + td.decode(buffer.subarray(0, pos)) : out;
503
- }
504
- }
505
- class StringReader {
506
- constructor(buffer) {
507
- this.pos = 0;
508
- this.buffer = buffer;
509
- }
510
- next() {
511
- return this.buffer.charCodeAt(this.pos++);
512
- }
513
- peek() {
514
- return this.buffer.charCodeAt(this.pos);
515
- }
516
- indexOf(char) {
517
- const { buffer, pos } = this;
518
- const idx = buffer.indexOf(char, pos);
519
- return idx === -1 ? buffer.length : idx;
520
- }
521
- }
522
-
523
- function decode(mappings) {
524
- const { length } = mappings;
525
- const reader = new StringReader(mappings);
526
- const decoded = [];
527
- let genColumn = 0;
528
- let sourcesIndex = 0;
529
- let sourceLine = 0;
530
- let sourceColumn = 0;
531
- let namesIndex = 0;
532
- do {
533
- const semi = reader.indexOf(';');
534
- const line = [];
535
- let sorted = true;
536
- let lastCol = 0;
537
- genColumn = 0;
538
- while (reader.pos < semi) {
539
- let seg;
540
- genColumn = decodeInteger(reader, genColumn);
541
- if (genColumn < lastCol)
542
- sorted = false;
543
- lastCol = genColumn;
544
- if (hasMoreVlq(reader, semi)) {
545
- sourcesIndex = decodeInteger(reader, sourcesIndex);
546
- sourceLine = decodeInteger(reader, sourceLine);
547
- sourceColumn = decodeInteger(reader, sourceColumn);
548
- if (hasMoreVlq(reader, semi)) {
549
- namesIndex = decodeInteger(reader, namesIndex);
550
- seg = [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex];
551
- }
552
- else {
553
- seg = [genColumn, sourcesIndex, sourceLine, sourceColumn];
554
- }
555
- }
556
- else {
557
- seg = [genColumn];
558
- }
559
- line.push(seg);
560
- reader.pos++;
561
- }
562
- if (!sorted)
563
- sort(line);
564
- decoded.push(line);
565
- reader.pos = semi + 1;
566
- } while (reader.pos <= length);
567
- return decoded;
568
- }
569
- function sort(line) {
570
- line.sort(sortComparator$1);
571
- }
572
- function sortComparator$1(a, b) {
573
- return a[0] - b[0];
574
- }
575
- function encode(decoded) {
576
- const writer = new StringWriter();
577
- let sourcesIndex = 0;
578
- let sourceLine = 0;
579
- let sourceColumn = 0;
580
- let namesIndex = 0;
581
- for (let i = 0; i < decoded.length; i++) {
582
- const line = decoded[i];
583
- if (i > 0)
584
- writer.write(semicolon);
585
- if (line.length === 0)
586
- continue;
587
- let genColumn = 0;
588
- for (let j = 0; j < line.length; j++) {
589
- const segment = line[j];
590
- if (j > 0)
591
- writer.write(comma);
592
- genColumn = encodeInteger(writer, segment[0], genColumn);
593
- if (segment.length === 1)
594
- continue;
595
- sourcesIndex = encodeInteger(writer, segment[1], sourcesIndex);
596
- sourceLine = encodeInteger(writer, segment[2], sourceLine);
597
- sourceColumn = encodeInteger(writer, segment[3], sourceColumn);
598
- if (segment.length === 4)
599
- continue;
600
- namesIndex = encodeInteger(writer, segment[4], namesIndex);
601
- }
602
- }
603
- return writer.flush();
604
- }
605
-
606
- // Matches the scheme of a URL, eg "http://"
607
- const schemeRegex = /^[\w+.-]+:\/\//;
608
- /**
609
- * Matches the parts of a URL:
610
- * 1. Scheme, including ":", guaranteed.
611
- * 2. User/password, including "@", optional.
612
- * 3. Host, guaranteed.
613
- * 4. Port, including ":", optional.
614
- * 5. Path, including "/", optional.
615
- * 6. Query, including "?", optional.
616
- * 7. Hash, including "#", optional.
617
- */
618
- const urlRegex = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/;
619
- /**
620
- * File URLs are weird. They dont' need the regular `//` in the scheme, they may or may not start
621
- * with a leading `/`, they can have a domain (but only if they don't start with a Windows drive).
622
- *
623
- * 1. Host, optional.
624
- * 2. Path, which may include "/", guaranteed.
625
- * 3. Query, including "?", optional.
626
- * 4. Hash, including "#", optional.
627
- */
628
- const fileRegex = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
629
- function isAbsoluteUrl(input) {
630
- return schemeRegex.test(input);
631
- }
632
- function isSchemeRelativeUrl(input) {
633
- return input.startsWith('//');
634
- }
635
- function isAbsolutePath(input) {
636
- return input.startsWith('/');
637
- }
638
- function isFileUrl(input) {
639
- return input.startsWith('file:');
640
- }
641
- function isRelative(input) {
642
- return /^[.?#]/.test(input);
643
- }
644
- function parseAbsoluteUrl(input) {
645
- const match = urlRegex.exec(input);
646
- return makeUrl(match[1], match[2] || '', match[3], match[4] || '', match[5] || '/', match[6] || '', match[7] || '');
647
- }
648
- function parseFileUrl(input) {
649
- const match = fileRegex.exec(input);
650
- const path = match[2];
651
- return makeUrl('file:', '', match[1] || '', '', isAbsolutePath(path) ? path : '/' + path, match[3] || '', match[4] || '');
652
- }
653
- function makeUrl(scheme, user, host, port, path, query, hash) {
654
- return {
655
- scheme,
656
- user,
657
- host,
658
- port,
659
- path,
660
- query,
661
- hash,
662
- type: 7 /* Absolute */,
663
- };
664
- }
665
- function parseUrl(input) {
666
- if (isSchemeRelativeUrl(input)) {
667
- const url = parseAbsoluteUrl('http:' + input);
668
- url.scheme = '';
669
- url.type = 6 /* SchemeRelative */;
670
- return url;
671
- }
672
- if (isAbsolutePath(input)) {
673
- const url = parseAbsoluteUrl('http://foo.com' + input);
674
- url.scheme = '';
675
- url.host = '';
676
- url.type = 5 /* AbsolutePath */;
677
- return url;
678
- }
679
- if (isFileUrl(input))
680
- return parseFileUrl(input);
681
- if (isAbsoluteUrl(input))
682
- return parseAbsoluteUrl(input);
683
- const url = parseAbsoluteUrl('http://foo.com/' + input);
684
- url.scheme = '';
685
- url.host = '';
686
- url.type = input
687
- ? input.startsWith('?')
688
- ? 3 /* Query */
689
- : input.startsWith('#')
690
- ? 2 /* Hash */
691
- : 4 /* RelativePath */
692
- : 1 /* Empty */;
693
- return url;
694
- }
695
- function stripPathFilename(path) {
696
- // If a path ends with a parent directory "..", then it's a relative path with excess parent
697
- // paths. It's not a file, so we can't strip it.
698
- if (path.endsWith('/..'))
699
- return path;
700
- const index = path.lastIndexOf('/');
701
- return path.slice(0, index + 1);
702
- }
703
- function mergePaths(url, base) {
704
- normalizePath(base, base.type);
705
- // If the path is just a "/", then it was an empty path to begin with (remember, we're a relative
706
- // path).
707
- if (url.path === '/') {
708
- url.path = base.path;
709
- }
710
- else {
711
- // Resolution happens relative to the base path's directory, not the file.
712
- url.path = stripPathFilename(base.path) + url.path;
713
- }
714
- }
715
- /**
716
- * The path can have empty directories "//", unneeded parents "foo/..", or current directory
717
- * "foo/.". We need to normalize to a standard representation.
718
- */
719
- function normalizePath(url, type) {
720
- const rel = type <= 4 /* RelativePath */;
721
- const pieces = url.path.split('/');
722
- // We need to preserve the first piece always, so that we output a leading slash. The item at
723
- // pieces[0] is an empty string.
724
- let pointer = 1;
725
- // Positive is the number of real directories we've output, used for popping a parent directory.
726
- // Eg, "foo/bar/.." will have a positive 2, and we can decrement to be left with just "foo".
727
- let positive = 0;
728
- // We need to keep a trailing slash if we encounter an empty directory (eg, splitting "foo/" will
729
- // generate `["foo", ""]` pieces). And, if we pop a parent directory. But once we encounter a
730
- // real directory, we won't need to append, unless the other conditions happen again.
731
- let addTrailingSlash = false;
732
- for (let i = 1; i < pieces.length; i++) {
733
- const piece = pieces[i];
734
- // An empty directory, could be a trailing slash, or just a double "//" in the path.
735
- if (!piece) {
736
- addTrailingSlash = true;
737
- continue;
738
- }
739
- // If we encounter a real directory, then we don't need to append anymore.
740
- addTrailingSlash = false;
741
- // A current directory, which we can always drop.
742
- if (piece === '.')
743
- continue;
744
- // A parent directory, we need to see if there are any real directories we can pop. Else, we
745
- // have an excess of parents, and we'll need to keep the "..".
746
- if (piece === '..') {
747
- if (positive) {
748
- addTrailingSlash = true;
749
- positive--;
750
- pointer--;
751
- }
752
- else if (rel) {
753
- // If we're in a relativePath, then we need to keep the excess parents. Else, in an absolute
754
- // URL, protocol relative URL, or an absolute path, we don't need to keep excess.
755
- pieces[pointer++] = piece;
756
- }
757
- continue;
758
- }
759
- // We've encountered a real directory. Move it to the next insertion pointer, which accounts for
760
- // any popped or dropped directories.
761
- pieces[pointer++] = piece;
762
- positive++;
763
- }
764
- let path = '';
765
- for (let i = 1; i < pointer; i++) {
766
- path += '/' + pieces[i];
767
- }
768
- if (!path || (addTrailingSlash && !path.endsWith('/..'))) {
769
- path += '/';
770
- }
771
- url.path = path;
772
- }
773
- /**
774
- * Attempts to resolve `input` URL/path relative to `base`.
775
- */
776
- function resolve$1(input, base) {
777
- if (!input && !base)
778
- return '';
779
- const url = parseUrl(input);
780
- let inputType = url.type;
781
- if (base && inputType !== 7 /* Absolute */) {
782
- const baseUrl = parseUrl(base);
783
- const baseType = baseUrl.type;
784
- switch (inputType) {
785
- case 1 /* Empty */:
786
- url.hash = baseUrl.hash;
787
- // fall through
788
- case 2 /* Hash */:
789
- url.query = baseUrl.query;
790
- // fall through
791
- case 3 /* Query */:
792
- case 4 /* RelativePath */:
793
- mergePaths(url, baseUrl);
794
- // fall through
795
- case 5 /* AbsolutePath */:
796
- // The host, user, and port are joined, you can't copy one without the others.
797
- url.user = baseUrl.user;
798
- url.host = baseUrl.host;
799
- url.port = baseUrl.port;
800
- // fall through
801
- case 6 /* SchemeRelative */:
802
- // The input doesn't have a schema at least, so we need to copy at least that over.
803
- url.scheme = baseUrl.scheme;
804
- }
805
- if (baseType > inputType)
806
- inputType = baseType;
807
- }
808
- normalizePath(url, inputType);
809
- const queryHash = url.query + url.hash;
810
- switch (inputType) {
811
- // This is impossible, because of the empty checks at the start of the function.
812
- // case UrlType.Empty:
813
- case 2 /* Hash */:
814
- case 3 /* Query */:
815
- return queryHash;
816
- case 4 /* RelativePath */: {
817
- // The first char is always a "/", and we need it to be relative.
818
- const path = url.path.slice(1);
819
- if (!path)
820
- return queryHash || '.';
821
- if (isRelative(base || input) && !isRelative(path)) {
822
- // If base started with a leading ".", or there is no base and input started with a ".",
823
- // then we need to ensure that the relative path starts with a ".". We don't know if
824
- // relative starts with a "..", though, so check before prepending.
825
- return './' + path + queryHash;
826
- }
827
- return path + queryHash;
828
- }
829
- case 5 /* AbsolutePath */:
830
- return url.path + queryHash;
831
- default:
832
- return url.scheme + '//' + url.user + url.host + url.port + url.path + queryHash;
833
- }
834
- }
835
-
836
- function resolve(input, base) {
837
- // The base is always treated as a directory, if it's not empty.
838
- // https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327
839
- // https://github.com/chromium/chromium/blob/da4adbb3/third_party/blink/renderer/devtools/front_end/sdk/SourceMap.js#L400-L401
840
- if (base && !base.endsWith('/'))
841
- base += '/';
842
- return resolve$1(input, base);
843
- }
844
-
845
- /**
846
- * Removes everything after the last "/", but leaves the slash.
847
- */
848
- function stripFilename(path) {
849
- if (!path)
850
- return '';
851
- const index = path.lastIndexOf('/');
852
- return path.slice(0, index + 1);
853
- }
854
-
855
- const COLUMN$1 = 0;
856
-
857
- function maybeSort(mappings, owned) {
858
- const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
859
- if (unsortedIndex === mappings.length)
860
- return mappings;
861
- // If we own the array (meaning we parsed it from JSON), then we're free to directly mutate it. If
862
- // not, we do not want to modify the consumer's input array.
863
- if (!owned)
864
- mappings = mappings.slice();
865
- for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
866
- mappings[i] = sortSegments(mappings[i], owned);
867
- }
868
- return mappings;
869
- }
870
- function nextUnsortedSegmentLine(mappings, start) {
871
- for (let i = start; i < mappings.length; i++) {
872
- if (!isSorted(mappings[i]))
873
- return i;
874
- }
875
- return mappings.length;
876
- }
877
- function isSorted(line) {
878
- for (let j = 1; j < line.length; j++) {
879
- if (line[j][COLUMN$1] < line[j - 1][COLUMN$1]) {
880
- return false;
881
- }
882
- }
883
- return true;
884
- }
885
- function sortSegments(line, owned) {
886
- if (!owned)
887
- line = line.slice();
888
- return line.sort(sortComparator);
889
- }
890
- function sortComparator(a, b) {
891
- return a[COLUMN$1] - b[COLUMN$1];
892
- }
893
- function memoizedState() {
894
- return {
895
- lastKey: -1,
896
- lastNeedle: -1,
897
- lastIndex: -1,
898
- };
899
- }
900
- class TraceMap {
901
- constructor(map, mapUrl) {
902
- const isString = typeof map === 'string';
903
- if (!isString && map._decodedMemo)
904
- return map;
905
- const parsed = (isString ? JSON.parse(map) : map);
906
- const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
907
- this.version = version;
908
- this.file = file;
909
- this.names = names || [];
910
- this.sourceRoot = sourceRoot;
911
- this.sources = sources;
912
- this.sourcesContent = sourcesContent;
913
- this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || undefined;
914
- const from = resolve(sourceRoot || '', stripFilename(mapUrl));
915
- this.resolvedSources = sources.map((s) => resolve(s || '', from));
916
- const { mappings } = parsed;
917
- if (typeof mappings === 'string') {
918
- this._encoded = mappings;
919
- this._decoded = undefined;
920
- }
921
- else {
922
- this._encoded = undefined;
923
- this._decoded = maybeSort(mappings, isString);
924
- }
925
- this._decodedMemo = memoizedState();
926
- this._bySources = undefined;
927
- this._bySourceMemos = undefined;
928
- }
929
- }
930
- /**
931
- * Typescript doesn't allow friend access to private fields, so this just casts the map into a type
932
- * with public access modifiers.
933
- */
934
- function cast$2(map) {
935
- return map;
936
- }
937
- /**
938
- * Returns the decoded (array of lines of segments) form of the SourceMap's mappings field.
939
- */
940
- function decodedMappings(map) {
941
- var _a;
942
- return ((_a = cast$2(map))._decoded || (_a._decoded = decode(cast$2(map)._encoded)));
943
- }
944
- /**
945
- * Iterates each mapping in generated position order.
946
- */
947
- function eachMapping(map, cb) {
948
- const decoded = decodedMappings(map);
949
- const { names, resolvedSources } = map;
950
- for (let i = 0; i < decoded.length; i++) {
951
- const line = decoded[i];
952
- for (let j = 0; j < line.length; j++) {
953
- const seg = line[j];
954
- const generatedLine = i + 1;
955
- const generatedColumn = seg[0];
956
- let source = null;
957
- let originalLine = null;
958
- let originalColumn = null;
959
- let name = null;
960
- if (seg.length !== 1) {
961
- source = resolvedSources[seg[1]];
962
- originalLine = seg[2] + 1;
963
- originalColumn = seg[3];
964
- }
965
- if (seg.length === 5)
966
- name = names[seg[4]];
967
- cb({
968
- generatedLine,
969
- generatedColumn,
970
- source,
971
- originalLine,
972
- originalColumn,
973
- name,
974
- });
975
- }
976
- }
977
- }
978
-
979
- /**
980
- * SetArray acts like a `Set` (allowing only one occurrence of a string `key`), but provides the
981
- * index of the `key` in the backing array.
982
- *
983
- * This is designed to allow synchronizing a second array with the contents of the backing array,
984
- * like how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`,
985
- * and there are never duplicates.
986
- */
987
- class SetArray {
988
- constructor() {
989
- this._indexes = { __proto__: null };
990
- this.array = [];
991
- }
992
- }
993
- /**
994
- * Typescript doesn't allow friend access to private fields, so this just casts the set into a type
995
- * with public access modifiers.
996
- */
997
- function cast$1(set) {
998
- return set;
999
- }
1000
- /**
1001
- * Gets the index associated with `key` in the backing array, if it is already present.
1002
- */
1003
- function get(setarr, key) {
1004
- return cast$1(setarr)._indexes[key];
1005
- }
1006
- /**
1007
- * Puts `key` into the backing array, if it is not already present. Returns
1008
- * the index of the `key` in the backing array.
1009
- */
1010
- function put(setarr, key) {
1011
- // The key may or may not be present. If it is present, it's a number.
1012
- const index = get(setarr, key);
1013
- if (index !== undefined)
1014
- return index;
1015
- const { array, _indexes: indexes } = cast$1(setarr);
1016
- const length = array.push(key);
1017
- return (indexes[key] = length - 1);
1018
- }
1019
-
1020
- const COLUMN = 0;
1021
-
1022
- const NO_NAME = -1;
1023
- /**
1024
- * Provides the state to generate a sourcemap.
1025
- */
1026
- class GenMapping {
1027
- constructor({ file, sourceRoot } = {}) {
1028
- this._names = new SetArray();
1029
- this._sources = new SetArray();
1030
- this._sourcesContent = [];
1031
- this._mappings = [];
1032
- this.file = file;
1033
- this.sourceRoot = sourceRoot;
1034
- this._ignoreList = new SetArray();
1035
- }
1036
- }
1037
- /**
1038
- * Typescript doesn't allow friend access to private fields, so this just casts the map into a type
1039
- * with public access modifiers.
1040
- */
1041
- function cast(map) {
1042
- return map;
1043
- }
1044
- function addMapping(map, mapping) {
1045
- return addMappingInternal(false, map, mapping);
1046
- }
1047
- /**
1048
- * Returns a sourcemap object (with decoded mappings) suitable for passing to a library that expects
1049
- * a sourcemap, or to JSON.stringify.
1050
- */
1051
- function toDecodedMap(map) {
1052
- const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, _ignoreList: ignoreList, } = cast(map);
1053
- removeEmptyFinalLines(mappings);
1054
- return {
1055
- version: 3,
1056
- file: map.file || undefined,
1057
- names: names.array,
1058
- sourceRoot: map.sourceRoot || undefined,
1059
- sources: sources.array,
1060
- sourcesContent,
1061
- mappings,
1062
- ignoreList: ignoreList.array,
1063
- };
1064
- }
1065
- /**
1066
- * Returns a sourcemap object (with encoded mappings) suitable for passing to a library that expects
1067
- * a sourcemap, or to JSON.stringify.
1068
- */
1069
- function toEncodedMap(map) {
1070
- const decoded = toDecodedMap(map);
1071
- return Object.assign(Object.assign({}, decoded), { mappings: encode(decoded.mappings) });
1072
- }
1073
- /**
1074
- * Constructs a new GenMapping, using the already present mappings of the input.
1075
- */
1076
- function fromMap(input) {
1077
- const map = new TraceMap(input);
1078
- const gen = new GenMapping({ file: map.file, sourceRoot: map.sourceRoot });
1079
- putAll(cast(gen)._names, map.names);
1080
- putAll(cast(gen)._sources, map.sources);
1081
- cast(gen)._sourcesContent = map.sourcesContent || map.sources.map(() => null);
1082
- cast(gen)._mappings = decodedMappings(map);
1083
- if (map.ignoreList)
1084
- putAll(cast(gen)._ignoreList, map.ignoreList);
1085
- return gen;
1086
- }
1087
- // This split declaration is only so that terser can elminiate the static initialization block.
1088
- function addSegmentInternal(skipable, map, genLine, genColumn, source, sourceLine, sourceColumn, name, content) {
1089
- const { _mappings: mappings, _sources: sources, _sourcesContent: sourcesContent, _names: names, } = cast(map);
1090
- const line = getLine(mappings, genLine);
1091
- const index = getColumnIndex(line, genColumn);
1092
- if (!source) {
1093
- return insert(line, index, [genColumn]);
1094
- }
1095
- const sourcesIndex = put(sources, source);
1096
- const namesIndex = name ? put(names, name) : NO_NAME;
1097
- if (sourcesIndex === sourcesContent.length)
1098
- sourcesContent[sourcesIndex] = content !== null && content !== void 0 ? content : null;
1099
- return insert(line, index, name
1100
- ? [genColumn, sourcesIndex, sourceLine, sourceColumn, namesIndex]
1101
- : [genColumn, sourcesIndex, sourceLine, sourceColumn]);
1102
- }
1103
- function getLine(mappings, index) {
1104
- for (let i = mappings.length; i <= index; i++) {
1105
- mappings[i] = [];
1106
- }
1107
- return mappings[index];
1108
- }
1109
- function getColumnIndex(line, genColumn) {
1110
- let index = line.length;
1111
- for (let i = index - 1; i >= 0; index = i--) {
1112
- const current = line[i];
1113
- if (genColumn >= current[COLUMN])
1114
- break;
1115
- }
1116
- return index;
1117
- }
1118
- function insert(array, index, value) {
1119
- for (let i = array.length; i > index; i--) {
1120
- array[i] = array[i - 1];
1121
- }
1122
- array[index] = value;
1123
- }
1124
- function removeEmptyFinalLines(mappings) {
1125
- const { length } = mappings;
1126
- let len = length;
1127
- for (let i = len - 1; i >= 0; len = i, i--) {
1128
- if (mappings[i].length > 0)
1129
- break;
1130
- }
1131
- if (len < length)
1132
- mappings.length = len;
1133
- }
1134
- function putAll(setarr, array) {
1135
- for (let i = 0; i < array.length; i++)
1136
- put(setarr, array[i]);
1137
- }
1138
- function addMappingInternal(skipable, map, mapping) {
1139
- const { generated, source, original, name, content } = mapping;
1140
- if (!source) {
1141
- return addSegmentInternal(skipable, map, generated.line - 1, generated.column, null, null, null, null, null);
1142
- }
1143
- return addSegmentInternal(skipable, map, generated.line - 1, generated.column, source, original.line - 1, original.column, name, content);
1144
- }
1145
-
1146
- function getDefaultExportFromCjs (x) {
1147
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
1148
- }
1149
-
1150
- var src = {exports: {}};
1151
-
1152
- var browser = {exports: {}};
1153
-
1154
- /**
1155
- * Helpers.
1156
- */
1157
-
1158
- var ms;
1159
- var hasRequiredMs;
1160
-
1161
- function requireMs () {
1162
- if (hasRequiredMs) return ms;
1163
- hasRequiredMs = 1;
1164
- var s = 1000;
1165
- var m = s * 60;
1166
- var h = m * 60;
1167
- var d = h * 24;
1168
- var w = d * 7;
1169
- var y = d * 365.25;
1170
-
1171
- /**
1172
- * Parse or format the given `val`.
1173
- *
1174
- * Options:
1175
- *
1176
- * - `long` verbose formatting [false]
1177
- *
1178
- * @param {String|Number} val
1179
- * @param {Object} [options]
1180
- * @throws {Error} throw an error if val is not a non-empty string or a number
1181
- * @return {String|Number}
1182
- * @api public
1183
- */
1184
-
1185
- ms = function (val, options) {
1186
- options = options || {};
1187
- var type = typeof val;
1188
- if (type === 'string' && val.length > 0) {
1189
- return parse(val);
1190
- } else if (type === 'number' && isFinite(val)) {
1191
- return options.long ? fmtLong(val) : fmtShort(val);
1192
- }
1193
- throw new Error(
1194
- 'val is not a non-empty string or a valid number. val=' +
1195
- JSON.stringify(val)
1196
- );
1197
- };
1198
-
1199
- /**
1200
- * Parse the given `str` and return milliseconds.
1201
- *
1202
- * @param {String} str
1203
- * @return {Number}
1204
- * @api private
1205
- */
1206
-
1207
- function parse(str) {
1208
- str = String(str);
1209
- if (str.length > 100) {
1210
- return;
1211
- }
1212
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
1213
- str
1214
- );
1215
- if (!match) {
1216
- return;
1217
- }
1218
- var n = parseFloat(match[1]);
1219
- var type = (match[2] || 'ms').toLowerCase();
1220
- switch (type) {
1221
- case 'years':
1222
- case 'year':
1223
- case 'yrs':
1224
- case 'yr':
1225
- case 'y':
1226
- return n * y;
1227
- case 'weeks':
1228
- case 'week':
1229
- case 'w':
1230
- return n * w;
1231
- case 'days':
1232
- case 'day':
1233
- case 'd':
1234
- return n * d;
1235
- case 'hours':
1236
- case 'hour':
1237
- case 'hrs':
1238
- case 'hr':
1239
- case 'h':
1240
- return n * h;
1241
- case 'minutes':
1242
- case 'minute':
1243
- case 'mins':
1244
- case 'min':
1245
- case 'm':
1246
- return n * m;
1247
- case 'seconds':
1248
- case 'second':
1249
- case 'secs':
1250
- case 'sec':
1251
- case 's':
1252
- return n * s;
1253
- case 'milliseconds':
1254
- case 'millisecond':
1255
- case 'msecs':
1256
- case 'msec':
1257
- case 'ms':
1258
- return n;
1259
- default:
1260
- return undefined;
1261
- }
1262
- }
1263
-
1264
- /**
1265
- * Short format for `ms`.
1266
- *
1267
- * @param {Number} ms
1268
- * @return {String}
1269
- * @api private
1270
- */
1271
-
1272
- function fmtShort(ms) {
1273
- var msAbs = Math.abs(ms);
1274
- if (msAbs >= d) {
1275
- return Math.round(ms / d) + 'd';
1276
- }
1277
- if (msAbs >= h) {
1278
- return Math.round(ms / h) + 'h';
1279
- }
1280
- if (msAbs >= m) {
1281
- return Math.round(ms / m) + 'm';
1282
- }
1283
- if (msAbs >= s) {
1284
- return Math.round(ms / s) + 's';
1285
- }
1286
- return ms + 'ms';
1287
- }
1288
-
1289
- /**
1290
- * Long format for `ms`.
1291
- *
1292
- * @param {Number} ms
1293
- * @return {String}
1294
- * @api private
1295
- */
1296
-
1297
- function fmtLong(ms) {
1298
- var msAbs = Math.abs(ms);
1299
- if (msAbs >= d) {
1300
- return plural(ms, msAbs, d, 'day');
1301
- }
1302
- if (msAbs >= h) {
1303
- return plural(ms, msAbs, h, 'hour');
1304
- }
1305
- if (msAbs >= m) {
1306
- return plural(ms, msAbs, m, 'minute');
1307
- }
1308
- if (msAbs >= s) {
1309
- return plural(ms, msAbs, s, 'second');
1310
- }
1311
- return ms + ' ms';
1312
- }
1313
-
1314
- /**
1315
- * Pluralization helper.
1316
- */
1317
-
1318
- function plural(ms, msAbs, n, name) {
1319
- var isPlural = msAbs >= n * 1.5;
1320
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
1321
- }
1322
- return ms;
1323
- }
1324
-
1325
- var common;
1326
- var hasRequiredCommon;
1327
-
1328
- function requireCommon () {
1329
- if (hasRequiredCommon) return common;
1330
- hasRequiredCommon = 1;
1331
- /**
1332
- * This is the common logic for both the Node.js and web browser
1333
- * implementations of `debug()`.
1334
- */
1335
-
1336
- function setup(env) {
1337
- createDebug.debug = createDebug;
1338
- createDebug.default = createDebug;
1339
- createDebug.coerce = coerce;
1340
- createDebug.disable = disable;
1341
- createDebug.enable = enable;
1342
- createDebug.enabled = enabled;
1343
- createDebug.humanize = requireMs();
1344
- createDebug.destroy = destroy;
1345
-
1346
- Object.keys(env).forEach(key => {
1347
- createDebug[key] = env[key];
1348
- });
1349
-
1350
- /**
1351
- * The currently active debug mode names, and names to skip.
1352
- */
1353
-
1354
- createDebug.names = [];
1355
- createDebug.skips = [];
1356
-
1357
- /**
1358
- * Map of special "%n" handling functions, for the debug "format" argument.
1359
- *
1360
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
1361
- */
1362
- createDebug.formatters = {};
1363
-
1364
- /**
1365
- * Selects a color for a debug namespace
1366
- * @param {String} namespace The namespace string for the debug instance to be colored
1367
- * @return {Number|String} An ANSI color code for the given namespace
1368
- * @api private
1369
- */
1370
- function selectColor(namespace) {
1371
- let hash = 0;
1372
-
1373
- for (let i = 0; i < namespace.length; i++) {
1374
- hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
1375
- hash |= 0; // Convert to 32bit integer
1376
- }
1377
-
1378
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
1379
- }
1380
- createDebug.selectColor = selectColor;
1381
-
1382
- /**
1383
- * Create a debugger with the given `namespace`.
1384
- *
1385
- * @param {String} namespace
1386
- * @return {Function}
1387
- * @api public
1388
- */
1389
- function createDebug(namespace) {
1390
- let prevTime;
1391
- let enableOverride = null;
1392
- let namespacesCache;
1393
- let enabledCache;
1394
-
1395
- function debug(...args) {
1396
- // Disabled?
1397
- if (!debug.enabled) {
1398
- return;
1399
- }
1400
-
1401
- const self = debug;
1402
-
1403
- // Set `diff` timestamp
1404
- const curr = Number(new Date());
1405
- const ms = curr - (prevTime || curr);
1406
- self.diff = ms;
1407
- self.prev = prevTime;
1408
- self.curr = curr;
1409
- prevTime = curr;
1410
-
1411
- args[0] = createDebug.coerce(args[0]);
1412
-
1413
- if (typeof args[0] !== 'string') {
1414
- // Anything else let's inspect with %O
1415
- args.unshift('%O');
1416
- }
1417
-
1418
- // Apply any `formatters` transformations
1419
- let index = 0;
1420
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
1421
- // If we encounter an escaped % then don't increase the array index
1422
- if (match === '%%') {
1423
- return '%';
1424
- }
1425
- index++;
1426
- const formatter = createDebug.formatters[format];
1427
- if (typeof formatter === 'function') {
1428
- const val = args[index];
1429
- match = formatter.call(self, val);
1430
-
1431
- // Now we need to remove `args[index]` since it's inlined in the `format`
1432
- args.splice(index, 1);
1433
- index--;
1434
- }
1435
- return match;
1436
- });
1437
-
1438
- // Apply env-specific formatting (colors, etc.)
1439
- createDebug.formatArgs.call(self, args);
1440
-
1441
- const logFn = self.log || createDebug.log;
1442
- logFn.apply(self, args);
1443
- }
1444
-
1445
- debug.namespace = namespace;
1446
- debug.useColors = createDebug.useColors();
1447
- debug.color = createDebug.selectColor(namespace);
1448
- debug.extend = extend;
1449
- debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
1450
-
1451
- Object.defineProperty(debug, 'enabled', {
1452
- enumerable: true,
1453
- configurable: false,
1454
- get: () => {
1455
- if (enableOverride !== null) {
1456
- return enableOverride;
1457
- }
1458
- if (namespacesCache !== createDebug.namespaces) {
1459
- namespacesCache = createDebug.namespaces;
1460
- enabledCache = createDebug.enabled(namespace);
1461
- }
1462
-
1463
- return enabledCache;
1464
- },
1465
- set: v => {
1466
- enableOverride = v;
1467
- }
1468
- });
1469
-
1470
- // Env-specific initialization logic for debug instances
1471
- if (typeof createDebug.init === 'function') {
1472
- createDebug.init(debug);
1473
- }
1474
-
1475
- return debug;
1476
- }
1477
-
1478
- function extend(namespace, delimiter) {
1479
- const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
1480
- newDebug.log = this.log;
1481
- return newDebug;
1482
- }
1483
-
1484
- /**
1485
- * Enables a debug mode by namespaces. This can include modes
1486
- * separated by a colon and wildcards.
1487
- *
1488
- * @param {String} namespaces
1489
- * @api public
1490
- */
1491
- function enable(namespaces) {
1492
- createDebug.save(namespaces);
1493
- createDebug.namespaces = namespaces;
1494
-
1495
- createDebug.names = [];
1496
- createDebug.skips = [];
1497
-
1498
- const split = (typeof namespaces === 'string' ? namespaces : '')
1499
- .trim()
1500
- .replace(' ', ',')
1501
- .split(',')
1502
- .filter(Boolean);
1503
-
1504
- for (const ns of split) {
1505
- if (ns[0] === '-') {
1506
- createDebug.skips.push(ns.slice(1));
1507
- } else {
1508
- createDebug.names.push(ns);
1509
- }
1510
- }
1511
- }
1512
-
1513
- /**
1514
- * Checks if the given string matches a namespace template, honoring
1515
- * asterisks as wildcards.
1516
- *
1517
- * @param {String} search
1518
- * @param {String} template
1519
- * @return {Boolean}
1520
- */
1521
- function matchesTemplate(search, template) {
1522
- let searchIndex = 0;
1523
- let templateIndex = 0;
1524
- let starIndex = -1;
1525
- let matchIndex = 0;
1526
-
1527
- while (searchIndex < search.length) {
1528
- if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
1529
- // Match character or proceed with wildcard
1530
- if (template[templateIndex] === '*') {
1531
- starIndex = templateIndex;
1532
- matchIndex = searchIndex;
1533
- templateIndex++; // Skip the '*'
1534
- } else {
1535
- searchIndex++;
1536
- templateIndex++;
1537
- }
1538
- } else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
1539
- // Backtrack to the last '*' and try to match more characters
1540
- templateIndex = starIndex + 1;
1541
- matchIndex++;
1542
- searchIndex = matchIndex;
1543
- } else {
1544
- return false; // No match
1545
- }
1546
- }
1547
-
1548
- // Handle trailing '*' in template
1549
- while (templateIndex < template.length && template[templateIndex] === '*') {
1550
- templateIndex++;
1551
- }
1552
-
1553
- return templateIndex === template.length;
1554
- }
1555
-
1556
- /**
1557
- * Disable debug output.
1558
- *
1559
- * @return {String} namespaces
1560
- * @api public
1561
- */
1562
- function disable() {
1563
- const namespaces = [
1564
- ...createDebug.names,
1565
- ...createDebug.skips.map(namespace => '-' + namespace)
1566
- ].join(',');
1567
- createDebug.enable('');
1568
- return namespaces;
1569
- }
1570
-
1571
- /**
1572
- * Returns true if the given mode name is enabled, false otherwise.
1573
- *
1574
- * @param {String} name
1575
- * @return {Boolean}
1576
- * @api public
1577
- */
1578
- function enabled(name) {
1579
- for (const skip of createDebug.skips) {
1580
- if (matchesTemplate(name, skip)) {
1581
- return false;
1582
- }
1583
- }
1584
-
1585
- for (const ns of createDebug.names) {
1586
- if (matchesTemplate(name, ns)) {
1587
- return true;
1588
- }
1589
- }
1590
-
1591
- return false;
1592
- }
1593
-
1594
- /**
1595
- * Coerce `val`.
1596
- *
1597
- * @param {Mixed} val
1598
- * @return {Mixed}
1599
- * @api private
1600
- */
1601
- function coerce(val) {
1602
- if (val instanceof Error) {
1603
- return val.stack || val.message;
1604
- }
1605
- return val;
1606
- }
1607
-
1608
- /**
1609
- * XXX DO NOT USE. This is a temporary stub function.
1610
- * XXX It WILL be removed in the next major release.
1611
- */
1612
- function destroy() {
1613
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1614
- }
1615
-
1616
- createDebug.enable(createDebug.load());
1617
-
1618
- return createDebug;
1619
- }
1620
-
1621
- common = setup;
1622
- return common;
1623
- }
1624
-
1625
- /* eslint-env browser */
1626
-
1627
- var hasRequiredBrowser;
1628
-
1629
- function requireBrowser () {
1630
- if (hasRequiredBrowser) return browser.exports;
1631
- hasRequiredBrowser = 1;
1632
- (function (module, exports) {
1633
- /**
1634
- * This is the web browser implementation of `debug()`.
1635
- */
1636
-
1637
- exports.formatArgs = formatArgs;
1638
- exports.save = save;
1639
- exports.load = load;
1640
- exports.useColors = useColors;
1641
- exports.storage = localstorage();
1642
- exports.destroy = (() => {
1643
- let warned = false;
1644
-
1645
- return () => {
1646
- if (!warned) {
1647
- warned = true;
1648
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1649
- }
1650
- };
1651
- })();
1652
-
1653
- /**
1654
- * Colors.
1655
- */
1656
-
1657
- exports.colors = [
1658
- '#0000CC',
1659
- '#0000FF',
1660
- '#0033CC',
1661
- '#0033FF',
1662
- '#0066CC',
1663
- '#0066FF',
1664
- '#0099CC',
1665
- '#0099FF',
1666
- '#00CC00',
1667
- '#00CC33',
1668
- '#00CC66',
1669
- '#00CC99',
1670
- '#00CCCC',
1671
- '#00CCFF',
1672
- '#3300CC',
1673
- '#3300FF',
1674
- '#3333CC',
1675
- '#3333FF',
1676
- '#3366CC',
1677
- '#3366FF',
1678
- '#3399CC',
1679
- '#3399FF',
1680
- '#33CC00',
1681
- '#33CC33',
1682
- '#33CC66',
1683
- '#33CC99',
1684
- '#33CCCC',
1685
- '#33CCFF',
1686
- '#6600CC',
1687
- '#6600FF',
1688
- '#6633CC',
1689
- '#6633FF',
1690
- '#66CC00',
1691
- '#66CC33',
1692
- '#9900CC',
1693
- '#9900FF',
1694
- '#9933CC',
1695
- '#9933FF',
1696
- '#99CC00',
1697
- '#99CC33',
1698
- '#CC0000',
1699
- '#CC0033',
1700
- '#CC0066',
1701
- '#CC0099',
1702
- '#CC00CC',
1703
- '#CC00FF',
1704
- '#CC3300',
1705
- '#CC3333',
1706
- '#CC3366',
1707
- '#CC3399',
1708
- '#CC33CC',
1709
- '#CC33FF',
1710
- '#CC6600',
1711
- '#CC6633',
1712
- '#CC9900',
1713
- '#CC9933',
1714
- '#CCCC00',
1715
- '#CCCC33',
1716
- '#FF0000',
1717
- '#FF0033',
1718
- '#FF0066',
1719
- '#FF0099',
1720
- '#FF00CC',
1721
- '#FF00FF',
1722
- '#FF3300',
1723
- '#FF3333',
1724
- '#FF3366',
1725
- '#FF3399',
1726
- '#FF33CC',
1727
- '#FF33FF',
1728
- '#FF6600',
1729
- '#FF6633',
1730
- '#FF9900',
1731
- '#FF9933',
1732
- '#FFCC00',
1733
- '#FFCC33'
1734
- ];
1735
-
1736
- /**
1737
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
1738
- * and the Firebug extension (any Firefox version) are known
1739
- * to support "%c" CSS customizations.
1740
- *
1741
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
1742
- */
1743
-
1744
- // eslint-disable-next-line complexity
1745
- function useColors() {
1746
- // NB: In an Electron preload script, document will be defined but not fully
1747
- // initialized. Since we know we're in Chrome, we'll just detect this case
1748
- // explicitly
1749
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
1750
- return true;
1751
- }
1752
-
1753
- // Internet Explorer and Edge do not support colors.
1754
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
1755
- return false;
1756
- }
1757
-
1758
- let m;
1759
-
1760
- // Is webkit? http://stackoverflow.com/a/16459606/376773
1761
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
1762
- // eslint-disable-next-line no-return-assign
1763
- return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
1764
- // Is firebug? http://stackoverflow.com/a/398120/376773
1765
- (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
1766
- // Is firefox >= v31?
1767
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
1768
- (typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
1769
- // Double check webkit in userAgent just in case we are in a worker
1770
- (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
1771
- }
1772
-
1773
- /**
1774
- * Colorize log arguments if enabled.
1775
- *
1776
- * @api public
1777
- */
1778
-
1779
- function formatArgs(args) {
1780
- args[0] = (this.useColors ? '%c' : '') +
1781
- this.namespace +
1782
- (this.useColors ? ' %c' : ' ') +
1783
- args[0] +
1784
- (this.useColors ? '%c ' : ' ') +
1785
- '+' + module.exports.humanize(this.diff);
1786
-
1787
- if (!this.useColors) {
1788
- return;
1789
- }
1790
-
1791
- const c = 'color: ' + this.color;
1792
- args.splice(1, 0, c, 'color: inherit');
1793
-
1794
- // The final "%c" is somewhat tricky, because there could be other
1795
- // arguments passed either before or after the %c, so we need to
1796
- // figure out the correct index to insert the CSS into
1797
- let index = 0;
1798
- let lastC = 0;
1799
- args[0].replace(/%[a-zA-Z%]/g, match => {
1800
- if (match === '%%') {
1801
- return;
1802
- }
1803
- index++;
1804
- if (match === '%c') {
1805
- // We only are interested in the *last* %c
1806
- // (the user may have provided their own)
1807
- lastC = index;
1808
- }
1809
- });
1810
-
1811
- args.splice(lastC, 0, c);
1812
- }
1813
-
1814
- /**
1815
- * Invokes `console.debug()` when available.
1816
- * No-op when `console.debug` is not a "function".
1817
- * If `console.debug` is not available, falls back
1818
- * to `console.log`.
1819
- *
1820
- * @api public
1821
- */
1822
- exports.log = console.debug || console.log || (() => {});
1823
-
1824
- /**
1825
- * Save `namespaces`.
1826
- *
1827
- * @param {String} namespaces
1828
- * @api private
1829
- */
1830
- function save(namespaces) {
1831
- try {
1832
- if (namespaces) {
1833
- exports.storage.setItem('debug', namespaces);
1834
- } else {
1835
- exports.storage.removeItem('debug');
1836
- }
1837
- } catch (error) {
1838
- // Swallow
1839
- // XXX (@Qix-) should we be logging these?
1840
- }
1841
- }
1842
-
1843
- /**
1844
- * Load `namespaces`.
1845
- *
1846
- * @return {String} returns the previously persisted debug modes
1847
- * @api private
1848
- */
1849
- function load() {
1850
- let r;
1851
- try {
1852
- r = exports.storage.getItem('debug');
1853
- } catch (error) {
1854
- // Swallow
1855
- // XXX (@Qix-) should we be logging these?
1856
- }
1857
-
1858
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
1859
- if (!r && typeof process !== 'undefined' && 'env' in process) {
1860
- r = process.env.DEBUG;
1861
- }
1862
-
1863
- return r;
1864
- }
1865
-
1866
- /**
1867
- * Localstorage attempts to return the localstorage.
1868
- *
1869
- * This is necessary because safari throws
1870
- * when a user disables cookies/localstorage
1871
- * and you attempt to access it.
1872
- *
1873
- * @return {LocalStorage}
1874
- * @api private
1875
- */
1876
-
1877
- function localstorage() {
1878
- try {
1879
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
1880
- // The Browser also has localStorage in the global context.
1881
- return localStorage;
1882
- } catch (error) {
1883
- // Swallow
1884
- // XXX (@Qix-) should we be logging these?
1885
- }
1886
- }
1887
-
1888
- module.exports = requireCommon()(exports);
1889
-
1890
- const {formatters} = module.exports;
1891
-
1892
- /**
1893
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
1894
- */
1895
-
1896
- formatters.j = function (v) {
1897
- try {
1898
- return JSON.stringify(v);
1899
- } catch (error) {
1900
- return '[UnexpectedJSONParseError]: ' + error.message;
1901
- }
1902
- };
1903
- } (browser, browser.exports));
1904
- return browser.exports;
1905
- }
1906
-
1907
- var node = {exports: {}};
1908
-
1909
- /**
1910
- * Module dependencies.
1911
- */
1912
-
1913
- var hasRequiredNode;
1914
-
1915
- function requireNode () {
1916
- if (hasRequiredNode) return node.exports;
1917
- hasRequiredNode = 1;
1918
- (function (module, exports) {
1919
- const tty = require$$0__default;
1920
- const util = require$$1__default;
1921
-
1922
- /**
1923
- * This is the Node.js implementation of `debug()`.
1924
- */
1925
-
1926
- exports.init = init;
1927
- exports.log = log;
1928
- exports.formatArgs = formatArgs;
1929
- exports.save = save;
1930
- exports.load = load;
1931
- exports.useColors = useColors;
1932
- exports.destroy = util.deprecate(
1933
- () => {},
1934
- 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
1935
- );
1936
-
1937
- /**
1938
- * Colors.
1939
- */
1940
-
1941
- exports.colors = [6, 2, 3, 4, 5, 1];
1942
-
1943
- try {
1944
- // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
1945
- // eslint-disable-next-line import/no-extraneous-dependencies
1946
- const supportsColor = require('supports-color');
1947
-
1948
- if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
1949
- exports.colors = [
1950
- 20,
1951
- 21,
1952
- 26,
1953
- 27,
1954
- 32,
1955
- 33,
1956
- 38,
1957
- 39,
1958
- 40,
1959
- 41,
1960
- 42,
1961
- 43,
1962
- 44,
1963
- 45,
1964
- 56,
1965
- 57,
1966
- 62,
1967
- 63,
1968
- 68,
1969
- 69,
1970
- 74,
1971
- 75,
1972
- 76,
1973
- 77,
1974
- 78,
1975
- 79,
1976
- 80,
1977
- 81,
1978
- 92,
1979
- 93,
1980
- 98,
1981
- 99,
1982
- 112,
1983
- 113,
1984
- 128,
1985
- 129,
1986
- 134,
1987
- 135,
1988
- 148,
1989
- 149,
1990
- 160,
1991
- 161,
1992
- 162,
1993
- 163,
1994
- 164,
1995
- 165,
1996
- 166,
1997
- 167,
1998
- 168,
1999
- 169,
2000
- 170,
2001
- 171,
2002
- 172,
2003
- 173,
2004
- 178,
2005
- 179,
2006
- 184,
2007
- 185,
2008
- 196,
2009
- 197,
2010
- 198,
2011
- 199,
2012
- 200,
2013
- 201,
2014
- 202,
2015
- 203,
2016
- 204,
2017
- 205,
2018
- 206,
2019
- 207,
2020
- 208,
2021
- 209,
2022
- 214,
2023
- 215,
2024
- 220,
2025
- 221
2026
- ];
2027
- }
2028
- } catch (error) {
2029
- // Swallow - we only care if `supports-color` is available; it doesn't have to be.
2030
- }
2031
-
2032
- /**
2033
- * Build up the default `inspectOpts` object from the environment variables.
2034
- *
2035
- * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
2036
- */
2037
-
2038
- exports.inspectOpts = Object.keys(process.env).filter(key => {
2039
- return /^debug_/i.test(key);
2040
- }).reduce((obj, key) => {
2041
- // Camel-case
2042
- const prop = key
2043
- .substring(6)
2044
- .toLowerCase()
2045
- .replace(/_([a-z])/g, (_, k) => {
2046
- return k.toUpperCase();
2047
- });
2048
-
2049
- // Coerce string value into JS value
2050
- let val = process.env[key];
2051
- if (/^(yes|on|true|enabled)$/i.test(val)) {
2052
- val = true;
2053
- } else if (/^(no|off|false|disabled)$/i.test(val)) {
2054
- val = false;
2055
- } else if (val === 'null') {
2056
- val = null;
2057
- } else {
2058
- val = Number(val);
2059
- }
2060
-
2061
- obj[prop] = val;
2062
- return obj;
2063
- }, {});
2064
-
2065
- /**
2066
- * Is stdout a TTY? Colored output is enabled when `true`.
2067
- */
2068
-
2069
- function useColors() {
2070
- return 'colors' in exports.inspectOpts ?
2071
- Boolean(exports.inspectOpts.colors) :
2072
- tty.isatty(process.stderr.fd);
2073
- }
2074
-
2075
- /**
2076
- * Adds ANSI color escape codes if enabled.
2077
- *
2078
- * @api public
2079
- */
2080
-
2081
- function formatArgs(args) {
2082
- const {namespace: name, useColors} = this;
2083
-
2084
- if (useColors) {
2085
- const c = this.color;
2086
- const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
2087
- const prefix = ` ${colorCode};1m${name} \u001B[0m`;
2088
-
2089
- args[0] = prefix + args[0].split('\n').join('\n' + prefix);
2090
- args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
2091
- } else {
2092
- args[0] = getDate() + name + ' ' + args[0];
2093
- }
2094
- }
2095
-
2096
- function getDate() {
2097
- if (exports.inspectOpts.hideDate) {
2098
- return '';
2099
- }
2100
- return new Date().toISOString() + ' ';
2101
- }
2102
-
2103
- /**
2104
- * Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
2105
- */
2106
-
2107
- function log(...args) {
2108
- return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
2109
- }
2110
-
2111
- /**
2112
- * Save `namespaces`.
2113
- *
2114
- * @param {String} namespaces
2115
- * @api private
2116
- */
2117
- function save(namespaces) {
2118
- if (namespaces) {
2119
- process.env.DEBUG = namespaces;
2120
- } else {
2121
- // If you set a process.env field to null or undefined, it gets cast to the
2122
- // string 'null' or 'undefined'. Just delete instead.
2123
- delete process.env.DEBUG;
2124
- }
2125
- }
2126
-
2127
- /**
2128
- * Load `namespaces`.
2129
- *
2130
- * @return {String} returns the previously persisted debug modes
2131
- * @api private
2132
- */
2133
-
2134
- function load() {
2135
- return process.env.DEBUG;
2136
- }
2137
-
2138
- /**
2139
- * Init logic for `debug` instances.
2140
- *
2141
- * Create a new `inspectOpts` object in case `useColors` is set
2142
- * differently for a particular `debug` instance.
2143
- */
2144
-
2145
- function init(debug) {
2146
- debug.inspectOpts = {};
2147
-
2148
- const keys = Object.keys(exports.inspectOpts);
2149
- for (let i = 0; i < keys.length; i++) {
2150
- debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
2151
- }
2152
- }
2153
-
2154
- module.exports = requireCommon()(exports);
2155
-
2156
- const {formatters} = module.exports;
2157
-
2158
- /**
2159
- * Map %o to `util.inspect()`, all on a single line.
2160
- */
2161
-
2162
- formatters.o = function (v) {
2163
- this.inspectOpts.colors = this.useColors;
2164
- return util.inspect(v, this.inspectOpts)
2165
- .split('\n')
2166
- .map(str => str.trim())
2167
- .join(' ');
2168
- };
2169
-
2170
- /**
2171
- * Map %O to `util.inspect()`, allowing multiple lines if needed.
2172
- */
2173
-
2174
- formatters.O = function (v) {
2175
- this.inspectOpts.colors = this.useColors;
2176
- return util.inspect(v, this.inspectOpts);
2177
- };
2178
- } (node, node.exports));
2179
- return node.exports;
2180
- }
2181
-
2182
- /**
2183
- * Detect Electron renderer / nwjs process, which is node, but we should
2184
- * treat as a browser.
2185
- */
2186
-
2187
- var hasRequiredSrc;
2188
-
2189
- function requireSrc () {
2190
- if (hasRequiredSrc) return src.exports;
2191
- hasRequiredSrc = 1;
2192
- if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
2193
- src.exports = requireBrowser();
2194
- } else {
2195
- src.exports = requireNode();
2196
- }
2197
- return src.exports;
2198
- }
2199
-
2200
- var srcExports = requireSrc();
2201
- const _debug = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
2202
-
2203
- const debug = _debug("vite:hmr");
2204
- const directRequestRE = /(?:\?|&)direct\b/;
2205
- async function handleHotUpdate({ file, modules, read }, options, customElement, typeDepModules) {
2206
- const prevDescriptor = getDescriptor(file, options, false, true);
2207
- if (!prevDescriptor) {
2208
- return;
2209
- }
2210
- const content = await read();
2211
- const { descriptor } = createDescriptor(file, content, options, true);
2212
- let needRerender = false;
2213
- const affectedModules = /* @__PURE__ */ new Set();
2214
- const mainModule = getMainModule(modules);
2215
- const templateModule = modules.find((m) => /type=template/.test(m.url));
2216
- resolveScript(descriptor, options, false, customElement);
2217
- const scriptChanged = hasScriptChanged(prevDescriptor, descriptor);
2218
- if (scriptChanged) {
2219
- affectedModules.add(getScriptModule(modules) || mainModule);
2220
- }
2221
- if (!isEqualBlock(descriptor.template, prevDescriptor.template)) {
2222
- if (!scriptChanged) {
2223
- setResolvedScript(
2224
- descriptor,
2225
- getResolvedScript(prevDescriptor, false),
2226
- false
2227
- );
2228
- }
2229
- affectedModules.add(templateModule);
2230
- needRerender = true;
2231
- }
2232
- let didUpdateStyle = false;
2233
- const prevStyles = prevDescriptor.styles || [];
2234
- const nextStyles = descriptor.styles || [];
2235
- if (prevDescriptor.cssVars.join("") !== descriptor.cssVars.join("")) {
2236
- affectedModules.add(mainModule);
2237
- }
2238
- if (prevStyles.some((s) => s.scoped) !== nextStyles.some((s) => s.scoped)) {
2239
- affectedModules.add(templateModule);
2240
- affectedModules.add(mainModule);
2241
- }
2242
- for (let i = 0; i < nextStyles.length; i++) {
2243
- const prev = prevStyles[i];
2244
- const next = nextStyles[i];
2245
- if (!prev || !isEqualBlock(prev, next)) {
2246
- didUpdateStyle = true;
2247
- const mod = modules.find(
2248
- (m) => m.url.includes(`type=style&index=${i}`) && m.url.endsWith(`.${next.lang || "css"}`) && !directRequestRE.test(m.url)
2249
- );
2250
- if (mod) {
2251
- affectedModules.add(mod);
2252
- if (mod.url.includes("&inline")) {
2253
- affectedModules.add(mainModule);
2254
- }
2255
- } else {
2256
- affectedModules.add(mainModule);
2257
- }
2258
- }
2259
- }
2260
- if (prevStyles.length > nextStyles.length) {
2261
- affectedModules.add(mainModule);
2262
- }
2263
- const prevCustoms = prevDescriptor.customBlocks || [];
2264
- const nextCustoms = descriptor.customBlocks || [];
2265
- if (prevCustoms.length !== nextCustoms.length) {
2266
- affectedModules.add(mainModule);
2267
- } else {
2268
- for (let i = 0; i < nextCustoms.length; i++) {
2269
- const prev = prevCustoms[i];
2270
- const next = nextCustoms[i];
2271
- if (!prev || !isEqualBlock(prev, next)) {
2272
- const mod = modules.find(
2273
- (m) => m.url.includes(`type=${prev.type}&index=${i}`)
2274
- );
2275
- if (mod) {
2276
- affectedModules.add(mod);
2277
- } else {
2278
- affectedModules.add(mainModule);
2279
- }
2280
- }
2281
- }
2282
- }
2283
- const updateType = [];
2284
- if (needRerender) {
2285
- updateType.push(`template`);
2286
- if (!templateModule) {
2287
- affectedModules.add(mainModule);
2288
- } else if (mainModule && !affectedModules.has(mainModule)) {
2289
- const styleImporters = [...mainModule.importers].filter(
2290
- (m) => vite.isCSSRequest(m.url)
2291
- );
2292
- styleImporters.forEach((m) => affectedModules.add(m));
2293
- }
2294
- }
2295
- if (didUpdateStyle) {
2296
- updateType.push(`style`);
2297
- }
2298
- if (updateType.length) {
2299
- if (file.endsWith(".vue")) {
2300
- invalidateDescriptor(file);
2301
- } else {
2302
- cache.set(file, descriptor);
2303
- }
2304
- debug(`[vue:update(${updateType.join("&")})] ${file}`);
2305
- }
2306
- return [...affectedModules, ...typeDepModules || []].filter(
2307
- Boolean
2308
- );
2309
- }
2310
- function isEqualBlock(a, b) {
2311
- if (!a && !b) return true;
2312
- if (!a || !b) return false;
2313
- if (a.src && b.src && a.src === b.src) return true;
2314
- if (a.content !== b.content) return false;
2315
- const keysA = Object.keys(a.attrs);
2316
- const keysB = Object.keys(b.attrs);
2317
- if (keysA.length !== keysB.length) {
2318
- return false;
2319
- }
2320
- return keysA.every((key) => a.attrs[key] === b.attrs[key]);
2321
- }
2322
- function isOnlyTemplateChanged(prev, next) {
2323
- return !hasScriptChanged(prev, next) && prev.styles.length === next.styles.length && prev.styles.every((s, i) => isEqualBlock(s, next.styles[i])) && prev.customBlocks.length === next.customBlocks.length && prev.customBlocks.every((s, i) => isEqualBlock(s, next.customBlocks[i]));
2324
- }
2325
- function deepEqual(obj1, obj2, excludeProps = [], deepParentsOfObj1 = []) {
2326
- if (typeof obj1 !== typeof obj2) {
2327
- return false;
2328
- }
2329
- if (obj1 == null || obj2 == null || typeof obj1 !== "object" || deepParentsOfObj1.includes(obj1)) {
2330
- return obj1 === obj2;
2331
- }
2332
- const keys1 = Object.keys(obj1);
2333
- const keys2 = Object.keys(obj2);
2334
- if (keys1.length !== keys2.length) {
2335
- return false;
2336
- }
2337
- for (const key of keys1) {
2338
- if (excludeProps.includes(key)) {
2339
- continue;
2340
- }
2341
- if (!deepEqual(obj1[key], obj2[key], excludeProps, [
2342
- ...deepParentsOfObj1,
2343
- obj1
2344
- ])) {
2345
- return false;
2346
- }
2347
- }
2348
- return true;
2349
- }
2350
- function isEqualAst(prev, next) {
2351
- if (typeof prev === "undefined" || typeof next === "undefined") {
2352
- return prev === next;
2353
- }
2354
- if (prev.length !== next.length) {
2355
- return false;
2356
- }
2357
- for (let i = 0; i < prev.length; i++) {
2358
- const prevNode = prev[i];
2359
- const nextNode = next[i];
2360
- if (
2361
- // deep equal, but ignore start/end/loc/range/leadingComments/trailingComments/innerComments
2362
- !deepEqual(prevNode, nextNode, [
2363
- "start",
2364
- "end",
2365
- "loc",
2366
- "range",
2367
- "leadingComments",
2368
- "trailingComments",
2369
- "innerComments",
2370
- // https://github.com/vuejs/core/issues/11923
2371
- // avoid comparing the following properties of typeParameters
2372
- // as it may be imported from 3rd lib and complex to compare
2373
- "_ownerScope",
2374
- "_resolvedReference",
2375
- "_resolvedElements"
2376
- ])
2377
- ) {
2378
- return false;
2379
- }
2380
- }
2381
- return true;
2382
- }
2383
- function hasScriptChanged(prev, next) {
2384
- const prevScript = getResolvedScript(prev, false);
2385
- const nextScript = getResolvedScript(next, false);
2386
- if (!isEqualBlock(prev.script, next.script) && !isEqualAst(prevScript?.scriptAst, nextScript?.scriptAst)) {
2387
- return true;
2388
- }
2389
- if (!isEqualBlock(prev.scriptSetup, next.scriptSetup) && !isEqualAst(prevScript?.scriptSetupAst, nextScript?.scriptSetupAst)) {
2390
- return true;
2391
- }
2392
- const prevResolvedScript = getResolvedScript(prev, false);
2393
- const prevImports = prevResolvedScript?.imports;
2394
- if (prevImports) {
2395
- return !next.template || next.shouldForceReload(prevImports);
2396
- }
2397
- return false;
2398
- }
2399
- function getMainModule(modules) {
2400
- return modules.filter((m) => !/type=/.test(m.url) || /type=script/.test(m.url)).sort((m1, m2) => {
2401
- return m1.url.length - m2.url.length;
2402
- })[0];
2403
- }
2404
- function getScriptModule(modules) {
2405
- return modules.find((m) => /type=script.*&lang\.\w+$/.test(m.url));
2406
- }
2407
- function handleTypeDepChange(affectedComponents, { modules, server: { moduleGraph } }) {
2408
- const affected = /* @__PURE__ */ new Set();
2409
- for (const file of affectedComponents) {
2410
- invalidateScript(file);
2411
- const mods = moduleGraph.getModulesByFile(file);
2412
- if (mods) {
2413
- const arr = [...mods];
2414
- affected.add(getScriptModule(arr) || getMainModule(arr));
2415
- }
2416
- }
2417
- return [...modules, ...affected];
2418
- }
2419
-
2420
- const EXPORT_HELPER_ID = "\0plugin-vue:export-helper";
2421
- const helperCode = `
2422
- export default (sfc, props) => {
2423
- const target = sfc.__vccOpts || sfc;
2424
- for (const [key, val] of props) {
2425
- target[key] = val;
2426
- }
2427
- return target;
2428
- }
2429
- `;
2430
-
2431
- async function transformMain(code, filename, options, pluginContext, ssr, customElement) {
2432
- const { devServer, isProduction, devToolsEnabled } = options;
2433
- const prevDescriptor = getPrevDescriptor(filename);
2434
- const { descriptor, errors } = createDescriptor(filename, code, options);
2435
- if (fs__default.existsSync(filename)) {
2436
- getDescriptor(
2437
- filename,
2438
- options,
2439
- true,
2440
- true,
2441
- // for vue files, create descriptor from fs read to be consistent with
2442
- // logic in handleHotUpdate()
2443
- // for non vue files, e.g. md files in vitepress, we assume
2444
- // `hmrContext.read` is overwritten so handleHotUpdate() is dealing with
2445
- // post-transform code, so we populate the descriptor with post-transform
2446
- // code here as well.
2447
- filename.endsWith(".vue") ? void 0 : code
2448
- );
2449
- }
2450
- if (errors.length) {
2451
- errors.forEach(
2452
- (error) => pluginContext.error(createRollupError(filename, error))
2453
- );
2454
- return null;
2455
- }
2456
- const attachedProps = [];
2457
- const hasScoped = descriptor.styles.some((s) => s.scoped);
2458
- const { code: scriptCode, map: scriptMap } = await genScriptCode(
2459
- descriptor,
2460
- options,
2461
- pluginContext,
2462
- ssr,
2463
- customElement
2464
- );
2465
- const hasTemplateImport = descriptor.template && !isUseInlineTemplate(descriptor, options);
2466
- let templateCode = "";
2467
- let templateMap = void 0;
2468
- if (hasTemplateImport) {
2469
- ({ code: templateCode, map: templateMap } = await genTemplateCode(
2470
- descriptor,
2471
- options,
2472
- pluginContext,
2473
- ssr,
2474
- customElement
2475
- ));
2476
- }
2477
- if (hasTemplateImport) {
2478
- attachedProps.push(
2479
- ssr ? ["ssrRender", "_sfc_ssrRender"] : ["render", "_sfc_render"]
2480
- );
2481
- } else {
2482
- if (prevDescriptor && !isEqualBlock(descriptor.template, prevDescriptor.template)) {
2483
- attachedProps.push([ssr ? "ssrRender" : "render", "() => {}"]);
2484
- }
2485
- }
2486
- const stylesCode = await genStyleCode(
2487
- descriptor,
2488
- pluginContext,
2489
- customElement,
2490
- attachedProps
2491
- );
2492
- const customBlocksCode = await genCustomBlockCode(descriptor, pluginContext);
2493
- const output = [
2494
- scriptCode,
2495
- templateCode,
2496
- stylesCode,
2497
- customBlocksCode
2498
- ];
2499
- if (hasScoped) {
2500
- attachedProps.push([`__scopeId`, JSON.stringify(`data-v-${descriptor.id}`)]);
2501
- }
2502
- if (devToolsEnabled || devServer && !isProduction) {
2503
- attachedProps.push([
2504
- `__file`,
2505
- JSON.stringify(isProduction ? path__default.basename(filename) : filename)
2506
- ]);
2507
- }
2508
- if (devServer && devServer.config.server.hmr !== false && !ssr && !isProduction) {
2509
- output.push(`_sfc_main.__hmrId = ${JSON.stringify(descriptor.id)}`);
2510
- output.push(
2511
- `typeof __VUE_HMR_RUNTIME__ !== 'undefined' && __VUE_HMR_RUNTIME__.createRecord(_sfc_main.__hmrId, _sfc_main)`
2512
- );
2513
- output.push(
2514
- `import.meta.hot.on('file-changed', ({ file }) => {`,
2515
- ` __VUE_HMR_RUNTIME__.CHANGED_FILE = file`,
2516
- `})`
2517
- );
2518
- if (prevDescriptor && isOnlyTemplateChanged(prevDescriptor, descriptor)) {
2519
- output.push(
2520
- `export const _rerender_only = __VUE_HMR_RUNTIME__.CHANGED_FILE === ${JSON.stringify(vite.normalizePath(filename))}`
2521
- );
2522
- }
2523
- output.push(
2524
- `import.meta.hot.accept(mod => {`,
2525
- ` if (!mod) return`,
2526
- ` const { default: updated, _rerender_only } = mod`,
2527
- ` if (_rerender_only) {`,
2528
- ` __VUE_HMR_RUNTIME__.rerender(updated.__hmrId, updated.render)`,
2529
- ` } else {`,
2530
- ` __VUE_HMR_RUNTIME__.reload(updated.__hmrId, updated)`,
2531
- ` }`,
2532
- `})`
2533
- );
2534
- }
2535
- if (ssr) {
2536
- const normalizedFilename = vite.normalizePath(
2537
- path__default.relative(options.root, filename)
2538
- );
2539
- output.push(
2540
- `import { useSSRContext as __vite_useSSRContext } from 'vue'`,
2541
- `const _sfc_setup = _sfc_main.setup`,
2542
- `_sfc_main.setup = (props, ctx) => {`,
2543
- ` const ssrContext = __vite_useSSRContext()`,
2544
- ` ;(ssrContext.modules || (ssrContext.modules = new Set())).add(${JSON.stringify(
2545
- normalizedFilename
2546
- )})`,
2547
- ` return _sfc_setup ? _sfc_setup(props, ctx) : undefined`,
2548
- `}`
2549
- );
2550
- }
2551
- let resolvedMap = void 0;
2552
- if (options.sourceMap) {
2553
- if (templateMap) {
2554
- const from = scriptMap ?? {
2555
- file: filename,
2556
- sourceRoot: "",
2557
- version: 3,
2558
- sources: [],
2559
- sourcesContent: [],
2560
- names: [],
2561
- mappings: ""
2562
- };
2563
- const gen = fromMap(
2564
- // version property of result.map is declared as string
2565
- // but actually it is `3`
2566
- from
2567
- );
2568
- const tracer = new TraceMap(
2569
- // same above
2570
- templateMap
2571
- );
2572
- const offset = (scriptCode.match(/\r?\n/g)?.length ?? 0) + 1;
2573
- eachMapping(tracer, (m) => {
2574
- if (m.source == null) return;
2575
- addMapping(gen, {
2576
- source: m.source,
2577
- original: { line: m.originalLine, column: m.originalColumn },
2578
- generated: {
2579
- line: m.generatedLine + offset,
2580
- column: m.generatedColumn
2581
- }
2582
- });
2583
- });
2584
- resolvedMap = toEncodedMap(gen);
2585
- resolvedMap.sourcesContent = templateMap.sourcesContent;
2586
- } else {
2587
- resolvedMap = scriptMap;
2588
- }
2589
- }
2590
- if (!attachedProps.length) {
2591
- output.push(`export default _sfc_main`);
2592
- } else {
2593
- output.push(
2594
- `import _export_sfc from '${EXPORT_HELPER_ID}'`,
2595
- `export default /*#__PURE__*/_export_sfc(_sfc_main, [${attachedProps.map(([key, val]) => `['${key}',${val}]`).join(",")}])`
2596
- );
2597
- }
2598
- let resolvedCode = output.join("\n");
2599
- const lang = descriptor.scriptSetup?.lang || descriptor.script?.lang;
2600
- if (lang && /tsx?$/.test(lang) && !descriptor.script?.src) {
2601
- const { transformWithOxc } = await import('vite');
2602
- if (transformWithOxc) {
2603
- const { code: code2, map } = await transformWithOxc(
2604
- resolvedCode,
2605
- filename,
2606
- {
2607
- // #430 support decorators in .vue file
2608
- // target can be overridden by oxc config target
2609
- // @ts-ignore Rolldown-specific
2610
- ...options.devServer?.config.oxc,
2611
- lang: "ts",
2612
- sourcemap: options.sourceMap
2613
- },
2614
- resolvedMap
2615
- );
2616
- resolvedCode = code2;
2617
- resolvedMap = resolvedMap ? map : resolvedMap;
2618
- } else {
2619
- const { code: code2, map } = await vite.transformWithEsbuild(
2620
- resolvedCode,
2621
- filename,
2622
- {
2623
- target: "esnext",
2624
- charset: "utf8",
2625
- // #430 support decorators in .vue file
2626
- // target can be overridden by esbuild config target
2627
- ...options.devServer?.config.esbuild,
2628
- loader: "ts",
2629
- sourcemap: options.sourceMap
2630
- },
2631
- resolvedMap
2632
- );
2633
- resolvedCode = code2;
2634
- resolvedMap = resolvedMap ? map : resolvedMap;
2635
- }
2636
- }
2637
- return {
2638
- code: resolvedCode,
2639
- map: resolvedMap || {
2640
- mappings: ""
2641
- },
2642
- meta: {
2643
- vite: {
2644
- lang: descriptor.script?.lang || descriptor.scriptSetup?.lang || "js"
2645
- }
2646
- }
2647
- };
2648
- }
2649
- async function genTemplateCode(descriptor, options, pluginContext, ssr, customElement) {
2650
- const template = descriptor.template;
2651
- const hasScoped = descriptor.styles.some((style) => style.scoped);
2652
- if ((!template.lang || template.lang === "html") && !template.src) {
2653
- return transformTemplateInMain(
2654
- template.content,
2655
- descriptor,
2656
- options,
2657
- pluginContext,
2658
- ssr,
2659
- customElement
2660
- );
2661
- } else {
2662
- if (template.src) {
2663
- await linkSrcToDescriptor(
2664
- template.src,
2665
- descriptor,
2666
- pluginContext,
2667
- hasScoped
2668
- );
2669
- }
2670
- const src = template.src || descriptor.filename;
2671
- const srcQuery = template.src ? hasScoped ? `&src=${descriptor.id}` : "&src=true" : "";
2672
- const scopedQuery = hasScoped ? `&scoped=${descriptor.id}` : ``;
2673
- const attrsQuery = attrsToQuery(template.attrs, "js", true);
2674
- const query = `?vue&type=template${srcQuery}${scopedQuery}${attrsQuery}`;
2675
- const request = JSON.stringify(src + query);
2676
- const renderFnName = ssr ? "ssrRender" : "render";
2677
- return {
2678
- code: `import { ${renderFnName} as _sfc_${renderFnName} } from ${request}`,
2679
- map: void 0
2680
- };
2681
- }
2682
- }
2683
- async function genScriptCode(descriptor, options, pluginContext, ssr, customElement) {
2684
- const vaporFlag = descriptor.vapor ? "__vapor: true" : "";
2685
- let scriptCode = `const ${scriptIdentifier} = { ${vaporFlag} }`;
2686
- let map;
2687
- const script = resolveScript(descriptor, options, ssr, customElement);
2688
- if (script) {
2689
- if (canInlineMain(descriptor, options)) {
2690
- if (!options.compiler.version) {
2691
- const userPlugins = options.script?.babelParserPlugins || [];
2692
- const defaultPlugins = script.lang === "ts" ? userPlugins.includes("decorators") ? ["typescript"] : ["typescript", "decorators-legacy"] : [];
2693
- scriptCode = options.compiler.rewriteDefault(
2694
- script.content,
2695
- scriptIdentifier,
2696
- [...defaultPlugins, ...userPlugins]
2697
- );
2698
- } else {
2699
- scriptCode = script.content;
2700
- }
2701
- map = script.map;
2702
- } else {
2703
- if (script.src) {
2704
- await linkSrcToDescriptor(script.src, descriptor, pluginContext, false);
2705
- }
2706
- const src = script.src || descriptor.filename;
2707
- const langFallback = script.src && path__default.extname(src).slice(1) || "js";
2708
- const attrsQuery = attrsToQuery(script.attrs, langFallback);
2709
- const srcQuery = script.src ? `&src=true` : ``;
2710
- const query = `?vue&type=script${srcQuery}${attrsQuery}`;
2711
- const request = JSON.stringify(src + query);
2712
- scriptCode = `import _sfc_main from ${request}
2713
- export * from ${request}`;
2714
- }
2715
- }
2716
- return {
2717
- code: scriptCode,
2718
- map
2719
- };
2720
- }
2721
- async function genStyleCode(descriptor, pluginContext, customElement, attachedProps) {
2722
- let stylesCode = ``;
2723
- let cssModulesMap;
2724
- if (descriptor.styles.length) {
2725
- for (let i = 0; i < descriptor.styles.length; i++) {
2726
- const style = descriptor.styles[i];
2727
- if (style.src) {
2728
- await linkSrcToDescriptor(
2729
- style.src,
2730
- descriptor,
2731
- pluginContext,
2732
- style.scoped
2733
- );
2734
- }
2735
- const src = style.src || descriptor.filename;
2736
- const attrsQuery = attrsToQuery(style.attrs, "css");
2737
- const srcQuery = style.src ? style.scoped ? `&src=${descriptor.id}` : "&src=true" : "";
2738
- const directQuery = customElement ? `&inline` : ``;
2739
- const scopedQuery = style.scoped ? `&scoped=${descriptor.id}` : ``;
2740
- const query = `?vue&type=style&index=${i}${srcQuery}${directQuery}${scopedQuery}`;
2741
- const styleRequest = src + query + attrsQuery;
2742
- if (style.module) {
2743
- if (customElement) {
2744
- throw new Error(
2745
- `<style module> is not supported in custom elements mode.`
2746
- );
2747
- }
2748
- const [importCode, nameMap] = genCSSModulesCode(
2749
- i,
2750
- styleRequest,
2751
- style.module
2752
- );
2753
- stylesCode += importCode;
2754
- Object.assign(cssModulesMap ||= {}, nameMap);
2755
- } else {
2756
- if (customElement) {
2757
- stylesCode += `
2758
- import _style_${i} from ${JSON.stringify(
2759
- styleRequest
2760
- )}`;
2761
- } else {
2762
- stylesCode += `
2763
- import ${JSON.stringify(styleRequest)}`;
2764
- }
2765
- }
2766
- }
2767
- if (customElement) {
2768
- attachedProps.push([
2769
- `styles`,
2770
- `[${descriptor.styles.map((_, i) => `_style_${i}`).join(",")}]`
2771
- ]);
2772
- }
2773
- }
2774
- if (cssModulesMap) {
2775
- const mappingCode = Object.entries(cssModulesMap).reduce(
2776
- (code, [key, value]) => code + `"${key}":${value},
2777
- `,
2778
- "{\n"
2779
- ) + "}";
2780
- stylesCode += `
2781
- const cssModules = ${mappingCode}`;
2782
- attachedProps.push([`__cssModules`, `cssModules`]);
2783
- }
2784
- return stylesCode;
2785
- }
2786
- function genCSSModulesCode(index, request, moduleName) {
2787
- const styleVar = `style${index}`;
2788
- const exposedName = typeof moduleName === "string" ? moduleName : "$style";
2789
- const moduleRequest = request.replace(/\.(\w+)$/, ".module.$1");
2790
- return [
2791
- `
2792
- import ${styleVar} from ${JSON.stringify(moduleRequest)}`,
2793
- { [exposedName]: styleVar }
2794
- ];
2795
- }
2796
- async function genCustomBlockCode(descriptor, pluginContext) {
2797
- let code = "";
2798
- for (let index = 0; index < descriptor.customBlocks.length; index++) {
2799
- const block = descriptor.customBlocks[index];
2800
- if (block.src) {
2801
- await linkSrcToDescriptor(block.src, descriptor, pluginContext, false);
2802
- }
2803
- const src = block.src || descriptor.filename;
2804
- const attrsQuery = attrsToQuery(block.attrs, block.type);
2805
- const srcQuery = block.src ? `&src=true` : ``;
2806
- const query = `?vue&type=${block.type}&index=${index}${srcQuery}${attrsQuery}`;
2807
- const request = JSON.stringify(src + query);
2808
- code += `import block${index} from ${request}
2809
- `;
2810
- code += `if (typeof block${index} === 'function') block${index}(_sfc_main)
2811
- `;
2812
- }
2813
- return code;
2814
- }
2815
- async function linkSrcToDescriptor(src, descriptor, pluginContext, scoped) {
2816
- const srcFile = (await pluginContext.resolve(src, descriptor.filename))?.id || src;
2817
- setSrcDescriptor(srcFile.replace(/\?.*$/, ""), descriptor, scoped);
2818
- }
2819
- const ignoreList = [
2820
- "id",
2821
- "index",
2822
- "src",
2823
- "type",
2824
- "lang",
2825
- "module",
2826
- "scoped",
2827
- "generic"
2828
- ];
2829
- function attrsToQuery(attrs, langFallback, forceLangFallback = false) {
2830
- let query = ``;
2831
- for (const name in attrs) {
2832
- const value = attrs[name];
2833
- if (!ignoreList.includes(name)) {
2834
- query += `&${encodeURIComponent(name)}${value ? `=${encodeURIComponent(value)}` : ``}`;
2835
- }
2836
- }
2837
- if (langFallback || attrs.lang) {
2838
- query += `lang` in attrs ? forceLangFallback ? `&lang.${langFallback}` : `&lang.${attrs.lang}` : `&lang.${langFallback}`;
2839
- }
2840
- return query;
2841
- }
2842
-
2843
- async function transformStyle(code, descriptor, index, options, pluginContext, filename) {
2844
- const block = descriptor.styles[index];
2845
- const result = await options.compiler.compileStyleAsync({
2846
- ...options.style,
2847
- filename: descriptor.filename,
2848
- id: `data-v-${descriptor.id}`,
2849
- isProd: options.isProduction,
2850
- source: code,
2851
- scoped: block.scoped,
2852
- ...options.cssDevSourcemap ? {
2853
- postcssOptions: {
2854
- map: {
2855
- from: filename,
2856
- inline: false,
2857
- annotation: false
2858
- }
2859
- }
2860
- } : {}
2861
- });
2862
- if (result.errors.length) {
2863
- result.errors.forEach((error) => {
2864
- if (error.line && error.column) {
2865
- error.loc = {
2866
- file: descriptor.filename,
2867
- line: error.line + block.loc.start.line,
2868
- column: error.column
2869
- };
2870
- }
2871
- pluginContext.error(error);
2872
- });
2873
- return null;
2874
- }
2875
- const map = result.map ? await vite.formatPostcssSourceMap(
2876
- // version property of result.map is declared as string
2877
- // but actually it is a number
2878
- result.map,
2879
- filename
2880
- ) : { mappings: "" };
2881
- return {
2882
- code: result.code,
2883
- map,
2884
- meta: block.scoped && !descriptor.isTemp ? {
2885
- vite: {
2886
- cssScopeTo: [descriptor.filename, "default"]
2887
- }
2888
- } : void 0
2889
- };
2890
- }
2891
-
2892
- function vuePlugin(rawOptions = {}) {
2893
- clearScriptCache();
2894
- const options = vue.shallowRef({
2895
- isProduction: process.env.NODE_ENV === "production",
2896
- compiler: null,
2897
- // to be set in buildStart
2898
- include: /\.vue$/,
2899
- customElement: /\.ce\.vue$/,
2900
- ...rawOptions,
2901
- root: process.cwd(),
2902
- sourceMap: true,
2903
- cssDevSourcemap: false
2904
- });
2905
- const filter = vue.computed(
2906
- () => vite.createFilter(options.value.include, options.value.exclude)
2907
- );
2908
- const customElementFilter = vue.computed(() => {
2909
- const customElement = options.value.features?.customElement || options.value.customElement;
2910
- return typeof customElement === "boolean" ? () => customElement : vite.createFilter(customElement);
2911
- });
2912
- let transformCachedModule = false;
2913
- return {
2914
- name: "vite:vue",
2915
- api: {
2916
- get options() {
2917
- return options.value;
2918
- },
2919
- set options(value) {
2920
- options.value = value;
2921
- },
2922
- version
2923
- },
2924
- handleHotUpdate(ctx) {
2925
- ctx.server.ws.send({
2926
- type: "custom",
2927
- event: "file-changed",
2928
- data: { file: vite.normalizePath(ctx.file) }
2929
- });
2930
- if (options.value.compiler.invalidateTypeCache) {
2931
- options.value.compiler.invalidateTypeCache(ctx.file);
2932
- }
2933
- let typeDepModules;
2934
- const matchesFilter = filter.value(ctx.file);
2935
- if (typeDepToSFCMap.has(ctx.file)) {
2936
- typeDepModules = handleTypeDepChange(
2937
- typeDepToSFCMap.get(ctx.file),
2938
- ctx
2939
- );
2940
- if (!matchesFilter) return typeDepModules;
2941
- }
2942
- if (matchesFilter) {
2943
- return handleHotUpdate(
2944
- ctx,
2945
- options.value,
2946
- customElementFilter.value(ctx.file),
2947
- typeDepModules
2948
- );
2949
- }
2950
- },
2951
- config(config) {
2952
- const parseDefine = (v) => {
2953
- try {
2954
- return typeof v === "string" ? JSON.parse(v) : v;
2955
- } catch (err) {
2956
- return v;
2957
- }
2958
- };
2959
- return {
2960
- resolve: {
2961
- dedupe: config.build?.ssr ? [] : ["vue"]
2962
- },
2963
- define: {
2964
- __VUE_OPTIONS_API__: options.value.features?.optionsAPI ?? parseDefine(config.define?.__VUE_OPTIONS_API__) ?? true,
2965
- __VUE_PROD_DEVTOOLS__: (options.value.features?.prodDevtools || parseDefine(config.define?.__VUE_PROD_DEVTOOLS__)) ?? false,
2966
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: (options.value.features?.prodHydrationMismatchDetails || parseDefine(
2967
- config.define?.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__
2968
- )) ?? false
2969
- },
2970
- ssr: {
2971
- // @ts-ignore -- config.legacy.buildSsrCjsExternalHeuristics will be removed in Vite 5
2972
- external: config.legacy?.buildSsrCjsExternalHeuristics ? ["vue", "@vue/server-renderer"] : []
2973
- }
2974
- };
2975
- },
2976
- configResolved(config) {
2977
- options.value = {
2978
- ...options.value,
2979
- root: config.root,
2980
- sourceMap: config.command === "build" ? !!config.build.sourcemap : true,
2981
- cssDevSourcemap: config.css?.devSourcemap ?? false,
2982
- isProduction: config.isProduction,
2983
- devToolsEnabled: !!(options.value.features?.prodDevtools || config.define.__VUE_PROD_DEVTOOLS__ || !config.isProduction)
2984
- };
2985
- const _warn = config.logger.warn;
2986
- config.logger.warn = (...args) => {
2987
- const msg = args[0];
2988
- if (msg.match(
2989
- /\[lightningcss\] '(deep|slotted|global)' is not recognized as a valid pseudo-/
2990
- )) {
2991
- return;
2992
- }
2993
- _warn(...args);
2994
- };
2995
- transformCachedModule = config.command === "build" && options.value.sourceMap && config.build.watch != null;
2996
- },
2997
- shouldTransformCachedModule({ id }) {
2998
- if (transformCachedModule && parseVueRequest(id).query.vue) {
2999
- return true;
3000
- }
3001
- return false;
3002
- },
3003
- configureServer(server) {
3004
- options.value.devServer = server;
3005
- },
3006
- buildStart() {
3007
- const compiler = options.value.compiler = options.value.compiler || resolveCompiler(options.value.root);
3008
- if (compiler.invalidateTypeCache) {
3009
- options.value.devServer?.watcher.on("unlink", (file) => {
3010
- compiler.invalidateTypeCache(file);
3011
- });
3012
- }
3013
- },
3014
- async resolveId(id) {
3015
- if (id === EXPORT_HELPER_ID) {
3016
- return id;
3017
- }
3018
- if (parseVueRequest(id).query.vue) {
3019
- return id;
3020
- }
3021
- },
3022
- load(id, opt) {
3023
- if (id === EXPORT_HELPER_ID) {
3024
- return helperCode;
3025
- }
3026
- const ssr = opt?.ssr === true;
3027
- const { filename, query } = parseVueRequest(id);
3028
- if (query.vue) {
3029
- if (query.src) {
3030
- return fs__default.readFileSync(filename, "utf-8");
3031
- }
3032
- const descriptor = getDescriptor(filename, options.value);
3033
- let block;
3034
- if (query.type === "script") {
3035
- block = resolveScript(
3036
- descriptor,
3037
- options.value,
3038
- ssr,
3039
- customElementFilter.value(filename)
3040
- );
3041
- } else if (query.type === "template") {
3042
- block = descriptor.template;
3043
- } else if (query.type === "style") {
3044
- block = descriptor.styles[query.index];
3045
- } else if (query.index != null) {
3046
- block = descriptor.customBlocks[query.index];
3047
- }
3048
- if (block) {
3049
- return {
3050
- code: block.content,
3051
- map: block.map
3052
- };
3053
- }
3054
- }
3055
- },
3056
- transform(code, id, opt) {
3057
- const ssr = opt?.ssr === true;
3058
- const { filename, query } = parseVueRequest(id);
3059
- if (query.raw || query.url) {
3060
- return;
3061
- }
3062
- if (!filter.value(filename) && !query.vue) {
3063
- return;
3064
- }
3065
- if (!query.vue) {
3066
- return transformMain(
3067
- code,
3068
- filename,
3069
- options.value,
3070
- this,
3071
- ssr,
3072
- customElementFilter.value(filename)
3073
- );
3074
- } else {
3075
- const descriptor = query.src ? getSrcDescriptor(filename, query) || getTempSrcDescriptor(filename, query) : getDescriptor(filename, options.value);
3076
- if (query.src) {
3077
- this.addWatchFile(filename);
3078
- }
3079
- if (query.type === "template") {
3080
- return transformTemplateAsModule(
3081
- code,
3082
- descriptor,
3083
- options.value,
3084
- this,
3085
- ssr,
3086
- customElementFilter.value(filename)
3087
- );
3088
- } else if (query.type === "style") {
3089
- return transformStyle(
3090
- code,
3091
- descriptor,
3092
- Number(query.index || 0),
3093
- options.value,
3094
- this,
3095
- filename
3096
- );
3097
- }
3098
- }
3099
- }
3100
- };
3101
- }
3102
-
3103
- module.exports = vuePlugin;
3104
- module.exports.default = vuePlugin;
3105
- module.exports.parseVueRequest = parseVueRequest;