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