@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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "3.0.0-alpha-3021320211109003";
3
+ var version = "3.0.0-alpha-3021320211117002";
4
4
 
5
5
  const STAT_VERSION = version;
6
6
  const STAT_URL = 'https://tongji.dcloud.io/uni/stat';
@@ -1,4 +1,4 @@
1
- var version = "3.0.0-alpha-3021320211109003";
1
+ var version = "3.0.0-alpha-3021320211117002";
2
2
 
3
3
  const STAT_VERSION = version;
4
4
  const STAT_URL = 'https://tongji.dcloud.io/uni/stat';
package/lib/uni.plugin.js CHANGED
@@ -1,69 +1,70 @@
1
- const debug = require('debug')
2
- const {
3
- M,
4
- defineUniMainJsPlugin,
5
- getUniStatistics,
6
- parseManifestJsonOnce,
7
- parsePagesJsonOnce,
8
- } = require('@dcloudio/uni-cli-shared')
1
+ 'use strict';
9
2
 
10
- module.exports = [
11
- 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 = 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 isSsr(command, config) {
62
- if (command === 'serve') {
63
- return !!(config.server && config.server.middlewareMode)
64
- }
65
- if (command === 'build') {
66
- return !!(config.build && config.build.ssr)
67
- }
68
- return false
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-3021320211109003",
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
  }