@dcloudio/uni-cli-shared 3.0.0-alpha-3040820220424003 → 3.0.0-alpha-3040920220508001
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checkUpdate.js +1 -11
- package/dist/env/define.d.ts +0 -2
- package/dist/env/define.js +0 -2
- package/dist/vite/plugins/vitejs/plugins/asset.d.ts +1 -1
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +2 -4
- package/dist/vite/plugins/vitejs/plugins/css.js +38 -189
- package/dist/vite/plugins/vitejs/utils.d.ts +0 -3
- package/dist/vite/plugins/vitejs/utils.js +6 -78
- package/package.json +5 -11
- package/dist/vite/plugins/vitejs/cleanString.d.ts +0 -1
- package/dist/vite/plugins/vitejs/cleanString.js +0 -9
- package/lib/.DS_Store +0 -0
- package/lib/vue-i18n/.DS_Store +0 -0
package/dist/checkUpdate.js
CHANGED
|
@@ -147,17 +147,7 @@ function getMac() {
|
|
|
147
147
|
if (!item.family || (item.mac && item.mac === '00:00:00:00:00:00')) {
|
|
148
148
|
continue;
|
|
149
149
|
}
|
|
150
|
-
if (
|
|
151
|
-
// Node < v18
|
|
152
|
-
typeof item.family === 'string' &&
|
|
153
|
-
(item.family === 'IPv4' || item.family === 'IPv6')) {
|
|
154
|
-
mac = item.mac;
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
else if (
|
|
158
|
-
// Node >= v18
|
|
159
|
-
typeof item.family === 'number' &&
|
|
160
|
-
(item.family === 4 || item.family === 6)) {
|
|
150
|
+
if (item.family === 'IPv4' || item.family === 'IPv6') {
|
|
161
151
|
mac = item.mac;
|
|
162
152
|
break;
|
|
163
153
|
}
|
package/dist/env/define.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ export declare function initDefine(stringifyBoolean?: boolean): {
|
|
|
3
3
|
'process.env.UNI_DEBUG': string | boolean;
|
|
4
4
|
'process.env.UNI_APP_ID': string;
|
|
5
5
|
'process.env.UNI_APP_NAME': string;
|
|
6
|
-
'process.env.UNI_APP_VERSION_NAME': string;
|
|
7
|
-
'process.env.UNI_APP_VERSION_CODE': string;
|
|
8
6
|
'process.env.UNI_PLATFORM': string;
|
|
9
7
|
'process.env.UNI_MP_PLUGIN': string;
|
|
10
8
|
'process.env.UNI_SUBPACKAGE': string;
|
package/dist/env/define.js
CHANGED
|
@@ -15,8 +15,6 @@ function initDefine(stringifyBoolean = false) {
|
|
|
15
15
|
: isDebug,
|
|
16
16
|
'process.env.UNI_APP_ID': JSON.stringify(manifestJson.appid || ''),
|
|
17
17
|
'process.env.UNI_APP_NAME': JSON.stringify(manifestJson.name || ''),
|
|
18
|
-
'process.env.UNI_APP_VERSION_NAME': JSON.stringify(manifestJson.versionName || ''),
|
|
19
|
-
'process.env.UNI_APP_VERSION_CODE': JSON.stringify(manifestJson.versionCode || ''),
|
|
20
18
|
'process.env.UNI_PLATFORM': JSON.stringify(process.env.UNI_PLATFORM),
|
|
21
19
|
'process.env.UNI_MP_PLUGIN': JSON.stringify(process.env.UNI_MP_PLUGIN),
|
|
22
20
|
'process.env.UNI_SUBPACKAGE': JSON.stringify(process.env.UNI_SUBPACKAGE),
|
|
@@ -36,5 +36,5 @@ export declare function getAssetFilename(hash: string, config: ResolvedConfig):
|
|
|
36
36
|
* @returns output filename
|
|
37
37
|
*/
|
|
38
38
|
export declare function assetFileNamesToFileName(assetFileNames: Exclude<OutputOptions['assetFileNames'], undefined>, file: string, contentHash: string, content: string | Buffer): string;
|
|
39
|
-
export declare function getAssetHash(content: Buffer
|
|
39
|
+
export declare function getAssetHash(content: Buffer): string;
|
|
40
40
|
export declare function urlToBuiltUrl(url: string, importer: string, config: ResolvedConfig, pluginContext: PluginContext): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RollupError } from 'rollup';
|
|
2
2
|
import { Plugin } from '../plugin';
|
|
3
3
|
import { ResolvedConfig } from '../config';
|
|
4
4
|
import * as Postcss from 'postcss';
|
|
@@ -38,14 +38,12 @@ export declare function cssPostPlugin(config: ResolvedConfig, { chunkCssFilename
|
|
|
38
38
|
chunkCssFilename: (id: string) => string | void;
|
|
39
39
|
chunkCssCode: (filename: string, cssCode: string) => Promise<string> | string;
|
|
40
40
|
}): Plugin;
|
|
41
|
-
export declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): ExistingRawSourceMap;
|
|
42
41
|
export declare const cssUrlRE: RegExp;
|
|
43
42
|
export declare function minifyCSS(css: string, config: ResolvedConfig): Promise<string>;
|
|
44
43
|
export declare function hoistAtRules(css: string): Promise<string>;
|
|
45
44
|
export interface StylePreprocessorResults {
|
|
46
45
|
code: string;
|
|
47
|
-
map?:
|
|
48
|
-
additionalMap?: ExistingRawSourceMap | undefined;
|
|
46
|
+
map?: object;
|
|
49
47
|
errors: RollupError[];
|
|
50
48
|
deps: string[];
|
|
51
49
|
}
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.hoistAtRules = exports.minifyCSS = exports.cssUrlRE = exports.
|
|
29
|
+
exports.hoistAtRules = exports.minifyCSS = exports.cssUrlRE = exports.cssPostPlugin = exports.cssPlugin = exports.isDirectCSSRequest = exports.isCSSRequest = exports.commonjsProxyRE = exports.cssLangRE = void 0;
|
|
30
30
|
const fs_1 = __importDefault(require("fs"));
|
|
31
31
|
const path_1 = __importDefault(require("path"));
|
|
32
32
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
@@ -39,13 +39,11 @@ const magic_string_1 = __importDefault(require("magic-string"));
|
|
|
39
39
|
const esbuild_1 = require("esbuild");
|
|
40
40
|
const preprocess_1 = require("../../../../preprocess");
|
|
41
41
|
const constants_1 = require("../../../../constants");
|
|
42
|
-
const cleanString_1 = require("../cleanString");
|
|
43
42
|
const cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
|
|
44
43
|
exports.cssLangRE = new RegExp(cssLangs);
|
|
45
44
|
const cssModuleRE = new RegExp(`\\.module${cssLangs}`);
|
|
46
45
|
const directRequestRE = /(\?|&)direct\b/;
|
|
47
46
|
exports.commonjsProxyRE = /\?commonjs-proxy/;
|
|
48
|
-
const varRE = /^var\(/i;
|
|
49
47
|
const isCSSRequest = (request) => exports.cssLangRE.test(request) && !directRequestRE.test(request);
|
|
50
48
|
exports.isCSSRequest = isCSSRequest;
|
|
51
49
|
const isDirectCSSRequest = (request) => exports.cssLangRE.test(request) && directRequestRE.test(request);
|
|
@@ -255,7 +253,7 @@ function getCssResolversKeys(resolvers) {
|
|
|
255
253
|
}
|
|
256
254
|
async function compileCSS(id, code, config, urlReplacer, atImportResolvers, server) {
|
|
257
255
|
var _a;
|
|
258
|
-
const { modules: modulesOptions, preprocessorOptions
|
|
256
|
+
const { modules: modulesOptions, preprocessorOptions } = config.css || {};
|
|
259
257
|
const isModule = modulesOptions !== false && cssModuleRE.test(id);
|
|
260
258
|
// although at serve time it can work without processing, we do need to
|
|
261
259
|
// crawl them in order to register watch dependencies.
|
|
@@ -269,9 +267,9 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
269
267
|
!isModule &&
|
|
270
268
|
!needInlineImport &&
|
|
271
269
|
!hasUrl) {
|
|
272
|
-
return { code
|
|
270
|
+
return { code };
|
|
273
271
|
}
|
|
274
|
-
let
|
|
272
|
+
let map;
|
|
275
273
|
let modules;
|
|
276
274
|
const deps = new Set();
|
|
277
275
|
// 2. pre-processors: sass etc.
|
|
@@ -299,13 +297,12 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
299
297
|
}
|
|
300
298
|
// important: set this for relative import resolving
|
|
301
299
|
opts.filename = (0, utils_1.cleanUrl)(id);
|
|
302
|
-
opts.enableSourcemap = devSourcemap !== null && devSourcemap !== void 0 ? devSourcemap : false;
|
|
303
300
|
const preprocessResult = await preProcessor(code, config.root, opts, atImportResolvers, !!config.nvue);
|
|
304
301
|
if (preprocessResult.errors.length) {
|
|
305
302
|
throw preprocessResult.errors[0];
|
|
306
303
|
}
|
|
307
304
|
code = preprocessResult.code;
|
|
308
|
-
|
|
305
|
+
map = preprocessResult.map;
|
|
309
306
|
if (preprocessResult.deps) {
|
|
310
307
|
preprocessResult.deps.forEach((dep) => {
|
|
311
308
|
// sometimes sass registers the file itself as a dep
|
|
@@ -321,10 +318,6 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
321
318
|
if (needInlineImport) {
|
|
322
319
|
postcssPlugins.unshift((await Promise.resolve().then(() => __importStar(require('postcss-import')))).default({
|
|
323
320
|
async resolve(id, basedir) {
|
|
324
|
-
// const publicFile = checkPublicFile(id, config)
|
|
325
|
-
// if (publicFile) {
|
|
326
|
-
// return publicFile
|
|
327
|
-
// }
|
|
328
321
|
const resolved = await atImportResolvers.css(id, path_1.default.join(basedir, '*'));
|
|
329
322
|
if (resolved) {
|
|
330
323
|
return path_1.default.resolve(resolved);
|
|
@@ -359,7 +352,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
359
352
|
if (!postcssPlugins.length) {
|
|
360
353
|
return {
|
|
361
354
|
code,
|
|
362
|
-
map
|
|
355
|
+
map,
|
|
363
356
|
};
|
|
364
357
|
}
|
|
365
358
|
// postcss is an unbundled dep and should be lazy imported
|
|
@@ -372,17 +365,13 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
372
365
|
map: {
|
|
373
366
|
inline: false,
|
|
374
367
|
annotation: false,
|
|
375
|
-
|
|
376
|
-
// we cannot obtain content of them, so this needs to be enabled
|
|
377
|
-
sourcesContent: true,
|
|
378
|
-
// when "prev: preprocessorMap", the result map may include duplicate filename in `postcssResult.map.sources`
|
|
379
|
-
// prev: preprocessorMap,
|
|
368
|
+
prev: map,
|
|
380
369
|
},
|
|
381
370
|
});
|
|
382
371
|
// record CSS dependencies from @imports
|
|
383
372
|
for (const message of postcssResult.messages) {
|
|
384
373
|
if (message.type === 'dependency') {
|
|
385
|
-
deps.add(
|
|
374
|
+
deps.add(message.file);
|
|
386
375
|
}
|
|
387
376
|
else if (message.type === 'dir-dependency') {
|
|
388
377
|
// https://github.com/postcss/postcss/blob/main/docs/guidelines/plugin.md#3-dependencies
|
|
@@ -421,58 +410,14 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
421
410
|
config.logger.warn(picocolors_1.default.yellow(msg));
|
|
422
411
|
}
|
|
423
412
|
}
|
|
424
|
-
if (!devSourcemap) {
|
|
425
|
-
return {
|
|
426
|
-
ast: postcssResult,
|
|
427
|
-
code: postcssResult.css,
|
|
428
|
-
map: { mappings: '' },
|
|
429
|
-
modules,
|
|
430
|
-
deps,
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
const rawPostcssMap = postcssResult.map.toJSON();
|
|
434
|
-
const postcssMap = formatPostcssSourceMap(
|
|
435
|
-
// version property of rawPostcssMap is declared as string
|
|
436
|
-
// but actually it is a number
|
|
437
|
-
rawPostcssMap, (0, utils_1.cleanUrl)(id));
|
|
438
413
|
return {
|
|
439
414
|
ast: postcssResult,
|
|
440
415
|
code: postcssResult.css,
|
|
441
|
-
map:
|
|
416
|
+
map: postcssResult.map,
|
|
442
417
|
modules,
|
|
443
418
|
deps,
|
|
444
419
|
};
|
|
445
420
|
}
|
|
446
|
-
function formatPostcssSourceMap(rawMap, file) {
|
|
447
|
-
const inputFileDir = path_1.default.dirname(file);
|
|
448
|
-
const sources = rawMap.sources.map((source) => {
|
|
449
|
-
const cleanSource = (0, utils_1.cleanUrl)(decodeURIComponent(source));
|
|
450
|
-
// postcss returns virtual files
|
|
451
|
-
if (/^<.+>$/.test(cleanSource)) {
|
|
452
|
-
return `\0${cleanSource}`;
|
|
453
|
-
}
|
|
454
|
-
return (0, utils_1.normalizePath)(path_1.default.resolve(inputFileDir, cleanSource));
|
|
455
|
-
});
|
|
456
|
-
return {
|
|
457
|
-
file,
|
|
458
|
-
mappings: rawMap.mappings,
|
|
459
|
-
names: rawMap.names,
|
|
460
|
-
sources,
|
|
461
|
-
sourcesContent: rawMap.sourcesContent,
|
|
462
|
-
version: rawMap.version,
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
exports.formatPostcssSourceMap = formatPostcssSourceMap;
|
|
466
|
-
function combineSourcemapsIfExists(filename, map1, map2) {
|
|
467
|
-
return map1 && map2
|
|
468
|
-
? (0, utils_1.combineSourcemaps)(filename, [
|
|
469
|
-
// type of version property of ExistingRawSourceMap is number
|
|
470
|
-
// but it is always 3
|
|
471
|
-
map1,
|
|
472
|
-
map2,
|
|
473
|
-
])
|
|
474
|
-
: map1;
|
|
475
|
-
}
|
|
476
421
|
async function resolvePostcssConfig(config) {
|
|
477
422
|
var _a;
|
|
478
423
|
let result = postcssConfigCache.get(config);
|
|
@@ -490,23 +435,14 @@ async function resolvePostcssConfig(config) {
|
|
|
490
435
|
};
|
|
491
436
|
}
|
|
492
437
|
else {
|
|
493
|
-
const searchPath = typeof inlineOptions === 'string' ? inlineOptions : config.root;
|
|
494
438
|
try {
|
|
439
|
+
const searchPath = typeof inlineOptions === 'string' ? inlineOptions : config.root;
|
|
495
440
|
// @ts-ignore
|
|
496
441
|
result = await (0, postcss_load_config_1.default)({}, searchPath);
|
|
497
442
|
}
|
|
498
443
|
catch (e) {
|
|
499
444
|
if (!/No PostCSS Config found/.test(e.message)) {
|
|
500
|
-
|
|
501
|
-
const { name, message, stack } = e;
|
|
502
|
-
e.name = 'Failed to load PostCSS config';
|
|
503
|
-
e.message = `Failed to load PostCSS config (searchPath: ${searchPath}): [${name}] ${message}\n${stack}`;
|
|
504
|
-
e.stack = ''; // add stack to message to retain stack
|
|
505
|
-
throw e;
|
|
506
|
-
}
|
|
507
|
-
else {
|
|
508
|
-
throw new Error(`Failed to load PostCSS config: ${e}`);
|
|
509
|
-
}
|
|
445
|
+
throw e;
|
|
510
446
|
}
|
|
511
447
|
result = null;
|
|
512
448
|
}
|
|
@@ -516,7 +452,7 @@ async function resolvePostcssConfig(config) {
|
|
|
516
452
|
}
|
|
517
453
|
// https://drafts.csswg.org/css-syntax-3/#identifier-code-point
|
|
518
454
|
exports.cssUrlRE = /(?<=^|[^\w\-\u0080-\uffff])url\(\s*('[^']+'|"[^"]+"|[^'")]+)\s*\)/;
|
|
519
|
-
const cssImageSetRE = /
|
|
455
|
+
const cssImageSetRE = /image-set\(([^)]+)\)/;
|
|
520
456
|
const UrlRewritePostcssPlugin = (opts) => {
|
|
521
457
|
if (!opts) {
|
|
522
458
|
throw new Error('base or replace is required');
|
|
@@ -534,9 +470,7 @@ const UrlRewritePostcssPlugin = (opts) => {
|
|
|
534
470
|
const importer = (_a = declaration.source) === null || _a === void 0 ? void 0 : _a.input.file;
|
|
535
471
|
return opts.replacer(rawUrl, importer);
|
|
536
472
|
};
|
|
537
|
-
const rewriterToUse =
|
|
538
|
-
? rewriteCssImageSet
|
|
539
|
-
: rewriteCssUrls;
|
|
473
|
+
const rewriterToUse = isCssUrl ? rewriteCssUrls : rewriteCssImageSet;
|
|
540
474
|
promises.push(rewriterToUse(declaration.value, replacerForDeclaration).then((url) => {
|
|
541
475
|
declaration.value = url;
|
|
542
476
|
}));
|
|
@@ -550,16 +484,9 @@ const UrlRewritePostcssPlugin = (opts) => {
|
|
|
550
484
|
};
|
|
551
485
|
UrlRewritePostcssPlugin.postcss = true;
|
|
552
486
|
function rewriteCssUrls(css, replacer) {
|
|
553
|
-
return (0, utils_1.asyncReplace)(css,
|
|
554
|
-
const [, rawUrl] = match;
|
|
555
|
-
|
|
556
|
-
// the url maybe url(...)
|
|
557
|
-
if (exports.cssUrlRE.test(url)) {
|
|
558
|
-
return await rewriteCssUrls(url, replacer);
|
|
559
|
-
}
|
|
560
|
-
return await doUrlReplace(url, url, replacer);
|
|
561
|
-
});
|
|
562
|
-
return url;
|
|
487
|
+
return (0, utils_1.asyncReplace)(css, exports.cssUrlRE, async (match) => {
|
|
488
|
+
const [matched, rawUrl] = match;
|
|
489
|
+
return await doUrlReplace(rawUrl, matched, replacer);
|
|
563
490
|
});
|
|
564
491
|
}
|
|
565
492
|
function rewriteCssImageSet(css, replacer) {
|
|
@@ -576,10 +503,7 @@ async function doUrlReplace(rawUrl, matched, replacer) {
|
|
|
576
503
|
wrap = first;
|
|
577
504
|
rawUrl = rawUrl.slice(1, -1);
|
|
578
505
|
}
|
|
579
|
-
if ((0, utils_1.isExternalUrl)(rawUrl) ||
|
|
580
|
-
(0, utils_1.isDataUrl)(rawUrl) ||
|
|
581
|
-
rawUrl.startsWith('#') ||
|
|
582
|
-
varRE.test(rawUrl)) {
|
|
506
|
+
if ((0, utils_1.isExternalUrl)(rawUrl) || (0, utils_1.isDataUrl)(rawUrl) || rawUrl.startsWith('#')) {
|
|
583
507
|
return matched;
|
|
584
508
|
}
|
|
585
509
|
return `url(${wrap}${await replacer(rawUrl)}${wrap})`;
|
|
@@ -609,29 +533,24 @@ async function minifyCSS(css, config) {
|
|
|
609
533
|
exports.minifyCSS = minifyCSS;
|
|
610
534
|
async function hoistAtRules(css) {
|
|
611
535
|
const s = new magic_string_1.default(css);
|
|
612
|
-
const cleanCss = (0, cleanString_1.emptyCssComments)(css);
|
|
613
|
-
let match;
|
|
614
536
|
// #1845
|
|
615
537
|
// CSS @import can only appear at top of the file. We need to hoist all @import
|
|
616
538
|
// to top when multiple files are concatenated.
|
|
617
539
|
// match until semicolon that's not in quotes
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
s.appendLeft(0, match[0]);
|
|
623
|
-
}
|
|
540
|
+
s.replace(/@import\s*(?:url\([^\)]*\)|"[^"]*"|'[^']*'|[^;]*).*?;/gm, (match) => {
|
|
541
|
+
s.appendLeft(0, match);
|
|
542
|
+
return '';
|
|
543
|
+
});
|
|
624
544
|
// #6333
|
|
625
545
|
// CSS @charset must be the top-first in the file, hoist the first to top
|
|
626
|
-
const atCharsetRE = /@charset\s*(?:"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|[^;]*).*?;/gm;
|
|
627
546
|
let foundCharset = false;
|
|
628
|
-
|
|
629
|
-
s.remove(match.index, match.index + match[0].length);
|
|
547
|
+
s.replace(/@charset\s*(?:"[^"]*"|'[^']*'|[^;]*).*?;/gm, (match) => {
|
|
630
548
|
if (!foundCharset) {
|
|
631
|
-
s.prepend(match
|
|
549
|
+
s.prepend(match);
|
|
632
550
|
foundCharset = true;
|
|
633
551
|
}
|
|
634
|
-
|
|
552
|
+
return '';
|
|
553
|
+
});
|
|
635
554
|
return s.toString();
|
|
636
555
|
}
|
|
637
556
|
exports.hoistAtRules = hoistAtRules;
|
|
@@ -658,12 +577,10 @@ const scss = async (source, root, options, resolvers, isNVue) => {
|
|
|
658
577
|
const internalImporter = (url, importer, done) => {
|
|
659
578
|
resolvers.sass(url, importer).then((resolved) => {
|
|
660
579
|
if (resolved) {
|
|
661
|
-
rebaseUrls(resolved, options.filename, options.alias, isNVue)
|
|
662
|
-
.then((data) => done === null || done === void 0 ? void 0 : done(data))
|
|
663
|
-
.catch((data) => done === null || done === void 0 ? void 0 : done(data));
|
|
580
|
+
rebaseUrls(resolved, options.filename, options.alias, isNVue).then(done);
|
|
664
581
|
}
|
|
665
582
|
else {
|
|
666
|
-
done
|
|
583
|
+
done && done(null);
|
|
667
584
|
}
|
|
668
585
|
});
|
|
669
586
|
};
|
|
@@ -673,20 +590,12 @@ const scss = async (source, root, options, resolvers, isNVue) => {
|
|
|
673
590
|
? importer.push(...options.importer)
|
|
674
591
|
: importer.push(options.importer);
|
|
675
592
|
}
|
|
676
|
-
const { content: data, map: additionalMap } = await getSource(source, options.filename, options.additionalData, options.enableSourcemap);
|
|
677
593
|
const finalOptions = {
|
|
678
594
|
...options,
|
|
679
|
-
data,
|
|
595
|
+
data: await getSource(source, options.filename, options.additionalData),
|
|
680
596
|
file: options.filename,
|
|
681
597
|
outFile: options.filename,
|
|
682
598
|
importer,
|
|
683
|
-
...(options.enableSourcemap
|
|
684
|
-
? {
|
|
685
|
-
sourceMap: true,
|
|
686
|
-
omitSourceMapUrl: true,
|
|
687
|
-
sourceMapRoot: path_1.default.dirname(options.filename),
|
|
688
|
-
}
|
|
689
|
-
: {}),
|
|
690
599
|
};
|
|
691
600
|
try {
|
|
692
601
|
const result = await new Promise((resolve, reject) => {
|
|
@@ -700,13 +609,8 @@ const scss = async (source, root, options, resolvers, isNVue) => {
|
|
|
700
609
|
});
|
|
701
610
|
});
|
|
702
611
|
const deps = result.stats.includedFiles;
|
|
703
|
-
const map = result.map
|
|
704
|
-
? JSON.parse(result.map.toString())
|
|
705
|
-
: undefined;
|
|
706
612
|
return {
|
|
707
613
|
code: result.css.toString(),
|
|
708
|
-
map,
|
|
709
|
-
additionalMap,
|
|
710
614
|
errors: [],
|
|
711
615
|
deps,
|
|
712
616
|
};
|
|
@@ -769,20 +673,12 @@ async function rebaseUrls(file, rootFile, alias, isNVue = false) {
|
|
|
769
673
|
const less = async (source, root, options, resolvers, isNVue) => {
|
|
770
674
|
const nodeLess = loadPreprocessor("less" /* less */, root);
|
|
771
675
|
const viteResolverPlugin = createViteLessPlugin(nodeLess, options.filename, options.alias, resolvers, isNVue);
|
|
772
|
-
|
|
676
|
+
source = await getSource(source, options.filename, options.additionalData);
|
|
773
677
|
let result;
|
|
774
678
|
try {
|
|
775
|
-
result = await nodeLess.render(
|
|
679
|
+
result = await nodeLess.render(source, {
|
|
776
680
|
...options,
|
|
777
681
|
plugins: [viteResolverPlugin, ...(options.plugins || [])],
|
|
778
|
-
...(options.enableSourcemap
|
|
779
|
-
? {
|
|
780
|
-
sourceMap: {
|
|
781
|
-
outputSourceFiles: true,
|
|
782
|
-
sourceMapFileInline: false,
|
|
783
|
-
},
|
|
784
|
-
}
|
|
785
|
-
: {}),
|
|
786
682
|
});
|
|
787
683
|
}
|
|
788
684
|
catch (e) {
|
|
@@ -796,14 +692,8 @@ const less = async (source, root, options, resolvers, isNVue) => {
|
|
|
796
692
|
};
|
|
797
693
|
return { code: '', errors: [normalizedError], deps: [] };
|
|
798
694
|
}
|
|
799
|
-
const map = result.map && JSON.parse(result.map);
|
|
800
|
-
if (map) {
|
|
801
|
-
delete map.sourcesContent;
|
|
802
|
-
}
|
|
803
695
|
return {
|
|
804
696
|
code: result.css.toString(),
|
|
805
|
-
map,
|
|
806
|
-
additionalMap,
|
|
807
697
|
deps: result.imports,
|
|
808
698
|
errors: [],
|
|
809
699
|
};
|
|
@@ -862,70 +752,29 @@ const styl = async (source, root, options) => {
|
|
|
862
752
|
const nodeStylus = loadPreprocessor("stylus" /* stylus */, root);
|
|
863
753
|
// Get source with preprocessor options.additionalData. Make sure a new line separator
|
|
864
754
|
// is added to avoid any render error, as added stylus content may not have semi-colon separators
|
|
865
|
-
|
|
755
|
+
source = await getSource(source, options.filename, options.additionalData, '\n');
|
|
866
756
|
// Get preprocessor options.imports dependencies as stylus
|
|
867
757
|
// does not return them with its builtin `.deps()` method
|
|
868
758
|
const importsDeps = ((_a = options.imports) !== null && _a !== void 0 ? _a : []).map((dep) => path_1.default.resolve(dep));
|
|
869
759
|
try {
|
|
870
|
-
const ref = nodeStylus(
|
|
871
|
-
if (
|
|
872
|
-
ref.set('sourcemap', {
|
|
873
|
-
comment: false,
|
|
874
|
-
inline: false,
|
|
875
|
-
basePath: root,
|
|
876
|
-
});
|
|
877
|
-
}
|
|
760
|
+
const ref = nodeStylus(source, options);
|
|
761
|
+
// if (map) ref.set('sourcemap', { inline: false, comment: false })
|
|
878
762
|
const result = ref.render();
|
|
879
763
|
// Concat imports deps with computed deps
|
|
880
764
|
const deps = [...ref.deps(), ...importsDeps];
|
|
881
|
-
|
|
882
|
-
const map = ref.sourcemap;
|
|
883
|
-
return {
|
|
884
|
-
code: result,
|
|
885
|
-
map: formatStylusSourceMap(map, root),
|
|
886
|
-
additionalMap,
|
|
887
|
-
errors: [],
|
|
888
|
-
deps,
|
|
889
|
-
};
|
|
765
|
+
return { code: result, errors: [], deps };
|
|
890
766
|
}
|
|
891
767
|
catch (e) {
|
|
892
768
|
return { code: '', errors: [e], deps: [] };
|
|
893
769
|
}
|
|
894
770
|
};
|
|
895
|
-
function
|
|
896
|
-
if (!mapBefore)
|
|
897
|
-
return undefined;
|
|
898
|
-
const map = { ...mapBefore };
|
|
899
|
-
const resolveFromRoot = (p) => (0, utils_1.normalizePath)(path_1.default.resolve(root, p));
|
|
900
|
-
if (map.file) {
|
|
901
|
-
map.file = resolveFromRoot(map.file);
|
|
902
|
-
}
|
|
903
|
-
map.sources = map.sources.map(resolveFromRoot);
|
|
904
|
-
return map;
|
|
905
|
-
}
|
|
906
|
-
async function getSource(source, filename, additionalData, enableSourcemap, sep = '') {
|
|
771
|
+
function getSource(source, filename, additionalData, sep = '') {
|
|
907
772
|
if (!additionalData)
|
|
908
|
-
return
|
|
773
|
+
return source;
|
|
909
774
|
if (typeof additionalData === 'function') {
|
|
910
|
-
|
|
911
|
-
if (typeof newContent === 'string') {
|
|
912
|
-
return { content: newContent };
|
|
913
|
-
}
|
|
914
|
-
return newContent;
|
|
915
|
-
}
|
|
916
|
-
if (!enableSourcemap) {
|
|
917
|
-
return { content: additionalData + sep + source };
|
|
775
|
+
return additionalData(source, filename);
|
|
918
776
|
}
|
|
919
|
-
|
|
920
|
-
ms.appendLeft(0, sep);
|
|
921
|
-
ms.appendLeft(0, additionalData);
|
|
922
|
-
const map = ms.generateMap({ hires: true });
|
|
923
|
-
map.file = filename;
|
|
924
|
-
map.sources = [filename];
|
|
925
|
-
return {
|
|
926
|
-
content: ms.toString(),
|
|
927
|
-
map,
|
|
928
|
-
};
|
|
777
|
+
return additionalData + sep + source;
|
|
929
778
|
}
|
|
930
779
|
const preProcessors = Object.freeze({
|
|
931
780
|
["less" /* less */]: less,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { DecodedSourceMap, RawSourceMap } from '@ampproject/remapping';
|
|
2
1
|
export declare function slash(p: string): string;
|
|
3
2
|
export declare const bareImportRE: RegExp;
|
|
4
3
|
export declare const deepImportRE: RegExp;
|
|
@@ -11,7 +10,6 @@ export declare const externalRE: RegExp;
|
|
|
11
10
|
export declare const isExternalUrl: (url: string) => boolean;
|
|
12
11
|
export declare const dataUrlRE: RegExp;
|
|
13
12
|
export declare const isDataUrl: (url: string) => boolean;
|
|
14
|
-
export declare const multilineCommentsRE: RegExp;
|
|
15
13
|
export declare function asyncReplace(input: string, re: RegExp, replacer: (match: RegExpExecArray) => string | Promise<string>): Promise<string>;
|
|
16
14
|
export declare function isObject(value: unknown): value is Record<string, any>;
|
|
17
15
|
export declare function pad(source: string, n?: number): string;
|
|
@@ -28,5 +26,4 @@ interface ImageCandidate {
|
|
|
28
26
|
descriptor: string;
|
|
29
27
|
}
|
|
30
28
|
export declare function processSrcSet(srcs: string, replacer: (arg: ImageCandidate) => Promise<string>): Promise<string>;
|
|
31
|
-
export declare function combineSourcemaps(filename: string, sourcemapList: Array<DecodedSourceMap | RawSourceMap>, excludeContent?: boolean): RawSourceMap;
|
|
32
29
|
export {};
|
|
@@ -3,13 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.processSrcSet = exports.generateCodeFrame = exports.posToNumber = exports.pad = exports.isObject = exports.asyncReplace = exports.isDataUrl = exports.dataUrlRE = exports.isExternalUrl = exports.externalRE = exports.cleanUrl = exports.hashRE = exports.queryRE = exports.normalizePath = exports.isWindows = exports.deepImportRE = exports.bareImportRE = exports.slash = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* https://github.com/vitejs/vite/blob/main/packages/vite/src/node/utils.ts
|
|
9
9
|
*/
|
|
10
10
|
const os_1 = __importDefault(require("os"));
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const remapping_1 = __importDefault(require("@ampproject/remapping"));
|
|
13
12
|
function slash(p) {
|
|
14
13
|
return p.replace(/\\/g, '/');
|
|
15
14
|
}
|
|
@@ -31,7 +30,6 @@ exports.isExternalUrl = isExternalUrl;
|
|
|
31
30
|
exports.dataUrlRE = /^\s*data:/i;
|
|
32
31
|
const isDataUrl = (url) => exports.dataUrlRE.test(url);
|
|
33
32
|
exports.isDataUrl = isDataUrl;
|
|
34
|
-
exports.multilineCommentsRE = /\/\*(.|[\r\n])*?\*\//gm;
|
|
35
33
|
async function asyncReplace(input, re, replacer) {
|
|
36
34
|
let match;
|
|
37
35
|
let remaining = input;
|
|
@@ -104,17 +102,15 @@ function generateCodeFrame(source, start = 0, end) {
|
|
|
104
102
|
}
|
|
105
103
|
exports.generateCodeFrame = generateCodeFrame;
|
|
106
104
|
const escapedSpaceCharacters = /( |\\t|\\n|\\f|\\r)+/g;
|
|
107
|
-
const imageSetUrlRE = /^(?:[\w\-]+\(.*?\)|'.*?'|".*?"|\S*)/;
|
|
108
105
|
async function processSrcSet(srcs, replacer) {
|
|
109
106
|
const imageCandidates = srcs
|
|
110
107
|
.split(',')
|
|
111
108
|
.map((s) => {
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
};
|
|
109
|
+
const [url, descriptor] = s
|
|
110
|
+
.replace(escapedSpaceCharacters, ' ')
|
|
111
|
+
.trim()
|
|
112
|
+
.split(' ', 2);
|
|
113
|
+
return { url, descriptor };
|
|
118
114
|
})
|
|
119
115
|
.filter(({ url }) => !!url);
|
|
120
116
|
const ret = await Promise.all(imageCandidates.map(async ({ url, descriptor }) => {
|
|
@@ -131,71 +127,3 @@ async function processSrcSet(srcs, replacer) {
|
|
|
131
127
|
return url;
|
|
132
128
|
}
|
|
133
129
|
exports.processSrcSet = processSrcSet;
|
|
134
|
-
function escapeToLinuxLikePath(path) {
|
|
135
|
-
if (/^[A-Z]:/.test(path)) {
|
|
136
|
-
return path.replace(/^([A-Z]):\//, '/windows/$1/');
|
|
137
|
-
}
|
|
138
|
-
if (/^\/[^/]/.test(path)) {
|
|
139
|
-
return `/linux${path}`;
|
|
140
|
-
}
|
|
141
|
-
return path;
|
|
142
|
-
}
|
|
143
|
-
function unescapeToLinuxLikePath(path) {
|
|
144
|
-
if (path.startsWith('/linux/')) {
|
|
145
|
-
return path.slice('/linux'.length);
|
|
146
|
-
}
|
|
147
|
-
if (path.startsWith('/windows/')) {
|
|
148
|
-
return path.replace(/^\/windows\/([A-Z])\//, '$1:/');
|
|
149
|
-
}
|
|
150
|
-
return path;
|
|
151
|
-
}
|
|
152
|
-
// based on https://github.com/sveltejs/svelte/blob/abf11bb02b2afbd3e4cac509a0f70e318c306364/src/compiler/utils/mapped_code.ts#L221
|
|
153
|
-
const nullSourceMap = {
|
|
154
|
-
names: [],
|
|
155
|
-
sources: [],
|
|
156
|
-
mappings: '',
|
|
157
|
-
version: 3,
|
|
158
|
-
};
|
|
159
|
-
function combineSourcemaps(filename, sourcemapList, excludeContent = true) {
|
|
160
|
-
if (sourcemapList.length === 0 ||
|
|
161
|
-
sourcemapList.every((m) => m.sources.length === 0)) {
|
|
162
|
-
return { ...nullSourceMap };
|
|
163
|
-
}
|
|
164
|
-
// hack for parse broken with normalized absolute paths on windows (C:/path/to/something).
|
|
165
|
-
// escape them to linux like paths
|
|
166
|
-
// also avoid mutation here to prevent breaking plugin's using cache to generate sourcemaps like vue (see #7442)
|
|
167
|
-
sourcemapList = sourcemapList.map((sourcemap) => {
|
|
168
|
-
const newSourcemaps = { ...sourcemap };
|
|
169
|
-
newSourcemaps.sources = sourcemap.sources.map((source) => source ? escapeToLinuxLikePath(source) : null);
|
|
170
|
-
if (sourcemap.sourceRoot) {
|
|
171
|
-
newSourcemaps.sourceRoot = escapeToLinuxLikePath(sourcemap.sourceRoot);
|
|
172
|
-
}
|
|
173
|
-
return newSourcemaps;
|
|
174
|
-
});
|
|
175
|
-
const escapedFilename = escapeToLinuxLikePath(filename);
|
|
176
|
-
// We don't declare type here so we can convert/fake/map as RawSourceMap
|
|
177
|
-
let map; //: SourceMap
|
|
178
|
-
let mapIndex = 1;
|
|
179
|
-
const useArrayInterface = sourcemapList.slice(0, -1).find((m) => m.sources.length !== 1) === undefined;
|
|
180
|
-
if (useArrayInterface) {
|
|
181
|
-
map = (0, remapping_1.default)(sourcemapList, () => null, excludeContent);
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
map = (0, remapping_1.default)(sourcemapList[0], function loader(sourcefile) {
|
|
185
|
-
if (sourcefile === escapedFilename && sourcemapList[mapIndex]) {
|
|
186
|
-
return sourcemapList[mapIndex++];
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
}, excludeContent);
|
|
192
|
-
}
|
|
193
|
-
if (!map.file) {
|
|
194
|
-
delete map.file;
|
|
195
|
-
}
|
|
196
|
-
// unescape the previous hack
|
|
197
|
-
map.sources = map.sources.map((source) => source ? unescapeToLinuxLikePath(source) : source);
|
|
198
|
-
map.file = filename;
|
|
199
|
-
return map;
|
|
200
|
-
}
|
|
201
|
-
exports.combineSourcemaps = combineSourcemaps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-cli-shared",
|
|
3
|
-
"version": "3.0.0-alpha-
|
|
3
|
+
"version": "3.0.0-alpha-3040920220508001",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,12 +18,11 @@
|
|
|
18
18
|
"url": "https://github.com/dcloudio/uni-app/issues"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@ampproject/remapping": "^2.1.2",
|
|
22
21
|
"@babel/core": "^7.17.9",
|
|
23
22
|
"@babel/parser": "^7.17.9",
|
|
24
23
|
"@babel/types": "^7.17.0",
|
|
25
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
26
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
24
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3040920220508001",
|
|
25
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3040920220508001",
|
|
27
26
|
"@intlify/core-base": "9.1.9",
|
|
28
27
|
"@intlify/shared": "9.1.9",
|
|
29
28
|
"@intlify/vue-devtools": "9.1.9",
|
|
@@ -33,7 +32,7 @@
|
|
|
33
32
|
"@vue/compiler-sfc": "3.2.33",
|
|
34
33
|
"@vue/server-renderer": "3.2.33",
|
|
35
34
|
"@vue/shared": "3.2.33",
|
|
36
|
-
"autoprefixer": "^10.4.
|
|
35
|
+
"autoprefixer": "^10.4.5",
|
|
37
36
|
"base64url": "^3.0.1",
|
|
38
37
|
"chokidar": "^3.5.3",
|
|
39
38
|
"compare-versions": "^3.6.0",
|
|
@@ -60,18 +59,13 @@
|
|
|
60
59
|
},
|
|
61
60
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
62
61
|
"devDependencies": {
|
|
63
|
-
"@types/babel__core": "^7.1.19",
|
|
64
62
|
"@types/debug": "^4.1.7",
|
|
65
|
-
"@types/estree": "^0.0.51",
|
|
66
63
|
"@types/fs-extra": "^9.0.13",
|
|
67
64
|
"@types/hash-sum": "^1.0.0",
|
|
68
65
|
"@types/less": "^3.0.3",
|
|
69
66
|
"@types/mime": "^2.0.3",
|
|
70
67
|
"@types/module-alias": "^2.0.1",
|
|
71
|
-
"@types/resolve": "^1.20.2",
|
|
72
|
-
"@types/sass": "^1.43.1",
|
|
73
68
|
"@types/stylus": "^0.48.36",
|
|
74
|
-
"postcss": "^8.4.
|
|
75
|
-
"vue": "3.2.33"
|
|
69
|
+
"postcss": "^8.4.12"
|
|
76
70
|
}
|
|
77
71
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function emptyCssComments(raw: string): string;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.emptyCssComments = void 0;
|
|
4
|
-
const utils_1 = require("./utils");
|
|
5
|
-
const blankReplacer = (s) => ' '.repeat(s.length);
|
|
6
|
-
function emptyCssComments(raw) {
|
|
7
|
-
return raw.replace(utils_1.multilineCommentsRE, blankReplacer);
|
|
8
|
-
}
|
|
9
|
-
exports.emptyCssComments = emptyCssComments;
|
package/lib/.DS_Store
DELETED
|
Binary file
|
package/lib/vue-i18n/.DS_Store
DELETED
|
Binary file
|