@trops/dash-core 0.1.390 → 0.1.391
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 +49 -7
- package/dist/electron/index.js.map +1 -1
- package/package.json +1 -1
package/dist/electron/index.js
CHANGED
|
@@ -29711,14 +29711,23 @@ async function searchThemes(query = "", filters = {}) {
|
|
|
29711
29711
|
* where the user is browsing registry widgets and wants to see them render
|
|
29712
29712
|
* inline before choosing to install or remix.
|
|
29713
29713
|
*
|
|
29714
|
+
* Multi-widget packages (e.g. @trops/clock contains Analog/Digital/Flip/Text
|
|
29715
|
+
* clocks) ship with one .js + .dash.js pair per widget. Pass `componentName`
|
|
29716
|
+
* to pick a specific widget — otherwise we return the alphabetically-first
|
|
29717
|
+
* widget found, which is almost never what the caller wants for UI previews.
|
|
29718
|
+
*
|
|
29714
29719
|
* @param {string} packageName - Any form accepted by getPackage()
|
|
29715
29720
|
* (bare name, scoped "scope/name", or displayName)
|
|
29721
|
+
* @param {string} [componentName] - Specific widget inside the package to
|
|
29722
|
+
* return. Matched against file names in `widgets/`. Accepts either a
|
|
29723
|
+
* bare name ("FlipClockWidget") or a dotted scoped id
|
|
29724
|
+
* ("trops.clock.FlipClockWidget") — the last dotted segment is used.
|
|
29716
29725
|
* @returns {Promise<Object>} {
|
|
29717
29726
|
* componentCode, configCode, bundleSource, widgetName,
|
|
29718
29727
|
* displayName, description, packageName, scope, downloadUrl
|
|
29719
29728
|
* }
|
|
29720
29729
|
*/
|
|
29721
|
-
async function fetchPackageSource(packageName) {
|
|
29730
|
+
async function fetchPackageSource(packageName, componentName = null) {
|
|
29722
29731
|
if (!packageName) {
|
|
29723
29732
|
throw new Error("fetchPackageSource: packageName is required");
|
|
29724
29733
|
}
|
|
@@ -29809,14 +29818,40 @@ async function fetchPackageSource(packageName) {
|
|
|
29809
29818
|
|
|
29810
29819
|
if (fs$5.existsSync(widgetsDir)) {
|
|
29811
29820
|
const files = fs$5.readdirSync(widgetsDir);
|
|
29812
|
-
const
|
|
29821
|
+
const dashFiles = files.filter((f) => f.endsWith(".dash.js"));
|
|
29822
|
+
const componentFiles = files.filter(
|
|
29823
|
+
(f) => f.endsWith(".js") && !f.endsWith(".dash.js") && f !== "index.js",
|
|
29824
|
+
);
|
|
29825
|
+
|
|
29826
|
+
// Normalize componentName hint: accept "FlipClockWidget" or the
|
|
29827
|
+
// dotted form "trops.clock.FlipClockWidget" (last segment wins).
|
|
29828
|
+
const bareHint =
|
|
29829
|
+
typeof componentName === "string" && componentName.length
|
|
29830
|
+
? componentName.split(".").pop()
|
|
29831
|
+
: null;
|
|
29832
|
+
|
|
29833
|
+
// Pick the .dash.js pair that matches the hint; fall back to the
|
|
29834
|
+
// first file so pre-hint callers still work.
|
|
29835
|
+
let configFile = null;
|
|
29836
|
+
if (bareHint) {
|
|
29837
|
+
configFile = dashFiles.find((f) => f === `${bareHint}.dash.js`);
|
|
29838
|
+
}
|
|
29839
|
+
if (!configFile) configFile = dashFiles[0];
|
|
29840
|
+
|
|
29813
29841
|
if (configFile) {
|
|
29814
29842
|
configCode = fs$5.readFileSync(path$9.join(widgetsDir, configFile), "utf8");
|
|
29815
29843
|
widgetName = configFile.replace(/\.dash\.js$/, "");
|
|
29816
29844
|
}
|
|
29817
|
-
|
|
29818
|
-
|
|
29819
|
-
)
|
|
29845
|
+
|
|
29846
|
+
let componentFile = null;
|
|
29847
|
+
if (widgetName) {
|
|
29848
|
+
componentFile = componentFiles.find((f) => f === `${widgetName}.js`);
|
|
29849
|
+
}
|
|
29850
|
+
if (!componentFile && bareHint) {
|
|
29851
|
+
componentFile = componentFiles.find((f) => f === `${bareHint}.js`);
|
|
29852
|
+
}
|
|
29853
|
+
if (!componentFile) componentFile = componentFiles[0];
|
|
29854
|
+
|
|
29820
29855
|
if (componentFile) {
|
|
29821
29856
|
componentCode = fs$5.readFileSync(
|
|
29822
29857
|
path$9.join(widgetsDir, componentFile),
|
|
@@ -74400,11 +74435,18 @@ const registryApi$2 = {
|
|
|
74400
74435
|
* Discover tab).
|
|
74401
74436
|
*
|
|
74402
74437
|
* @param {string} packageName - Name of the package (any form)
|
|
74438
|
+
* @param {string} [componentName] - Specific widget in a multi-widget
|
|
74439
|
+
* package. Accepts either a bare name ("FlipClockWidget") or a dotted
|
|
74440
|
+
* scoped id ("trops.clock.FlipClockWidget").
|
|
74403
74441
|
* @returns {Promise<Object>} { componentCode, configCode, bundleSource, widgetName, displayName, description, packageName, scope, downloadUrl }
|
|
74404
74442
|
*/
|
|
74405
|
-
previewFetch: async (packageName) => {
|
|
74443
|
+
previewFetch: async (packageName, componentName = null) => {
|
|
74406
74444
|
try {
|
|
74407
|
-
return await ipcRenderer$h.invoke(
|
|
74445
|
+
return await ipcRenderer$h.invoke(
|
|
74446
|
+
"registry:preview-fetch",
|
|
74447
|
+
packageName,
|
|
74448
|
+
componentName,
|
|
74449
|
+
);
|
|
74408
74450
|
} catch (error) {
|
|
74409
74451
|
console.error(
|
|
74410
74452
|
`[RegistryApi] Error fetching preview source for ${packageName}:`,
|