@dcloudio/uni-cli-shared 3.0.0-alpha-4000020231227002 → 3.0.0-alpha-4000020240111001
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/constants.js +0 -2
- package/dist/json/json.js +5 -1
- package/dist/json/mp/pages.js +1 -1
- package/dist/json/pages.d.ts +1 -0
- package/dist/json/pages.js +64 -1
- package/dist/json/uni-x/index.js +2 -0
- package/dist/postcss/plugins/uniapp.js +1 -1
- package/dist/preprocess/index.js +6 -0
- package/dist/uni_modules.js +14 -2
- package/dist/uts.d.ts +2 -1
- package/dist/uts.js +7 -1
- package/dist/vite/autoImport.js +10 -1
- package/dist/vite/plugins/easycom.d.ts +8 -0
- package/dist/vite/plugins/easycom.js +52 -0
- package/dist/vite/plugins/index.d.ts +2 -0
- package/dist/vite/plugins/index.js +2 -0
- package/dist/vite/plugins/inject.d.ts +1 -0
- package/dist/vite/plugins/inject.js +1 -1
- package/dist/vite/plugins/uts/ext-api.d.ts +2 -0
- package/dist/vite/plugins/uts/ext-api.js +22 -0
- package/dist/vite/plugins/uts/uni_modules.js +2 -0
- package/dist/vue/transforms/index.d.ts +1 -0
- package/dist/vue/transforms/index.js +1 -0
- package/dist/vue/transforms/transformUTSComponent.d.ts +8 -0
- package/dist/vue/transforms/transformUTSComponent.js +22 -0
- package/lib/preprocess/lib/preprocess.js +92 -91
- package/package.json +4 -4
package/dist/constants.js
CHANGED
package/dist/json/json.js
CHANGED
|
@@ -4,6 +4,10 @@ exports.parseJson = void 0;
|
|
|
4
4
|
const jsonc_parser_1 = require("jsonc-parser");
|
|
5
5
|
const preprocess_1 = require("../preprocess");
|
|
6
6
|
function parseJson(jsonStr, shouldPre = false) {
|
|
7
|
-
return (0, jsonc_parser_1.parse)(shouldPre
|
|
7
|
+
return (0, jsonc_parser_1.parse)(shouldPre
|
|
8
|
+
? process.env.UNI_APP_X === 'true'
|
|
9
|
+
? (0, preprocess_1.preUVueJson)(jsonStr)
|
|
10
|
+
: (0, preprocess_1.preJson)(jsonStr)
|
|
11
|
+
: jsonStr);
|
|
8
12
|
}
|
|
9
13
|
exports.parseJson = parseJson;
|
package/dist/json/mp/pages.js
CHANGED
|
@@ -114,7 +114,7 @@ function parsePagesJson(jsonStr, platform, { debug, darkmode, networkTimeout, su
|
|
|
114
114
|
appJson.tabBar = tabBar;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
;
|
|
117
|
+
(0, pages_1.filterPlatformPages)(platform, pagesJson);
|
|
118
118
|
['preloadRule', 'workers', 'plugins', 'entryPagePath'].forEach((name) => {
|
|
119
119
|
if ((0, shared_1.hasOwn)(pagesJson, name)) {
|
|
120
120
|
appJson[name] = pagesJson[name];
|
package/dist/json/pages.d.ts
CHANGED
|
@@ -28,4 +28,5 @@ export declare function removePlatformStyle(pageStyle: Record<string, any>): Rec
|
|
|
28
28
|
export declare function normalizePagesRoute(pagesJson: UniApp.PagesJson): UniApp.UniRoute[];
|
|
29
29
|
declare function parseSubpackagesRoot(inputDir: string, platform: UniApp.PLATFORM): string[];
|
|
30
30
|
export declare const parseSubpackagesRootOnce: typeof parseSubpackagesRoot;
|
|
31
|
+
export declare function filterPlatformPages(platform: UniApp.PLATFORM, pagesJson: UniApp.PagesJson): void;
|
|
31
32
|
export {};
|
package/dist/json/pages.js
CHANGED
|
@@ -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.parseSubpackagesRootOnce = exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageSetupAndTs = exports.isUniPageFile = void 0;
|
|
6
|
+
exports.filterPlatformPages = exports.parseSubpackagesRootOnce = exports.normalizePagesRoute = exports.removePlatformStyle = exports.validatePages = exports.normalizePagesJson = exports.parsePagesJsonOnce = exports.parsePagesJson = exports.isUniPageSfcFile = exports.isUniPageSetupAndTs = exports.isUniPageFile = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const shared_1 = require("@vue/shared");
|
|
@@ -108,6 +108,8 @@ function normalizePagesJson(jsonStr, platform, { subpackages, } = { subpackages:
|
|
|
108
108
|
delete pagesJson.tabBar;
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
|
+
// 过滤平台page
|
|
112
|
+
filterPlatformPages(platform, pagesJson);
|
|
111
113
|
// 缓存页面列表
|
|
112
114
|
pagesCacheSet.clear();
|
|
113
115
|
pagesJson.pages.forEach((page) => pagesCacheSet.add(page.path));
|
|
@@ -441,3 +443,64 @@ function parseSubpackagesRoot(inputDir, platform) {
|
|
|
441
443
|
return roots;
|
|
442
444
|
}
|
|
443
445
|
exports.parseSubpackagesRootOnce = (0, uni_shared_1.once)(parseSubpackagesRoot);
|
|
446
|
+
let isInvalidPagesWarned = false;
|
|
447
|
+
function filterPlatformPages(platform, pagesJson) {
|
|
448
|
+
const invalidPages = [];
|
|
449
|
+
pagesJson.pages = pagesJson.pages.filter(({ path }) => {
|
|
450
|
+
if (isPlatformPage(platform, path)) {
|
|
451
|
+
return true;
|
|
452
|
+
}
|
|
453
|
+
invalidPages.push(path);
|
|
454
|
+
return false;
|
|
455
|
+
});
|
|
456
|
+
if (pagesJson.subPackages) {
|
|
457
|
+
pagesJson.subPackages.forEach((subPackage) => {
|
|
458
|
+
if (subPackage.pages) {
|
|
459
|
+
subPackage.pages = subPackage.pages.filter(({ path }) => {
|
|
460
|
+
const pagePath = subPackage.root + '/' + path;
|
|
461
|
+
if (isPlatformPage(platform, pagePath)) {
|
|
462
|
+
return true;
|
|
463
|
+
}
|
|
464
|
+
invalidPages.push(pagePath);
|
|
465
|
+
return false;
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
if (pagesJson.subpackages) {
|
|
471
|
+
pagesJson.subpackages.forEach((subPackage) => {
|
|
472
|
+
if (subPackage.pages) {
|
|
473
|
+
subPackage.pages = subPackage.pages.filter(({ path }) => {
|
|
474
|
+
const pagePath = subPackage.root + '/' + path;
|
|
475
|
+
if (isPlatformPage(platform, pagePath)) {
|
|
476
|
+
return true;
|
|
477
|
+
}
|
|
478
|
+
invalidPages.push(pagePath);
|
|
479
|
+
return false;
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
// 目前仅启动的时候警告一次,该方法可能会被调用很多次
|
|
485
|
+
if (invalidPages.length) {
|
|
486
|
+
if (!isInvalidPagesWarned) {
|
|
487
|
+
isInvalidPagesWarned = true;
|
|
488
|
+
console.log(`已忽略页面:${invalidPages.join('、')}。详见:https://uniapp.dcloud.net.cn/tutorial/platform.html#platforms`);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
exports.filterPlatformPages = filterPlatformPages;
|
|
493
|
+
function isPlatformPage(platform, pagePath) {
|
|
494
|
+
if (pagePath.startsWith('platforms/')) {
|
|
495
|
+
if (platform === 'app' || platform === 'app-plus') {
|
|
496
|
+
return (pagePath.startsWith('platforms/app/') ||
|
|
497
|
+
pagePath.startsWith('platforms/app-plus/'));
|
|
498
|
+
}
|
|
499
|
+
else if (platform === 'h5' || platform === 'web') {
|
|
500
|
+
return (pagePath.startsWith('platforms/h5/') ||
|
|
501
|
+
pagePath.startsWith('platforms/web/'));
|
|
502
|
+
}
|
|
503
|
+
return pagePath.startsWith('platforms/' + platform + '/');
|
|
504
|
+
}
|
|
505
|
+
return true;
|
|
506
|
+
}
|
package/dist/json/uni-x/index.js
CHANGED
|
@@ -163,6 +163,8 @@ function normalizeUniAppXAppPagesJson(jsonStr) {
|
|
|
163
163
|
if (userPagesJson.uniIdRouter) {
|
|
164
164
|
pagesJson.uniIdRouter = userPagesJson.uniIdRouter;
|
|
165
165
|
}
|
|
166
|
+
// 是否应该用 process.env.UNI_UTS_PLATFORM
|
|
167
|
+
(0, pages_1.filterPlatformPages)(process.env.UNI_PLATFORM, pagesJson);
|
|
166
168
|
return pagesJson;
|
|
167
169
|
}
|
|
168
170
|
exports.normalizeUniAppXAppPagesJson = normalizeUniAppXAppPagesJson;
|
|
@@ -62,7 +62,7 @@ function filterPrefersColorScheme(root, force = false) {
|
|
|
62
62
|
const filePath = root.source?.input.file;
|
|
63
63
|
if (force || (filePath && filePath.includes('@dcloudio'))) {
|
|
64
64
|
root.walkAtRules((rule) => {
|
|
65
|
-
if (
|
|
65
|
+
if (/prefers-color-scheme\s*:\s*dark/.test(rule.params)) {
|
|
66
66
|
rule.remove();
|
|
67
67
|
}
|
|
68
68
|
});
|
package/dist/preprocess/index.js
CHANGED
|
@@ -7,10 +7,16 @@ const { preprocess } = require('../../lib/preprocess');
|
|
|
7
7
|
var context_2 = require("./context");
|
|
8
8
|
Object.defineProperty(exports, "initPreContext", { enumerable: true, get: function () { return context_2.initPreContext; } });
|
|
9
9
|
function preJs(jsCode) {
|
|
10
|
+
if (process.env.UNI_APP_X === 'true') {
|
|
11
|
+
return preUVueJs(jsCode);
|
|
12
|
+
}
|
|
10
13
|
return preprocess(jsCode, (0, context_1.getPreVueContext)(), { type: 'js' });
|
|
11
14
|
}
|
|
12
15
|
exports.preJs = preJs;
|
|
13
16
|
function preHtml(htmlCode) {
|
|
17
|
+
if (process.env.UNI_APP_X === 'true') {
|
|
18
|
+
return preUVueHtml(htmlCode);
|
|
19
|
+
}
|
|
14
20
|
return preprocess(htmlCode, (0, context_1.getPreVueContext)(), { type: 'html' });
|
|
15
21
|
}
|
|
16
22
|
exports.preHtml = preHtml;
|
package/dist/uni_modules.js
CHANGED
|
@@ -75,9 +75,10 @@ function parseInjects(vite = true, platform, language, source, uniModuleRootDir,
|
|
|
75
75
|
});
|
|
76
76
|
const injects = {};
|
|
77
77
|
if (Object.keys(rootDefines).length) {
|
|
78
|
+
const platformIndexFileName = path_1.default.resolve(uniModuleRootDir, 'utssdk', platform);
|
|
79
|
+
const rootIndexFileName = path_1.default.resolve(uniModuleRootDir, 'utssdk', 'index.uts');
|
|
78
80
|
let hasPlatformFile = uniModuleRootDir
|
|
79
|
-
? fs_extra_1.default.existsSync(
|
|
80
|
-
fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', platform))
|
|
81
|
+
? fs_extra_1.default.existsSync(rootIndexFileName) || fs_extra_1.default.existsSync(platformIndexFileName)
|
|
81
82
|
: true;
|
|
82
83
|
if (!hasPlatformFile) {
|
|
83
84
|
if (platform === 'app') {
|
|
@@ -86,6 +87,17 @@ function parseInjects(vite = true, platform, language, source, uniModuleRootDir,
|
|
|
86
87
|
fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'app-ios'));
|
|
87
88
|
}
|
|
88
89
|
}
|
|
90
|
+
// 其他平台修改source,直接指向目标文件,否则 uts2js 找不到类型信息
|
|
91
|
+
if (platform !== 'app' &&
|
|
92
|
+
platform !== 'app-android' &&
|
|
93
|
+
platform !== 'app-ios') {
|
|
94
|
+
if (fs_extra_1.default.existsSync(platformIndexFileName)) {
|
|
95
|
+
source = `${source}/utssdk/${platform}/index.uts`;
|
|
96
|
+
}
|
|
97
|
+
else if (fs_extra_1.default.existsSync(rootIndexFileName)) {
|
|
98
|
+
source = `${source}/utssdk/index.uts`;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
89
101
|
for (const key in rootDefines) {
|
|
90
102
|
Object.assign(injects, parseInject(vite, platform, language, source, 'uni', rootDefines[key], hasPlatformFile));
|
|
91
103
|
}
|
package/dist/uts.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import * as UTSCompiler from '@dcloudio/uni-uts-v1';
|
|
4
|
-
import type
|
|
4
|
+
import { type EasycomMatcher } from './easycom';
|
|
5
5
|
/**
|
|
6
6
|
* 解析 app 平台的 uts 插件,任意平台(android|ios)存在即可
|
|
7
7
|
* @param id
|
|
@@ -23,3 +23,4 @@ export declare function parseSwiftPackageWithPluginId(id: string, is_uni_modules
|
|
|
23
23
|
export type UTSTargetLanguage = typeof process.env.UNI_UTS_TARGET_LANGUAGE;
|
|
24
24
|
export declare const parseUniExtApiNamespacesOnce: (platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage) => Record<string, [string, string]>;
|
|
25
25
|
export declare const parseUniExtApiNamespacesJsOnce: (platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage) => Record<string, [string, string]>;
|
|
26
|
+
export declare function matchUTSComponent(tag: string): boolean;
|
package/dist/uts.js
CHANGED
|
@@ -3,12 +3,13 @@ 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.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.initUTSComponents = exports.parseUTSComponent = exports.isUTSComponent = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
|
|
6
|
+
exports.matchUTSComponent = exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.initUTSComponents = exports.parseUTSComponent = exports.isUTSComponent = 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
9
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
10
10
|
const hbx_1 = require("./hbx");
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
|
+
const easycom_1 = require("./easycom");
|
|
12
13
|
const uni_modules_1 = require("./uni_modules");
|
|
13
14
|
// 重要,该文件编译后的 js 需要同步到 vue2 编译器 uni-cli-shared/lib/uts
|
|
14
15
|
function once(fn, ctx = null) {
|
|
@@ -255,3 +256,8 @@ exports.parseUniExtApiNamespacesJsOnce = once((platform, language) => {
|
|
|
255
256
|
});
|
|
256
257
|
return namespaces;
|
|
257
258
|
});
|
|
259
|
+
function matchUTSComponent(tag) {
|
|
260
|
+
const source = (0, easycom_1.matchEasycom)(tag);
|
|
261
|
+
return !!(source && source.includes('uts-proxy'));
|
|
262
|
+
}
|
|
263
|
+
exports.matchUTSComponent = matchUTSComponent;
|
package/dist/vite/autoImport.js
CHANGED
|
@@ -30,6 +30,10 @@ const uniPreset = {
|
|
|
30
30
|
'onPullDownRefresh',
|
|
31
31
|
],
|
|
32
32
|
};
|
|
33
|
+
const uniH5Preset = {
|
|
34
|
+
from: '@dcloudio/uni-h5',
|
|
35
|
+
imports: ['UniElement', 'UniElementImpl'],
|
|
36
|
+
};
|
|
33
37
|
const cloudPreset = {
|
|
34
38
|
'@dcloudio/uni-cloud': [['default', 'uniCloud']],
|
|
35
39
|
};
|
|
@@ -93,12 +97,17 @@ const vuePreset = {
|
|
|
93
97
|
],
|
|
94
98
|
};
|
|
95
99
|
function initAutoImportOptions(platform, { imports = [], ...userOptions }) {
|
|
100
|
+
const autoImport = [uniPreset, cloudPreset, vuePreset];
|
|
101
|
+
if (platform === 'web') {
|
|
102
|
+
autoImport.push(uniH5Preset);
|
|
103
|
+
}
|
|
96
104
|
return {
|
|
97
105
|
...userOptions,
|
|
98
106
|
include: [/\.[u]?ts$/, /\.[u]?vue$/, /\.[u]?vue\?vue/],
|
|
107
|
+
exclude: [/[\\/]\.git[\\/]/],
|
|
99
108
|
imports: imports.concat(
|
|
100
109
|
// app-android 平台暂不注入其他
|
|
101
|
-
platform === 'app-android' ? [] :
|
|
110
|
+
platform === 'app-android' ? [] : autoImport),
|
|
102
111
|
dts: false,
|
|
103
112
|
};
|
|
104
113
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
import { FilterPattern } from '@rollup/pluginutils';
|
|
3
|
+
interface UniEasycomPluginOptions {
|
|
4
|
+
include?: FilterPattern;
|
|
5
|
+
exclude?: FilterPattern;
|
|
6
|
+
}
|
|
7
|
+
export declare function uniEasycomPlugin(options: UniEasycomPluginOptions): Plugin;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
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.uniEasycomPlugin = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const shared_1 = require("@vue/shared");
|
|
9
|
+
const pluginutils_1 = require("@rollup/pluginutils");
|
|
10
|
+
const url_1 = require("../utils/url");
|
|
11
|
+
const constants_1 = require("../../constants");
|
|
12
|
+
const easycom_1 = require("../../easycom");
|
|
13
|
+
function uniEasycomPlugin(options) {
|
|
14
|
+
const filter = (0, pluginutils_1.createFilter)(options.include, options.exclude);
|
|
15
|
+
return {
|
|
16
|
+
name: 'uni:app-easycom',
|
|
17
|
+
transform(code, id) {
|
|
18
|
+
if (!filter(id)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const { filename } = (0, url_1.parseVueRequest)(id);
|
|
22
|
+
if (!constants_1.EXTNAME_VUE_TEMPLATE.includes(path_1.default.extname(filename))) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!code.includes('_resolveComponent')) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
let i = 0;
|
|
29
|
+
const importDeclarations = [];
|
|
30
|
+
code = code.replace(/_resolveComponent\("(.+?)"(, true)?\)/g, (str, name) => {
|
|
31
|
+
if (name && !name.startsWith('_')) {
|
|
32
|
+
const source = (0, easycom_1.matchEasycom)(name);
|
|
33
|
+
if (source) {
|
|
34
|
+
// 处理easycom组件优先级
|
|
35
|
+
return (0, easycom_1.genResolveEasycomCode)(importDeclarations, str, (0, easycom_1.addImportDeclaration)(importDeclarations, `__easycom_${i++}`, source, source.includes('uts-proxy')
|
|
36
|
+
? (0, shared_1.capitalize)((0, shared_1.camelize)(name)) + 'Component'
|
|
37
|
+
: ''));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return str;
|
|
41
|
+
});
|
|
42
|
+
if (importDeclarations.length) {
|
|
43
|
+
code = importDeclarations.join('') + code;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
code,
|
|
47
|
+
map: null,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
exports.uniEasycomPlugin = uniEasycomPlugin;
|
|
@@ -7,6 +7,8 @@ export * from './console';
|
|
|
7
7
|
export * from './dynamicImportPolyfill';
|
|
8
8
|
export * from './uts/uni_modules';
|
|
9
9
|
export * from './uts/uvue';
|
|
10
|
+
export * from './uts/ext-api';
|
|
11
|
+
export * from './easycom';
|
|
10
12
|
export { assetPlugin, parseAssets, getAssetHash } from './vitejs/plugins/asset';
|
|
11
13
|
export { isCSSRequest, cssPlugin, cssPostPlugin, minifyCSS, cssLangRE, commonjsProxyRE, } from './vitejs/plugins/css';
|
|
12
14
|
export { generateCodeFrame, locToStartAndEnd, offsetToStartAndEnd, } from './vitejs/utils';
|
|
@@ -24,6 +24,8 @@ __exportStar(require("./console"), exports);
|
|
|
24
24
|
__exportStar(require("./dynamicImportPolyfill"), exports);
|
|
25
25
|
__exportStar(require("./uts/uni_modules"), exports);
|
|
26
26
|
__exportStar(require("./uts/uvue"), exports);
|
|
27
|
+
__exportStar(require("./uts/ext-api"), exports);
|
|
28
|
+
__exportStar(require("./easycom"), exports);
|
|
27
29
|
var asset_1 = require("./vitejs/plugins/asset");
|
|
28
30
|
Object.defineProperty(exports, "assetPlugin", { enumerable: true, get: function () { return asset_1.assetPlugin; } });
|
|
29
31
|
Object.defineProperty(exports, "parseAssets", { enumerable: true, get: function () { return asset_1.parseAssets; } });
|
|
@@ -2,6 +2,7 @@ import type { Plugin } from 'vite';
|
|
|
2
2
|
import { FilterPattern } from '@rollup/pluginutils';
|
|
3
3
|
type Injectment = string | [string, string];
|
|
4
4
|
export interface InjectOptions {
|
|
5
|
+
enforce?: 'pre' | 'post';
|
|
5
6
|
sourceMap?: boolean;
|
|
6
7
|
callback?: (imports: Map<any, any>, mod: [string, string]) => void;
|
|
7
8
|
include?: FilterPattern;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniUTSExtApi = void 0;
|
|
4
|
+
const uni_modules_1 = require("../../../uni_modules");
|
|
5
|
+
const inject_1 = require("../inject");
|
|
6
|
+
function uniUTSExtApi() {
|
|
7
|
+
return {
|
|
8
|
+
name: 'uni:uts-ext-api',
|
|
9
|
+
configResolved(config) {
|
|
10
|
+
// 在 uts 之前插入 ext-api-inject
|
|
11
|
+
const index = config.plugins.findIndex((p) => p.name === 'uts');
|
|
12
|
+
if (index > -1) {
|
|
13
|
+
const injects = (0, uni_modules_1.parseUniExtApis)(true, process.env.UNI_UTS_PLATFORM, 'javascript');
|
|
14
|
+
if (Object.keys(injects).length) {
|
|
15
|
+
// @ts-expect-error
|
|
16
|
+
config.plugins.splice(index, 0, (0, inject_1.uniViteInjectPlugin)('uni:ext-api-inject', injects));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.uniUTSExtApi = uniUTSExtApi;
|
|
@@ -56,6 +56,7 @@ function uniUTSUniModulesPlugin(options = {}) {
|
|
|
56
56
|
});
|
|
57
57
|
return {
|
|
58
58
|
code: result.code,
|
|
59
|
+
map: null,
|
|
59
60
|
syntheticNamedExports: result.encrypt,
|
|
60
61
|
meta: result.meta,
|
|
61
62
|
};
|
|
@@ -80,6 +81,7 @@ function uniUTSUniModulesPlugin(options = {}) {
|
|
|
80
81
|
});
|
|
81
82
|
return {
|
|
82
83
|
code: result.code,
|
|
84
|
+
map: null,
|
|
83
85
|
syntheticNamedExports: result.encrypt,
|
|
84
86
|
meta: result.meta,
|
|
85
87
|
};
|
|
@@ -3,6 +3,7 @@ export * from './transformPageHead';
|
|
|
3
3
|
export * from './transformComponent';
|
|
4
4
|
export * from './transformEvent';
|
|
5
5
|
export * from './transformTag';
|
|
6
|
+
export * from './transformUTSComponent';
|
|
6
7
|
export { createAssetUrlTransformWithOptions } from './templateTransformAssetUrl';
|
|
7
8
|
export { createSrcsetTransformWithOptions } from './templateTransformSrcset';
|
|
8
9
|
export { STRINGIFY_JSON, ATTR_DATASET_EVENT_OPTS, createTransformOn, defaultMatch as matchTransformOn, } from './vOn';
|
|
@@ -25,6 +25,7 @@ __exportStar(require("./transformPageHead"), exports);
|
|
|
25
25
|
__exportStar(require("./transformComponent"), exports);
|
|
26
26
|
__exportStar(require("./transformEvent"), exports);
|
|
27
27
|
__exportStar(require("./transformTag"), exports);
|
|
28
|
+
__exportStar(require("./transformUTSComponent"), exports);
|
|
28
29
|
var templateTransformAssetUrl_1 = require("./templateTransformAssetUrl");
|
|
29
30
|
Object.defineProperty(exports, "createAssetUrlTransformWithOptions", { enumerable: true, get: function () { return templateTransformAssetUrl_1.createAssetUrlTransformWithOptions; } });
|
|
30
31
|
var templateTransformSrcset_1 = require("./templateTransformSrcset");
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformUTSComponent = void 0;
|
|
4
|
+
const ast_1 = require("../../vite/utils/ast");
|
|
5
|
+
const uts_1 = require("../../uts");
|
|
6
|
+
/**
|
|
7
|
+
* 将uts组件保存到自定义组件列表中
|
|
8
|
+
* @param node
|
|
9
|
+
* @param context
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const transformUTSComponent = (node, context) => {
|
|
13
|
+
if (!(0, ast_1.isElementNode)(node)) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if ((0, uts_1.matchUTSComponent)(node.tag)) {
|
|
17
|
+
if (!context.root.components.includes(node.tag)) {
|
|
18
|
+
context.components.add(node.tag);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
exports.transformUTSComponent = transformUTSComponent;
|
|
@@ -94,71 +94,72 @@ function preprocessor(src, context, opts, noRestoreEol) {
|
|
|
94
94
|
|
|
95
95
|
var rv = src;
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
97
|
+
// 不支持该语法,无需执行,大字符串时,该正则性能极低(比如包含较大base64时)(https://github.com/dcloudio/uni-app/issues/4661)
|
|
98
|
+
// rv = replace(rv, opts.type.include, processIncludeDirective.bind(null, false, context, opts));
|
|
99
|
+
|
|
100
|
+
// if (opts.type.extend) {
|
|
101
|
+
// rv = replaceRecursive(rv, opts.type.extend, function(startMatches, endMatches, include, recurse) {
|
|
102
|
+
// var file = (startMatches[1] || '').trim();
|
|
103
|
+
// var extendedContext = copy(context);
|
|
104
|
+
// var extendedOpts = copy(opts);
|
|
105
|
+
// extendedContext.src = path.join(opts.srcDir, file);
|
|
106
|
+
// extendedOpts.srcDir = path.dirname(extendedContext.src);
|
|
107
|
+
|
|
108
|
+
// var fileContents = getFileContents(extendedContext.src, opts.fileNotFoundSilentFail, context.src);
|
|
109
|
+
// if (fileContents.error) {
|
|
110
|
+
// return fileContents.contents;
|
|
111
|
+
// }
|
|
112
|
+
|
|
113
|
+
// var extendedSource = preprocessor(fileContents.contents, extendedContext, extendedOpts, true).trim();
|
|
114
|
+
|
|
115
|
+
// if (extendedSource) {
|
|
116
|
+
// include = include.replace(/^\n?|\n?$/g, '');
|
|
117
|
+
// return replace(extendedSource, opts.type.extendable, recurse(include));
|
|
118
|
+
// } else {
|
|
119
|
+
// return '';
|
|
120
|
+
// }
|
|
121
|
+
// });
|
|
122
|
+
// }
|
|
123
|
+
|
|
124
|
+
// if (opts.type.foreach) {
|
|
125
|
+
// rv = replaceRecursive(rv, opts.type.foreach, function(startMatches, endMatches, include, recurse) {
|
|
126
|
+
// var variable = (startMatches[1] || '').trim();
|
|
127
|
+
// var forParams = variable.split(' ');
|
|
128
|
+
// if (forParams.length === 3) {
|
|
129
|
+
// var contextVar = forParams[2];
|
|
130
|
+
// var arrString = getDeepPropFromObj(context, contextVar);
|
|
131
|
+
// var eachArr;
|
|
132
|
+
// if (arrString.match(/\{(.*)\}/)) {
|
|
133
|
+
// eachArr = JSON.parse(arrString);
|
|
134
|
+
// } else if (arrString.match(/\[(.*)\]/)) {
|
|
135
|
+
// eachArr = arrString.slice(1, -1);
|
|
136
|
+
// eachArr = eachArr.split(',');
|
|
137
|
+
// eachArr = eachArr.map(function(arrEntry){
|
|
138
|
+
// return arrEntry.replace(/\s*(['"])(.*)\1\s*/, '$2');
|
|
139
|
+
// });
|
|
140
|
+
// } else {
|
|
141
|
+
// eachArr = arrString.split(',');
|
|
142
|
+
// }
|
|
143
|
+
|
|
144
|
+
// var replaceToken = new RegExp(XRegExp.escape(forParams[0]), 'g');
|
|
145
|
+
// var recursedInclude = recurse(include);
|
|
146
|
+
|
|
147
|
+
// return Object.keys(eachArr).reduce(function(stringBuilder, arrKey){
|
|
148
|
+
// var arrEntry = eachArr[arrKey];
|
|
149
|
+
// return stringBuilder + recursedInclude.replace(replaceToken, arrEntry);
|
|
150
|
+
// }, '');
|
|
151
|
+
// } else {
|
|
152
|
+
// return '';
|
|
153
|
+
// }
|
|
154
|
+
// });
|
|
155
|
+
// }
|
|
156
|
+
|
|
157
|
+
// if (opts.type.exclude) {
|
|
158
|
+
// rv = replaceRecursive(rv, opts.type.exclude, function(startMatches, endMatches, include, recurse){
|
|
159
|
+
// var test = (startMatches[1] || '').trim();
|
|
160
|
+
// return testPasses(test,context) ? '' : recurse(include);
|
|
161
|
+
// });
|
|
162
|
+
// }
|
|
162
163
|
|
|
163
164
|
if (opts.type.if) {
|
|
164
165
|
rv = replaceRecursive(rv, opts.type.if, function (startMatches, endMatches, include, recurse) {
|
|
@@ -194,39 +195,39 @@ function preprocessor(src, context, opts, noRestoreEol) {
|
|
|
194
195
|
});
|
|
195
196
|
}
|
|
196
197
|
|
|
197
|
-
rv = replace(rv, opts.type.echo, function (match, variable) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
198
|
+
// rv = replace(rv, opts.type.echo, function (match, variable) {
|
|
199
|
+
// variable = (variable || '').trim();
|
|
200
|
+
// // if we are surrounded by quotes, echo as a string
|
|
201
|
+
// var stringMatch = variable.match(/^(['"])(.*)\1$/);
|
|
202
|
+
// if (stringMatch) return stringMatch[2];
|
|
202
203
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
});
|
|
204
|
+
// var arrString = getDeepPropFromObj(context, variable);
|
|
205
|
+
// return typeof arrString !== 'undefined' ? arrString : '';
|
|
206
|
+
// });
|
|
206
207
|
|
|
207
|
-
rv = replace(rv, opts.type.exec, function (match, name, value) {
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
// rv = replace(rv, opts.type.exec, function (match, name, value) {
|
|
209
|
+
// name = (name || '').trim();
|
|
210
|
+
// value = value || '';
|
|
210
211
|
|
|
211
|
-
|
|
212
|
-
|
|
212
|
+
// var params = value.split(',');
|
|
213
|
+
// var stringRegex = /^['"](.*)['"]$/;
|
|
213
214
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
215
|
+
// params = params.map(function(param){
|
|
216
|
+
// param = param.trim();
|
|
217
|
+
// if (stringRegex.test(param)) { // handle string parameter
|
|
218
|
+
// return param.replace(stringRegex, '$1');
|
|
219
|
+
// } else { // handle variable parameter
|
|
220
|
+
// return getDeepPropFromObj(context, param);
|
|
221
|
+
// }
|
|
222
|
+
// });
|
|
222
223
|
|
|
223
|
-
|
|
224
|
-
|
|
224
|
+
// var fn = getDeepPropFromObj(context, name);
|
|
225
|
+
// if (!fn || typeof fn !== 'function') return '';
|
|
225
226
|
|
|
226
|
-
|
|
227
|
-
});
|
|
227
|
+
// return fn.apply(context, params);
|
|
228
|
+
// });
|
|
228
229
|
|
|
229
|
-
rv = replace(rv, opts.type['include-static'], processIncludeDirective.bind(null, true, context, opts));
|
|
230
|
+
// rv = replace(rv, opts.type['include-static'], processIncludeDirective.bind(null, true, context, opts));
|
|
230
231
|
|
|
231
232
|
if (!noRestoreEol) {
|
|
232
233
|
rv = restoreEol(rv, opts.srcEol);
|
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-4000020240111001",
|
|
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.21.3",
|
|
27
27
|
"@babel/parser": "^7.23.5",
|
|
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-4000020240111001",
|
|
30
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-4000020240111001",
|
|
31
31
|
"@intlify/core-base": "9.1.9",
|
|
32
32
|
"@intlify/shared": "9.1.9",
|
|
33
33
|
"@intlify/vue-devtools": "9.1.9",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
},
|
|
67
67
|
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@dcloudio/uni-uts-v1": "3.0.0-alpha-
|
|
69
|
+
"@dcloudio/uni-uts-v1": "3.0.0-alpha-4000020240111001",
|
|
70
70
|
"@types/babel__code-frame": "^7.0.6",
|
|
71
71
|
"@types/babel__core": "^7.1.19",
|
|
72
72
|
"@types/debug": "^4.1.7",
|