@dcloudio/uni-cli-shared 2.0.2-3061820230117003 → 2.0.2-3070820230322001

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.
@@ -53,10 +53,10 @@ export default {
53
53
  pageStyle: {
54
54
  type: String,
55
55
  default: ''
56
- },
57
- enablePullDownRefresh: {
58
- type: [Boolean, String],
59
- default: false
56
+ },
57
+ enablePullDownRefresh: {
58
+ type: [Boolean, String],
59
+ default: false
60
60
  },
61
61
  rootFontSize: {
62
62
  type: String,
@@ -81,8 +81,8 @@ export default {
81
81
  // 父节点一定是 page
82
82
  this.$pageVm.$on('hook:onPageScroll', evt => {
83
83
  this.$emit('scroll', evt)
84
- })
85
-
84
+ })
85
+
86
86
  // #ifdef APP-PLUS
87
87
  this._currentWebview = page.$getAppWebview()
88
88
  if (this.enablePullDownRefresh) {
@@ -90,7 +90,7 @@ export default {
90
90
  }
91
91
  this.$watch('enablePullDownRefresh', (val) => {
92
92
  this.setPullDownRefresh(this._currentWebview, val)
93
- })
93
+ })
94
94
  // #endif
95
95
 
96
96
  // props
@@ -124,16 +124,18 @@ export default {
124
124
  this.setPageMeta()
125
125
  }
126
126
  this.backgroundTextStyle && this.setBackgroundTextStyle()
127
+ },
128
+ mounted () {
127
129
  this.scrollTop && this.pageScrollTo()
128
130
  },
129
- methods: {
130
- setPullDownRefresh (webview, enabled) {
131
- webview.setStyle({
132
- pullToRefresh: {
133
- support: enabled,
134
- style: plus.os.name === 'Android' ? 'circle' : 'default'
135
- }
136
- })
131
+ methods: {
132
+ setPullDownRefresh (webview, enabled) {
133
+ webview.setStyle({
134
+ pullToRefresh: {
135
+ support: enabled,
136
+ style: plus.os.name === 'Android' ? 'circle' : 'default'
137
+ }
138
+ })
137
139
  },
138
140
  setPageMeta () {
139
141
  // h5 和 app-plus 设置 rootFontSize
@@ -187,4 +189,4 @@ export default {
187
189
  }
188
190
  }
189
191
  }
190
- </script>
192
+ </script>
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-3061820230117003",
3
+ "version": "2.0.2-3070820230322001",
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": "bb5ad3659107f8923fd018ef14b137cc2d6768a8"
29
+ "gitHead": "30d5b6dfb5029d265121ad9fb32eb72992e27bba"
29
30
  }