@cabin-icarus/tooltip_generator 1.7.5 → 1.7.7

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.
package/install.ts CHANGED
@@ -21,7 +21,7 @@ const aliases = [
21
21
  // Check package.json
22
22
  function CheckPackage() {
23
23
  console.log("Searching for package.json...");
24
- const rootPath = "../../../../";
24
+ const rootPath = "../../../";
25
25
  const scriptPath = "./";
26
26
 
27
27
  console.log("F: ",fs.realpathSync(rootPath + "package.json"))
@@ -143,6 +143,6 @@ function CheckPackage() {
143
143
  })
144
144
  }
145
145
 
146
- console.log("F: ",fs.realpathSync("../../../../package.json"))
146
+ console.log("F: ",fs.realpathSync("../../../package.json"))
147
147
 
148
148
  CheckPackage();
package/package.json CHANGED
@@ -45,5 +45,5 @@
45
45
  "dev:runlocalizationWatcher": "ts-node node_modules/~generator/fsWatcher.ts",
46
46
  "init": "link-module-alias && ts-node node_modules/~generator/init.ts"
47
47
  },
48
- "version": "1.7.5"
48
+ "version": "1.7.7"
49
49
  }
package/tsconfig.json CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  /* Basic Options */
6
6
  // "incremental": true, /* Enable incremental compilation */
7
- "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
7
+ "target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
8
8
  "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
9
9
  // "lib": [], /* Specify library files to be included in the compilation. */
10
10
  // "allowJs": true, /* Allow javascript files to be compiled. */
@@ -21,7 +21,7 @@
21
21
  // "removeComments": true, /* Do not emit comments to output. */
22
22
  // "noEmit": true, /* Do not emit outputs. */
23
23
  // "importHelpers": true, /* Import emit helpers from 'tslib'. */
24
- "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
24
+ "downlevelIteration": false, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
25
25
  // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
26
26
 
27
27
  /* Strict Type-Checking Options */
@@ -41,7 +41,7 @@
41
41
  // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
42
42
 
43
43
  /* Module Resolution Options */
44
- // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
44
+ "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
45
45
  // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
46
46
  // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
47
47
  // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
@@ -59,14 +59,15 @@
59
59
  // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
60
60
 
61
61
  /* Experimental Options */
62
- // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
63
- // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
62
+ "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
63
+ "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
64
64
 
65
65
  /* Advanced Options */
66
66
  "skipLibCheck": true, /* Skip type checking of declaration files. */
67
+ "skipDefaultLibCheck":true,
67
68
  "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
68
69
  "types": [
69
70
  "@types/node"
70
- ]
71
+ ],
71
72
  },
72
73
  }
package/fsWatcher.js DELETED
@@ -1,81 +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
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- var fs = __importStar(require("fs"));
23
- var watch = require("node-watch");
24
- var completeData = {};
25
- var resourcePath = "node_modules/~resource";
26
- var generatorPath = "node_modules/~generator";
27
- console.log(fs.realpathSync(generatorPath));
28
- var watcher = watch([resourcePath + "/localization", generatorPath + "/localizationCompiler.js"], { recursive: true });
29
- watcher.on("change", function (eventType, filePath) {
30
- if (!filePath)
31
- return;
32
- if (filePath.includes("localizationCompiler.js")) {
33
- compiler = loadCompiler();
34
- }
35
- var match = /(node_modules[\\/])?(.*[\/|\\](\w+)).js/g.exec(filePath);
36
- if (eventType == "update" && filePath && match) {
37
- var curpath = match[2];
38
- var data = getDataFromFile(curpath + ".js");
39
- if (data) {
40
- completeData[curpath] = data;
41
- combineData();
42
- }
43
- }
44
- else if (eventType == "remove" && match) {
45
- if (completeData.hasOwnProperty(match[2])) {
46
- delete completeData[match[2]];
47
- combineData();
48
- }
49
- }
50
- });
51
- // not really neccessarry:
52
- watcher.on("error", function (error) {
53
- console.log("\x1b[31m%s\x1b[0m", "Something went wrong!");
54
- console.log(error);
55
- });
56
- watcher.on("ready", function () {
57
- console.log("\x1b[32m%s\x1b[0m", "Ready!");
58
- });
59
- var compiler = loadCompiler();
60
- function getDataFromFile(filePath) {
61
- if (!fs.existsSync("node_modules/" + filePath)) {
62
- return;
63
- }
64
- delete require.cache[require.resolve(filePath)];
65
- var file = require(filePath);
66
- if (file["GenerateLocalizationData"]) {
67
- var localizationArr = file["GenerateLocalizationData"]();
68
- return localizationArr;
69
- }
70
- return;
71
- }
72
- function combineData() {
73
- compiler.OnLocalizationDataChanged(completeData);
74
- }
75
- function loadCompiler() {
76
- // Clear require cache
77
- delete require.cache[require.resolve("~generator/localizationCompiler")];
78
- // Require latest compiler version
79
- var compilerClass = require("~generator/localizationCompiler").LocalizationCompiler;
80
- return new compilerClass();
81
- }
package/init.js DELETED
@@ -1,146 +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
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- Object.defineProperty(exports, "__esModule", { value: true });
22
- var fs = __importStar(require("fs"));
23
- function copyFiles() {
24
- console.log("Copying initial files...");
25
- var resourcePath = "node_modules/~resource";
26
- var filePath = __dirname + "/tsconfig.json";
27
- if (fs.existsSync(resourcePath)) {
28
- filePath = __dirname + "/tsconfig.json";
29
- var resultPath = resourcePath + "/tsconfig.json";
30
- console.log("Checking if tsconfig.json exists in " + filePath);
31
- if (fs.existsSync(resultPath)) {
32
- console.log("tsconfig.json found!");
33
- }
34
- else {
35
- fs.copyFileSync(filePath, resultPath);
36
- console.log("Not found, tsconfig.json copied to " + resultPath + " folder");
37
- }
38
- filePath = __dirname + "/ModifierProperties.d.ts";
39
- resultPath = resourcePath + "/ModifierProperties.d.ts";
40
- console.log("Checking if ModifierProperties.d.ts exists in " + filePath);
41
- if (fs.existsSync(resultPath)) {
42
- console.log("ModifierProperties.d.ts found!");
43
- }
44
- else {
45
- fs.copyFileSync(filePath, resultPath);
46
- console.log("Not found, ModifierProperties.d.ts copied to " + resultPath + " folder");
47
- }
48
- filePath = __dirname + "/languages.ts";
49
- resultPath = resourcePath + "/languages.ts";
50
- console.log("Checking if languages.ts exsts in " + filePath);
51
- if (fs.existsSync(resultPath)) {
52
- console.log("languages.ts found!");
53
- }
54
- else {
55
- fs.copyFileSync(filePath, resultPath);
56
- console.log("Not found, languages.ts copied to " + resultPath + " folder");
57
- }
58
- filePath = __dirname + "/languages.js";
59
- resultPath = resourcePath + "/languages.js";
60
- console.log("Checking if languages.js exsts in " + filePath);
61
- if (fs.existsSync(resultPath)) {
62
- console.log("languages.js found!");
63
- }
64
- else {
65
- fs.copyFileSync(filePath, resultPath);
66
- console.log("Not found, languages.js copied to " + resultPath + " folder");
67
- }
68
- }
69
- var dirPath = __dirname + "/localization";
70
- if (fs.existsSync(filePath) && fs.existsSync(resourcePath)) {
71
- var resultPath = resourcePath + "/localization";
72
- console.log("Checking if localization folder exists in " + resultPath);
73
- if (!fs.existsSync(resultPath)) {
74
- fs.mkdirSync(resultPath);
75
- console.log("localization folder not found, creating the folder.");
76
- }
77
- console.log("Checking if localization folder is empty");
78
- if (fs.readdirSync(resultPath).length === 0) {
79
- console.log("Localization folder is empty, copying example files.");
80
- if (!fs.existsSync(resultPath + "/localizationData.ts")) {
81
- fs.copyFileSync(dirPath + "/localizationData.ts", resultPath + "/localizationData.ts");
82
- }
83
- if (!fs.existsSync(resultPath + "/localizationData.js")) {
84
- fs.copyFileSync(dirPath + "/localizationData.js", resultPath + "/localizationData.js");
85
- }
86
- }
87
- }
88
- console.log("\x1b[36m%s\x1b[0m", "Finished copy process!");
89
- }
90
- function changeImports() {
91
- var resourcePath = "node_modules/~resource";
92
- var compilerFilePath = __dirname + "/localizationCompiler.ts";
93
- if (fs.existsSync(compilerFilePath)) {
94
- fs.readFile(compilerFilePath, 'utf8', function (err, data) {
95
- if (err) {
96
- return console.log(err);
97
- }
98
- var result = data.replace('import { Language } from "./languages"', 'import { Language } from "~resource/languages"');
99
- fs.writeFile(compilerFilePath, result, 'utf8', function (err) {
100
- if (err)
101
- return console.log(err);
102
- });
103
- });
104
- }
105
- var compilerJSFilePath = __dirname + "/localizationCompiler.js";
106
- if (fs.existsSync(compilerJSFilePath)) {
107
- fs.readFile(compilerJSFilePath, 'utf8', function (err, data) {
108
- if (err) {
109
- return console.log(err);
110
- }
111
- var result = data.replace('languages_1 = require("./languages");', 'languages_1 = require("~resource/languages");');
112
- fs.writeFile(compilerJSFilePath, result, 'utf8', function (err) {
113
- if (err)
114
- return console.log(err);
115
- });
116
- });
117
- }
118
- var interfacesFilePath = __dirname + "/localizationInterfaces.ts";
119
- if (fs.existsSync(interfacesFilePath)) {
120
- fs.readFile(interfacesFilePath, 'utf8', function (err, data) {
121
- if (err) {
122
- return console.log(err);
123
- }
124
- var stringResult = data.replace('import { Language } from "./languages"', 'import { Language } from "~resource/languages"');
125
- fs.writeFile(interfacesFilePath, stringResult, 'utf8', function (err) {
126
- if (err)
127
- return console.log(err);
128
- });
129
- });
130
- }
131
- var exampleFilePath = resourcePath + "/localization/localizationData.ts";
132
- if (fs.existsSync(exampleFilePath)) {
133
- fs.readFile(exampleFilePath, 'utf8', function (err, data) {
134
- if (err) {
135
- return console.log(err);
136
- }
137
- var stringResult = data.replace('import { AbilityLocalization, LocalizationData, ModifierLocalization, StandardLocalization } from "../localizationInterfaces";', 'import { AbilityLocalization, LocalizationData, ModifierLocalization, StandardLocalization } from "~generator/localizationInterfaces";');
138
- fs.writeFile(exampleFilePath, stringResult, 'utf8', function (err) {
139
- if (err)
140
- return console.log(err);
141
- });
142
- });
143
- }
144
- }
145
- copyFiles();
146
- changeImports();
package/install.js DELETED
@@ -1,192 +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
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __values = (this && this.__values) || function(o) {
22
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
23
- if (m) return m.call(o);
24
- if (o && typeof o.length === "number") return {
25
- next: function () {
26
- if (o && i >= o.length) o = void 0;
27
- return { value: o && o[i++], done: !o };
28
- }
29
- };
30
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
31
- };
32
- var __read = (this && this.__read) || function (o, n) {
33
- var m = typeof Symbol === "function" && o[Symbol.iterator];
34
- if (!m) return o;
35
- var i = m.call(o), r, ar = [], e;
36
- try {
37
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
38
- }
39
- catch (error) { e = { error: error }; }
40
- finally {
41
- try {
42
- if (r && !r.done && (m = i["return"])) m.call(i);
43
- }
44
- finally { if (e) throw e.error; }
45
- }
46
- return ar;
47
- };
48
- Object.defineProperty(exports, "__esModule", { value: true });
49
- var fs = __importStar(require("fs"));
50
- var child = __importStar(require("child_process"));
51
- // define package insertions
52
- var devScripts = [
53
- ["dev:localizationCompiler", "tsc --project node_modules/~resource/tsconfig.json"],
54
- ["dev:localizationCompilerWatcher", "tsc --project node_modules/~resource/tsconfig.json --watch"],
55
- ["dev:runlocalizationWatcher", "node node_modules/~generator/fsWatcher.js"]
56
- ];
57
- var initSCript = ["init", "link-module-alias && node node_modules/~generator/init.js"];
58
- var aliases = [
59
- ["~resource", "resource"],
60
- ["~generator", "node_modules/@shushishtok/tooltip_generator"]
61
- ];
62
- // Check package.json
63
- function CheckPackage() {
64
- var e_1, _a;
65
- console.log("Searching for package.json...");
66
- var rootPath = "../../../";
67
- var scriptPath = "./";
68
- // adjust existing package.json
69
- if (fs.existsSync(rootPath + "package.json")) {
70
- console.log("Checking existing package.json...");
71
- var goalPackageRaw = fs.readFileSync(rootPath + "package.json");
72
- var goalPackage = JSON.parse(goalPackageRaw.toString());
73
- // check script part
74
- var hasDev = false;
75
- var hasInit = false;
76
- if (goalPackage.scripts) {
77
- var scripts = goalPackage.scripts;
78
- for (var name_1 in scripts) {
79
- if (name_1 == "dev") {
80
- if (scripts[name_1] !== "run-p dev:*") {
81
- console.log("\x1b[31m%s\x1b[0m", "Unexpected 'dev' script in package.json!");
82
- return;
83
- }
84
- hasDev = true;
85
- }
86
- if (name_1 == "init") {
87
- if (scripts[name_1] !== "link-module-alias && node node_modules/~generator/init.js") {
88
- console.log("\x1b[31m%s\x1b[0m", "Unexpected 'init' script in package.json!");
89
- return;
90
- }
91
- hasInit = true;
92
- }
93
- }
94
- }
95
- else {
96
- goalPackage.scripts = {};
97
- }
98
- if (!hasDev) {
99
- goalPackage.scripts["dev"] = "run-p dev:*";
100
- }
101
- try {
102
- for (var devScripts_1 = __values(devScripts), devScripts_1_1 = devScripts_1.next(); !devScripts_1_1.done; devScripts_1_1 = devScripts_1.next()) {
103
- var _b = __read(devScripts_1_1.value, 2), name_2 = _b[0], cmd = _b[1];
104
- goalPackage.scripts[name_2] = cmd;
105
- }
106
- }
107
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
108
- finally {
109
- try {
110
- if (devScripts_1_1 && !devScripts_1_1.done && (_a = devScripts_1.return)) _a.call(devScripts_1);
111
- }
112
- finally { if (e_1) throw e_1.error; }
113
- }
114
- if (!hasInit) {
115
- goalPackage.scripts["init"] = "link-module-alias && node node_modules/~generator/init.js";
116
- }
117
- // check module aliases
118
- var hasResource = false;
119
- var hasGenerator = false;
120
- if (goalPackage._moduleAliases) {
121
- for (var name_3 in goalPackage._moduleAliases) {
122
- if (name_3 == "~resource") {
123
- hasResource = true;
124
- }
125
- if (name_3 == "~generator") {
126
- hasGenerator = true;
127
- }
128
- }
129
- }
130
- else {
131
- goalPackage._moduleAliases = {};
132
- }
133
- if (!hasResource) {
134
- goalPackage._moduleAliases["~resource"] = "resource";
135
- }
136
- if (!hasGenerator) {
137
- goalPackage._moduleAliases["~generator"] = "node_modules/@shushishtok/tooltip_generator";
138
- }
139
- var origPackagePath = scriptPath + "package.json";
140
- if (fs.existsSync(origPackagePath)) {
141
- var origPackageRaw = fs.readFileSync(scriptPath + "package.json");
142
- var origPackage = JSON.parse(origPackageRaw.toString());
143
- if (!goalPackage.dependencies) {
144
- goalPackage.dependencies = {};
145
- }
146
- if (!goalPackage.devDependencies) {
147
- goalPackage.devDependencies = {};
148
- }
149
- origPackage.dependencies["@shushishtok/tooltip_generator"] = "latest";
150
- for (var name_4 in origPackage.devDependencies) {
151
- if (!goalPackage.devDependencies.hasOwnProperty(name_4) && !goalPackage.dependencies.hasOwnProperty(name_4)) {
152
- goalPackage.devDependencies[name_4] = origPackage.devDependencies[name_4];
153
- }
154
- }
155
- for (var name_5 in origPackage.dependencies) {
156
- if (!goalPackage.dependencies.hasOwnProperty(name_5) && !goalPackage.devDependencies.hasOwnProperty(name_5)) {
157
- goalPackage.dependencies[name_5] = origPackage.dependencies[name_5];
158
- }
159
- }
160
- }
161
- console.log("Creating backup of package.json...");
162
- fs.copyFileSync(rootPath + "package.json", rootPath + "backup_package.json");
163
- console.log("Adjusting package.json...");
164
- var data = JSON.stringify(goalPackage, undefined, 2);
165
- fs.writeFileSync(rootPath + "package.json", data);
166
- // copy the default package.json if there wasn't any previously
167
- }
168
- else {
169
- var copyPackage = scriptPath + "_package.json";
170
- if (fs.existsSync(copyPackage)) {
171
- console.log("Copying new package.json");
172
- fs.copyFileSync(copyPackage, rootPath + "package.json");
173
- }
174
- else {
175
- console.log("\x1b[31m%s\x1b[0m", "\nCouldn't find _package.json! Have you installed this module correctly?");
176
- return;
177
- }
178
- }
179
- console.log("Running final installation, please wait for the success message...");
180
- child.exec("npm install", {
181
- cwd: rootPath,
182
- }, function (err, stdout) {
183
- if (err) {
184
- console.log("\x1b[31m%s\x1b[0m", "Something went wrong...\n\n");
185
- console.log(err);
186
- }
187
- else {
188
- console.log("\x1b[32m%s\x1b[0m", "package.json adjustments successful!");
189
- }
190
- });
191
- }
192
- CheckPackage();
package/languages.js DELETED
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Language = void 0;
4
- var Language;
5
- (function (Language) {
6
- Language["None"] = "none";
7
- // Brazilian = 'brazilian',
8
- // Bulgarian = 'bulgarian',
9
- // Czech = 'czech',
10
- // Danish = 'danish',
11
- Language["English"] = "english";
12
- // Finnish = 'finnish',
13
- // French = `french`,
14
- // German = `german`,
15
- // Greek = 'greek',
16
- // Hungarian = 'hungarian',
17
- // Italian = 'italian',
18
- // Japanese = 'japanese',
19
- // Koreana = 'koreana',
20
- // Latam = 'latam',
21
- // Norwegian = `norwegian`,
22
- // Polish = 'polish',
23
- // Portuguese = `portuguese`,
24
- Language["Russian"] = "russian";
25
- Language["Schinese"] = "schinese";
26
- // Spanish = `spanish`,
27
- // Swedish = `swedish`,
28
- // TChinese = `tchinese`,
29
- // Thai = 'thai',
30
- // Turkish = 'turkish',
31
- // Ukrainian = 'ukrainian',
32
- // Vietnamese = `vietnamese`
33
- })(Language = exports.Language || (exports.Language = {}));
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GenerateLocalizationData = void 0;
4
- function GenerateLocalizationData() {
5
- // This section can be safely ignored, as it is only logic.
6
- //#region Localization logic
7
- // Arrays
8
- var Abilities = new Array();
9
- var Modifiers = new Array();
10
- var StandardTooltips = new Array();
11
- // Create object of arrays
12
- var localization_info = {
13
- AbilityArray: Abilities,
14
- ModifierArray: Modifiers,
15
- StandardArray: StandardTooltips,
16
- };
17
- //#endregion
18
- // Enter localization data below!
19
- StandardTooltips.push({
20
- classname: "Hello",
21
- name: "test"
22
- });
23
- // Return data to compiler
24
- return localization_info;
25
- }
26
- exports.GenerateLocalizationData = GenerateLocalizationData;
@@ -1,438 +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
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __values = (this && this.__values) || function(o) {
22
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
23
- if (m) return m.call(o);
24
- if (o && typeof o.length === "number") return {
25
- next: function () {
26
- if (o && i >= o.length) o = void 0;
27
- return { value: o && o[i++], done: !o };
28
- }
29
- };
30
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
31
- };
32
- var __read = (this && this.__read) || function (o, n) {
33
- var m = typeof Symbol === "function" && o[Symbol.iterator];
34
- if (!m) return o;
35
- var i = m.call(o), r, ar = [], e;
36
- try {
37
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
38
- }
39
- catch (error) { e = { error: error }; }
40
- finally {
41
- try {
42
- if (r && !r.done && (m = i["return"])) m.call(i);
43
- }
44
- finally { if (e) throw e.error; }
45
- }
46
- return ar;
47
- };
48
- Object.defineProperty(exports, "__esModule", { value: true });
49
- exports.LocalizationCompiler = void 0;
50
- var fs = __importStar(require("fs"));
51
- var path = __importStar(require("path"));
52
- var valve_kv_1 = require("valve-kv");
53
- var languages_1 = require("~resource/languages");
54
- var LocalizationCompiler = /** @class */ (function () {
55
- function LocalizationCompiler() {
56
- this.addon_filepath = path.join("node_modules/~resource", "addon_");
57
- this.filepath_format = ".txt";
58
- this.currentWrites = new Set();
59
- }
60
- // Helper functions
61
- LocalizationCompiler.prototype.TransformForLocalization = function (text, modifier) {
62
- if (modifier) {
63
- text = text.replace(/\{([^f]\w+)\}($|[^%])/g, "%d$1%$2");
64
- text = text.replace(/\{([^f]\w+)\}%/g, "%d$1%%%");
65
- text = text.replace(/\{f(\w+)\}($|[^%])/g, "%f$1%$2");
66
- text = text.replace(/\{f(\w+)\}%/g, "%f$1%%%");
67
- text = text.replace(/%\{([^f]\w+)\}/g, "%%%d$1%");
68
- text = text.replace(/%\{f(\w+)\}/g, "%%%f$1%");
69
- return text;
70
- }
71
- else {
72
- text = text.replace(/\{(\w*)}($|[^%])/g, "%$1%$2");
73
- text = text.replace(/\{(\w*)}%/g, "%$1%%%");
74
- text = text.replace(/%\{(\w*)}/g, "%%%$1%");
75
- return text;
76
- }
77
- };
78
- LocalizationCompiler.prototype.OnLocalizationDataChanged = function (allData) {
79
- var e_1, _a, e_2, _b;
80
- // console.log("Localization event fired");
81
- var Abilities = new Array();
82
- var Modifiers = new Array();
83
- var StandardTooltips = new Array();
84
- //let Talents: Array<HeroTalents> = new Array<HeroTalents>();
85
- var localization_info = {
86
- AbilityArray: Abilities,
87
- ModifierArray: Modifiers,
88
- StandardArray: StandardTooltips,
89
- };
90
- try {
91
- for (var _c = __values(Object.entries(allData)), _d = _c.next(); !_d.done; _d = _c.next()) {
92
- var _e = __read(_d.value, 2), key = _e[0], data = _e[1];
93
- if (data.AbilityArray) {
94
- Array.prototype.push.apply(Abilities, data.AbilityArray);
95
- }
96
- if (data.ModifierArray) {
97
- Array.prototype.push.apply(Modifiers, data.ModifierArray);
98
- }
99
- if (data.StandardArray) {
100
- Array.prototype.push.apply(StandardTooltips, data.StandardArray);
101
- }
102
- }
103
- }
104
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
105
- finally {
106
- try {
107
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
108
- }
109
- finally { if (e_1) throw e_1.error; }
110
- }
111
- // Generate information for every language
112
- var languages = Object.values(languages_1.Language).filter(function (v) { return typeof v !== "number"; });
113
- try {
114
- for (var languages_2 = __values(languages), languages_2_1 = languages_2.next(); !languages_2_1.done; languages_2_1 = languages_2.next()) {
115
- var language = languages_2_1.value;
116
- if (language !== languages_1.Language.None) {
117
- var tokens = this.GenerateContentStringForLanguage(language, localization_info);
118
- this.WriteContentToAddonFile(language, tokens);
119
- }
120
- }
121
- }
122
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
123
- finally {
124
- try {
125
- if (languages_2_1 && !languages_2_1.done && (_b = languages_2.return)) _b.call(languages_2);
126
- }
127
- finally { if (e_2) throw e_2.error; }
128
- }
129
- };
130
- LocalizationCompiler.prototype.GenerateContentStringForLanguage = function (language, localized_data) {
131
- var e_3, _a, e_4, _b, e_5, _c, e_6, _d, e_7, _e, e_8, _f, e_9, _g, e_10, _h;
132
- var tokens = {};
133
- // Go over standard tooltips
134
- if (localized_data.StandardArray) {
135
- try {
136
- for (var _j = __values(localized_data.StandardArray), _k = _j.next(); !_k.done; _k = _j.next()) {
137
- var standardLocalization = _k.value;
138
- // Check for name override for the language we're checking
139
- var standard_tooltip_string = standardLocalization.name;
140
- if (standardLocalization.language_overrides && standardLocalization.language_overrides.length > 0) {
141
- try {
142
- for (var _l = (e_4 = void 0, __values(standardLocalization.language_overrides)), _m = _l.next(); !_m.done; _m = _l.next()) {
143
- var language_override = _m.value;
144
- if (language_override.language === language) {
145
- standard_tooltip_string = language_override.name_override;
146
- }
147
- }
148
- }
149
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
150
- finally {
151
- try {
152
- if (_m && !_m.done && (_b = _l.return)) _b.call(_l);
153
- }
154
- finally { if (e_4) throw e_4.error; }
155
- }
156
- }
157
- tokens[standardLocalization.classname] = standard_tooltip_string;
158
- }
159
- }
160
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
161
- finally {
162
- try {
163
- if (_k && !_k.done && (_a = _j.return)) _a.call(_j);
164
- }
165
- finally { if (e_3) throw e_3.error; }
166
- }
167
- }
168
- // Go over abilities for this language
169
- if (localized_data.AbilityArray) {
170
- try {
171
- for (var _o = __values(localized_data.AbilityArray), _p = _o.next(); !_p.done; _p = _o.next()) {
172
- var ability = _p.value;
173
- // Class name is identical for all languages, so we would always use it
174
- var ability_string = "DOTA_Tooltip_Ability_" + ability.ability_classname;
175
- // Name
176
- var ability_name = ability.name;
177
- var ability_description = ability.description;
178
- //let reimagined_effects = ability.reimagined_effects;
179
- var ability_lore = ability.lore;
180
- var ability_notes = ability.notes;
181
- var scepter_description = ability.scepter_description;
182
- var shard_description = ability.shard_description;
183
- var ability_specials = ability.ability_specials;
184
- if (ability.language_overrides) {
185
- try {
186
- for (var _q = (e_6 = void 0, __values(ability.language_overrides)), _r = _q.next(); !_r.done; _r = _q.next()) {
187
- var language_override = _r.value;
188
- if (language_override.language === language) {
189
- // Check for name override
190
- if (language_override.name_override) {
191
- ability_name = language_override.name_override;
192
- }
193
- // Check for description overrides
194
- if (language_override.description_override) {
195
- ability_description = language_override.description_override;
196
- }
197
- // Check for reimagined effect overrides
198
- //if (language_override.reimagined_effects_override)
199
- //{
200
- //reimagined_effects = language_override.reimagined_effects_override;
201
- //}
202
- // Check for lore override
203
- if (language_override.lore_override) {
204
- ability_lore = language_override.lore_override;
205
- }
206
- // Check for note override
207
- if (language_override.notes_override) {
208
- ability_notes = language_override.notes_override;
209
- }
210
- // Check for scepter override
211
- if (language_override.scepter_description_override) {
212
- scepter_description = language_override.scepter_description_override;
213
- }
214
- // Check for shard override
215
- if (language_override.shard_description_override) {
216
- shard_description = language_override.shard_description_override;
217
- }
218
- // Check for ability specials override, if any
219
- if (language_override.ability_specials_override) {
220
- ability_specials = language_override.ability_specials_override;
221
- }
222
- }
223
- }
224
- }
225
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
226
- finally {
227
- try {
228
- if (_r && !_r.done && (_d = _q.return)) _d.call(_q);
229
- }
230
- finally { if (e_6) throw e_6.error; }
231
- }
232
- }
233
- // Add name localization
234
- if (ability_name) {
235
- tokens[ability_string] = ability_name;
236
- }
237
- // Add description localization
238
- if (ability_description) {
239
- ability_description = this.TransformForLocalization(ability_description, false);
240
- tokens[ability_string + "_description"] = ability_description;
241
- }
242
- // Lore, if any
243
- if (ability_lore) {
244
- var transformed_lore = this.TransformForLocalization(ability_lore, false);
245
- tokens[ability_string + "_Lore"] = transformed_lore;
246
- }
247
- // Notes, if any
248
- if (ability_notes) {
249
- var counter = 0;
250
- try {
251
- for (var ability_notes_1 = (e_7 = void 0, __values(ability_notes)), ability_notes_1_1 = ability_notes_1.next(); !ability_notes_1_1.done; ability_notes_1_1 = ability_notes_1.next()) {
252
- var note = ability_notes_1_1.value;
253
- var transformed_note = this.TransformForLocalization(note, false);
254
- tokens[ability_string + "_Note" + counter] = transformed_note;
255
- counter++;
256
- }
257
- }
258
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
259
- finally {
260
- try {
261
- if (ability_notes_1_1 && !ability_notes_1_1.done && (_e = ability_notes_1.return)) _e.call(ability_notes_1);
262
- }
263
- finally { if (e_7) throw e_7.error; }
264
- }
265
- }
266
- // Scepter, if any
267
- if (scepter_description) {
268
- var ability_scepter_description = this.TransformForLocalization(scepter_description, false);
269
- tokens[ability_string + "_scepter_description"] = ability_scepter_description;
270
- }
271
- // Shard, if any
272
- if (shard_description) {
273
- var ability_shard_description = this.TransformForLocalization(shard_description, false);
274
- tokens[ability_string + "_shard_description"] = ability_shard_description;
275
- }
276
- // Ability specials, if any
277
- if (ability_specials) {
278
- try {
279
- for (var ability_specials_1 = (e_8 = void 0, __values(ability_specials)), ability_specials_1_1 = ability_specials_1.next(); !ability_specials_1_1.done; ability_specials_1_1 = ability_specials_1.next()) {
280
- var ability_special = ability_specials_1_1.value;
281
- // Construct the ability special
282
- var ability_special_text = "";
283
- if (ability_special.percentage) {
284
- ability_special_text = "%";
285
- }
286
- else if (ability_special.item_stat) {
287
- ability_special_text = "+$";
288
- }
289
- ability_special_text += ability_special.text;
290
- tokens[ability_string + "_" + ability_special.ability_special] = ability_special_text;
291
- }
292
- }
293
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
294
- finally {
295
- try {
296
- if (ability_specials_1_1 && !ability_specials_1_1.done && (_f = ability_specials_1.return)) _f.call(ability_specials_1);
297
- }
298
- finally { if (e_8) throw e_8.error; }
299
- }
300
- }
301
- }
302
- }
303
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
304
- finally {
305
- try {
306
- if (_p && !_p.done && (_c = _o.return)) _c.call(_o);
307
- }
308
- finally { if (e_5) throw e_5.error; }
309
- }
310
- }
311
- // Go over modifiers
312
- if (localized_data.ModifierArray) {
313
- try {
314
- for (var _s = __values(localized_data.ModifierArray), _t = _s.next(); !_t.done; _t = _s.next()) {
315
- var modifier = _t.value;
316
- var modifier_string = "DOTA_Tooltip_" + modifier.modifier_classname;
317
- // Name
318
- var modifier_name = modifier.name;
319
- var modifier_description = modifier.description;
320
- if (modifier.language_overrides) {
321
- try {
322
- for (var _u = (e_10 = void 0, __values(modifier.language_overrides)), _v = _u.next(); !_v.done; _v = _u.next()) {
323
- var language_override = _v.value;
324
- if (language_override.language === language) {
325
- // Name overrides for a specific language, if necessary
326
- if (language_override.name_override) {
327
- modifier_name = language_override.name_override;
328
- }
329
- // Description overrides for a specific language, if necessary
330
- if (language_override.description_override) {
331
- modifier_description = language_override.description_override;
332
- }
333
- }
334
- }
335
- }
336
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
337
- finally {
338
- try {
339
- if (_v && !_v.done && (_h = _u.return)) _h.call(_u);
340
- }
341
- finally { if (e_10) throw e_10.error; }
342
- }
343
- }
344
- // Add name to localization string
345
- if (modifier_name) {
346
- tokens[modifier_string] = modifier_name;
347
- }
348
- // Add description to localization string
349
- if (modifier_description) {
350
- modifier_description = this.TransformForLocalization(modifier_description, true);
351
- tokens[modifier_string + "_description"] = modifier_description;
352
- }
353
- }
354
- }
355
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
356
- finally {
357
- try {
358
- if (_t && !_t.done && (_g = _s.return)) _g.call(_s);
359
- }
360
- finally { if (e_9) throw e_9.error; }
361
- }
362
- }
363
- return tokens;
364
- };
365
- LocalizationCompiler.prototype.WriteContentToAddonFile = function (language, tokens) {
366
- var _this = this;
367
- // Set based on language
368
- var filepath = this.addon_filepath + language.toString() + this.filepath_format;
369
- // Add the opening tokens
370
- var kv = { lang: { Language: language, Tokens: tokens } };
371
- // Serialize!
372
- var write_string = valve_kv_1.serialize(kv);
373
- // Try writing if the output is not busy
374
- this.TryWriting(filepath, write_string, function () {
375
- // Prepare the output
376
- _this.currentWrites.add(language);
377
- if (_this.writeTimeout) {
378
- clearTimeout(_this.writeTimeout);
379
- }
380
- _this.writeTimeout = setTimeout(function () { return _this.FinishWrite(); }, 500);
381
- });
382
- };
383
- LocalizationCompiler.prototype.TryWriting = function (filepath, write_string, success, tries) {
384
- var _this = this;
385
- if (tries === void 0) { tries = 0; }
386
- if (tries > 5) {
387
- console.log("\x1b[31m%s\x1b[0m", "Tried too many times to write without success!");
388
- return;
389
- }
390
- try {
391
- // Remove file contents, or create a fresh one if it doesn't exists yet.
392
- var fd = fs.openSync(filepath, 'w');
393
- fs.closeSync(fd);
394
- // Write to the file
395
- fs.writeFileSync(filepath, write_string);
396
- }
397
- catch (_a) {
398
- // try again after a short time
399
- setTimeout(function () { return _this.TryWriting(filepath, write_string, success, tries + 1); }, 1000);
400
- return;
401
- }
402
- success();
403
- };
404
- // Print the output
405
- LocalizationCompiler.prototype.FinishWrite = function () {
406
- var e_11, _a;
407
- if (this.currentWrites.size === 0)
408
- return;
409
- var languages = [];
410
- try {
411
- for (var _b = __values(this.currentWrites.values()), _c = _b.next(); !_c.done; _c = _b.next()) {
412
- var language = _c.value;
413
- languages.push(language);
414
- }
415
- }
416
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
417
- finally {
418
- try {
419
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
420
- }
421
- finally { if (e_11) throw e_11.error; }
422
- }
423
- this.currentWrites.clear();
424
- var languageText = languages[0];
425
- if (languages.length > 1) {
426
- var lastLang = languages.splice(-1)[0];
427
- var otherLangs = languages.join(", ");
428
- if (otherLangs !== "") {
429
- languageText = otherLangs;
430
- }
431
- languageText += " and " + lastLang;
432
- }
433
- console.log("Finished writing tooltips for " + languageText);
434
- console.log("");
435
- };
436
- return LocalizationCompiler;
437
- }());
438
- exports.LocalizationCompiler = LocalizationCompiler;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });