@trops/dash-core 0.1.362 → 0.1.364

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.
@@ -49680,7 +49680,7 @@ var mcpDashServerController_1 = mcpDashServerController$4;
49680
49680
 
49681
49681
  var widgetRegistry$1 = {exports: {}};
49682
49682
 
49683
- var dynamicWidgetLoader$2 = {exports: {}};
49683
+ var dynamicWidgetLoader$3 = {exports: {}};
49684
49684
 
49685
49685
  /**
49686
49686
  * Widget Compiler
@@ -49707,7 +49707,7 @@ const path$6 = require$$1$2;
49707
49707
  * @param {string} widgetPath - Absolute path to the widget directory
49708
49708
  * @returns {string|null} Path to the widgets/ directory, or null
49709
49709
  */
49710
- function findWidgetsDir$1(widgetPath) {
49710
+ function findWidgetsDir$2(widgetPath) {
49711
49711
  const direct = path$6.join(widgetPath, "widgets");
49712
49712
  if (fs$3.existsSync(direct)) {
49713
49713
  return direct;
@@ -49762,7 +49762,7 @@ function findWidgetsDir$1(widgetPath) {
49762
49762
  * @returns {Promise<string|null>} Path to the compiled bundle, or null if nothing to compile
49763
49763
  */
49764
49764
  async function compileWidget(widgetPath) {
49765
- const widgetsDir = findWidgetsDir$1(widgetPath);
49765
+ const widgetsDir = findWidgetsDir$2(widgetPath);
49766
49766
 
49767
49767
  if (!widgetsDir) {
49768
49768
  console.log(
@@ -49884,7 +49884,7 @@ async function compileWidget(widgetPath) {
49884
49884
  }
49885
49885
  }
49886
49886
 
49887
- var widgetCompiler$1 = { compileWidget, findWidgetsDir: findWidgetsDir$1 };
49887
+ var widgetCompiler$1 = { compileWidget, findWidgetsDir: findWidgetsDir$2 };
49888
49888
 
49889
49889
  /**
49890
49890
  * Dynamic Widget Loader
@@ -49901,7 +49901,7 @@ var widgetCompiler$1 = { compileWidget, findWidgetsDir: findWidgetsDir$1 };
49901
49901
  const fs$2 = require$$0$2;
49902
49902
  const path$5 = require$$1$2;
49903
49903
  const vm = require$$2$4;
49904
- const { findWidgetsDir } = widgetCompiler$1;
49904
+ const { findWidgetsDir: findWidgetsDir$1 } = widgetCompiler$1;
49905
49905
 
49906
49906
  class DynamicWidgetLoader {
49907
49907
  constructor(componentManager = null) {
@@ -49940,7 +49940,7 @@ class DynamicWidgetLoader {
49940
49940
  );
49941
49941
 
49942
49942
  const widgetsDir =
49943
- findWidgetsDir(widgetPath) || path$5.join(widgetPath, "widgets");
49943
+ findWidgetsDir$1(widgetPath) || path$5.join(widgetPath, "widgets");
49944
49944
  const componentPath = path$5.join(widgetsDir, `${componentName}.js`);
49945
49945
  const configPath = path$5.join(widgetsDir, `${componentName}.dash.js`);
49946
49946
 
@@ -50048,7 +50048,7 @@ class DynamicWidgetLoader {
50048
50048
  */
50049
50049
  discoverWidgets(widgetPath) {
50050
50050
  try {
50051
- const widgetsDir = findWidgetsDir(widgetPath);
50051
+ const widgetsDir = findWidgetsDir$1(widgetPath);
50052
50052
  if (!widgetsDir) {
50053
50053
  return [];
50054
50054
  }
@@ -50079,12 +50079,12 @@ class DynamicWidgetLoader {
50079
50079
  }
50080
50080
  }
50081
50081
 
50082
- const dynamicWidgetLoader$1 = new DynamicWidgetLoader();
50082
+ const dynamicWidgetLoader$2 = new DynamicWidgetLoader();
50083
50083
 
50084
- dynamicWidgetLoader$2.exports = DynamicWidgetLoader;
50085
- dynamicWidgetLoader$2.exports.dynamicWidgetLoader = dynamicWidgetLoader$1;
50084
+ dynamicWidgetLoader$3.exports = DynamicWidgetLoader;
50085
+ dynamicWidgetLoader$3.exports.dynamicWidgetLoader = dynamicWidgetLoader$2;
50086
50086
 
50087
- var dynamicWidgetLoaderExports = dynamicWidgetLoader$2.exports;
50087
+ var dynamicWidgetLoaderExports = dynamicWidgetLoader$3.exports;
50088
50088
 
50089
50089
  /**
50090
50090
  * schedulerController.js
@@ -71862,12 +71862,45 @@ const {
71862
71862
  getRegistryProfile: getRegistryProfile$1,
71863
71863
  } = registryAuthController$2;
71864
71864
  const widgetRegistryModule = widgetRegistryExports;
71865
+ const { dynamicWidgetLoader: dynamicWidgetLoader$1 } = dynamicWidgetLoaderExports;
71866
+ const { findWidgetsDir } = widgetCompiler$1;
71865
71867
  const {
71866
71868
  resolveNextVersion,
71867
71869
  parsePackageName,
71868
71870
  generateWidgetRegistryManifest,
71869
71871
  } = widgetPublishManifest;
71870
71872
 
71873
+ /**
71874
+ * Scan a widget package directory for `.dash.js` component configs and
71875
+ * return the parsed configs. Used when the widget registry's cached
71876
+ * `config.widgets` is missing or empty (e.g. for orphaned / locally-
71877
+ * registered widgets) — lets us build a valid manifest from source.
71878
+ */
71879
+ async function scanWidgetConfigs(widgetPath) {
71880
+ try {
71881
+ const widgetsDir =
71882
+ findWidgetsDir(widgetPath) || path.join(widgetPath, "widgets");
71883
+ if (!fs.existsSync(widgetsDir)) return [];
71884
+ const files = fs.readdirSync(widgetsDir);
71885
+ const configs = [];
71886
+ for (const file of files) {
71887
+ if (!file.endsWith(".dash.js")) continue;
71888
+ const configPath = path.join(widgetsDir, file);
71889
+ try {
71890
+ // eslint-disable-next-line no-await-in-loop
71891
+ const cfg = await dynamicWidgetLoader$1.loadConfigFile(configPath);
71892
+ if (cfg && typeof cfg === "object") configs.push(cfg);
71893
+ } catch (err) {
71894
+ console.warn(`[widgetRegistry] skip ${file}: ${err.message}`);
71895
+ }
71896
+ }
71897
+ return configs;
71898
+ } catch (err) {
71899
+ console.warn("[widgetRegistry] scanWidgetConfigs failed:", err.message);
71900
+ return [];
71901
+ }
71902
+ }
71903
+
71871
71904
  // ─── ZIP builder ─────────────────────────────────────────────────────────────
71872
71905
 
71873
71906
  const ZIP_EXCLUDE_DIRS = new Set([
@@ -71960,9 +71993,13 @@ async function prepareWidgetForPublish$1(appId, packageId, options = {}) {
71960
71993
  };
71961
71994
  }
71962
71995
  const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
71996
+ // Scope resolution: the caller's registry username always wins. The
71997
+ // package.json may use a local naming convention (e.g. `@ai-built/…`
71998
+ // for AI-generated widgets) but the registry only allows publishing
71999
+ // under the authenticated user's scope. `options.scope` is honored
72000
+ // only if explicitly provided (e.g. for future org publishing).
71963
72001
  const parsedName = parsePackageName(pkgJson.name || "");
71964
- const resolvedScope =
71965
- options.scope || parsedName.scope || widget.scope || callerScope;
72002
+ const resolvedScope = options.scope || callerScope;
71966
72003
 
71967
72004
  // 4. Compute + persist new version
71968
72005
  const previousVersion = pkgJson.version || "1.0.0";
@@ -71972,22 +72009,33 @@ async function prepareWidgetForPublish$1(appId, packageId, options = {}) {
71972
72009
  fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + "\n");
71973
72010
  }
71974
72011
 
71975
- // 5. Build manifest using the widget's component configs
71976
- const manifest = generateWidgetRegistryManifest(
71977
- pkgJson,
71978
- widget.widgets || [],
71979
- {
71980
- scope: resolvedScope,
71981
- version: newVersion,
71982
- visibility: options.visibility,
71983
- description: options.description,
71984
- tags: options.tags,
71985
- icon: options.icon,
71986
- category: options.category,
71987
- authorName: options.authorName,
71988
- appOrigin: appId,
71989
- },
71990
- );
72012
+ // 5. Build manifest using the widget's component configs. The
72013
+ // registry cache may be missing widgets (orphaned / locally-
72014
+ // registered packages), so fall back to scanning the package's
72015
+ // .dash.js files from disk.
72016
+ let widgetConfigs = widget.widgets || [];
72017
+ if (!widgetConfigs.length) {
72018
+ widgetConfigs = await scanWidgetConfigs(widget.path);
72019
+ }
72020
+
72021
+ if (!widgetConfigs.length) {
72022
+ return {
72023
+ success: false,
72024
+ error: `No .dash.js widget configs found under ${widget.path}. A widget package must expose at least one component.`,
72025
+ };
72026
+ }
72027
+
72028
+ const manifest = generateWidgetRegistryManifest(pkgJson, widgetConfigs, {
72029
+ scope: resolvedScope,
72030
+ version: newVersion,
72031
+ visibility: options.visibility,
72032
+ description: options.description,
72033
+ tags: options.tags,
72034
+ icon: options.icon,
72035
+ category: options.category,
72036
+ authorName: options.authorName,
72037
+ appOrigin: appId,
72038
+ });
71991
72039
 
71992
72040
  // 6. Zip the widget directory to a temp file
71993
72041
  const zipName = `widget-${manifest.scope}-${manifest.name}-v${manifest.version}.zip`;
@@ -72002,13 +72050,18 @@ async function prepareWidgetForPublish$1(appId, packageId, options = {}) {
72002
72050
  manifest,
72003
72051
  );
72004
72052
 
72005
- // 8. On failure: revert package.json
72006
- if (!registryResult.success && newVersion !== previousVersion) {
72007
- try {
72008
- pkgJson.version = previousVersion;
72009
- fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + "\n");
72010
- } catch {
72011
- /* best effort */
72053
+ // 8. On failure: revert package.json (if we bumped) and surface details
72054
+ if (!registryResult.success) {
72055
+ if (newVersion !== previousVersion) {
72056
+ try {
72057
+ pkgJson.version = previousVersion;
72058
+ fs.writeFileSync(
72059
+ pkgJsonPath,
72060
+ JSON.stringify(pkgJson, null, 2) + "\n",
72061
+ );
72062
+ } catch {
72063
+ /* best effort */
72064
+ }
72012
72065
  }
72013
72066
  return {
72014
72067
  success: false,