@eaprelsky/nocturna-wheel 3.0.0 → 3.0.1

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.
@@ -83,47 +83,16 @@ class ServiceRegistry {
83
83
  }
84
84
 
85
85
  /**
86
- * Gets or creates an IconProvider instance
87
- * @param {string} basePath - Optional base path for SVG assets
88
- * @returns {Object} The IconProvider instance
86
+ * Gets the IconProvider instance
87
+ * NOTE: IconProvider should be registered externally before use
88
+ * This method only retrieves, does not create
89
+ * @returns {Object|undefined} The IconProvider instance if registered
89
90
  */
90
- static getIconProvider(basePath = './assets/svg/zodiac/') {
91
+ static getIconProvider() {
91
92
  if (!this.has('iconProvider')) {
92
- // Create a simple icon provider
93
- const iconProvider = {
94
- basePath: basePath,
95
-
96
- getPlanetIconPath(planetName) {
97
- return `${this.basePath}zodiac-planet-${planetName.toLowerCase()}.svg`;
98
- },
99
-
100
- getZodiacIconPath(signName) {
101
- return `${this.basePath}zodiac-sign-${signName.toLowerCase()}.svg`;
102
- },
103
-
104
- getAspectIconPath(aspectType) {
105
- return `${this.basePath}zodiac-aspect-${aspectType.toLowerCase()}.svg`;
106
- },
107
-
108
- createTextFallback(svgUtils, options, text) {
109
- const { x, y, size = '16px', color = '#000000', className = 'icon-fallback' } = options;
110
-
111
- const textElement = svgUtils.createSVGElement("text", {
112
- x: x,
113
- y: y,
114
- 'text-anchor': 'middle',
115
- 'dominant-baseline': 'middle',
116
- 'font-size': size,
117
- 'class': className,
118
- 'fill': color
119
- });
120
-
121
- textElement.textContent = text;
122
- return textElement;
123
- }
124
- };
125
-
126
- this.register('iconProvider', iconProvider);
93
+ console.warn('ServiceRegistry: IconProvider not registered. Icons may not work correctly.');
94
+ console.warn('ServiceRegistry: This should be initialized in main.js with inline IconData.');
95
+ return null;
127
96
  }
128
97
  return this.get('iconProvider');
129
98
  }
@@ -136,8 +105,8 @@ class ServiceRegistry {
136
105
  // Initialize SvgUtils
137
106
  this.getSvgUtils();
138
107
 
139
- // Initialize IconProvider with the assets base path
140
- this.getIconProvider(options.assetBasePath || './assets/svg/zodiac/');
108
+ // Note: IconProvider should be registered externally in main.js
109
+ // with inline IconData before calling this method
141
110
 
142
111
  console.log("ServiceRegistry: Core services initialized");
143
112
  }
@@ -153,17 +122,6 @@ class ServiceRegistry {
153
122
  * 2. External mode: Uses external file paths (for custom icons)
154
123
  */
155
124
 
156
- // Try to import IconData if available (after build)
157
- let InlineIconData = null;
158
- try {
159
- // This will be replaced by rollup during build
160
- // During development or if IconData doesn't exist, this will fail gracefully
161
- InlineIconData = null; // Will be set up after IconData.js is generated
162
- } catch (e) {
163
- // IconData not available yet
164
- InlineIconData = null;
165
- }
166
-
167
125
  class IconProvider {
168
126
  /**
169
127
  * Constructor
@@ -184,6 +142,9 @@ class IconProvider {
184
142
 
185
143
  // Lazy-load IconData on first use
186
144
  this.inlineData = null;
145
+
146
+ // Track if warning was already shown (to avoid spam)
147
+ this._warnedAboutMissingData = false;
187
148
  }
188
149
 
189
150
  /**
@@ -191,9 +152,6 @@ class IconProvider {
191
152
  * @private
192
153
  */
193
154
  _getInlineData() {
194
- if (!this.inlineData && InlineIconData) {
195
- this.inlineData = InlineIconData;
196
- }
197
155
  return this.inlineData;
198
156
  }
199
157
 
@@ -203,7 +161,11 @@ class IconProvider {
203
161
  */
204
162
  setInlineData(iconData) {
205
163
  this.inlineData = iconData;
206
- InlineIconData = iconData;
164
+ console.log('IconProvider.setInlineData(): Data loaded successfully',
165
+ 'planets:', Object.keys(iconData?.planets || {}).length,
166
+ 'signs:', Object.keys(iconData?.signs || {}).length,
167
+ 'aspects:', Object.keys(iconData?.aspects || {}).length
168
+ );
207
169
  }
208
170
 
209
171
  /**
@@ -224,6 +186,16 @@ class IconProvider {
224
186
  const inlineData = this._getInlineData();
225
187
  if (inlineData?.planets?.[name]) {
226
188
  return inlineData.planets[name];
189
+ } else {
190
+ // Debug: log when inline data is not available (only once)
191
+ if (!this._warnedAboutMissingData) {
192
+ this._warnedAboutMissingData = true;
193
+ if (!inlineData) {
194
+ console.warn(`IconProvider: Inline data not loaded, falling back to external paths. Call setInlineData() to load inline icons.`);
195
+ } else if (!inlineData.planets) {
196
+ console.warn(`IconProvider: Inline data missing 'planets' category`);
197
+ }
198
+ }
227
199
  }
228
200
  }
229
201
 
@@ -315,7 +287,7 @@ class IconProvider {
315
287
  /**
316
288
  * IconData.js
317
289
  * Auto-generated module containing inline SVG icons as data URLs
318
- * Generated at: 2025-11-13T13:46:12.044Z
290
+ * Generated at: 2025-11-14T10:26:57.036Z
319
291
  *
320
292
  * This file is automatically generated by the build process.
321
293
  * Do not edit manually - changes will be overwritten.
@@ -1962,11 +1934,18 @@ class ZodiacRenderer extends BaseRenderer {
1962
1934
  */
1963
1935
  constructor(options) {
1964
1936
  super(options);
1965
- if (!options.assetBasePath) {
1966
- throw new Error("ZodiacRenderer: Missing required option assetBasePath");
1937
+
1938
+ // Store the icon provider
1939
+ this.iconProvider = options.iconProvider;
1940
+
1941
+ // assetBasePath is required only if IconProvider is not available
1942
+ if (!options.assetBasePath && !this.iconProvider) {
1943
+ throw new Error("ZodiacRenderer: Missing required option assetBasePath or iconProvider");
1967
1944
  }
1968
-
1969
- this.iconProvider = options.iconProvider; // Store the icon provider
1945
+
1946
+ // Set default assetBasePath if not provided (for backward compatibility)
1947
+ this.assetBasePath = options.assetBasePath || './assets/';
1948
+
1970
1949
  this.signIconRadius = (this.outerRadius + this.middleRadius) / 2;
1971
1950
  this.signIconSize = 30;
1972
1951
  }
@@ -2077,10 +2056,17 @@ class ZodiacRenderer extends BaseRenderer {
2077
2056
  iconHref = this.iconProvider.getZodiacIconPath(signName);
2078
2057
  } else {
2079
2058
  // Fallback to old path construction
2080
- iconHref = `${this.options.assetBasePath}svg/zodiac/zodiac-sign-${signName}.svg`;
2059
+ const basePath = this.options.assetBasePath || this.assetBasePath || './assets/';
2060
+ iconHref = `${basePath}svg/zodiac/zodiac-sign-${signName}.svg`;
2081
2061
  }
2082
2062
 
2083
- console.log(`Loading zodiac sign: ${iconHref}`);
2063
+ // Log icon path for debugging (only log first time for each sign to avoid spam)
2064
+ if (!this._loggedSigns) this._loggedSigns = {};
2065
+ if (!this._loggedSigns[signName]) {
2066
+ console.log(`ZodiacRenderer: Loading sign '${signName}':`,
2067
+ iconHref.startsWith('data:') ? 'inline data URL' : iconHref);
2068
+ this._loggedSigns[signName] = true;
2069
+ }
2084
2070
 
2085
2071
  const icon = this.svgUtils.createSVGElement("image", {
2086
2072
  x: point.x - this.signIconSize / 2, // Offset to center the icon
@@ -2399,12 +2385,17 @@ class BasePlanetRenderer extends BaseRenderer {
2399
2385
  */
2400
2386
  constructor(options) {
2401
2387
  super(options);
2402
- if (!options.assetBasePath) {
2403
- throw new Error(`${this.constructor.name}: Missing required option assetBasePath`);
2404
- }
2405
2388
 
2406
2389
  // Store the icon provider
2407
2390
  this.iconProvider = options.iconProvider;
2391
+
2392
+ // assetBasePath is required only if IconProvider is not available
2393
+ if (!options.assetBasePath && !this.iconProvider) {
2394
+ throw new Error(`${this.constructor.name}: Missing required option assetBasePath or iconProvider`);
2395
+ }
2396
+
2397
+ // Set default assetBasePath if not provided (for backward compatibility)
2398
+ this.assetBasePath = options.assetBasePath || './assets/';
2408
2399
  }
2409
2400
 
2410
2401
  /**
@@ -2506,7 +2497,8 @@ class PlanetSymbolRenderer extends BasePlanetRenderer {
2506
2497
  iconPath = this.iconProvider.getPlanetIconPath(planet.name);
2507
2498
  } else {
2508
2499
  // Fallback to old path construction if IconProvider is not available
2509
- iconPath = `${this.options.assetBasePath}svg/zodiac/zodiac-planet-${planet.name.toLowerCase()}.svg`;
2500
+ const basePath = this.options.assetBasePath || this.assetBasePath || './assets/';
2501
+ iconPath = `${basePath}svg/zodiac/zodiac-planet-${planet.name.toLowerCase()}.svg`;
2510
2502
  }
2511
2503
 
2512
2504
  // Calculate top-left position of the icon (centered on the calculated point)
@@ -3508,7 +3500,7 @@ class ClientSideAspectRenderer extends BaseRenderer { // No longer extends IAspe
3508
3500
  this.renderedAspects = []; // Store calculated aspects
3509
3501
  this._aspectCacheKey = null; // Cache key for aspect calculations
3510
3502
  this._aspectCache = []; // Cached aspect results
3511
- this.assetBasePath = options.assetBasePath || ''; // Store asset base path
3503
+ this.assetBasePath = options.assetBasePath || './assets/'; // Store asset base path with fallback
3512
3504
  this.iconProvider = options.iconProvider; // Store the icon provider
3513
3505
 
3514
3506
  // Define major aspects and their angles (can be overridden/extended by config)
@@ -4037,7 +4029,12 @@ class RendererFactory {
4037
4029
  this.config = config;
4038
4030
  this.svgNS = svgNS;
4039
4031
  this.svgUtils = ServiceRegistry.getSvgUtils();
4040
- this.iconProvider = ServiceRegistry.getIconProvider(config.assets?.basePath);
4032
+ this.iconProvider = ServiceRegistry.getIconProvider();
4033
+
4034
+ // If IconProvider is null, log error for debugging
4035
+ if (!this.iconProvider) {
4036
+ console.error('RendererFactory: IconProvider not available. Icons will not render correctly.');
4037
+ }
4041
4038
  }
4042
4039
 
4043
4040
  /**
@@ -5621,17 +5618,31 @@ class WheelChart {
5621
5618
  * See examples/factory-injection-example.js for more advanced usage patterns.
5622
5619
  */
5623
5620
 
5624
- // Initialize core services immediately
5625
- ServiceRegistry.initializeServices();
5621
+ // CRITICAL: Register IconProvider BEFORE initializing other services
5622
+ // This ensures renderers get the inline-capable provider, not a legacy stub
5623
+ const iconProvider = new IconProvider({
5624
+ useInline: true,
5625
+ basePath: './assets/svg/zodiac/' // Fallback for external mode
5626
+ });
5626
5627
 
5627
- // Initialize IconProvider with inline data if available
5628
+ // Initialize with inline data if available
5628
5629
  if (IconData && Object.keys(IconData.planets || {}).length > 0) {
5629
- const iconProvider = ServiceRegistry.getIconProvider();
5630
- if (iconProvider && typeof iconProvider.setInlineData === 'function') {
5631
- iconProvider.setInlineData(IconData);
5632
- }
5630
+ iconProvider.setInlineData(IconData);
5631
+ console.log('IconProvider: Initialized with inline icons -',
5632
+ 'Planets:', Object.keys(IconData.planets).length,
5633
+ 'Signs:', Object.keys(IconData.signs).length,
5634
+ 'Aspects:', Object.keys(IconData.aspects).length
5635
+ );
5636
+ } else {
5637
+ console.warn('IconProvider: IconData not loaded, will use external paths');
5633
5638
  }
5634
5639
 
5640
+ // Register IconProvider BEFORE initializing services
5641
+ ServiceRegistry.register('iconProvider', iconProvider);
5642
+
5643
+ // Now initialize other core services
5644
+ ServiceRegistry.initializeServices();
5645
+
5635
5646
  // Library version
5636
5647
  const VERSION = '0.2.0';
5637
5648