@forcecalendar/core 2.1.8 → 2.1.9

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.
@@ -731,23 +731,29 @@ export class Calendar {
731
731
  * Destroy the calendar and clean up
732
732
  */
733
733
  destroy() {
734
+ // Emit destroy event before clearing listeners
735
+ this._emit('destroy');
736
+
734
737
  // Clear all listeners
735
738
  this.listeners.clear();
736
739
 
737
740
  // Properly destroy EventStore (clears events, caches, and cleanup timers)
738
741
  this.eventStore.destroy();
739
742
 
740
- // Clear plugins
743
+ // Clear plugins — wrap each uninstall in try-catch so one failure
744
+ // doesn't prevent cleanup of remaining plugins
741
745
  this.plugins.forEach(plugin => {
742
746
  if (typeof plugin.uninstall === 'function') {
743
- plugin.uninstall(this);
747
+ try {
748
+ plugin.uninstall(this);
749
+ } catch (error) {
750
+ console.error('Error uninstalling plugin:', error);
751
+ }
744
752
  }
745
753
  });
746
754
  this.plugins.clear();
747
755
 
748
756
  // Clear view instances
749
757
  this.views.clear();
750
-
751
- this._emit('destroy');
752
758
  }
753
759
  } // Test workflow
@@ -288,9 +288,13 @@ export class DateUtils {
288
288
  * @returns {number}
289
289
  */
290
290
  static getWeekNumber(date) {
291
- const firstDayOfYear = new Date(date.getFullYear(), 0, 1);
292
- const pastDaysOfYear = (date - firstDayOfYear) / 86400000;
293
- return Math.ceil((pastDaysOfYear + firstDayOfYear.getDay() + 1) / 7);
291
+ // ISO 8601: week 1 is the week containing the first Thursday of the year
292
+ const target = new Date(date);
293
+ target.setHours(0, 0, 0, 0);
294
+ // Set to nearest Thursday (current date + 4 - current day number, with Sunday as 7)
295
+ target.setDate(target.getDate() + 4 - (target.getDay() || 7));
296
+ const yearStart = new Date(target.getFullYear(), 0, 1);
297
+ return Math.ceil(((target - yearStart) / 86400000 + 1) / 7);
294
298
  }
295
299
 
296
300
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forcecalendar/core",
3
- "version": "2.1.8",
3
+ "version": "2.1.9",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "A modern, lightweight, framework-agnostic calendar engine optimized for Salesforce",