@trops/dash-core 0.1.321 → 0.1.322
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.
- package/dist/electron/index.js +100 -0
- package/dist/electron/index.js.map +1 -1
- package/dist/index.esm.js +106 -50
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +74 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/electron/index.js
CHANGED
|
@@ -51640,6 +51640,84 @@ var schedulerController_1 = schedulerController$2;
|
|
|
51640
51640
|
}
|
|
51641
51641
|
});
|
|
51642
51642
|
|
|
51643
|
+
ipcMain.handle(
|
|
51644
|
+
"widget:read-sources",
|
|
51645
|
+
async (event, { widgetName, componentName }) => {
|
|
51646
|
+
try {
|
|
51647
|
+
const registry = getWidgetRegistry();
|
|
51648
|
+
const widget = registry.getWidget(widgetName);
|
|
51649
|
+
if (!widget || !widget.path) {
|
|
51650
|
+
return {
|
|
51651
|
+
success: false,
|
|
51652
|
+
error: `Widget not found: ${widgetName}`,
|
|
51653
|
+
};
|
|
51654
|
+
}
|
|
51655
|
+
|
|
51656
|
+
const widgetsDir = findWidgetsDir(widget.path);
|
|
51657
|
+
if (!widgetsDir) {
|
|
51658
|
+
return {
|
|
51659
|
+
success: false,
|
|
51660
|
+
error: `No source files found for: ${widgetName}`,
|
|
51661
|
+
};
|
|
51662
|
+
}
|
|
51663
|
+
|
|
51664
|
+
// Find target component (use componentName or first .dash.js file)
|
|
51665
|
+
const files = fs.readdirSync(widgetsDir);
|
|
51666
|
+
const target =
|
|
51667
|
+
componentName ||
|
|
51668
|
+
files.find((f) => f.endsWith(".dash.js"))?.replace(".dash.js", "");
|
|
51669
|
+
|
|
51670
|
+
if (!target) {
|
|
51671
|
+
return {
|
|
51672
|
+
success: false,
|
|
51673
|
+
error: `No widget component found in: ${widgetsDir}`,
|
|
51674
|
+
};
|
|
51675
|
+
}
|
|
51676
|
+
|
|
51677
|
+
const componentPath = path.join(widgetsDir, `${target}.js`);
|
|
51678
|
+
const configPath = path.join(widgetsDir, `${target}.dash.js`);
|
|
51679
|
+
|
|
51680
|
+
if (!fs.existsSync(componentPath)) {
|
|
51681
|
+
return {
|
|
51682
|
+
success: false,
|
|
51683
|
+
error: `Component source not found: ${target}.js`,
|
|
51684
|
+
};
|
|
51685
|
+
}
|
|
51686
|
+
|
|
51687
|
+
const componentCode = fs.readFileSync(componentPath, "utf8");
|
|
51688
|
+
const configCode = fs.existsSync(configPath)
|
|
51689
|
+
? fs.readFileSync(configPath, "utf8")
|
|
51690
|
+
: "";
|
|
51691
|
+
|
|
51692
|
+
// Read manifest
|
|
51693
|
+
const manifestPath = path.join(widget.path, "dash.json");
|
|
51694
|
+
let manifest = null;
|
|
51695
|
+
if (fs.existsSync(manifestPath)) {
|
|
51696
|
+
try {
|
|
51697
|
+
manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
|
|
51698
|
+
} catch (_) {
|
|
51699
|
+
/* ignore parse errors */
|
|
51700
|
+
}
|
|
51701
|
+
}
|
|
51702
|
+
|
|
51703
|
+
return {
|
|
51704
|
+
success: true,
|
|
51705
|
+
componentCode,
|
|
51706
|
+
configCode,
|
|
51707
|
+
manifest,
|
|
51708
|
+
widgetName,
|
|
51709
|
+
componentName: target,
|
|
51710
|
+
};
|
|
51711
|
+
} catch (error) {
|
|
51712
|
+
console.error(
|
|
51713
|
+
`[WidgetRegistry] Error reading sources for ${widgetName}:`,
|
|
51714
|
+
error,
|
|
51715
|
+
);
|
|
51716
|
+
return { success: false, error: error.message };
|
|
51717
|
+
}
|
|
51718
|
+
},
|
|
51719
|
+
);
|
|
51720
|
+
|
|
51643
51721
|
ipcMain.handle("widget:read-all-bundles", async () => {
|
|
51644
51722
|
try {
|
|
51645
51723
|
const registry = getWidgetRegistry();
|
|
@@ -71996,6 +72074,28 @@ const widgetApi$2 = {
|
|
|
71996
72074
|
}
|
|
71997
72075
|
},
|
|
71998
72076
|
|
|
72077
|
+
/**
|
|
72078
|
+
* Read widget source files (.js + .dash.js + manifest)
|
|
72079
|
+
*
|
|
72080
|
+
* @param {string} widgetName - Scoped widget package name (e.g., "@ai-built/counter")
|
|
72081
|
+
* @param {string} [componentName] - Specific component to read (optional, defaults to first found)
|
|
72082
|
+
* @returns {Promise<Object>} { success, componentCode, configCode, manifest, widgetName, componentName }
|
|
72083
|
+
*/
|
|
72084
|
+
readSources: async (widgetName, componentName) => {
|
|
72085
|
+
try {
|
|
72086
|
+
return await ipcRenderer$k.invoke("widget:read-sources", {
|
|
72087
|
+
widgetName,
|
|
72088
|
+
componentName,
|
|
72089
|
+
});
|
|
72090
|
+
} catch (error) {
|
|
72091
|
+
console.error(
|
|
72092
|
+
`[WidgetApi] Error reading sources for ${widgetName}:`,
|
|
72093
|
+
error,
|
|
72094
|
+
);
|
|
72095
|
+
return { success: false, error: error.message };
|
|
72096
|
+
}
|
|
72097
|
+
},
|
|
72098
|
+
|
|
71999
72099
|
/**
|
|
72000
72100
|
* Read CJS bundle sources for all installed widgets
|
|
72001
72101
|
*
|