export-table-pulgin-csharp 1.1.82 → 1.1.83

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