syncorejs 0.2.4 → 0.2.5

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.
Files changed (31) hide show
  1. package/dist/_dashboard/assets/ConfirmActionDialog-Db4VzVp6.js +1 -0
  2. package/dist/_dashboard/assets/circle-x-VsB4Z8W4.js +1 -0
  3. package/dist/_dashboard/assets/data.lazy-DjdU9CzX.js +18 -0
  4. package/dist/_dashboard/assets/file-code-BrOKjG4n.js +1 -0
  5. package/dist/_dashboard/assets/functions.lazy-DvDwAGHq.js +1 -0
  6. package/dist/_dashboard/assets/funnel-BH8EMMJI.js +1 -0
  7. package/dist/_dashboard/assets/index-DT9ZEELb.css +1 -0
  8. package/dist/_dashboard/assets/index-DrSG4qZZ.js +54 -0
  9. package/dist/_dashboard/assets/loader-circle-CmJFSYga.js +1 -0
  10. package/dist/_dashboard/assets/logs.lazy-50KTk5yd.js +1 -0
  11. package/dist/_dashboard/assets/play-DS52VsLN.js +1 -0
  12. package/dist/_dashboard/assets/queries.lazy-CfysRWkz.js +1 -0
  13. package/dist/_dashboard/assets/scheduler.lazy-BB88mZk-.js +1 -0
  14. package/dist/_dashboard/assets/select-THYcR8Wt.js +1 -0
  15. package/dist/_dashboard/assets/separator-BU7xg615.js +1 -0
  16. package/dist/_dashboard/assets/shared-Bh0wwC2k.js +1 -0
  17. package/dist/_dashboard/assets/sql.lazy-CHtU9Qnt.js +13 -0
  18. package/dist/_dashboard/assets/storage.lazy-CneN7wVU.js +1 -0
  19. package/dist/_dashboard/assets/table-2-CH8JoMXf.js +1 -0
  20. package/dist/_dashboard/index.html +18 -0
  21. package/dist/_vendor/cli/app.d.mts.map +1 -1
  22. package/dist/_vendor/cli/app.mjs +16 -5
  23. package/dist/_vendor/cli/app.mjs.map +1 -1
  24. package/dist/_vendor/core/cli.d.mts.map +1 -1
  25. package/dist/_vendor/core/cli.mjs +86 -9
  26. package/dist/_vendor/core/cli.mjs.map +1 -1
  27. package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs +4 -1
  28. package/dist/_vendor/core/runtime/internal/engines/executionEngine.mjs.map +1 -1
  29. package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs +5 -2
  30. package/dist/_vendor/core/runtime/internal/engines/reactivityEngine.mjs.map +1 -1
  31. package/package.json +2 -2
@@ -1522,8 +1522,11 @@ async function startDevHub(options) {
1522
1522
  await runDevProjectBootstrap(options.cwd, options.template);
1523
1523
  await setupDevProjectWatch(options.cwd, options.template);
1524
1524
  if (await isLocalPortInUse(devtoolsPort)) {
1525
+ const activeSessionState = await readDevtoolsSessionState(options.cwd) ?? sessionState;
1525
1526
  console.log(`Syncore devtools hub already running at ws://localhost:${devtoolsPort}. Reusing existing hub/dashboard.`);
1526
- return await readDevtoolsSessionState(options.cwd) ?? sessionState;
1527
+ console.log(`Devtools dashboard token: ${activeSessionState.token}`);
1528
+ console.log(`Dashboard shell: ${activeSessionState.authenticatedDashboardUrl}`);
1529
+ return activeSessionState;
1527
1530
  }
1528
1531
  await writeDevtoolsSessionState(options.cwd, sessionState);
1529
1532
  const httpServer = createServer((request, response) => {
@@ -1978,19 +1981,18 @@ async function startDevHub(options) {
1978
1981
  console.log(`Electron/Node runtimes: set devtoolsUrl to ws://localhost:${devtoolsPort}.`);
1979
1982
  console.log(`Web/Next apps: connect the dashboard or worker bridge to ws://localhost:${devtoolsPort}.`);
1980
1983
  console.log("Expo apps: use the same hub URL through LAN or adb reverse while developing.");
1981
- const dashboardRoot = path.resolve(CORE_PACKAGE_ROOT, "..", "..", "apps", "dashboard");
1982
- if (await fileExists(path.join(dashboardRoot, "vite.config.ts"))) try {
1983
- await (await (await import("vite")).createServer({
1984
- configFile: path.join(dashboardRoot, "vite.config.ts"),
1985
- root: dashboardRoot,
1986
- server: { port: dashboardPort }
1987
- })).listen();
1984
+ let dashboardStaticServer;
1985
+ const dashboardStaticRoot = await resolvePackagedDashboardRoot();
1986
+ if (!dashboardStaticRoot) throw new Error("Syncore Dashboard build is missing. Expected the packaged dashboard at syncorejs/dist/_dashboard/index.html. Rebuild syncorejs before running `syncorejs dev`.");
1987
+ try {
1988
+ dashboardStaticServer = await startPackagedDashboardServer(dashboardStaticRoot, dashboardPort);
1988
1989
  console.log(`Dashboard shell: ${sessionState.authenticatedDashboardUrl}`);
1989
1990
  } catch (error) {
1990
- console.log(`Dashboard source not started automatically: ${formatError(error)}`);
1991
+ throw new Error(`Syncore Dashboard shell could not start: ${formatError(error)}`, { cause: error });
1991
1992
  }
1992
1993
  const close = () => {
1993
1994
  projectTargetBackend?.dispose();
1995
+ dashboardStaticServer?.close();
1994
1996
  websocketServer.close();
1995
1997
  httpServer.close();
1996
1998
  process.exit(0);
@@ -1999,6 +2001,81 @@ async function startDevHub(options) {
1999
2001
  process.on("SIGTERM", close);
2000
2002
  return sessionState;
2001
2003
  }
2004
+ async function resolvePackagedDashboardRoot() {
2005
+ const candidates = [
2006
+ path.resolve(CORE_PACKAGE_ROOT, "..", "_dashboard"),
2007
+ path.resolve(CORE_PACKAGE_ROOT, "_dashboard"),
2008
+ path.resolve(CORE_PACKAGE_ROOT, "..", "syncore", "dist", "_dashboard")
2009
+ ];
2010
+ for (const candidate of candidates) if (await fileExists(path.join(candidate, "index.html"))) return candidate;
2011
+ return null;
2012
+ }
2013
+ async function startPackagedDashboardServer(root, port) {
2014
+ const server = createServer((request, response) => {
2015
+ serveDashboardAsset(root, request, response).catch((error) => {
2016
+ if (!response.headersSent) writeTextResponse(response, 500, formatError(error));
2017
+ else response.destroy(error instanceof Error ? error : void 0);
2018
+ });
2019
+ });
2020
+ await new Promise((resolve, reject) => {
2021
+ server.once("error", reject);
2022
+ server.listen(port, "127.0.0.1", () => {
2023
+ server.off("error", reject);
2024
+ resolve();
2025
+ });
2026
+ });
2027
+ return server;
2028
+ }
2029
+ async function serveDashboardAsset(root, request, response) {
2030
+ if (request.method !== "GET" && request.method !== "HEAD") {
2031
+ writeTextResponse(response, 405, "Method not allowed.");
2032
+ return;
2033
+ }
2034
+ const requestUrl = new URL(request.url ?? "/", "http://127.0.0.1");
2035
+ const requestedPath = decodeURIComponent(requestUrl.pathname);
2036
+ const relativePath = requestedPath === "/" ? "index.html" : requestedPath.slice(1);
2037
+ let assetPath = path.resolve(root, relativePath);
2038
+ if (!isPathInside(root, assetPath)) {
2039
+ writeTextResponse(response, 403, "Forbidden.");
2040
+ return;
2041
+ }
2042
+ try {
2043
+ if ((await stat(assetPath)).isDirectory()) assetPath = path.join(assetPath, "index.html");
2044
+ } catch {
2045
+ assetPath = path.join(root, "index.html");
2046
+ }
2047
+ if (!isPathInside(root, assetPath)) {
2048
+ writeTextResponse(response, 403, "Forbidden.");
2049
+ return;
2050
+ }
2051
+ const body = await readFile(assetPath);
2052
+ response.writeHead(200, {
2053
+ "Content-Type": getDashboardAssetContentType(assetPath),
2054
+ "Content-Length": body.byteLength
2055
+ });
2056
+ if (request.method === "HEAD") {
2057
+ response.end();
2058
+ return;
2059
+ }
2060
+ response.end(body);
2061
+ }
2062
+ function isPathInside(root, candidate) {
2063
+ const relative = path.relative(root, candidate);
2064
+ return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
2065
+ }
2066
+ function getDashboardAssetContentType(filePath) {
2067
+ switch (path.extname(filePath)) {
2068
+ case ".html": return "text/html; charset=utf-8";
2069
+ case ".js": return "text/javascript; charset=utf-8";
2070
+ case ".css": return "text/css; charset=utf-8";
2071
+ case ".json": return "application/json; charset=utf-8";
2072
+ case ".svg": return "image/svg+xml";
2073
+ case ".png": return "image/png";
2074
+ case ".ico": return "image/x-icon";
2075
+ case ".woff2": return "font/woff2";
2076
+ default: return "application/octet-stream";
2077
+ }
2078
+ }
2002
2079
  function setStorageCorsHeaders(response) {
2003
2080
  response.setHeader("Access-Control-Allow-Origin", "*");
2004
2081
  response.setHeader("Access-Control-Allow-Methods", "GET, HEAD, OPTIONS");