@trops/dash-core 0.1.89 → 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.
@@ -591,6 +591,8 @@ const DASHBOARD_CONFIG_IMPORT$1 = "dashboard-config-import";
591
591
  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
+ const DASHBOARD_CONFIG_PREVIEW$1 = "dashboard-config-preview";
595
+ const DASHBOARD_CONFIG_CHECK_UPDATES$1 = "dashboard-config-check-updates";
594
596
 
595
597
  var dashboardConfigEvents$1 = {
596
598
  DASHBOARD_CONFIG_EXPORT: DASHBOARD_CONFIG_EXPORT$1,
@@ -598,6 +600,8 @@ var dashboardConfigEvents$1 = {
598
600
  DASHBOARD_CONFIG_INSTALL: DASHBOARD_CONFIG_INSTALL$1,
599
601
  DASHBOARD_CONFIG_COMPATIBILITY: DASHBOARD_CONFIG_COMPATIBILITY$1,
600
602
  DASHBOARD_CONFIG_PUBLISH: DASHBOARD_CONFIG_PUBLISH$1,
603
+ DASHBOARD_CONFIG_PREVIEW: DASHBOARD_CONFIG_PREVIEW$1,
604
+ DASHBOARD_CONFIG_CHECK_UPDATES: DASHBOARD_CONFIG_CHECK_UPDATES$1,
601
605
  };
602
606
 
603
607
  /**
@@ -8497,6 +8501,103 @@ function generateRegistryManifest(dashboardConfig, options = {}) {
8497
8501
  return manifest;
8498
8502
  }
8499
8503
 
8504
+ /**
8505
+ * Build a structured preview object from a dashboard registry package
8506
+ * or dashboard config. Provides all data needed for a rich preview UI.
8507
+ *
8508
+ * @param {Object} source - Registry package manifest or dashboard config
8509
+ * @returns {Object} Structured preview with metadata, widgets, wiring, providers
8510
+ */
8511
+ function buildDashboardPreview(source) {
8512
+ const preview = {
8513
+ name: source.displayName || source.name || "Dashboard",
8514
+ description: source.description || "",
8515
+ author: typeof source.author === "object"
8516
+ ? source.author.name || ""
8517
+ : source.author || "",
8518
+ authorId: typeof source.author === "object"
8519
+ ? source.author.id || ""
8520
+ : "",
8521
+ version: source.version || "",
8522
+ icon: source.icon || "grip",
8523
+ tags: source.tags || [],
8524
+ screenshots: source.screenshots || [],
8525
+ publishedAt: source.publishedAt || null,
8526
+ category: source.category || "general",
8527
+ widgets: (source.widgets || []).map((w) => ({
8528
+ name: w.name || w.id || w.package || "",
8529
+ package: w.package || "",
8530
+ version: w.version || "*",
8531
+ required: w.required !== false,
8532
+ author: w.author || "",
8533
+ })),
8534
+ eventWiring: (source.eventWiring || []).map((wire) => ({
8535
+ raw: wire,
8536
+ summary: `${wire.source?.widget || "?"}.${wire.source?.event || "?"} → ${wire.target?.widget || "?"}.${wire.target?.handler || wire.source?.event || "?"}`,
8537
+ })),
8538
+ providers: (source.providers || []).map((p) => ({
8539
+ type: p.type || "",
8540
+ providerClass: p.providerClass || "",
8541
+ required: p.required !== false,
8542
+ usedBy: p.usedBy || [],
8543
+ })),
8544
+ summary: {
8545
+ widgetCount: (source.widgets || []).length,
8546
+ eventCount: (source.eventWiring || []).length,
8547
+ providerCount: (source.providers || []).length,
8548
+ requiredWidgets: (source.widgets || []).filter((w) => w.required !== false).length,
8549
+ optionalWidgets: (source.widgets || []).filter((w) => w.required === false).length,
8550
+ },
8551
+ };
8552
+
8553
+ return preview;
8554
+ }
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
+
8500
8601
  var dashboardConfigUtils$1 = {
8501
8602
  collectComponentNames: collectComponentNames$1,
8502
8603
  extractEventWiring: extractEventWiring$1,
@@ -8505,6 +8606,8 @@ var dashboardConfigUtils$1 = {
8505
8606
  applyEventWiringToLayout: applyEventWiringToLayout$1,
8506
8607
  checkDashboardCompatibility,
8507
8608
  generateRegistryManifest,
8609
+ buildDashboardPreview,
8610
+ checkDashboardUpdates,
8508
8611
  };
8509
8612
 
8510
8613
  var widgetRegistry$1 = {exports: {}};
@@ -10244,6 +10347,8 @@ async function processDashboardConfig(
10244
10347
  importedAt: new Date().toISOString(),
10245
10348
  originalAuthor: dashboardConfig.author,
10246
10349
  schemaVersion: dashboardConfig.schemaVersion,
10350
+ registryPackage: options.registryPackage || null,
10351
+ installedVersion: options.installedVersion || null,
10247
10352
  };
10248
10353
 
10249
10354
  // Save workspace to workspaces.json
@@ -10400,6 +10505,8 @@ async function installDashboardFromRegistry$1(
10400
10505
  widgetRegistry,
10401
10506
  {
10402
10507
  source: "registry",
10508
+ registryPackage: packageName,
10509
+ installedVersion: registryPkg.version || null,
10403
10510
  },
10404
10511
  );
10405
10512
  } catch (error) {
@@ -10625,12 +10732,104 @@ async function prepareDashboardForPublish$1(
10625
10732
  }
10626
10733
  }
10627
10734
 
10735
+ /**
10736
+ * Get a full preview of a dashboard package from the registry.
10737
+ * Combines the structured preview data with a compatibility check.
10738
+ *
10739
+ * @param {string} packageName - Registry package name
10740
+ * @param {Object} widgetRegistry - WidgetRegistry instance
10741
+ * @returns {Promise<Object>} Preview data with compatibility report
10742
+ */
10743
+ async function getDashboardPreview$1(packageName, widgetRegistry = null) {
10744
+ const { buildDashboardPreview, checkDashboardCompatibility } =
10745
+ dashboardConfigUtils$1;
10746
+ const { getPackage, fetchRegistryIndex } = registryController$1;
10747
+
10748
+ const pkg = await getPackage(packageName);
10749
+ if (!pkg) {
10750
+ return {
10751
+ success: false,
10752
+ error: `Dashboard package not found: ${packageName}`,
10753
+ };
10754
+ }
10755
+
10756
+ const preview = buildDashboardPreview(pkg);
10757
+
10758
+ // Get compatibility report
10759
+ const installedWidgets = widgetRegistry ? widgetRegistry.getWidgets() : [];
10760
+ let registryPackages = [];
10761
+ try {
10762
+ const index = await fetchRegistryIndex();
10763
+ registryPackages = index.packages || [];
10764
+ } catch (err) {
10765
+ // Non-fatal — preview still works without compatibility
10766
+ }
10767
+
10768
+ const compatibility = checkDashboardCompatibility(
10769
+ pkg.widgets || [],
10770
+ installedWidgets,
10771
+ registryPackages,
10772
+ );
10773
+
10774
+ return {
10775
+ success: true,
10776
+ preview,
10777
+ compatibility,
10778
+ };
10779
+ }
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
+
10628
10825
  var dashboardConfigController$1 = {
10629
10826
  exportDashboardConfig: exportDashboardConfig$1,
10630
10827
  importDashboardConfig: importDashboardConfig$1,
10631
10828
  installDashboardFromRegistry: installDashboardFromRegistry$1,
10632
10829
  checkCompatibility: checkCompatibility$1,
10633
10830
  prepareDashboardForPublish: prepareDashboardForPublish$1,
10831
+ getDashboardPreview: getDashboardPreview$1,
10832
+ checkDashboardUpdatesForApp: checkDashboardUpdatesForApp$1,
10634
10833
  };
10635
10834
 
10636
10835
  /**
@@ -10725,6 +10924,8 @@ const {
10725
10924
  installDashboardFromRegistry,
10726
10925
  checkCompatibility,
10727
10926
  prepareDashboardForPublish,
10927
+ getDashboardPreview,
10928
+ checkDashboardUpdatesForApp,
10728
10929
  } = dashboardConfigController$1;
10729
10930
 
10730
10931
  var controller = {
@@ -10773,6 +10974,8 @@ var controller = {
10773
10974
  installDashboardFromRegistry,
10774
10975
  checkCompatibility,
10775
10976
  prepareDashboardForPublish,
10977
+ getDashboardPreview,
10978
+ checkDashboardUpdatesForApp,
10776
10979
  };
10777
10980
 
10778
10981
  const { ipcRenderer: ipcRenderer$i } = require$$0$1;
@@ -12154,6 +12357,8 @@ const {
12154
12357
  DASHBOARD_CONFIG_INSTALL,
12155
12358
  DASHBOARD_CONFIG_COMPATIBILITY,
12156
12359
  DASHBOARD_CONFIG_PUBLISH,
12360
+ DASHBOARD_CONFIG_PREVIEW,
12361
+ DASHBOARD_CONFIG_CHECK_UPDATES,
12157
12362
  } = events$8;
12158
12363
 
12159
12364
  const dashboardConfigApi$2 = {
@@ -12227,6 +12432,25 @@ const dashboardConfigApi$2 = {
12227
12432
  workspaceId,
12228
12433
  options,
12229
12434
  }),
12435
+
12436
+ /**
12437
+ * Get a preview of a dashboard package from the registry.
12438
+ * Returns structured preview data and compatibility report.
12439
+ *
12440
+ * @param {string} packageName - Registry package name
12441
+ * @returns {Promise<Object>} Preview with metadata, widgets, wiring, compatibility
12442
+ */
12443
+ getDashboardPreview: (packageName) =>
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 }),
12230
12454
  };
12231
12455
 
12232
12456
  var dashboardConfigApi_1 = dashboardConfigApi$2;