@dcloudio/uni-cli-shared 3.0.0-alpha-4000320240311001 → 3.0.0-alpha-4000620240320001
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/deps.d.ts +2 -0
- package/dist/deps.js +3 -0
- package/dist/easycom.js +3 -2
- package/dist/hbx/alias.js +20 -3
- package/dist/hbx/log.js +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/json/app/pages/code.d.ts +1 -1
- package/dist/json/mp/index.d.ts +1 -1
- package/dist/json/mp/project.js +2 -2
- package/dist/json/mp/types.d.ts +1 -1
- package/dist/json/uni-x/uniConfig.js +4 -0
- package/dist/mp/tags.js +5 -5
- package/dist/uni_modules.d.ts +20 -0
- package/dist/uni_modules.js +71 -12
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +7 -7
- package/dist/uts.d.ts +1 -3
- package/dist/uts.js +23 -44
- package/dist/utsUtils.d.ts +2 -0
- package/dist/utsUtils.js +44 -0
- package/dist/vite/autoImport.js +41 -1
- package/dist/vite/features.js +27 -27
- package/dist/vite/index.d.ts +1 -0
- package/dist/vite/plugins/inject.js +2 -2
- package/dist/vite/plugins/uts/ext-api.d.ts +2 -1
- package/dist/vite/plugins/uts/ext-api.js +4 -5
- package/dist/vite/plugins/uts/uni_modules.js +11 -2
- package/dist/vite/plugins/vitejs/plugins/asset.js +1 -1
- package/dist/vite/plugins/vitejs/plugins/css.js +10 -1
- package/dist/vite/utils/ast.js +7 -6
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue/index.js +3 -1
- package/dist/vue/parse.js +8 -7
- package/dist/vue/polyfill.d.ts +3 -0
- package/dist/vue/polyfill.js +24 -0
- package/dist/vue/transforms/index.d.ts +1 -0
- package/dist/vue/transforms/index.js +1 -0
- package/dist/vue/transforms/templateTransformAssetUrl.js +8 -8
- package/dist/vue/transforms/templateTransformSrcset.js +7 -7
- package/dist/vue/transforms/transformComponent.js +7 -3
- package/dist/vue/transforms/transformRef.js +1 -1
- package/dist/vue/transforms/transformRefresherSlot.d.ts +8 -0
- package/dist/vue/transforms/transformRefresherSlot.js +58 -0
- package/dist/vue/transforms/transformUTSComponent.js +2 -2
- package/dist/vue/transforms/vOn.js +4 -4
- package/dist/vue/utils.d.ts +4 -1
- package/dist/vue/utils.js +47 -8
- package/package.json +16 -16
package/dist/deps.d.ts
CHANGED
package/dist/deps.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.COMPONENT_DEPS_CSS = exports.API_DEPS_CSS = void 0;
|
|
4
4
|
const constants_1 = require("./constants");
|
|
5
5
|
const RESIZE_SENSOR_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'resize-sensor.css';
|
|
6
|
+
const REFRESHER_CSS = constants_1.BASE_COMPONENTS_STYLE_PATH + 'refresher.css';
|
|
6
7
|
exports.API_DEPS_CSS = {
|
|
7
8
|
showModal: [`${constants_1.H5_API_STYLE_PATH}modal.css`],
|
|
8
9
|
showToast: [`${constants_1.H5_API_STYLE_PATH}toast.css`],
|
|
@@ -36,4 +37,6 @@ exports.COMPONENT_DEPS_CSS = {
|
|
|
36
37
|
`${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view.css`,
|
|
37
38
|
`${constants_1.BASE_COMPONENTS_STYLE_PATH}picker-view-column.css`,
|
|
38
39
|
],
|
|
40
|
+
'scroll-view': [REFRESHER_CSS],
|
|
41
|
+
'list-view': [RESIZE_SENSOR_CSS, REFRESHER_CSS],
|
|
39
42
|
};
|
package/dist/easycom.js
CHANGED
|
@@ -14,6 +14,7 @@ const utils_1 = require("./utils");
|
|
|
14
14
|
const pages_1 = require("./json/pages");
|
|
15
15
|
const messages_1 = require("./messages");
|
|
16
16
|
const uts_1 = require("./uts");
|
|
17
|
+
const utsUtils_1 = require("./utsUtils");
|
|
17
18
|
const debugEasycom = (0, debug_1.default)('uni:easycom');
|
|
18
19
|
const easycoms = [];
|
|
19
20
|
const easycomsCache = new Map();
|
|
@@ -265,8 +266,8 @@ function genUTSComponentPublicInstanceImported(root, fileName) {
|
|
|
265
266
|
fileName = (0, utils_1.normalizePath)(path_1.default.relative(root, fileName));
|
|
266
267
|
}
|
|
267
268
|
if (fileName.startsWith('@/')) {
|
|
268
|
-
return ((0,
|
|
269
|
+
return ((0, utsUtils_1.genUTSClassName)(fileName.replace('@/', '')) + 'ComponentPublicInstance');
|
|
269
270
|
}
|
|
270
|
-
return (0,
|
|
271
|
+
return (0, utsUtils_1.genUTSClassName)(fileName) + 'ComponentPublicInstance';
|
|
271
272
|
}
|
|
272
273
|
exports.genUTSComponentPublicInstanceImported = genUTSComponentPublicInstanceImported;
|
package/dist/hbx/alias.js
CHANGED
|
@@ -34,8 +34,21 @@ function initModuleAlias() {
|
|
|
34
34
|
}
|
|
35
35
|
if ((0, env_1.isInHBuilderX)()) {
|
|
36
36
|
// 又是为了复用 HBuilderX 的插件逻辑,硬编码映射
|
|
37
|
-
Object.keys(hbxPlugins).forEach((
|
|
38
|
-
|
|
37
|
+
Object.keys(hbxPlugins).forEach((lang) => {
|
|
38
|
+
const realPath = path_1.default.resolve(process.env.UNI_HBUILDERX_PLUGINS, hbxPlugins[lang]);
|
|
39
|
+
module_alias_1.default.addAlias(lang,
|
|
40
|
+
// @ts-expect-error
|
|
41
|
+
() => {
|
|
42
|
+
try {
|
|
43
|
+
require.resolve(realPath);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
const msg = exports.moduleAliasFormatter.format(`Preprocessor dependency "${lang}" not found. Did you install it?`);
|
|
47
|
+
console.error(msg);
|
|
48
|
+
process.exit(0);
|
|
49
|
+
}
|
|
50
|
+
return realPath;
|
|
51
|
+
});
|
|
39
52
|
});
|
|
40
53
|
// web 平台用了 vite 内置 css 插件,该插件会加载预编译器如scss、less等,需要转向到 HBuilderX 的对应编译器插件
|
|
41
54
|
if (process.env.UNI_PLATFORM === 'h5' ||
|
|
@@ -91,7 +104,11 @@ exports.moduleAliasFormatter = {
|
|
|
91
104
|
format(msg) {
|
|
92
105
|
let lang = '';
|
|
93
106
|
let preprocessor = '';
|
|
94
|
-
if (msg.includes(`"
|
|
107
|
+
if (msg.includes(`"pug"`)) {
|
|
108
|
+
lang = 'pug';
|
|
109
|
+
preprocessor = 'compile-pug-cli';
|
|
110
|
+
}
|
|
111
|
+
else if (msg.includes(`"sass"`)) {
|
|
95
112
|
lang = 'sass';
|
|
96
113
|
preprocessor = 'compile-dart-sass';
|
|
97
114
|
}
|
package/dist/hbx/log.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.errorFormatter = exports.removeWarnFormatter = exports.removeInfoFormatt
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const picocolors_1 = __importDefault(require("picocolors"));
|
|
10
|
+
const compiler_core_1 = require("@vue/compiler-core");
|
|
10
11
|
const shared_1 = require("@vue/shared");
|
|
11
12
|
const utils_1 = require("../utils");
|
|
12
13
|
const constants_1 = require("../constants");
|
|
@@ -117,7 +118,7 @@ function buildErrorMessage(err, args = [], includeStack = true) {
|
|
|
117
118
|
constants_1.EXTNAME_VUE_RE.test(err.id)) {
|
|
118
119
|
try {
|
|
119
120
|
const ast = (0, ast_1.parseVue)(fs_1.default.readFileSync(err.id, 'utf8'), []);
|
|
120
|
-
const scriptNode = ast.children.find((node) => node.type ===
|
|
121
|
+
const scriptNode = ast.children.find((node) => node.type === compiler_core_1.NodeTypes.ELEMENT && node.tag === 'script');
|
|
121
122
|
if (scriptNode) {
|
|
122
123
|
const scriptLoc = scriptNode.loc;
|
|
123
124
|
args.push(picocolors_1.default.yellow(pad((0, utils_2.generateCodeFrame)(scriptLoc.source, err.loc))));
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,8 @@ export * from './esbuild';
|
|
|
21
21
|
export * from './resolve';
|
|
22
22
|
export * from './scripts';
|
|
23
23
|
export * from './platform';
|
|
24
|
-
export
|
|
24
|
+
export * from './utsUtils';
|
|
25
|
+
export { parseUniExtApis, parseInjects, Define, DefineOptions, Defines, getUniExtApiProviderRegisters, } from './uni_modules';
|
|
25
26
|
export { M } from './messages';
|
|
26
27
|
export * from './exports';
|
|
27
28
|
export { checkUpdate } from './checkUpdate';
|
package/dist/index.js
CHANGED
|
@@ -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.checkUpdate = exports.M = exports.parseInjects = exports.parseUniExtApis = void 0;
|
|
17
|
+
exports.checkUpdate = exports.M = exports.getUniExtApiProviderRegisters = exports.parseInjects = exports.parseUniExtApis = void 0;
|
|
18
18
|
__exportStar(require("./fs"), exports);
|
|
19
19
|
__exportStar(require("./mp"), exports);
|
|
20
20
|
__exportStar(require("./url"), exports);
|
|
@@ -38,9 +38,11 @@ __exportStar(require("./esbuild"), exports);
|
|
|
38
38
|
__exportStar(require("./resolve"), exports);
|
|
39
39
|
__exportStar(require("./scripts"), exports);
|
|
40
40
|
__exportStar(require("./platform"), exports);
|
|
41
|
+
__exportStar(require("./utsUtils"), exports);
|
|
41
42
|
var uni_modules_1 = require("./uni_modules");
|
|
42
43
|
Object.defineProperty(exports, "parseUniExtApis", { enumerable: true, get: function () { return uni_modules_1.parseUniExtApis; } });
|
|
43
44
|
Object.defineProperty(exports, "parseInjects", { enumerable: true, get: function () { return uni_modules_1.parseInjects; } });
|
|
45
|
+
Object.defineProperty(exports, "getUniExtApiProviderRegisters", { enumerable: true, get: function () { return uni_modules_1.getUniExtApiProviderRegisters; } });
|
|
44
46
|
var messages_1 = require("./messages");
|
|
45
47
|
Object.defineProperty(exports, "M", { enumerable: true, get: function () { return messages_1.M; } });
|
|
46
48
|
__exportStar(require("./exports"), exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const arrayBufferCode = "\nif (typeof uni !== 'undefined' && uni && uni.requireGlobal) {\n const global = uni.requireGlobal()\n ArrayBuffer = global.ArrayBuffer\n Int8Array = global.Int8Array\n Uint8Array = global.Uint8Array\n Uint8ClampedArray = global.Uint8ClampedArray\n Int16Array = global.Int16Array\n Uint16Array = global.Uint16Array\n Int32Array = global.Int32Array\n Uint32Array = global.Uint32Array\n Float32Array = global.Float32Array\n Float64Array = global.Float64Array\n BigInt64Array = global.BigInt64Array\n BigUint64Array = global.BigUint64Array\n};\n";
|
|
2
|
-
export declare const polyfillCode
|
|
2
|
+
export declare const polyfillCode = "\nif (typeof Promise !== 'undefined' && !Promise.prototype.finally) {\n Promise.prototype.finally = function(callback) {\n const promise = this.constructor\n return this.then(\n value => promise.resolve(callback()).then(() => value),\n reason => promise.resolve(callback()).then(() => {\n throw reason\n })\n )\n }\n};\n\nif (typeof uni !== 'undefined' && uni && uni.requireGlobal) {\n const global = uni.requireGlobal()\n ArrayBuffer = global.ArrayBuffer\n Int8Array = global.Int8Array\n Uint8Array = global.Uint8Array\n Uint8ClampedArray = global.Uint8ClampedArray\n Int16Array = global.Int16Array\n Uint16Array = global.Uint16Array\n Int32Array = global.Int32Array\n Uint32Array = global.Uint32Array\n Float32Array = global.Float32Array\n Float64Array = global.Float64Array\n BigInt64Array = global.BigInt64Array\n BigUint64Array = global.BigUint64Array\n};\n\n";
|
|
3
3
|
export declare const restoreGlobalCode = "\nif(uni.restoreGlobal){\n uni.restoreGlobal(Vue,weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)\n}\n";
|
|
4
4
|
export declare const globalCode: string;
|
package/dist/json/mp/index.d.ts
CHANGED
package/dist/json/mp/project.js
CHANGED
|
@@ -83,8 +83,8 @@ function parseMiniProgramCondition(pagesJson) {
|
|
|
83
83
|
list: [
|
|
84
84
|
{
|
|
85
85
|
id: 0,
|
|
86
|
-
name: launchPagePath,
|
|
87
|
-
pathName: launchPagePath,
|
|
86
|
+
name: launchPagePath, // 模式名称
|
|
87
|
+
pathName: launchPagePath, // 启动页面,必选
|
|
88
88
|
query: process.env.UNI_CLI_LAUNCH_PAGE_QUERY || '', // 启动参数,在页面的onLoad函数里面得到。
|
|
89
89
|
},
|
|
90
90
|
],
|
package/dist/json/mp/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export interface ComponentJson {
|
|
|
2
2
|
component: true;
|
|
3
3
|
usingComponents?: UsingComponents;
|
|
4
4
|
usingSwanComponents?: UsingComponents;
|
|
5
|
-
styleIsolation?: 'apply-shared' | 'shared';
|
|
5
|
+
styleIsolation?: 'apply-shared' | 'shared' | 'isolated';
|
|
6
6
|
}
|
|
7
7
|
interface ShareWindowOptions {
|
|
8
8
|
navigationBarBackgroundColor?: string;
|
|
@@ -12,6 +12,10 @@ function normalizeAppXUniConfig(pagesJson, manifestJson) {
|
|
|
12
12
|
tabBar: pagesJson.tabBar,
|
|
13
13
|
fallbackLocale: manifestJson.fallbackLocale,
|
|
14
14
|
};
|
|
15
|
+
if (config.realEntryPagePath) {
|
|
16
|
+
config.conditionUrl = config.entryPagePath;
|
|
17
|
+
config.entryPagePath = config.realEntryPagePath;
|
|
18
|
+
}
|
|
15
19
|
// TODO 待支持分包
|
|
16
20
|
return JSON.stringify(config);
|
|
17
21
|
}
|
package/dist/mp/tags.js
CHANGED
|
@@ -103,12 +103,12 @@ exports.HTML_TO_MINI_PROGRAM_TAGS = {
|
|
|
103
103
|
dialog: 'view',
|
|
104
104
|
summary: 'view',
|
|
105
105
|
// progress: 'progress',
|
|
106
|
-
meter: 'progress',
|
|
107
|
-
head: 'view',
|
|
108
|
-
meta: 'view',
|
|
109
|
-
base: 'text',
|
|
106
|
+
meter: 'progress', // todo
|
|
107
|
+
head: 'view', // todo
|
|
108
|
+
meta: 'view', // todo
|
|
109
|
+
base: 'text', // todo
|
|
110
110
|
// 'map': 'image', // TODO不是很恰当
|
|
111
|
-
area: 'navigator',
|
|
111
|
+
area: 'navigator', // j结合map使用
|
|
112
112
|
script: 'view',
|
|
113
113
|
noscript: 'view',
|
|
114
114
|
embed: 'view',
|
package/dist/uni_modules.d.ts
CHANGED
|
@@ -21,6 +21,11 @@ export declare function getUniExtApiProviders(): {
|
|
|
21
21
|
name?: string | undefined;
|
|
22
22
|
servicePlugin?: string | undefined;
|
|
23
23
|
}[];
|
|
24
|
+
export declare function getUniExtApiProviderRegisters(): {
|
|
25
|
+
name: string;
|
|
26
|
+
service: string;
|
|
27
|
+
class: string;
|
|
28
|
+
}[];
|
|
24
29
|
export declare function parseUniExtApis(vite: boolean | undefined, platform: typeof process.env.UNI_UTS_PLATFORM, language?: UTSTargetLanguage): Injects;
|
|
25
30
|
export type Injects = {
|
|
26
31
|
[name: string]: string | [string, string] | [string, string, DefineOptions['app']] | false;
|
|
@@ -47,3 +52,18 @@ export type Injects = {
|
|
|
47
52
|
* @returns
|
|
48
53
|
*/
|
|
49
54
|
export declare function parseInjects(vite: boolean | undefined, platform: typeof process.env.UNI_UTS_PLATFORM, language: UTSTargetLanguage, source: string, uniModuleRootDir: string, exports?: Exports): Injects;
|
|
55
|
+
/**
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
export declare const camelize: (str: string) => string;
|
|
59
|
+
/**
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
export declare const capitalize: (str: string) => string;
|
|
63
|
+
/**
|
|
64
|
+
* 解析 UTS 类型的模块依赖列表
|
|
65
|
+
* @param deps
|
|
66
|
+
* @param inputDir
|
|
67
|
+
* @returns
|
|
68
|
+
*/
|
|
69
|
+
export declare function parseUTSModuleDeps(deps: string[], inputDir: string): string[];
|
package/dist/uni_modules.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.parseInjects = exports.parseUniExtApis = exports.getUniExtApiProviders = void 0;
|
|
6
|
+
exports.parseUTSModuleDeps = exports.capitalize = exports.camelize = exports.parseInjects = exports.parseUniExtApis = exports.getUniExtApiProviderRegisters = 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"));
|
|
@@ -12,6 +12,24 @@ function getUniExtApiProviders() {
|
|
|
12
12
|
return extApiProviders;
|
|
13
13
|
}
|
|
14
14
|
exports.getUniExtApiProviders = getUniExtApiProviders;
|
|
15
|
+
function getUniExtApiProviderRegisters() {
|
|
16
|
+
const result = [];
|
|
17
|
+
extApiProviders.forEach((provider) => {
|
|
18
|
+
if (provider.name && provider.service) {
|
|
19
|
+
result.push({
|
|
20
|
+
name: provider.name,
|
|
21
|
+
service: provider.service,
|
|
22
|
+
class: `uts.sdk.modules.${(0, exports.camelize)(provider.plugin)}.${(0, exports.capitalize)((0, exports.camelize)('uni-ext-api-' +
|
|
23
|
+
provider.service +
|
|
24
|
+
'-' +
|
|
25
|
+
provider.name +
|
|
26
|
+
'-provider'))}`,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
exports.getUniExtApiProviderRegisters = getUniExtApiProviderRegisters;
|
|
15
33
|
function parseUniExtApis(vite = true, platform, language = 'javascript') {
|
|
16
34
|
if (!process.env.UNI_INPUT_DIR) {
|
|
17
35
|
return {};
|
|
@@ -109,6 +127,11 @@ function parseInjects(vite = true, platform, language, source, uniModuleRootDir,
|
|
|
109
127
|
source = `${source}/utssdk/index.uts`;
|
|
110
128
|
}
|
|
111
129
|
}
|
|
130
|
+
else if (process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js') {
|
|
131
|
+
if (fs_extra_1.default.existsSync(path_1.default.resolve(uniModuleRootDir, 'utssdk', 'app-js', 'index.uts'))) {
|
|
132
|
+
source = `${source}/utssdk/app-js/index.uts`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
112
135
|
for (const key in rootDefines) {
|
|
113
136
|
Object.assign(injects, parseInject(vite, platform, language, source, 'uni', rootDefines[key], hasPlatformFile));
|
|
114
137
|
}
|
|
@@ -157,19 +180,24 @@ function parseInject(vite = true, platform, language, source, globalObject, defi
|
|
|
157
180
|
if (p === 'app') {
|
|
158
181
|
const appOptions = defineOptions.app;
|
|
159
182
|
if (isPlainObject(appOptions)) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
183
|
+
// js engine 下且存在 app-js,不检查
|
|
184
|
+
const skipCheck = process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js' &&
|
|
185
|
+
source.includes('app-js');
|
|
186
|
+
if (!skipCheck) {
|
|
187
|
+
if (language === 'javascript') {
|
|
188
|
+
if (appOptions.js === false) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
163
191
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
192
|
+
else if (language === 'kotlin') {
|
|
193
|
+
if (appOptions.kotlin === false) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
168
196
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
197
|
+
else if (language === 'swift') {
|
|
198
|
+
if (appOptions.swift === false) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
173
201
|
}
|
|
174
202
|
}
|
|
175
203
|
}
|
|
@@ -197,3 +225,34 @@ const toTypeString = (value) => objectToString.call(value);
|
|
|
197
225
|
function isPlainObject(val) {
|
|
198
226
|
return toTypeString(val) === '[object Object]';
|
|
199
227
|
}
|
|
228
|
+
const cacheStringFunction = (fn) => {
|
|
229
|
+
const cache = Object.create(null);
|
|
230
|
+
return ((str) => {
|
|
231
|
+
const hit = cache[str];
|
|
232
|
+
return hit || (cache[str] = fn(str));
|
|
233
|
+
});
|
|
234
|
+
};
|
|
235
|
+
const camelizeRE = /-(\w)/g;
|
|
236
|
+
/**
|
|
237
|
+
* @private
|
|
238
|
+
*/
|
|
239
|
+
exports.camelize = cacheStringFunction((str) => {
|
|
240
|
+
return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
|
|
241
|
+
});
|
|
242
|
+
/**
|
|
243
|
+
* @private
|
|
244
|
+
*/
|
|
245
|
+
exports.capitalize = cacheStringFunction((str) => str.charAt(0).toUpperCase() + str.slice(1));
|
|
246
|
+
/**
|
|
247
|
+
* 解析 UTS 类型的模块依赖列表
|
|
248
|
+
* @param deps
|
|
249
|
+
* @param inputDir
|
|
250
|
+
* @returns
|
|
251
|
+
*/
|
|
252
|
+
function parseUTSModuleDeps(deps, inputDir) {
|
|
253
|
+
const modulesDir = path_1.default.resolve(inputDir, 'uni_modules');
|
|
254
|
+
return deps.filter((dep) => {
|
|
255
|
+
return fs_extra_1.default.existsSync(path_1.default.resolve(modulesDir, dep, 'utssdk'));
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
exports.parseUTSModuleDeps = parseUTSModuleDeps;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export { default as hash } from 'hash-sum';
|
|
2
2
|
import { ElementNode, RootNode, TemplateChildNode } from '@vue/compiler-core';
|
|
3
3
|
import { ParserPlugin } from '@babel/parser';
|
|
4
|
-
export declare const version: any;
|
|
5
4
|
export { camelize, capitalize, isArray } from '@vue/shared';
|
|
6
|
-
export declare let isRunningWithYarnPnp: boolean;
|
|
7
5
|
export declare const isWindows: boolean;
|
|
8
6
|
export declare function normalizePath(id: string): string;
|
|
9
7
|
export declare function checkElementNodeTag(node: RootNode | TemplateChildNode | null | undefined, tag: string): node is ElementNode;
|
package/dist/utils.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.createResolveErrorMsg = exports.parseImporter = exports.resolveAppVue = exports.isAppVue = exports.installDepTips = exports.resolveSourceMapPath = exports.pathToGlob = exports.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.
|
|
6
|
+
exports.createResolveErrorMsg = exports.parseImporter = exports.resolveAppVue = exports.isAppVue = exports.installDepTips = exports.resolveSourceMapPath = exports.pathToGlob = exports.normalizeParsePlugins = exports.normalizeMiniProgramFilename = exports.normalizeNodeModules = exports.removeExt = exports.normalizePagePath = exports.normalizeIdentifier = exports.checkElementNodeTag = exports.normalizePath = exports.isWindows = exports.isArray = exports.capitalize = exports.camelize = exports.hash = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -12,25 +12,25 @@ const shared_1 = require("@vue/shared");
|
|
|
12
12
|
var hash_sum_1 = require("hash-sum");
|
|
13
13
|
Object.defineProperty(exports, "hash", { enumerable: true, get: function () { return __importDefault(hash_sum_1).default; } });
|
|
14
14
|
const constants_1 = require("./constants");
|
|
15
|
+
const compiler_core_1 = require("@vue/compiler-core");
|
|
15
16
|
const platform_1 = require("./platform");
|
|
16
17
|
const hbx_1 = require("./hbx");
|
|
17
|
-
exports.version = require('../package.json').version;
|
|
18
18
|
// 专为 uts.ts 服务
|
|
19
19
|
var shared_2 = require("@vue/shared");
|
|
20
20
|
Object.defineProperty(exports, "camelize", { enumerable: true, get: function () { return shared_2.camelize; } });
|
|
21
21
|
Object.defineProperty(exports, "capitalize", { enumerable: true, get: function () { return shared_2.capitalize; } });
|
|
22
22
|
Object.defineProperty(exports, "isArray", { enumerable: true, get: function () { return shared_2.isArray; } });
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
catch {
|
|
23
|
+
// export let isRunningWithYarnPnp: boolean
|
|
24
|
+
// try {
|
|
25
|
+
// isRunningWithYarnPnp = Boolean(require('pnpapi'))
|
|
26
|
+
// } catch {}
|
|
27
27
|
exports.isWindows = os_1.default.platform() === 'win32';
|
|
28
28
|
function normalizePath(id) {
|
|
29
29
|
return exports.isWindows ? id.replace(/\\/g, '/') : id;
|
|
30
30
|
}
|
|
31
31
|
exports.normalizePath = normalizePath;
|
|
32
32
|
function checkElementNodeTag(node, tag) {
|
|
33
|
-
return !!node && node.type ===
|
|
33
|
+
return !!node && node.type === compiler_core_1.NodeTypes.ELEMENT && node.tag === tag;
|
|
34
34
|
}
|
|
35
35
|
exports.checkElementNodeTag = checkElementNodeTag;
|
|
36
36
|
function normalizeIdentifier(str) {
|
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 {
|
|
4
|
+
import type { EasycomMatcher } from './easycom';
|
|
5
5
|
/**
|
|
6
6
|
* 解析 app 平台的 uts 插件,任意平台(android|ios)存在即可
|
|
7
7
|
* @param id
|
|
@@ -23,5 +23,3 @@ 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;
|
|
27
|
-
export declare function genUTSClassName(fileName: string, prefix?: string): string;
|
package/dist/uts.js
CHANGED
|
@@ -3,15 +3,14 @@ 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.
|
|
6
|
+
exports.parseUniExtApiNamespacesJsOnce = exports.parseUniExtApiNamespacesOnce = exports.parseSwiftPackageWithPluginId = exports.parseKotlinPackageWithPluginId = exports.initUTSComponents = exports.parseUTSComponent = exports.isUTSComponent = exports.resolveUTSCompiler = exports.resolveUTSModule = exports.resolveUTSAppModule = void 0;
|
|
7
|
+
// 重要,该文件编译后的 js 需要同步到 vue2 编译器 uni-cli-shared/lib/uts
|
|
7
8
|
const fs_1 = __importDefault(require("fs"));
|
|
8
9
|
const path_1 = __importDefault(require("path"));
|
|
9
10
|
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
10
11
|
const hbx_1 = require("./hbx");
|
|
11
12
|
const utils_1 = require("./utils");
|
|
12
|
-
const easycom_1 = require("./easycom");
|
|
13
13
|
const uni_modules_1 = require("./uni_modules");
|
|
14
|
-
// 重要,该文件编译后的 js 需要同步到 vue2 编译器 uni-cli-shared/lib/uts
|
|
15
14
|
function once(fn, ctx = null) {
|
|
16
15
|
let res;
|
|
17
16
|
return ((...args) => {
|
|
@@ -36,6 +35,15 @@ function resolveUTSAppModule(id, importer, includeUTSSDK = true) {
|
|
|
36
35
|
if (parentDir === 'uni_modules' ||
|
|
37
36
|
(includeUTSSDK && parentDir === 'utssdk')) {
|
|
38
37
|
const basedir = parentDir === 'uni_modules' ? 'utssdk' : '';
|
|
38
|
+
if (process.env.UNI_APP_X_UVUE_SCRIPT_ENGINE === 'js') {
|
|
39
|
+
// js engine
|
|
40
|
+
if (parentDir === 'uni_modules') {
|
|
41
|
+
const appJsIndex = path_1.default.resolve(id, basedir, 'app-js', 'index.uts');
|
|
42
|
+
if (fs_1.default.existsSync(appJsIndex)) {
|
|
43
|
+
return appJsIndex;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
39
47
|
if (fs_1.default.existsSync(path_1.default.resolve(id, basedir, 'index.uts'))) {
|
|
40
48
|
return id;
|
|
41
49
|
}
|
|
@@ -104,8 +112,18 @@ function resolveUTSCompiler() {
|
|
|
104
112
|
});
|
|
105
113
|
}
|
|
106
114
|
catch (e) {
|
|
107
|
-
let utsCompilerVersion =
|
|
108
|
-
|
|
115
|
+
let utsCompilerVersion = '';
|
|
116
|
+
try {
|
|
117
|
+
utsCompilerVersion = require('../package.json').version;
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
try {
|
|
121
|
+
// vue2
|
|
122
|
+
utsCompilerVersion = require('../../package.json').version;
|
|
123
|
+
}
|
|
124
|
+
catch (e) { }
|
|
125
|
+
}
|
|
126
|
+
if (utsCompilerVersion.startsWith('2.0.')) {
|
|
109
127
|
utsCompilerVersion = '^3.0.0-alpha-3060920221117001';
|
|
110
128
|
}
|
|
111
129
|
console.error((0, utils_1.installDepTips)('devDependencies', '@dcloudio/uni-uts-v1', utsCompilerVersion));
|
|
@@ -254,42 +272,3 @@ exports.parseUniExtApiNamespacesJsOnce = once((platform, language) => {
|
|
|
254
272
|
});
|
|
255
273
|
return namespaces;
|
|
256
274
|
});
|
|
257
|
-
function matchUTSComponent(tag) {
|
|
258
|
-
const source = (0, easycom_1.matchEasycom)(tag);
|
|
259
|
-
return !!(source && source.includes('uts-proxy'));
|
|
260
|
-
}
|
|
261
|
-
exports.matchUTSComponent = matchUTSComponent;
|
|
262
|
-
function genUTSClassName(fileName, prefix = 'Gen') {
|
|
263
|
-
return (prefix +
|
|
264
|
-
(0, utils_1.capitalize)((0, utils_1.camelize)(verifySymbol((0, utils_1.removeExt)((0, utils_1.normalizeNodeModules)(fileName)
|
|
265
|
-
.replace(/[\/|_]/g, '-')
|
|
266
|
-
.replace(/-+/g, '-'))))));
|
|
267
|
-
}
|
|
268
|
-
exports.genUTSClassName = genUTSClassName;
|
|
269
|
-
function isValidStart(c) {
|
|
270
|
-
return !!c.match(/^[A-Za-z_-]$/);
|
|
271
|
-
}
|
|
272
|
-
function isValidContinue(c) {
|
|
273
|
-
return !!c.match(/^[A-Za-z0-9_-]$/);
|
|
274
|
-
}
|
|
275
|
-
function verifySymbol(s) {
|
|
276
|
-
const chars = Array.from(s);
|
|
277
|
-
if (isValidStart(chars[0]) && chars.slice(1).every(isValidContinue)) {
|
|
278
|
-
return s;
|
|
279
|
-
}
|
|
280
|
-
const buf = [];
|
|
281
|
-
let hasStart = false;
|
|
282
|
-
for (const c of chars) {
|
|
283
|
-
if (!hasStart && isValidStart(c)) {
|
|
284
|
-
hasStart = true;
|
|
285
|
-
buf.push(c);
|
|
286
|
-
}
|
|
287
|
-
else if (isValidContinue(c)) {
|
|
288
|
-
buf.push(c);
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
if (buf.length === 0) {
|
|
292
|
-
buf.push('_');
|
|
293
|
-
}
|
|
294
|
-
return buf.join('');
|
|
295
|
-
}
|
package/dist/utsUtils.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.genUTSClassName = exports.matchUTSComponent = void 0;
|
|
4
|
+
const easycom_1 = require("./easycom");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
function matchUTSComponent(tag) {
|
|
7
|
+
const source = (0, easycom_1.matchEasycom)(tag);
|
|
8
|
+
return !!(source && source.includes('uts-proxy'));
|
|
9
|
+
}
|
|
10
|
+
exports.matchUTSComponent = matchUTSComponent;
|
|
11
|
+
function genUTSClassName(fileName, prefix = 'Gen') {
|
|
12
|
+
return (prefix +
|
|
13
|
+
(0, utils_1.capitalize)((0, utils_1.camelize)(verifySymbol((0, utils_1.removeExt)((0, utils_1.normalizeNodeModules)(fileName)
|
|
14
|
+
.replace(/[\/|_]/g, '-')
|
|
15
|
+
.replace(/-+/g, '-'))))));
|
|
16
|
+
}
|
|
17
|
+
exports.genUTSClassName = genUTSClassName;
|
|
18
|
+
function isValidStart(c) {
|
|
19
|
+
return !!c.match(/^[A-Za-z_-]$/);
|
|
20
|
+
}
|
|
21
|
+
function isValidContinue(c) {
|
|
22
|
+
return !!c.match(/^[A-Za-z0-9_-]$/);
|
|
23
|
+
}
|
|
24
|
+
function verifySymbol(s) {
|
|
25
|
+
const chars = Array.from(s);
|
|
26
|
+
if (isValidStart(chars[0]) && chars.slice(1).every(isValidContinue)) {
|
|
27
|
+
return s;
|
|
28
|
+
}
|
|
29
|
+
const buf = [];
|
|
30
|
+
let hasStart = false;
|
|
31
|
+
for (const c of chars) {
|
|
32
|
+
if (!hasStart && isValidStart(c)) {
|
|
33
|
+
hasStart = true;
|
|
34
|
+
buf.push(c);
|
|
35
|
+
}
|
|
36
|
+
else if (isValidContinue(c)) {
|
|
37
|
+
buf.push(c);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (buf.length === 0) {
|
|
41
|
+
buf.push('_');
|
|
42
|
+
}
|
|
43
|
+
return buf.join('');
|
|
44
|
+
}
|
package/dist/vite/autoImport.js
CHANGED
|
@@ -36,7 +36,47 @@ const uniPreset = {
|
|
|
36
36
|
};
|
|
37
37
|
const uniH5Preset = {
|
|
38
38
|
from: '@dcloudio/uni-h5',
|
|
39
|
-
imports: [
|
|
39
|
+
imports: [
|
|
40
|
+
'UniElement',
|
|
41
|
+
'UniElementImpl',
|
|
42
|
+
'UniButtonElement',
|
|
43
|
+
'UniCanvasElement',
|
|
44
|
+
'UniCheckboxElement',
|
|
45
|
+
'UniCheckboxGroupElement',
|
|
46
|
+
'UniEditorElement',
|
|
47
|
+
'UniFormElement',
|
|
48
|
+
'UniIconElement',
|
|
49
|
+
'UniImageElement',
|
|
50
|
+
'UniInputElement',
|
|
51
|
+
'UniLabelElement',
|
|
52
|
+
'UniMovableAreaElement',
|
|
53
|
+
'UniMovableViewElement',
|
|
54
|
+
'UniNavigatorElement',
|
|
55
|
+
'UniPickerViewElement',
|
|
56
|
+
'UniPickerViewColumnElement',
|
|
57
|
+
'UniProgressElement',
|
|
58
|
+
'UniRadioElement',
|
|
59
|
+
'UniRadioGroupElement',
|
|
60
|
+
'UniRichTextElement',
|
|
61
|
+
'UniScrollViewElement',
|
|
62
|
+
'UniSliderElement',
|
|
63
|
+
'UniSwiperElement',
|
|
64
|
+
'UniSwiperItemElement',
|
|
65
|
+
'UniSwitchElement',
|
|
66
|
+
'UniTextElement',
|
|
67
|
+
'UniTextareaElement',
|
|
68
|
+
'UniViewElement',
|
|
69
|
+
'UniListViewElement',
|
|
70
|
+
'UniListItemElement',
|
|
71
|
+
'UniStickySectionElement',
|
|
72
|
+
'UniStickyHeaderElement',
|
|
73
|
+
'UniVideoElement',
|
|
74
|
+
'UniWebViewElement',
|
|
75
|
+
'UniMapElement',
|
|
76
|
+
'UniCoverViewElement',
|
|
77
|
+
'UniCoverImageElement',
|
|
78
|
+
'UniPickerElement',
|
|
79
|
+
],
|
|
40
80
|
};
|
|
41
81
|
const cloudPreset = {
|
|
42
82
|
'@dcloudio/uni-cloud': [['default', 'uniCloud']],
|