@trops/dash-core 0.1.369 → 0.1.371

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.
@@ -64891,13 +64891,21 @@ async function collectDashboardDependencies$1(
64891
64891
  const installedWidgets = widgetRegistry ? widgetRegistry.getWidgets() : [];
64892
64892
 
64893
64893
  const widgets = deps.map((dep) => {
64894
- // Find the installed widget whose componentNames contains this dep's widgetName
64894
+ // Match by componentName OR by any shape of the package id.
64895
+ // Registry packages are stored as `@scope/name` but callers may
64896
+ // synthesize `scope/name`; try both before giving up.
64897
+ const candidateIds = new Set();
64898
+ if (dep.scope && dep.packageName) {
64899
+ candidateIds.add(`@${dep.scope}/${dep.packageName}`);
64900
+ candidateIds.add(`${dep.scope}/${dep.packageName}`);
64901
+ }
64895
64902
  const match = installedWidgets.find(
64896
64903
  (w) =>
64897
64904
  (w.componentNames && w.componentNames.includes(dep.widgetName)) ||
64898
64905
  (w.scope === dep.scope &&
64899
64906
  (w.name === dep.packageName ||
64900
- w.packageId === `${dep.scope}/${dep.packageName}`)),
64907
+ candidateIds.has(w.packageId) ||
64908
+ candidateIds.has(w.name))),
64901
64909
  );
64902
64910
 
64903
64911
  return {
@@ -64907,7 +64915,11 @@ async function collectDashboardDependencies$1(
64907
64915
  component: dep.widgetName,
64908
64916
  localVersion: dep.version,
64909
64917
  packageDir: match?.path || null,
64910
- packageId: match?.packageId || null,
64918
+ packageId:
64919
+ match?.packageId ||
64920
+ (dep.scope && dep.packageName
64921
+ ? `@${dep.scope}/${dep.packageName}`
64922
+ : null),
64911
64923
  author: dep.author || "",
64912
64924
  hasLocalPackage: !!match?.path,
64913
64925
  };
@@ -65232,49 +65244,9 @@ async function prepareDashboardForPublish$1(
65232
65244
 
65233
65245
  // 6. Check which widgets exist in the registry (soft warning, not blocking)
65234
65246
  const { fetchRegistryIndex } = registryController$3;
65235
- let registryPackages = [];
65236
- let registryCheckFailed = false;
65237
- try {
65238
- const index = await fetchRegistryIndex();
65239
- registryPackages = index.packages || [];
65240
- } catch (err) {
65241
- console.warn(
65242
- `[DashboardConfigController] Unable to verify registry: ${err.message}`,
65243
- );
65244
- registryCheckFailed = true;
65245
- }
65246
-
65247
- let missingFromRegistry = [];
65248
- if (!registryCheckFailed) {
65249
- const registryNames = new Set(registryPackages.map((p) => p.name));
65250
- const registryWidgetNames = new Set();
65251
- for (const pkg of registryPackages) {
65252
- if (pkg.widgets) {
65253
- for (const w of pkg.widgets) {
65254
- if (w.name) registryWidgetNames.add(w.name);
65255
- }
65256
- }
65257
- }
65258
- const missingWidgets = widgets.filter(
65259
- (w) =>
65260
- w.required !== false &&
65261
- !registryNames.has(w.package) &&
65262
- !registryWidgetNames.has(w.package),
65263
- );
65264
- const grouped = {};
65265
- for (const w of missingWidgets) {
65266
- if (!grouped[w.package]) grouped[w.package] = [];
65267
- const widgetName = w.id.includes(".") ? w.id.split(".")[1] : w.id;
65268
- if (!grouped[w.package].includes(widgetName)) {
65269
- grouped[w.package].push(widgetName);
65270
- }
65271
- }
65272
- missingFromRegistry = Object.entries(grouped).map(
65273
- ([pkg, widgetNames]) => ({ package: pkg, widgets: widgetNames }),
65274
- );
65275
- }
65276
-
65277
- // 7. Resolve registry username for scope
65247
+ // 7. Resolve registry username for scope (needed by the missing-widget
65248
+ // check so we look up each dep under the caller's actual scope,
65249
+ // not the local scope from the package.json).
65278
65250
  let registryUsername = options.githubUser || "";
65279
65251
  if (!registryUsername) {
65280
65252
  try {
@@ -65286,6 +65258,65 @@ async function prepareDashboardForPublish$1(
65286
65258
  }
65287
65259
  }
65288
65260
 
65261
+ // Check each widget dep's existence in the registry via the dynamic
65262
+ // resolve endpoint (static registry-index.json lags behind freshly-
65263
+ // published packages). Auth-scoped so private packages owned by the
65264
+ // caller surface as existing.
65265
+ let missingFromRegistry = [];
65266
+ let registryCheckFailed = false;
65267
+ try {
65268
+ const { resolvePackages } = registryApiController$3;
65269
+ const seen = new Set();
65270
+ const refs = [];
65271
+ for (const w of widgets) {
65272
+ if (w.required === false) continue;
65273
+ const scope = w.scope || registryUsername;
65274
+ const name = w.package || w.packageName;
65275
+ if (!scope || !name) continue;
65276
+ const key = `${scope}/${name}`;
65277
+ if (seen.has(key)) continue;
65278
+ seen.add(key);
65279
+ // Resolve under the caller's scope — that's where the package
65280
+ // would have been published regardless of the local scope on disk.
65281
+ refs.push({ scope: registryUsername || scope, name });
65282
+ }
65283
+ if (refs.length > 0) {
65284
+ const res = await resolvePackages(refs);
65285
+ if (!res.success) {
65286
+ registryCheckFailed = true;
65287
+ } else {
65288
+ const existsByKey = new Map();
65289
+ for (const r of res.resolved || []) {
65290
+ existsByKey.set(`${r.scope}/${r.name}`, r.exists);
65291
+ }
65292
+ const grouped = {};
65293
+ for (const w of widgets) {
65294
+ if (w.required === false) continue;
65295
+ const name = w.package || w.packageName;
65296
+ if (!name) continue;
65297
+ const resolveKey = `${registryUsername || w.scope}/${name}`;
65298
+ const exists = existsByKey.get(resolveKey);
65299
+ if (exists) continue;
65300
+ const widgetName = w.id?.includes(".")
65301
+ ? w.id.split(".")[1]
65302
+ : w.id || name;
65303
+ if (!grouped[name]) grouped[name] = [];
65304
+ if (!grouped[name].includes(widgetName)) {
65305
+ grouped[name].push(widgetName);
65306
+ }
65307
+ }
65308
+ missingFromRegistry = Object.entries(grouped).map(
65309
+ ([pkg, widgetNames]) => ({ package: pkg, widgets: widgetNames }),
65310
+ );
65311
+ }
65312
+ }
65313
+ } catch (err) {
65314
+ console.warn(
65315
+ `[DashboardConfigController] Unable to verify registry: ${err.message}`,
65316
+ );
65317
+ registryCheckFailed = true;
65318
+ }
65319
+
65289
65320
  // 8. Generate registry manifest
65290
65321
  const manifest = generateRegistryManifest(dashboardConfig, {
65291
65322
  githubUser: registryUsername,
@@ -71949,6 +71980,29 @@ const {
71949
71980
  generateWidgetRegistryManifest,
71950
71981
  } = widgetPublishManifest;
71951
71982
 
71983
+ /**
71984
+ * Resilient widget lookup. Callers pass identifiers in different shapes —
71985
+ * `@scope/name`, `scope/name`, sometimes bare `name`. Try a few common
71986
+ * variants so the batch-publish dialog (which synthesizes a fallback
71987
+ * packageId from scope/packageName without the `@` prefix) still finds
71988
+ * the registered package.
71989
+ */
71990
+ function findWidget(registry, packageId) {
71991
+ if (!packageId) return null;
71992
+ const candidates = new Set();
71993
+ candidates.add(packageId);
71994
+ if (packageId.startsWith("@")) {
71995
+ candidates.add(packageId.slice(1));
71996
+ } else if (packageId.includes("/")) {
71997
+ candidates.add(`@${packageId}`);
71998
+ }
71999
+ for (const id of candidates) {
72000
+ const w = registry.getWidget(id);
72001
+ if (w) return w;
72002
+ }
72003
+ return null;
72004
+ }
72005
+
71952
72006
  /**
71953
72007
  * Scan a widget package directory for `.dash.js` component configs and
71954
72008
  * return the parsed configs. Used when the widget registry's cached
@@ -72055,7 +72109,7 @@ async function prepareWidgetForPublish$1(appId, packageId, options = {}) {
72055
72109
 
72056
72110
  // 2. Look up widget in local registry
72057
72111
  const registry = widgetRegistryModule.getWidgetRegistry();
72058
- const widget = registry.getWidget(packageId);
72112
+ const widget = findWidget(registry, packageId);
72059
72113
  if (!widget || !widget.path) {
72060
72114
  return {
72061
72115
  success: false,
@@ -72181,7 +72235,7 @@ async function prepareWidgetForPublish$1(appId, packageId, options = {}) {
72181
72235
  async function inspectWidgetPackage$1(packageId) {
72182
72236
  try {
72183
72237
  const registry = widgetRegistryModule.getWidgetRegistry();
72184
- const widget = registry.getWidget(packageId);
72238
+ const widget = findWidget(registry, packageId);
72185
72239
  if (!widget || !widget.path) {
72186
72240
  return {
72187
72241
  success: false,