@fluid-app/fluid-cli-portal 0.1.45 → 0.1.47
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/backend-dev-plugin-B9-S4Is-.mjs +64 -0
- package/dist/backend-dev-plugin-B9-S4Is-.mjs.map +1 -0
- package/dist/index.mjs +47 -13
- package/dist/index.mjs.map +1 -1
- package/dist/portal-dev-plugin-DBoPIt_V.mjs +233 -0
- package/dist/portal-dev-plugin-DBoPIt_V.mjs.map +1 -0
- package/dist/{pull-CG5dELOX.mjs → pull-XOsFaqz2.mjs} +2 -14
- package/dist/{pull-CG5dELOX.mjs.map → pull-XOsFaqz2.mjs.map} +1 -1
- package/dist/rolldown-runtime-twds-ZHy.mjs +14 -0
- package/dist/vite-plugin.mjs +2 -282
- package/package.json +1 -1
- package/templates/starter/package.json.template +1 -1
- package/dist/vite-plugin.mjs.map +0 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-twds-ZHy.mjs";
|
|
2
|
+
//#region src/vite-plugin/backend-dev-plugin.ts
|
|
3
|
+
var backend_dev_plugin_exports = /* @__PURE__ */ __exportAll({ backendDevPlugin: () => backendDevPlugin });
|
|
4
|
+
/**
|
|
5
|
+
* Serves dev-compatible responses at production asset paths so the Rails
|
|
6
|
+
* backend can point `PORTAL_CDN_BASE` at `http://localhost:5173` and get
|
|
7
|
+
* HMR + live source without any template changes.
|
|
8
|
+
*
|
|
9
|
+
* Handles:
|
|
10
|
+
* - `/portal.js` → ESM shim that loads `@vite/client` + the real entry
|
|
11
|
+
* - `/portal.css` → empty (Vite injects CSS via JS in dev)
|
|
12
|
+
* - `/vendor.js`, `/query.js` → empty ES modules (no chunks in dev)
|
|
13
|
+
*/
|
|
14
|
+
function backendDevPlugin(options) {
|
|
15
|
+
const entry = options?.entry ?? "/src/main.tsx";
|
|
16
|
+
const chunks = options?.chunks ?? ["vendor.js", "query.js"];
|
|
17
|
+
return {
|
|
18
|
+
name: "fluid-backend-dev",
|
|
19
|
+
apply: "serve",
|
|
20
|
+
configureServer(server) {
|
|
21
|
+
const flagged = server;
|
|
22
|
+
if (flagged.__fluidBackendDevWired) return;
|
|
23
|
+
flagged.__fluidBackendDevWired = true;
|
|
24
|
+
server.middlewares.use((req, res, next) => {
|
|
25
|
+
const raw = req.url ?? "";
|
|
26
|
+
const qIndex = raw.indexOf("?");
|
|
27
|
+
const url = qIndex === -1 ? raw : raw.slice(0, qIndex);
|
|
28
|
+
if (url === "/portal.js") {
|
|
29
|
+
serve(res, "application/javascript", [
|
|
30
|
+
`import RefreshRuntime from "/@react-refresh";`,
|
|
31
|
+
`import "/@vite/client";`,
|
|
32
|
+
`RefreshRuntime.injectIntoGlobalHook(window);`,
|
|
33
|
+
`window.$RefreshReg$ = () => {};`,
|
|
34
|
+
`window.$RefreshSig$ = () => (type) => type;`,
|
|
35
|
+
`window.__vite_plugin_react_preamble_installed__ = true;`,
|
|
36
|
+
`await import("${entry}");`
|
|
37
|
+
].join("\n"));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (url === "/portal.css") {
|
|
41
|
+
serve(res, "text/css", "/* dev: CSS injected via JS */");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const chunkName = url.startsWith("/") ? url.slice(1) : url;
|
|
45
|
+
if (chunks.includes(chunkName)) {
|
|
46
|
+
serve(res, "application/javascript", "export {};");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
next();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function serve(res, contentType, body) {
|
|
55
|
+
res.setHeader("Content-Type", `${contentType}; charset=utf-8`);
|
|
56
|
+
res.setHeader("Cache-Control", "no-store");
|
|
57
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
58
|
+
res.statusCode = 200;
|
|
59
|
+
res.end(body);
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
export { backend_dev_plugin_exports as n, backendDevPlugin as t };
|
|
63
|
+
|
|
64
|
+
//# sourceMappingURL=backend-dev-plugin-B9-S4Is-.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend-dev-plugin-B9-S4Is-.mjs","names":[],"sources":["../src/vite-plugin/backend-dev-plugin.ts"],"sourcesContent":["import type { Plugin } from \"vite\";\n\nexport interface BackendDevPluginOptions {\n /** Entry module path relative to project root. @default \"/src/main.tsx\" */\n entry?: string;\n /** Production chunk filenames to stub as empty ES modules. */\n chunks?: string[];\n}\n\n/**\n * Serves dev-compatible responses at production asset paths so the Rails\n * backend can point `PORTAL_CDN_BASE` at `http://localhost:5173` and get\n * HMR + live source without any template changes.\n *\n * Handles:\n * - `/portal.js` → ESM shim that loads `@vite/client` + the real entry\n * - `/portal.css` → empty (Vite injects CSS via JS in dev)\n * - `/vendor.js`, `/query.js` → empty ES modules (no chunks in dev)\n */\nexport function backendDevPlugin(options?: BackendDevPluginOptions): Plugin {\n const entry = options?.entry ?? \"/src/main.tsx\";\n const chunks = options?.chunks ?? [\"vendor.js\", \"query.js\"];\n\n return {\n name: \"fluid-backend-dev\",\n apply: \"serve\",\n\n // Register BEFORE Vite's SPA fallback so these paths don't\n // get caught by the index.html catch-all.\n configureServer(server) {\n // Idempotency guard: the CLI injects this plugin and a vite.config may\n // also wire it — only register the middleware once.\n const flagged = server as unknown as { __fluidBackendDevWired?: boolean };\n if (flagged.__fluidBackendDevWired) return;\n flagged.__fluidBackendDevWired = true;\n\n server.middlewares.use((req, res, next) => {\n const raw = req.url ?? \"\";\n const qIndex = raw.indexOf(\"?\");\n const url = qIndex === -1 ? raw : raw.slice(0, qIndex);\n\n if (url === \"/portal.js\") {\n serve(\n res,\n \"application/javascript\",\n [\n `import RefreshRuntime from \"/@react-refresh\";`,\n `import \"/@vite/client\";`,\n `RefreshRuntime.injectIntoGlobalHook(window);`,\n `window.$RefreshReg$ = () => {};`,\n `window.$RefreshSig$ = () => (type) => type;`,\n `window.__vite_plugin_react_preamble_installed__ = true;`,\n `await import(\"${entry}\");`,\n ].join(\"\\n\"),\n );\n return;\n }\n\n if (url === \"/portal.css\") {\n serve(res, \"text/css\", \"/* dev: CSS injected via JS */\");\n return;\n }\n\n const chunkName = url.startsWith(\"/\") ? url.slice(1) : url;\n if (chunks.includes(chunkName)) {\n serve(res, \"application/javascript\", \"export {};\");\n return;\n }\n\n next();\n });\n },\n };\n}\n\nfunction serve(\n res: import(\"http\").ServerResponse,\n contentType: string,\n body: string,\n) {\n res.setHeader(\"Content-Type\", `${contentType}; charset=utf-8`);\n res.setHeader(\"Cache-Control\", \"no-store\");\n res.setHeader(\"Access-Control-Allow-Origin\", \"*\");\n res.statusCode = 200;\n res.end(body);\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,SAAgB,iBAAiB,SAA2C;CAC1E,MAAM,QAAQ,SAAS,SAAS;CAChC,MAAM,SAAS,SAAS,UAAU,CAAC,aAAa,WAAW;AAE3D,QAAO;EACL,MAAM;EACN,OAAO;EAIP,gBAAgB,QAAQ;GAGtB,MAAM,UAAU;AAChB,OAAI,QAAQ,uBAAwB;AACpC,WAAQ,yBAAyB;AAEjC,UAAO,YAAY,KAAK,KAAK,KAAK,SAAS;IACzC,MAAM,MAAM,IAAI,OAAO;IACvB,MAAM,SAAS,IAAI,QAAQ,IAAI;IAC/B,MAAM,MAAM,WAAW,KAAK,MAAM,IAAI,MAAM,GAAG,OAAO;AAEtD,QAAI,QAAQ,cAAc;AACxB,WACE,KACA,0BACA;MACE;MACA;MACA;MACA;MACA;MACA;MACA,iBAAiB,MAAM;MACxB,CAAC,KAAK,KAAK,CACb;AACD;;AAGF,QAAI,QAAQ,eAAe;AACzB,WAAM,KAAK,YAAY,iCAAiC;AACxD;;IAGF,MAAM,YAAY,IAAI,WAAW,IAAI,GAAG,IAAI,MAAM,EAAE,GAAG;AACvD,QAAI,OAAO,SAAS,UAAU,EAAE;AAC9B,WAAM,KAAK,0BAA0B,aAAa;AAClD;;AAGF,UAAM;KACN;;EAEL;;AAGH,SAAS,MACP,KACA,aACA,MACA;AACA,KAAI,UAAU,gBAAgB,GAAG,YAAY,iBAAiB;AAC9D,KAAI,UAAU,iBAAiB,WAAW;AAC1C,KAAI,UAAU,+BAA+B,IAAI;AACjD,KAAI,aAAa;AACjB,KAAI,IAAI,KAAK"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as fluid_os_v0_create_fluid_osversion, B as fluid_os_v0_update_fluid_osnavigation, C as writeMappings, D as fluid_os_v0_create_fluid_osprofile, E as fluid_os_v0_create_fluid_osnavigation_item, F as fluid_os_v0_delete_fluid_osscreen, G as fluid_os_v0_update_fluid_osversion, H as fluid_os_v0_update_fluid_osprofile, I as fluid_os_v0_delete_fluid_ostheme, K as createFetchClient, L as fluid_os_v0_list_fluid_osdefinitions, M as fluid_os_v0_delete_fluid_osnavigation, N as fluid_os_v0_delete_fluid_osnavigation_item, O as fluid_os_v0_create_fluid_osscreen, P as fluid_os_v0_delete_fluid_osprofile, R as fluid_os_v0_list_fluid_osnavigation_items, S as updateMapping, T as fluid_os_v0_create_fluid_osnavigation, U as fluid_os_v0_update_fluid_osscreen, V as fluid_os_v0_update_fluid_osnavigation_item, W as fluid_os_v0_update_fluid_ostheme, _ as deriveSlug, a as buildThemeIdToSlugMap, b as resolveIdToSlug, c as transformNavigationItems, d as transformTheme, f as buildSnapshot, g as writeSnapshot, h as readSnapshot, i as buildNavigationIdToSlugMap, j as fluid_os_v0_create_widget_package_version, k as fluid_os_v0_create_fluid_ostheme, l as transformProfile, m as diffAgainstSnapshot, o as deriveScreenSlug, p as computeFileHash, r as buildIdToSlugMap, s as transformNavigation, t as pullCommand, u as transformScreen, v as readMappings, w as fluid_os_v0_complete_widget_package_version_upload, x as resolveSlugToId, y as removeMapping, z as fluid_os_v0_list_fluid_osversions } from "./pull-
|
|
1
|
+
import { A as fluid_os_v0_create_fluid_osversion, B as fluid_os_v0_update_fluid_osnavigation, C as writeMappings, D as fluid_os_v0_create_fluid_osprofile, E as fluid_os_v0_create_fluid_osnavigation_item, F as fluid_os_v0_delete_fluid_osscreen, G as fluid_os_v0_update_fluid_osversion, H as fluid_os_v0_update_fluid_osprofile, I as fluid_os_v0_delete_fluid_ostheme, K as createFetchClient, L as fluid_os_v0_list_fluid_osdefinitions, M as fluid_os_v0_delete_fluid_osnavigation, N as fluid_os_v0_delete_fluid_osnavigation_item, O as fluid_os_v0_create_fluid_osscreen, P as fluid_os_v0_delete_fluid_osprofile, R as fluid_os_v0_list_fluid_osnavigation_items, S as updateMapping, T as fluid_os_v0_create_fluid_osnavigation, U as fluid_os_v0_update_fluid_osscreen, V as fluid_os_v0_update_fluid_osnavigation_item, W as fluid_os_v0_update_fluid_ostheme, _ as deriveSlug, a as buildThemeIdToSlugMap, b as resolveIdToSlug, c as transformNavigationItems, d as transformTheme, f as buildSnapshot, g as writeSnapshot, h as readSnapshot, i as buildNavigationIdToSlugMap, j as fluid_os_v0_create_widget_package_version, k as fluid_os_v0_create_fluid_ostheme, l as transformProfile, m as diffAgainstSnapshot, o as deriveScreenSlug, p as computeFileHash, r as buildIdToSlugMap, s as transformNavigation, t as pullCommand, u as transformScreen, v as readMappings, w as fluid_os_v0_complete_widget_package_version_upload, x as resolveSlugToId, y as removeMapping, z as fluid_os_v0_list_fluid_osversions } from "./pull-XOsFaqz2.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import chalk from "chalk";
|
|
@@ -1158,7 +1158,7 @@ async function autoPull(cwd) {
|
|
|
1158
1158
|
console.log(chalk.yellow("No portal/ directory found.") + " Attempting to pull content...");
|
|
1159
1159
|
console.log();
|
|
1160
1160
|
try {
|
|
1161
|
-
const { pullCommand } = await import("./pull-
|
|
1161
|
+
const { pullCommand } = await import("./pull-XOsFaqz2.mjs").then((n) => n.n);
|
|
1162
1162
|
await pullCommand.parseAsync([], { from: "user" });
|
|
1163
1163
|
return hasPortalContent(cwd);
|
|
1164
1164
|
} catch (err) {
|
|
@@ -1177,7 +1177,8 @@ const devCommand = new Command("dev").description("Start the development server
|
|
|
1177
1177
|
console.error(chalk.yellow("Make sure you're in a Fluid project directory"));
|
|
1178
1178
|
process.exit(1);
|
|
1179
1179
|
}
|
|
1180
|
-
|
|
1180
|
+
const viteConfigPath = join(cwd, "vite.config.ts");
|
|
1181
|
+
if (!existsSync(viteConfigPath)) {
|
|
1181
1182
|
console.error(chalk.red("Error: No vite.config.ts found"));
|
|
1182
1183
|
console.error(chalk.yellow("This command must be run from a Fluid project directory"));
|
|
1183
1184
|
process.exit(1);
|
|
@@ -1192,24 +1193,57 @@ const devCommand = new Command("dev").description("Start the development server
|
|
|
1192
1193
|
if (hasPortalContent(cwd)) {
|
|
1193
1194
|
console.log();
|
|
1194
1195
|
console.log(chalk.green("Portal dev mode: ") + "local content from " + chalk.cyan("portal/") + " will be served");
|
|
1195
|
-
console.log(chalk.gray(" Manifest requests intercepted at /api/fluid_os/definitions/active"));
|
|
1196
|
+
console.log(chalk.gray(" Manifest requests intercepted at /api/app/manifest (+ /api/fluid_os/definitions/active)"));
|
|
1196
1197
|
console.log(chalk.gray(" File changes in portal/ will trigger a page reload"));
|
|
1197
1198
|
}
|
|
1198
|
-
const viteArgs = ["vite"];
|
|
1199
|
-
if (options.port) viteArgs.push("--port", String(options.port));
|
|
1200
|
-
if (options.host) viteArgs.push("--host");
|
|
1201
1199
|
console.log();
|
|
1202
1200
|
console.log(chalk.bold("Starting development server..."));
|
|
1203
1201
|
console.log();
|
|
1202
|
+
const viteArgs = ["vite"];
|
|
1203
|
+
if (options.port) viteArgs.push("--port", String(options.port));
|
|
1204
|
+
if (options.host) viteArgs.push("--host");
|
|
1205
|
+
const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL ?? "https://api.fluid.app";
|
|
1206
|
+
const parsedPort = Number(options.port);
|
|
1207
|
+
const port = Number.isFinite(parsedPort) ? parsedPort : 5173;
|
|
1204
1208
|
try {
|
|
1205
|
-
await
|
|
1206
|
-
|
|
1207
|
-
|
|
1209
|
+
const { createServer } = await import("vite");
|
|
1210
|
+
const { portalDevPlugin } = await import("./portal-dev-plugin-DBoPIt_V.mjs").then((n) => n.n);
|
|
1211
|
+
const { backendDevPlugin } = await import("./backend-dev-plugin-B9-S4Is-.mjs").then((n) => n.n);
|
|
1212
|
+
const server = await createServer({
|
|
1213
|
+
configFile: viteConfigPath,
|
|
1214
|
+
root: cwd,
|
|
1215
|
+
envPrefix: ["VITE_", "NEXT_PUBLIC_"],
|
|
1216
|
+
plugins: [portalDevPlugin(), backendDevPlugin()],
|
|
1217
|
+
server: {
|
|
1218
|
+
port,
|
|
1219
|
+
host: options.host ? true : void 0,
|
|
1220
|
+
proxy: { "/api": {
|
|
1221
|
+
target: apiBaseUrl,
|
|
1222
|
+
changeOrigin: true
|
|
1223
|
+
} }
|
|
1224
|
+
}
|
|
1208
1225
|
});
|
|
1226
|
+
await server.listen();
|
|
1227
|
+
server.printUrls();
|
|
1228
|
+
const shutdown = () => {
|
|
1229
|
+
server.close().finally(() => process.exit(0));
|
|
1230
|
+
};
|
|
1231
|
+
process.on("SIGINT", shutdown);
|
|
1232
|
+
process.on("SIGTERM", shutdown);
|
|
1233
|
+
await new Promise(() => {});
|
|
1209
1234
|
} catch (error) {
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1235
|
+
console.warn(chalk.yellow("Could not start the enriched dev server; falling back to `vite`. Local portal content requires portalDevPlugin in vite.config for the fallback path."), error instanceof Error ? error.message : String(error));
|
|
1236
|
+
try {
|
|
1237
|
+
await execa("pnpm", viteArgs, {
|
|
1238
|
+
cwd,
|
|
1239
|
+
stdio: "inherit"
|
|
1240
|
+
});
|
|
1241
|
+
} catch (fallbackErr) {
|
|
1242
|
+
const execaError = fallbackErr;
|
|
1243
|
+
if (execaError.signal === "SIGINT" || execaError.signal === "SIGTERM") return;
|
|
1244
|
+
console.error(chalk.red("Development server exited with an error"));
|
|
1245
|
+
process.exit(1);
|
|
1246
|
+
}
|
|
1213
1247
|
}
|
|
1214
1248
|
});
|
|
1215
1249
|
//#endregion
|