export-table-pulgin-csharp 1.1.114 → 1.1.116

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,11 +1,12 @@
1
1
  import { HandleSheetParams, PluginBase, HandleBatchParams } from "export-table-lib";
2
2
  export declare function exportUJson(paras: HandleSheetParams): string | null;
3
3
  export declare function exportUJsonLoader(paras: HandleSheetParams): string | null;
4
- export declare function ConvJson2LiteDB(litedbpath: string, savePaths: string[]): void;
4
+ export declare function RemoveJsonFiles(savePaths2: string[]): Promise<void>;
5
+ export declare function ConvJson2LiteDB(litedbpath: string, savePaths: string[]): Promise<void>;
5
6
  export declare class ExportLiteDBUJsonPlugin extends PluginBase {
6
7
  name: string;
7
8
  tags: string[];
8
9
  handleSheet(paras: HandleSheetParams): string | null;
9
- handleBatch(paras: HandleBatchParams): void;
10
+ handleBatch(paras: HandleBatchParams): Promise<void>;
10
11
  }
11
12
  //# sourceMappingURL=ExportLiteDBUnityCSJsonPlugin.d.ts.map
@@ -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,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAuFnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAsDzE;AAED,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QA6BtE;AAED,qBAAa,uBAAwB,SAAQ,UAAU;IACtD,IAAI,SAAgB;IACpB,IAAI,EAAE,MAAM,EAAE,CAAkB;IAEhC,WAAW,CAAC,KAAK,EAAE,iBAAiB;IAoBpC,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI;CA+C3C"}
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,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAuFnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAsDzE;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;CAgD1C"}
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.ExportLiteDBUJsonPlugin = exports.ConvJson2LiteDB = exports.exportUJsonLoader = exports.exportUJson = void 0;
29
+ exports.ExportLiteDBUJsonPlugin = exports.ConvJson2LiteDB = exports.RemoveJsonFiles = exports.exportUJsonLoader = exports.exportUJson = void 0;
30
30
  const export_table_lib_1 = require("export-table-lib");
31
31
  const fs = __importStar(require("fs-extra"));
32
32
  const CSParseTool_1 = require("./CSParseTool");
@@ -160,7 +160,23 @@ namespace ${exportNamespace}
160
160
  return temp;
161
161
  }
162
162
  exports.exportUJsonLoader = exportUJsonLoader;
163
- function ConvJson2LiteDB(litedbpath, savePaths) {
163
+ async function RemoveJsonFiles(savePaths2) {
164
+ let deleteTasks = savePaths2.map(async (savePath2) => {
165
+ console.log(`delete file: ${savePath2}`);
166
+ try {
167
+ if (fs.existsSync(savePath2)) {
168
+ fs.removeSync(savePath2);
169
+ }
170
+ }
171
+ catch (ex) {
172
+ console.error(`error: cannot delete file ${savePath2}`);
173
+ console.error(ex);
174
+ }
175
+ });
176
+ await Promise.all(deleteTasks);
177
+ }
178
+ exports.RemoveJsonFiles = RemoveJsonFiles;
179
+ async function ConvJson2LiteDB(litedbpath, savePaths) {
164
180
  if (litedbpath != null) {
165
181
  let modulePath = require.resolve(".");
166
182
  let binPath = path_1.default.resolve(modulePath, "../../bin/Json2LiteDB.exe");
@@ -174,18 +190,7 @@ function ConvJson2LiteDB(litedbpath, savePaths) {
174
190
  console.log("execute-cmdline: " + cmdline);
175
191
  var output = cp.spawnSync(binPath, cmdParas);
176
192
  console.log(output.output.toString());
177
- for (let savePath2 of savePaths2) {
178
- console.log(`delete file: ${savePath2}`);
179
- try {
180
- if (fs.existsSync(savePath2)) {
181
- fs.removeSync(savePath2);
182
- }
183
- }
184
- catch (ex) {
185
- console.error(`error: cannot delete file ${savePath2}`);
186
- console.error(ex);
187
- }
188
- }
193
+ RemoveJsonFiles(savePaths2);
189
194
  }
190
195
  else {
191
196
  console.log(`no litedbpath given, skip conv database`);
@@ -213,7 +218,7 @@ class ExportLiteDBUJsonPlugin extends export_table_lib_1.PluginBase {
213
218
  return content2;
214
219
  }
215
220
  }
216
- handleBatch(paras) {
221
+ async handleBatch(paras) {
217
222
  let { moreOptions, tables, exportNamespace, } = paras;
218
223
  let isSkipIndexLoader = !!moreOptions?.SkipIndexLoader ?? false;
219
224
  if (isSkipIndexLoader0) {
@@ -249,7 +254,7 @@ ${(0, export_table_lib_1.foreach)(tables.sort((ta, tb) => ta.name.localeCompare(
249
254
  let savePath = new export_table_lib_1.OutFilePath(paras.outPath, fullName, ".json").fullPath;
250
255
  return savePath;
251
256
  });
252
- ConvJson2LiteDB(litedbpath, cmdParas);
257
+ await ConvJson2LiteDB(litedbpath, cmdParas);
253
258
  }
254
259
  }
255
260
  exports.ExportLiteDBUJsonPlugin = ExportLiteDBUJsonPlugin;
@@ -121,7 +121,7 @@ function exportUJsonLoader(paras) {
121
121
  using UnityEngine.AddressableAssets;
122
122
  using System.Threading.Tasks;
123
123
  using UnityEngine;
124
- using ${jsonToolNamespace};
124
+ // using ${jsonToolNamespace};
125
125
 
126
126
  namespace ${exportNamespace}
127
127
  {
@@ -149,7 +149,7 @@ namespace ${exportNamespace}
149
149
  ${RowClass}[] jsonObjs;
150
150
  try
151
151
  {
152
- jsonObjs = JSON.parse<${RowClass}[]>(configJson.text);
152
+ jsonObjs = JsonUtility.FromJson<${RowClass}[]>(configJson.text);
153
153
  }
154
154
  catch(System.Exception ex)
155
155
  {
@@ -179,7 +179,7 @@ namespace ${exportNamespace}
179
179
  var configJson = UnityEditor.AssetDatabase.LoadAssetAtPath<TextAsset>(loadUrl);
180
180
  if (configJson != null)
181
181
  {
182
- var jsonObjs = JSON.parse<${RowClass}[]>(configJson.text);
182
+ var jsonObjs = JsonUtility.FromJson<${RowClass}[]>(configJson.text);
183
183
  var configs = ${RowClass}.Configs;
184
184
  configs.Clear();
185
185
  configs.AddRange(jsonObjs);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "export-table-pulgin-csharp",
3
- "version": "1.1.114",
3
+ "version": "1.1.116",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {},
@@ -154,7 +154,22 @@ namespace ${exportNamespace}
154
154
 
155
155
  }
156
156
 
157
- export function ConvJson2LiteDB(litedbpath: string, savePaths: string[]) {
157
+ export async function RemoveJsonFiles(savePaths2: string[]) {
158
+ let deleteTasks = savePaths2.map(async (savePath2) => {
159
+ console.log(`delete file: ${savePath2}`)
160
+ try {
161
+ if (fs.existsSync(savePath2)) {
162
+ fs.removeSync(savePath2);
163
+ }
164
+ } catch (ex) {
165
+ console.error(`error: cannot delete file ${savePath2}`);
166
+ console.error(ex);
167
+ }
168
+ })
169
+
170
+ await Promise.all(deleteTasks)
171
+ }
172
+ export async function ConvJson2LiteDB(litedbpath: string, savePaths: string[]) {
158
173
  if (litedbpath != null) {
159
174
  let modulePath = require.resolve(".")
160
175
  let binPath = path.resolve(modulePath, "../../bin/Json2LiteDB.exe")
@@ -169,17 +184,7 @@ export function ConvJson2LiteDB(litedbpath: string, savePaths: string[]) {
169
184
  var output = cp.spawnSync(binPath, cmdParas)
170
185
  console.log(output.output.toString())
171
186
 
172
- for (let savePath2 of savePaths2) {
173
- console.log(`delete file: ${savePath2}`)
174
- try {
175
- if (fs.existsSync(savePath2)) {
176
- fs.removeSync(savePath2);
177
- }
178
- } catch (ex) {
179
- console.error(`error: cannot delete file ${savePath2}`);
180
- console.error(ex);
181
- }
182
- }
187
+ RemoveJsonFiles(savePaths2)
183
188
  } else {
184
189
  console.log(`no litedbpath given, skip conv database`)
185
190
  }
@@ -209,7 +214,7 @@ export class ExportLiteDBUJsonPlugin extends PluginBase {
209
214
  }
210
215
  }
211
216
 
212
- handleBatch(paras: HandleBatchParams): void {
217
+ async handleBatch(paras: HandleBatchParams) {
213
218
 
214
219
  let {
215
220
  moreOptions,
@@ -253,7 +258,8 @@ ${foreach(tables.sort((ta, tb) => ta.name.localeCompare(tb.name)), (table) => `
253
258
  let savePath = new OutFilePath(paras.outPath, fullName, ".json").fullPath
254
259
  return savePath
255
260
  })
256
- ConvJson2LiteDB(litedbpath, cmdParas);
261
+
262
+ await ConvJson2LiteDB(litedbpath, cmdParas);
257
263
 
258
264
  }
259
265
  }
@@ -117,7 +117,7 @@ export function exportUJsonLoader(paras: HandleSheetParams): string | null {
117
117
  using UnityEngine.AddressableAssets;
118
118
  using System.Threading.Tasks;
119
119
  using UnityEngine;
120
- using ${jsonToolNamespace};
120
+ // using ${jsonToolNamespace};
121
121
 
122
122
  namespace ${exportNamespace}
123
123
  {
@@ -145,7 +145,7 @@ namespace ${exportNamespace}
145
145
  ${RowClass}[] jsonObjs;
146
146
  try
147
147
  {
148
- jsonObjs = JSON.parse<${RowClass}[]>(configJson.text);
148
+ jsonObjs = JsonUtility.FromJson<${RowClass}[]>(configJson.text);
149
149
  }
150
150
  catch(System.Exception ex)
151
151
  {
@@ -175,7 +175,7 @@ namespace ${exportNamespace}
175
175
  var configJson = UnityEditor.AssetDatabase.LoadAssetAtPath<TextAsset>(loadUrl);
176
176
  if (configJson != null)
177
177
  {
178
- var jsonObjs = JSON.parse<${RowClass}[]>(configJson.text);
178
+ var jsonObjs = JsonUtility.FromJson<${RowClass}[]>(configJson.text);
179
179
  var configs = ${RowClass}.Configs;
180
180
  configs.Clear();
181
181
  configs.AddRange(jsonObjs);