@notask/unity-cli-tools 1.1.2 → 2.0.0

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.
Files changed (58) hide show
  1. package/.claude/settings.local.json +7 -0
  2. package/CHANGELOG.md +164 -146
  3. package/LICENSE +23 -23
  4. package/README.md +809 -347
  5. package/dist/cjs/errors/Result.js +76 -0
  6. package/dist/cjs/errors/UnityError.js +77 -0
  7. package/dist/cjs/errors/index.js +18 -0
  8. package/dist/cjs/events/hubEventEmitter.js +16 -16
  9. package/dist/cjs/events/hubEventParser.js +97 -27
  10. package/dist/cjs/events/patterns/implementations/bracketModulePattern.js +57 -0
  11. package/dist/cjs/events/patterns/implementations/errorPattern.js +99 -0
  12. package/dist/cjs/events/patterns/implementations/fallbackPattern.js +63 -0
  13. package/dist/cjs/events/patterns/implementations/index.js +9 -0
  14. package/dist/cjs/events/patterns/index.js +23 -0
  15. package/dist/cjs/events/patterns/patternRegistry.js +69 -0
  16. package/dist/cjs/events/patterns/statusNormalizer.js +280 -0
  17. package/dist/cjs/events/patterns/types.js +2 -0
  18. package/dist/cjs/index.js +7 -6
  19. package/dist/cjs/unityEditor.js +162 -194
  20. package/dist/cjs/unityHub.js +82 -78
  21. package/dist/cjs/utils/commandExecutor.js +8 -9
  22. package/dist/esm/errors/Result.d.ts +21 -0
  23. package/dist/esm/errors/Result.js +63 -0
  24. package/dist/esm/errors/UnityError.d.ts +36 -0
  25. package/dist/esm/errors/UnityError.js +64 -0
  26. package/dist/esm/errors/index.d.ts +2 -0
  27. package/dist/esm/errors/index.js +2 -0
  28. package/dist/esm/events/hubEventEmitter.d.ts +1 -1
  29. package/dist/esm/events/hubEventParser.d.ts +17 -3
  30. package/dist/esm/events/hubEventParser.js +97 -27
  31. package/dist/esm/events/patterns/implementations/bracketModulePattern.d.ts +11 -0
  32. package/dist/esm/events/patterns/implementations/bracketModulePattern.js +53 -0
  33. package/dist/esm/events/patterns/implementations/errorPattern.d.ts +22 -0
  34. package/dist/esm/events/patterns/implementations/errorPattern.js +95 -0
  35. package/dist/esm/events/patterns/implementations/fallbackPattern.d.ts +13 -0
  36. package/dist/esm/events/patterns/implementations/fallbackPattern.js +59 -0
  37. package/dist/esm/events/patterns/implementations/index.d.ts +3 -0
  38. package/dist/esm/events/patterns/implementations/index.js +3 -0
  39. package/dist/esm/events/patterns/index.d.ts +4 -0
  40. package/dist/esm/events/patterns/index.js +4 -0
  41. package/dist/esm/events/patterns/patternRegistry.d.ts +14 -0
  42. package/dist/esm/events/patterns/patternRegistry.js +65 -0
  43. package/dist/esm/events/patterns/statusNormalizer.d.ts +15 -0
  44. package/dist/esm/events/patterns/statusNormalizer.js +276 -0
  45. package/dist/esm/events/patterns/types.d.ts +30 -0
  46. package/dist/esm/events/patterns/types.js +1 -0
  47. package/dist/esm/index.d.ts +5 -4
  48. package/dist/esm/index.js +1 -0
  49. package/dist/esm/unityEditor.d.ts +11 -13
  50. package/dist/esm/unityEditor.js +175 -207
  51. package/dist/esm/unityHub.d.ts +12 -11
  52. package/dist/esm/unityHub.js +80 -76
  53. package/dist/esm/utils/commandExecutor.d.ts +4 -3
  54. package/dist/esm/utils/commandExecutor.js +8 -9
  55. package/package.json +70 -70
  56. package/sandbox/index.js +51 -0
  57. package/sandbox/node_modules/.package-lock.json +10495 -0
  58. package/sandbox/package.json +13 -0
@@ -0,0 +1,53 @@
1
+ import { InstallerStatus } from "../../../types/unity.js";
2
+ export class BracketModulePattern {
3
+ name = "BracketModulePattern";
4
+ priority = 80;
5
+ locale;
6
+ statusNormalizer;
7
+ pattern = /^\s*[\[\(]([^\]\)]+)[\]\)]\s+(.+?)(?:\s+(\d+(?:\.\d+)?)\s*%)?\.{0,3}\s*$/;
8
+ constructor(statusNormalizer, locale) {
9
+ this.statusNormalizer = statusNormalizer;
10
+ this.locale = locale;
11
+ }
12
+ match(line, locale) {
13
+ const trimmedLine = line.trim();
14
+ if (!trimmedLine) {
15
+ return null;
16
+ }
17
+ const match = trimmedLine.match(this.pattern);
18
+ if (!match) {
19
+ return null;
20
+ }
21
+ const [, moduleName, statusText, progressStr] = match;
22
+ if (!moduleName || !statusText) {
23
+ return null;
24
+ }
25
+ const effectiveLocale = locale || this.locale;
26
+ const normalizedStatus = this.statusNormalizer.normalize(statusText, effectiveLocale);
27
+ if (!normalizedStatus) {
28
+ return {
29
+ module: moduleName.trim(),
30
+ status: statusText.trim(),
31
+ progress: progressStr ? parseFloat(progressStr) : null,
32
+ confidence: 40,
33
+ };
34
+ }
35
+ let progress = null;
36
+ if (progressStr) {
37
+ const parsed = parseFloat(progressStr);
38
+ if (!isNaN(parsed) && parsed >= 0 && parsed <= 100) {
39
+ progress = parsed;
40
+ }
41
+ }
42
+ else if (normalizedStatus === InstallerStatus.Downloading ||
43
+ normalizedStatus === InstallerStatus.Installing) {
44
+ progress = 0;
45
+ }
46
+ return {
47
+ module: moduleName.trim(),
48
+ status: normalizedStatus,
49
+ progress,
50
+ confidence: 85,
51
+ };
52
+ }
53
+ }
@@ -0,0 +1,22 @@
1
+ import { Pattern, PatternMatch } from "../types.js";
2
+ declare enum ErrorSeverity {
3
+ Critical = "critical",
4
+ Error = "error",
5
+ Warning = "warning"
6
+ }
7
+ export declare class ErrorPattern implements Pattern {
8
+ readonly name = "ErrorPattern";
9
+ readonly priority = 90;
10
+ readonly locale?: string;
11
+ private criticalPatterns;
12
+ private errorPatterns;
13
+ private warningPatterns;
14
+ private localizedErrorPatterns;
15
+ constructor(locale?: string);
16
+ match(line: string, locale?: string): PatternMatch | null;
17
+ private matchesAnyPattern;
18
+ private createErrorMatch;
19
+ addErrorPattern(pattern: RegExp, severity?: ErrorSeverity): void;
20
+ addLocalizedPatterns(locale: string, patterns: RegExp[]): void;
21
+ }
22
+ export {};
@@ -0,0 +1,95 @@
1
+ import { InstallerStatus } from "../../../types/unity.js";
2
+ var ErrorSeverity;
3
+ (function (ErrorSeverity) {
4
+ ErrorSeverity["Critical"] = "critical";
5
+ ErrorSeverity["Error"] = "error";
6
+ ErrorSeverity["Warning"] = "warning";
7
+ })(ErrorSeverity || (ErrorSeverity = {}));
8
+ export class ErrorPattern {
9
+ name = "ErrorPattern";
10
+ priority = 90;
11
+ locale;
12
+ criticalPatterns = [
13
+ /\b(?:fatal|critical|emergency)\b/i,
14
+ /\bexception\b/i,
15
+ /\bstack\s*trace\b/i,
16
+ /\bcrash(?:ed)?\b/i,
17
+ ];
18
+ errorPatterns = [
19
+ /\berror\s*:/i,
20
+ /\berror\b/i,
21
+ /\bfailed\b/i,
22
+ /\bcannot\b/i,
23
+ /\bunable\s+to\b/i,
24
+ /\bcould\s+not\b/i,
25
+ /\bfailure\b/i,
26
+ ];
27
+ warningPatterns = [/\bwarning\s*:/i, /\bwarning\b/i, /\bcaution\b/i];
28
+ localizedErrorPatterns = new Map([
29
+ ["ja", [/エラー/, /失敗/, /例外/, /できません/]],
30
+ ["de", [/fehler/i, /fehlgeschlagen/i, /ausnahme/i, /kann\s+nicht/i]],
31
+ ["fr", [/erreur/i, /échec/i, /échoué/i, /exception/i, /impossible/i]],
32
+ ["es", [/error/i, /fallo/i, /fallido/i, /excepción/i, /no\s+se\s+puede/i]],
33
+ ["zh-Hans", [/错误/, /失败/, /异常/, /无法/]],
34
+ ["zh-Hant", [/錯誤/, /失敗/, /異常/, /無法/]],
35
+ ["ko", [/오류/, /실패/, /예외/, /할\s*수\s*없습니다/]],
36
+ ]);
37
+ constructor(locale) {
38
+ this.locale = locale;
39
+ }
40
+ match(line, locale) {
41
+ const trimmedLine = line.trim();
42
+ if (!trimmedLine) {
43
+ return null;
44
+ }
45
+ const effectiveLocale = locale || this.locale;
46
+ if (this.matchesAnyPattern(trimmedLine, this.criticalPatterns)) {
47
+ return this.createErrorMatch(trimmedLine, ErrorSeverity.Critical, 95);
48
+ }
49
+ if (this.matchesAnyPattern(trimmedLine, this.errorPatterns)) {
50
+ return this.createErrorMatch(trimmedLine, ErrorSeverity.Error, 90);
51
+ }
52
+ if (effectiveLocale && this.localizedErrorPatterns.has(effectiveLocale)) {
53
+ const patterns = this.localizedErrorPatterns.get(effectiveLocale);
54
+ if (this.matchesAnyPattern(trimmedLine, patterns)) {
55
+ return this.createErrorMatch(trimmedLine, ErrorSeverity.Error, 88);
56
+ }
57
+ }
58
+ if (this.matchesAnyPattern(trimmedLine, this.warningPatterns)) {
59
+ return this.createErrorMatch(trimmedLine, ErrorSeverity.Warning, 70);
60
+ }
61
+ return null;
62
+ }
63
+ matchesAnyPattern(line, patterns) {
64
+ return patterns.some((pattern) => pattern.test(line));
65
+ }
66
+ createErrorMatch(line, severity, confidence) {
67
+ const bracketMatch = line.match(/^\s*[\[\(]([^\]\)]+)[\]\)]/);
68
+ const module = bracketMatch ? bracketMatch[1].trim() : "UnityHub";
69
+ return {
70
+ module,
71
+ status: InstallerStatus.Error,
72
+ error: line.trim(),
73
+ confidence,
74
+ };
75
+ }
76
+ addErrorPattern(pattern, severity = ErrorSeverity.Error) {
77
+ switch (severity) {
78
+ case ErrorSeverity.Critical:
79
+ this.criticalPatterns.push(pattern);
80
+ break;
81
+ case ErrorSeverity.Error:
82
+ this.errorPatterns.push(pattern);
83
+ break;
84
+ case ErrorSeverity.Warning:
85
+ this.warningPatterns.push(pattern);
86
+ break;
87
+ }
88
+ }
89
+ addLocalizedPatterns(locale, patterns) {
90
+ if (!this.localizedErrorPatterns.has(locale)) {
91
+ this.localizedErrorPatterns.set(locale, []);
92
+ }
93
+ this.localizedErrorPatterns.get(locale).push(...patterns);
94
+ }
95
+ }
@@ -0,0 +1,13 @@
1
+ import { Pattern, PatternMatch } from "../types.js";
2
+ import { StatusNormalizer } from "../statusNormalizer.js";
3
+ export declare class FallbackPattern implements Pattern {
4
+ readonly name = "FallbackPattern";
5
+ readonly priority = 20;
6
+ readonly locale?: string;
7
+ private statusNormalizer;
8
+ constructor(statusNormalizer: StatusNormalizer, locale?: string);
9
+ match(line: string, locale?: string): PatternMatch | null;
10
+ private findStatusInLine;
11
+ private extractModuleName;
12
+ private escapeRegex;
13
+ }
@@ -0,0 +1,59 @@
1
+ export class FallbackPattern {
2
+ name = "FallbackPattern";
3
+ priority = 20;
4
+ locale;
5
+ statusNormalizer;
6
+ constructor(statusNormalizer, locale) {
7
+ this.statusNormalizer = statusNormalizer;
8
+ this.locale = locale;
9
+ }
10
+ match(line, locale) {
11
+ const trimmedLine = line.trim();
12
+ if (!trimmedLine) {
13
+ return null;
14
+ }
15
+ const effectiveLocale = locale || this.locale;
16
+ const progressMatch = trimmedLine.match(/(\d+(?:\.\d+)?)\s*%/);
17
+ const progress = progressMatch ? parseFloat(progressMatch[1]) : null;
18
+ const statusMatch = this.findStatusInLine(trimmedLine, effectiveLocale);
19
+ if (!statusMatch) {
20
+ return null;
21
+ }
22
+ const moduleName = this.extractModuleName(trimmedLine, statusMatch.statusText);
23
+ return {
24
+ module: moduleName || "Unknown",
25
+ status: statusMatch.status,
26
+ progress,
27
+ confidence: 30,
28
+ };
29
+ }
30
+ findStatusInLine(line, locale) {
31
+ const normalizations = this.statusNormalizer.getNormalizationsForLocale(locale);
32
+ const sortedNormalizations = Array.from(normalizations.entries()).sort((a, b) => b[0].length - a[0].length);
33
+ for (const [statusText, status] of sortedNormalizations) {
34
+ const pattern = new RegExp(`\\b${this.escapeRegex(statusText)}\\b`, "i");
35
+ if (pattern.test(line)) {
36
+ return { status, statusText };
37
+ }
38
+ }
39
+ return null;
40
+ }
41
+ extractModuleName(line, statusText) {
42
+ let cleanLine = line.replace(new RegExp(`\\b${this.escapeRegex(statusText)}\\b`, "gi"), "");
43
+ cleanLine = cleanLine.replace(/\d+(?:\.\d+)?\s*%/, "");
44
+ cleanLine = cleanLine.replace(/[:\-\[\]\(\)]/g, " ");
45
+ cleanLine = cleanLine.trim();
46
+ const words = cleanLine.split(/\s+/).filter((w) => w.length > 0);
47
+ if (words.length === 0) {
48
+ return null;
49
+ }
50
+ const capitalizedWords = words.filter((w) => /^[A-Z]/.test(w));
51
+ if (capitalizedWords.length > 0) {
52
+ return capitalizedWords.join(" ");
53
+ }
54
+ return words.join(" ");
55
+ }
56
+ escapeRegex(str) {
57
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
58
+ }
59
+ }
@@ -0,0 +1,3 @@
1
+ export { BracketModulePattern } from "./bracketModulePattern.js";
2
+ export { ErrorPattern } from "./errorPattern.js";
3
+ export { FallbackPattern } from "./fallbackPattern.js";
@@ -0,0 +1,3 @@
1
+ export { BracketModulePattern } from "./bracketModulePattern.js";
2
+ export { ErrorPattern } from "./errorPattern.js";
3
+ export { FallbackPattern } from "./fallbackPattern.js";
@@ -0,0 +1,4 @@
1
+ export * from "./types.js";
2
+ export { StatusNormalizer } from "./statusNormalizer.js";
3
+ export { PatternRegistry } from "./patternRegistry.js";
4
+ export * from "./implementations/index.js";
@@ -0,0 +1,4 @@
1
+ export * from "./types.js";
2
+ export { StatusNormalizer } from "./statusNormalizer.js";
3
+ export { PatternRegistry } from "./patternRegistry.js";
4
+ export * from "./implementations/index.js";
@@ -0,0 +1,14 @@
1
+ import { Pattern, PatternMatch } from "./types.js";
2
+ export declare class PatternRegistry {
3
+ private patterns;
4
+ register(pattern: Pattern): void;
5
+ registerAll(patterns: Pattern[]): void;
6
+ unregister(patternName: string): boolean;
7
+ getPatterns(locale?: string): Pattern[];
8
+ match(line: string, locale?: string, minConfidence?: number): PatternMatch | null;
9
+ matchAll(line: string, locale?: string): PatternMatch[];
10
+ getPatternNames(): string[];
11
+ clear(): void;
12
+ count(): number;
13
+ private sortPatterns;
14
+ }
@@ -0,0 +1,65 @@
1
+ export class PatternRegistry {
2
+ patterns = [];
3
+ register(pattern) {
4
+ this.patterns.push(pattern);
5
+ this.sortPatterns();
6
+ }
7
+ registerAll(patterns) {
8
+ this.patterns.push(...patterns);
9
+ this.sortPatterns();
10
+ }
11
+ unregister(patternName) {
12
+ const initialLength = this.patterns.length;
13
+ this.patterns = this.patterns.filter((p) => p.name !== patternName);
14
+ return this.patterns.length < initialLength;
15
+ }
16
+ getPatterns(locale) {
17
+ if (!locale) {
18
+ return [...this.patterns];
19
+ }
20
+ return this.patterns.filter((p) => !p.locale || p.locale === locale);
21
+ }
22
+ match(line, locale, minConfidence = 0) {
23
+ const applicablePatterns = this.getPatterns(locale);
24
+ for (const pattern of applicablePatterns) {
25
+ try {
26
+ const match = pattern.match(line, locale);
27
+ if (match && match.confidence >= minConfidence) {
28
+ return match;
29
+ }
30
+ }
31
+ catch (error) {
32
+ console.error(`Error in pattern "${pattern.name}":`, error);
33
+ }
34
+ }
35
+ return null;
36
+ }
37
+ matchAll(line, locale) {
38
+ const applicablePatterns = this.getPatterns(locale);
39
+ const matches = [];
40
+ for (const pattern of applicablePatterns) {
41
+ try {
42
+ const match = pattern.match(line, locale);
43
+ if (match) {
44
+ matches.push(match);
45
+ }
46
+ }
47
+ catch (error) {
48
+ console.error(`Error in pattern "${pattern.name}":`, error);
49
+ }
50
+ }
51
+ return matches.sort((a, b) => b.confidence - a.confidence);
52
+ }
53
+ getPatternNames() {
54
+ return this.patterns.map((p) => p.name);
55
+ }
56
+ clear() {
57
+ this.patterns = [];
58
+ }
59
+ count() {
60
+ return this.patterns.length;
61
+ }
62
+ sortPatterns() {
63
+ this.patterns.sort((a, b) => b.priority - a.priority);
64
+ }
65
+ }
@@ -0,0 +1,15 @@
1
+ import { InstallerStatus } from "../../types/unity.js";
2
+ import { StatusNormalization } from "./types.js";
3
+ export declare class StatusNormalizer {
4
+ private normalizations;
5
+ private localeNormalizations;
6
+ private unknownStatuses;
7
+ constructor();
8
+ private initializeDefaultNormalizations;
9
+ addNormalization(normalization: StatusNormalization): void;
10
+ normalize(statusText: string, locale?: string): InstallerStatus | null;
11
+ isKnownStatus(statusText: string, locale?: string): boolean;
12
+ getUnknownStatuses(): string[];
13
+ clearUnknownStatuses(): void;
14
+ getNormalizationsForLocale(locale?: string): Map<string, InstallerStatus>;
15
+ }
@@ -0,0 +1,276 @@
1
+ import { InstallerStatus } from "../../types/unity.js";
2
+ export class StatusNormalizer {
3
+ normalizations = new Map();
4
+ localeNormalizations = new Map();
5
+ unknownStatuses = new Set();
6
+ constructor() {
7
+ this.initializeDefaultNormalizations();
8
+ }
9
+ initializeDefaultNormalizations() {
10
+ this.addNormalization({
11
+ text: "queued for download",
12
+ status: InstallerStatus.Queued,
13
+ });
14
+ this.addNormalization({
15
+ text: "download queued",
16
+ status: InstallerStatus.Queued,
17
+ });
18
+ this.addNormalization({
19
+ text: "validating download",
20
+ status: InstallerStatus.Validating,
21
+ });
22
+ this.addNormalization({
23
+ text: "validating",
24
+ status: InstallerStatus.Validating,
25
+ });
26
+ this.addNormalization({
27
+ text: "in progress",
28
+ status: InstallerStatus.InProgress,
29
+ });
30
+ this.addNormalization({
31
+ text: "downloading",
32
+ status: InstallerStatus.Downloading,
33
+ });
34
+ this.addNormalization({
35
+ text: "download in progress",
36
+ status: InstallerStatus.Downloading,
37
+ });
38
+ this.addNormalization({
39
+ text: "queued for install",
40
+ status: InstallerStatus.QueuedInstall,
41
+ });
42
+ this.addNormalization({
43
+ text: "install queued",
44
+ status: InstallerStatus.QueuedInstall,
45
+ });
46
+ this.addNormalization({
47
+ text: "validation installation",
48
+ status: InstallerStatus.ValidatingInstall,
49
+ });
50
+ this.addNormalization({
51
+ text: "validating installation",
52
+ status: InstallerStatus.ValidatingInstall,
53
+ });
54
+ this.addNormalization({
55
+ text: "installing",
56
+ status: InstallerStatus.Installing,
57
+ });
58
+ this.addNormalization({
59
+ text: "install in progress",
60
+ status: InstallerStatus.Installing,
61
+ });
62
+ this.addNormalization({
63
+ text: "verifying",
64
+ status: InstallerStatus.Verifying,
65
+ });
66
+ this.addNormalization({
67
+ text: "installed successfully",
68
+ status: InstallerStatus.Installed,
69
+ });
70
+ this.addNormalization({
71
+ text: "installed",
72
+ status: InstallerStatus.Installed,
73
+ });
74
+ this.addNormalization({
75
+ text: "complete",
76
+ status: InstallerStatus.Installed,
77
+ });
78
+ this.addNormalization({
79
+ text: "completed",
80
+ status: InstallerStatus.Installed,
81
+ });
82
+ this.addNormalization({
83
+ text: "ダウンロード中",
84
+ status: InstallerStatus.Downloading,
85
+ locale: "ja",
86
+ });
87
+ this.addNormalization({
88
+ text: "インストール中",
89
+ status: InstallerStatus.Installing,
90
+ locale: "ja",
91
+ });
92
+ this.addNormalization({
93
+ text: "検証中",
94
+ status: InstallerStatus.Verifying,
95
+ locale: "ja",
96
+ });
97
+ this.addNormalization({
98
+ text: "完了",
99
+ status: InstallerStatus.Installed,
100
+ locale: "ja",
101
+ });
102
+ this.addNormalization({
103
+ text: "wird heruntergeladen",
104
+ status: InstallerStatus.Downloading,
105
+ locale: "de",
106
+ });
107
+ this.addNormalization({
108
+ text: "wird installiert",
109
+ status: InstallerStatus.Installing,
110
+ locale: "de",
111
+ });
112
+ this.addNormalization({
113
+ text: "wird überprüft",
114
+ status: InstallerStatus.Verifying,
115
+ locale: "de",
116
+ });
117
+ this.addNormalization({
118
+ text: "erfolgreich installiert",
119
+ status: InstallerStatus.Installed,
120
+ locale: "de",
121
+ });
122
+ this.addNormalization({
123
+ text: "téléchargement en cours",
124
+ status: InstallerStatus.Downloading,
125
+ locale: "fr",
126
+ });
127
+ this.addNormalization({
128
+ text: "installation en cours",
129
+ status: InstallerStatus.Installing,
130
+ locale: "fr",
131
+ });
132
+ this.addNormalization({
133
+ text: "vérification",
134
+ status: InstallerStatus.Verifying,
135
+ locale: "fr",
136
+ });
137
+ this.addNormalization({
138
+ text: "installé avec succès",
139
+ status: InstallerStatus.Installed,
140
+ locale: "fr",
141
+ });
142
+ this.addNormalization({
143
+ text: "descargando",
144
+ status: InstallerStatus.Downloading,
145
+ locale: "es",
146
+ });
147
+ this.addNormalization({
148
+ text: "instalando",
149
+ status: InstallerStatus.Installing,
150
+ locale: "es",
151
+ });
152
+ this.addNormalization({
153
+ text: "verificando",
154
+ status: InstallerStatus.Verifying,
155
+ locale: "es",
156
+ });
157
+ this.addNormalization({
158
+ text: "instalado correctamente",
159
+ status: InstallerStatus.Installed,
160
+ locale: "es",
161
+ });
162
+ this.addNormalization({
163
+ text: "正在下载",
164
+ status: InstallerStatus.Downloading,
165
+ locale: "zh-Hans",
166
+ });
167
+ this.addNormalization({
168
+ text: "正在安装",
169
+ status: InstallerStatus.Installing,
170
+ locale: "zh-Hans",
171
+ });
172
+ this.addNormalization({
173
+ text: "正在验证",
174
+ status: InstallerStatus.Verifying,
175
+ locale: "zh-Hans",
176
+ });
177
+ this.addNormalization({
178
+ text: "安装成功",
179
+ status: InstallerStatus.Installed,
180
+ locale: "zh-Hans",
181
+ });
182
+ this.addNormalization({
183
+ text: "正在下載",
184
+ status: InstallerStatus.Downloading,
185
+ locale: "zh-Hant",
186
+ });
187
+ this.addNormalization({
188
+ text: "正在安裝",
189
+ status: InstallerStatus.Installing,
190
+ locale: "zh-Hant",
191
+ });
192
+ this.addNormalization({
193
+ text: "正在驗證",
194
+ status: InstallerStatus.Verifying,
195
+ locale: "zh-Hant",
196
+ });
197
+ this.addNormalization({
198
+ text: "安裝成功",
199
+ status: InstallerStatus.Installed,
200
+ locale: "zh-Hant",
201
+ });
202
+ this.addNormalization({
203
+ text: "다운로드 중",
204
+ status: InstallerStatus.Downloading,
205
+ locale: "ko",
206
+ });
207
+ this.addNormalization({
208
+ text: "설치 중",
209
+ status: InstallerStatus.Installing,
210
+ locale: "ko",
211
+ });
212
+ this.addNormalization({
213
+ text: "확인 중",
214
+ status: InstallerStatus.Verifying,
215
+ locale: "ko",
216
+ });
217
+ this.addNormalization({
218
+ text: "설치 완료",
219
+ status: InstallerStatus.Installed,
220
+ locale: "ko",
221
+ });
222
+ }
223
+ addNormalization(normalization) {
224
+ const key = normalization.text.toLowerCase().trim();
225
+ if (normalization.locale) {
226
+ if (!this.localeNormalizations.has(normalization.locale)) {
227
+ this.localeNormalizations.set(normalization.locale, new Map());
228
+ }
229
+ this.localeNormalizations.get(normalization.locale).set(key, normalization.status);
230
+ }
231
+ else {
232
+ this.normalizations.set(key, normalization.status);
233
+ }
234
+ }
235
+ normalize(statusText, locale) {
236
+ const cleanText = statusText.toLowerCase().trim();
237
+ if (locale && this.localeNormalizations.has(locale)) {
238
+ const localeMap = this.localeNormalizations.get(locale);
239
+ if (localeMap.has(cleanText)) {
240
+ return localeMap.get(cleanText);
241
+ }
242
+ }
243
+ if (this.normalizations.has(cleanText)) {
244
+ return this.normalizations.get(cleanText);
245
+ }
246
+ for (const enumValue of Object.values(InstallerStatus)) {
247
+ if (enumValue.toLowerCase() === cleanText) {
248
+ return enumValue;
249
+ }
250
+ }
251
+ this.unknownStatuses.add(statusText);
252
+ return null;
253
+ }
254
+ isKnownStatus(statusText, locale) {
255
+ return this.normalize(statusText, locale) !== null;
256
+ }
257
+ getUnknownStatuses() {
258
+ return Array.from(this.unknownStatuses);
259
+ }
260
+ clearUnknownStatuses() {
261
+ this.unknownStatuses.clear();
262
+ }
263
+ getNormalizationsForLocale(locale) {
264
+ if (!locale) {
265
+ return new Map(this.normalizations);
266
+ }
267
+ const result = new Map(this.normalizations);
268
+ if (this.localeNormalizations.has(locale)) {
269
+ const localeMap = this.localeNormalizations.get(locale);
270
+ for (const [key, value] of localeMap) {
271
+ result.set(key, value);
272
+ }
273
+ }
274
+ return result;
275
+ }
276
+ }
@@ -0,0 +1,30 @@
1
+ import { InstallerEvent, InstallerStatus } from "../../types/unity.js";
2
+ export interface PatternMatch {
3
+ module: string;
4
+ status: InstallerStatus;
5
+ progress?: number | null;
6
+ error?: string | null;
7
+ confidence: number;
8
+ }
9
+ export interface Pattern {
10
+ priority: number;
11
+ locale?: string;
12
+ name: string;
13
+ match(line: string, locale?: string): PatternMatch | null;
14
+ }
15
+ export interface StatusNormalization {
16
+ text: string;
17
+ status: InstallerStatus;
18
+ locale?: string;
19
+ }
20
+ export interface ParserConfig {
21
+ locale: string;
22
+ logUnknownStatuses: boolean;
23
+ minConfidence: number;
24
+ useFallbackPatterns: boolean;
25
+ }
26
+ export interface ParseResult {
27
+ events: InstallerEvent[];
28
+ unknownStatuses: string[];
29
+ unparsedLines: string[];
30
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
- export { default as UnityHub } from "./unityHub.ts";
2
- export { default as UnityEditor } from "./unityEditor.ts";
3
- export { UnityHubInstallerEvent } from "./events/hubEventEmitter.ts";
4
- export * from "./types/unity.ts";
1
+ export { default as UnityHub } from "./unityHub.js";
2
+ export { default as UnityEditor } from "./unityEditor.js";
3
+ export { UnityHubInstallerEvent } from "./events/hubEventEmitter.js";
4
+ export * from "./types/unity.js";
5
+ export * from "./errors/index.js";