@dcloudio/uni-cli-shared 3.0.0-alpha-3090920231215001 → 3.0.0-alpha-4000020231218001

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/utils.d.ts CHANGED
@@ -7,12 +7,12 @@ export declare let isRunningWithYarnPnp: boolean;
7
7
  export declare const isWindows: boolean;
8
8
  export declare function normalizePath(id: string): string;
9
9
  export declare function checkElementNodeTag(node: RootNode | TemplateChildNode | null | undefined, tag: string): node is ElementNode;
10
- export declare function normalizeIdentifier(str: string): string;
10
+ export declare function normalizeIdentifier(str: string): Capitalize<string>;
11
11
  export declare function normalizePagePath(pagePath: string, platform: UniApp.PLATFORM): string | undefined;
12
12
  export declare function removeExt(str: string): string;
13
13
  export declare function normalizeNodeModules(str: string): string;
14
14
  export declare function normalizeMiniProgramFilename(filename: string, inputDir?: string): string;
15
- export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): ParserPlugin[];
15
+ export declare function normalizeParsePlugins(importer: string, babelParserPlugins?: ParserPlugin[]): (import("@babel/parser").ParserPluginWithOptions | ("asyncDoExpressions" | "asyncGenerators" | "bigInt" | "classPrivateMethods" | "classPrivateProperties" | "classProperties" | "classStaticBlock" | "decimal" | "decorators-legacy" | "deferredImportEvaluation" | "decoratorAutoAccessors" | "destructuringPrivate" | "doExpressions" | "dynamicImport" | "explicitResourceManagement" | "exportDefaultFrom" | "exportNamespaceFrom" | "flow" | "flowComments" | "functionBind" | "functionSent" | "importMeta" | "jsx" | "logicalAssignment" | "importAssertions" | "importAttributes" | "importReflection" | "moduleBlocks" | "moduleStringNames" | "nullishCoalescingOperator" | "numericSeparator" | "objectRestSpread" | "optionalCatchBinding" | "optionalChaining" | "partialApplication" | "placeholders" | "privateIn" | "regexpUnicodeSets" | "sourcePhaseImports" | "throwExpressions" | "topLevelAwait" | "v8intrinsic" | "decorators" | "estree" | "moduleAttributes" | "optionalChainingAssign" | "pipelineOperator" | "recordAndTuple" | "typescript"))[];
16
16
  export declare function pathToGlob(pathString: string, glob: string, options?: {
17
17
  windows?: boolean;
18
18
  escape?: boolean;
@@ -19,14 +19,17 @@ function uniUTSUVueJavaScriptPlugin(options = {}) {
19
19
  if (!(0, vue_1.isVueSfcFile)(id)) {
20
20
  return;
21
21
  }
22
- return code.replace(/<script([^>]*)>/gi, (match, attributes) => {
23
- // 如果 <script> 标签中没有 lang 属性,添加 lang="uts"
24
- if (!/lang=["']?[^"']*["']?/.test(attributes)) {
25
- return `<script${attributes} lang="uts">`;
26
- }
27
- // 否则,将现有的 lang 属性替换为 lang="uts"
28
- return match.replace(/lang=["']?ts["']?/, 'lang="uts"');
29
- });
22
+ return {
23
+ code: code.replace(/<script([^>]*)>/gi, (match, attributes) => {
24
+ // 如果 <script> 标签中没有 lang 属性,添加 lang="uts"
25
+ if (!/lang=["']?[^"']*["']?/.test(attributes)) {
26
+ return `<script${attributes} lang="uts">`;
27
+ }
28
+ // 否则,将现有的 lang 属性替换为 lang="uts"
29
+ return match.replace(/lang=["']?ts["']?/, 'lang="uts"');
30
+ }),
31
+ map: null,
32
+ };
30
33
  },
31
34
  };
32
35
  }
@@ -8,7 +8,7 @@ export declare const chunkToEmittedAssetsMap: WeakMap<RenderedChunk, Set<string>
8
8
  * Also supports loading plain strings with import text from './foo.txt?raw'
9
9
  */
10
10
  export declare function assetPlugin(config: ResolvedConfig, options?: {
11
- isAppX: boolean;
11
+ isAndroidX: boolean;
12
12
  }): Plugin;
13
13
  export declare function parseAssets(config: ResolvedConfig, code: string): string;
14
14
  export declare function registerAssetToChunk(chunk: RenderedChunk, file: string): void;
@@ -84,7 +84,7 @@ function assetPlugin(config, options) {
84
84
  return;
85
85
  }
86
86
  id = id.replace(urlRE, '$1').replace(/[\?&]$/, '');
87
- const url = await fileToUrl(id, config, options?.isAppX
87
+ const url = await fileToUrl(id, config, options?.isAndroidX
88
88
  ? {
89
89
  emitFile(emittedFile) {
90
90
  // 直接写入目标目录
@@ -92,7 +92,7 @@ function assetPlugin(config, options) {
92
92
  },
93
93
  }
94
94
  : this);
95
- if (options?.isAppX) {
95
+ if (options?.isAndroidX) {
96
96
  this.emitFile({
97
97
  type: 'asset',
98
98
  fileName: (0, utils_3.normalizeNodeModules)(path_1.default.relative(process.env.UNI_INPUT_DIR, id) + '.uts'),
@@ -32,7 +32,7 @@ export declare const isDirectCSSRequest: (request: string) => boolean;
32
32
  * Plugin applied before user plugins
33
33
  */
34
34
  export declare function cssPlugin(config: ResolvedConfig, options?: {
35
- isAppX: boolean;
35
+ isAndroidX: boolean;
36
36
  getDescriptor?(filename: string): SFCDescriptor | undefined;
37
37
  }): Plugin;
38
38
  /**
@@ -97,7 +97,7 @@ function wrapResolve(resolve, code, source, getDescriptor) {
97
97
  /**
98
98
  * Plugin applied before user plugins
99
99
  */
100
- function cssPlugin(config, options = { isAppX: false }) {
100
+ function cssPlugin(config, options = { isAndroidX: false }) {
101
101
  let server;
102
102
  let moduleCache;
103
103
  const resolveUrl = config.createResolver({
@@ -127,7 +127,7 @@ function cssPlugin(config, options = { isAppX: false }) {
127
127
  }
128
128
  const resolved = await wrapResolve(resolveUrl, source?.input.css || raw, source, options.getDescriptor)(url, importer);
129
129
  if (resolved) {
130
- return (0, asset_1.fileToUrl)(resolved, config, options?.isAppX
130
+ return (0, asset_1.fileToUrl)(resolved, config, options?.isAndroidX
131
131
  ? {
132
132
  emitFile(emittedFile) {
133
133
  // 直接写入目标目录
@@ -1,5 +1,6 @@
1
1
  import type { DecodedSourceMap, RawSourceMap } from '@ampproject/remapping';
2
- import { SourceLocation } from '@vue/compiler-core';
2
+ import { Position, SourceLocation } from '@vue/compiler-core';
3
+ import { LinesAndColumns } from 'lines-and-columns';
3
4
  export declare function slash(p: string): string;
4
5
  export declare const bareImportRE: RegExp;
5
6
  export declare const deepImportRE: RegExp;
@@ -21,6 +22,7 @@ export declare function offsetToLineColumn(source: string, offset: number): {
21
22
  line: number;
22
23
  column: number;
23
24
  };
25
+ export declare function offsetToLineColumnByLines(lines: LinesAndColumns, offset: number): Position;
24
26
  export declare function posToNumber(source: string, pos: number | {
25
27
  line: number;
26
28
  column: number;
@@ -3,13 +3,14 @@ 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.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;
6
+ exports.combineSourcemaps = exports.processSrcSet = exports.generateCodeFrame = exports.locToStartAndEnd = exports.posToNumber = exports.offsetToLineColumnByLines = 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
  */
10
10
  const os_1 = __importDefault(require("os"));
11
11
  const path_1 = __importDefault(require("path"));
12
12
  const remapping_1 = __importDefault(require("@ampproject/remapping"));
13
+ const lines_and_columns_1 = require("lines-and-columns");
13
14
  function slash(p) {
14
15
  return p.replace(/\\/g, '/');
15
16
  }
@@ -57,7 +58,7 @@ function pad(source, n = 2) {
57
58
  }
58
59
  exports.pad = pad;
59
60
  function offsetToStartAndEnd(source, startOffset, endOffset) {
60
- const lines = source.split(splitRE);
61
+ const lines = new lines_and_columns_1.LinesAndColumns(source);
61
62
  return {
62
63
  start: offsetToLineColumnByLines(lines, startOffset),
63
64
  end: offsetToLineColumnByLines(lines, endOffset),
@@ -65,39 +66,31 @@ function offsetToStartAndEnd(source, startOffset, endOffset) {
65
66
  };
66
67
  }
67
68
  exports.offsetToStartAndEnd = offsetToStartAndEnd;
68
- function offsetToLineColumnByLines(lines, offset) {
69
- let currentOffset = 0;
70
- for (let i = 0; i < lines.length; i++) {
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 };
76
- }
77
- currentOffset += lineLength;
78
- }
79
- return { line: lines.length, column: lines[lines.length - 1].length, offset };
80
- }
81
69
  function offsetToLineColumn(source, offset) {
82
- return offsetToLineColumnByLines(source.split(splitRE), offset);
70
+ return offsetToLineColumnByLines(new lines_and_columns_1.LinesAndColumns(source), offset);
83
71
  }
84
72
  exports.offsetToLineColumn = offsetToLineColumn;
73
+ function offsetToLineColumnByLines(lines, offset) {
74
+ let location = lines.locationForIndex(offset);
75
+ if (!location) {
76
+ location = lines.locationForIndex(offset);
77
+ }
78
+ // lines-and-columns is 0-indexed while positions are 1-indexed
79
+ return { line: location.line + 1, column: location.column, offset: 0 };
80
+ }
81
+ exports.offsetToLineColumnByLines = offsetToLineColumnByLines;
85
82
  function posToNumber(source, pos) {
86
83
  if (typeof pos === 'number')
87
84
  return pos;
88
- const lines = source.split(splitRE);
89
- return posToNumberByLines(lines, pos.line, pos.column);
85
+ return posToNumberByLines(new lines_and_columns_1.LinesAndColumns(source), pos.line, pos.column);
90
86
  }
91
87
  exports.posToNumber = posToNumber;
92
88
  function posToNumberByLines(lines, line, column) {
93
- let start = 0;
94
- for (let i = 0; i < line - 1; i++) {
95
- start += lines[i].length + 1;
96
- }
97
- return start + column;
89
+ // lines-and-columns is 0-indexed while positions are 1-indexed
90
+ return lines.indexForLocation({ line: line - 1, column }) || 0;
98
91
  }
99
92
  function locToStartAndEnd(source, loc) {
100
- const lines = source.split(splitRE);
93
+ const lines = new lines_and_columns_1.LinesAndColumns(source);
101
94
  const start = posToNumberByLines(lines, loc.start.line, loc.start.column);
102
95
  const end = loc.end
103
96
  ? posToNumberByLines(lines, loc.end.line, loc.end.column)
@@ -5,7 +5,7 @@ export interface UniViteFilterPluginOptions {
5
5
  filter: (id: string) => boolean;
6
6
  }
7
7
  export declare function injectAssetPlugin(config: ResolvedConfig, options?: {
8
- isAppX: boolean;
8
+ isAndroidX: boolean;
9
9
  }): void;
10
10
  export declare function injectCssPlugin(config: ResolvedConfig): void;
11
11
  export declare function injectCssPostPlugin(config: ResolvedConfig, newCssPostPlugin: Plugin): void;
@@ -1,7 +1,9 @@
1
1
  import type { ConfigEnv, ResolvedConfig, UserConfig } from 'vite';
2
2
  import { RollupError } from 'rollup';
3
3
  import { CompilerError } from '@vue/compiler-sfc';
4
+ import { codeFrameColumns } from '@babel/code-frame';
4
5
  export declare function withSourcemap(config: ResolvedConfig): boolean;
5
6
  export declare function isInHybridNVue(config: UserConfig | ResolvedConfig): boolean;
6
7
  export declare function isSsr(command: ConfigEnv['command'], config: UserConfig | ResolvedConfig): boolean;
7
8
  export declare function createRollupError(plugin: string, id: string, error: CompilerError | SyntaxError, source?: string): RollupError;
9
+ export declare const generateCodeFrameColumns: typeof codeFrameColumns;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRollupError = exports.isSsr = exports.isInHybridNVue = exports.withSourcemap = void 0;
4
- const utils_1 = require("../plugins/vitejs/utils");
3
+ exports.generateCodeFrameColumns = exports.createRollupError = exports.isSsr = exports.isInHybridNVue = exports.withSourcemap = void 0;
5
4
  const shared_1 = require("@vue/shared");
5
+ const code_frame_1 = require("@babel/code-frame");
6
+ const utils_1 = require("../plugins/vitejs/utils");
6
7
  function withSourcemap(config) {
7
8
  if (config.command === 'serve') {
8
9
  return true;
@@ -40,11 +41,10 @@ function createRollupError(plugin, id, error, source) {
40
41
  };
41
42
  if (source && source.length > 0) {
42
43
  if ('offsetStart' in error && 'offsetEnd' in error) {
43
- rollupError.frame = (0, utils_1.generateCodeFrame)(source, error.offsetStart, error.offsetEnd).replace(/\t/g, ' ');
44
+ rollupError.frame = (0, code_frame_1.codeFrameColumns)(source, (0, utils_1.offsetToStartAndEnd)(source, error.offsetStart, error.offsetEnd));
44
45
  }
45
46
  else {
46
- const { start, end } = (0, utils_1.locToStartAndEnd)(source, error.loc);
47
- rollupError.frame = (0, utils_1.generateCodeFrame)(source, start, end).replace(/\t/g, ' ');
47
+ rollupError.frame = (0, code_frame_1.codeFrameColumns)(source, error.loc);
48
48
  }
49
49
  }
50
50
  }
@@ -60,3 +60,4 @@ function createRollupError(plugin, id, error, source) {
60
60
  return rollupError;
61
61
  }
62
62
  exports.createRollupError = createRollupError;
63
+ exports.generateCodeFrameColumns = code_frame_1.codeFrameColumns;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-3090920231215001",
3
+ "version": "3.0.0-alpha-4000020231218001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -22,20 +22,21 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@ampproject/remapping": "^2.1.2",
25
+ "@babel/code-frame": "^7.23.5",
25
26
  "@babel/core": "^7.21.3",
26
- "@babel/parser": "^7.16.4",
27
+ "@babel/parser": "^7.23.5",
27
28
  "@babel/types": "^7.20.7",
28
- "@dcloudio/uni-i18n": "3.0.0-alpha-3090920231215001",
29
- "@dcloudio/uni-shared": "3.0.0-alpha-3090920231215001",
29
+ "@dcloudio/uni-i18n": "3.0.0-alpha-4000020231218001",
30
+ "@dcloudio/uni-shared": "3.0.0-alpha-4000020231218001",
30
31
  "@intlify/core-base": "9.1.9",
31
32
  "@intlify/shared": "9.1.9",
32
33
  "@intlify/vue-devtools": "9.1.9",
33
34
  "@rollup/pluginutils": "^4.2.0",
34
- "@vue/compiler-core": "3.2.47",
35
- "@vue/compiler-dom": "3.2.47",
36
- "@vue/compiler-sfc": "3.2.47",
37
- "@vue/server-renderer": "3.2.47",
38
- "@vue/shared": "3.2.47",
35
+ "@vue/compiler-core": "3.3.11",
36
+ "@vue/compiler-dom": "3.3.11",
37
+ "@vue/compiler-sfc": "3.3.11",
38
+ "@vue/server-renderer": "3.3.11",
39
+ "@vue/shared": "3.3.11",
39
40
  "autoprefixer": "^10.4.14",
40
41
  "base64url": "^3.0.1",
41
42
  "chokidar": "^3.5.3",
@@ -47,7 +48,8 @@
47
48
  "fast-glob": "^3.2.11",
48
49
  "fs-extra": "^10.0.0",
49
50
  "hash-sum": "^2.0.0",
50
- "jsonc-parser": "^3.0.0",
51
+ "jsonc-parser": "^3.2.0",
52
+ "lines-and-columns": "^2.0.4",
51
53
  "magic-string": "^0.30.0",
52
54
  "merge": "^2.1.1",
53
55
  "mime": "^3.0.0",
@@ -64,7 +66,8 @@
64
66
  },
65
67
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
66
68
  "devDependencies": {
67
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-3090920231215001",
69
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-4000020231218001",
70
+ "@types/babel__code-frame": "^7.0.6",
68
71
  "@types/babel__core": "^7.1.19",
69
72
  "@types/debug": "^4.1.7",
70
73
  "@types/estree": "^0.0.51",
@@ -76,8 +79,9 @@
76
79
  "@types/resolve": "^1.20.2",
77
80
  "@types/sass": "^1.43.1",
78
81
  "@types/stylus": "^0.48.36",
82
+ "code-frame": "link:@types/@babel/code-frame",
79
83
  "postcss": "^8.4.21",
80
84
  "unplugin-auto-import": "^0.16.7",
81
- "vue": "3.2.47"
85
+ "vue": "3.3.11"
82
86
  }
83
87
  }