@dcloudio/uni-cli-shared 3.0.0-alpha-4020520240726003 → 3.0.0-alpha-4020520240808001
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/resolve.js +5 -3
- package/dist/vite/plugins/copy.js +11 -16
- package/dist/vite/plugins/uts/uni_modules.js +8 -1
- package/dist/watcher.d.ts +3 -2
- package/dist/watcher.js +22 -24
- package/package.json +4 -4
package/dist/resolve.js
CHANGED
|
@@ -30,9 +30,11 @@ function relativeFile(from, to) {
|
|
|
30
30
|
}
|
|
31
31
|
exports.relativeFile = relativeFile;
|
|
32
32
|
exports.resolveMainPathOnce = (0, uni_shared_1.once)((inputDir) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
if (process.env.UNI_APP_X === 'true') {
|
|
34
|
+
const mainUTSPath = path_1.default.resolve(inputDir, 'main.uts');
|
|
35
|
+
if (fs_1.default.existsSync(mainUTSPath)) {
|
|
36
|
+
return (0, utils_1.normalizePath)(mainUTSPath);
|
|
37
|
+
}
|
|
36
38
|
}
|
|
37
39
|
const mainTsPath = path_1.default.resolve(inputDir, 'main.ts');
|
|
38
40
|
if (fs_1.default.existsSync(mainTsPath)) {
|
|
@@ -22,30 +22,25 @@ function uniViteCopyPlugin({ targets, }) {
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
initialized = true;
|
|
25
|
+
const is_prod = process.env.NODE_ENV !== 'development' ||
|
|
26
|
+
process.env.UNI_AUTOMATOR_CONFIG;
|
|
27
|
+
const onChange = is_prod
|
|
28
|
+
? undefined
|
|
29
|
+
: (0, uni_shared_1.debounce)(() => {
|
|
30
|
+
(0, logs_1.resetOutput)('log');
|
|
31
|
+
(0, logs_1.output)('log', messages_1.M['dev.watching.end']);
|
|
32
|
+
}, 100, { setTimeout, clearTimeout });
|
|
25
33
|
return new Promise((resolve) => {
|
|
26
34
|
Promise.all(targets.map(({ watchOptions, ...target }) => {
|
|
27
35
|
return new Promise((resolve) => {
|
|
28
|
-
// 防抖,可能短时间触发很多次add,unlink
|
|
29
|
-
const onChange = (0, uni_shared_1.debounce)(() => {
|
|
30
|
-
(0, logs_1.resetOutput)('log');
|
|
31
|
-
(0, logs_1.output)('log', messages_1.M['dev.watching.end']);
|
|
32
|
-
}, 100, { setTimeout, clearTimeout });
|
|
33
36
|
new watcher_1.FileWatcher({
|
|
34
37
|
...target,
|
|
35
38
|
}).watch({
|
|
36
39
|
cwd: process.env.UNI_INPUT_DIR,
|
|
40
|
+
persistent: is_prod ? false : true,
|
|
37
41
|
...watchOptions,
|
|
38
|
-
}, (
|
|
39
|
-
|
|
40
|
-
process.env.UNI_AUTOMATOR_CONFIG) {
|
|
41
|
-
// 生产或自动化测试模式下,延迟 close,否则会影响 chokidar 初始化的 add 等事件
|
|
42
|
-
setTimeout(() => {
|
|
43
|
-
watcher.close().then(() => resolve(void 0));
|
|
44
|
-
}, 2000);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
resolve(void 0);
|
|
48
|
-
}
|
|
42
|
+
}, () => {
|
|
43
|
+
resolve(void 0);
|
|
49
44
|
}, onChange);
|
|
50
45
|
});
|
|
51
46
|
})).then(() => resolve());
|
|
@@ -81,7 +81,14 @@ function uniUTSAppUniModulesPlugin(options = {}) {
|
|
|
81
81
|
// 获取 provider 扩展(编译所有uni)
|
|
82
82
|
const plugins = (0, uni_modules_1.getUniExtApiPlugins)().filter((provider) => !utsPlugins.has(provider.plugin));
|
|
83
83
|
for (const plugin of plugins) {
|
|
84
|
-
const
|
|
84
|
+
const pluginDir = path_1.default.resolve(inputDir, 'uni_modules', plugin.plugin);
|
|
85
|
+
// 如果是 app-js 环境
|
|
86
|
+
if (process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js') {
|
|
87
|
+
if (fs_1.default.existsSync(path_1.default.resolve(pluginDir, 'utssdk', 'app-js', 'index.uts'))) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const result = await compilePlugin(pluginDir);
|
|
85
92
|
if (result) {
|
|
86
93
|
// 时机不对,不能addWatch
|
|
87
94
|
// result.deps.forEach((dep) => {
|
package/dist/watcher.d.ts
CHANGED
|
@@ -15,12 +15,13 @@ export declare class FileWatcher {
|
|
|
15
15
|
constructor({ src, dest, transform }: FileWatcherOptions);
|
|
16
16
|
watch(watchOptions: WatchOptions & {
|
|
17
17
|
cwd: string;
|
|
18
|
+
readyTimeout?: number;
|
|
18
19
|
}, onReady?: (watcher: FSWatcher) => void, onChange?: () => void): FSWatcher;
|
|
19
20
|
add(paths: string | ReadonlyArray<string>): FSWatcher;
|
|
20
21
|
unwatch(paths: string | ReadonlyArray<string>): FSWatcher;
|
|
21
22
|
close(): Promise<void>;
|
|
22
|
-
copy(from: string):
|
|
23
|
-
remove(from: string):
|
|
23
|
+
copy(from: string): void;
|
|
24
|
+
remove(from: string): void;
|
|
24
25
|
info(type: 'close' | 'copy' | 'remove' | 'add' | 'unwatch', msg?: string | unknown): void;
|
|
25
26
|
from(from: string): string;
|
|
26
27
|
to(from: string): string;
|
package/dist/watcher.js
CHANGED
|
@@ -23,17 +23,26 @@ class FileWatcher {
|
|
|
23
23
|
const remove = this.remove.bind(this);
|
|
24
24
|
// escape chokidar cwd
|
|
25
25
|
const src = this.src.map((src) => (0, utils_1.pathToGlob)(path_1.default.resolve(watchOptions.cwd), src));
|
|
26
|
+
let closeTimer;
|
|
27
|
+
const checkReady = () => {
|
|
28
|
+
if (closeTimer) {
|
|
29
|
+
clearTimeout(closeTimer);
|
|
30
|
+
}
|
|
31
|
+
closeTimer = setTimeout(() => {
|
|
32
|
+
onReady && onReady(this.watcher);
|
|
33
|
+
// 等首次change完,触发完ready,在切换到真实的onChange
|
|
34
|
+
this.onChange = onChange;
|
|
35
|
+
}, watchOptions.readyTimeout || 300);
|
|
36
|
+
};
|
|
37
|
+
this.onChange = checkReady;
|
|
26
38
|
this.watcher = (0, chokidar_1.watch)(src, watchOptions)
|
|
27
39
|
.on('add', copy)
|
|
28
|
-
.on('addDir', copy)
|
|
40
|
+
// .on('addDir', copy)
|
|
29
41
|
.on('change', copy)
|
|
30
42
|
.on('unlink', remove)
|
|
31
|
-
.on('unlinkDir', remove)
|
|
43
|
+
// .on('unlinkDir', remove)
|
|
32
44
|
.on('ready', () => {
|
|
33
|
-
|
|
34
|
-
setTimeout(() => {
|
|
35
|
-
this.onChange = onChange;
|
|
36
|
-
}, 1000);
|
|
45
|
+
checkReady();
|
|
37
46
|
})
|
|
38
47
|
.on('error', (e) => console.error('watch', e));
|
|
39
48
|
}
|
|
@@ -60,29 +69,18 @@ class FileWatcher {
|
|
|
60
69
|
content = this.transform(fs_extra_1.default.readFileSync(filename), filename);
|
|
61
70
|
}
|
|
62
71
|
if (content) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// this.info('copy', e)
|
|
67
|
-
})
|
|
68
|
-
.then(() => this.onChange && this.onChange());
|
|
72
|
+
fs_extra_1.default.outputFileSync(to, content);
|
|
73
|
+
this.onChange && this.onChange();
|
|
74
|
+
return;
|
|
69
75
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
.catch(() => {
|
|
73
|
-
// this.info('copy', e)
|
|
74
|
-
})
|
|
75
|
-
.then(() => this.onChange && this.onChange());
|
|
76
|
+
fs_extra_1.default.copySync(this.from(from), to, { overwrite: true });
|
|
77
|
+
this.onChange && this.onChange();
|
|
76
78
|
}
|
|
77
79
|
remove(from) {
|
|
78
80
|
const to = this.to(from);
|
|
79
81
|
this.info('remove', from + '=>' + to);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.catch(() => {
|
|
83
|
-
// this.info('remove', e)
|
|
84
|
-
})
|
|
85
|
-
.then(() => this.onChange && this.onChange());
|
|
82
|
+
fs_extra_1.default.removeSync(to);
|
|
83
|
+
this.onChange && this.onChange();
|
|
86
84
|
}
|
|
87
85
|
info(type, msg) {
|
|
88
86
|
debugWatcher.enabled && debugWatcher(type, msg);
|
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-4020520240808001",
|
|
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-
|
|
30
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
29
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-4020520240808001",
|
|
30
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-4020520240808001",
|
|
31
31
|
"@intlify/core-base": "9.1.9",
|
|
32
32
|
"@intlify/shared": "9.1.9",
|
|
33
33
|
"@intlify/vue-devtools": "9.1.9",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@dcloudio/uni-uts-v1": "3.0.0-alpha-
|
|
74
|
+
"@dcloudio/uni-uts-v1": "3.0.0-alpha-4020520240808001",
|
|
75
75
|
"@types/adm-zip": "^0.5.5",
|
|
76
76
|
"@types/babel__code-frame": "^7.0.6",
|
|
77
77
|
"@types/babel__core": "^7.1.19",
|