@dcloudio/uni-cli-shared 2.0.2-alpha-3061420221216003 → 2.0.2-alpha-3061520221220001

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/lib/pages.js CHANGED
@@ -425,6 +425,16 @@ function initAutoComponents () {
425
425
 
426
426
  function initAutoImportScanComponents () {
427
427
  const components = initAutoComponents()
428
+
429
+ const {
430
+ initUTSComponents
431
+ } = require('./uts/uts.js')
432
+
433
+ initUTSComponents(process.env.UNI_INPUT_DIR, process.env.UNI_PLATFORM).forEach((item) => {
434
+ components[item.pattern.source] = item.replacement.replace('\0', '').replace('?uts-proxy',
435
+ '/package.json?uts-proxy')
436
+ })
437
+
428
438
  if (process.env.UNI_PLATFORM === 'quickapp-native') {
429
439
  if (!uniQuickAppAutoImportScanComponents) {
430
440
  uniQuickAppAutoImportScanComponents = getAutoComponentsByDir(
@@ -463,8 +473,7 @@ function initAutoImportComponents (easycom = {}) {
463
473
  }
464
474
  initBuiltInEasycom(BUILT_IN_EASYCOMS, usingAutoImportComponents)
465
475
  // 目前仅 mp-weixin 内置支持 page-meta 等组件
466
- if (process.env.UNI_PLATFORM === 'mp-weixin') {
467
- } else if (process.env.UNI_PLATFORM === 'mp-alipay') {
476
+ if (process.env.UNI_PLATFORM === 'mp-weixin') {} else if (process.env.UNI_PLATFORM === 'mp-alipay') {
468
477
  initBuiltInEasycom(BUILT_IN_COMPONENTS_ALIPAY, usingAutoImportComponents)
469
478
  } else {
470
479
  initBuiltInEasycom(BUILT_IN_COMPONENTS, usingAutoImportComponents)
package/lib/uts/uts.js CHANGED
@@ -3,9 +3,10 @@ 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.resolveUTSCompiler = exports.resolveUtsModule = exports.resolveUtsAppModule = void 0;
6
+ exports.initUTSComponents = exports.resolveUTSCompiler = exports.resolveUtsModule = exports.resolveUtsAppModule = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
+ const fast_glob_1 = __importDefault(require("fast-glob"));
9
10
  const hbx_1 = require("./hbx");
10
11
  const utils_1 = require("./utils");
11
12
  /**
@@ -99,3 +100,65 @@ function resolveUTSCompiler() {
99
100
  return require(compilerPath);
100
101
  }
101
102
  exports.resolveUTSCompiler = resolveUTSCompiler;
103
+ function initUTSComponents(inputDir, platform) {
104
+ const components = [];
105
+ if (platform !== 'app' && platform !== 'app-plus') {
106
+ return components;
107
+ }
108
+ const easycomsObj = Object.create(null);
109
+ const dirs = resolveUTSComponentDirs(inputDir);
110
+ dirs.forEach((dir) => {
111
+ const is_uni_modules_utssdk = dir.endsWith('utssdk');
112
+ const is_ussdk = !is_uni_modules_utssdk && path_1.default.dirname(dir).endsWith('utssdk');
113
+ if (is_uni_modules_utssdk || is_ussdk) {
114
+ fast_glob_1.default
115
+ .sync('**/*.vue', {
116
+ cwd: dir,
117
+ absolute: true,
118
+ })
119
+ .forEach((file) => {
120
+ let name = parseVueComponentName(file);
121
+ if (!name) {
122
+ if (file.endsWith('index.vue')) {
123
+ name = path_1.default.basename(is_uni_modules_utssdk ? path_1.default.dirname(dir) : dir);
124
+ }
125
+ }
126
+ if (name) {
127
+ const importDir = (0, utils_1.normalizePath)(is_uni_modules_utssdk ? path_1.default.dirname(dir) : dir);
128
+ easycomsObj[`^${name}$`] = `\0${importDir}?uts-proxy`;
129
+ }
130
+ });
131
+ }
132
+ });
133
+ Object.keys(easycomsObj).forEach((name) => {
134
+ components.push({
135
+ pattern: new RegExp(name),
136
+ replacement: easycomsObj[name],
137
+ });
138
+ });
139
+ return components;
140
+ }
141
+ exports.initUTSComponents = initUTSComponents;
142
+ function resolveUTSComponentDirs(inputDir) {
143
+ const utssdkDir = path_1.default.resolve(inputDir, 'utssdk');
144
+ const uniModulesDir = path_1.default.resolve(inputDir, 'uni_modules');
145
+ return fast_glob_1.default
146
+ .sync('*', {
147
+ cwd: utssdkDir,
148
+ absolute: true,
149
+ onlyDirectories: true,
150
+ })
151
+ .concat(fast_glob_1.default.sync('*/utssdk', {
152
+ cwd: uniModulesDir,
153
+ absolute: true,
154
+ onlyDirectories: true,
155
+ }));
156
+ }
157
+ const nameRE = /name\s*:\s*['|"](.*)['|"]/;
158
+ function parseVueComponentName(file) {
159
+ const content = fs_1.default.readFileSync(file, 'utf8');
160
+ const matches = content.match(nameRE);
161
+ if (matches) {
162
+ return matches[1];
163
+ }
164
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "2.0.2-alpha-3061420221216003",
3
+ "version": "2.0.2-alpha-3061520221220001",
4
4
  "description": "uni-cli-shared",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
@@ -20,10 +20,11 @@
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
22
  "escape-string-regexp": "^4.0.0",
23
+ "fast-glob": "^3.2.11",
23
24
  "glob-escape": "^0.0.2",
24
25
  "hash-sum": "^1.0.2",
25
26
  "postcss-urlrewrite": "^0.2.2",
26
27
  "strip-json-comments": "^2.0.1"
27
28
  },
28
- "gitHead": "d5a8bd175373e9e5daef8846ae15c439a16b5c38"
29
+ "gitHead": "029a07aae58f836f6e2d3d8e0a51d175bae5cb6d"
29
30
  }