export-table-pulgin-csharp 1.1.96 → 1.1.98

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,242 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ExportLiteDBCSPlugin = exports.export_stuff = void 0;
27
+ const export_table_lib_1 = require("export-table-lib");
28
+ const CSParseTool_1 = require("./CSParseTool");
29
+ const fs = __importStar(require("fs-extra"));
30
+ function export_stuff(paras) {
31
+ let { datas, fields, inject, name, objects, packagename, tables, xxtea, exportNamespace, moreOptions, } = paras;
32
+ let isSkipExportDefaults = !!moreOptions?.SkipDefaults ?? false;
33
+ if (CSParseTool_1.isSkipExportDefaults0) {
34
+ isSkipExportDefaults = true;
35
+ }
36
+ let RowClass = (0, CSParseTool_1.firstLetterUpper)(name);
37
+ let initFunc = name + "Init";
38
+ let mapfield = fields.find(a => a.type == "key"); //如果是map,则生成对应的map
39
+ let mapName = name + "Map";
40
+ let temp = `
41
+ using System.Collections.Generic;
42
+ using System.Linq;
43
+
44
+ namespace ${exportNamespace}{
45
+ [System.Serializable]
46
+ public partial class ${RowClass} {
47
+
48
+ private static List<${RowClass}> _configs;
49
+
50
+ public static List<${RowClass}> Configs
51
+ {
52
+ get
53
+ {
54
+ if (_configs == null)
55
+ {
56
+ _configs = Collection.FindAll().ToList();
57
+ }
58
+
59
+ return _configs;
60
+ }
61
+ }
62
+
63
+ public ${RowClass}() { }
64
+ public ${RowClass}(${(0, export_table_lib_1.st)(() => fields.map(f => `${(0, CSParseTool_1.getFieldType)(f)} ${(0, CSParseTool_1.convVarName)(f.name)}`).join(", "))})
65
+ {
66
+ ${(0, export_table_lib_1.foreach)(fields, f => ` this.${(0, CSParseTool_1.convMemberName)(f.name)} = ${(0, CSParseTool_1.convVarName)(f.name)};`)}
67
+ }
68
+
69
+ public virtual ${RowClass} MergeFrom(${RowClass} source)
70
+ {
71
+ ${(0, export_table_lib_1.foreach)(fields, f => ` this.${(0, CSParseTool_1.convMemberName)(f.name)} = source.${(0, CSParseTool_1.convMemberName)(f.name)};`)}
72
+ return this;
73
+ }
74
+
75
+ public virtual ${RowClass} Clone()
76
+ {
77
+ var config = new ${RowClass}();
78
+ config.MergeFrom(this);
79
+ return config;
80
+ }
81
+
82
+ ${(0, export_table_lib_1.cmm)( /**生成字段 */)}
83
+ ${(0, export_table_lib_1.foreach)(fields, f => `
84
+ /// <summary>
85
+ ${(0, export_table_lib_1.foreach)((0, CSParseTool_1.getDescripts)(f), line => ` /// ${line}`)}
86
+ /// </summary>
87
+ public ${(0, CSParseTool_1.getFieldType)(f)} ${(0, CSParseTool_1.convMemberName)(f.name)};
88
+
89
+ ${(0, export_table_lib_1.iff)(f.rawType.startsWith("@"), () => `
90
+ /// <summary>
91
+ ${(0, export_table_lib_1.foreach)((0, CSParseTool_1.getDescripts)(f), line => ` /// ${line}`)}
92
+ /// </summary>
93
+ ${(0, CSParseTool_1.convTupleArrayType)(f)}`)}`)}
94
+
95
+ ${(0, export_table_lib_1.cmm)( /**生成get字段 */)}
96
+ #region get字段
97
+ ${(0, export_table_lib_1.foreach)(fields, f => {
98
+ if (f.nameOrigin != f.name) {
99
+ return ` public ${(0, CSParseTool_1.getFieldType)(f)} ${(0, CSParseTool_1.getTitle)(f).replace(" ", "_")} => ${(0, CSParseTool_1.convMemberName)(f.name)};`;
100
+ }
101
+ else {
102
+ return "";
103
+ }
104
+ })}
105
+ #endregion
106
+
107
+ #region uid map
108
+ ${(0, export_table_lib_1.foreach)(fields, f => {
109
+ if (f.isUnique) {
110
+ let memberName = (0, CSParseTool_1.convMemberName)(f.name);
111
+ let paraName = (0, CSParseTool_1.convVarName)(memberName);
112
+ let tempDictByMemberName = `tempDictBy${memberName}`;
113
+ let memberType = (0, CSParseTool_1.getFieldType)(f);
114
+ return `
115
+ protected static Dictionary<${memberType}, ${RowClass}> ${tempDictByMemberName};
116
+ public static ${RowClass} GetConfigBy${memberName}(${memberType} ${paraName})
117
+ {
118
+ if (${tempDictByMemberName} == null)
119
+ {
120
+ ${tempDictByMemberName} = new Dictionary<int, ${memberType}>(Configs.Count);
121
+ }
122
+
123
+ if (${tempDictByMemberName}.TryGetValue(${paraName}, out var result))
124
+ {
125
+ return result;
126
+ }
127
+
128
+ result = Collection.FindOne(record => record.${memberName} == ${paraName});
129
+ ${tempDictByMemberName}.Add(${paraName}, result);
130
+ return result;
131
+ }
132
+ `;
133
+ }
134
+ else if (f.type == "number" || f.type == "float" || f.type == "int" || f.type == "long" || f.type == "string") {
135
+ let memberName = (0, CSParseTool_1.convMemberName)(f.name);
136
+ let paraName = (0, CSParseTool_1.convVarName)(memberName);
137
+ let tempRecordsDictByMemberName = `tempRecordsDictBy${memberName}`;
138
+ let memberType = (0, CSParseTool_1.getFieldType)(f);
139
+ return `
140
+ protected static Dictionary<${memberType}, ${RowClass}[]> ${tempRecordsDictByMemberName};
141
+ public static ${RowClass}[] GetConfigsBy${memberName}(${memberType} ${paraName})
142
+ {
143
+ if (${tempRecordsDictByMemberName} != null && ${tempRecordsDictByMemberName}.TryGetValue(${paraName},out var retValue))
144
+ {
145
+ return retValue;
146
+ }
147
+ else
148
+ {
149
+ if (${tempRecordsDictByMemberName} == null)
150
+ {
151
+ ${tempRecordsDictByMemberName} = new Dictionary<${memberType}, ${RowClass}[]>(Configs.Count);
152
+ }
153
+ var records = Collection.Find(c => c.${memberName} == ${paraName}).ToArray();
154
+ ${tempRecordsDictByMemberName}.Add(${paraName}, records);
155
+ return records;
156
+ }
157
+ }
158
+ `;
159
+ }
160
+ else {
161
+ return "";
162
+ }
163
+ })}
164
+
165
+ #endregion uid map
166
+
167
+ #region 生成fk.get/set
168
+ ${(0, export_table_lib_1.foreach)(fields, f => `
169
+ ${(0, export_table_lib_1.iff)(f.type == "fk", () => `
170
+ ${(0, export_table_lib_1.iff)((0, CSParseTool_1.getFkFieldType)(tables, f).toLowerCase() != "uid", () => `
171
+ protected ${(0, CSParseTool_1.convMemberName)(f.fkTableName)}[] _fk${(0, CSParseTool_1.convMemberName)(f.name)}=null;
172
+ /**
173
+ * ${f.describe}
174
+ **/
175
+ public virtual ${(0, CSParseTool_1.convMemberName)(f.fkTableName)}[] ${(0, CSParseTool_1.convMemberName)(f.name)}DataList{
176
+ get{
177
+ if(this._fk${(0, CSParseTool_1.convMemberName)(f.name)}==null){
178
+ if(null==this.${(0, CSParseTool_1.convMemberName)(f.name)}){
179
+ this._fk${(0, CSParseTool_1.convMemberName)(f.name)} = new ${(0, CSParseTool_1.convMemberName)(f.fkTableName)}[0];
180
+ }else{
181
+ this._fk${(0, CSParseTool_1.convMemberName)(f.name)}=${(0, CSParseTool_1.convMemberName)(f.fkTableName)}.Configs.FindAll(a=>a.${(0, CSParseTool_1.convMemberName)(f.fkFieldName)}!=null && this.${(0, CSParseTool_1.convMemberName)(f.name)}==a.${(0, CSParseTool_1.convMemberName)(f.fkFieldName)}).ToArray();
182
+ }
183
+ }
184
+ return this._fk${(0, CSParseTool_1.convMemberName)(f.name)};
185
+ }
186
+ }
187
+ `).else(() => `
188
+ protected ${(0, CSParseTool_1.convMemberName)(f.fkTableName)} _fk${(0, CSParseTool_1.convMemberName)(f.name)}=null;
189
+ /**
190
+ * ${f.describe}
191
+ **/
192
+ public virtual ${(0, CSParseTool_1.convMemberName)(f.fkTableName)} ${(0, CSParseTool_1.convMemberName)(f.name)}Data{
193
+ get{
194
+ if(this._fk${(0, CSParseTool_1.convMemberName)(f.name)}==null){
195
+ this._fk${(0, CSParseTool_1.convMemberName)(f.name)}=${(0, CSParseTool_1.convMemberName)(f.fkTableName)}.Configs.Find(a=>a.${(0, CSParseTool_1.convMemberName)(f.fkFieldName)}==this.${(0, CSParseTool_1.convMemberName)(f.name)});
196
+ }
197
+ return this._fk${(0, CSParseTool_1.convMemberName)(f.name)};
198
+ }
199
+ }
200
+ `)}
201
+ `)}
202
+ ${(0, export_table_lib_1.iff)(f.type == "fk[]", () => `
203
+ protected ${(0, CSParseTool_1.convMemberName)(f.fkTableName)}[] _fk${(0, CSParseTool_1.convMemberName)(f.name)}=null;
204
+ /**
205
+ * ${f.describe}
206
+ **/
207
+ public virtual ${(0, CSParseTool_1.convMemberName)(f.fkTableName)}[] ${(0, CSParseTool_1.convMemberName)(f.name)}DataList{
208
+ get{
209
+ if(this._fk${(0, CSParseTool_1.convMemberName)(f.name)}==null){
210
+ if(null==this.${(0, CSParseTool_1.convMemberName)(f.name)}){
211
+ this._fk${(0, CSParseTool_1.convMemberName)(f.name)} = new ${(0, CSParseTool_1.convMemberName)(f.fkTableName)}[0];
212
+ }else{
213
+ this._fk${(0, CSParseTool_1.convMemberName)(f.name)}=${exportNamespace}.${(0, CSParseTool_1.convMemberName)(f.fkTableName)}.Configs.FindAll(a=>a.${(0, CSParseTool_1.convMemberName)(f.fkFieldName)}!=null && this.${(0, CSParseTool_1.convMemberName)(f.name)}!.Contains(a.${(0, CSParseTool_1.convMemberName)(f.fkFieldName)})).ToArray();
214
+ }
215
+ }
216
+ return this._fk${(0, CSParseTool_1.convMemberName)(f.name)};
217
+ }
218
+ }
219
+ `)}
220
+ `)}
221
+ #endregion 生成fk.get/set
222
+ }
223
+ }
224
+ `;
225
+ return temp;
226
+ }
227
+ exports.export_stuff = export_stuff;
228
+ class ExportLiteDBCSPlugin extends export_table_lib_1.PluginBase {
229
+ name = "csharp";
230
+ tags = ["litedbcs"];
231
+ handleSheet(paras) {
232
+ let content = export_stuff(paras);
233
+ if (content != null) {
234
+ var fullName = `${paras.table.workbookName}-${paras.name}`;
235
+ let savePath = new export_table_lib_1.OutFilePath(paras.outPath, fullName, ".cs").fullPath;
236
+ console.log("LFJKFELK:" + savePath);
237
+ fs.outputFileSync(savePath, content, "utf-8");
238
+ }
239
+ return content;
240
+ }
241
+ }
242
+ exports.ExportLiteDBCSPlugin = ExportLiteDBCSPlugin;
@@ -0,0 +1,10 @@
1
+ import { HandleSheetParams, PluginBase, HandleBatchParams } from "export-table-lib";
2
+ export declare function exportUJson(paras: HandleSheetParams): string | null;
3
+ export declare function exportUJsonLoader(paras: HandleSheetParams): string | null;
4
+ export declare class ExportLiteDBUJsonPlugin extends PluginBase {
5
+ name: string;
6
+ tags: string[];
7
+ handleSheet(paras: HandleSheetParams): string | null;
8
+ handleBatch(paras: HandleBatchParams): void;
9
+ }
10
+ //# sourceMappingURL=ExportLiteDBUnityCSJsonPlugin.d.ts.map
@@ -0,0 +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;AAOxJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAuFnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAsDzE;AAED,qBAAa,uBAAwB,SAAQ,UAAU;IACtD,IAAI,SAAU;IACd,IAAI,EAAE,MAAM,EAAE,CAAkB;IAEhC,WAAW,CAAC,KAAK,EAAE,iBAAiB;IAmBpC,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;CAmC3C"}
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ExportLiteDBUJsonPlugin = exports.exportUJsonLoader = exports.exportUJson = void 0;
27
+ const export_table_lib_1 = require("export-table-lib");
28
+ const fs = __importStar(require("fs-extra"));
29
+ const CSParseTool_1 = require("./CSParseTool");
30
+ var isSkipIndexLoader0 = process.argv.findIndex(v => v == "--SkipIndexLoader") >= 0;
31
+ let firstLetterUpper = export_table_lib_1.makeFirstLetterUpper;
32
+ function exportUJson(paras) {
33
+ let { datas, fields, name, objects, table, } = paras;
34
+ var fullName = `${table.workbookName}-${name}`;
35
+ let jsonString = JSON.stringify(objects.map(obj => {
36
+ var newObj = Object.create(null);
37
+ for (let f of fields) {
38
+ let key = f.name;
39
+ var newKey = (0, CSParseTool_1.convMemberName)(key);
40
+ newObj[newKey] = obj[key];
41
+ var line = f.rawType.replaceAll(/(?<=[^\w])(boolean)(?=[^\w]|$)/g, "bool");
42
+ let m = line.match(/\@\((\w+),(\w+)\)(\[\])?/);
43
+ if (m != null) {
44
+ // [{"Item1":99,"Item2":"klwjefl"}]
45
+ let content = obj[key];
46
+ let index = 0;
47
+ let index2 = -1;
48
+ let objs = [];
49
+ while (0 <= index && index < content.length) {
50
+ index2 = content.indexOf("|", index);
51
+ let numStr = content.substring(index, index2);
52
+ let t1 = m[1];
53
+ let v1 = (0, CSParseTool_1.TryConvValue)(numStr, t1, f);
54
+ index = content.indexOf(";;", index2);
55
+ let posEnd = index;
56
+ if (index == -1) {
57
+ posEnd = content.length;
58
+ }
59
+ else {
60
+ index += 2;
61
+ }
62
+ let ssStr = content.substring(index2 + 1, posEnd);
63
+ let t2 = m[2];
64
+ let v2 = (0, CSParseTool_1.TryConvValue)(ssStr, t2, f);
65
+ console.log(`parseinfo1: ${content}, ${index2}, ${index}, ${numStr}, ${t1}, ${v1}`);
66
+ console.log(`parseinfo2: ${content}, ${index2}, ${index}, ${ssStr}, ${t2}, ${v2}`);
67
+ objs.push({
68
+ Item1: v1,
69
+ Item2: v2,
70
+ });
71
+ }
72
+ let isArray = m[3] == "[]";
73
+ if (isArray) {
74
+ newObj[newKey + "Obj"] = objs;
75
+ }
76
+ else {
77
+ if (objs.length > 1) {
78
+ console.log(`配置错误,过多的条目数量: ${content}`);
79
+ }
80
+ newObj[newKey + "Obj"] = objs[0] ?? {};
81
+ }
82
+ }
83
+ }
84
+ // Object.keys(obj).forEach(key => {
85
+ // var newKey = convMemberName(key);
86
+ // newObj[newKey] = obj[key];
87
+ // })
88
+ return newObj;
89
+ }));
90
+ return jsonString;
91
+ // // !!!必须开头没有空格
92
+ // let temp = `%YAML 1.1
93
+ // %TAG !u! tag:unity3d.com,2011:
94
+ // --- !u!114 &11400000
95
+ // MonoBehaviour:
96
+ // m_ObjectHideFlags: 0
97
+ // m_CorrespondingSourceObject: {fileID: 0}
98
+ // m_PrefabInstance: {fileID: 0}
99
+ // m_PrefabAsset: {fileID: 0}
100
+ // m_GameObject: {fileID: 0}
101
+ // m_Enabled: 1
102
+ // m_EditorHideFlags: 0
103
+ // m_Script: {fileID: 11500000, guid: 496f60086c072a8479a6e0b948efb5e8, type: 3}
104
+ // m_Name: ${fullName}
105
+ // m_EditorClassIdentifier:
106
+ // JsonText: ${JSON.stringify(jsonString)}
107
+ // `
108
+ // return temp
109
+ }
110
+ exports.exportUJson = exportUJson;
111
+ function exportUJsonLoader(paras) {
112
+ let { datas, fields, name, objects, table, exportNamespace, } = paras;
113
+ let jsonToolNamespaceIndex = process.argv.findIndex(v => v == "--JsonToolNamespace");
114
+ let jsonToolNamespace = "lang.json";
115
+ if (jsonToolNamespaceIndex >= 0 && process.argv.length > jsonToolNamespaceIndex + 1) {
116
+ jsonToolNamespace = process.argv[jsonToolNamespaceIndex + 1];
117
+ }
118
+ let RowClass = firstLetterUpper(name);
119
+ var fullName = `${table.workbookName}-${name}`;
120
+ // !!!必须开头没有空格
121
+ let temp = `
122
+ using UnityEngine.AddressableAssets;
123
+ using System.Threading.Tasks;
124
+ using LiteDB;
125
+ using UnityEngine;
126
+ using ${jsonToolNamespace};
127
+
128
+ namespace ${exportNamespace}
129
+ {
130
+ public partial class ${RowClass}
131
+ {
132
+ protected static LiteDatabase Database;
133
+ protected static ILiteCollection<${RowClass}> Collection;
134
+ public static Task Load()
135
+ {
136
+ #if UNITY_EDITOR && ENABLE_CONFIG_LOG
137
+ Debug.Log("ReferConfig-${RowClass}");
138
+ #endif
139
+
140
+ var ldb = SharedLiteDB.Database;
141
+ Database = ldb;
142
+ const string key = "${fullName.replace("-", "_")}";
143
+ if (!ldb.CollectionExists(key))
144
+ {
145
+ Debug.LogError($"配表资源缺失: {key}");
146
+ }
147
+ Collection = ldb.GetCollection<${RowClass}>(key);
148
+
149
+ return Task.CompletedTask;
150
+ }
151
+ }
152
+ }
153
+ `;
154
+ return temp;
155
+ }
156
+ exports.exportUJsonLoader = exportUJsonLoader;
157
+ class ExportLiteDBUJsonPlugin extends export_table_lib_1.PluginBase {
158
+ name = "ujson";
159
+ tags = ["litedbujson"];
160
+ handleSheet(paras) {
161
+ var fullName = `${paras.table.workbookName}-${paras.name}`;
162
+ {
163
+ let content1 = exportUJsonLoader(paras);
164
+ if (content1 != null) {
165
+ let savePath = new export_table_lib_1.OutFilePath(paras.outPath, fullName, "Loader.cs").fullPath;
166
+ fs.outputFileSync(savePath, content1, "utf-8");
167
+ }
168
+ }
169
+ {
170
+ let content2 = exportUJson(paras);
171
+ if (content2 != null) {
172
+ let savePath = new export_table_lib_1.OutFilePath(paras.outPath, fullName, ".json").fullPath;
173
+ fs.outputFileSync(savePath, content2, "utf-8");
174
+ }
175
+ return content2;
176
+ }
177
+ }
178
+ handleBatch(paras) {
179
+ let { moreOptions, tables, exportNamespace, } = paras;
180
+ let isSkipIndexLoader = !!moreOptions?.SkipIndexLoader ?? false;
181
+ if (isSkipIndexLoader0) {
182
+ isSkipIndexLoader = true;
183
+ }
184
+ if (isSkipIndexLoader) {
185
+ return;
186
+ }
187
+ var temp = `
188
+ using System;
189
+ using System.Collections.Generic;
190
+ using System.Threading.Tasks;
191
+
192
+ namespace ${exportNamespace}
193
+ {
194
+ public static class DefaultConfigLoader{
195
+ public static IEnumerable<Func<Task>> Load(){
196
+ ${(0, export_table_lib_1.foreach)(tables.sort((ta, tb) => ta.name.localeCompare(tb.name)), (table) => `
197
+ yield return ${firstLetterUpper(table.name)}.Load;
198
+ `)}
199
+ yield break;
200
+ }
201
+ }
202
+ }
203
+ `;
204
+ let savePath = paras.outPath + "/DefaultConfigLoader.cs";
205
+ fs.outputFileSync(savePath, temp, "utf-8");
206
+ }
207
+ }
208
+ exports.ExportLiteDBUJsonPlugin = ExportLiteDBUJsonPlugin;
@@ -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;AAOxJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA6FnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAgGzE;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;AAOxJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAsFnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAiGzE;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"}
@@ -26,23 +26,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.ExportUJsonPlugin = exports.exportUJsonLoader = exports.exportUJson = void 0;
27
27
  const export_table_lib_1 = require("export-table-lib");
28
28
  const fs = __importStar(require("fs-extra"));
29
- const ExportCSPlugin_1 = require("./ExportCSPlugin");
29
+ const CSParseTool_1 = require("./CSParseTool");
30
30
  var isSkipIndexLoader0 = process.argv.findIndex(v => v == "--SkipIndexLoader") >= 0;
31
31
  let firstLetterUpper = export_table_lib_1.makeFirstLetterUpper;
32
32
  function exportUJson(paras) {
33
33
  let { datas, fields, name, objects, table, } = paras;
34
- let firstLetterLower = function (str) {
35
- return str.charAt(0).toLowerCase() + str.slice(1);
36
- };
37
- let convMemberName = function (str) {
38
- return str.split("_").map(s => firstLetterUpper(s)).join("");
39
- };
40
34
  var fullName = `${table.workbookName}-${name}`;
41
35
  let jsonString = JSON.stringify(objects.map(obj => {
42
36
  var newObj = Object.create(null);
43
37
  for (let f of fields) {
44
38
  let key = f.name;
45
- var newKey = convMemberName(key);
39
+ var newKey = (0, CSParseTool_1.convMemberName)(key);
46
40
  newObj[newKey] = obj[key];
47
41
  let m = f.rawType.match(/\@\((\w+),(\w+)\)(\[\])?/);
48
42
  if (m != null) {
@@ -55,7 +49,7 @@ function exportUJson(paras) {
55
49
  index2 = content.indexOf("|", index);
56
50
  let numStr = content.substring(index, index2);
57
51
  let t1 = m[1];
58
- let v1 = (0, ExportCSPlugin_1.TryConvValue)(numStr, t1, f);
52
+ let v1 = (0, CSParseTool_1.TryConvValue)(numStr, t1, f);
59
53
  index = content.indexOf(";;", index2);
60
54
  let posEnd = index;
61
55
  if (index == -1) {
@@ -66,7 +60,7 @@ function exportUJson(paras) {
66
60
  }
67
61
  let ssStr = content.substring(index2 + 1, posEnd);
68
62
  let t2 = m[2];
69
- let v2 = (0, ExportCSPlugin_1.TryConvValue)(ssStr, t2, f);
63
+ let v2 = (0, CSParseTool_1.TryConvValue)(ssStr, t2, f);
70
64
  console.log(`parseinfo1: ${content}, ${index2}, ${index}, ${numStr}, ${t1}, ${v1}`);
71
65
  console.log(`parseinfo2: ${content}, ${index2}, ${index}, ${ssStr}, ${t2}, ${v2}`);
72
66
  objs.push({
@@ -151,6 +145,7 @@ namespace ${exportNamespace}
151
145
  #endif
152
146
  if (configJson != null)
153
147
  {
148
+ Debug.Log($"解析配表: {loadUrl}");
154
149
  ${RowClass}[] jsonObjs;
155
150
  try
156
151
  {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { ExportPlugin as ExportCSPlugin } from "./ExportCSPlugin";
2
+ import { ExportLiteDBCSPlugin } from "./ExportLiteDBCSPlugin";
3
+ import { ExportLiteDBUJsonPlugin } from "./ExportLiteDBUnityCSJsonPlugin";
2
4
  import { ExportUJsonPlugin } from "./ExportUnityCSJsonPlugin";
3
- export declare const ExportPlugins: (ExportCSPlugin | ExportUJsonPlugin)[];
5
+ export declare const ExportPlugins: (ExportCSPlugin | ExportLiteDBCSPlugin | ExportLiteDBUJsonPlugin | ExportUJsonPlugin)[];
4
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAE7D,eAAO,MAAM,aAAa,wCAGzB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAE7D,eAAO,MAAM,aAAa,yFAKzB,CAAA"}
package/dist/index.js CHANGED
@@ -2,8 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ExportPlugins = void 0;
4
4
  const ExportCSPlugin_1 = require("./ExportCSPlugin");
5
+ const ExportLiteDBCSPlugin_1 = require("./ExportLiteDBCSPlugin");
6
+ const ExportLiteDBUnityCSJsonPlugin_1 = require("./ExportLiteDBUnityCSJsonPlugin");
5
7
  const ExportUnityCSJsonPlugin_1 = require("./ExportUnityCSJsonPlugin");
6
8
  exports.ExportPlugins = [
7
9
  new ExportCSPlugin_1.ExportPlugin(),
8
10
  new ExportUnityCSJsonPlugin_1.ExportUJsonPlugin(),
11
+ new ExportLiteDBCSPlugin_1.ExportLiteDBCSPlugin(),
12
+ new ExportLiteDBUnityCSJsonPlugin_1.ExportLiteDBUJsonPlugin(),
9
13
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "export-table-pulgin-csharp",
3
- "version": "1.1.96",
3
+ "version": "1.1.98",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {