@dcloudio/uni-cli-shared 3.0.0-alpha-4010120240403003 → 3.0.0-alpha-4010320240415001

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.
Files changed (62) hide show
  1. package/dist/hbx/alias.js +1 -1
  2. package/dist/hbx/index.d.ts +1 -1
  3. package/dist/hbx/log.d.ts +1 -1
  4. package/dist/index.js +0 -1
  5. package/dist/json/mp/jsonFile.d.ts +1 -1
  6. package/dist/json/mp/pages.d.ts +1 -1
  7. package/dist/json/mp/utils.d.ts +1 -1
  8. package/dist/logs/format.d.ts +1 -1
  9. package/dist/mp/ast.d.ts +1 -1
  10. package/dist/mp/externalClasses.d.ts +1 -1
  11. package/dist/mp/imports.d.ts +2 -2
  12. package/dist/mp/plugin.d.ts +1 -1
  13. package/dist/mp/tags.js +0 -1
  14. package/dist/mp/usingComponents.d.ts +1 -1
  15. package/dist/postcss/index.d.ts +1 -1
  16. package/dist/uni_modules.d.ts +3 -0
  17. package/dist/uni_modules.js +10 -1
  18. package/dist/utils.d.ts +2 -2
  19. package/dist/uts.d.ts +1 -1
  20. package/dist/vite/autoImport.d.ts +1 -1
  21. package/dist/vite/index.d.ts +1 -1
  22. package/dist/vite/plugins/console.d.ts +2 -2
  23. package/dist/vite/plugins/copy.d.ts +1 -1
  24. package/dist/vite/plugins/easycom.d.ts +2 -2
  25. package/dist/vite/plugins/index.d.ts +1 -0
  26. package/dist/vite/plugins/index.js +3 -1
  27. package/dist/vite/plugins/inject.d.ts +1 -1
  28. package/dist/vite/plugins/jsonJs.d.ts +3 -3
  29. package/dist/vite/plugins/mainJs.d.ts +2 -2
  30. package/dist/vite/plugins/sfc.d.ts +6 -0
  31. package/dist/vite/plugins/sfc.js +136 -0
  32. package/dist/vite/plugins/uts/ext-api.d.ts +1 -1
  33. package/dist/vite/plugins/uts/uni_modules.d.ts +1 -1
  34. package/dist/vite/plugins/uts/uni_modules.js +5 -5
  35. package/dist/vite/plugins/vitejs/plugins/asset.d.ts +2 -2
  36. package/dist/vite/plugins/vitejs/plugins/css.d.ts +4 -4
  37. package/dist/vite/plugins/vitejs/plugins/css.js +0 -1
  38. package/dist/vite/plugins/vitejs/utils.d.ts +1 -1
  39. package/dist/vite/utils/ast.d.ts +2 -2
  40. package/dist/vite/utils/utils.d.ts +2 -2
  41. package/dist/vue/babel.d.ts +1 -1
  42. package/dist/vue/index.d.ts +0 -1
  43. package/dist/vue/index.js +1 -3
  44. package/dist/vue/parse.d.ts +1 -1
  45. package/dist/vue/transforms/templateTransformAssetUrl.d.ts +1 -1
  46. package/dist/vue/transforms/templateTransformSrcset.d.ts +2 -2
  47. package/dist/vue/transforms/templateUtils.d.ts +1 -1
  48. package/dist/vue/transforms/transformComponent.d.ts +2 -2
  49. package/dist/vue/transforms/transformEvent.d.ts +1 -1
  50. package/dist/vue/transforms/transformPageHead.d.ts +1 -1
  51. package/dist/vue/transforms/transformRef.d.ts +1 -1
  52. package/dist/vue/transforms/transformRefresherSlot.d.ts +1 -1
  53. package/dist/vue/transforms/transformTag.d.ts +1 -1
  54. package/dist/vue/transforms/transformUTSComponent.d.ts +1 -1
  55. package/dist/vue/transforms/vModel.d.ts +1 -1
  56. package/dist/vue/transforms/vOn.d.ts +1 -1
  57. package/dist/vue/utils.d.ts +1 -1
  58. package/dist/watcher.d.ts +1 -1
  59. package/lib/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +44 -22
  60. package/package.json +9 -7
  61. package/dist/vue/polyfill.d.ts +0 -3
  62. package/dist/vue/polyfill.js +0 -24
package/dist/hbx/alias.js CHANGED
@@ -15,7 +15,7 @@ const hbxPlugins = {
15
15
  pug: 'compile-pug-cli/node_modules/pug',
16
16
  };
17
17
  function initModuleAlias() {
18
- const compilerSfcPath = require.resolve('@vue/compiler-sfc');
18
+ const compilerSfcPath = path_1.default.resolve(__dirname, '../../lib/@vue/compiler-sfc');
19
19
  const serverRendererPath = require.resolve('@vue/server-renderer');
20
20
  module_alias_1.default.addAliases({
21
21
  '@vue/shared': require.resolve('@vue/shared'),
@@ -1,4 +1,4 @@
1
1
  export { formatAtFilename } from './log';
2
2
  export * from './env';
3
3
  export { initModuleAlias, installHBuilderXPlugin, formatInstallHBuilderXPluginTips, } from './alias';
4
- export declare function uniHBuilderXConsolePlugin(method?: string): import("vite").Plugin;
4
+ export declare function uniHBuilderXConsolePlugin(method?: string): import("vite").Plugin<any>;
package/dist/hbx/log.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { LogErrorOptions } from 'vite';
2
- import { Formatter } from '../logs/format';
2
+ import type { Formatter } from '../logs/format';
3
3
  export declare function formatAtFilename(filename: string, line?: number, column?: number): string;
4
4
  export declare const h5ServeFormatter: Formatter;
5
5
  export declare const removeInfoFormatter: Formatter;
package/dist/index.js CHANGED
@@ -46,6 +46,5 @@ Object.defineProperty(exports, "getUniExtApiProviderRegisters", { enumerable: tr
46
46
  var messages_1 = require("./messages");
47
47
  Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
48
48
  __exportStar(require("./exports"), exports);
49
- // @ts-ignore
50
49
  var checkUpdate_1 = require("./checkUpdate");
51
50
  Object.defineProperty(exports, "checkUpdate", { enumerable: true, get: function () { return checkUpdate_1.checkUpdate; } });
@@ -1,4 +1,4 @@
1
- import { ComponentJson, PageWindowOptions, UsingComponents } from './types';
1
+ import type { ComponentJson, PageWindowOptions, UsingComponents } from './types';
2
2
  export declare function isMiniProgramPageFile(file: string, inputDir?: string): boolean;
3
3
  export declare function isMiniProgramPageSfcFile(file: string, inputDir?: string): boolean;
4
4
  export declare function hasJsonFile(filename: string): boolean;
@@ -1,4 +1,4 @@
1
- import { AppJson, NetworkTimeout, PageWindowOptions } from './types';
1
+ import type { AppJson, NetworkTimeout, PageWindowOptions } from './types';
2
2
  interface ParsePagesJsonOptions {
3
3
  debug?: boolean;
4
4
  darkmode?: boolean;
@@ -1,3 +1,3 @@
1
- import { AppWindowOptions, PageWindowOptions, TabBar } from './types';
1
+ import type { AppWindowOptions, PageWindowOptions, TabBar } from './types';
2
2
  export declare function parseWindowOptions(style: UniApp.PagesJsonPageStyle, platform: UniApp.PLATFORM, windowOptionsMap?: Record<string, string>): PageWindowOptions | AppWindowOptions;
3
3
  export declare function parseTabBar(tabBar: UniApp.TabBarOptions, platform: UniApp.PLATFORM, tabBarOptionsMap?: Record<string, string>, tabBarItemOptionsMap?: Record<string, string>): TabBar;
@@ -1,4 +1,4 @@
1
- import { LogErrorOptions, LogOptions } from 'vite';
1
+ import type { LogErrorOptions, LogOptions } from 'vite';
2
2
  export interface Formatter<T extends LogOptions = LogOptions> {
3
3
  test: (msg: string, options?: T) => boolean;
4
4
  format: (msg: string, options?: T) => string;
package/dist/mp/ast.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Program } from '@babel/types';
2
- import { ParserPlugin } from '@babel/parser';
2
+ import { type ParserPlugin } from '@babel/parser';
3
3
  export declare function parseProgram(code: string, importer: string, { babelParserPlugins }: {
4
4
  babelParserPlugins?: ParserPlugin[];
5
5
  }): Program;
@@ -1,4 +1,4 @@
1
- import { Program } from '@babel/types';
1
+ import { type Program } from '@babel/types';
2
2
  export declare function hasExternalClasses(code: string): boolean;
3
3
  export declare function findMiniProgramComponentExternalClasses(filename: string): string[] | undefined;
4
4
  export declare function updateMiniProgramComponentExternalClasses(filename: string, classes: string[]): void;
@@ -1,5 +1,5 @@
1
- import { PluginContext } from 'rollup';
2
- import { ImportSpecifier } from 'es-module-lexer';
1
+ import type { PluginContext } from 'rollup';
2
+ import { type ImportSpecifier } from 'es-module-lexer';
3
3
  /**
4
4
  * 暂时没用
5
5
  * @param source
@@ -1,3 +1,3 @@
1
- import { UniViteCopyPluginTarget } from '../vite/plugins/copy';
1
+ import type { UniViteCopyPluginTarget } from '../vite/plugins/copy';
2
2
  export declare const copyMiniProgramPluginJson: UniViteCopyPluginTarget;
3
3
  export declare const copyMiniProgramThemeJson: () => UniViteCopyPluginTarget[];
package/dist/mp/tags.js CHANGED
@@ -49,7 +49,6 @@ exports.HTML_TO_MINI_PROGRAM_TAGS = {
49
49
  select: 'picker',
50
50
  option: 'view',
51
51
  optgroup: 'view',
52
- // label: 'label',
53
52
  fieldset: 'view',
54
53
  datalist: 'picker',
55
54
  legend: 'view',
@@ -1,4 +1,4 @@
1
- import { ImportDeclaration, Program } from '@babel/types';
1
+ import { type ImportDeclaration, type Program } from '@babel/types';
2
2
  import type { PluginContext } from 'rollup';
3
3
  type BindingComponents = Record<string, {
4
4
  tag: string;
@@ -1,7 +1,7 @@
1
1
  import type { Plugin } from 'postcss';
2
2
  import type { Options } from 'autoprefixer';
3
3
  import uniPostcssScopedPlugin from './plugins/stylePluginScoped';
4
- import uniPostcssPlugin, { UniAppCssProcessorOptions } from './plugins/uniapp';
4
+ import uniPostcssPlugin, { type UniAppCssProcessorOptions } from './plugins/uniapp';
5
5
  export { uniPostcssPlugin };
6
6
  export { uniPostcssScopedPlugin };
7
7
  export declare function initPostcssPlugin({ uniApp, autoprefixer, }?: {
@@ -21,6 +21,9 @@ export declare function getUniExtApiProviders(): {
21
21
  name?: string | undefined;
22
22
  servicePlugin?: string | undefined;
23
23
  }[];
24
+ export declare function getUniExtApiPlugins(): {
25
+ plugin: string;
26
+ }[];
24
27
  export declare function getUniExtApiProviderRegisters(): {
25
28
  name: string;
26
29
  service: string;
@@ -3,15 +3,22 @@ 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.parseUTSModuleDeps = exports.capitalize = exports.camelize = exports.parseInjects = exports.parseUniExtApis = exports.getUniExtApiProviderRegisters = exports.getUniExtApiProviders = void 0;
6
+ exports.parseUTSModuleDeps = exports.capitalize = exports.camelize = exports.parseInjects = exports.parseUniExtApis = exports.getUniExtApiProviderRegisters = exports.getUniExtApiPlugins = exports.getUniExtApiProviders = void 0;
7
7
  // 重要:此文件编译后的js,需同步至 vue2 编译器中 uni-cli-shared/lib/uts/uni_modules.js
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const fs_extra_1 = __importDefault(require("fs-extra"));
10
10
  const extApiProviders = [];
11
+ const extApiPlugins = new Set();
11
12
  function getUniExtApiProviders() {
12
13
  return extApiProviders;
13
14
  }
14
15
  exports.getUniExtApiProviders = getUniExtApiProviders;
16
+ function getUniExtApiPlugins() {
17
+ return [...extApiPlugins].map((plugin) => {
18
+ return { plugin };
19
+ });
20
+ }
21
+ exports.getUniExtApiPlugins = getUniExtApiPlugins;
15
22
  function getUniExtApiProviderRegisters() {
16
23
  const result = [];
17
24
  extApiProviders.forEach((provider) => {
@@ -40,6 +47,7 @@ function parseUniExtApis(vite = true, platform, language = 'javascript') {
40
47
  }
41
48
  const injects = {};
42
49
  extApiProviders.length = 0;
50
+ extApiPlugins.clear();
43
51
  fs_extra_1.default.readdirSync(uniModulesDir).forEach((uniModuleDir) => {
44
52
  // 必须以 uni- 开头
45
53
  if (!uniModuleDir.startsWith('uni-')) {
@@ -62,6 +70,7 @@ function parseUniExtApis(vite = true, platform, language = 'javascript') {
62
70
  provider.plugin = uniModuleDir;
63
71
  extApiProviders.push(provider);
64
72
  }
73
+ extApiPlugins.add(uniModuleDir);
65
74
  const curInjects = parseInjects(vite, platform, language, `@/uni_modules/${uniModuleDir}`, uniModuleRootDir, exports);
66
75
  Object.assign(injects, curInjects);
67
76
  }
package/dist/utils.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { default as hash } from 'hash-sum';
2
- import { ElementNode, RootNode, TemplateChildNode } from '@vue/compiler-core';
3
- import { ParserPlugin } from '@babel/parser';
2
+ import { type ElementNode, type RootNode, type TemplateChildNode } from '@vue/compiler-core';
3
+ import type { ParserPlugin } from '@babel/parser';
4
4
  export { camelize, capitalize, isArray } from '@vue/shared';
5
5
  export declare const isWindows: boolean;
6
6
  export declare function normalizePath(id: string): string;
package/dist/uts.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import * as UTSCompiler from '@dcloudio/uni-uts-v1';
3
+ import type * as UTSCompiler from '@dcloudio/uni-uts-v1';
4
4
  import type { EasycomMatcher } from './easycom';
5
5
  /**
6
6
  * 解析 app 平台的 uts 插件,任意平台(android|ios)存在即可
@@ -1,3 +1,3 @@
1
- import { Options } from 'unplugin-auto-import/types';
1
+ import type { Options } from 'unplugin-auto-import/types';
2
2
  export type AutoImportOptions = Options;
3
3
  export declare function initAutoImportOptions(platform: typeof process.env.UNI_UTS_PLATFORM, { imports, ...userOptions }: AutoImportOptions): AutoImportOptions;
@@ -2,7 +2,7 @@ import type { Plugin } from 'vite';
2
2
  import type { EmittedAsset } from 'rollup';
3
3
  import type { ParserOptions } from '@vue/compiler-core';
4
4
  import type { CompilerOptions, SFCStyleCompileOptions, TemplateCompiler } from '@vue/compiler-sfc';
5
- import { UniViteCopyPluginOptions } from './plugins/copy';
5
+ import type { UniViteCopyPluginOptions } from './plugins/copy';
6
6
  export declare const cssTarget = "chrome53";
7
7
  export interface CopyOptions {
8
8
  /**
@@ -1,5 +1,5 @@
1
- import { Plugin } from 'vite';
2
- import { FilterPattern } from '@rollup/pluginutils';
1
+ import type { Plugin } from 'vite';
2
+ import { type FilterPattern } from '@rollup/pluginutils';
3
3
  export interface ConsoleOptions {
4
4
  method: string;
5
5
  filename?: (filename: string) => string;
@@ -1,6 +1,6 @@
1
1
  import type { WatchOptions } from 'chokidar';
2
2
  import type { Plugin } from 'vite';
3
- import { FileWatcherOptions } from '../../watcher';
3
+ import { type FileWatcherOptions } from '../../watcher';
4
4
  export type UniViteCopyPluginTarget = Omit<FileWatcherOptions, 'verbose'> & {
5
5
  watchOptions?: WatchOptions;
6
6
  };
@@ -1,5 +1,5 @@
1
- import { Plugin } from 'vite';
2
- import { FilterPattern } from '@rollup/pluginutils';
1
+ import type { Plugin } from 'vite';
2
+ import { type FilterPattern } from '@rollup/pluginutils';
3
3
  interface UniEasycomPluginOptions {
4
4
  include?: FilterPattern;
5
5
  exclude?: FilterPattern;
@@ -9,6 +9,7 @@ export * from './uts/uni_modules';
9
9
  export * from './uts/uvue';
10
10
  export * from './uts/ext-api';
11
11
  export * from './easycom';
12
+ export { uniViteSfcSrcImportPlugin } from './sfc';
12
13
  export { assetPlugin, parseAssets, getAssetHash } from './vitejs/plugins/asset';
13
14
  export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, rewriteScssReadFileSync, } from './vitejs/plugins/css';
14
15
  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.offsetToStartAndEnd = exports.locToStartAndEnd = exports.generateCodeFrame = exports.rewriteScssReadFileSync = 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.rewriteScssReadFileSync = exports.commonjsProxyRE = exports.cssLangRE = exports.minifyCSS = exports.cssPostPlugin = exports.cssPlugin = exports.isCSSRequest = exports.getAssetHash = exports.parseAssets = exports.assetPlugin = exports.uniViteSfcSrcImportPlugin = void 0;
18
18
  __exportStar(require("./cssScoped"), exports);
19
19
  __exportStar(require("./copy"), exports);
20
20
  __exportStar(require("./inject"), exports);
@@ -26,6 +26,8 @@ __exportStar(require("./uts/uni_modules"), exports);
26
26
  __exportStar(require("./uts/uvue"), exports);
27
27
  __exportStar(require("./uts/ext-api"), exports);
28
28
  __exportStar(require("./easycom"), exports);
29
+ var sfc_1 = require("./sfc");
30
+ Object.defineProperty(exports, "uniViteSfcSrcImportPlugin", { enumerable: true, get: function () { return sfc_1.uniViteSfcSrcImportPlugin; } });
29
31
  var asset_1 = require("./vitejs/plugins/asset");
30
32
  Object.defineProperty(exports, "assetPlugin", { enumerable: true, get: function () { return asset_1.assetPlugin; } });
31
33
  Object.defineProperty(exports, "parseAssets", { enumerable: true, get: function () { return asset_1.parseAssets; } });
@@ -1,5 +1,5 @@
1
1
  import type { Plugin } from 'vite';
2
- import { FilterPattern } from '@rollup/pluginutils';
2
+ import { type FilterPattern } from '@rollup/pluginutils';
3
3
  type Injectment = string | [string, string];
4
4
  export interface InjectOptions {
5
5
  enforce?: 'pre' | 'post';
@@ -1,3 +1,3 @@
1
- import { CreateUniViteFilterPlugin } from '../utils/plugin';
2
- export declare const defineUniPagesJsonPlugin: (createVitePlugin: CreateUniViteFilterPlugin) => import("vite").Plugin;
3
- export declare const defineUniManifestJsonPlugin: (createVitePlugin: CreateUniViteFilterPlugin) => import("vite").Plugin;
1
+ import type { CreateUniViteFilterPlugin } from '../utils/plugin';
2
+ export declare const defineUniPagesJsonPlugin: (createVitePlugin: CreateUniViteFilterPlugin) => import("vite").Plugin<any>;
3
+ export declare const defineUniManifestJsonPlugin: (createVitePlugin: CreateUniViteFilterPlugin) => import("vite").Plugin<any>;
@@ -1,2 +1,2 @@
1
- import { CreateUniViteFilterPlugin } from '../utils/plugin';
2
- export declare function defineUniMainJsPlugin(createUniMainJsPlugin: CreateUniViteFilterPlugin): import("vite").Plugin;
1
+ import type { CreateUniViteFilterPlugin } from '../utils/plugin';
2
+ export declare function defineUniMainJsPlugin(createUniMainJsPlugin: CreateUniViteFilterPlugin): import("vite").Plugin<any>;
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from 'vite';
2
+ export declare function isSrcImport(code: string): boolean;
3
+ export declare function isSrcImportVue(code: string): boolean;
4
+ export declare function uniViteSfcSrcImportPlugin({ onlyVue }?: {
5
+ onlyVue: boolean;
6
+ }): Plugin;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.uniViteSfcSrcImportPlugin = exports.isSrcImportVue = exports.isSrcImport = void 0;
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const magic_string_1 = __importDefault(require("magic-string"));
9
+ const vue_1 = require("../../vue");
10
+ const utils_1 = require("../utils");
11
+ const preprocess_1 = require("../../preprocess");
12
+ const SRC_IMPORT_RE = /<(template|script|style)[^>]*src\s*=\s*["']([^"']+)["'][^>]*>/;
13
+ const SRC_IMPORT_VUE_RE = /<(template|script|style)[^>]*src\s*=\s*["'](.*\.uvue|.*\.vue)["'][^>]*>/;
14
+ function isSrcImport(code) {
15
+ return SRC_IMPORT_RE.test(code);
16
+ }
17
+ exports.isSrcImport = isSrcImport;
18
+ function isSrcImportVue(code) {
19
+ return SRC_IMPORT_VUE_RE.test(code);
20
+ }
21
+ exports.isSrcImportVue = isSrcImportVue;
22
+ function uniViteSfcSrcImportPlugin({ onlyVue } = { onlyVue: true }) {
23
+ const { parse } = require('@vue/compiler-sfc');
24
+ const hasImport = onlyVue ? isSrcImportVue : isSrcImport;
25
+ const isValidSrc = onlyVue ? vue_1.isVueSfcFile : () => true;
26
+ return {
27
+ name: 'uni:sfc-src-import',
28
+ async transform(code, id) {
29
+ if (!(0, vue_1.isVueSfcFile)(id)) {
30
+ return;
31
+ }
32
+ if (!hasImport(code)) {
33
+ return;
34
+ }
35
+ const s = new magic_string_1.default(code);
36
+ const sourceMap = process.env.NODE_ENV === 'development';
37
+ const createDescriptor = (filename, code, from) => {
38
+ if (from === 'vue' || (0, vue_1.isVueSfcFile)(filename)) {
39
+ const { descriptor, errors } = parse(code, {
40
+ filename,
41
+ sourceMap,
42
+ });
43
+ errors.forEach((error) => this.error((0, utils_1.createRollupError)('', filename, error, code)));
44
+ return descriptor;
45
+ }
46
+ else {
47
+ const descriptor = {
48
+ filename,
49
+ source: fs_extra_1.default.readFileSync(filename, 'utf-8'),
50
+ template: null,
51
+ script: null,
52
+ scriptSetup: null,
53
+ styles: [],
54
+ customBlocks: [],
55
+ };
56
+ if (from === 'template') {
57
+ descriptor.template = {
58
+ content: descriptor.source,
59
+ };
60
+ }
61
+ else if (from === 'script') {
62
+ descriptor.script = {
63
+ content: descriptor.source,
64
+ };
65
+ }
66
+ else if (from === 'style') {
67
+ descriptor.styles = [
68
+ {
69
+ content: descriptor.source,
70
+ },
71
+ ];
72
+ }
73
+ return descriptor;
74
+ }
75
+ };
76
+ const descriptor = createDescriptor(id, code, 'vue');
77
+ const cache = new Map();
78
+ const getSrcDescriptor = async (src, from) => {
79
+ if (cache.has(src)) {
80
+ return cache.get(src);
81
+ }
82
+ const resolved = await this.resolve(src, descriptor.filename);
83
+ if (resolved) {
84
+ const filename = resolved.id;
85
+ const srcDescriptor = createDescriptor(filename, (0, preprocess_1.preUVueJs)((0, preprocess_1.preUVueHtml)(fs_extra_1.default.readFileSync(filename, 'utf-8'))), from);
86
+ cache.set(src, srcDescriptor);
87
+ this.addWatchFile(filename);
88
+ return srcDescriptor;
89
+ }
90
+ };
91
+ if (descriptor.template?.src && isValidSrc(descriptor.template.src)) {
92
+ const srcDescriptor = await getSrcDescriptor(descriptor.template.src, 'template');
93
+ if (srcDescriptor && srcDescriptor.template?.content) {
94
+ overwriteContent(s, descriptor.template.loc, srcDescriptor.template.content);
95
+ }
96
+ }
97
+ if (descriptor.script?.src && isValidSrc(descriptor.script.src)) {
98
+ const srcDescriptor = await getSrcDescriptor(descriptor.script.src, 'script');
99
+ if (srcDescriptor && srcDescriptor.script?.content) {
100
+ overwriteContent(s, descriptor.script.loc, srcDescriptor.script.content);
101
+ }
102
+ }
103
+ for (const style of descriptor.styles) {
104
+ if (style.src && isValidSrc(style.src)) {
105
+ const srcDescriptor = await getSrcDescriptor(style.src, 'style');
106
+ if (srcDescriptor && srcDescriptor.styles[0]) {
107
+ overwriteContent(s, style.loc, srcDescriptor.styles[0].content);
108
+ }
109
+ }
110
+ }
111
+ if (!s.hasChanged()) {
112
+ return;
113
+ }
114
+ // 移除所有的 src 属性
115
+ const regex = /(<(template|script|style)[^>]*)src\s*=\s*["']([^"']+)["']([^>]*>)/g;
116
+ let match;
117
+ while ((match = regex.exec(code))) {
118
+ const [_, start, _tag, _src, end] = match;
119
+ s.overwrite(match.index, match.index + _.length, `${start}${end}`);
120
+ }
121
+ return {
122
+ code: s.toString(),
123
+ map: sourceMap ? s.generateMap({ hires: true }) : { mappings: '' },
124
+ };
125
+ },
126
+ };
127
+ }
128
+ exports.uniViteSfcSrcImportPlugin = uniViteSfcSrcImportPlugin;
129
+ function overwriteContent(s, loc, content) {
130
+ if (loc.start.offset === loc.end.offset) {
131
+ s.appendRight(loc.start.offset, content);
132
+ }
133
+ else {
134
+ s.overwrite(loc.start.offset, loc.end.offset, content);
135
+ }
136
+ }
@@ -1,5 +1,5 @@
1
1
  import type { Plugin } from 'vite';
2
- import { Injects, parseUniExtApis } from '../../../uni_modules';
2
+ import { type Injects, parseUniExtApis } from '../../../uni_modules';
3
3
  export declare const parseUniExtApisOnce: typeof parseUniExtApis;
4
4
  export declare function uniUTSExtApiReplace(): Plugin;
5
5
  /**
@@ -6,7 +6,7 @@ interface UniUTSPluginOptions {
6
6
  }
7
7
  export declare const utsPlugins: Set<string>;
8
8
  export declare function uniUTSUniModulesPlugin(options?: UniUTSPluginOptions): Plugin;
9
- export declare function buildUniExtApiProviders(): Promise<void>;
9
+ export declare function buildUniExtApis(): Promise<void>;
10
10
  export declare function resolveExtApiProvider(pkg: Record<string, any>): {
11
11
  name?: string | undefined;
12
12
  plugin?: string | undefined;
@@ -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.resolveExtApiProvider = exports.buildUniExtApiProviders = exports.uniUTSUniModulesPlugin = exports.utsPlugins = void 0;
6
+ exports.resolveExtApiProvider = exports.buildUniExtApis = exports.uniUTSUniModulesPlugin = exports.utsPlugins = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const uni_shared_1 = require("@dcloudio/uni-shared");
@@ -53,8 +53,8 @@ function uniUTSUniModulesPlugin(options = {}) {
53
53
  });
54
54
  };
55
55
  uniExtApiCompiler = async () => {
56
- // 获取 provider 扩展
57
- const plugins = (0, uni_modules_1.getUniExtApiProviders)().filter((provider) => !exports.utsPlugins.has(provider.plugin));
56
+ // 获取 provider 扩展(编译所有uni)
57
+ const plugins = (0, uni_modules_1.getUniExtApiPlugins)().filter((provider) => !exports.utsPlugins.has(provider.plugin));
58
58
  for (const plugin of plugins) {
59
59
  const result = await compilePlugin(path_1.default.resolve(process.env.UNI_INPUT_DIR, 'uni_modules', plugin.plugin));
60
60
  if (result) {
@@ -137,10 +137,10 @@ function uniUTSUniModulesPlugin(options = {}) {
137
137
  };
138
138
  }
139
139
  exports.uniUTSUniModulesPlugin = uniUTSUniModulesPlugin;
140
- async function buildUniExtApiProviders() {
140
+ async function buildUniExtApis() {
141
141
  await uniExtApiCompiler();
142
142
  }
143
- exports.buildUniExtApiProviders = buildUniExtApiProviders;
143
+ exports.buildUniExtApis = buildUniExtApis;
144
144
  function resolveExtApiProvider(pkg) {
145
145
  const provider = pkg.uni_modules?.['uni-ext-api']?.provider;
146
146
  if (provider?.service) {
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type { OutputOptions, PluginContext, RenderedChunk } from 'rollup';
3
- import { Plugin } from '../plugin';
4
- import { ResolvedConfig } from '../config';
3
+ import type { Plugin } from '../plugin';
4
+ import type { ResolvedConfig } from '../config';
5
5
  export declare const assetUrlRE: RegExp;
6
6
  export declare const chunkToEmittedAssetsMap: WeakMap<RenderedChunk, Set<string>>;
7
7
  /**
@@ -1,8 +1,8 @@
1
- import { ExistingRawSourceMap, RollupError } from 'rollup';
2
- import { Plugin } from '../plugin';
3
- import { ResolvedConfig } from '../config';
1
+ import type { SFCDescriptor } from '@vue/compiler-sfc';
2
+ import type { ExistingRawSourceMap, RollupError } from 'rollup';
3
+ import type { Plugin } from '../plugin';
4
+ import type { ResolvedConfig } from '../config';
4
5
  import * as Postcss from 'postcss';
5
- import { SFCDescriptor } from '@vue/compiler-sfc';
6
6
  export interface CSSOptions {
7
7
  /**
8
8
  * https://github.com/css-modules/postcss-modules
@@ -607,7 +607,6 @@ async function resolvePostcssConfig(config) {
607
607
  else {
608
608
  const searchPath = (0, shared_1.isString)(inlineOptions) ? inlineOptions : config.root;
609
609
  try {
610
- // @ts-ignore
611
610
  result = await (0, postcss_load_config_1.default)({}, searchPath);
612
611
  }
613
612
  catch (e) {
@@ -1,5 +1,5 @@
1
1
  import type { DecodedSourceMap, RawSourceMap } from '@ampproject/remapping';
2
- import { Position, SourceLocation } from '@vue/compiler-core';
2
+ import type { Position, SourceLocation } from '@vue/compiler-core';
3
3
  import { LinesAndColumns } from 'lines-and-columns';
4
4
  export declare function slash(p: string): string;
5
5
  export declare const bareImportRE: RegExp;
@@ -1,5 +1,5 @@
1
- import type { Literal, BaseNode, Property, Identifier, CallExpression, AssignmentExpression, MemberExpression, MethodDefinition, ExportSpecifier } from 'estree';
2
- import { Node, ElementNode, DirectiveNode, SimpleExpressionNode, AttributeNode, CompoundExpressionNode } from '@vue/compiler-core';
1
+ import type { AssignmentExpression, BaseNode, CallExpression, ExportSpecifier, Identifier, Literal, MemberExpression, MethodDefinition, Property } from 'estree';
2
+ import { type AttributeNode, type CompoundExpressionNode, type DirectiveNode, type ElementNode, type Node, type SimpleExpressionNode } from '@vue/compiler-core';
3
3
  export declare const isProperty: (node: BaseNode) => node is Property;
4
4
  export declare const isIdentifier: (node: BaseNode) => node is Identifier;
5
5
  export declare const isAssignmentExpression: (node: BaseNode) => node is AssignmentExpression;
@@ -1,6 +1,6 @@
1
1
  import type { ConfigEnv, ResolvedConfig, UserConfig } from 'vite';
2
- import { RollupError } from 'rollup';
3
- import { CompilerError } from '@vue/compiler-sfc';
2
+ import type { RollupError } from 'rollup';
3
+ import type { CompilerError } from '@vue/compiler-sfc';
4
4
  import { codeFrameColumns } from '@babel/code-frame';
5
5
  export declare function withSourcemap(config: ResolvedConfig): boolean;
6
6
  export declare function isInHybridNVue(config: UserConfig | ResolvedConfig): boolean;
@@ -1,3 +1,3 @@
1
- import * as BabelCore from '@babel/core';
1
+ import type * as BabelCore from '@babel/core';
2
2
  import type { PluginObj } from '@babel/core';
3
3
  export declare function transformUniH5Jsx({ types }: typeof BabelCore): PluginObj;
@@ -1,6 +1,5 @@
1
1
  export * from './transforms';
2
2
  export * from './utils';
3
3
  export * from './parse';
4
- export { rewriteCompileScriptSetupLangOnce } from './polyfill';
5
4
  export { transformUniH5Jsx } from './babel';
6
5
  export { isExternalUrl } from './transforms/templateUtils';
package/dist/vue/index.js CHANGED
@@ -14,12 +14,10 @@ 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.isExternalUrl = exports.transformUniH5Jsx = exports.rewriteCompileScriptSetupLangOnce = void 0;
17
+ exports.isExternalUrl = exports.transformUniH5Jsx = void 0;
18
18
  __exportStar(require("./transforms"), exports);
19
19
  __exportStar(require("./utils"), exports);
20
20
  __exportStar(require("./parse"), exports);
21
- var polyfill_1 = require("./polyfill");
22
- Object.defineProperty(exports, "rewriteCompileScriptSetupLangOnce", { enumerable: true, get: function () { return polyfill_1.rewriteCompileScriptSetupLangOnce; } });
23
21
  var babel_1 = require("./babel");
24
22
  Object.defineProperty(exports, "transformUniH5Jsx", { enumerable: true, get: function () { return babel_1.transformUniH5Jsx; } });
25
23
  var templateUtils_1 = require("./transforms/templateUtils");
@@ -1,4 +1,4 @@
1
- import { ElementNode, RootNode } from '@vue/compiler-core';
1
+ import { type ElementNode, type RootNode } from '@vue/compiler-core';
2
2
  export declare function parseVueCode(code: string, isNVue?: boolean): {
3
3
  code: string;
4
4
  files?: undefined;
@@ -1,4 +1,4 @@
1
- import { NodeTransform } from '@vue/compiler-core';
1
+ import { type NodeTransform } from '@vue/compiler-core';
2
2
  export interface AssetURLTagConfig {
3
3
  [name: string]: string[];
4
4
  }
@@ -1,4 +1,4 @@
1
- import { NodeTransform } from '@vue/compiler-core';
2
- import { AssetURLOptions } from './templateTransformAssetUrl';
1
+ import { type NodeTransform } from '@vue/compiler-core';
2
+ import { type AssetURLOptions } from './templateTransformAssetUrl';
3
3
  export declare const createSrcsetTransformWithOptions: (options: Required<AssetURLOptions>) => NodeTransform;
4
4
  export declare const transformSrcset: NodeTransform;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { UrlWithStringQuery } from 'url';
2
+ import { type UrlWithStringQuery } from 'url';
3
3
  export declare function isRelativeUrl(url: string): boolean;
4
4
  export declare function isExternalUrl(url: string): boolean;
5
5
  export declare function isDataUrl(url: string): boolean;
@@ -1,3 +1,3 @@
1
- import { NodeTypes, RootNode, TemplateChildNode, TransformContext } from '@vue/compiler-core';
2
- import { COMPONENT_BIND_LINK, COMPONENT_ON_LINK } from '../../mp/constants';
1
+ import { NodeTypes, type RootNode, type TemplateChildNode, type TransformContext } from '@vue/compiler-core';
2
+ import type { COMPONENT_BIND_LINK, COMPONENT_ON_LINK } from '../../mp/constants';
3
3
  export declare function createTransformComponentLink(name: typeof COMPONENT_BIND_LINK | typeof COMPONENT_ON_LINK, type?: NodeTypes.ATTRIBUTE | NodeTypes.DIRECTIVE): (node: RootNode | TemplateChildNode, context: TransformContext) => void;
@@ -1,2 +1,2 @@
1
- import { DirectiveNode, ElementNode, NodeTransform } from '@vue/compiler-core';
1
+ import type { DirectiveNode, ElementNode, NodeTransform } from '@vue/compiler-core';
2
2
  export declare function createTransformEvent(options: Record<string, string | ((node: ElementNode, dir: DirectiveNode) => string)>): NodeTransform;
@@ -1,2 +1,2 @@
1
- import { NodeTransform } from '@vue/compiler-core';
1
+ import type { NodeTransform } from '@vue/compiler-core';
2
2
  export declare const transformPageHead: NodeTransform;
@@ -1,2 +1,2 @@
1
- import { RootNode, TemplateChildNode, TransformContext } from '@vue/compiler-core';
1
+ import { type RootNode, type TemplateChildNode, type TransformContext } from '@vue/compiler-core';
2
2
  export declare function transformRef(node: RootNode | TemplateChildNode, context: TransformContext): void;
@@ -1,4 +1,4 @@
1
- import { RootNode, TemplateChildNode } from '@vue/compiler-core';
1
+ import { type RootNode, type TemplateChildNode } from '@vue/compiler-core';
2
2
  /**
3
3
  * 将scroll-view、list-view内的<view slot="refresher">转为vue支持的用法,此transform需要再较早时机执行,暂时放在transformTag前。此时node.tag还没有加上v-uni-前缀
4
4
  * @param node
@@ -1,2 +1,2 @@
1
- import { NodeTransform } from '@vue/compiler-core';
1
+ import type { NodeTransform } from '@vue/compiler-core';
2
2
  export declare function createTransformTag(opts: Record<string, string>): NodeTransform;
@@ -1,4 +1,4 @@
1
- import { NodeTransform } from '@vue/compiler-core';
1
+ import type { NodeTransform } from '@vue/compiler-core';
2
2
  /**
3
3
  * 将uts组件保存到自定义组件列表中
4
4
  * @param node
@@ -1,4 +1,4 @@
1
- import { DirectiveTransform, ElementNode, TransformContext } from '@vue/compiler-core';
1
+ import type { DirectiveTransform, ElementNode, TransformContext } from '@vue/compiler-core';
2
2
  export declare function defaultMatch(node: ElementNode, context: TransformContext): boolean;
3
3
  interface CreateTransformModelOptions {
4
4
  match: typeof defaultMatch;
@@ -1,4 +1,4 @@
1
- import { ExpressionNode, DirectiveTransform, ElementNode, TransformContext } from '@vue/compiler-core';
1
+ import { type DirectiveTransform, type ElementNode, type ExpressionNode, type TransformContext } from '@vue/compiler-core';
2
2
  export declare function defaultMatch(name: string, node: ElementNode, context: TransformContext): boolean;
3
3
  interface CreateTransformOnOptions {
4
4
  match: typeof defaultMatch;
@@ -1,4 +1,4 @@
1
- import { AttributeNode, ComponentNode, DirectiveNode, ElementNode, RootNode, ExpressionNode, TemplateChildNode, TransformContext, SourceLocation, Position } from '@vue/compiler-core';
1
+ import { type AttributeNode, type ComponentNode, type DirectiveNode, type ElementNode, type ExpressionNode, type Position, type RootNode, type SourceLocation, type TemplateChildNode, type TransformContext } from '@vue/compiler-core';
2
2
  export declare const VUE_REF = "r";
3
3
  export declare const VUE_REF_IN_FOR = "r-i-f";
4
4
  export declare function isVueSfcFile(id: string): boolean;
package/dist/watcher.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { FSWatcher, WatchOptions } from 'chokidar';
2
+ import { type FSWatcher, type WatchOptions } from 'chokidar';
3
3
  type FileTransform = (source: Buffer, filename: string) => void | string;
4
4
  export interface FileWatcherOptions {
5
5
  src: string | string[];
@@ -2076,8 +2076,8 @@ function isEmpty(node) {
2076
2076
  }
2077
2077
  return true;
2078
2078
  }
2079
- function hmrShouldReload(prevImports, next) {
2080
- if (!next.scriptSetup || next.scriptSetup.lang !== "ts" && next.scriptSetup.lang !== "tsx") {
2079
+ function hmrShouldReload(prevImports, next) { // fixed by xxxxxx
2080
+ if (!next.scriptSetup || next.scriptSetup.lang !== "ts" && next.scriptSetup.lang !== "tsx" && next.scriptSetup.lang !== "uts") {
2081
2081
  return false;
2082
2082
  }
2083
2083
  for (const key in prevImports) {
@@ -15532,6 +15532,8 @@ class ScriptCompileContext {
15532
15532
  const scriptSetupLang = scriptSetup && scriptSetup.lang;
15533
15533
  this.isJS = scriptLang === "js" || scriptLang === "jsx" || scriptSetupLang === "js" || scriptSetupLang === "jsx";
15534
15534
  this.isTS = scriptLang === "ts" || scriptLang === "tsx" || scriptSetupLang === "ts" || scriptSetupLang === "tsx";
15535
+ // fixed by xxxxxx
15536
+ this.isUTS = scriptLang === "uts" || scriptSetupLang === "uts"
15535
15537
  const customElement = options.customElement;
15536
15538
  const filename = this.descriptor.filename;
15537
15539
  if (customElement) {
@@ -15540,14 +15542,18 @@ class ScriptCompileContext {
15540
15542
  const plugins = resolveParserPlugins(
15541
15543
  scriptLang || scriptSetupLang,
15542
15544
  options.babelParserPlugins
15543
- );
15544
- function parse(input, offset) {
15545
+ );// fixed by xxxxxx
15546
+ function parse(input, offset, startLine) {
15545
15547
  try {
15546
15548
  return parser$1.parse(input, {
15547
15549
  plugins,
15548
- sourceType: "module"
15550
+ sourceType: "module",
15549
15551
  }).program;
15550
15552
  } catch (e) {
15553
+ // fixed by xxxxxx
15554
+ if (e.loc && startLine) {
15555
+ e.loc.line = e.loc.line + (startLine - 1)
15556
+ }
15551
15557
  e.message = `[vue/compiler-sfc] ${e.message}
15552
15558
 
15553
15559
  ${descriptor.filename}
@@ -15559,8 +15565,8 @@ ${shared.generateCodeFrame(
15559
15565
  throw e;
15560
15566
  }
15561
15567
  }
15562
- this.scriptAst = descriptor.script && parse(descriptor.script.content, descriptor.script.loc.start.offset);
15563
- this.scriptSetupAst = descriptor.scriptSetup && parse(descriptor.scriptSetup.content, this.startOffset);
15568
+ this.scriptAst = descriptor.script && parse(descriptor.script.content, descriptor.script.loc.start.offset, descriptor.script.loc.start.line);// fixed by xxxxxx
15569
+ this.scriptSetupAst = descriptor.scriptSetup && parse(descriptor.scriptSetup.content, this.startOffset, descriptor.scriptSetup.loc.start.line);// fixed by xxxxxx
15564
15570
  }
15565
15571
  helper(key) {
15566
15572
  this.helperImports.add(key);
@@ -15595,8 +15601,8 @@ function resolveParserPlugins(lang, userPlugins, dts = false) {
15595
15601
  plugins.push("jsx");
15596
15602
  } else if (userPlugins) {
15597
15603
  userPlugins = userPlugins.filter((p) => p !== "jsx");
15598
- }
15599
- if (lang === "ts" || lang === "tsx") {
15604
+ } // fixed by xxxxxx
15605
+ if (lang === "ts" || lang === "tsx" || lang === 'uts') {
15600
15606
  plugins.push(["typescript", { dts }], "explicitResourceManagement");
15601
15607
  if (!userPlugins || !userPlugins.includes("decorators")) {
15602
15608
  plugins.push("decorators-legacy");
@@ -15704,7 +15710,7 @@ const normalScriptDefaultVar = `__default__`;
15704
15710
  function processNormalScript(ctx, scopeId) {
15705
15711
  var _a;
15706
15712
  const script = ctx.descriptor.script;
15707
- if (script.lang && !ctx.isJS && !ctx.isTS) {
15713
+ if (script.lang && !ctx.isJS && !ctx.isTS && !ctx.isUTS) {
15708
15714
  return script;
15709
15715
  }
15710
15716
  try {
@@ -15718,6 +15724,17 @@ function processNormalScript(ctx, scopeId) {
15718
15724
  const defaultVar = genDefaultAs || normalScriptDefaultVar;
15719
15725
  const s = new MagicString(content);
15720
15726
  rewriteDefaultAST(scriptAst.body, s, defaultVar);
15727
+ // fixed by xxxxxx
15728
+ if(ctx.isUTS) {
15729
+ scriptAst.body.forEach((node) => {
15730
+ if (node.type === "ExportDefaultDeclaration") {
15731
+ if (node.declaration.type === "ObjectExpression") {
15732
+ s.appendLeft(node.declaration.start, `defineComponent(`);
15733
+ s.appendRight (node.declaration.end, `)`);
15734
+ }
15735
+ }
15736
+ })
15737
+ }
15721
15738
  content = s.toString();
15722
15739
  if (cssVars.length && !((_a = ctx.options.templateOptions) == null ? void 0 : _a.ssr)) {
15723
15740
  content += genNormalScriptCssVarsCode(
@@ -18397,7 +18414,10 @@ function importSourceToScope(ctx, node, scope, source) {
18397
18414
  } else if (source.startsWith(".")) {
18398
18415
  const filename = joinPaths(path$3.dirname(scope.filename), source);
18399
18416
  resolved = resolveExt(filename, fs);
18400
- } else {
18417
+ // fixed by xxxxxx
18418
+ } else if(process.env.UNI_INPUT_DIR && source.startsWith("@/")) {
18419
+ resolved = resolveExt(joinPaths(process.env.UNI_INPUT_DIR, source.replace("@/", "")), fs);
18420
+ } else {
18401
18421
  if (!ts) {
18402
18422
  if (loadTS)
18403
18423
  ts = loadTS();
@@ -18539,7 +18559,8 @@ function fileToScope(ctx, filename, asGlobal = false) {
18539
18559
  }
18540
18560
  function parseFile(filename, content, parserPlugins) {
18541
18561
  const ext = path$3.extname(filename);
18542
- if (ext === ".ts" || ext === ".tsx") {
18562
+ // fixed by xxxxxx
18563
+ if (ext === ".uts" || ext === ".ts" || ext === ".tsx") {
18543
18564
  return parser$1.parse(content, {
18544
18565
  plugins: resolveParserPlugins(
18545
18566
  ext.slice(1),
@@ -18548,7 +18569,8 @@ function parseFile(filename, content, parserPlugins) {
18548
18569
  ),
18549
18570
  sourceType: "module"
18550
18571
  }).program.body;
18551
- } else if (ext === ".vue") {
18572
+ // fixed by xxxxxx
18573
+ } else if (ext === ".vue" || ext === ".uvue" || ext === ".nvue") {
18552
18574
  const {
18553
18575
  descriptor: { script, scriptSetup }
18554
18576
  } = parse$2(content);
@@ -19181,8 +19203,8 @@ function genModelProps(ctx) {
19181
19203
  skipCheck && "skipCheck: true"
19182
19204
  ]);
19183
19205
  let decl;
19184
- if (runtimeType && options) {
19185
- decl = ctx.isTS ? `{ ${codegenOptions}, ...${options} }` : `Object.assign({ ${codegenOptions} }, ${options})`;
19206
+ if (runtimeType && options) { // fixed by xxxxxx
19207
+ decl = ctx.isTS || ctx.isUTS ? `{ ${codegenOptions}, ...${options} }` : `Object.assign({ ${codegenOptions} }, ${options})`;
19186
19208
  } else {
19187
19209
  decl = options || (runtimeType ? `{ ${codegenOptions} }` : "{}");
19188
19210
  }
@@ -19850,8 +19872,8 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
19850
19872
  throw new Error(
19851
19873
  `[@vue/compiler-sfc] <script> and <script setup> must have the same language type.`
19852
19874
  );
19853
- }
19854
- if (scriptSetupLang && !ctx.isJS && !ctx.isTS) {
19875
+ } // fixed by xxxxxx
19876
+ if (scriptSetupLang && !ctx.isJS && !ctx.isTS && !ctx.isUTS) {
19855
19877
  return scriptSetup;
19856
19878
  }
19857
19879
  const scriptBindings = /* @__PURE__ */ Object.create(null);
@@ -19879,8 +19901,8 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
19879
19901
  ctx.s.move(start, end, 0);
19880
19902
  }
19881
19903
  function registerUserImport(source2, local, imported, isType, isFromSetup, needTemplateUsageCheck) {
19882
- let isUsedInTemplate = needTemplateUsageCheck;
19883
- if (needTemplateUsageCheck && ctx.isTS && sfc.template && !sfc.template.src && !sfc.template.lang) {
19904
+ let isUsedInTemplate = needTemplateUsageCheck; // fixed by xxxxxx
19905
+ if (needTemplateUsageCheck && ( ctx.isTS || ctx.isUTS ) && sfc.template && !sfc.template.src && !sfc.template.lang) {
19884
19906
  isUsedInTemplate = isImportUsed(local, sfc);
19885
19907
  }
19886
19908
  ctx.userImports[local] = {
@@ -20169,7 +20191,7 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
20169
20191
  node
20170
20192
  );
20171
20193
  }
20172
- if (ctx.isTS) {
20194
+ if (ctx.isTS || ctx.isUTS) { // fixed by xxxxxx
20173
20195
  if (node.type.startsWith("TS") || node.type === "ExportNamedDeclaration" && node.exportKind === "type" || node.type === "VariableDeclaration" && node.declare) {
20174
20196
  if (node.type !== "TSEnumDeclaration") {
20175
20197
  hoistNode(node);
@@ -20263,7 +20285,7 @@ ${genCssVarsCode(
20263
20285
  }
20264
20286
  }
20265
20287
  if (hasAwait) {
20266
- const any = ctx.isTS ? `: any` : ``;
20288
+ const any = (ctx.isTS || ctx.isUTS) ? `: any` : ``; // fixed by xxxxxx
20267
20289
  ctx.s.prependLeft(startOffset, `
20268
20290
  let __temp${any}, __restore${any}
20269
20291
  `);
@@ -20395,7 +20417,7 @@ return ${returned}
20395
20417
  }
20396
20418
  const exposeCall = ctx.hasDefineExposeCall || options.inlineTemplate ? `` : ` __expose();
20397
20419
  `;
20398
- if (ctx.isTS) {
20420
+ if (ctx.isTS || ctx.isUTS) { // fixed by xxxxxx
20399
20421
  const def = (defaultExport ? `
20400
20422
  ...${normalScriptDefaultVar},` : ``) + (definedOptions ? `
20401
20423
  ...${definedOptions},` : "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-4010120240403003",
3
+ "version": "3.0.0-alpha-4010320240415001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -26,8 +26,8 @@
26
26
  "@babel/core": "^7.23.3",
27
27
  "@babel/parser": "^7.23.9",
28
28
  "@babel/types": "^7.20.7",
29
- "@dcloudio/uni-i18n": "3.0.0-alpha-4010120240403003",
30
- "@dcloudio/uni-shared": "3.0.0-alpha-4010120240403003",
29
+ "@dcloudio/uni-i18n": "3.0.0-alpha-4010320240415001",
30
+ "@dcloudio/uni-shared": "3.0.0-alpha-4010320240415001",
31
31
  "@intlify/core-base": "9.1.9",
32
32
  "@intlify/shared": "9.1.9",
33
33
  "@intlify/vue-devtools": "9.1.9",
@@ -35,15 +35,16 @@
35
35
  "@vue/compiler-core": "3.4.21",
36
36
  "@vue/compiler-dom": "3.4.21",
37
37
  "@vue/compiler-sfc": "3.4.21",
38
+ "@vue/compiler-ssr": "3.4.21",
38
39
  "@vue/server-renderer": "3.4.21",
39
40
  "@vue/shared": "3.4.21",
40
- "autoprefixer": "^10.4.18",
41
+ "autoprefixer": "^10.4.19",
41
42
  "base64url": "^3.0.1",
42
43
  "chokidar": "^3.5.3",
43
44
  "compare-versions": "^3.6.0",
44
45
  "debug": "^4.3.3",
45
46
  "es-module-lexer": "^1.2.1",
46
- "esbuild": "^0.17.5",
47
+ "esbuild": "^0.20.1",
47
48
  "estree-walker": "^2.0.2",
48
49
  "fast-glob": "^3.2.11",
49
50
  "fs-extra": "^10.0.0",
@@ -61,17 +62,18 @@
61
62
  "postcss-modules": "^4.3.0",
62
63
  "postcss-selector-parser": "^6.0.6",
63
64
  "resolve": "^1.22.1",
65
+ "source-map-js": "^1.0.2",
64
66
  "tapable": "^2.2.0",
65
67
  "unplugin-auto-import": "^0.16.7",
66
68
  "xregexp": "3.1.0"
67
69
  },
68
70
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
69
71
  "devDependencies": {
70
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-4010120240403003",
72
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-4010320240415001",
71
73
  "@types/babel__code-frame": "^7.0.6",
72
74
  "@types/babel__core": "^7.1.19",
73
75
  "@types/debug": "^4.1.7",
74
- "@types/estree": "^0.0.51",
76
+ "@types/estree": "^1.0.5",
75
77
  "@types/fs-extra": "^9.0.13",
76
78
  "@types/hash-sum": "^1.0.0",
77
79
  "@types/less": "^3.0.3",
@@ -1,3 +0,0 @@
1
- export declare const rewriteCompileScriptSetupLangOnce: typeof rewriteCompileScriptSetupLang;
2
- declare function rewriteCompileScriptSetupLang(): void;
3
- export {};
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rewriteCompileScriptSetupLangOnce = void 0;
4
- const uni_shared_1 = require("@dcloudio/uni-shared");
5
- const resolve_1 = require("../resolve");
6
- exports.rewriteCompileScriptSetupLangOnce = (0, uni_shared_1.once)(rewriteCompileScriptSetupLang);
7
- // 临时重写lang,用于激活 compileScript 内部判断,确保 setup 生成 export default defineComponent({})
8
- // uts2js (iOS|web)
9
- function rewriteCompileScriptSetupLang() {
10
- const compiler = require((0, resolve_1.resolveBuiltIn)('@vue/compiler-sfc'));
11
- const { compileScript } = compiler;
12
- // script-setup + v-bind
13
- compiler.compileScript = (sfc, options) => {
14
- const originalScriptSetupLang = sfc.scriptSetup?.lang;
15
- if (originalScriptSetupLang === 'uts') {
16
- sfc.scriptSetup.lang = 'ts';
17
- }
18
- const result = compileScript(sfc, options);
19
- if (originalScriptSetupLang === 'uts') {
20
- sfc.scriptSetup.lang = 'uts';
21
- }
22
- return result;
23
- };
24
- }