@trops/dash-core 0.1.90 → 0.1.91

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.
@@ -592,6 +592,7 @@ const DASHBOARD_CONFIG_INSTALL$1 = "dashboard-config-install";
592
592
  const DASHBOARD_CONFIG_COMPATIBILITY$1 = "dashboard-config-compatibility";
593
593
  const DASHBOARD_CONFIG_PUBLISH$1 = "dashboard-config-publish";
594
594
  const DASHBOARD_CONFIG_PREVIEW$1 = "dashboard-config-preview";
595
+ const DASHBOARD_CONFIG_CHECK_UPDATES$1 = "dashboard-config-check-updates";
595
596
 
596
597
  var dashboardConfigEvents$1 = {
597
598
  DASHBOARD_CONFIG_EXPORT: DASHBOARD_CONFIG_EXPORT$1,
@@ -600,6 +601,7 @@ var dashboardConfigEvents$1 = {
600
601
  DASHBOARD_CONFIG_COMPATIBILITY: DASHBOARD_CONFIG_COMPATIBILITY$1,
601
602
  DASHBOARD_CONFIG_PUBLISH: DASHBOARD_CONFIG_PUBLISH$1,
602
603
  DASHBOARD_CONFIG_PREVIEW: DASHBOARD_CONFIG_PREVIEW$1,
604
+ DASHBOARD_CONFIG_CHECK_UPDATES: DASHBOARD_CONFIG_CHECK_UPDATES$1,
603
605
  };
604
606
 
605
607
  /**
@@ -8551,6 +8553,51 @@ function buildDashboardPreview(source) {
8551
8553
  return preview;
8552
8554
  }
8553
8555
 
8556
+ /**
8557
+ * Check installed dashboards for available updates in the registry.
8558
+ *
8559
+ * Compares the `_dashboardConfig.installedVersion` of each workspace
8560
+ * against the current version in the registry.
8561
+ *
8562
+ * @param {Array} workspaces - All workspaces from workspaces.json
8563
+ * @param {Array} registryPackages - Packages from registry index
8564
+ * @returns {Array} Update records with workspace info and version comparison
8565
+ */
8566
+ function checkDashboardUpdates(workspaces = [], registryPackages = []) {
8567
+ const registryByName = new Map();
8568
+ for (const pkg of registryPackages) {
8569
+ if (pkg.name && (pkg.type || "widget") === "dashboard") {
8570
+ registryByName.set(pkg.name, pkg);
8571
+ }
8572
+ }
8573
+
8574
+ const updates = [];
8575
+
8576
+ for (const ws of workspaces) {
8577
+ const config = ws._dashboardConfig;
8578
+ if (!config || !config.registryPackage) continue;
8579
+
8580
+ const registryPkg = registryByName.get(config.registryPackage);
8581
+ if (!registryPkg) continue;
8582
+
8583
+ const installedVersion = config.installedVersion || "0.0.0";
8584
+ const latestVersion = registryPkg.version || "0.0.0";
8585
+
8586
+ if (installedVersion !== latestVersion) {
8587
+ updates.push({
8588
+ workspaceId: ws.id,
8589
+ workspaceName: ws.name || ws.label || "",
8590
+ registryPackage: config.registryPackage,
8591
+ installedVersion,
8592
+ latestVersion,
8593
+ importedAt: config.importedAt || null,
8594
+ });
8595
+ }
8596
+ }
8597
+
8598
+ return updates;
8599
+ }
8600
+
8554
8601
  var dashboardConfigUtils$1 = {
8555
8602
  collectComponentNames: collectComponentNames$1,
8556
8603
  extractEventWiring: extractEventWiring$1,
@@ -8560,6 +8607,7 @@ var dashboardConfigUtils$1 = {
8560
8607
  checkDashboardCompatibility,
8561
8608
  generateRegistryManifest,
8562
8609
  buildDashboardPreview,
8610
+ checkDashboardUpdates,
8563
8611
  };
8564
8612
 
8565
8613
  var widgetRegistry$1 = {exports: {}};
@@ -10299,6 +10347,8 @@ async function processDashboardConfig(
10299
10347
  importedAt: new Date().toISOString(),
10300
10348
  originalAuthor: dashboardConfig.author,
10301
10349
  schemaVersion: dashboardConfig.schemaVersion,
10350
+ registryPackage: options.registryPackage || null,
10351
+ installedVersion: options.installedVersion || null,
10302
10352
  };
10303
10353
 
10304
10354
  // Save workspace to workspaces.json
@@ -10455,6 +10505,8 @@ async function installDashboardFromRegistry$1(
10455
10505
  widgetRegistry,
10456
10506
  {
10457
10507
  source: "registry",
10508
+ registryPackage: packageName,
10509
+ installedVersion: registryPkg.version || null,
10458
10510
  },
10459
10511
  );
10460
10512
  } catch (error) {
@@ -10726,6 +10778,50 @@ async function getDashboardPreview$1(packageName, widgetRegistry = null) {
10726
10778
  };
10727
10779
  }
10728
10780
 
10781
+ /**
10782
+ * Check installed dashboards for available updates.
10783
+ * Reads workspaces, finds those installed from the registry,
10784
+ * and compares versions against the current registry index.
10785
+ *
10786
+ * @param {string} appId - Application identifier
10787
+ * @returns {Promise<Object>} Result with updates array
10788
+ */
10789
+ async function checkDashboardUpdatesForApp$1(appId) {
10790
+ const { checkDashboardUpdates } = dashboardConfigUtils$1;
10791
+ const { fetchRegistryIndex } = registryController$1;
10792
+
10793
+ try {
10794
+ const filename = path.join(
10795
+ app.getPath("userData"),
10796
+ appName,
10797
+ appId,
10798
+ configFilename,
10799
+ );
10800
+ const workspaces = getFileContents(filename) || [];
10801
+
10802
+ const index = await fetchRegistryIndex();
10803
+ const registryPackages = index.packages || [];
10804
+
10805
+ const updates = checkDashboardUpdates(workspaces, registryPackages);
10806
+
10807
+ return {
10808
+ success: true,
10809
+ updates,
10810
+ totalInstalled: workspaces.filter((w) => w._dashboardConfig?.registryPackage).length,
10811
+ };
10812
+ } catch (error) {
10813
+ console.error(
10814
+ "[DashboardConfigController] Error checking dashboard updates:",
10815
+ error,
10816
+ );
10817
+ return {
10818
+ success: false,
10819
+ error: error.message,
10820
+ updates: [],
10821
+ };
10822
+ }
10823
+ }
10824
+
10729
10825
  var dashboardConfigController$1 = {
10730
10826
  exportDashboardConfig: exportDashboardConfig$1,
10731
10827
  importDashboardConfig: importDashboardConfig$1,
@@ -10733,6 +10829,7 @@ var dashboardConfigController$1 = {
10733
10829
  checkCompatibility: checkCompatibility$1,
10734
10830
  prepareDashboardForPublish: prepareDashboardForPublish$1,
10735
10831
  getDashboardPreview: getDashboardPreview$1,
10832
+ checkDashboardUpdatesForApp: checkDashboardUpdatesForApp$1,
10736
10833
  };
10737
10834
 
10738
10835
  /**
@@ -10828,6 +10925,7 @@ const {
10828
10925
  checkCompatibility,
10829
10926
  prepareDashboardForPublish,
10830
10927
  getDashboardPreview,
10928
+ checkDashboardUpdatesForApp,
10831
10929
  } = dashboardConfigController$1;
10832
10930
 
10833
10931
  var controller = {
@@ -10877,6 +10975,7 @@ var controller = {
10877
10975
  checkCompatibility,
10878
10976
  prepareDashboardForPublish,
10879
10977
  getDashboardPreview,
10978
+ checkDashboardUpdatesForApp,
10880
10979
  };
10881
10980
 
10882
10981
  const { ipcRenderer: ipcRenderer$i } = require$$0$1;
@@ -12259,6 +12358,7 @@ const {
12259
12358
  DASHBOARD_CONFIG_COMPATIBILITY,
12260
12359
  DASHBOARD_CONFIG_PUBLISH,
12261
12360
  DASHBOARD_CONFIG_PREVIEW,
12361
+ DASHBOARD_CONFIG_CHECK_UPDATES,
12262
12362
  } = events$8;
12263
12363
 
12264
12364
  const dashboardConfigApi$2 = {
@@ -12342,6 +12442,15 @@ const dashboardConfigApi$2 = {
12342
12442
  */
12343
12443
  getDashboardPreview: (packageName) =>
12344
12444
  ipcRenderer$1.invoke(DASHBOARD_CONFIG_PREVIEW, { packageName }),
12445
+
12446
+ /**
12447
+ * Check installed dashboards for available updates.
12448
+ *
12449
+ * @param {string} appId - Application identifier
12450
+ * @returns {Promise<Object>} Result with updates array
12451
+ */
12452
+ checkDashboardUpdates: (appId) =>
12453
+ ipcRenderer$1.invoke(DASHBOARD_CONFIG_CHECK_UPDATES, { appId }),
12345
12454
  };
12346
12455
 
12347
12456
  var dashboardConfigApi_1 = dashboardConfigApi$2;