@dcloudio/uni-cli-shared 3.0.0-alpha-3040620220419002 → 3.0.0-alpha-3040720220422002
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/json/app/index.d.ts +1 -1
- package/dist/json/app/index.js +3 -1
- package/dist/json/app/manifest/merge.js +1 -0
- package/dist/json/app/manifest/plus.js +41 -0
- package/dist/json/app/pages/code.d.ts +2 -1
- package/dist/json/app/pages/code.js +20 -5
- package/dist/json/app/pages/index.js +1 -1
- package/dist/mp/template.d.ts +4 -0
- package/dist/mp/usingComponents.d.ts +5 -4
- package/dist/mp/usingComponents.js +10 -10
- package/package.json +3 -3
package/dist/json/app/index.d.ts
CHANGED
package/dist/json/app/index.js
CHANGED
|
@@ -14,8 +14,10 @@ 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.polyfillCode = void 0;
|
|
17
|
+
exports.restoreGlobalCode = exports.arrayBufferCode = exports.polyfillCode = void 0;
|
|
18
18
|
__exportStar(require("./pages"), exports);
|
|
19
19
|
__exportStar(require("./manifest"), exports);
|
|
20
20
|
var code_1 = require("./pages/code");
|
|
21
21
|
Object.defineProperty(exports, "polyfillCode", { enumerable: true, get: function () { return code_1.polyfillCode; } });
|
|
22
|
+
Object.defineProperty(exports, "arrayBufferCode", { enumerable: true, get: function () { return code_1.arrayBufferCode; } });
|
|
23
|
+
Object.defineProperty(exports, "restoreGlobalCode", { enumerable: true, get: function () { return code_1.restoreGlobalCode; } });
|
|
@@ -12,6 +12,7 @@ function initRecursiveMerge(manifestJson, userManifestJson) {
|
|
|
12
12
|
code: userManifestJson.versionCode,
|
|
13
13
|
},
|
|
14
14
|
locale: userManifestJson.locale,
|
|
15
|
+
uniStatistics: userManifestJson.uniStatistics,
|
|
15
16
|
}, { plus: userManifestJson['app-plus'] });
|
|
16
17
|
}
|
|
17
18
|
exports.initRecursiveMerge = initRecursiveMerge;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.initPlus = void 0;
|
|
4
|
+
const shared_1 = require("@vue/shared");
|
|
5
|
+
const merge_1 = require("merge");
|
|
4
6
|
const wxPageOrientationMapping = {
|
|
5
7
|
auto: [
|
|
6
8
|
'portrait-primary',
|
|
@@ -13,6 +15,7 @@ const wxPageOrientationMapping = {
|
|
|
13
15
|
};
|
|
14
16
|
function initPlus(manifestJson, pagesJson) {
|
|
15
17
|
var _a;
|
|
18
|
+
initUniStatistics(manifestJson);
|
|
16
19
|
// 转换为老版本配置
|
|
17
20
|
if (manifestJson.plus.modules) {
|
|
18
21
|
manifestJson.permissions = manifestJson.plus.modules;
|
|
@@ -81,3 +84,41 @@ function initPlus(manifestJson, pagesJson) {
|
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
exports.initPlus = initPlus;
|
|
87
|
+
function initUniStatistics(manifestJson) {
|
|
88
|
+
var _a;
|
|
89
|
+
// 根节点配置了统计
|
|
90
|
+
if (manifestJson.uniStatistics) {
|
|
91
|
+
manifestJson.plus.uniStatistics = (0, merge_1.recursive)(true, manifestJson.uniStatistics, manifestJson.plus.uniStatistics);
|
|
92
|
+
delete manifestJson.uniStatistics;
|
|
93
|
+
}
|
|
94
|
+
if (!process.env.UNI_CLOUD_SPACES) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
let spaces = [];
|
|
98
|
+
try {
|
|
99
|
+
spaces = JSON.parse(process.env.UNI_CLOUD_SPACES);
|
|
100
|
+
}
|
|
101
|
+
catch (e) { }
|
|
102
|
+
if (!(0, shared_1.isArray)(spaces) || !spaces.length) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const space = spaces[0];
|
|
106
|
+
if (!space) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const uniStatistics = (_a = manifestJson.plus) === null || _a === void 0 ? void 0 : _a.uniStatistics;
|
|
110
|
+
if (!uniStatistics) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (uniStatistics.version === 2 || uniStatistics.version === '2') {
|
|
114
|
+
if (uniStatistics.uniCloud && uniStatistics.uniCloud.spaceId) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
uniStatistics.uniCloud = {
|
|
118
|
+
provider: space.provider,
|
|
119
|
+
spaceId: space.id,
|
|
120
|
+
clientSecret: space.clientSecret,
|
|
121
|
+
endpoint: space.apiEndpoint,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
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: string;
|
|
2
3
|
export declare const restoreGlobalCode = "\nif(uni.restoreGlobal){\n uni.restoreGlobal(Vue,weex,plus,setTimeout,clearTimeout,setInterval,clearInterval)\n}\n";
|
|
3
4
|
export declare const globalCode: string;
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.globalCode = exports.restoreGlobalCode = exports.polyfillCode = void 0;
|
|
3
|
+
exports.globalCode = exports.restoreGlobalCode = exports.polyfillCode = exports.arrayBufferCode = void 0;
|
|
4
|
+
exports.arrayBufferCode = `
|
|
5
|
+
if (typeof uni !== 'undefined' && uni && uni.requireGlobal) {
|
|
6
|
+
const global = uni.requireGlobal()
|
|
7
|
+
ArrayBuffer = global.ArrayBuffer
|
|
8
|
+
Int8Array = global.Int8Array
|
|
9
|
+
Uint8Array = global.Uint8Array
|
|
10
|
+
Uint8ClampedArray = global.Uint8ClampedArray
|
|
11
|
+
Int16Array = global.Int16Array
|
|
12
|
+
Uint16Array = global.Uint16Array
|
|
13
|
+
Int32Array = global.Int32Array
|
|
14
|
+
Uint32Array = global.Uint32Array
|
|
15
|
+
Float32Array = global.Float32Array
|
|
16
|
+
Float64Array = global.Float64Array
|
|
17
|
+
BigInt64Array = global.BigInt64Array
|
|
18
|
+
BigUint64Array = global.BigUint64Array
|
|
19
|
+
};
|
|
20
|
+
`;
|
|
4
21
|
exports.polyfillCode = `
|
|
5
22
|
if (typeof Promise !== 'undefined' && !Promise.prototype.finally) {
|
|
6
23
|
Promise.prototype.finally = function(callback) {
|
|
@@ -12,10 +29,8 @@ if (typeof Promise !== 'undefined' && !Promise.prototype.finally) {
|
|
|
12
29
|
})
|
|
13
30
|
)
|
|
14
31
|
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
ArrayBuffer = uni.base64ToArrayBuffer('').constructor
|
|
18
|
-
}
|
|
32
|
+
};
|
|
33
|
+
${exports.arrayBufferCode}
|
|
19
34
|
`;
|
|
20
35
|
exports.restoreGlobalCode = `
|
|
21
36
|
if(uni.restoreGlobal){
|
|
@@ -6,7 +6,7 @@ const definePage_1 = require("./definePage");
|
|
|
6
6
|
const uniConfig_1 = require("./uniConfig");
|
|
7
7
|
const uniRoutes_1 = require("./uniRoutes");
|
|
8
8
|
function normalizeAppPagesJson(pagesJson) {
|
|
9
|
-
return
|
|
9
|
+
return (0, definePage_1.definePageCode)(pagesJson);
|
|
10
10
|
}
|
|
11
11
|
exports.normalizeAppPagesJson = normalizeAppPagesJson;
|
|
12
12
|
function normalizeAppNVuePagesJson(pagesJson) {
|
package/dist/mp/template.d.ts
CHANGED
|
@@ -53,6 +53,10 @@ export interface MiniProgramCompilerOptions {
|
|
|
53
53
|
* 父组件 setData 后,子组件的 properties 是否可以同步获取,目前仅 mp-weixin,mp-qq,mp-alipay 支持
|
|
54
54
|
*/
|
|
55
55
|
getPropertySync?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* 格式化组件名称,比如 wx-btn => weixin-btn (微信不允许以 wx 命名自定义组件)
|
|
58
|
+
*/
|
|
59
|
+
normalizeName?: (name: string) => string;
|
|
56
60
|
};
|
|
57
61
|
directive: string;
|
|
58
62
|
emitFile?: (emittedFile: EmittedAsset) => string;
|
|
@@ -10,15 +10,16 @@ interface MainDescriptor {
|
|
|
10
10
|
template: string;
|
|
11
11
|
}
|
|
12
12
|
export declare function parseMainDescriptor(filename: string, ast: Program, resolve: ParseDescriptor['resolve']): Promise<MainDescriptor>;
|
|
13
|
-
export declare function updateMiniProgramComponentsByScriptFilename(scriptFilename: string, inputDir: string): void;
|
|
14
|
-
export declare function updateMiniProgramComponentsByTemplateFilename(templateFilename: string, inputDir: string): void;
|
|
15
|
-
export declare function updateMiniProgramGlobalComponents(filename: string, ast: Program, { inputDir, resolve, }: {
|
|
13
|
+
export declare function updateMiniProgramComponentsByScriptFilename(scriptFilename: string, inputDir: string, normalizeComponentName: (name: string) => string): void;
|
|
14
|
+
export declare function updateMiniProgramComponentsByTemplateFilename(templateFilename: string, inputDir: string, normalizeComponentName: (name: string) => string): void;
|
|
15
|
+
export declare function updateMiniProgramGlobalComponents(filename: string, ast: Program, { inputDir, resolve, normalizeComponentName, }: {
|
|
16
16
|
inputDir: string;
|
|
17
17
|
resolve: ParseDescriptor['resolve'];
|
|
18
|
+
normalizeComponentName: (name: string) => string;
|
|
18
19
|
}): Promise<{
|
|
19
20
|
imports: ImportDeclaration[];
|
|
20
21
|
}>;
|
|
21
|
-
export declare function updateMiniProgramComponentsByMainFilename(mainFilename: string, inputDir: string): void;
|
|
22
|
+
export declare function updateMiniProgramComponentsByMainFilename(mainFilename: string, inputDir: string, normalizeComponentName: (name: string) => string): void;
|
|
22
23
|
export interface TemplateDescriptor {
|
|
23
24
|
bindingComponents: BindingComponents;
|
|
24
25
|
imports: ImportDeclaration[];
|
|
@@ -60,17 +60,17 @@ async function parseMainDescriptor(filename, ast, resolve) {
|
|
|
60
60
|
return descriptor;
|
|
61
61
|
}
|
|
62
62
|
exports.parseMainDescriptor = parseMainDescriptor;
|
|
63
|
-
function updateMiniProgramComponentsByScriptFilename(scriptFilename, inputDir) {
|
|
63
|
+
function updateMiniProgramComponentsByScriptFilename(scriptFilename, inputDir, normalizeComponentName) {
|
|
64
64
|
const mainFilename = findMainFilenameByScriptFilename(scriptFilename);
|
|
65
65
|
if (mainFilename) {
|
|
66
|
-
updateMiniProgramComponentsByMainFilename(mainFilename, inputDir);
|
|
66
|
+
updateMiniProgramComponentsByMainFilename(mainFilename, inputDir, normalizeComponentName);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
exports.updateMiniProgramComponentsByScriptFilename = updateMiniProgramComponentsByScriptFilename;
|
|
70
|
-
function updateMiniProgramComponentsByTemplateFilename(templateFilename, inputDir) {
|
|
70
|
+
function updateMiniProgramComponentsByTemplateFilename(templateFilename, inputDir, normalizeComponentName) {
|
|
71
71
|
const mainFilename = findMainFilenameByTemplateFilename(templateFilename);
|
|
72
72
|
if (mainFilename) {
|
|
73
|
-
updateMiniProgramComponentsByMainFilename(mainFilename, inputDir);
|
|
73
|
+
updateMiniProgramComponentsByMainFilename(mainFilename, inputDir, normalizeComponentName);
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
exports.updateMiniProgramComponentsByTemplateFilename = updateMiniProgramComponentsByTemplateFilename;
|
|
@@ -82,29 +82,29 @@ function findMainFilenameByTemplateFilename(templateFilename) {
|
|
|
82
82
|
const keys = [...mainDescriptors.keys()];
|
|
83
83
|
return keys.find((key) => mainDescriptors.get(key).template === templateFilename);
|
|
84
84
|
}
|
|
85
|
-
async function updateMiniProgramGlobalComponents(filename, ast, { inputDir, resolve, }) {
|
|
85
|
+
async function updateMiniProgramGlobalComponents(filename, ast, { inputDir, resolve, normalizeComponentName, }) {
|
|
86
86
|
const { bindingComponents, imports } = await parseGlobalDescriptor(filename, ast, resolve);
|
|
87
|
-
(0, jsonFile_1.addMiniProgramUsingComponents)('app', createUsingComponents(bindingComponents, imports, inputDir));
|
|
87
|
+
(0, jsonFile_1.addMiniProgramUsingComponents)('app', createUsingComponents(bindingComponents, imports, inputDir, normalizeComponentName));
|
|
88
88
|
return {
|
|
89
89
|
imports,
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
92
|
exports.updateMiniProgramGlobalComponents = updateMiniProgramGlobalComponents;
|
|
93
|
-
function createUsingComponents(bindingComponents, imports, inputDir) {
|
|
93
|
+
function createUsingComponents(bindingComponents, imports, inputDir, normalizeComponentName) {
|
|
94
94
|
const usingComponents = {};
|
|
95
95
|
imports.forEach(({ source: { value }, specifiers: [specifier] }) => {
|
|
96
96
|
const { name } = specifier.local;
|
|
97
97
|
if (!bindingComponents[name]) {
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
|
-
const componentName = (0, shared_1.hyphenate)(bindingComponents[name].tag);
|
|
100
|
+
const componentName = normalizeComponentName((0, shared_1.hyphenate)(bindingComponents[name].tag));
|
|
101
101
|
if (!usingComponents[componentName]) {
|
|
102
102
|
usingComponents[componentName] = (0, uni_shared_1.addLeadingSlash)((0, utils_1.removeExt)((0, utils_1.normalizeMiniProgramFilename)(value, inputDir)));
|
|
103
103
|
}
|
|
104
104
|
});
|
|
105
105
|
return usingComponents;
|
|
106
106
|
}
|
|
107
|
-
function updateMiniProgramComponentsByMainFilename(mainFilename, inputDir) {
|
|
107
|
+
function updateMiniProgramComponentsByMainFilename(mainFilename, inputDir, normalizeComponentName) {
|
|
108
108
|
const mainDescriptor = mainDescriptors.get(mainFilename);
|
|
109
109
|
if (!mainDescriptor) {
|
|
110
110
|
return;
|
|
@@ -119,7 +119,7 @@ function updateMiniProgramComponentsByMainFilename(mainFilename, inputDir) {
|
|
|
119
119
|
}
|
|
120
120
|
const bindingComponents = parseBindingComponents(templateDescriptor.bindingComponents, scriptDescriptor.bindingComponents);
|
|
121
121
|
const imports = parseImports(mainDescriptor.imports, scriptDescriptor.imports, templateDescriptor.imports);
|
|
122
|
-
(0, jsonFile_1.addMiniProgramUsingComponents)((0, utils_1.removeExt)((0, utils_1.normalizeMiniProgramFilename)(mainFilename, inputDir)), createUsingComponents(bindingComponents, imports, inputDir));
|
|
122
|
+
(0, jsonFile_1.addMiniProgramUsingComponents)((0, utils_1.removeExt)((0, utils_1.normalizeMiniProgramFilename)(mainFilename, inputDir)), createUsingComponents(bindingComponents, imports, inputDir, normalizeComponentName));
|
|
123
123
|
}
|
|
124
124
|
exports.updateMiniProgramComponentsByMainFilename = updateMiniProgramComponentsByMainFilename;
|
|
125
125
|
function findBindingComponent(tag, bindingComponents) {
|
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-3040720220422002",
|
|
4
4
|
"description": "@dcloudio/uni-cli-shared",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@babel/core": "^7.17.9",
|
|
22
22
|
"@babel/parser": "^7.17.9",
|
|
23
23
|
"@babel/types": "^7.17.0",
|
|
24
|
-
"@dcloudio/uni-i18n": "3.0.0-alpha-
|
|
25
|
-
"@dcloudio/uni-shared": "3.0.0-alpha-
|
|
24
|
+
"@dcloudio/uni-i18n": "3.0.0-alpha-3040720220422002",
|
|
25
|
+
"@dcloudio/uni-shared": "3.0.0-alpha-3040720220422002",
|
|
26
26
|
"@intlify/core-base": "9.1.9",
|
|
27
27
|
"@intlify/shared": "9.1.9",
|
|
28
28
|
"@intlify/vue-devtools": "9.1.9",
|