@trops/dash-core 0.1.320 → 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 +104 -0
- package/dist/electron/index.js.map +1 -1
- package/dist/index.esm.js +133 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +133 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/electron/index.js
CHANGED
|
@@ -27881,6 +27881,10 @@ const cliController$2 = {
|
|
|
27881
27881
|
stdio: ["pipe", "pipe", "pipe"],
|
|
27882
27882
|
};
|
|
27883
27883
|
if (cwd) {
|
|
27884
|
+
const fs = require("fs");
|
|
27885
|
+
if (!fs.existsSync(cwd)) {
|
|
27886
|
+
fs.mkdirSync(cwd, { recursive: true });
|
|
27887
|
+
}
|
|
27884
27888
|
spawnOpts.cwd = cwd;
|
|
27885
27889
|
}
|
|
27886
27890
|
const child = spawn(binaryPath, args, spawnOpts);
|
|
@@ -51636,6 +51640,84 @@ var schedulerController_1 = schedulerController$2;
|
|
|
51636
51640
|
}
|
|
51637
51641
|
});
|
|
51638
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
|
+
|
|
51639
51721
|
ipcMain.handle("widget:read-all-bundles", async () => {
|
|
51640
51722
|
try {
|
|
51641
51723
|
const registry = getWidgetRegistry();
|
|
@@ -71992,6 +72074,28 @@ const widgetApi$2 = {
|
|
|
71992
72074
|
}
|
|
71993
72075
|
},
|
|
71994
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
|
+
|
|
71995
72099
|
/**
|
|
71996
72100
|
* Read CJS bundle sources for all installed widgets
|
|
71997
72101
|
*
|