@trops/dash-core 0.1.364 → 0.1.366

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.
@@ -471,6 +471,7 @@ const REGISTRY_CHECK_UPDATES = "registry:check-updates";
471
471
  const REGISTRY_SEARCH_DASHBOARDS = "registry:search-dashboards";
472
472
  const REGISTRY_SEARCH_THEMES = "registry:search-themes";
473
473
  const REGISTRY_PUBLISH_WIDGET = "registry:publish-widget";
474
+ const REGISTRY_INSPECT_WIDGET_PACKAGE = "registry:inspect-widget-package";
474
475
 
475
476
  var registryEvents$1 = {
476
477
  REGISTRY_FETCH_INDEX,
@@ -480,6 +481,7 @@ var registryEvents$1 = {
480
481
  REGISTRY_SEARCH_DASHBOARDS,
481
482
  REGISTRY_SEARCH_THEMES,
482
483
  REGISTRY_PUBLISH_WIDGET,
484
+ REGISTRY_INSPECT_WIDGET_PACKAGE,
483
485
  };
484
486
 
485
487
  /**
@@ -63031,10 +63033,36 @@ function collectComponentNamesFromWorkspace$1(workspace) {
63031
63033
  return Array.from(names);
63032
63034
  }
63033
63035
 
63036
+ /**
63037
+ * Extract event wiring across a workspace's main layout, every page
63038
+ * layout, and the sidebar layout. Mirrors collectComponentNamesFromWorkspace
63039
+ * — the single-layout `extractEventWiring` misses widgets on non-active
63040
+ * pages or in the sidebar.
63041
+ *
63042
+ * @param {Object} workspace - Workspace object
63043
+ * @returns {Array} Event wiring array
63044
+ */
63045
+ function extractEventWiringFromWorkspace$1(workspace) {
63046
+ const wiring = [];
63047
+ const pushAll = (layout) => {
63048
+ if (!Array.isArray(layout)) return;
63049
+ for (const entry of extractEventWiring$1(layout)) wiring.push(entry);
63050
+ };
63051
+
63052
+ pushAll(workspace?.layout);
63053
+ pushAll(workspace?.sidebarLayout);
63054
+ if (Array.isArray(workspace?.pages)) {
63055
+ for (const page of workspace.pages) pushAll(page?.layout);
63056
+ }
63057
+
63058
+ return wiring;
63059
+ }
63060
+
63034
63061
  var dashboardConfigUtils$1 = {
63035
63062
  collectComponentNames: collectComponentNames$1,
63036
63063
  collectComponentNamesFromWorkspace: collectComponentNamesFromWorkspace$1,
63037
63064
  extractEventWiring: extractEventWiring$1,
63065
+ extractEventWiringFromWorkspace: extractEventWiringFromWorkspace$1,
63038
63066
  buildWidgetDependencies: buildWidgetDependencies$1,
63039
63067
  buildProviderRequirements: buildProviderRequirements$1,
63040
63068
  applyEventWiringToLayout: applyEventWiringToLayout$1,
@@ -63785,6 +63813,7 @@ const {
63785
63813
  collectComponentNames,
63786
63814
  collectComponentNamesFromWorkspace,
63787
63815
  extractEventWiring,
63816
+ extractEventWiringFromWorkspace,
63788
63817
  buildWidgetDependencies,
63789
63818
  buildProviderRequirements,
63790
63819
  applyEventWiringToLayout,
@@ -63837,9 +63866,11 @@ async function exportDashboardConfig$1(
63837
63866
 
63838
63867
  const layout = workspace.layout || [];
63839
63868
 
63840
- // 2. Collect components, extract wiring, resolve deps
63841
- const componentNames = collectComponentNames(layout);
63842
- const eventWiring = extractEventWiring(layout);
63869
+ // 2. Collect components, extract wiring, resolve deps — walk main
63870
+ // layout, every page, and the sidebar so multi-page / sidebar
63871
+ // dashboards export the full picture.
63872
+ const componentNames = collectComponentNamesFromWorkspace(workspace);
63873
+ const eventWiring = extractEventWiringFromWorkspace(workspace);
63843
63874
  const widgets = buildWidgetDependencies(componentNames, widgetRegistry);
63844
63875
  const providers = buildProviderRequirements(componentNames, widgetRegistry);
63845
63876
 
@@ -63861,6 +63892,16 @@ async function exportDashboardConfig$1(
63861
63892
  label: workspace.label || workspace.name,
63862
63893
  version: workspace.version || 1,
63863
63894
  layout,
63895
+ ...(Array.isArray(workspace.pages) && workspace.pages.length > 0
63896
+ ? { pages: workspace.pages, activePageId: workspace.activePageId }
63897
+ : {}),
63898
+ ...(Array.isArray(workspace.sidebarLayout) &&
63899
+ workspace.sidebarLayout.length > 0
63900
+ ? {
63901
+ sidebarLayout: workspace.sidebarLayout,
63902
+ sidebarEnabled: workspace.sidebarEnabled !== false,
63903
+ }
63904
+ : {}),
63864
63905
  menuId: workspace.menuId || 1,
63865
63906
  },
63866
63907
  widgets,
@@ -65070,9 +65111,9 @@ async function prepareDashboardForPublish$1(
65070
65111
 
65071
65112
  const layout = workspace.layout || [];
65072
65113
 
65073
- // 3. Build the dashboard config (reuse export logic)
65074
- const componentNames = collectComponentNames(layout);
65075
- const eventWiring = extractEventWiring(layout);
65114
+ // 3. Build the dashboard config walk main + pages + sidebar
65115
+ const componentNames = collectComponentNamesFromWorkspace(workspace);
65116
+ const eventWiring = extractEventWiringFromWorkspace(workspace);
65076
65117
 
65077
65118
  // Build componentConfigs map from renderer-supplied data
65078
65119
  // This resolves scope/packageName for built-in widgets that aren't in widgetRegistry
@@ -65108,6 +65149,16 @@ async function prepareDashboardForPublish$1(
65108
65149
  label: workspace.label || workspace.name,
65109
65150
  version: workspace.version || 1,
65110
65151
  layout,
65152
+ ...(Array.isArray(workspace.pages) && workspace.pages.length > 0
65153
+ ? { pages: workspace.pages, activePageId: workspace.activePageId }
65154
+ : {}),
65155
+ ...(Array.isArray(workspace.sidebarLayout) &&
65156
+ workspace.sidebarLayout.length > 0
65157
+ ? {
65158
+ sidebarLayout: workspace.sidebarLayout,
65159
+ sidebarEnabled: workspace.sidebarEnabled !== false,
65160
+ }
65161
+ : {}),
65111
65162
  menuId: workspace.menuId || 1,
65112
65163
  },
65113
65164
  widgets,
@@ -65444,8 +65495,7 @@ function getDashboardPublishPreview$1(appId, workspaceId, widgetRegistry = null)
65444
65495
  return { success: false, error: `Workspace not found: ${workspaceId}` };
65445
65496
  }
65446
65497
 
65447
- const layout = workspace.layout || [];
65448
- const componentNames = collectComponentNames(layout);
65498
+ const componentNames = collectComponentNamesFromWorkspace(workspace);
65449
65499
  const widgets = buildWidgetDependencies(componentNames, widgetRegistry);
65450
65500
 
65451
65501
  return {
@@ -72091,8 +72141,67 @@ async function prepareWidgetForPublish$1(appId, packageId, options = {}) {
72091
72141
  }
72092
72142
  }
72093
72143
 
72144
+ /**
72145
+ * Inspect a locally-installed widget package and return a summary of
72146
+ * metadata the publish UI can display — package.json fields, the
72147
+ * caller's scope, and the list of component widgets the package exposes.
72148
+ *
72149
+ * @param {string} packageId - Widget packageId (e.g. "@scope/name")
72150
+ * @returns {Promise<Object>} { success, packageId, scope, name, version, displayName, description, components: [...] }
72151
+ */
72152
+ async function inspectWidgetPackage$1(packageId) {
72153
+ try {
72154
+ const registry = widgetRegistryModule.getWidgetRegistry();
72155
+ const widget = registry.getWidget(packageId);
72156
+ if (!widget || !widget.path) {
72157
+ return {
72158
+ success: false,
72159
+ error: `Widget package not found locally: ${packageId}`,
72160
+ };
72161
+ }
72162
+
72163
+ let pkgJson = {};
72164
+ const pkgJsonPath = path.join(widget.path, "package.json");
72165
+ if (fs.existsSync(pkgJsonPath)) {
72166
+ try {
72167
+ pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
72168
+ } catch {
72169
+ /* ignore */
72170
+ }
72171
+ }
72172
+ const parsed = parsePackageName(pkgJson.name || packageId);
72173
+
72174
+ let widgetConfigs = widget.widgets || [];
72175
+ if (!widgetConfigs.length) {
72176
+ widgetConfigs = await scanWidgetConfigs(widget.path);
72177
+ }
72178
+
72179
+ const components = widgetConfigs.map((cfg) => ({
72180
+ name: cfg.component || cfg.name,
72181
+ displayName: cfg.name || cfg.component,
72182
+ description: cfg.description || "",
72183
+ icon: cfg.icon || "square",
72184
+ }));
72185
+
72186
+ return {
72187
+ success: true,
72188
+ packageId,
72189
+ localScope: parsed.scope || widget.scope || null,
72190
+ name: parsed.name,
72191
+ version: pkgJson.version || widget.version || null,
72192
+ displayName: pkgJson.displayName || widget.displayName || parsed.name,
72193
+ description: pkgJson.description || widget.description || "",
72194
+ path: widget.path,
72195
+ components,
72196
+ };
72197
+ } catch (err) {
72198
+ return { success: false, error: err.message };
72199
+ }
72200
+ }
72201
+
72094
72202
  var widgetRegistryController = {
72095
72203
  prepareWidgetForPublish: prepareWidgetForPublish$1,
72204
+ inspectWidgetPackage: inspectWidgetPackage$1,
72096
72205
  };
72097
72206
 
72098
72207
  /**
@@ -72205,7 +72314,10 @@ const {
72205
72314
  installThemeFromRegistry,
72206
72315
  getThemePublishPreview,
72207
72316
  } = themeRegistryController$1;
72208
- const { prepareWidgetForPublish } = widgetRegistryController;
72317
+ const {
72318
+ prepareWidgetForPublish,
72319
+ inspectWidgetPackage,
72320
+ } = widgetRegistryController;
72209
72321
  const {
72210
72322
  assignRoles,
72211
72323
  matchTailwindFamily,
@@ -72294,6 +72406,7 @@ var controller = {
72294
72406
  installThemeFromRegistry,
72295
72407
  getThemePublishPreview,
72296
72408
  prepareWidgetForPublish,
72409
+ inspectWidgetPackage,
72297
72410
  assignRoles,
72298
72411
  matchTailwindFamily,
72299
72412
  generateThemeFromPalette,
@@ -73418,6 +73531,25 @@ const registryApi$2 = {
73418
73531
  throw error;
73419
73532
  }
73420
73533
  },
73534
+
73535
+ /**
73536
+ * Inspect a locally-installed widget package and return its metadata
73537
+ * + list of component widgets. Used by the publish modal to show
73538
+ * "what's getting published" before the user hits Publish.
73539
+ *
73540
+ * @param {string} packageId - Widget packageId (e.g. "@scope/name")
73541
+ * @returns {Promise<Object>} { success, packageId, localScope, name, version, displayName, description, components: [{name, displayName, description, icon}] }
73542
+ */
73543
+ inspectWidgetPackage: async (packageId) => {
73544
+ try {
73545
+ return await ipcRenderer$h.invoke("registry:inspect-widget-package", {
73546
+ packageId,
73547
+ });
73548
+ } catch (error) {
73549
+ console.error("[RegistryApi] Error inspecting package:", error);
73550
+ throw error;
73551
+ }
73552
+ },
73421
73553
  };
73422
73554
 
73423
73555
  var registryApi_1 = registryApi$2;