export-table-pulgin-csharp 1.1.78 → 1.1.80

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":"ExportUnityCSJsonPlugin.d.ts","sourceRoot":"","sources":["../src/ExportUnityCSJsonPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAO,iBAAiB,EAA+B,UAAU,EAAE,iBAAiB,EAAqC,MAAM,kBAAkB,CAAA;AAIxJ,wBAAgB,WAAW,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CA+CnE;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAgFzE;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;CAsB3C"}
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,CAgFzE;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;CAgC3C"}
@@ -26,6 +26,7 @@ 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
+ var isSkipIndexLoader0 = process.argv.findIndex(v => v == "--SkipIndexLoader") >= 0;
29
30
  let firstLetterUpper = export_table_lib_1.makeFirstLetterUpper;
30
31
  function exportUJson(paras) {
31
32
  let { datas, fields, name, objects, table, } = paras;
@@ -164,6 +165,15 @@ class ExportUJsonPlugin extends export_table_lib_1.PluginBase {
164
165
  }
165
166
  }
166
167
  handleBatch(paras) {
168
+ var _a;
169
+ let moreOptions = paras.moreOptions;
170
+ let isSkipIndexLoader = (_a = !!moreOptions.SkipIndexLoader) !== null && _a !== void 0 ? _a : false;
171
+ if (isSkipIndexLoader0) {
172
+ isSkipIndexLoader = true;
173
+ }
174
+ if (isSkipIndexLoader) {
175
+ return;
176
+ }
167
177
  var tables = paras.tables;
168
178
  var temp = `
169
179
  using System;
@@ -174,7 +184,7 @@ namespace MEEC.ExportedConfigs
174
184
  {
175
185
  public static class DefaultConfigLoader{
176
186
  public static IEnumerable<Func<Task>> Load(){
177
- ${(0, export_table_lib_1.foreach)(tables, (table) => `
187
+ ${(0, export_table_lib_1.foreach)(tables.sort((ta, tb) => ta.name.localeCompare(tb.name)), (table) => `
178
188
  yield return ${firstLetterUpper(table.name)}.Load;
179
189
  `)}
180
190
  yield break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "export-table-pulgin-csharp",
3
- "version": "1.1.78",
3
+ "version": "1.1.80",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -2,6 +2,8 @@
2
2
  import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, HandleBatchParams, OutFilePath, makeFirstLetterUpper } from "export-table-lib"
3
3
  import * as fs from "fs-extra"
4
4
 
5
+ var isSkipIndexLoader0 = process.argv.findIndex(v => v == "--SkipIndexLoader") >= 0
6
+
5
7
  let firstLetterUpper = makeFirstLetterUpper;
6
8
  export function exportUJson(paras: HandleSheetParams): string | null {
7
9
  let {
@@ -158,6 +160,16 @@ export class ExportUJsonPlugin extends PluginBase {
158
160
  }
159
161
 
160
162
  handleBatch(paras: HandleBatchParams): void {
163
+
164
+ let moreOptions = paras.moreOptions
165
+ let isSkipIndexLoader = !!moreOptions.SkipIndexLoader ?? false
166
+ if (isSkipIndexLoader0) {
167
+ isSkipIndexLoader = true
168
+ }
169
+ if (isSkipIndexLoader) {
170
+ return;
171
+ }
172
+
161
173
  var tables = paras.tables;
162
174
  var temp = `
163
175
  using System;
@@ -168,7 +180,7 @@ namespace MEEC.ExportedConfigs
168
180
  {
169
181
  public static class DefaultConfigLoader{
170
182
  public static IEnumerable<Func<Task>> Load(){
171
- ${foreach(tables, (table) => `
183
+ ${foreach(tables.sort((ta, tb) => ta.name.localeCompare(tb.name)), (table) => `
172
184
  yield return ${firstLetterUpper(table.name)}.Load;
173
185
  `)}
174
186
  yield break;
@@ -1,143 +0,0 @@
1
-
2
- import { cmm, HandleSheetParams, Field, foreach, IPlugin, st, PluginBase, HandleBatchParams, OutFilePath, makeFirstLetterUpper } from "export-table-lib"
3
- import * as fs from "fs-extra"
4
-
5
- let firstLetterUpper = makeFirstLetterUpper;
6
- function exportUJson(paras: HandleSheetParams): string | null {
7
- let {
8
- datas,
9
- fields,
10
- name,
11
- objects,
12
- table,
13
- } = paras;
14
-
15
- let firstLetterLower = function (str: string) {
16
- return str.charAt(0).toLowerCase() + str.slice(1);
17
- };
18
- let convMemberName = function (str: string) {
19
- return str.split("_").map(s => firstLetterUpper(s)).join("")
20
- }
21
-
22
- var fullName = `${table.workbookName}-${name}`
23
- let jsonString = JSON.stringify(objects.map(obj => {
24
- var newObj = Object.create(null);
25
- Object.keys(obj).forEach(key => {
26
- var newKey = convMemberName(key);
27
- newObj[newKey] = obj[key];
28
- })
29
- return newObj
30
- }));
31
-
32
- // !!!必须开头没有空格
33
- let temp = `%YAML 1.1
34
- %TAG !u! tag:unity3d.com,2011:
35
- --- !u!114 &11400000
36
- MonoBehaviour:
37
- m_ObjectHideFlags: 0
38
- m_CorrespondingSourceObject: {fileID: 0}
39
- m_PrefabInstance: {fileID: 0}
40
- m_PrefabAsset: {fileID: 0}
41
- m_GameObject: {fileID: 0}
42
- m_Enabled: 1
43
- m_EditorHideFlags: 0
44
- m_Script: {fileID: 11500000, guid: 496f60086c072a8479a6e0b948efb5e8, type: 3}
45
- m_Name: ${fullName}
46
- m_EditorClassIdentifier:
47
- JsonText: ${JSON.stringify(jsonString)}
48
- `
49
- return temp
50
-
51
- }
52
-
53
- function exportUJsonLoader(paras: HandleSheetParams): string | null {
54
- let {
55
- datas,
56
- fields,
57
- name,
58
- objects,
59
- table,
60
- } = paras;
61
-
62
- let RowClass = firstLetterUpper(name)
63
- var fullName = `${table.workbookName}-${name}`
64
- // !!!必须开头没有空格
65
- let temp = `
66
- using lang.json;
67
- using UnityEngine.AddressableAssets;
68
- using System.Threading.Tasks;
69
- using UnityEngine;
70
-
71
- namespace MEEC.ExportedConfigs
72
- {
73
- public partial class ${RowClass}
74
- {
75
- public static async Task Load()
76
- {
77
- var loadUrl="Assets/Bundles/GameConfigs/Auto/${fullName}.asset";
78
- var configJson = await Addressables.LoadAssetAsync<ExcelConfigJson>(loadUrl).Task;
79
- if (configJson != null)
80
- {
81
- var jsonObjs = JSON.parse<${RowClass}[]>(configJson.JsonText);
82
- var configs = ${RowClass}.Configs;
83
- configs.Clear();
84
- configs.AddRange(jsonObjs);
85
- }
86
- else
87
- {
88
- Debug.LogError($"配表资源缺失: {loadUrl}");
89
- }
90
- }
91
- }
92
- }
93
- `
94
- return temp
95
-
96
- }
97
-
98
- export class ExportUJsonPluginV1 extends PluginBase {
99
- name = "ujson1"
100
- tags: string[] = ["ujson1"]
101
-
102
- handleSheet(paras: HandleSheetParams) {
103
- var fullName = `${paras.table.workbookName}-${paras.name}`
104
- {
105
- let content1 = exportUJsonLoader(paras)
106
- if (content1 != null) {
107
- let savePath = new OutFilePath(paras.outPath, fullName, "Loader.cs").fullPath
108
- fs.outputFileSync(savePath, content1, "utf-8")
109
- }
110
- }
111
- {
112
- let content2 = exportUJson(paras)
113
- if (content2 != null) {
114
- let savePath = new OutFilePath(paras.outPath, fullName, ".asset").fullPath
115
- fs.outputFileSync(savePath, content2, "utf-8")
116
- }
117
- return content2
118
- }
119
- }
120
-
121
- handleBatch(paras: HandleBatchParams): void {
122
- var tables = paras.tables;
123
- var temp = `
124
- using System;
125
- using System.Collections.Generic;
126
- using System.Threading.Tasks;
127
-
128
- namespace MEEC.ExportedConfigs
129
- {
130
- public static class DefaultConfigLoader{
131
- public static IEnumerable<Func<Task>> Load(){
132
- ${foreach(tables, (table) => `
133
- yield return ${firstLetterUpper(table.name)}.Load;
134
- `)}
135
- yield break;
136
- }
137
- }
138
- }
139
- `
140
- let savePath = paras.outPath + "/DefaultConfigLoader.cs";
141
- fs.outputFileSync(savePath, temp, "utf-8");
142
- }
143
- }