export-table-pulgin-csharp 1.1.147 → 1.1.149

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,16 +1,31 @@
1
1
  import { Field, FieldType, DataTable } from "export-table-lib";
2
2
  export declare function TryConvValue(value: any, t: FieldType, f: Field): any;
3
3
  export declare function ConvValue(value: any, t: FieldType, f: Field): any;
4
+ export type ValueTuple = {
5
+ Item1?: any;
6
+ Item2?: any;
7
+ };
8
+ export declare function genTupleArrayValue(f: Field, content: string): {
9
+ isArray: boolean;
10
+ objs: ValueTuple[];
11
+ } | undefined;
12
+ export declare function ToNewTupleStatement(obj: ValueTuple): string;
4
13
  export declare function ConvValue2Literal(value: any, t: FieldType, f: Field): string;
5
14
  export declare let isSkipExportDefaults0: boolean;
6
15
  export declare let firstLetterUpper: (str: string) => string;
7
16
  export declare let firstLetterLower: (str: string) => string;
8
17
  export declare let convMemberName: (str: string) => string;
9
18
  export declare let convVarName: (str: string) => string;
19
+ export declare let getFieldElementType: (f: Field) => string;
10
20
  export declare let getFieldType: (f: Field) => FieldType | "Dictionary<string,string>" | "List<Dictionary<string,string>>" | "double" | "double[]";
21
+ export declare let isTypeArray: (f: Field) => boolean;
22
+ export declare let getFieldAnnotation: (f: Field) => string;
23
+ export declare let getCustomFieldTypeAnnotation: (f: Field) => string;
11
24
  export declare let getFkFieldType: (tables: DataTable[], field: Field) => FieldType;
12
25
  export declare const genValue: (value: any, f: Field) => string;
13
26
  export declare const getTitle: (v: Field) => string;
14
27
  export declare const getDescripts: (v: Field) => string[];
15
- export declare const convTupleArrayType: (f: Field) => string;
28
+ export declare const convTupleArrayType: (f: Field) => Field | undefined;
29
+ export declare const convTupleArrayTypeDefine: (f: Field) => string;
30
+ export declare function GetUsingJsonToolNamespace(): string;
16
31
  //# sourceMappingURL=CSParseTool.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CSParseTool.d.ts","sourceRoot":"","sources":["../src/CSParseTool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C,CAAA;AAED,eAAO,MAAM,QAAQ,MAAO,KAAK,WAEhC,CAAA;AAED,eAAO,MAAM,YAAY,MAAO,KAAK,aAEpC,CAAA;AAED,eAAO,MAAM,kBAAkB,MAAO,KAAK,sBAc1C,CAAA;AAED,eAAO,MAAM,wBAAwB,MAAO,KAAK,WAYhD,CAAA;AAED,wBAAgB,yBAAyB,WAQxC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convTupleArrayType = exports.getDescripts = exports.getTitle = exports.genValue = exports.getFkFieldType = exports.getFieldType = exports.convVarName = exports.convMemberName = exports.firstLetterLower = exports.firstLetterUpper = exports.isSkipExportDefaults0 = exports.ConvValue2Literal = exports.ConvValue = exports.TryConvValue = void 0;
3
+ exports.GetUsingJsonToolNamespace = exports.convTupleArrayTypeDefine = exports.convTupleArrayType = exports.getDescripts = exports.getTitle = exports.genValue = exports.getFkFieldType = exports.getCustomFieldTypeAnnotation = exports.getFieldAnnotation = exports.isTypeArray = exports.getFieldType = exports.getFieldElementType = exports.convVarName = exports.convMemberName = exports.firstLetterLower = exports.firstLetterUpper = exports.isSkipExportDefaults0 = exports.ConvValue2Literal = exports.ToNewTupleStatement = exports.genTupleArrayValue = exports.ConvValue = exports.TryConvValue = void 0;
4
+ const export_table_lib_1 = require("export-table-lib");
4
5
  function TryConvValue(value, t, f) {
5
6
  try {
6
7
  return ConvValue(value, t, f);
@@ -75,7 +76,61 @@ function ConvValue(value, t, f) {
75
76
  throw new TypeError(`invalid unkown type ${f.name}:<${f.rawType} => ${f.type} << ${t}>`);
76
77
  }
77
78
  exports.ConvValue = ConvValue;
79
+ function genTupleArrayValue(f, content) {
80
+ var line = f.rawType.replaceAll(/(?<=[^\w])(boolean)(?=[^\w]|$)/g, "bool");
81
+ let m = line.match(/\@\((\w+),(\w+)\)(\[\])?/);
82
+ if (m != null) {
83
+ // [{"Item1":99,"Item2":"klwjefl"}]
84
+ let index = 0;
85
+ let objs = [];
86
+ let isArray = false;
87
+ // console.log(`input: ${content}`)
88
+ while (0 <= index && index < content.length) {
89
+ let segIndex = content.indexOf(";;", index);
90
+ if (segIndex == -1) {
91
+ segIndex = content.length;
92
+ }
93
+ let index2 = content.indexOf("|", index);
94
+ if (index2 == -1 || index2 >= segIndex) {
95
+ if (content.length > 0) {
96
+ console.error(`表格格式错误,缺少部分数据,将用默认值填充<${f.name}>: ${content}`);
97
+ }
98
+ index2 = segIndex;
99
+ }
100
+ let numStr = content.substring(index, index2);
101
+ let t1 = m[1];
102
+ let v1 = index == index2 ? undefined : TryConvValue(numStr, t1, f);
103
+ // console.log(`parseinfo1: ${content}, ${index}, ${index2}, ${numStr}, ${t1}, ${v1}`)
104
+ let index3 = Math.min(index2 + 1, segIndex);
105
+ let ssStr = content.substring(index3, segIndex);
106
+ let t2 = m[2];
107
+ let v2 = index3 == segIndex ? undefined : TryConvValue(ssStr, t2, f);
108
+ // console.log(`parseinfo2: ${content}, ${index3}, ${segIndex}, ${ssStr}, ${t2}, ${v2}`)
109
+ let obj = {};
110
+ if (v1 != undefined) {
111
+ obj.Item1 = v1;
112
+ }
113
+ if (v2 != undefined) {
114
+ obj.Item2 = v2;
115
+ }
116
+ objs.push(obj);
117
+ if (segIndex >= content.length) {
118
+ break;
119
+ }
120
+ index = segIndex + 2;
121
+ }
122
+ isArray = m[3] == "[]";
123
+ return { isArray, objs };
124
+ }
125
+ return undefined;
126
+ }
127
+ exports.genTupleArrayValue = genTupleArrayValue;
128
+ function ToNewTupleStatement(obj) {
129
+ return `new(){${(0, export_table_lib_1.iff)(obj.Item1 != null, () => `Item1=${obj.Item1},`)}${(0, export_table_lib_1.iff)(obj.Item2 != null, () => `Item2=${obj.Item2},`)}}`;
130
+ }
131
+ exports.ToNewTupleStatement = ToNewTupleStatement;
78
132
  function ConvValue2Literal(value, t, f) {
133
+ // console.log(t)
79
134
  if (t == "object") {
80
135
  //throw new Error("invalid type <object>")
81
136
  let convert = [];
@@ -134,6 +189,21 @@ function ConvValue2Literal(value, t, f) {
134
189
  let values = value;
135
190
  return `new string[]{${values.map(v => JSON.stringify(v)).join(", ")}}`;
136
191
  }
192
+ else if (t.startsWith("WritableValueTuple<")) {
193
+ let result = genTupleArrayValue(f, value);
194
+ // console.log(`result: ${value}=> ${JSON.stringify(result)}`)
195
+ if (result == null) {
196
+ throw new Error(`invalid tuple/tuple[] format: ${value}`);
197
+ }
198
+ let { isArray, objs } = result;
199
+ if (isArray) {
200
+ return `new ${f.type}{${(0, export_table_lib_1.foreach)(objs, obj => ToNewTupleStatement(obj), ",")}}`;
201
+ }
202
+ else {
203
+ let obj = objs[0] ?? {};
204
+ return ToNewTupleStatement(obj);
205
+ }
206
+ }
137
207
  else if (t == "fk") {
138
208
  return `${value}`;
139
209
  }
@@ -143,7 +213,7 @@ function ConvValue2Literal(value, t, f) {
143
213
  }
144
214
  else if (t == "any") {
145
215
  console.log(f);
146
- throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`);
216
+ throw new Error(`invalid type ${f.name}:<${f.rawType} | ${f.type} => any>`);
147
217
  }
148
218
  else if (t == "key") {
149
219
  return `${value}`;
@@ -165,6 +235,25 @@ let convMemberName = function (str) {
165
235
  };
166
236
  exports.convMemberName = convMemberName;
167
237
  exports.convVarName = exports.firstLetterLower;
238
+ let getFieldElementType = function (f) {
239
+ let t = f.type;
240
+ if (t.endsWith("[]")) {
241
+ var type = (0, exports.getFieldType)(f);
242
+ return type.substring(0, type.length - 2);
243
+ }
244
+ else if (t == "any") {
245
+ console.log(f);
246
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`);
247
+ }
248
+ else if (t == "key") {
249
+ return "string";
250
+ }
251
+ else {
252
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`);
253
+ }
254
+ return t;
255
+ };
256
+ exports.getFieldElementType = getFieldElementType;
168
257
  let getFieldType = function (f) {
169
258
  let t = f.type;
170
259
  if (t == "object") {
@@ -220,6 +309,9 @@ let getFieldType = function (f) {
220
309
  else if (t == "fk[]") {
221
310
  return "int[]";
222
311
  }
312
+ else if (t.startsWith("WritableValueTuple<")) {
313
+ return t;
314
+ }
223
315
  else if (t == "any") {
224
316
  console.log(f);
225
317
  throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`);
@@ -233,6 +325,102 @@ let getFieldType = function (f) {
233
325
  return t;
234
326
  };
235
327
  exports.getFieldType = getFieldType;
328
+ let isTypeArray = function (f) {
329
+ let t = f.type;
330
+ let isArray = t.endsWith("[]");
331
+ return isArray;
332
+ };
333
+ exports.isTypeArray = isTypeArray;
334
+ let getFieldAnnotation = function (f) {
335
+ let anno = '[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0)]';
336
+ let t = f.type;
337
+ if (t == "object") {
338
+ return "";
339
+ }
340
+ else if (t == "object[]") {
341
+ //throw new Error("invalid type <Dictionary<string,string>[]>")
342
+ return "";
343
+ }
344
+ else if (t == "number") {
345
+ return "";
346
+ }
347
+ else if (t == "number[]") {
348
+ return anno;
349
+ }
350
+ else if (t == "float") {
351
+ return "";
352
+ }
353
+ else if (t == "float[]") {
354
+ return anno;
355
+ }
356
+ else if (t == "int") {
357
+ return "";
358
+ }
359
+ else if (t == "int[]") {
360
+ return anno;
361
+ }
362
+ else if (t == "long") {
363
+ return "";
364
+ }
365
+ else if (t == "long[]") {
366
+ return anno;
367
+ }
368
+ else if (t == "uid") {
369
+ return "";
370
+ }
371
+ else if (t == "bool") {
372
+ return "";
373
+ }
374
+ else if (t == "bool[]") {
375
+ return anno;
376
+ }
377
+ else if (t == "string") {
378
+ return "";
379
+ }
380
+ else if (t == "string[]") {
381
+ return anno;
382
+ }
383
+ else if (t == "fk") {
384
+ return "";
385
+ }
386
+ else if (t == "fk[]") {
387
+ return anno;
388
+ }
389
+ else if (t == "any") {
390
+ console.log(f);
391
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`);
392
+ }
393
+ else if (t == "key") {
394
+ return "string";
395
+ }
396
+ else {
397
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`);
398
+ }
399
+ return t;
400
+ };
401
+ exports.getFieldAnnotation = getFieldAnnotation;
402
+ let getCustomFieldTypeAnnotation = function (f) {
403
+ let anno = '[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0)]';
404
+ let t = f.type;
405
+ if (t == "string") {
406
+ if (f.rawType.endsWith("[]")) {
407
+ return anno;
408
+ }
409
+ return "";
410
+ }
411
+ else if (t == "any") {
412
+ console.log(f);
413
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => any>`);
414
+ }
415
+ else if (t == "key") {
416
+ return "string";
417
+ }
418
+ else {
419
+ throw new Error(`invalid type ${f.name}:<${f.rawType} => unkown>`);
420
+ }
421
+ return t;
422
+ };
423
+ exports.getCustomFieldTypeAnnotation = getCustomFieldTypeAnnotation;
236
424
  let getFkFieldType = function (tables, field) {
237
425
  return tables.find(a => a.name == field.fkTableName).fields.find(a => a.name == field.fkFieldName).type;
238
426
  };
@@ -251,7 +439,23 @@ const getDescripts = (v) => {
251
439
  exports.getDescripts = getDescripts;
252
440
  const convTupleArrayType = (f) => {
253
441
  let line0 = f.rawType.replaceAll(/(?<=[^\w])(number)(?=[^\w]|$)/g, "double").replaceAll(/(?<=[^\w])(boolean)(?=[^\w]|$)/g, "bool");
254
- console.log(line0);
442
+ let m = line0.match(/\@\((\w+),(\w+)\)(\[\])?/);
443
+ if (m != null) {
444
+ let type1 = m[1];
445
+ let type2 = m[2];
446
+ let isArray = m[3] != null;
447
+ let type = `WritableValueTuple<${type1}, ${type2}>${isArray ? "[]" : ""}`;
448
+ let name = `${(0, exports.convMemberName)(f.name)}Obj`;
449
+ let f2 = { ...f, type, name };
450
+ return f2;
451
+ }
452
+ else {
453
+ return undefined;
454
+ }
455
+ };
456
+ exports.convTupleArrayType = convTupleArrayType;
457
+ const convTupleArrayTypeDefine = (f) => {
458
+ let line0 = f.rawType.replaceAll(/(?<=[^\w])(number)(?=[^\w]|$)/g, "double").replaceAll(/(?<=[^\w])(boolean)(?=[^\w]|$)/g, "bool");
255
459
  let m = line0.match(/\@\((\w+),(\w+)\)(\[\])?/);
256
460
  if (m != null) {
257
461
  let type1 = m[1];
@@ -264,4 +468,14 @@ const convTupleArrayType = (f) => {
264
468
  return `public ${line0} ${(0, exports.convMemberName)(f.name)}Obj;`;
265
469
  }
266
470
  };
267
- exports.convTupleArrayType = convTupleArrayType;
471
+ exports.convTupleArrayTypeDefine = convTupleArrayTypeDefine;
472
+ function GetUsingJsonToolNamespace() {
473
+ let jsonToolNamespaceIndex = process.argv.findIndex(v => v == "--AssetToolNamespace");
474
+ let jsonToolNamespace = null;
475
+ if (jsonToolNamespaceIndex >= 0 && process.argv.length > jsonToolNamespaceIndex + 1) {
476
+ jsonToolNamespace = process.argv[jsonToolNamespaceIndex + 1];
477
+ }
478
+ let useJsonToolNamesapce = jsonToolNamespace != null ? `using ${jsonToolNamespace};` : ``;
479
+ return useJsonToolNamesapce;
480
+ }
481
+ exports.GetUsingJsonToolNamespace = GetUsingJsonToolNamespace;
@@ -1 +1 @@
1
- {"version":3,"file":"ExportCSPlugin.d.ts","sourceRoot":"","sources":["../src/ExportCSPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAsE,MAAM,kBAAkB,CAAA;AAItK,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAyNpE;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,EAAsE,MAAM,kBAAkB,CAAA;AAItK,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAqOpE;AAED,qBAAa,YAAa,SAAQ,UAAU;IAC3C,IAAI,SAAW;IACf,IAAI,EAAE,MAAM,EAAE,CAAS;IAEvB,WAAW,CAAC,KAAK,EAAE,iBAAiB;CAOpC"}
@@ -37,9 +37,18 @@ function export_stuff(paras) {
37
37
  let initFunc = name + "Init";
38
38
  let mapfield = fields.find(a => a.type == "key"); //如果是map,则生成对应的map
39
39
  let mapName = name + "Map";
40
+ let customFields = [];
41
+ for (let f2 of fields) {
42
+ customFields.push(f2);
43
+ let f3 = (0, CSParseTool_1.convTupleArrayType)(f2);
44
+ if (f3 != undefined) {
45
+ customFields.push(f3);
46
+ }
47
+ }
40
48
  let temp = `
41
49
  using System.Collections.Generic;
42
50
  using System.Linq;
51
+ using System.Runtime.InteropServices;
43
52
 
44
53
  namespace ${exportNamespace}{
45
54
  [System.Serializable]
@@ -48,19 +57,19 @@ public partial class ${RowClass} {
48
57
  public static List<${RowClass}> Configs = new List<${RowClass}>()
49
58
  {
50
59
  ${(0, export_table_lib_1.iff)(!isSkipExportDefaults, () => `
51
- ${(0, export_table_lib_1.foreach)(datas, data => ` new ${RowClass}(${(0, export_table_lib_1.st)(() => fields.map((f, index) => (0, CSParseTool_1.genValue)(data[index], f)).join(", "))}),`)}
60
+ ${(0, export_table_lib_1.foreach)(datas, data => ` new ${RowClass}(${(0, export_table_lib_1.st)(() => customFields.map((f, index) => (0, CSParseTool_1.genValue)(data[f.index], f)).join(", "))}),`)}
52
61
  `)}
53
62
  };
54
63
 
55
64
  public ${RowClass}() { }
56
- public ${RowClass}(${(0, export_table_lib_1.st)(() => fields.map(f => `${(0, CSParseTool_1.getFieldType)(f)} ${(0, CSParseTool_1.convVarName)(f.name)}`).join(", "))})
65
+ public ${RowClass}(${(0, export_table_lib_1.st)(() => customFields.map(f => `${(0, CSParseTool_1.getFieldType)(f)} ${(0, CSParseTool_1.convVarName)(f.name)}`).join(", "))})
57
66
  {
58
- ${(0, export_table_lib_1.foreach)(fields, f => ` this.${(0, CSParseTool_1.convMemberName)(f.name)} = ${(0, CSParseTool_1.convVarName)(f.name)};`)}
67
+ ${(0, export_table_lib_1.foreach)(customFields, f => ` this.${(0, CSParseTool_1.convMemberName)(f.name)} = ${(0, CSParseTool_1.convVarName)(f.name)};`)}
59
68
  }
60
69
 
61
70
  public virtual ${RowClass} MergeFrom(${RowClass} source)
62
71
  {
63
- ${(0, export_table_lib_1.foreach)(fields, f => ` this.${(0, CSParseTool_1.convMemberName)(f.name)} = source.${(0, CSParseTool_1.convMemberName)(f.name)};`)}
72
+ ${(0, export_table_lib_1.foreach)(customFields, f => ` this.${(0, CSParseTool_1.convMemberName)(f.name)} = source.${(0, CSParseTool_1.convMemberName)(f.name)};`)}
64
73
  return this;
65
74
  }
66
75
 
@@ -76,13 +85,15 @@ ${(0, export_table_lib_1.foreach)(fields, f => `
76
85
  /// <summary>
77
86
  ${(0, export_table_lib_1.foreach)((0, CSParseTool_1.getDescripts)(f), line => ` /// ${line}`)}
78
87
  /// </summary>
88
+ ${(0, CSParseTool_1.getFieldAnnotation)(f)}
79
89
  public ${(0, CSParseTool_1.getFieldType)(f)} ${(0, CSParseTool_1.convMemberName)(f.name)};
80
90
 
81
91
  ${(0, export_table_lib_1.iff)(f.rawType.startsWith("@"), () => `
82
92
  /// <summary>
83
93
  ${(0, export_table_lib_1.foreach)((0, CSParseTool_1.getDescripts)(f), line => ` /// ${line}`)}
84
94
  /// </summary>
85
- ${(0, CSParseTool_1.convTupleArrayType)(f)}`)}`)}
95
+ ${(0, CSParseTool_1.getCustomFieldTypeAnnotation)(f)}
96
+ ${(0, CSParseTool_1.convTupleArrayTypeDefine)(f)}`)}`)}
86
97
 
87
98
  ${(0, export_table_lib_1.cmm)( /**生成get字段 */)}
88
99
  #region get字段
@@ -94,7 +94,7 @@ ${(0, export_table_lib_1.iff)(f.rawType.startsWith("@"), () => `
94
94
  /// <summary>
95
95
  ${(0, export_table_lib_1.foreach)((0, CSParseTool_1.getDescripts)(f), line => ` /// ${line}`)}
96
96
  /// </summary>
97
- ${(0, CSParseTool_1.convTupleArrayType)(f)}`)}`)}
97
+ ${(0, CSParseTool_1.convTupleArrayTypeDefine)(f)}`)}`)}
98
98
 
99
99
  ${(0, export_table_lib_1.cmm)( /**生成get字段 */)}
100
100
  #region get字段
@@ -1 +1 @@
1
- {"version":3,"file":"ExportLiteDBUnityCSJsonPlugin.d.ts","sourceRoot":"","sources":["../src/ExportLiteDBUnityCSJsonPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAE,iBAAiB,EAAqC,MAAM,kBAAkB,CAAA;AAUxJ,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAqDzE;AAED,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,iBAczD;AACD,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,iBAmB5E;AAED,qBAAa,uBAAwB,SAAQ,UAAU;IACtD,IAAI,SAAgB;IACpB,IAAI,EAAE,MAAM,EAAE,CAAkB;IAEhC,WAAW,CAAC,KAAK,EAAE,iBAAiB;IAoB9B,WAAW,CAAC,KAAK,EAAE,iBAAiB;CAqD1C"}
1
+ {"version":3,"file":"ExportLiteDBUnityCSJsonPlugin.d.ts","sourceRoot":"","sources":["../src/ExportLiteDBUnityCSJsonPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAE,iBAAiB,EAAqC,MAAM,kBAAkB,CAAA;AAUxJ,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAiDzE;AAED,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,iBAczD;AACD,wBAAsB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,iBAmB5E;AAED,qBAAa,uBAAwB,SAAQ,UAAU;IACtD,IAAI,SAAgB;IACpB,IAAI,EAAE,MAAM,EAAE,CAAkB;IAEhC,WAAW,CAAC,KAAK,EAAE,iBAAiB;IAoB9B,WAAW,CAAC,KAAK,EAAE,iBAAiB;CAqD1C"}
@@ -36,11 +36,7 @@ const ExportUnityCSJsonPlugin_1 = require("./ExportUnityCSJsonPlugin");
36
36
  var isSkipIndexLoader0 = process.argv.findIndex(v => v == "--SkipIndexLoader") >= 0;
37
37
  function exportUJsonLoader(paras) {
38
38
  let { datas, fields, name, objects, table, exportNamespace, } = paras;
39
- let jsonToolNamespaceIndex = process.argv.findIndex(v => v == "--AssetToolNamespace");
40
- let jsonToolNamespace = "lang.json";
41
- if (jsonToolNamespaceIndex >= 0 && process.argv.length > jsonToolNamespaceIndex + 1) {
42
- jsonToolNamespace = process.argv[jsonToolNamespaceIndex + 1];
43
- }
39
+ let useJsonToolNamesapce = (0, CSParseTool_1.GetUsingJsonToolNamespace)();
44
40
  let RowClass = (0, CSParseTool_1.firstLetterUpper)(name);
45
41
  var fullName = `${table.workbookName}-${name}`;
46
42
  // !!!必须开头没有空格
@@ -48,7 +44,7 @@ function exportUJsonLoader(paras) {
48
44
  using System.Threading.Tasks;
49
45
  using LiteDB;
50
46
  using UnityEngine;
51
- using ${jsonToolNamespace};
47
+ ${useJsonToolNamesapce}
52
48
 
53
49
  namespace ${exportNamespace}
54
50
  {
@@ -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;AAQxJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA+FnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA8GzE;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;CA4C3C"}
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;AAQxJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA2DnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA0GzE;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;CA4C3C"}
@@ -39,47 +39,10 @@ function exportUJson(paras) {
39
39
  let key = f.name;
40
40
  var newKey = (0, CSParseTool_1.convMemberName)(key);
41
41
  newObj[newKey] = obj[key];
42
- var line = f.rawType.replaceAll(/(?<=[^\w])(boolean)(?=[^\w]|$)/g, "bool");
43
- let m = line.match(/\@\((\w+),(\w+)\)(\[\])?/);
44
- if (m != null) {
45
- // [{"Item1":99,"Item2":"klwjefl"}]
46
- let content = obj[key];
47
- let index = 0;
48
- let index2 = -1;
49
- let objs = [];
50
- while (0 <= index && index < content.length) {
51
- index2 = content.indexOf("|", index);
52
- if (index2 == -1) {
53
- if (content.length > 0) {
54
- console.error(`表格格式错误,缺少部分数据,将用默认值填充<${key}>: ${content}`);
55
- }
56
- index2 = content.indexOf(";;", index);
57
- index = index2;
58
- }
59
- else {
60
- index = content.indexOf(";;", index2);
61
- }
62
- let numStr = content.substring(index, index2);
63
- let t1 = m[1];
64
- let v1 = (0, CSParseTool_1.TryConvValue)(numStr, t1, f);
65
- let posEnd = index;
66
- if (index == -1) {
67
- posEnd = content.length;
68
- }
69
- else {
70
- index += 2;
71
- }
72
- let ssStr = content.substring(index2 + 1, posEnd);
73
- let t2 = m[2];
74
- let v2 = (0, CSParseTool_1.TryConvValue)(ssStr, t2, f);
75
- // console.log(`parseinfo1: ${content}, ${index2}, ${index}, ${numStr}, ${t1}, ${v1}`)
76
- // console.log(`parseinfo2: ${content}, ${index2}, ${index}, ${ssStr}, ${t2}, ${v2}`)
77
- objs.push({
78
- Item1: v1,
79
- Item2: v2,
80
- });
81
- }
82
- let isArray = m[3] == "[]";
42
+ let content = obj[key];
43
+ let result = (0, CSParseTool_1.genTupleArrayValue)(f, content);
44
+ if (result != null) {
45
+ let { isArray, objs } = result;
83
46
  if (isArray) {
84
47
  newObj[newKey + "Obj"] = objs;
85
48
  }
@@ -120,11 +83,7 @@ function exportUJson(paras) {
120
83
  exports.exportUJson = exportUJson;
121
84
  function exportUJsonLoader(paras) {
122
85
  let { datas, fields, name, objects, table, exportNamespace, } = paras;
123
- let jsonToolNamespaceIndex = process.argv.findIndex(v => v == "--AssetToolNamespace");
124
- let jsonToolNamespace = "lang.json";
125
- if (jsonToolNamespaceIndex >= 0 && process.argv.length > jsonToolNamespaceIndex + 1) {
126
- jsonToolNamespace = process.argv[jsonToolNamespaceIndex + 1];
127
- }
86
+ let useJsonToolNamesapce = (0, CSParseTool_1.GetUsingJsonToolNamespace)();
128
87
  let RowClass = firstLetterUpper(name);
129
88
  var fullName = `${table.workbookName}-${name}`;
130
89
  var mmpMark = isEnableMMPB ? "[MemoryPack.MemoryPackable]" : "";
@@ -133,7 +92,7 @@ function exportUJsonLoader(paras) {
133
92
  using System.Collections.Generic;
134
93
  using System.Threading.Tasks;
135
94
  using UnityEngine;
136
- using ${jsonToolNamespace};
95
+ ${useJsonToolNamesapce}
137
96
 
138
97
  namespace ${exportNamespace}
139
98
  {
@@ -147,7 +106,7 @@ namespace ${exportNamespace}
147
106
  }
148
107
  #endif
149
108
  [System.Serializable]
150
- internal struct TempA
109
+ private struct TempA
151
110
  {
152
111
  public List<${RowClass}> a;
153
112
  }
@@ -182,7 +141,7 @@ namespace ${exportNamespace}
182
141
  }
183
142
 
184
143
  #if UNITY_EDITOR
185
- public static void LoadInEditor(bool force = false)
144
+ public static void LoadInEditor(bool force = false, System.Func<string, string> pathConverter = null)
186
145
  {
187
146
  if (Application.isPlaying && (!force))
188
147
  {
@@ -190,8 +149,8 @@ namespace ${exportNamespace}
190
149
  Debug.LogError(tip);
191
150
  throw new System.Exception(tip);
192
151
  }
193
- var loadUrl = LoadUrl;
194
- var configJson = UnityEditor.AssetDatabase.LoadAssetAtPath<TextAsset>(loadUrl);
152
+ var loadUrl = pathConverter == null ? LoadUrl : pathConverter(LoadUrl);
153
+ var configJson = System.IO.File.ReadAllText(loadUrl, Encoding.UTF8);
195
154
  if (configJson != null)
196
155
  {
197
156
  var obj = new TempA()
@@ -266,7 +225,7 @@ ${(0, export_table_lib_1.foreach)(tables.sort((ta, tb) => ta.name.localeCompare(
266
225
  }
267
226
 
268
227
  #if UNITY_EDITOR
269
- public static IEnumerable<Action<bool>> LoadInEditor(){
228
+ public static IEnumerable<Action<bool, System.Func<string, string>>> LoadInEditor(){
270
229
  ${(0, export_table_lib_1.foreach)(tables.sort((ta, tb) => ta.name.localeCompare(tb.name)), (table) => `
271
230
  yield return ${firstLetterUpper(table.name)}.LoadInEditor;
272
231
  `)}
@@ -0,0 +1,8 @@
1
+ import { HandleSheetParams, PluginBase } from "export-table-lib";
2
+ export declare function exportMMP(paras: HandleSheetParams): string | null;
3
+ export declare class ExportUnityMMPPlugin extends PluginBase {
4
+ name: string;
5
+ tags: string[];
6
+ handleSheet(paras: HandleSheetParams): void;
7
+ }
8
+ //# sourceMappingURL=ExportUnityMMPPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExportUnityMMPPlugin.d.ts","sourceRoot":"","sources":["../src/ExportUnityMMPPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAA6D,MAAM,kBAAkB,CAAA;AAQ7J,wBAAgB,SAAS,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAqGjE;AAED,qBAAa,oBAAqB,SAAQ,UAAU;IACnD,IAAI,SAAQ;IACZ,IAAI,EAAE,MAAM,EAAE,CAAU;IAExB,WAAW,CAAC,KAAK,EAAE,iBAAiB;CAUpC"}