@dcloudio/uni-stat 0.0.1-nvue3.3030820220125001

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.
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ var debug = require('debug');
4
+ var uniCliShared = require('@dcloudio/uni-cli-shared');
5
+
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
+ let isNVue = false;
14
+ return {
15
+ name: 'uni:stat',
16
+ enforce: 'pre',
17
+ config(config, env) {
18
+ if (isSsr(env.command, config)) {
19
+ return;
20
+ }
21
+ isNVue = config.nvue;
22
+ const inputDir = process.env.UNI_INPUT_DIR;
23
+ const platform = process.env.UNI_PLATFORM;
24
+ isEnable = uniCliShared.getUniStatistics(inputDir, platform).enable === true;
25
+ if (process.env.NODE_ENV === 'production') {
26
+ const manifestJson = uniCliShared.parseManifestJsonOnce(inputDir);
27
+ if (!manifestJson.appid) {
28
+ console.log();
29
+ console.warn(uniCliShared.M['stat.warn.appid']);
30
+ console.log();
31
+ isEnable = false;
32
+ }
33
+ }
34
+ const titlesJson = Object.create(null);
35
+ if (isEnable) {
36
+ uniCliShared.parsePagesJson(inputDir, platform).pages.forEach((page) => {
37
+ var _a;
38
+ const style = page.style || {};
39
+ const titleText =
40
+ // MP
41
+ style.navigationBarTitleText ||
42
+ (
43
+ // H5 || App
44
+ (_a = style.navigationBar) === null || _a === void 0 ? void 0 : _a.titleText) ||
45
+ '';
46
+ if (titleText) {
47
+ titlesJson[page.path] = titleText;
48
+ }
49
+ });
50
+ }
51
+ debug__default["default"]('uni:stat')('isEnable', isEnable);
52
+ process.env.UNI_STAT_TITLE_JSON = JSON.stringify(titlesJson);
53
+ return {
54
+ define: {
55
+ 'process.env.UNI_STAT_TITLE_JSON': process.env.UNI_STAT_TITLE_JSON,
56
+ },
57
+ };
58
+ },
59
+ transform(code, id) {
60
+ if (isEnable && !isNVue && opts.filter(id)) {
61
+ return {
62
+ code: code + `;import '@dcloudio/uni-stat';`,
63
+ map: null,
64
+ };
65
+ }
66
+ },
67
+ };
68
+ }),
69
+ ];
70
+ function isSsr(command, config) {
71
+ if (command === 'serve') {
72
+ return !!(config.server && config.server.middlewareMode);
73
+ }
74
+ if (command === 'build') {
75
+ return !!(config.build && config.build.ssr);
76
+ }
77
+ return false;
78
+ }
79
+
80
+ module.exports = index;
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@dcloudio/uni-stat",
3
+ "version": "0.0.1-nvue3.3030820220125001",
4
+ "description": "@dcloudio/uni-stat",
5
+ "main": "dist/uni-stat.es.js",
6
+ "module": "dist/uni-stat.es.js",
7
+ "files": [
8
+ "dist",
9
+ "lib"
10
+ ],
11
+ "sideEffects": false,
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/dcloudio/uni-app.git",
15
+ "directory": "packages/uni-stat"
16
+ },
17
+ "license": "Apache-2.0",
18
+ "bugs": {
19
+ "url": "https://github.com/dcloudio/uni-app/issues"
20
+ },
21
+ "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
22
+ "dependencies": {
23
+ "@dcloudio/uni-cli-shared": "0.0.1-nvue3.3030820220125001",
24
+ "debug": "^4.3.2"
25
+ },
26
+ "devDependencies": {
27
+ "@types/debug": "^4.1.7"
28
+ }
29
+ }