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