@dcloudio/uni-stat 3.0.0-alpha-3021320211109003 → 3.0.0-alpha-3021320211117002
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/uni-stat.cjs.js +1 -1
- package/dist/uni-stat.es.js +1 -1
- package/lib/uni.plugin.js +67 -66
- package/package.json +9 -2
package/dist/uni-stat.cjs.js
CHANGED
package/dist/uni-stat.es.js
CHANGED
package/lib/uni.plugin.js
CHANGED
|
@@ -1,69 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
const {
|
|
3
|
-
M,
|
|
4
|
-
defineUniMainJsPlugin,
|
|
5
|
-
getUniStatistics,
|
|
6
|
-
parseManifestJsonOnce,
|
|
7
|
-
parsePagesJsonOnce,
|
|
8
|
-
} = require('@dcloudio/uni-cli-shared')
|
|
1
|
+
'use strict';
|
|
9
2
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
let isEnable = false
|
|
13
|
-
return {
|
|
14
|
-
name: 'vite:uni-stat',
|
|
15
|
-
enforce: 'pre',
|
|
16
|
-
config(config, env) {
|
|
17
|
-
if (isSsr(env.command, config)) {
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
const inputDir = process.env.UNI_INPUT_DIR
|
|
21
|
-
const platform = process.env.UNI_PLATFORM
|
|
22
|
-
isEnable = getUniStatistics(inputDir, platform).enable === true
|
|
23
|
-
if (process.env.NODE_ENV === 'production') {
|
|
24
|
-
const manifestJson = parseManifestJsonOnce(inputDir)
|
|
25
|
-
if (!manifestJson.appid) {
|
|
26
|
-
console.log()
|
|
27
|
-
console.warn(M['stat.warn.appid'])
|
|
28
|
-
console.log()
|
|
29
|
-
isEnable = false
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const titlesJson = Object.create(null)
|
|
33
|
-
if (isEnable) {
|
|
34
|
-
parsePagesJsonOnce(inputDir, platform).pages.forEach((page) => {
|
|
35
|
-
const titleText = page.style.navigationBar.titleText || ''
|
|
36
|
-
if (titleText) {
|
|
37
|
-
titlesJson[page.path] = titleText
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
debug('vite:uni:stat')('isEnable', isEnable)
|
|
42
|
-
process.env.UNI_STAT_TITLE_JSON = JSON.stringify(titlesJson)
|
|
43
|
-
return {
|
|
44
|
-
define: {
|
|
45
|
-
'process.env.UNI_STAT_TITLE_JSON': process.env.UNI_STAT_TITLE_JSON,
|
|
46
|
-
},
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
transform(code, id) {
|
|
50
|
-
if (isEnable && opts.filter(id)) {
|
|
51
|
-
return {
|
|
52
|
-
code: code + `;import '@dcloudio/uni-stat';`,
|
|
53
|
-
map: null,
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
}
|
|
58
|
-
}),
|
|
59
|
-
]
|
|
3
|
+
var debug = require('debug');
|
|
4
|
+
var uniCliShared = require('@dcloudio/uni-cli-shared');
|
|
60
5
|
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
6
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
7
|
+
|
|
8
|
+
var debug__default = /*#__PURE__*/_interopDefaultLegacy(debug);
|
|
9
|
+
|
|
10
|
+
var index = [
|
|
11
|
+
uniCliShared.defineUniMainJsPlugin((opts) => {
|
|
12
|
+
let isEnable = false;
|
|
13
|
+
return {
|
|
14
|
+
name: 'vite:uni-stat',
|
|
15
|
+
enforce: 'pre',
|
|
16
|
+
config(config, env) {
|
|
17
|
+
if (isSsr(env.command, config)) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const inputDir = process.env.UNI_INPUT_DIR;
|
|
21
|
+
const platform = process.env.UNI_PLATFORM;
|
|
22
|
+
isEnable = uniCliShared.getUniStatistics(inputDir, platform).enable === true;
|
|
23
|
+
if (process.env.NODE_ENV === 'production') {
|
|
24
|
+
const manifestJson = uniCliShared.parseManifestJsonOnce(inputDir);
|
|
25
|
+
if (!manifestJson.appid) {
|
|
26
|
+
console.log();
|
|
27
|
+
console.warn(uniCliShared.M['stat.warn.appid']);
|
|
28
|
+
console.log();
|
|
29
|
+
isEnable = false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const titlesJson = Object.create(null);
|
|
33
|
+
if (isEnable) {
|
|
34
|
+
uniCliShared.parsePagesJsonOnce(inputDir, platform).pages.forEach((page) => {
|
|
35
|
+
const titleText = page.style.navigationBar.titleText || '';
|
|
36
|
+
if (titleText) {
|
|
37
|
+
titlesJson[page.path] = titleText;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
debug__default["default"]('vite:uni:stat')('isEnable', isEnable);
|
|
42
|
+
process.env.UNI_STAT_TITLE_JSON = JSON.stringify(titlesJson);
|
|
43
|
+
return {
|
|
44
|
+
define: {
|
|
45
|
+
'process.env.UNI_STAT_TITLE_JSON': process.env.UNI_STAT_TITLE_JSON,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
transform(code, id) {
|
|
50
|
+
if (isEnable && opts.filter(id)) {
|
|
51
|
+
return {
|
|
52
|
+
code: code + `;import '@dcloudio/uni-stat';`,
|
|
53
|
+
map: null,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}),
|
|
59
|
+
];
|
|
60
|
+
function isSsr(command, config) {
|
|
61
|
+
if (command === 'serve') {
|
|
62
|
+
return !!(config.server && config.server.middlewareMode);
|
|
63
|
+
}
|
|
64
|
+
if (command === 'build') {
|
|
65
|
+
return !!(config.build && config.build.ssr);
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
69
68
|
}
|
|
69
|
+
|
|
70
|
+
module.exports = index;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/uni-stat",
|
|
3
|
-
"version": "3.0.0-alpha-
|
|
3
|
+
"version": "3.0.0-alpha-3021320211117002",
|
|
4
4
|
"description": "@dcloudio/uni-stat",
|
|
5
5
|
"main": "dist/uni-stat.es.js",
|
|
6
6
|
"module": "dist/uni-stat.es.js",
|
|
@@ -18,5 +18,12 @@
|
|
|
18
18
|
"bugs": {
|
|
19
19
|
"url": "https://github.com/dcloudio/uni-app/issues"
|
|
20
20
|
},
|
|
21
|
-
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da"
|
|
21
|
+
"gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@dcloudio/uni-cli-shared": "3.0.0-alpha-3021320211117002",
|
|
24
|
+
"debug": "^4.3.2"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/debug": "^4.1.7"
|
|
28
|
+
}
|
|
22
29
|
}
|