@trops/dash-core 0.1.376 → 0.1.378
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 +56 -11
- package/dist/electron/index.js.map +1 -1
- package/dist/index.esm.js +38 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +38 -8
- package/dist/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 {
|
|
@@ -72130,15 +72152,28 @@ async function prepareWidgetForPublish$1(appId, packageId, options = {}) {
|
|
|
72130
72152
|
};
|
|
72131
72153
|
}
|
|
72132
72154
|
|
|
72133
|
-
// 3. Read package.json
|
|
72155
|
+
// 3. Read package.json (or fall back to dash.json for registry-installed widgets)
|
|
72134
72156
|
const pkgJsonPath = path.join(widget.path, "package.json");
|
|
72135
|
-
|
|
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 {
|
|
72136
72172
|
return {
|
|
72137
72173
|
success: false,
|
|
72138
|
-
error: `Widget package is missing package.json: ${widget.path}`,
|
|
72174
|
+
error: `Widget package is missing package.json and dash.json: ${widget.path}`,
|
|
72139
72175
|
};
|
|
72140
72176
|
}
|
|
72141
|
-
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
|
72142
72177
|
// Scope resolution: the caller's registry username always wins. The
|
|
72143
72178
|
// package.json may use a local naming convention (e.g. `@ai-built/…`
|
|
72144
72179
|
// for AI-generated widgets) but the registry only allows publishing
|
|
@@ -72152,7 +72187,17 @@ async function prepareWidgetForPublish$1(appId, packageId, options = {}) {
|
|
|
72152
72187
|
const newVersion = resolveNextVersion(previousVersion, options);
|
|
72153
72188
|
if (newVersion !== previousVersion) {
|
|
72154
72189
|
pkgJson.version = newVersion;
|
|
72155
|
-
|
|
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
|
+
}
|
|
72156
72201
|
}
|
|
72157
72202
|
|
|
72158
72203
|
// 5. Build manifest using the widget's component configs. The
|