@trops/dash-core 0.1.23 → 0.1.26

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.
@@ -7567,6 +7567,12 @@ function findWidgetsDir$1(widgetPath) {
7567
7567
  return direct;
7568
7568
  }
7569
7569
 
7570
+ // Check configs/ directory (used by packageZip.js for distributed widgets)
7571
+ const configs = path$1.join(widgetPath, "configs");
7572
+ if (fs$1.existsSync(configs)) {
7573
+ return configs;
7574
+ }
7575
+
7570
7576
  // Check one level deeper for nested ZIP extraction
7571
7577
  try {
7572
7578
  const entries = fs$1.readdirSync(widgetPath, { withFileTypes: true });
@@ -7693,6 +7699,7 @@ async function compileWidget(widgetPath) {
7693
7699
  "react",
7694
7700
  "react-dom",
7695
7701
  "@trops/dash-react",
7702
+ "@trops/dash-core",
7696
7703
  "react/jsx-runtime",
7697
7704
  "prop-types",
7698
7705
  ],
@@ -7803,10 +7810,13 @@ class DynamicWidgetLoader {
7803
7810
 
7804
7811
  if (autoRegister && this.componentManager) {
7805
7812
  try {
7806
- this.componentManager.registerWidget(config, componentName);
7813
+ // Use scoped id as registration key if available,
7814
+ // otherwise fall back to componentName
7815
+ const registrationKey = config.id || componentName;
7816
+ this.componentManager.registerWidget(config, registrationKey);
7807
7817
  registered = true;
7808
7818
  console.log(
7809
- `[DynamicWidgetLoader] ✓ Registered ${componentName} with ComponentManager`,
7819
+ `[DynamicWidgetLoader] ✓ Registered ${registrationKey} with ComponentManager`,
7810
7820
  );
7811
7821
  } catch (regError) {
7812
7822
  console.warn(
@@ -7838,13 +7848,36 @@ class DynamicWidgetLoader {
7838
7848
  try {
7839
7849
  const source = fs.readFileSync(configPath, "utf8");
7840
7850
 
7841
- const exportMatch = source.match(/export\s+default\s+({[\s\S]*});?\s*$/);
7851
+ let exportMatch = source.match(/export\s+default\s+({[\s\S]*});?\s*$/);
7852
+
7853
+ // Handle variable export pattern: const x = {...}; export default x;
7854
+ if (!exportMatch) {
7855
+ const varExportMatch = source.match(
7856
+ /export\s+default\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*;?\s*$/,
7857
+ );
7858
+ if (varExportMatch) {
7859
+ const varName = varExportMatch[1];
7860
+ const varDeclMatch = source.match(
7861
+ new RegExp(
7862
+ `(?:const|let|var)\\s+${varName}\\s*=\\s*({[\\s\\S]*?});\\s*(?:export\\s+default)`,
7863
+ ),
7864
+ );
7865
+ if (varDeclMatch) {
7866
+ exportMatch = varDeclMatch;
7867
+ }
7868
+ }
7869
+ }
7842
7870
 
7843
7871
  if (!exportMatch) {
7844
7872
  throw new Error("Could not find default export in config file");
7845
7873
  }
7846
7874
 
7847
- const exportedObjectStr = exportMatch[1];
7875
+ // Sanitize component references so vm.runInContext doesn't fail
7876
+ // on unresolvable imports — replace component: SomeName with component: "SomeName"
7877
+ const exportedObjectStr = exportMatch[1].replace(
7878
+ /component\s*:\s*([A-Z][a-zA-Z0-9_$]*)/g,
7879
+ 'component: "$1"',
7880
+ );
7848
7881
 
7849
7882
  const context = vm.createContext({ module: { exports: {} } });
7850
7883
  vm.runInContext(`module.exports = ${exportedObjectStr}`, context);
@@ -8714,6 +8747,8 @@ var dynamicWidgetLoaderExports = dynamicWidgetLoader$2.exports;
8714
8747
  configs.push({
8715
8748
  componentName,
8716
8749
  widgetPackage: widget.name,
8750
+ // Include scoped id if present in the config
8751
+ id: config.id || null,
8717
8752
  config,
8718
8753
  });
8719
8754
  } catch (err) {