@dcloudio/uni-cli-shared 3.0.0-alpha-3090920231203001 → 3.0.0-alpha-3090920231207001
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/json/index.d.ts +1 -1
- package/dist/json/index.js +3 -1
- package/dist/json/uni-x/index.d.ts +1 -0
- package/dist/json/uni-x/index.js +4 -1
- package/dist/json/uni-x/manifest.d.ts +2 -0
- package/dist/json/uni-x/manifest.js +21 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +13 -1
- package/dist/vite/plugins/index.d.ts +1 -1
- package/dist/vite/plugins/index.js +2 -1
- package/dist/vite/plugins/vitejs/plugins/css.d.ts +2 -0
- package/dist/vite/plugins/vitejs/plugins/css.js +45 -5
- package/dist/vite/plugins/vitejs/utils.d.ts +2 -0
- package/dist/vite/plugins/vitejs/utils.js +36 -19
- package/dist/vite/utils/utils.js +12 -3
- package/package.json +4 -4
package/dist/json/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export * from './json';
|
|
|
4
4
|
export * from './pages';
|
|
5
5
|
export * from './manifest';
|
|
6
6
|
export * from './theme';
|
|
7
|
-
export { normalizeUniAppXAppPagesJson, normalizeUniAppXAppConfig, checkPagesJson, } from './uni-x';
|
|
7
|
+
export { normalizeUniAppXAppPagesJson, normalizeUniAppXAppConfig, checkPagesJson, parseUniXFlexDirection, parseUniXSplashScreen, } from './uni-x';
|
package/dist/json/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.checkPagesJson = exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = void 0;
|
|
17
|
+
exports.parseUniXSplashScreen = exports.parseUniXFlexDirection = exports.checkPagesJson = exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = void 0;
|
|
18
18
|
__exportStar(require("./mp"), exports);
|
|
19
19
|
__exportStar(require("./app"), exports);
|
|
20
20
|
__exportStar(require("./json"), exports);
|
|
@@ -25,3 +25,5 @@ var uni_x_1 = require("./uni-x");
|
|
|
25
25
|
Object.defineProperty(exports, "normalizeUniAppXAppPagesJson", { enumerable: true, get: function () { return uni_x_1.normalizeUniAppXAppPagesJson; } });
|
|
26
26
|
Object.defineProperty(exports, "normalizeUniAppXAppConfig", { enumerable: true, get: function () { return uni_x_1.normalizeUniAppXAppConfig; } });
|
|
27
27
|
Object.defineProperty(exports, "checkPagesJson", { enumerable: true, get: function () { return uni_x_1.checkPagesJson; } });
|
|
28
|
+
Object.defineProperty(exports, "parseUniXFlexDirection", { enumerable: true, get: function () { return uni_x_1.parseUniXFlexDirection; } });
|
|
29
|
+
Object.defineProperty(exports, "parseUniXSplashScreen", { enumerable: true, get: function () { return uni_x_1.parseUniXSplashScreen; } });
|
package/dist/json/uni-x/index.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = exports.checkPagesJson = void 0;
|
|
6
|
+
exports.normalizeUniAppXAppConfig = exports.normalizeUniAppXAppPagesJson = exports.checkPagesJson = exports.parseUniXSplashScreen = exports.parseUniXFlexDirection = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
@@ -14,6 +14,9 @@ const utils_1 = require("../../utils");
|
|
|
14
14
|
const uniRoutes_1 = require("../app/pages/uniRoutes");
|
|
15
15
|
const uniConfig_1 = require("./uniConfig");
|
|
16
16
|
const utils_2 = require("../../vite/plugins/vitejs/utils");
|
|
17
|
+
var manifest_1 = require("./manifest");
|
|
18
|
+
Object.defineProperty(exports, "parseUniXFlexDirection", { enumerable: true, get: function () { return manifest_1.parseUniXFlexDirection; } });
|
|
19
|
+
Object.defineProperty(exports, "parseUniXSplashScreen", { enumerable: true, get: function () { return manifest_1.parseUniXSplashScreen; } });
|
|
17
20
|
function checkPagesJson(jsonStr, inputDir) {
|
|
18
21
|
if (!inputDir) {
|
|
19
22
|
return false;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseUniXSplashScreen = exports.parseUniXFlexDirection = void 0;
|
|
4
|
+
const shared_1 = require("@vue/shared");
|
|
5
|
+
const flexDirs = ['row', 'row-reverse', 'column', 'column-reverse'];
|
|
6
|
+
function parseUniXFlexDirection(manifestJson) {
|
|
7
|
+
const flexDir = manifestJson?.['uni-app-x']?.['flex-direction'];
|
|
8
|
+
if (flexDir && flexDirs.includes(flexDir)) {
|
|
9
|
+
return flexDir;
|
|
10
|
+
}
|
|
11
|
+
return 'column';
|
|
12
|
+
}
|
|
13
|
+
exports.parseUniXFlexDirection = parseUniXFlexDirection;
|
|
14
|
+
function parseUniXSplashScreen(manifestJson) {
|
|
15
|
+
const splashScreen = manifestJson?.['app']?.['splashScreen'];
|
|
16
|
+
if ((0, shared_1.isPlainObject)(splashScreen)) {
|
|
17
|
+
return splashScreen;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
exports.parseUniXSplashScreen = parseUniXSplashScreen;
|
package/dist/utils.d.ts
CHANGED
|
@@ -21,3 +21,5 @@ export declare function resolveSourceMapPath(outputDir?: string, platform?: UniA
|
|
|
21
21
|
export declare function installDepTips(type: 'dependencies' | 'devDependencies', module: string, version?: string): string;
|
|
22
22
|
export declare function isAppVue(filename: string): boolean;
|
|
23
23
|
export declare function resolveAppVue(inputDir: string): string;
|
|
24
|
+
export declare function parseImporter(importer: string): string;
|
|
25
|
+
export declare function createResolveErrorMsg(source: string, importer: string): string;
|
package/dist/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.resolveAppVue = exports.isAppVue = exports.installDepTips = exports.resolveSourceMapPath = exports.pathToGlob = exports.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isRunningWithYarnPnp = exports.isArray = exports.capitalize = exports.camelize = exports.version = exports.hash = void 0;
|
|
6
|
+
exports.createResolveErrorMsg = exports.parseImporter = exports.resolveAppVue = exports.isAppVue = exports.installDepTips = exports.resolveSourceMapPath = exports.pathToGlob = exports.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isRunningWithYarnPnp = exports.isArray = exports.capitalize = exports.camelize = exports.version = exports.hash = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -129,3 +129,15 @@ function resolveAppVue(inputDir) {
|
|
|
129
129
|
return normalizePath(path_1.default.resolve(inputDir, 'App.vue'));
|
|
130
130
|
}
|
|
131
131
|
exports.resolveAppVue = resolveAppVue;
|
|
132
|
+
function parseImporter(importer) {
|
|
133
|
+
importer = importer.split('?')[0];
|
|
134
|
+
if (path_1.default.isAbsolute(importer)) {
|
|
135
|
+
return normalizePath(path_1.default.relative(process.env.UNI_INPUT_DIR, importer));
|
|
136
|
+
}
|
|
137
|
+
return importer;
|
|
138
|
+
}
|
|
139
|
+
exports.parseImporter = parseImporter;
|
|
140
|
+
function createResolveErrorMsg(source, importer) {
|
|
141
|
+
return `Could not resolve "${source}" from "${parseImporter(importer)}"`;
|
|
142
|
+
}
|
|
143
|
+
exports.createResolveErrorMsg = createResolveErrorMsg;
|
|
@@ -9,4 +9,4 @@ export * from './uts/uni_modules';
|
|
|
9
9
|
export * from './uts/uvue';
|
|
10
10
|
export { assetPlugin, parseAssets, getAssetHash } from './vitejs/plugins/asset';
|
|
11
11
|
export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, } from './vitejs/plugins/css';
|
|
12
|
-
export { generateCodeFrame, locToStartAndEnd } from './vitejs/utils';
|
|
12
|
+
export { generateCodeFrame, locToStartAndEnd, offsetToStartAndEnd, } from './vitejs/utils';
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.locToStartAndEnd = exports.generateCodeFrame = exports.commonjsProxyRE = exports.cssLangRE = exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.parseAssets = exports.assetPlugin = void 0;
|
|
17
|
+
exports.offsetToStartAndEnd = exports.locToStartAndEnd = exports.generateCodeFrame = exports.commonjsProxyRE = exports.cssLangRE = exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.parseAssets = exports.assetPlugin = void 0;
|
|
18
18
|
__exportStar(require("./cssScoped"), exports);
|
|
19
19
|
__exportStar(require("./copy"), exports);
|
|
20
20
|
__exportStar(require("./inject"), exports);
|
|
@@ -38,3 +38,4 @@ Object.defineProperty(exports, "commonjsProxyRE", { enumerable: true, get: funct
|
|
|
38
38
|
var utils_1 = require("./vitejs/utils");
|
|
39
39
|
Object.defineProperty(exports, "generateCodeFrame", { enumerable: true, get: function () { return utils_1.generateCodeFrame; } });
|
|
40
40
|
Object.defineProperty(exports, "locToStartAndEnd", { enumerable: true, get: function () { return utils_1.locToStartAndEnd; } });
|
|
41
|
+
Object.defineProperty(exports, "offsetToStartAndEnd", { enumerable: true, get: function () { return utils_1.offsetToStartAndEnd; } });
|
|
@@ -2,6 +2,7 @@ import { ExistingRawSourceMap, RollupError } from 'rollup';
|
|
|
2
2
|
import { Plugin } from '../plugin';
|
|
3
3
|
import { ResolvedConfig } from '../config';
|
|
4
4
|
import * as Postcss from 'postcss';
|
|
5
|
+
import { SFCDescriptor } from '@vue/compiler-sfc';
|
|
5
6
|
export interface CSSOptions {
|
|
6
7
|
/**
|
|
7
8
|
* https://github.com/css-modules/postcss-modules
|
|
@@ -32,6 +33,7 @@ export declare const isDirectCSSRequest: (request: string) => boolean;
|
|
|
32
33
|
*/
|
|
33
34
|
export declare function cssPlugin(config: ResolvedConfig, options?: {
|
|
34
35
|
isAppX: boolean;
|
|
36
|
+
getDescriptor?(filename: string): SFCDescriptor | undefined;
|
|
35
37
|
}): Plugin;
|
|
36
38
|
/**
|
|
37
39
|
* Plugin applied after user plugins
|
|
@@ -37,11 +37,15 @@ const utils_1 = require("../utils");
|
|
|
37
37
|
const asset_1 = require("./asset");
|
|
38
38
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
39
39
|
const Postcss = __importStar(require("postcss"));
|
|
40
|
+
const shared_1 = require("@vue/shared");
|
|
40
41
|
const preprocess_1 = require("../../../../preprocess");
|
|
41
42
|
const uniapp_1 = require("../../../../postcss/plugins/uniapp");
|
|
42
43
|
const cleanString_1 = require("../cleanString");
|
|
43
|
-
const shared_1 = require("@vue/shared");
|
|
44
44
|
const constants_1 = require("../../../../constants");
|
|
45
|
+
const utils_2 = require("../../../utils/utils");
|
|
46
|
+
const compiler_core_1 = require("@vue/compiler-core");
|
|
47
|
+
const utils_3 = require("../../../../utils");
|
|
48
|
+
const utils_4 = require("../../../utils");
|
|
45
49
|
const cssLangs = `\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)`;
|
|
46
50
|
exports.cssLangRE = new RegExp(cssLangs);
|
|
47
51
|
const cssModuleRE = new RegExp(`\\.module${cssLangs}`);
|
|
@@ -54,10 +58,46 @@ const isDirectCSSRequest = (request) => exports.cssLangRE.test(request) && direc
|
|
|
54
58
|
exports.isDirectCSSRequest = isDirectCSSRequest;
|
|
55
59
|
const cssModulesCache = new WeakMap();
|
|
56
60
|
const postcssConfigCache = new WeakMap();
|
|
61
|
+
function wrapResolve(resolve, code, source, getDescriptor) {
|
|
62
|
+
if (!source) {
|
|
63
|
+
return resolve;
|
|
64
|
+
}
|
|
65
|
+
return async (id, importer, aliasOnly, ssr) => {
|
|
66
|
+
try {
|
|
67
|
+
return await resolve(id, importer, aliasOnly, ssr);
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
if (importer && getDescriptor) {
|
|
71
|
+
const { filename, query } = (0, utils_4.parseVueRequest)(importer);
|
|
72
|
+
// 仅处理 vue | uvue
|
|
73
|
+
if (query.vue &&
|
|
74
|
+
query.type === 'style' &&
|
|
75
|
+
'index' in query &&
|
|
76
|
+
/\.[u]vue/.test(filename)) {
|
|
77
|
+
const descriptor = getDescriptor(importer.split('?')[0]);
|
|
78
|
+
if (descriptor) {
|
|
79
|
+
const styleBlock = descriptor.styles[query.index];
|
|
80
|
+
if (styleBlock) {
|
|
81
|
+
code = descriptor.source;
|
|
82
|
+
const offsetLine = styleBlock.loc.start.line - 1;
|
|
83
|
+
source.start.line = source.start.line + offsetLine;
|
|
84
|
+
source.end.line = source.end.line + offsetLine;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const error = (0, utils_2.createRollupError)('', importer || '', (0, compiler_core_1.createCompilerError)(0, { start: source.start, end: source.end, source: '' }, { 0: (0, utils_3.createResolveErrorMsg)(id, importer) }), code);
|
|
90
|
+
error.line = source.start.line;
|
|
91
|
+
error.column = source.start.column;
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
57
97
|
/**
|
|
58
98
|
* Plugin applied before user plugins
|
|
59
99
|
*/
|
|
60
|
-
function cssPlugin(config, options) {
|
|
100
|
+
function cssPlugin(config, options = { isAppX: false }) {
|
|
61
101
|
let server;
|
|
62
102
|
let moduleCache;
|
|
63
103
|
const resolveUrl = config.createResolver({
|
|
@@ -80,12 +120,12 @@ function cssPlugin(config, options) {
|
|
|
80
120
|
if (!exports.cssLangRE.test(id) || exports.commonjsProxyRE.test(id)) {
|
|
81
121
|
return;
|
|
82
122
|
}
|
|
83
|
-
const urlReplacer = async (url, importer) => {
|
|
123
|
+
const urlReplacer = async (url, importer, source) => {
|
|
84
124
|
if (url.startsWith('/') && !url.startsWith('//')) {
|
|
85
125
|
// /static/logo.png => @/static/logo.png
|
|
86
126
|
url = '@' + url;
|
|
87
127
|
}
|
|
88
|
-
const resolved = await resolveUrl(url, importer);
|
|
128
|
+
const resolved = await wrapResolve(resolveUrl, source?.input.css || raw, source, options.getDescriptor)(url, importer);
|
|
89
129
|
if (resolved) {
|
|
90
130
|
return (0, asset_1.fileToUrl)(resolved, config, options?.isAppX
|
|
91
131
|
? {
|
|
@@ -602,7 +642,7 @@ const UrlRewritePostcssPlugin = (opts) => {
|
|
|
602
642
|
if (isCssUrl || isCssImageSet) {
|
|
603
643
|
const replacerForDeclaration = (rawUrl) => {
|
|
604
644
|
const importer = declaration.source?.input.file;
|
|
605
|
-
return opts.replacer(rawUrl, importer);
|
|
645
|
+
return opts.replacer(rawUrl, importer, declaration.source);
|
|
606
646
|
};
|
|
607
647
|
const rewriterToUse = isCssImageSet
|
|
608
648
|
? rewriteCssImageSet
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DecodedSourceMap, RawSourceMap } from '@ampproject/remapping';
|
|
2
|
+
import { SourceLocation } from '@vue/compiler-core';
|
|
2
3
|
export declare function slash(p: string): string;
|
|
3
4
|
export declare const bareImportRE: RegExp;
|
|
4
5
|
export declare const deepImportRE: RegExp;
|
|
@@ -15,6 +16,7 @@ export declare const multilineCommentsRE: RegExp;
|
|
|
15
16
|
export declare function asyncReplace(input: string, re: RegExp, replacer: (match: RegExpExecArray) => string | Promise<string>): Promise<string>;
|
|
16
17
|
export declare function isObject(value: unknown): value is Record<string, any>;
|
|
17
18
|
export declare function pad(source: string, n?: number): string;
|
|
19
|
+
export declare function offsetToStartAndEnd(source: string, startOffset: number, endOffset: number): SourceLocation;
|
|
18
20
|
export declare function offsetToLineColumn(source: string, offset: number): {
|
|
19
21
|
line: number;
|
|
20
22
|
column: number;
|
|
@@ -3,7 +3,7 @@ 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.combineSourcemaps = exports.processSrcSet = exports.generateCodeFrame = exports.locToStartAndEnd = exports.posToNumber = exports.offsetToLineColumn = exports.pad = exports.isObject = exports.asyncReplace = exports.multilineCommentsRE = 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;
|
|
6
|
+
exports.combineSourcemaps = exports.processSrcSet = exports.generateCodeFrame = exports.locToStartAndEnd = exports.posToNumber = exports.offsetToLineColumn = exports.offsetToStartAndEnd = exports.pad = exports.isObject = exports.asyncReplace = exports.multilineCommentsRE = 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
|
*/
|
|
@@ -56,22 +56,30 @@ function pad(source, n = 2) {
|
|
|
56
56
|
return lines.map((l) => ` `.repeat(n) + l).join(`\n`);
|
|
57
57
|
}
|
|
58
58
|
exports.pad = pad;
|
|
59
|
-
function
|
|
59
|
+
function offsetToStartAndEnd(source, startOffset, endOffset) {
|
|
60
60
|
const lines = source.split(splitRE);
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
return {
|
|
62
|
+
start: offsetToLineColumnByLines(lines, startOffset),
|
|
63
|
+
end: offsetToLineColumnByLines(lines, endOffset),
|
|
64
|
+
source: '',
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
exports.offsetToStartAndEnd = offsetToStartAndEnd;
|
|
68
|
+
function offsetToLineColumnByLines(lines, offset) {
|
|
69
|
+
let currentOffset = 0;
|
|
63
70
|
for (let i = 0; i < lines.length; i++) {
|
|
64
|
-
const lineLength = lines[i].length + 1;
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
else {
|
|
70
|
-
offset -= lineLength;
|
|
71
|
-
line++;
|
|
71
|
+
const lineLength = lines[i].length + 1; // Adding 1 for the newline character
|
|
72
|
+
if (currentOffset + lineLength > offset) {
|
|
73
|
+
const line = i + 1; // Line numbers start from 1
|
|
74
|
+
const column = offset - currentOffset; // Column numbers start from 0
|
|
75
|
+
return { line, column, offset };
|
|
72
76
|
}
|
|
77
|
+
currentOffset += lineLength;
|
|
73
78
|
}
|
|
74
|
-
return { line, column };
|
|
79
|
+
return { line: lines.length, column: lines[lines.length - 1].length, offset };
|
|
80
|
+
}
|
|
81
|
+
function offsetToLineColumn(source, offset) {
|
|
82
|
+
return offsetToLineColumnByLines(source.split(splitRE), offset);
|
|
75
83
|
}
|
|
76
84
|
exports.offsetToLineColumn = offsetToLineColumn;
|
|
77
85
|
function posToNumber(source, pos) {
|
|
@@ -97,14 +105,22 @@ function locToStartAndEnd(source, loc) {
|
|
|
97
105
|
return { start, end };
|
|
98
106
|
}
|
|
99
107
|
exports.locToStartAndEnd = locToStartAndEnd;
|
|
100
|
-
function generateCodeFrame(source, start = 0, end) {
|
|
108
|
+
function generateCodeFrame(source, start = 0, end = source.length) {
|
|
101
109
|
start = posToNumber(source, start);
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
// Split the content into individual lines but capture the newline sequence
|
|
111
|
+
// that separated each line. This is important because the actual sequence is
|
|
112
|
+
// needed to properly take into account the full line length for offset
|
|
113
|
+
// comparison
|
|
114
|
+
let lines = source.split(/(\r?\n)/);
|
|
115
|
+
// Separate the lines and newline sequences into separate arrays for easier referencing
|
|
116
|
+
const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
|
117
|
+
lines = lines.filter((_, idx) => idx % 2 === 0);
|
|
104
118
|
let count = 0;
|
|
105
119
|
const res = [];
|
|
106
120
|
for (let i = 0; i < lines.length; i++) {
|
|
107
|
-
count +=
|
|
121
|
+
count +=
|
|
122
|
+
lines[i].length +
|
|
123
|
+
((newlineSequences[i] && newlineSequences[i].length) || 0);
|
|
108
124
|
if (count >= start) {
|
|
109
125
|
for (let j = i - range; j <= i + range || end > count; j++) {
|
|
110
126
|
if (j < 0 || j >= lines.length)
|
|
@@ -112,9 +128,10 @@ function generateCodeFrame(source, start = 0, end) {
|
|
|
112
128
|
const line = j + 1;
|
|
113
129
|
res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);
|
|
114
130
|
const lineLength = lines[j].length;
|
|
131
|
+
const newLineSeqLength = (newlineSequences[j] && newlineSequences[j].length) || 0;
|
|
115
132
|
if (j === i) {
|
|
116
133
|
// push underline
|
|
117
|
-
const pad = start - (count - lineLength
|
|
134
|
+
const pad = start - (count - (lineLength + newLineSeqLength));
|
|
118
135
|
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
119
136
|
res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));
|
|
120
137
|
}
|
|
@@ -123,7 +140,7 @@ function generateCodeFrame(source, start = 0, end) {
|
|
|
123
140
|
const length = Math.max(Math.min(end - count, lineLength), 1);
|
|
124
141
|
res.push(` | ` + '^'.repeat(length));
|
|
125
142
|
}
|
|
126
|
-
count += lineLength +
|
|
143
|
+
count += lineLength + newLineSeqLength;
|
|
127
144
|
}
|
|
128
145
|
}
|
|
129
146
|
break;
|
package/dist/vite/utils/utils.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createRollupError = exports.isSsr = exports.isInHybridNVue = exports.withSourcemap = void 0;
|
|
4
4
|
const utils_1 = require("../plugins/vitejs/utils");
|
|
5
|
+
const shared_1 = require("@vue/shared");
|
|
5
6
|
function withSourcemap(config) {
|
|
6
7
|
if (config.command === 'serve') {
|
|
7
8
|
return true;
|
|
@@ -25,13 +26,12 @@ function isSsr(command, config) {
|
|
|
25
26
|
exports.isSsr = isSsr;
|
|
26
27
|
function createRollupError(plugin, id, error, source) {
|
|
27
28
|
const { message, name, stack } = error;
|
|
28
|
-
const rollupError = {
|
|
29
|
+
const rollupError = (0, shared_1.extend)(new Error(message), {
|
|
29
30
|
id,
|
|
30
31
|
plugin,
|
|
31
|
-
message,
|
|
32
32
|
name,
|
|
33
33
|
stack,
|
|
34
|
-
};
|
|
34
|
+
});
|
|
35
35
|
if ('code' in error && error.loc) {
|
|
36
36
|
rollupError.loc = {
|
|
37
37
|
file: id,
|
|
@@ -48,6 +48,15 @@ function createRollupError(plugin, id, error, source) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
+
if (id) {
|
|
52
|
+
// 指定了id后,不让后续的rollup重写
|
|
53
|
+
Object.defineProperty(rollupError, 'id', {
|
|
54
|
+
get() {
|
|
55
|
+
return id;
|
|
56
|
+
},
|
|
57
|
+
set(_v) { },
|
|
58
|
+
});
|
|
59
|
+
}
|
|
51
60
|
return rollupError;
|
|
52
61
|
}
|
|
53
62
|
exports.createRollupError = createRollupError;
|
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-3090920231207001",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"@babel/core": "^7.21.3",
|
|
26
26
|
"@babel/parser": "^7.16.4",
|
|
27
27
|
"@babel/types": "^7.20.7",
|
|
28
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
29
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
28
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3090920231207001",
|
|
29
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3090920231207001",
|
|
30
30
|
"@intlify/core-base": "9.1.9",
|
|
31
31
|
"@intlify/shared": "9.1.9",
|
|
32
32
|
"@intlify/vue-devtools": "9.1.9",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@dcloudio/uni-uts-v1": "3.0.0-alpha-
|
|
67
|
+
"@dcloudio/uni-uts-v1": "3.0.0-alpha-3090920231207001",
|
|
68
68
|
"@types/babel__core": "^7.1.19",
|
|
69
69
|
"@types/debug": "^4.1.7",
|
|
70
70
|
"@types/estree": "^0.0.51",
|