@bettercms-ai/convert 0.17.0 → 0.17.1
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/CHANGELOG.md +6 -0
- package/dist/cli.js +22 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -409,7 +409,7 @@ interface ConversionReceipt {
|
|
|
409
409
|
* reader must treat absent as unknown rather than as `"pending"`.
|
|
410
410
|
*/
|
|
411
411
|
canvas?: {
|
|
412
|
-
lane: "bridge" | "pending";
|
|
412
|
+
lane: "bridge" | "draft-route" | "pending";
|
|
413
413
|
files?: string[];
|
|
414
414
|
};
|
|
415
415
|
/**
|
|
@@ -1242,7 +1242,7 @@ interface CanvasSource {
|
|
|
1242
1242
|
ast?: unknown;
|
|
1243
1243
|
}
|
|
1244
1244
|
interface CanvasResult {
|
|
1245
|
-
lane: "bridge" | "pending";
|
|
1245
|
+
lane: "bridge" | "draft-route" | "pending";
|
|
1246
1246
|
/** Files the bridge was installed in. */
|
|
1247
1247
|
files: string[];
|
|
1248
1248
|
/** Rewritten contents, by path. Empty when the lane is pending. */
|
|
@@ -1257,8 +1257,8 @@ declare const ASTRO_LANE_PENDING: PendingPath;
|
|
|
1257
1257
|
* Install the draft bridge, or say why not.
|
|
1258
1258
|
*
|
|
1259
1259
|
* `routes` maps a brief route (`/about`) to its slug, so a route written as a literal in the page
|
|
1260
|
-
* can name itself. An Astro project is
|
|
1261
|
-
*
|
|
1260
|
+
* can name itself. An Astro project is never bridged here: it either wired a lane itself (see
|
|
1261
|
+
* {@link astroLane}) or it carries the SSR recipe.
|
|
1262
1262
|
*/
|
|
1263
1263
|
declare function canvasBridge(sources: CanvasSource[], routes: Map<string, string>): CanvasResult;
|
|
1264
1264
|
|
package/dist/index.js
CHANGED
|
@@ -6090,9 +6090,28 @@ var pend = (reason, hint, file, line) => ({
|
|
|
6090
6090
|
hint
|
|
6091
6091
|
});
|
|
6092
6092
|
var ASTRO_LANE_PENDING = pend("SSR_DRAFT_ROUTE", SSR_DRAFT_RECIPE);
|
|
6093
|
+
function mounts(content, component) {
|
|
6094
|
+
const from = new RegExp(
|
|
6095
|
+
`import\\s+([A-Za-z_$][\\w$]*)\\s+from\\s+["']@bettercms-ai/astro/components/${component}\\.astro["']`
|
|
6096
|
+
);
|
|
6097
|
+
const local = content.match(from)?.[1];
|
|
6098
|
+
return local !== void 0 && new RegExp(`<${local}[\\s/>]`).test(content);
|
|
6099
|
+
}
|
|
6100
|
+
var ASTRO_CONFIG = /(^|\/)astro\.config\.(mjs|cjs|js|ts|mts)$/;
|
|
6101
|
+
function astroLane(sources) {
|
|
6102
|
+
const astro = sources.filter((s) => s.path.toLowerCase().endsWith(".astro"));
|
|
6103
|
+
const server = sources.some(
|
|
6104
|
+
(s) => ASTRO_CONFIG.test(s.path) && /\boutput\s*:\s*["']server["']/.test(s.content)
|
|
6105
|
+
);
|
|
6106
|
+
if (server && astro.some((s) => mounts(s.content, "BcmsLive"))) return "draft-route";
|
|
6107
|
+
if (astro.some((s) => mounts(s.content, "BcmsLiveBlocks"))) return "bridge";
|
|
6108
|
+
return null;
|
|
6109
|
+
}
|
|
6093
6110
|
function canvasBridge(sources, routes) {
|
|
6094
|
-
if (sources.some((s) => s.path.toLowerCase().endsWith(".astro")))
|
|
6095
|
-
|
|
6111
|
+
if (sources.some((s) => s.path.toLowerCase().endsWith(".astro"))) {
|
|
6112
|
+
const lane = astroLane(sources);
|
|
6113
|
+
return lane ? { lane, files: [], edits: /* @__PURE__ */ new Map(), pending: [] } : { lane: "pending", files: [], edits: /* @__PURE__ */ new Map(), pending: [ASTRO_LANE_PENDING] };
|
|
6114
|
+
}
|
|
6096
6115
|
const files = [];
|
|
6097
6116
|
const edits = /* @__PURE__ */ new Map();
|
|
6098
6117
|
const pending = [];
|