@dcloudio/uni-cli-shared 3.0.0-alpha-5000320260310001 → 3.0.0-alpha-5000420260319001

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.
@@ -9,86 +9,19 @@ const json_1 = require("../../json");
9
9
  const preprocess_1 = require("../../preprocess");
10
10
  const utils_1 = require("../utils");
11
11
  function uniJsonPlugin() {
12
- const UTS_CAST_ARRAY_MARKER = '/*__UTS_CAST_UTSJSON_ARRAY__*/';
13
- const UTS_CAST_OBJECT_MARKER = '/*__UTS_CAST_UTSJSON_OBJECT__*/';
14
- const IS_UNI_X_ANDROID = process.env.UNI_APP_X === 'true' &&
15
- process.env.UNI_UTS_PLATFORM === 'app-android';
16
12
  return {
17
13
  name: 'uni:json',
18
14
  enforce: 'pre',
19
- generateBundle(options, bundle) {
20
- if (IS_UNI_X_ANDROID) {
21
- for (const [fileName, file] of Object.entries(bundle)) {
22
- if (fileName.endsWith('.json.ts')) {
23
- if (file.type === 'asset' && file.source) {
24
- const source = file.source.toString();
25
- if (source.includes(UTS_CAST_ARRAY_MARKER) ||
26
- source.includes(UTS_CAST_OBJECT_MARKER)) {
27
- file.source = source
28
- .replace(new RegExp(UTS_CAST_ARRAY_MARKER.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), ' as UTSJSONObject[]')
29
- .replace(new RegExp(UTS_CAST_OBJECT_MARKER.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), ' as UTSJSONObject');
30
- }
31
- }
32
- }
33
- }
34
- }
35
- },
36
15
  transform(code, id) {
37
16
  // 如果已经被其他插件处理过了,就不再处理,比如 commonjs 插件,ICAPRegistrar.json?commonjs-external
38
17
  if (id.startsWith('\0')) {
39
18
  return;
40
19
  }
41
- const { filename } = (0, utils_1.parseVueRequest)(id);
42
- if (path_1.default.extname(filename) !== '.json') {
20
+ if (path_1.default.extname((0, utils_1.parseVueRequest)(id).filename) !== '.json') {
43
21
  return;
44
22
  }
45
- let codeObj = (0, json_1.parseJson)((0, preprocess_1.preJson)(code, id), false, id);
46
- let codeJson = '';
47
- if (IS_UNI_X_ANDROID) {
48
- if (Array.isArray(codeObj)) {
49
- codeJson +=
50
- 'export default JSON.parseArray(`' +
51
- JSON.stringify(codeObj, null, 2) +
52
- '`)' +
53
- UTS_CAST_ARRAY_MARKER +
54
- ';\n';
55
- }
56
- else {
57
- codeJson +=
58
- 'let __jsonObj = JSON.parseObject(`' +
59
- JSON.stringify(codeObj, null, 2) +
60
- '`);\n';
61
- for (const key in codeObj) {
62
- if (!Object.hasOwn(codeObj, key))
63
- continue;
64
- const element = codeObj[key];
65
- if (Array.isArray(element)) {
66
- codeJson += `export const ${key} = __jsonObj?.getArray("${key}")${UTS_CAST_ARRAY_MARKER};\n`;
67
- }
68
- else if (typeof element === 'object' && element !== null) {
69
- codeJson += `export const ${key} = __jsonObj?.get("${key}")${UTS_CAST_OBJECT_MARKER};\n`;
70
- }
71
- else if (typeof element === 'string') {
72
- codeJson += `export const ${key} = __jsonObj?.getString("${key}") ?? '';\n`;
73
- }
74
- else if (typeof element === 'number') {
75
- codeJson += `export const ${key} = __jsonObj?.getNumber("${key}") ?? 0;\n`;
76
- }
77
- else if (typeof element === 'boolean') {
78
- codeJson += `export const ${key} = __jsonObj?.getBoolean("${key}") ?? false;\n`;
79
- }
80
- else {
81
- codeJson += `export const ${key} = __jsonObj?.get("${key}")${UTS_CAST_OBJECT_MARKER};\n`;
82
- }
83
- }
84
- codeJson += `export default __jsonObj;`;
85
- }
86
- }
87
- else {
88
- codeJson = JSON.stringify(codeObj, null, 2);
89
- }
90
23
  return {
91
- code: codeJson,
24
+ code: JSON.stringify((0, json_1.parseJson)((0, preprocess_1.preJson)(code, id), false, id), null, 2),
92
25
  map: {
93
26
  mappings: '',
94
27
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/uni-cli-shared",
3
- "version": "3.0.0-alpha-5000320260310001",
3
+ "version": "3.0.0-alpha-5000420260319001",
4
4
  "description": "@dcloudio/uni-cli-shared",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -69,9 +69,9 @@
69
69
  "unimport": "4.1.1",
70
70
  "unplugin-auto-import": "19.1.0",
71
71
  "xregexp": "5.1.2",
72
- "@dcloudio/uni-i18n": "3.0.0-alpha-5000320260310001",
73
- "@dcloudio/uni-nvue-styler": "3.0.0-alpha-5000320260310001",
74
- "@dcloudio/uni-shared": "3.0.0-alpha-5000320260310001"
72
+ "@dcloudio/uni-nvue-styler": "3.0.0-alpha-5000420260319001",
73
+ "@dcloudio/uni-shared": "3.0.0-alpha-5000420260319001",
74
+ "@dcloudio/uni-i18n": "3.0.0-alpha-5000420260319001"
75
75
  },
76
76
  "gitHead": "33e807d66e1fe47e2ee08ad9c59247e37b8884da",
77
77
  "devDependencies": {
@@ -91,6 +91,6 @@
91
91
  "code-frame": "link:@types/@babel/code-frame",
92
92
  "postcss": "8.4.45",
93
93
  "vue": "3.4.21",
94
- "@dcloudio/uni-uts-v1": "3.0.0-alpha-5000320260310001"
94
+ "@dcloudio/uni-uts-v1": "3.0.0-alpha-5000420260319001"
95
95
  }
96
96
  }