export-table-pulgin-csharp 1.1.83 → 1.1.85

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 +1 @@
1
- {"version":3,"file":"ExportCSPlugin.d.ts","sourceRoot":"","sources":["../src/ExportCSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAA0B,MAAM,kBAAkB,CAAA;AAK1H,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA6UpE;AAED,qBAAa,YAAa,SAAQ,UAAU;IAC3C,IAAI,SAAW;IACf,IAAI,EAAE,MAAM,EAAE,CAAS;IAEvB,WAAW,CAAC,KAAK,EAAE,iBAAiB;CAOpC"}
1
+ {"version":3,"file":"ExportCSPlugin.d.ts","sourceRoot":"","sources":["../src/ExportCSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAA0B,MAAM,kBAAkB,CAAA;AAK1H,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAqVpE;AAED,qBAAa,YAAa,SAAQ,UAAU;IAC3C,IAAI,SAAW;IACf,IAAI,EAAE,MAAM,EAAE,CAAS;IAEvB,WAAW,CAAC,KAAK,EAAE,iBAAiB;CAOpC"}
@@ -28,9 +28,8 @@ const export_table_lib_1 = require("export-table-lib");
28
28
  const fs = __importStar(require("fs-extra"));
29
29
  var isSkipExportDefaults0 = process.argv.findIndex(v => v == "--SkipDefaults") >= 0;
30
30
  function export_stuff(paras) {
31
- var _a;
32
31
  let { datas, fields, inject, name, objects, packagename, tables, xxtea, exportNamespace, moreOptions, } = paras;
33
- let isSkipExportDefaults = (_a = !!moreOptions.SkipDefaults) !== null && _a !== void 0 ? _a : false;
32
+ let isSkipExportDefaults = !!moreOptions?.SkipDefaults ?? false;
34
33
  if (isSkipExportDefaults0) {
35
34
  isSkipExportDefaults = true;
36
35
  }
@@ -229,7 +228,13 @@ ${(0, export_table_lib_1.foreach)(fields, f => `
229
228
  /// <summary>
230
229
  ${(0, export_table_lib_1.foreach)(getDescripts(f), line => ` /// ${line}`)}
231
230
  /// </summary>
232
- public ${getFieldType(f)} ${convMemberName(f.name)};`)}
231
+ public ${getFieldType(f)} ${convMemberName(f.name)};
232
+
233
+ ${(0, export_table_lib_1.iff)(f.rawType == "@(int,string)[]", () => `
234
+ /// <summary>
235
+ ${(0, export_table_lib_1.foreach)(getDescripts(f), line => ` /// ${line}`)}
236
+ /// </summary>
237
+ public (int,string)[] ${convMemberName(f.name)}Obj;`)}`)}
233
238
 
234
239
  ${(0, export_table_lib_1.cmm)( /**生成get字段 */)}
235
240
  #region get字段
@@ -366,11 +371,8 @@ ${(0, export_table_lib_1.iff)(f.type == "fk[]", () => `
366
371
  }
367
372
  exports.export_stuff = export_stuff;
368
373
  class ExportPlugin extends export_table_lib_1.PluginBase {
369
- constructor() {
370
- super(...arguments);
371
- this.name = "csharp";
372
- this.tags = ["cs"];
373
- }
374
+ name = "csharp";
375
+ tags = ["cs"];
374
376
  handleSheet(paras) {
375
377
  let content = export_stuff(paras);
376
378
  if (content != null) {
@@ -1 +1 @@
1
- {"version":3,"file":"ExportUnityCSJsonPlugin.d.ts","sourceRoot":"","sources":["../src/ExportUnityCSJsonPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAE,iBAAiB,EAAqC,MAAM,kBAAkB,CAAA;AAMxJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA+CnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAiFzE;AAED,qBAAa,iBAAkB,SAAQ,UAAU;IAChD,IAAI,SAAU;IACd,IAAI,EAAE,MAAM,EAAE,CAAY;IAE1B,WAAW,CAAC,KAAK,EAAE,iBAAiB;IAmBpC,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;CAmC3C"}
1
+ {"version":3,"file":"ExportUnityCSJsonPlugin.d.ts","sourceRoot":"","sources":["../src/ExportUnityCSJsonPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAE,iBAAiB,EAAqC,MAAM,kBAAkB,CAAA;AAMxJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA8EnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAuFzE;AAED,qBAAa,iBAAkB,SAAQ,UAAU;IAChD,IAAI,SAAU;IACd,IAAI,EAAE,MAAM,EAAE,CAAY;IAE1B,WAAW,CAAC,KAAK,EAAE,iBAAiB;IAmBpC,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;CAmC3C"}
@@ -39,10 +39,41 @@ function exportUJson(paras) {
39
39
  var fullName = `${table.workbookName}-${name}`;
40
40
  let jsonString = JSON.stringify(objects.map(obj => {
41
41
  var newObj = Object.create(null);
42
- Object.keys(obj).forEach(key => {
42
+ for (let f of fields) {
43
+ let key = f.name;
43
44
  var newKey = convMemberName(key);
44
45
  newObj[newKey] = obj[key];
45
- });
46
+ if (f.rawType == "@(int,string)[]") {
47
+ // [{"Item1":99,"Item2":"klwjefl"}]
48
+ let content = obj[key];
49
+ let index = 0;
50
+ let index2 = -1;
51
+ let objs = [];
52
+ while (0 <= index && index < content.length) {
53
+ index2 = content.indexOf("|", index);
54
+ let numStr = content.substring(index, index2);
55
+ index = content.indexOf(";;", index2);
56
+ let posEnd = index;
57
+ if (index == -1) {
58
+ posEnd = content.length;
59
+ }
60
+ else {
61
+ index += 2;
62
+ }
63
+ let ssStr = content.substring(index2 + 1, posEnd);
64
+ // console.log(`parseinfo: ${index2}, ${index}, ${numStr}, ${ssStr}`)
65
+ objs.push({
66
+ Item1: parseFloat(numStr),
67
+ Item2: ssStr,
68
+ });
69
+ }
70
+ newObj[newKey + "Obj"] = objs;
71
+ }
72
+ }
73
+ // Object.keys(obj).forEach(key => {
74
+ // var newKey = convMemberName(key);
75
+ // newObj[newKey] = obj[key];
76
+ // })
46
77
  return newObj;
47
78
  }));
48
79
  return jsonString;
@@ -68,6 +99,11 @@ function exportUJson(paras) {
68
99
  exports.exportUJson = exportUJson;
69
100
  function exportUJsonLoader(paras) {
70
101
  let { datas, fields, name, objects, table, exportNamespace, } = paras;
102
+ let jsonToolNamespaceIndex = process.argv.findIndex(v => v == "--JsonToolNamespace");
103
+ let jsonToolNamespace = "lang.json";
104
+ if (jsonToolNamespaceIndex >= 0 && process.argv.length > jsonToolNamespaceIndex + 1) {
105
+ jsonToolNamespace = process.argv[jsonToolNamespaceIndex + 1];
106
+ }
71
107
  let RowClass = firstLetterUpper(name);
72
108
  var fullName = `${table.workbookName}-${name}`;
73
109
  // !!!必须开头没有空格
@@ -75,7 +111,7 @@ function exportUJsonLoader(paras) {
75
111
  using UnityEngine.AddressableAssets;
76
112
  using System.Threading.Tasks;
77
113
  using UnityEngine;
78
- using lang.json;
114
+ using ${jsonToolNamespace};
79
115
 
80
116
  namespace ${exportNamespace}
81
117
  {
@@ -141,11 +177,8 @@ namespace ${exportNamespace}
141
177
  }
142
178
  exports.exportUJsonLoader = exportUJsonLoader;
143
179
  class ExportUJsonPlugin extends export_table_lib_1.PluginBase {
144
- constructor() {
145
- super(...arguments);
146
- this.name = "ujson";
147
- this.tags = ["ujson"];
148
- }
180
+ name = "ujson";
181
+ tags = ["ujson"];
149
182
  handleSheet(paras) {
150
183
  var fullName = `${paras.table.workbookName}-${paras.name}`;
151
184
  {
@@ -165,9 +198,8 @@ class ExportUJsonPlugin extends export_table_lib_1.PluginBase {
165
198
  }
166
199
  }
167
200
  handleBatch(paras) {
168
- var _a;
169
201
  let { moreOptions, tables, exportNamespace, } = paras;
170
- let isSkipIndexLoader = (_a = !!moreOptions.SkipIndexLoader) !== null && _a !== void 0 ? _a : false;
202
+ let isSkipIndexLoader = !!moreOptions.SkipIndexLoader ?? false;
171
203
  if (isSkipIndexLoader0) {
172
204
  isSkipIndexLoader = true;
173
205
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "export-table-pulgin-csharp",
3
- "version": "1.1.83",
3
+ "version": "1.1.85",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -13,7 +13,7 @@
13
13
  "license": "ISC",
14
14
  "dependencies": {
15
15
  "@types/node": "^17.0.18",
16
- "export-table-lib": "^1.0.55",
16
+ "export-table-lib": "^1.0.56",
17
17
  "fs": "^0.0.1-security",
18
18
  "fs-extra": "^10.0.0",
19
19
  "fse": "^4.0.1"
@@ -18,7 +18,7 @@ export function export_stuff(paras: HandleSheetParams): string | null {
18
18
  moreOptions,
19
19
  } = paras;
20
20
 
21
- let isSkipExportDefaults = !!moreOptions.SkipDefaults ?? false
21
+ let isSkipExportDefaults = !!moreOptions?.SkipDefaults ?? false
22
22
  if (isSkipExportDefaults0) {
23
23
  isSkipExportDefaults = true
24
24
  }
@@ -201,8 +201,16 @@ ${foreach(getDescripts(f), line =>
201
201
  ` /// ${line}`
202
202
  )}
203
203
  /// </summary>
204
- public ${getFieldType(f)} ${convMemberName(f.name)};`
205
- )}
204
+ public ${getFieldType(f)} ${convMemberName(f.name)};
205
+
206
+ ${iff(f.rawType == "@(int,string)[]", () => `
207
+ /// <summary>
208
+ ${foreach(getDescripts(f), line =>
209
+ ` /// ${line}`
210
+ )}
211
+ /// </summary>
212
+ public (int,string)[] ${convMemberName(f.name)}Obj;`)}`
213
+ )}
206
214
 
207
215
  ${cmm(/**生成get字段 */)}
208
216
  #region get字段
@@ -24,10 +24,41 @@ export function exportUJson(paras: HandleSheetParams): string | null {
24
24
  var fullName = `${table.workbookName}-${name}`
25
25
  let jsonString = JSON.stringify(objects.map(obj => {
26
26
  var newObj = Object.create(null);
27
- Object.keys(obj).forEach(key => {
27
+ for (let f of fields) {
28
+ let key = f.name
28
29
  var newKey = convMemberName(key);
29
30
  newObj[newKey] = obj[key];
30
- })
31
+
32
+ if (f.rawType == "@(int,string)[]") {
33
+ // [{"Item1":99,"Item2":"klwjefl"}]
34
+ let content = obj[key] as string;
35
+ let index = 0;
36
+ let index2 = -1;
37
+ let objs: object[] = []
38
+ while (0 <= index && index < content.length) {
39
+ index2 = content.indexOf("|", index)
40
+ let numStr = content.substring(index, index2)
41
+ index = content.indexOf(";;", index2)
42
+ let posEnd = index
43
+ if (index == -1) {
44
+ posEnd = content.length
45
+ } else {
46
+ index += 2
47
+ }
48
+ let ssStr = content.substring(index2 + 1, posEnd)
49
+ // console.log(`parseinfo: ${index2}, ${index}, ${numStr}, ${ssStr}`)
50
+ objs.push({
51
+ Item1: parseFloat(numStr),
52
+ Item2: ssStr,
53
+ })
54
+ }
55
+ newObj[newKey + "Obj"] = objs
56
+ }
57
+ }
58
+ // Object.keys(obj).forEach(key => {
59
+ // var newKey = convMemberName(key);
60
+ // newObj[newKey] = obj[key];
61
+ // })
31
62
  return newObj
32
63
  }));
33
64
 
@@ -64,6 +95,12 @@ export function exportUJsonLoader(paras: HandleSheetParams): string | null {
64
95
  exportNamespace,
65
96
  } = paras;
66
97
 
98
+ let jsonToolNamespaceIndex = process.argv.findIndex(v => v == "--JsonToolNamespace")
99
+ let jsonToolNamespace = "lang.json";
100
+ if(jsonToolNamespaceIndex>=0 && process.argv.length>jsonToolNamespaceIndex+1){
101
+ jsonToolNamespace = process.argv[jsonToolNamespaceIndex+1]
102
+ }
103
+
67
104
  let RowClass = firstLetterUpper(name)
68
105
  var fullName = `${table.workbookName}-${name}`
69
106
  // !!!必须开头没有空格
@@ -71,7 +108,7 @@ export function exportUJsonLoader(paras: HandleSheetParams): string | null {
71
108
  using UnityEngine.AddressableAssets;
72
109
  using System.Threading.Tasks;
73
110
  using UnityEngine;
74
- using lang.json;
111
+ using ${jsonToolNamespace};
75
112
 
76
113
  namespace ${exportNamespace}
77
114
  {
package/tsconfig.json CHANGED
@@ -11,7 +11,7 @@
11
11
  // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
12
 
13
13
  /* Language and Environment */
14
- "target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
14
+ "target": "ES2022", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
15
  // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
16
  // "jsx": "preserve", /* Specify what JSX code is generated. */
17
17
  // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */