@trops/dash-core 0.1.375 → 0.1.377
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 +81 -23
- package/dist/electron/index.js.map +1 -1
- package/package.json +1 -1
package/dist/electron/index.js
CHANGED
|
@@ -49804,9 +49804,15 @@ async function compileWidget(widgetPath) {
|
|
|
49804
49804
|
);
|
|
49805
49805
|
|
|
49806
49806
|
if (hasComponent) {
|
|
49807
|
-
// Import the component and merge with config
|
|
49807
|
+
// Import the component and merge with config.
|
|
49808
|
+
// Use namespace import so both default and named exports work:
|
|
49809
|
+
// export default function Foo → _Mod.default
|
|
49810
|
+
// export const Foo = ... → _Mod.Foo
|
|
49808
49811
|
imports.push(
|
|
49809
|
-
`import ${componentName}
|
|
49812
|
+
`import * as ${componentName}_Mod from "${relWidgetsDir}/${componentFile}";`,
|
|
49813
|
+
);
|
|
49814
|
+
imports.push(
|
|
49815
|
+
`const ${componentName}Comp = ${componentName}_Mod.default || ${componentName}_Mod.${componentName} || Object.values(${componentName}_Mod).find(v => typeof v === 'function');`,
|
|
49810
49816
|
);
|
|
49811
49817
|
exportParts.push(
|
|
49812
49818
|
`export const ${componentName} = { ...${componentName}Config, component: ${componentName}Comp };`,
|
|
@@ -49859,6 +49865,9 @@ async function compileWidget(widgetPath) {
|
|
|
49859
49865
|
],
|
|
49860
49866
|
// Treat .js files as JSX (widget sources use JSX in .js files)
|
|
49861
49867
|
loader: { ".js": "jsx" },
|
|
49868
|
+
// Use automatic JSX runtime (React 17+) so sources don't need
|
|
49869
|
+
// explicit `import React from "react"`.
|
|
49870
|
+
jsx: "automatic",
|
|
49862
49871
|
logLevel: "warning",
|
|
49863
49872
|
});
|
|
49864
49873
|
|
|
@@ -51757,11 +51766,24 @@ var schedulerController_1 = schedulerController$2;
|
|
|
51757
51766
|
};
|
|
51758
51767
|
}
|
|
51759
51768
|
|
|
51760
|
-
// Find target component (use componentName or first .dash.js file)
|
|
51769
|
+
// Find target component (use componentName or first .dash.js file).
|
|
51770
|
+
// Strip scope prefix from scoped IDs like "trops.algolia.AlgoliaSearchWidget"
|
|
51771
|
+
// since the file on disk is just "AlgoliaSearchWidget.js".
|
|
51761
51772
|
const files = fs.readdirSync(widgetsDir);
|
|
51762
|
-
|
|
51763
|
-
|
|
51764
|
-
|
|
51773
|
+
let target = componentName;
|
|
51774
|
+
if (target && target.includes(".")) {
|
|
51775
|
+
const bare = target.split(".").pop();
|
|
51776
|
+
if (
|
|
51777
|
+
files.some((f) => f === `${bare}.js` || f === `${bare}.dash.js`)
|
|
51778
|
+
) {
|
|
51779
|
+
target = bare;
|
|
51780
|
+
}
|
|
51781
|
+
}
|
|
51782
|
+
if (!target) {
|
|
51783
|
+
target = files
|
|
51784
|
+
.find((f) => f.endsWith(".dash.js"))
|
|
51785
|
+
?.replace(".dash.js", "");
|
|
51786
|
+
}
|
|
51765
51787
|
|
|
51766
51788
|
if (!target) {
|
|
51767
51789
|
return {
|
|
@@ -62775,17 +62797,27 @@ function generateRegistryManifest(dashboardConfig, options = {}) {
|
|
|
62775
62797
|
downloadUrl: `https://github.com/${githubUser}/dash-registry/releases/download/${githubUser}--${name}--v{version}/dashboard-${name}-v{version}.zip`,
|
|
62776
62798
|
repository: options.repository || "",
|
|
62777
62799
|
publishedAt: new Date().toISOString(),
|
|
62778
|
-
widgets: (dashboardConfig.widgets || []).map((w) =>
|
|
62779
|
-
|
|
62780
|
-
scope
|
|
62781
|
-
|
|
62782
|
-
|
|
62783
|
-
|
|
62784
|
-
|
|
62785
|
-
|
|
62786
|
-
|
|
62787
|
-
|
|
62788
|
-
|
|
62800
|
+
widgets: (dashboardConfig.widgets || []).map((w) => {
|
|
62801
|
+
// Remap local scopes (e.g. `@ai-built/…` for AI-generated widgets)
|
|
62802
|
+
// to the caller's published scope. Local conventions are private to
|
|
62803
|
+
// the publisher's machine — installers can only resolve packages
|
|
62804
|
+
// under the scope they were actually published as.
|
|
62805
|
+
const remappedScope =
|
|
62806
|
+
options.callerScope && w.scope && w.scope !== options.callerScope
|
|
62807
|
+
? options.callerScope
|
|
62808
|
+
: w.scope || "";
|
|
62809
|
+
return {
|
|
62810
|
+
id: w.id,
|
|
62811
|
+
scope: remappedScope,
|
|
62812
|
+
packageName: w.packageName || w.package || "",
|
|
62813
|
+
widgetName: w.widgetName || (w.id ? w.id.split(".").pop() : w.package),
|
|
62814
|
+
name: w.id ? w.id.split(".").pop() : w.package,
|
|
62815
|
+
package: w.package,
|
|
62816
|
+
version: w.version || "*",
|
|
62817
|
+
required: w.required !== false,
|
|
62818
|
+
author: w.author || "",
|
|
62819
|
+
};
|
|
62820
|
+
}),
|
|
62789
62821
|
providers: dashboardConfig.providers || [],
|
|
62790
62822
|
eventWiring: dashboardConfig.eventWiring || [],
|
|
62791
62823
|
};
|
|
@@ -65317,9 +65349,12 @@ async function prepareDashboardForPublish$1(
|
|
|
65317
65349
|
registryCheckFailed = true;
|
|
65318
65350
|
}
|
|
65319
65351
|
|
|
65320
|
-
// 8. Generate registry manifest
|
|
65352
|
+
// 8. Generate registry manifest — pass callerScope so local-only
|
|
65353
|
+
// scopes (e.g. `@ai-built/…`) get rewritten to the publisher's
|
|
65354
|
+
// actual registry scope on the way out.
|
|
65321
65355
|
const manifest = generateRegistryManifest(dashboardConfig, {
|
|
65322
65356
|
githubUser: registryUsername,
|
|
65357
|
+
callerScope: registryUsername,
|
|
65323
65358
|
category: options.category || "general",
|
|
65324
65359
|
repository: options.repository || "",
|
|
65325
65360
|
appOrigin: appId,
|
|
@@ -72117,15 +72152,28 @@ async function prepareWidgetForPublish$1(appId, packageId, options = {}) {
|
|
|
72117
72152
|
};
|
|
72118
72153
|
}
|
|
72119
72154
|
|
|
72120
|
-
// 3. Read package.json
|
|
72155
|
+
// 3. Read package.json (or fall back to dash.json for registry-installed widgets)
|
|
72121
72156
|
const pkgJsonPath = path.join(widget.path, "package.json");
|
|
72122
|
-
|
|
72157
|
+
const dashJsonPath = path.join(widget.path, "dash.json");
|
|
72158
|
+
let pkgJson;
|
|
72159
|
+
if (fs.existsSync(pkgJsonPath)) {
|
|
72160
|
+
pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
|
72161
|
+
} else if (fs.existsSync(dashJsonPath)) {
|
|
72162
|
+
// Registry-installed widgets only have dash.json — synthesize
|
|
72163
|
+
// the fields the publish flow needs from it.
|
|
72164
|
+
const dashJson = JSON.parse(fs.readFileSync(dashJsonPath, "utf8"));
|
|
72165
|
+
pkgJson = {
|
|
72166
|
+
name: dashJson.name ? `@${callerScope}/${dashJson.name}` : packageId,
|
|
72167
|
+
version: dashJson.version || "1.0.0",
|
|
72168
|
+
description: dashJson.description || "",
|
|
72169
|
+
author: dashJson.author || profile?.displayName || "",
|
|
72170
|
+
};
|
|
72171
|
+
} else {
|
|
72123
72172
|
return {
|
|
72124
72173
|
success: false,
|
|
72125
|
-
error: `Widget package is missing package.json: ${widget.path}`,
|
|
72174
|
+
error: `Widget package is missing package.json and dash.json: ${widget.path}`,
|
|
72126
72175
|
};
|
|
72127
72176
|
}
|
|
72128
|
-
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
|
72129
72177
|
// Scope resolution: the caller's registry username always wins. The
|
|
72130
72178
|
// package.json may use a local naming convention (e.g. `@ai-built/…`
|
|
72131
72179
|
// for AI-generated widgets) but the registry only allows publishing
|
|
@@ -72139,7 +72187,17 @@ async function prepareWidgetForPublish$1(appId, packageId, options = {}) {
|
|
|
72139
72187
|
const newVersion = resolveNextVersion(previousVersion, options);
|
|
72140
72188
|
if (newVersion !== previousVersion) {
|
|
72141
72189
|
pkgJson.version = newVersion;
|
|
72142
|
-
|
|
72190
|
+
// Persist to whichever metadata file exists
|
|
72191
|
+
if (fs.existsSync(pkgJsonPath)) {
|
|
72192
|
+
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2) + "\n");
|
|
72193
|
+
} else if (fs.existsSync(dashJsonPath)) {
|
|
72194
|
+
const dashJson = JSON.parse(fs.readFileSync(dashJsonPath, "utf8"));
|
|
72195
|
+
dashJson.version = newVersion;
|
|
72196
|
+
fs.writeFileSync(
|
|
72197
|
+
dashJsonPath,
|
|
72198
|
+
JSON.stringify(dashJson, null, 2) + "\n",
|
|
72199
|
+
);
|
|
72200
|
+
}
|
|
72143
72201
|
}
|
|
72144
72202
|
|
|
72145
72203
|
// 5. Build manifest using the widget's component configs. The
|