@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.
@@ -89,47 +89,16 @@
89
89
  }
90
90
 
91
91
  /**
92
- * Gets or creates an IconProvider instance
93
- * @param {string} basePath - Optional base path for SVG assets
94
- * @returns {Object} The IconProvider instance
92
+ * Gets the IconProvider instance
93
+ * NOTE: IconProvider should be registered externally before use
94
+ * This method only retrieves, does not create
95
+ * @returns {Object|undefined} The IconProvider instance if registered
95
96
  */
96
- static getIconProvider(basePath = './assets/svg/zodiac/') {
97
+ static getIconProvider() {
97
98
  if (!this.has('iconProvider')) {
98
- // Create a simple icon provider
99
- const iconProvider = {
100
- basePath: basePath,
101
-
102
- getPlanetIconPath(planetName) {
103
- return `${this.basePath}zodiac-planet-${planetName.toLowerCase()}.svg`;
104
- },
105
-
106
- getZodiacIconPath(signName) {
107
- return `${this.basePath}zodiac-sign-${signName.toLowerCase()}.svg`;
108
- },
109
-
110
- getAspectIconPath(aspectType) {
111
- return `${this.basePath}zodiac-aspect-${aspectType.toLowerCase()}.svg`;
112
- },
113
-
114
- createTextFallback(svgUtils, options, text) {
115
- const { x, y, size = '16px', color = '#000000', className = 'icon-fallback' } = options;
116
-
117
- const textElement = svgUtils.createSVGElement("text", {
118
- x: x,
119
- y: y,
120
- 'text-anchor': 'middle',
121
- 'dominant-baseline': 'middle',
122
- 'font-size': size,
123
- 'class': className,
124
- 'fill': color
125
- });
126
-
127
- textElement.textContent = text;
128
- return textElement;
129
- }
130
- };
131
-
132
- this.register('iconProvider', iconProvider);
99
+ console.warn('ServiceRegistry: IconProvider not registered. Icons may not work correctly.');
100
+ console.warn('ServiceRegistry: This should be initialized in main.js with inline IconData.');
101
+ return null;
133
102
  }
134
103
  return this.get('iconProvider');
135
104
  }
@@ -142,8 +111,8 @@
142
111
  // Initialize SvgUtils
143
112
  this.getSvgUtils();
144
113
 
145
- // Initialize IconProvider with the assets base path
146
- this.getIconProvider(options.assetBasePath || './assets/svg/zodiac/');
114
+ // Note: IconProvider should be registered externally in main.js
115
+ // with inline IconData before calling this method
147
116
 
148
117
  console.log("ServiceRegistry: Core services initialized");
149
118
  }
@@ -159,17 +128,6 @@
159
128
  * 2. External mode: Uses external file paths (for custom icons)
160
129
  */
161
130
 
162
- // Try to import IconData if available (after build)
163
- let InlineIconData = null;
164
- try {
165
- // This will be replaced by rollup during build
166
- // During development or if IconData doesn't exist, this will fail gracefully
167
- InlineIconData = null; // Will be set up after IconData.js is generated
168
- } catch (e) {
169
- // IconData not available yet
170
- InlineIconData = null;
171
- }
172
-
173
131
  class IconProvider {
174
132
  /**
175
133
  * Constructor
@@ -190,6 +148,9 @@
190
148
 
191
149
  // Lazy-load IconData on first use
192
150
  this.inlineData = null;
151
+
152
+ // Track if warning was already shown (to avoid spam)
153
+ this._warnedAboutMissingData = false;
193
154
  }
194
155
 
195
156
  /**
@@ -197,9 +158,6 @@
197
158
  * @private
198
159
  */
199
160
  _getInlineData() {
200
- if (!this.inlineData && InlineIconData) {
201
- this.inlineData = InlineIconData;
202
- }
203
161
  return this.inlineData;
204
162
  }
205
163
 
@@ -209,7 +167,11 @@
209
167
  */
210
168
  setInlineData(iconData) {
211
169
  this.inlineData = iconData;
212
- InlineIconData = iconData;
170
+ console.log('IconProvider.setInlineData(): Data loaded successfully',
171
+ 'planets:', Object.keys(iconData?.planets || {}).length,
172
+ 'signs:', Object.keys(iconData?.signs || {}).length,
173
+ 'aspects:', Object.keys(iconData?.aspects || {}).length
174
+ );
213
175
  }
214
176
 
215
177
  /**
@@ -230,6 +192,16 @@
230
192
  const inlineData = this._getInlineData();
231
193
  if (inlineData?.planets?.[name]) {
232
194
  return inlineData.planets[name];
195
+ } else {
196
+ // Debug: log when inline data is not available (only once)
197
+ if (!this._warnedAboutMissingData) {
198
+ this._warnedAboutMissingData = true;
199
+ if (!inlineData) {
200
+ console.warn(`IconProvider: Inline data not loaded, falling back to external paths. Call setInlineData() to load inline icons.`);
201
+ } else if (!inlineData.planets) {
202
+ console.warn(`IconProvider: Inline data missing 'planets' category`);
203
+ }
204
+ }
233
205
  }
234
206
  }
235
207
 
@@ -321,7 +293,7 @@
321
293
  /**
322
294
  * IconData.js
323
295
  * Auto-generated module containing inline SVG icons as data URLs
324
- * Generated at: 2025-11-13T13:46:12.044Z
296
+ * Generated at: 2025-11-14T10:26:57.036Z
325
297
  *
326
298
  * This file is automatically generated by the build process.
327
299
  * Do not edit manually - changes will be overwritten.
@@ -1968,11 +1940,18 @@
1968
1940
  */
1969
1941
  constructor(options) {
1970
1942
  super(options);
1971
- if (!options.assetBasePath) {
1972
- throw new Error("ZodiacRenderer: Missing required option assetBasePath");
1943
+
1944
+ // Store the icon provider
1945
+ this.iconProvider = options.iconProvider;
1946
+
1947
+ // assetBasePath is required only if IconProvider is not available
1948
+ if (!options.assetBasePath && !this.iconProvider) {
1949
+ throw new Error("ZodiacRenderer: Missing required option assetBasePath or iconProvider");
1973
1950
  }
1974
-
1975
- this.iconProvider = options.iconProvider; // Store the icon provider
1951
+
1952
+ // Set default assetBasePath if not provided (for backward compatibility)
1953
+ this.assetBasePath = options.assetBasePath || './assets/';
1954
+
1976
1955
  this.signIconRadius = (this.outerRadius + this.middleRadius) / 2;
1977
1956
  this.signIconSize = 30;
1978
1957
  }
@@ -2083,10 +2062,17 @@
2083
2062
  iconHref = this.iconProvider.getZodiacIconPath(signName);
2084
2063
  } else {
2085
2064
  // Fallback to old path construction
2086
- iconHref = `${this.options.assetBasePath}svg/zodiac/zodiac-sign-${signName}.svg`;
2065
+ const basePath = this.options.assetBasePath || this.assetBasePath || './assets/';
2066
+ iconHref = `${basePath}svg/zodiac/zodiac-sign-${signName}.svg`;
2087
2067
  }
2088
2068
 
2089
- console.log(`Loading zodiac sign: ${iconHref}`);
2069
+ // Log icon path for debugging (only log first time for each sign to avoid spam)
2070
+ if (!this._loggedSigns) this._loggedSigns = {};
2071
+ if (!this._loggedSigns[signName]) {
2072
+ console.log(`ZodiacRenderer: Loading sign '${signName}':`,
2073
+ iconHref.startsWith('data:') ? 'inline data URL' : iconHref);
2074
+ this._loggedSigns[signName] = true;
2075
+ }
2090
2076
 
2091
2077
  const icon = this.svgUtils.createSVGElement("image", {
2092
2078
  x: point.x - this.signIconSize / 2, // Offset to center the icon
@@ -2405,12 +2391,17 @@
2405
2391
  */
2406
2392
  constructor(options) {
2407
2393
  super(options);
2408
- if (!options.assetBasePath) {
2409
- throw new Error(`${this.constructor.name}: Missing required option assetBasePath`);
2410
- }
2411
2394
 
2412
2395
  // Store the icon provider
2413
2396
  this.iconProvider = options.iconProvider;
2397
+
2398
+ // assetBasePath is required only if IconProvider is not available
2399
+ if (!options.assetBasePath && !this.iconProvider) {
2400
+ throw new Error(`${this.constructor.name}: Missing required option assetBasePath or iconProvider`);
2401
+ }
2402
+
2403
+ // Set default assetBasePath if not provided (for backward compatibility)
2404
+ this.assetBasePath = options.assetBasePath || './assets/';
2414
2405
  }
2415
2406
 
2416
2407
  /**
@@ -2512,7 +2503,8 @@
2512
2503
  iconPath = this.iconProvider.getPlanetIconPath(planet.name);
2513
2504
  } else {
2514
2505
  // Fallback to old path construction if IconProvider is not available
2515
- iconPath = `${this.options.assetBasePath}svg/zodiac/zodiac-planet-${planet.name.toLowerCase()}.svg`;
2506
+ const basePath = this.options.assetBasePath || this.assetBasePath || './assets/';
2507
+ iconPath = `${basePath}svg/zodiac/zodiac-planet-${planet.name.toLowerCase()}.svg`;
2516
2508
  }
2517
2509
 
2518
2510
  // Calculate top-left position of the icon (centered on the calculated point)
@@ -3514,7 +3506,7 @@
3514
3506
  this.renderedAspects = []; // Store calculated aspects
3515
3507
  this._aspectCacheKey = null; // Cache key for aspect calculations
3516
3508
  this._aspectCache = []; // Cached aspect results
3517
- this.assetBasePath = options.assetBasePath || ''; // Store asset base path
3509
+ this.assetBasePath = options.assetBasePath || './assets/'; // Store asset base path with fallback
3518
3510
  this.iconProvider = options.iconProvider; // Store the icon provider
3519
3511
 
3520
3512
  // Define major aspects and their angles (can be overridden/extended by config)
@@ -4043,7 +4035,12 @@
4043
4035
  this.config = config;
4044
4036
  this.svgNS = svgNS;
4045
4037
  this.svgUtils = ServiceRegistry.getSvgUtils();
4046
- this.iconProvider = ServiceRegistry.getIconProvider(config.assets?.basePath);
4038
+ this.iconProvider = ServiceRegistry.getIconProvider();
4039
+
4040
+ // If IconProvider is null, log error for debugging
4041
+ if (!this.iconProvider) {
4042
+ console.error('RendererFactory: IconProvider not available. Icons will not render correctly.');
4043
+ }
4047
4044
  }
4048
4045
 
4049
4046
  /**
@@ -5627,17 +5624,31 @@
5627
5624
  * See examples/factory-injection-example.js for more advanced usage patterns.
5628
5625
  */
5629
5626
 
5630
- // Initialize core services immediately
5631
- ServiceRegistry.initializeServices();
5627
+ // CRITICAL: Register IconProvider BEFORE initializing other services
5628
+ // This ensures renderers get the inline-capable provider, not a legacy stub
5629
+ const iconProvider = new IconProvider({
5630
+ useInline: true,
5631
+ basePath: './assets/svg/zodiac/' // Fallback for external mode
5632
+ });
5632
5633
 
5633
- // Initialize IconProvider with inline data if available
5634
+ // Initialize with inline data if available
5634
5635
  if (IconData && Object.keys(IconData.planets || {}).length > 0) {
5635
- const iconProvider = ServiceRegistry.getIconProvider();
5636
- if (iconProvider && typeof iconProvider.setInlineData === 'function') {
5637
- iconProvider.setInlineData(IconData);
5638
- }
5636
+ iconProvider.setInlineData(IconData);
5637
+ console.log('IconProvider: Initialized with inline icons -',
5638
+ 'Planets:', Object.keys(IconData.planets).length,
5639
+ 'Signs:', Object.keys(IconData.signs).length,
5640
+ 'Aspects:', Object.keys(IconData.aspects).length
5641
+ );
5642
+ } else {
5643
+ console.warn('IconProvider: IconData not loaded, will use external paths');
5639
5644
  }
5640
5645
 
5646
+ // Register IconProvider BEFORE initializing services
5647
+ ServiceRegistry.register('iconProvider', iconProvider);
5648
+
5649
+ // Now initialize other core services
5650
+ ServiceRegistry.initializeServices();
5651
+
5641
5652
  // Library version
5642
5653
  const VERSION = '0.2.0';
5643
5654