@xivdyetools/core 1.3.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.
Files changed (103) hide show
  1. package/LICENSE +37 -0
  2. package/README.md +400 -0
  3. package/dist/constants/index.d.ts +56 -0
  4. package/dist/constants/index.d.ts.map +1 -0
  5. package/dist/constants/index.js +103 -0
  6. package/dist/constants/index.js.map +1 -0
  7. package/dist/data/colors_xiv.json +3130 -0
  8. package/dist/data/locales/de.json +231 -0
  9. package/dist/data/locales/en.json +231 -0
  10. package/dist/data/locales/fr.json +231 -0
  11. package/dist/data/locales/ja.json +231 -0
  12. package/dist/data/locales/ko.json +233 -0
  13. package/dist/data/locales/zh.json +233 -0
  14. package/dist/data/presets.json +390 -0
  15. package/dist/index.d.ts +16 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +18 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/services/APIService.d.ts +246 -0
  20. package/dist/services/APIService.d.ts.map +1 -0
  21. package/dist/services/APIService.js +499 -0
  22. package/dist/services/APIService.js.map +1 -0
  23. package/dist/services/ColorService.d.ts +146 -0
  24. package/dist/services/ColorService.d.ts.map +1 -0
  25. package/dist/services/ColorService.js +209 -0
  26. package/dist/services/ColorService.js.map +1 -0
  27. package/dist/services/DyeService.d.ts +230 -0
  28. package/dist/services/DyeService.d.ts.map +1 -0
  29. package/dist/services/DyeService.js +326 -0
  30. package/dist/services/DyeService.js.map +1 -0
  31. package/dist/services/LocalizationService.d.ts +338 -0
  32. package/dist/services/LocalizationService.d.ts.map +1 -0
  33. package/dist/services/LocalizationService.js +449 -0
  34. package/dist/services/LocalizationService.js.map +1 -0
  35. package/dist/services/PaletteService.d.ts +137 -0
  36. package/dist/services/PaletteService.d.ts.map +1 -0
  37. package/dist/services/PaletteService.js +349 -0
  38. package/dist/services/PaletteService.js.map +1 -0
  39. package/dist/services/PresetService.d.ts +196 -0
  40. package/dist/services/PresetService.d.ts.map +1 -0
  41. package/dist/services/PresetService.js +261 -0
  42. package/dist/services/PresetService.js.map +1 -0
  43. package/dist/services/color/ColorAccessibility.d.ts +39 -0
  44. package/dist/services/color/ColorAccessibility.d.ts.map +1 -0
  45. package/dist/services/color/ColorAccessibility.js +71 -0
  46. package/dist/services/color/ColorAccessibility.js.map +1 -0
  47. package/dist/services/color/ColorConverter.d.ts +146 -0
  48. package/dist/services/color/ColorConverter.d.ts.map +1 -0
  49. package/dist/services/color/ColorConverter.js +393 -0
  50. package/dist/services/color/ColorConverter.js.map +1 -0
  51. package/dist/services/color/ColorManipulator.d.ts +36 -0
  52. package/dist/services/color/ColorManipulator.d.ts.map +1 -0
  53. package/dist/services/color/ColorManipulator.js +56 -0
  54. package/dist/services/color/ColorManipulator.js.map +1 -0
  55. package/dist/services/color/ColorblindnessSimulator.d.ts +35 -0
  56. package/dist/services/color/ColorblindnessSimulator.d.ts.map +1 -0
  57. package/dist/services/color/ColorblindnessSimulator.js +110 -0
  58. package/dist/services/color/ColorblindnessSimulator.js.map +1 -0
  59. package/dist/services/dye/DyeDatabase.d.ts +131 -0
  60. package/dist/services/dye/DyeDatabase.d.ts.map +1 -0
  61. package/dist/services/dye/DyeDatabase.js +367 -0
  62. package/dist/services/dye/DyeDatabase.js.map +1 -0
  63. package/dist/services/dye/DyeSearch.d.ts +55 -0
  64. package/dist/services/dye/DyeSearch.d.ts.map +1 -0
  65. package/dist/services/dye/DyeSearch.js +196 -0
  66. package/dist/services/dye/DyeSearch.js.map +1 -0
  67. package/dist/services/dye/HarmonyGenerator.d.ts +110 -0
  68. package/dist/services/dye/HarmonyGenerator.d.ts.map +1 -0
  69. package/dist/services/dye/HarmonyGenerator.js +221 -0
  70. package/dist/services/dye/HarmonyGenerator.js.map +1 -0
  71. package/dist/services/localization/LocaleLoader.d.ts +38 -0
  72. package/dist/services/localization/LocaleLoader.d.ts.map +1 -0
  73. package/dist/services/localization/LocaleLoader.js +83 -0
  74. package/dist/services/localization/LocaleLoader.js.map +1 -0
  75. package/dist/services/localization/LocaleRegistry.d.ts +73 -0
  76. package/dist/services/localization/LocaleRegistry.d.ts.map +1 -0
  77. package/dist/services/localization/LocaleRegistry.js +84 -0
  78. package/dist/services/localization/LocaleRegistry.js.map +1 -0
  79. package/dist/services/localization/TranslationProvider.d.ts +157 -0
  80. package/dist/services/localization/TranslationProvider.d.ts.map +1 -0
  81. package/dist/services/localization/TranslationProvider.js +289 -0
  82. package/dist/services/localization/TranslationProvider.js.map +1 -0
  83. package/dist/types/index.d.ts +409 -0
  84. package/dist/types/index.d.ts.map +1 -0
  85. package/dist/types/index.js +87 -0
  86. package/dist/types/index.js.map +1 -0
  87. package/dist/types/logger.d.ts +84 -0
  88. package/dist/types/logger.d.ts.map +1 -0
  89. package/dist/types/logger.js +54 -0
  90. package/dist/types/logger.js.map +1 -0
  91. package/dist/utils/index.d.ts +441 -0
  92. package/dist/utils/index.d.ts.map +1 -0
  93. package/dist/utils/index.js +577 -0
  94. package/dist/utils/index.js.map +1 -0
  95. package/dist/utils/kd-tree.d.ts +76 -0
  96. package/dist/utils/kd-tree.d.ts.map +1 -0
  97. package/dist/utils/kd-tree.js +195 -0
  98. package/dist/utils/kd-tree.js.map +1 -0
  99. package/dist/version.d.ts +11 -0
  100. package/dist/version.d.ts.map +1 -0
  101. package/dist/version.js +11 -0
  102. package/dist/version.js.map +1 -0
  103. package/package.json +84 -0
@@ -0,0 +1,209 @@
1
+ /**
2
+ * @xivdyetools/core - Color Service
3
+ *
4
+ * Color conversion algorithms and colorblindness simulation.
5
+ * Provides utilities for converting between RGB, HSV, and hex color formats,
6
+ * calculating color distances, and simulating color vision deficiencies.
7
+ *
8
+ * Per R-4: Facade class that delegates to focused service classes
9
+ * Maintains backward compatibility while using split services internally
10
+ *
11
+ * @module services/ColorService
12
+ * @example
13
+ * ```typescript
14
+ * import { ColorService } from '@xivdyetools/core';
15
+ *
16
+ * // Convert hex to RGB
17
+ * const rgb = ColorService.hexToRgb('#FF0000');
18
+ * // { r: 255, g: 0, b: 0 }
19
+ *
20
+ * // Convert RGB to HSV
21
+ * const hsv = ColorService.rgbToHsv(rgb);
22
+ * // { h: 0, s: 100, v: 100 }
23
+ *
24
+ * // Calculate color distance
25
+ * const distance = ColorService.getColorDistance('#FF0000', '#00FF00');
26
+ * ```
27
+ */
28
+ import { ColorConverter } from './color/ColorConverter.js';
29
+ import { ColorblindnessSimulator } from './color/ColorblindnessSimulator.js';
30
+ import { ColorAccessibility } from './color/ColorAccessibility.js';
31
+ import { ColorManipulator } from './color/ColorManipulator.js';
32
+ /**
33
+ * Color conversion and manipulation service (Facade)
34
+ * Per R-4: Delegates to focused service classes for better separation of concerns
35
+ * Maintains backward compatibility with existing API
36
+ */
37
+ export class ColorService {
38
+ // ============================================================================
39
+ // Cache Management
40
+ // ============================================================================
41
+ /**
42
+ * Clear all caches (useful for testing or memory management)
43
+ */
44
+ static clearCaches() {
45
+ ColorConverter.clearCaches();
46
+ ColorblindnessSimulator.clearCache();
47
+ }
48
+ /**
49
+ * Get cache statistics (for monitoring)
50
+ */
51
+ static getCacheStats() {
52
+ const converterStats = ColorConverter.getCacheStats();
53
+ const simulatorStats = ColorblindnessSimulator.getCacheStats();
54
+ return {
55
+ ...converterStats,
56
+ colorblind: simulatorStats.colorblind,
57
+ };
58
+ }
59
+ // ============================================================================
60
+ // Color Conversion (delegated to ColorConverter)
61
+ // ============================================================================
62
+ /**
63
+ * Convert hexadecimal color to RGB
64
+ * @example hexToRgb("#FF0000") -> { r: 255, g: 0, b: 0 }
65
+ */
66
+ static hexToRgb(hex) {
67
+ return ColorConverter.hexToRgb(hex);
68
+ }
69
+ /**
70
+ * Convert RGB to hexadecimal color
71
+ * @example rgbToHex(255, 0, 0) -> "#FF0000"
72
+ */
73
+ static rgbToHex(r, g, b) {
74
+ return ColorConverter.rgbToHex(r, g, b);
75
+ }
76
+ /**
77
+ * Convert RGB to HSV
78
+ * @example rgbToHsv(255, 0, 0) -> { h: 0, s: 100, v: 100 }
79
+ */
80
+ static rgbToHsv(r, g, b) {
81
+ return ColorConverter.rgbToHsv(r, g, b);
82
+ }
83
+ /**
84
+ * Convert HSV to RGB
85
+ * @example hsvToRgb(0, 100, 100) -> { r: 255, g: 0, b: 0 }
86
+ */
87
+ static hsvToRgb(h, s, v) {
88
+ return ColorConverter.hsvToRgb(h, s, v);
89
+ }
90
+ /**
91
+ * Convert hex to HSV
92
+ */
93
+ static hexToHsv(hex) {
94
+ return ColorConverter.hexToHsv(hex);
95
+ }
96
+ /**
97
+ * Convert HSV to hex
98
+ */
99
+ static hsvToHex(h, s, v) {
100
+ return ColorConverter.hsvToHex(h, s, v);
101
+ }
102
+ /**
103
+ * Normalize a hex color to #RRGGBB format
104
+ */
105
+ static normalizeHex(hex) {
106
+ return ColorConverter.normalizeHex(hex);
107
+ }
108
+ /**
109
+ * Calculate Euclidean distance between two RGB colors
110
+ * Returns 0 for identical colors, ~441.67 for white vs black
111
+ */
112
+ static getColorDistance(hex1, hex2) {
113
+ return ColorConverter.getColorDistance(hex1, hex2);
114
+ }
115
+ // ============================================================================
116
+ // Colorblindness Simulation (delegated to ColorblindnessSimulator)
117
+ // ============================================================================
118
+ /**
119
+ * Simulate colorblindness on an RGB color
120
+ * @example simulateColorblindness({ r: 255, g: 0, b: 0 }, 'deuteranopia')
121
+ */
122
+ static simulateColorblindness(rgb, visionType) {
123
+ return ColorblindnessSimulator.simulateColorblindness(rgb, visionType);
124
+ }
125
+ /**
126
+ * Simulate colorblindness on a hex color
127
+ */
128
+ static simulateColorblindnessHex(hex, visionType) {
129
+ return ColorblindnessSimulator.simulateColorblindnessHex(hex, visionType);
130
+ }
131
+ // ============================================================================
132
+ // Color Accessibility (delegated to ColorAccessibility)
133
+ // ============================================================================
134
+ /**
135
+ * Calculate perceived luminance of a color (0-1)
136
+ * Uses relative luminance formula from WCAG
137
+ */
138
+ static getPerceivedLuminance(hex) {
139
+ return ColorAccessibility.getPerceivedLuminance(hex);
140
+ }
141
+ /**
142
+ * Calculate contrast ratio between two colors
143
+ * Returns 1 (no contrast) to 21 (maximum contrast)
144
+ */
145
+ static getContrastRatio(hex1, hex2) {
146
+ return ColorAccessibility.getContrastRatio(hex1, hex2);
147
+ }
148
+ /**
149
+ * Check if two colors meet WCAG AA contrast ratio
150
+ */
151
+ static meetsWCAGAA(hex1, hex2, largeText = false) {
152
+ return ColorAccessibility.meetsWCAGAA(hex1, hex2, largeText);
153
+ }
154
+ /**
155
+ * Check if two colors meet WCAG AAA contrast ratio
156
+ */
157
+ static meetsWCAGAAA(hex1, hex2, largeText = false) {
158
+ return ColorAccessibility.meetsWCAGAAA(hex1, hex2, largeText);
159
+ }
160
+ /**
161
+ * Check if a color is light (for determining text color on background)
162
+ */
163
+ static isLightColor(hex) {
164
+ return ColorAccessibility.isLightColor(hex);
165
+ }
166
+ /**
167
+ * Get optimal text color for a background color
168
+ */
169
+ static getOptimalTextColor(backgroundColor) {
170
+ return ColorAccessibility.getOptimalTextColor(backgroundColor);
171
+ }
172
+ // ============================================================================
173
+ // Color Manipulation (delegated to ColorManipulator)
174
+ // ============================================================================
175
+ /**
176
+ * Adjust brightness of a color
177
+ * @param amount -100 to 100 (negative = darker, positive = lighter)
178
+ */
179
+ static adjustBrightness(hex, amount) {
180
+ return ColorManipulator.adjustBrightness(hex, amount);
181
+ }
182
+ /**
183
+ * Adjust saturation of a color
184
+ * @param amount -100 to 100 (negative = less saturated, positive = more saturated)
185
+ */
186
+ static adjustSaturation(hex, amount) {
187
+ return ColorManipulator.adjustSaturation(hex, amount);
188
+ }
189
+ /**
190
+ * Rotate hue of a color
191
+ * @param degrees 0-360 (amount to rotate hue)
192
+ */
193
+ static rotateHue(hex, degrees) {
194
+ return ColorManipulator.rotateHue(hex, degrees);
195
+ }
196
+ /**
197
+ * Invert a color (create complementary color)
198
+ */
199
+ static invert(hex) {
200
+ return ColorManipulator.invert(hex);
201
+ }
202
+ /**
203
+ * Desaturate a color (convert to grayscale)
204
+ */
205
+ static desaturate(hex) {
206
+ return ColorManipulator.desaturate(hex);
207
+ }
208
+ }
209
+ //# sourceMappingURL=ColorService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorService.js","sourceRoot":"","sources":["../../src/services/ColorService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D;;;;GAIG;AACH,MAAM,OAAO,YAAY;IACvB,+EAA+E;IAC/E,mBAAmB;IACnB,+EAA+E;IAE/E;;OAEG;IACH,MAAM,CAAC,WAAW;QAChB,cAAc,CAAC,WAAW,EAAE,CAAC;QAC7B,uBAAuB,CAAC,UAAU,EAAE,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa;QAQlB,MAAM,cAAc,GAAG,cAAc,CAAC,aAAa,EAAE,CAAC;QACtD,MAAM,cAAc,GAAG,uBAAuB,CAAC,aAAa,EAAE,CAAC;QAC/D,OAAO;YACL,GAAG,cAAc;YACjB,UAAU,EAAE,cAAc,CAAC,UAAU;SACtC,CAAC;IACJ,CAAC;IAED,+EAA+E;IAC/E,iDAAiD;IACjD,+EAA+E;IAE/E;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,GAAW;QACzB,OAAO,cAAc,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;QAC7C,OAAO,cAAc,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,CAAS,EAA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AAO,gBAAgB,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,GAAW;QACvB,OAAO,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,UAAU,CAAC,GAAW;QAC3B,OAAO,gBAAgB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;CACF"}
@@ -0,0 +1,230 @@
1
+ /**
2
+ * @xivdyetools/core - Dye Service
3
+ *
4
+ * FFXIV dye database management and search.
5
+ * Provides access to the complete FFXIV dye database with search,
6
+ * matching, and color harmony generation capabilities.
7
+ *
8
+ * Per R-4: Facade class that delegates to focused service classes
9
+ * Maintains backward compatibility while using split services internally
10
+ *
11
+ * Environment-agnostic (Node.js + Browser).
12
+ *
13
+ * @module services/DyeService
14
+ * @example
15
+ * ```typescript
16
+ * import { DyeService, dyeDatabase } from '@xivdyetools/core';
17
+ *
18
+ * const dyeService = new DyeService(dyeDatabase);
19
+ *
20
+ * // Find closest dye to a color
21
+ * const closestDye = dyeService.findClosestDye('#FF0000');
22
+ *
23
+ * // Generate color harmonies
24
+ * const harmonies = dyeService.findTriadicDyes('#FF0000');
25
+ * ```
26
+ */
27
+ import type { Dye, LocalizedDye, Logger } from '../types/index.js';
28
+ /**
29
+ * Configuration options for DyeService
30
+ */
31
+ export interface DyeServiceOptions {
32
+ /**
33
+ * Logger for service operations (defaults to NoOpLogger)
34
+ */
35
+ logger?: Logger;
36
+ }
37
+ /**
38
+ * Service for managing FFXIV dye database (Facade)
39
+ * Per R-4: Delegates to focused service classes for better separation of concerns
40
+ * Maintains backward compatibility with existing API
41
+ *
42
+ * @example
43
+ * // Node.js
44
+ * import { DyeService, dyeDatabase } from '@xivdyetools/core';
45
+ * const dyeService = new DyeService(dyeDatabase);
46
+ *
47
+ * // Browser (Vite auto-imports JSON)
48
+ * import { DyeService, dyeDatabase } from '@xivdyetools/core';
49
+ * const dyeService = new DyeService(dyeDatabase);
50
+ *
51
+ * // With custom logger
52
+ * import { ConsoleLogger } from '@xivdyetools/core';
53
+ * const dyeService = new DyeService(dyeDatabase, { logger: ConsoleLogger });
54
+ */
55
+ export declare class DyeService {
56
+ private database;
57
+ private search;
58
+ private harmony;
59
+ /**
60
+ * Initialize the dye database
61
+ * @param dyeData - Array of dyes or JSON object with dye array
62
+ * @param options - Optional configuration including logger
63
+ */
64
+ constructor(dyeData?: unknown, options?: DyeServiceOptions);
65
+ /**
66
+ * Get all dyes (defensive copy)
67
+ */
68
+ getAllDyes(): Dye[];
69
+ /**
70
+ * Get dye by ID
71
+ */
72
+ getDyeById(id: number): Dye | null;
73
+ /**
74
+ * Get multiple dyes by IDs
75
+ */
76
+ getDyesByIds(ids: number[]): Dye[];
77
+ /**
78
+ * Check if database is loaded
79
+ */
80
+ isLoadedStatus(): boolean;
81
+ /**
82
+ * Get timestamp of last load
83
+ */
84
+ getLastLoadedTime(): number;
85
+ /**
86
+ * Get total dye count
87
+ */
88
+ getDyeCount(): number;
89
+ /**
90
+ * Get all unique categories
91
+ */
92
+ getCategories(): string[];
93
+ /**
94
+ * Search dyes by name (case-insensitive, partial match)
95
+ */
96
+ searchByName(query: string): Dye[];
97
+ /**
98
+ * Search dyes by category
99
+ */
100
+ searchByCategory(category: string): Dye[];
101
+ /**
102
+ * Filter dyes with optional exclusion list
103
+ */
104
+ filterDyes(filter?: {
105
+ category?: string;
106
+ excludeIds?: number[];
107
+ minPrice?: number;
108
+ maxPrice?: number;
109
+ }): Dye[];
110
+ /**
111
+ * Find closest dye to a given hex color
112
+ * Per P-7: Uses k-d tree for O(log n) average case vs O(n) linear search
113
+ */
114
+ findClosestDye(hex: string, excludeIds?: number[]): Dye | null;
115
+ /**
116
+ * Find dyes within a color distance threshold
117
+ * Per P-7: Uses k-d tree for efficient range queries
118
+ */
119
+ findDyesWithinDistance(hex: string, maxDistance: number, limit?: number): Dye[];
120
+ /**
121
+ * Get dyes sorted by brightness
122
+ */
123
+ getDyesSortedByBrightness(ascending?: boolean): Dye[];
124
+ /**
125
+ * Get dyes sorted by saturation
126
+ */
127
+ getDyesSortedBySaturation(ascending?: boolean): Dye[];
128
+ /**
129
+ * Get dyes sorted by hue
130
+ */
131
+ getDyesSortedByHue(ascending?: boolean): Dye[];
132
+ /**
133
+ * Find dyes that form a complementary color pair
134
+ */
135
+ findComplementaryPair(hex: string): Dye | null;
136
+ /**
137
+ * Find analogous dyes (adjacent on color wheel)
138
+ * Returns dyes at ±angle degrees from the base color
139
+ */
140
+ findAnalogousDyes(hex: string, angle?: number): Dye[];
141
+ /**
142
+ * Find triadic color scheme (colors 120° apart on color wheel)
143
+ */
144
+ findTriadicDyes(hex: string): Dye[];
145
+ /**
146
+ * Find square color scheme (colors 90° apart on color wheel)
147
+ */
148
+ findSquareDyes(hex: string): Dye[];
149
+ /**
150
+ * Find tetradic color scheme (two complementary pairs)
151
+ */
152
+ findTetradicDyes(hex: string): Dye[];
153
+ /**
154
+ * Find monochromatic dyes (same hue, varying saturation/brightness)
155
+ */
156
+ findMonochromaticDyes(hex: string, limit?: number): Dye[];
157
+ /**
158
+ * Find compound harmony (analogous + complementary)
159
+ */
160
+ findCompoundDyes(hex: string): Dye[];
161
+ /**
162
+ * Find split-complementary harmony (±30° from the complementary hue)
163
+ */
164
+ findSplitComplementaryDyes(hex: string): Dye[];
165
+ /**
166
+ * Find shades (similar tones, ±15°)
167
+ */
168
+ findShadesDyes(hex: string): Dye[];
169
+ /**
170
+ * Search dyes by name (searches both English + localized names)
171
+ * If no locale is loaded, falls back to English-only search
172
+ *
173
+ * @param query - Search query
174
+ * @returns Matching dyes
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * await LocalizationService.setLocale('ja');
179
+ * const results = dyeService.searchByLocalizedName('スノウ');
180
+ * // Finds "Snow White" (スノウホワイト)
181
+ * ```
182
+ */
183
+ searchByLocalizedName(query: string): Dye[];
184
+ /**
185
+ * Get dye by ID with localized name
186
+ * Returns Dye with localizedName property if locale loaded
187
+ *
188
+ * @param id - Dye ID
189
+ * @returns Localized dye or null if not found
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * const dye = dyeService.getLocalizedDyeById(5729);
194
+ * const displayName = dye.localizedName || dye.name;
195
+ * // "スノウホワイト" (ja) or "Snow White" (en)
196
+ * ```
197
+ */
198
+ getLocalizedDyeById(id: number): LocalizedDye | null;
199
+ /**
200
+ * Get all dyes with localized names
201
+ * Returns array of dyes with localizedName property if locale loaded
202
+ *
203
+ * @returns Array of localized dyes
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * await LocalizationService.setLocale('ja');
208
+ * const dyes = dyeService.getAllLocalizedDyes();
209
+ * dyes.forEach(dye => {
210
+ * console.log(dye.localizedName || dye.name);
211
+ * });
212
+ * ```
213
+ */
214
+ getAllLocalizedDyes(): LocalizedDye[];
215
+ /**
216
+ * Get all non-metallic dyes (locale-aware)
217
+ * Excludes dyes based on metallic dye IDs from current locale
218
+ *
219
+ * @returns Array of non-metallic dyes
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * // Works in any locale - correctly excludes metallic dyes
224
+ * const nonMetallic = dyeService.getNonMetallicDyes();
225
+ * // Excludes: Metallic Silver, Metallic Brass, etc.
226
+ * ```
227
+ */
228
+ getNonMetallicDyes(): Dye[];
229
+ }
230
+ //# sourceMappingURL=DyeService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DyeService.d.ts","sourceRoot":"","sources":["../../src/services/DyeService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAOnE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH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