@trops/dash-core 0.1.412 → 0.1.414

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.
@@ -27103,7 +27103,7 @@ async function updateRegistryPackage$1(scope, name, updates) {
27103
27103
  * @param {string} name - Package name
27104
27104
  * @returns {Promise<Object|null>} Response or null
27105
27105
  */
27106
- async function deleteRegistryPackage(scope, name) {
27106
+ async function deleteRegistryPackage$1(scope, name) {
27107
27107
  const stored = getStoredToken$4();
27108
27108
  if (!stored) return null;
27109
27109
 
@@ -27124,7 +27124,19 @@ async function deleteRegistryPackage(scope, name) {
27124
27124
  }
27125
27125
  if (!response.ok) return null;
27126
27126
 
27127
- return await response.json();
27127
+ // A successful DELETE frequently returns 204 No Content, in which
27128
+ // case response.json() throws on empty body and the earlier version
27129
+ // swallowed it as a null result — the UI then skipped its "onDeleted"
27130
+ // refresh and looked like nothing happened. Handle 204 + unparseable
27131
+ // success responses as a successful delete.
27132
+ if (response.status === 204) {
27133
+ return { success: true };
27134
+ }
27135
+ try {
27136
+ return await response.json();
27137
+ } catch {
27138
+ return { success: true };
27139
+ }
27128
27140
  } catch {
27129
27141
  return null;
27130
27142
  }
@@ -27139,7 +27151,7 @@ var registryAuthController$2 = {
27139
27151
  updateRegistryProfile: updateRegistryProfile$1,
27140
27152
  getRegistryPackages: getRegistryPackages$1,
27141
27153
  updateRegistryPackage: updateRegistryPackage$1,
27142
- deleteRegistryPackage,
27154
+ deleteRegistryPackage: deleteRegistryPackage$1,
27143
27155
  clearToken: clearToken$2,
27144
27156
  };
27145
27157
 
@@ -63467,6 +63479,29 @@ function extractEventWiring$1(layout) {
63467
63479
  return wiring;
63468
63480
  }
63469
63481
 
63482
+ /**
63483
+ * Strip a `<scope>/` or `@<scope>/` prefix from a potentially-scoped
63484
+ * package name. Widgets installed from the registry carry
63485
+ * `w.name = "@scope/pkg"` alongside `w.scope = "scope"`; downstream
63486
+ * code builds `${scope}/${packageName}` for display and for registry
63487
+ * keys, so `packageName` must be the bare name or the scope doubles
63488
+ * (e.g. `@trops/@ai-built/pipeline` instead of `@trops/pipeline`).
63489
+ *
63490
+ * @param {string} fullName Potentially scoped (e.g. "@ai-built/pipeline" or "ai-built/pipeline")
63491
+ * @param {string} scope Scope to strip (e.g. "ai-built" or "@ai-built")
63492
+ * @returns {string} The bare package name
63493
+ */
63494
+ function stripScopePrefix(fullName, scope) {
63495
+ if (!fullName) return fullName || "";
63496
+ if (!scope) return fullName;
63497
+ const bareScope = scope.startsWith("@") ? scope.slice(1) : scope;
63498
+ const variants = [`@${bareScope}/`, `${bareScope}/`];
63499
+ for (const v of variants) {
63500
+ if (fullName.startsWith(v)) return fullName.slice(v.length);
63501
+ }
63502
+ return fullName;
63503
+ }
63504
+
63470
63505
  /**
63471
63506
  * Build the widget dependencies array from component names and
63472
63507
  * installed widget metadata.
@@ -63508,7 +63543,9 @@ function buildWidgetDependencies$1(
63508
63543
  for (const w of installedWidgets) {
63509
63544
  if (w.componentNames && w.componentNames.includes(name)) {
63510
63545
  if (!scope && w.scope) scope = w.scope;
63511
- if (!packageName || packageName === name) packageName = w.name || "";
63546
+ if (!packageName || packageName === name) {
63547
+ packageName = stripScopePrefix(w.name, w.scope || scope) || "";
63548
+ }
63512
63549
  version = w.version || "*";
63513
63550
  author =
63514
63551
  typeof w.author === "string" ? w.author : w.author?.name || "";
@@ -63521,8 +63558,9 @@ function buildWidgetDependencies$1(
63521
63558
  if (componentConfigs && componentConfigs[name]) {
63522
63559
  const config = componentConfigs[name];
63523
63560
  if (!scope && config.scope) scope = config.scope;
63524
- if ((!packageName || packageName === name) && config.packageName)
63525
- packageName = config.packageName;
63561
+ if ((!packageName || packageName === name) && config.packageName) {
63562
+ packageName = stripScopePrefix(config.packageName, scope);
63563
+ }
63526
63564
  if (config.id && !scope) {
63527
63565
  const idParts = config.id.split(".");
63528
63566
  if (idParts.length === 3) {
@@ -73193,7 +73231,38 @@ async function prepareWidgetForPublish$1(appId, packageId, options = {}) {
73193
73231
  }
73194
73232
  }
73195
73233
 
73196
- // 5. Build manifest using the widget's component configs. The
73234
+ // 5. Normalize dash.json's author field. The AI Widget Builder
73235
+ // scaffolds new @ai-built/* widgets with `author: "AI Assistant"`
73236
+ // as the placeholder, which ships unchanged to the registry and
73237
+ // is what installers see under the package's author — regardless
73238
+ // of who actually published it. If dash.json exists and its
73239
+ // author is blank or that placeholder, rewrite with the
73240
+ // publisher's registry display name (or username) before we zip
73241
+ // the package. Any other user-set author is preserved.
73242
+ const authorOverride =
73243
+ (options.authorName && options.authorName.trim()) ||
73244
+ profile?.displayName ||
73245
+ profile?.username ||
73246
+ "";
73247
+ if (authorOverride && fs.existsSync(dashJsonPath)) {
73248
+ try {
73249
+ const dashJson = JSON.parse(fs.readFileSync(dashJsonPath, "utf8"));
73250
+ const current = (dashJson.author || "").trim();
73251
+ const isPlaceholder = !current || current === "AI Assistant";
73252
+ if (isPlaceholder && dashJson.author !== authorOverride) {
73253
+ dashJson.author = authorOverride;
73254
+ fs.writeFileSync(
73255
+ dashJsonPath,
73256
+ JSON.stringify(dashJson, null, 2) + "\n",
73257
+ );
73258
+ }
73259
+ } catch {
73260
+ // Best-effort only — a malformed dash.json will surface later
73261
+ // during manifest generation with a clearer error.
73262
+ }
73263
+ }
73264
+
73265
+ // 6. Build manifest using the widget's component configs. The
73197
73266
  // registry cache may be missing widgets (orphaned / locally-
73198
73267
  // registered packages), so fall back to scanning the package's
73199
73268
  // .dash.js files from disk.
@@ -73217,24 +73286,27 @@ async function prepareWidgetForPublish$1(appId, packageId, options = {}) {
73217
73286
  tags: options.tags,
73218
73287
  icon: options.icon,
73219
73288
  category: options.category,
73220
- authorName: options.authorName,
73289
+ // Prefer the caller-supplied authorName; otherwise fall back to
73290
+ // the publisher's registry profile so the manifest author matches
73291
+ // the (now-rewritten) dash.json we just zipped.
73292
+ authorName: options.authorName || authorOverride || undefined,
73221
73293
  appOrigin: appId,
73222
73294
  });
73223
73295
 
73224
- // 6. Zip the widget directory to a temp file
73296
+ // 7. Zip the widget directory to a temp file
73225
73297
  const zipName = `widget-${manifest.scope}-${manifest.name}-v${manifest.version}.zip`;
73226
73298
  const zipPath = path.join(app.getPath("temp"), zipName);
73227
73299
  const zip = new AdmZip();
73228
73300
  addDirToZip(zip, widget.path);
73229
73301
  zip.writeZip(zipPath);
73230
73302
 
73231
- // 7. Publish to registry
73303
+ // 8. Publish to registry
73232
73304
  const registryResult = await registryApiController$1.publishToRegistry(
73233
73305
  zipPath,
73234
73306
  manifest,
73235
73307
  );
73236
73308
 
73237
- // 8. On failure: revert package.json (if we bumped) and surface details
73309
+ // 9. On failure: revert package.json (if we bumped) and surface details
73238
73310
  if (!registryResult.success) {
73239
73311
  if (newVersion !== previousVersion) {
73240
73312
  try {
@@ -73420,6 +73492,7 @@ const {
73420
73492
  updateRegistryProfile,
73421
73493
  getRegistryPackages,
73422
73494
  updateRegistryPackage,
73495
+ deleteRegistryPackage,
73423
73496
  clearToken: clearRegistryToken,
73424
73497
  } = registryAuthController$2;
73425
73498
  const {
@@ -73525,6 +73598,7 @@ var controller = {
73525
73598
  updateRegistryProfile,
73526
73599
  getRegistryPackages,
73527
73600
  updateRegistryPackage,
73601
+ deleteRegistryPackage,
73528
73602
  clearRegistryToken,
73529
73603
  publishToRegistry,
73530
73604
  getRegistryUrl,