@lite-fsm/cli 0.1.0 → 0.1.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.
Files changed (89) hide show
  1. package/README.md +130 -0
  2. package/dist/bin/lite-fsm.js +6714 -5
  3. package/package.json +6 -4
  4. package/dist/bin/lite-fsm.d.cts +0 -2
  5. package/dist/bin/lite-fsm.d.ts +0 -2
  6. package/dist/cli/context.d.cts +0 -21
  7. package/dist/cli/context.d.ts +0 -21
  8. package/dist/cli/context.js +0 -0
  9. package/dist/cli/create-program.d.cts +0 -6
  10. package/dist/cli/create-program.d.ts +0 -6
  11. package/dist/cli/create-program.js +0 -48
  12. package/dist/cli/diagnostics.d.cts +0 -15
  13. package/dist/cli/diagnostics.d.ts +0 -15
  14. package/dist/cli/diagnostics.js +0 -13
  15. package/dist/cli/node-fs.d.cts +0 -2
  16. package/dist/cli/node-fs.d.ts +0 -2
  17. package/dist/cli/node-fs.js +0 -33
  18. package/dist/cli/result.d.cts +0 -6
  19. package/dist/cli/result.d.ts +0 -6
  20. package/dist/cli/result.js +0 -8
  21. package/dist/export-graph/command.d.cts +0 -8
  22. package/dist/export-graph/command.d.ts +0 -8
  23. package/dist/export-graph/command.js +0 -30
  24. package/dist/export-graph/export-document.d.cts +0 -38
  25. package/dist/export-graph/export-document.d.ts +0 -38
  26. package/dist/export-graph/export-document.js +0 -35
  27. package/dist/export-graph/options.d.cts +0 -21
  28. package/dist/export-graph/options.d.ts +0 -21
  29. package/dist/export-graph/options.js +0 -40
  30. package/dist/export-graph/run-export-graph.d.cts +0 -10
  31. package/dist/export-graph/run-export-graph.d.ts +0 -10
  32. package/dist/export-graph/run-export-graph.js +0 -53
  33. package/dist/export-graph/source-bundle.d.cts +0 -12
  34. package/dist/export-graph/source-bundle.d.ts +0 -12
  35. package/dist/export-graph/source-bundle.js +0 -48
  36. package/dist/export-graph/write-output.d.cts +0 -10
  37. package/dist/export-graph/write-output.d.ts +0 -10
  38. package/dist/export-graph/write-output.js +0 -24
  39. package/dist/output/format-diagnostics.d.cts +0 -6
  40. package/dist/output/format-diagnostics.d.ts +0 -6
  41. package/dist/output/format-diagnostics.js +0 -33
  42. package/dist/output/stable-json.d.cts +0 -1
  43. package/dist/output/stable-json.d.ts +0 -1
  44. package/dist/output/stable-json.js +0 -72
  45. package/dist/project/build-project-graph.d.cts +0 -19
  46. package/dist/project/build-project-graph.d.ts +0 -19
  47. package/dist/project/build-project-graph.js +0 -64
  48. package/dist/project/create-project-host.d.cts +0 -4
  49. package/dist/project/create-project-host.d.ts +0 -4
  50. package/dist/project/create-project-host.js +0 -11
  51. package/dist/project/module-resolver.d.cts +0 -15
  52. package/dist/project/module-resolver.d.ts +0 -15
  53. package/dist/project/module-resolver.js +0 -111
  54. package/dist/project/source-cache.d.cts +0 -11
  55. package/dist/project/source-cache.d.ts +0 -11
  56. package/dist/project/source-cache.js +0 -55
  57. package/dist/project/tsconfig.d.cts +0 -15
  58. package/dist/project/tsconfig.d.ts +0 -15
  59. package/dist/project/tsconfig.js +0 -116
  60. package/dist/visualize/command.d.cts +0 -9
  61. package/dist/visualize/command.d.ts +0 -9
  62. package/dist/visualize/command.js +0 -35
  63. package/dist/visualize/http.d.cts +0 -11
  64. package/dist/visualize/http.d.ts +0 -11
  65. package/dist/visualize/http.js +0 -65
  66. package/dist/visualize/open-browser.d.cts +0 -22
  67. package/dist/visualize/open-browser.d.ts +0 -22
  68. package/dist/visualize/open-browser.js +0 -45
  69. package/dist/visualize/options.d.cts +0 -16
  70. package/dist/visualize/options.d.ts +0 -16
  71. package/dist/visualize/options.js +0 -51
  72. package/dist/visualize/routes.d.cts +0 -2
  73. package/dist/visualize/routes.d.ts +0 -2
  74. package/dist/visualize/routes.js +0 -24
  75. package/dist/visualize/run-visualize.d.cts +0 -32
  76. package/dist/visualize/run-visualize.d.ts +0 -32
  77. package/dist/visualize/run-visualize.js +0 -81
  78. package/dist/visualize/server.d.cts +0 -40
  79. package/dist/visualize/server.d.ts +0 -40
  80. package/dist/visualize/server.js +0 -90
  81. package/dist/visualize/session.d.cts +0 -34
  82. package/dist/visualize/session.d.ts +0 -34
  83. package/dist/visualize/session.js +0 -137
  84. package/dist/visualize/static-assets.d.cts +0 -17
  85. package/dist/visualize/static-assets.d.ts +0 -17
  86. package/dist/visualize/static-assets.js +0 -87
  87. package/dist/visualize/types.d.cts +0 -65
  88. package/dist/visualize/types.d.ts +0 -65
  89. package/dist/visualize/types.js +0 -0
@@ -1,40 +0,0 @@
1
- import type { CliContext } from "../cli/context.js";
2
- import type { CliDiagnostic } from "../cli/diagnostics.js";
3
- import type { VisualizerSession } from "./session.js";
4
- import type { VisualizerHttpRequest, VisualizerHttpResponse, VisualizerHttpResponseWriter, VisualizerRoute } from "./types.js";
5
- export type VisualizerServer = {
6
- url: string;
7
- port: number;
8
- close(): Promise<void>;
9
- };
10
- export type StartVisualizerServerOptions = {
11
- context: CliContext;
12
- port: number;
13
- session: VisualizerSession;
14
- staticRoot: string;
15
- };
16
- export type StartVisualizerServerDependencies = {
17
- routes?: readonly VisualizerRoute[];
18
- createHttpServer?: CreateVisualizerHttpServer;
19
- };
20
- export type StartVisualizerServerResult = {
21
- ok: true;
22
- server: VisualizerServer;
23
- } | {
24
- ok: false;
25
- diagnostics: CliDiagnostic[];
26
- };
27
- type VisualizerServerListenerArgs = [event: "error", listener: (error: NodeJS.ErrnoException) => void] | [event: "listening", listener: () => void];
28
- export type VisualizerHttpServer = {
29
- once(...args: VisualizerServerListenerArgs): VisualizerHttpServer;
30
- removeListener(...args: VisualizerServerListenerArgs): VisualizerHttpServer;
31
- listen(port: number, host: string): void;
32
- close(callback: (error?: Error) => void): void;
33
- };
34
- export type CreateVisualizerHttpServer = (handler: (request: VisualizerHttpRequest, response: VisualizerHttpResponseWriter) => void) => VisualizerHttpServer;
35
- export declare const handleVisualizerRequest: (options: StartVisualizerServerOptions & {
36
- routes: readonly VisualizerRoute[];
37
- }, request: VisualizerHttpRequest) => Promise<VisualizerHttpResponse>;
38
- export declare const startVisualizerServer: (options: StartVisualizerServerOptions, dependencies?: StartVisualizerServerDependencies) => Promise<StartVisualizerServerResult>;
39
- export declare const waitForSignalShutdown: (server: VisualizerServer) => Promise<void>;
40
- export {};
@@ -1,90 +0,0 @@
1
- import { createServer } from "node:http";
2
- import { cliDiagnostic } from "../cli/diagnostics.js";
3
- import { createRequestPathname, createRequestUrl, dispatchApiRoute, errorResponse, writeHttpResponse } from "./http.js";
4
- import { createVisualizerRoutes } from "./routes.js";
5
- import { serveStaticAsset } from "./static-assets.js";
6
- const diagnosticForListenError = (error, port) => {
7
- if (error.code === "EADDRINUSE") {
8
- return cliDiagnostic("LFC_VISUALIZER_PORT_UNAVAILABLE", "error", `Port ${port} is already in use.`);
9
- }
10
- return cliDiagnostic("LFC_VISUALIZER_SERVER_FAILED", "error", `Visualizer server failed to start: ${error.message}`);
11
- };
12
- const createNodeHttpServer = (handler) => createServer((request, response) => handler(request, response));
13
- const closeServer = (server) => new Promise((resolve, reject) => {
14
- server.close((error) => {
15
- if (error) reject(error);
16
- else resolve();
17
- });
18
- });
19
- const listenServer = async (server, port) => new Promise((resolve) => {
20
- const cleanup = () => {
21
- server.removeListener("error", onError);
22
- server.removeListener("listening", onListening);
23
- };
24
- const onError = (error) => {
25
- cleanup();
26
- resolve({ ok: false, error });
27
- };
28
- const onListening = () => {
29
- cleanup();
30
- resolve({ ok: true });
31
- };
32
- server.once("error", onError);
33
- server.once("listening", onListening);
34
- server.listen(port, "127.0.0.1");
35
- });
36
- const handleVisualizerRequest = async (options, request) => {
37
- const url = createRequestUrl(request);
38
- const pathname = createRequestPathname(request);
39
- if (url.pathname.startsWith("/api/")) {
40
- return dispatchApiRoute(options.routes, {
41
- request,
42
- url,
43
- cliContext: options.context,
44
- session: options.session
45
- });
46
- }
47
- return serveStaticAsset(options.context, {
48
- staticRoot: options.staticRoot,
49
- pathname,
50
- method: request.method
51
- });
52
- };
53
- const startVisualizerServer = async (options, dependencies = {}) => {
54
- const { createHttpServer = createNodeHttpServer, routes = createVisualizerRoutes() } = dependencies;
55
- const routeContext = { ...options, routes };
56
- const server = createHttpServer(async (request, response) => {
57
- try {
58
- const output = await handleVisualizerRequest(routeContext, request);
59
- writeHttpResponse(response, output);
60
- } catch {
61
- writeHttpResponse(response, errorResponse(500, "server-failure", "Unexpected visualizer server failure."));
62
- }
63
- });
64
- const listening = await listenServer(server, options.port);
65
- if (!listening.ok) {
66
- return { ok: false, diagnostics: [diagnosticForListenError(listening.error, options.port)] };
67
- }
68
- return {
69
- ok: true,
70
- server: {
71
- url: `http://127.0.0.1:${options.port}/?session=${options.session.token}`,
72
- port: options.port,
73
- close: () => closeServer(server)
74
- }
75
- };
76
- };
77
- const waitForSignalShutdown = (server) => new Promise((resolve) => {
78
- const shutdown = () => {
79
- process.removeListener("SIGINT", shutdown);
80
- process.removeListener("SIGTERM", shutdown);
81
- server.close().finally(resolve);
82
- };
83
- process.once("SIGINT", shutdown);
84
- process.once("SIGTERM", shutdown);
85
- });
86
- export {
87
- handleVisualizerRequest,
88
- startVisualizerServer,
89
- waitForSignalShutdown
90
- };
@@ -1,34 +0,0 @@
1
- import type { LiteFsmGraphProjectResult } from "@lite-fsm/graph";
2
- import type { CliContext } from "../cli/context.js";
3
- import type { LiteFsmProjectGraphExportDocument } from "../export-graph/export-document.js";
4
- import type { VisualizerHostCapabilities, VisualizerSessionResponse, VisualizerSourceResponse } from "./types.js";
5
- export type VisualizerSourceReadResult = {
6
- ok: true;
7
- response: VisualizerSourceResponse;
8
- } | {
9
- ok: false;
10
- status: 400 | 404 | 409 | 500;
11
- code: string;
12
- message: string;
13
- };
14
- export type VisualizerSession = {
15
- sessionId: string;
16
- token: string;
17
- projectRoot: string;
18
- exportDocument: LiteFsmProjectGraphExportDocument;
19
- capabilities: VisualizerHostCapabilities;
20
- authenticate(token: string | null): boolean;
21
- createSessionResponse(): VisualizerSessionResponse;
22
- readSource(context: CliContext, fileName: string | null): VisualizerSourceReadResult;
23
- };
24
- export type CreateVisualizerSessionOptions = {
25
- projectRoot: string;
26
- exportDocument: LiteFsmProjectGraphExportDocument;
27
- graphResult: LiteFsmGraphProjectResult;
28
- sessionId?: string;
29
- token?: string;
30
- };
31
- export declare const createGraphCompatibleSourceHash: (source: string) => string;
32
- export declare const createSessionToken: () => string;
33
- export declare const isValidProjectFileName: (fileName: string) => boolean;
34
- export declare const createVisualizerSession: ({ projectRoot, exportDocument, graphResult, sessionId, token, }: CreateVisualizerSessionOptions) => VisualizerSession;
@@ -1,34 +0,0 @@
1
- import type { LiteFsmGraphProjectResult } from "@lite-fsm/graph";
2
- import type { CliContext } from "../cli/context.js";
3
- import type { LiteFsmProjectGraphExportDocument } from "../export-graph/export-document.js";
4
- import type { VisualizerHostCapabilities, VisualizerSessionResponse, VisualizerSourceResponse } from "./types.js";
5
- export type VisualizerSourceReadResult = {
6
- ok: true;
7
- response: VisualizerSourceResponse;
8
- } | {
9
- ok: false;
10
- status: 400 | 404 | 409 | 500;
11
- code: string;
12
- message: string;
13
- };
14
- export type VisualizerSession = {
15
- sessionId: string;
16
- token: string;
17
- projectRoot: string;
18
- exportDocument: LiteFsmProjectGraphExportDocument;
19
- capabilities: VisualizerHostCapabilities;
20
- authenticate(token: string | null): boolean;
21
- createSessionResponse(): VisualizerSessionResponse;
22
- readSource(context: CliContext, fileName: string | null): VisualizerSourceReadResult;
23
- };
24
- export type CreateVisualizerSessionOptions = {
25
- projectRoot: string;
26
- exportDocument: LiteFsmProjectGraphExportDocument;
27
- graphResult: LiteFsmGraphProjectResult;
28
- sessionId?: string;
29
- token?: string;
30
- };
31
- export declare const createGraphCompatibleSourceHash: (source: string) => string;
32
- export declare const createSessionToken: () => string;
33
- export declare const isValidProjectFileName: (fileName: string) => boolean;
34
- export declare const createVisualizerSession: ({ projectRoot, exportDocument, graphResult, sessionId, token, }: CreateVisualizerSessionOptions) => VisualizerSession;
@@ -1,137 +0,0 @@
1
- import { randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
2
- import { resolve } from "node:path";
3
- import { normalizeAbsolutePath, normalizePath } from "../project/source-cache.js";
4
- const createGraphCompatibleSourceHash = (source) => {
5
- let hash = 2166136261;
6
- for (let index = 0; index < source.length; index += 1) {
7
- hash ^= source.charCodeAt(index);
8
- hash = Math.imul(hash, 16777619);
9
- }
10
- return (hash >>> 0).toString(16).padStart(8, "0");
11
- };
12
- const createSessionToken = () => {
13
- return randomBytes(32).toString("base64url");
14
- };
15
- const isAbsoluteFileName = (fileName) => {
16
- return fileName.startsWith("/") || /^[A-Za-z]:/.test(fileName);
17
- };
18
- const isValidProjectFileName = (fileName) => {
19
- if (fileName === "" || isAbsoluteFileName(fileName) || fileName.includes("\\")) return false;
20
- const segments = fileName.split("/");
21
- return segments.every((segment) => segment !== "" && segment !== "." && segment !== "..");
22
- };
23
- const sourcePath = (projectRoot, fileName) => {
24
- return normalizeAbsolutePath(resolve(projectRoot, fileName));
25
- };
26
- const tokenEquals = (actual, expected) => {
27
- const actualBuffer = Buffer.from(actual);
28
- const expectedBuffer = Buffer.from(expected);
29
- return actualBuffer.length === expectedBuffer.length && timingSafeEqual(actualBuffer, expectedBuffer);
30
- };
31
- const sourceFileByName = (files) => {
32
- return new Map(files.map((file) => [file.fileName, file]));
33
- };
34
- const invalidFileName = () => ({
35
- ok: false,
36
- status: 400,
37
- code: "invalid-file-name",
38
- message: "Source fileName must be a project-relative graph file."
39
- });
40
- const readSessionSource = (input) => {
41
- const { context, files, projectRoot, fileName } = input;
42
- if (fileName === null || !isValidProjectFileName(fileName)) return invalidFileName();
43
- const file = files.get(fileName);
44
- if (!file) {
45
- return {
46
- ok: false,
47
- status: 404,
48
- code: "source-not-found",
49
- message: `Source file '${fileName}' is not part of the graph session.`
50
- };
51
- }
52
- const absolutePath = sourcePath(projectRoot, fileName);
53
- try {
54
- if (!context.fs.fileExists(absolutePath)) {
55
- return {
56
- ok: false,
57
- status: 404,
58
- code: "source-not-found",
59
- message: `Source file '${fileName}' could not be read.`
60
- };
61
- }
62
- const text = context.fs.readFile(absolutePath);
63
- const hash = createGraphCompatibleSourceHash(text);
64
- if (hash !== file.hash) {
65
- return {
66
- ok: false,
67
- status: 409,
68
- code: "source-stale",
69
- message: `Source file '${fileName}' changed after graph build.`
70
- };
71
- }
72
- return {
73
- ok: true,
74
- response: {
75
- ok: true,
76
- fileName,
77
- language: file.language,
78
- hash,
79
- text
80
- }
81
- };
82
- } catch (error) {
83
- const message = error instanceof Error ? error.message : String(error);
84
- return {
85
- ok: false,
86
- status: 500,
87
- code: "source-read-failed",
88
- message: `Source file '${normalizePath(fileName)}' could not be read: ${message}`
89
- };
90
- }
91
- };
92
- const createVisualizerSession = ({
93
- projectRoot,
94
- exportDocument,
95
- graphResult,
96
- sessionId = randomUUID(),
97
- token = createSessionToken()
98
- }) => {
99
- const normalizedProjectRoot = normalizeAbsolutePath(projectRoot);
100
- const files = sourceFileByName(graphResult.files);
101
- const capabilities = {
102
- mode: "local",
103
- canReadFiles: true,
104
- canWriteFiles: false,
105
- canApplyPatch: false,
106
- projectRoot: normalizedProjectRoot
107
- };
108
- return {
109
- sessionId,
110
- token,
111
- projectRoot: normalizedProjectRoot,
112
- exportDocument,
113
- capabilities,
114
- authenticate(candidateToken) {
115
- return typeof candidateToken === "string" && tokenEquals(candidateToken, token);
116
- },
117
- createSessionResponse() {
118
- return {
119
- ok: true,
120
- sessionId,
121
- capabilities,
122
- entry: exportDocument.entry,
123
- projectRoot: normalizedProjectRoot,
124
- exportDocument
125
- };
126
- },
127
- readSource(context, fileName) {
128
- return readSessionSource({ context, files, projectRoot: normalizedProjectRoot, fileName });
129
- }
130
- };
131
- };
132
- export {
133
- createGraphCompatibleSourceHash,
134
- createSessionToken,
135
- createVisualizerSession,
136
- isValidProjectFileName
137
- };
@@ -1,17 +0,0 @@
1
- import type { CliContext } from "../cli/context.js";
2
- import type { CliDiagnostic } from "../cli/diagnostics.js";
3
- import type { VisualizerHttpResponse } from "./types.js";
4
- export type ServeStaticAssetOptions = {
5
- staticRoot: string;
6
- pathname: string;
7
- method?: string;
8
- };
9
- export declare const defaultVisualizerStaticRoot: () => string;
10
- export declare const verifyVisualizerStaticArtifact: (context: CliContext, staticRoot?: string) => {
11
- ok: true;
12
- staticRoot: string;
13
- } | {
14
- ok: false;
15
- diagnostics: CliDiagnostic[];
16
- };
17
- export declare const serveStaticAsset: (context: CliContext, { staticRoot, pathname, method }: ServeStaticAssetOptions) => VisualizerHttpResponse;
@@ -1,17 +0,0 @@
1
- import type { CliContext } from "../cli/context.js";
2
- import type { CliDiagnostic } from "../cli/diagnostics.js";
3
- import type { VisualizerHttpResponse } from "./types.js";
4
- export type ServeStaticAssetOptions = {
5
- staticRoot: string;
6
- pathname: string;
7
- method?: string;
8
- };
9
- export declare const defaultVisualizerStaticRoot: () => string;
10
- export declare const verifyVisualizerStaticArtifact: (context: CliContext, staticRoot?: string) => {
11
- ok: true;
12
- staticRoot: string;
13
- } | {
14
- ok: false;
15
- diagnostics: CliDiagnostic[];
16
- };
17
- export declare const serveStaticAsset: (context: CliContext, { staticRoot, pathname, method }: ServeStaticAssetOptions) => VisualizerHttpResponse;
@@ -1,87 +0,0 @@
1
- import { extname, resolve } from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- import { cliDiagnostic } from "../cli/diagnostics.js";
4
- import { normalizeAbsolutePath } from "../project/source-cache.js";
5
- const MIME_BY_EXTENSION = {
6
- ".html": "text/html; charset=utf-8",
7
- ".js": "text/javascript; charset=utf-8",
8
- ".css": "text/css; charset=utf-8",
9
- ".svg": "image/svg+xml",
10
- ".png": "image/png",
11
- ".ico": "image/x-icon",
12
- ".json": "application/json; charset=utf-8",
13
- ".map": "application/json; charset=utf-8"
14
- };
15
- const textResponse = (status, body) => ({
16
- status,
17
- headers: { "content-type": "text/plain; charset=utf-8" },
18
- body
19
- });
20
- const defaultVisualizerStaticRoot = () => {
21
- return normalizeAbsolutePath(fileURLToPath(new URL("../visualizer", import.meta.url)));
22
- };
23
- const verifyVisualizerStaticArtifact = (context, staticRoot = defaultVisualizerStaticRoot()) => {
24
- const root = normalizeAbsolutePath(staticRoot);
25
- const indexPath = normalizeAbsolutePath(resolve(root, "index.html"));
26
- if (context.fs.fileExists(indexPath)) return { ok: true, staticRoot: root };
27
- return {
28
- ok: false,
29
- diagnostics: [
30
- cliDiagnostic("LFC_VISUALIZER_STATIC_MISSING", "error", "Visualizer static artifact is missing.", {
31
- file: indexPath,
32
- hint: "Run the @lite-fsm/cli build pipeline so apps/visualizer/dist is copied to packages/cli/dist/visualizer."
33
- })
34
- ]
35
- };
36
- };
37
- const decodePathname = (pathname) => {
38
- try {
39
- return decodeURIComponent(pathname);
40
- } catch {
41
- return void 0;
42
- }
43
- };
44
- const bodyForFile = (context, fileName) => {
45
- return context.fs.readFileBuffer?.(fileName) ?? Buffer.from(context.fs.readFile(fileName), "utf8");
46
- };
47
- const fileResponse = (context, fileName) => {
48
- const extension = extname(fileName);
49
- const contentType = MIME_BY_EXTENSION[extension];
50
- if (!contentType) return textResponse(404, "Not found\n");
51
- return {
52
- status: 200,
53
- headers: {
54
- "content-type": contentType
55
- },
56
- body: bodyForFile(context, fileName)
57
- };
58
- };
59
- const serveStaticAsset = (context, { staticRoot, pathname, method = "GET" }) => {
60
- if (method !== "GET") {
61
- return {
62
- status: 405,
63
- headers: {
64
- "allow": "GET",
65
- "content-type": "text/plain; charset=utf-8"
66
- },
67
- body: `Method ${method} is not allowed.
68
- `
69
- };
70
- }
71
- const root = normalizeAbsolutePath(staticRoot);
72
- const decodedPathname = decodePathname(pathname);
73
- if (decodedPathname === void 0 || decodedPathname.includes("\\")) return textResponse(404, "Not found\n");
74
- if (decodedPathname.split("/").some((segment) => segment === "." || segment === "..")) {
75
- return textResponse(404, "Not found\n");
76
- }
77
- const isAssetRequest = decodedPathname === "/assets" || decodedPathname.startsWith("/assets/");
78
- const relativePath = decodedPathname === "/" || !isAssetRequest ? "index.html" : decodedPathname.slice(1);
79
- const fileName = normalizeAbsolutePath(resolve(root, relativePath));
80
- if (!context.fs.fileExists(fileName)) return textResponse(404, "Not found\n");
81
- return fileResponse(context, fileName);
82
- };
83
- export {
84
- defaultVisualizerStaticRoot,
85
- serveStaticAsset,
86
- verifyVisualizerStaticArtifact
87
- };
@@ -1,65 +0,0 @@
1
- import type { URL } from "node:url";
2
- import type { CliContext } from "../cli/context.js";
3
- import type { LiteFsmProjectGraphExportDocument } from "../export-graph/export-document.js";
4
- import type { VisualizerSession } from "./session.js";
5
- export type VisualizeOptions = {
6
- entry: string;
7
- tsconfig?: string;
8
- port: number;
9
- noOpen: boolean;
10
- };
11
- export type VisualizerHostCapabilities = {
12
- mode: "local";
13
- canReadFiles: boolean;
14
- canWriteFiles: boolean;
15
- canApplyPatch: boolean;
16
- projectRoot: string;
17
- };
18
- export type VisualizerSessionResponse = {
19
- ok: true;
20
- sessionId: string;
21
- capabilities: VisualizerHostCapabilities;
22
- entry: {
23
- path: string;
24
- tsconfigPath?: string;
25
- };
26
- projectRoot: string;
27
- exportDocument: LiteFsmProjectGraphExportDocument;
28
- };
29
- export type VisualizerSourceResponse = {
30
- ok: true;
31
- fileName: string;
32
- language: "ts";
33
- hash: string;
34
- text: string;
35
- };
36
- export type VisualizerErrorResponse = {
37
- ok: false;
38
- code: string;
39
- message: string;
40
- };
41
- export type VisualizerHttpResponse = {
42
- status: number;
43
- headers?: Record<string, string>;
44
- body?: string | Uint8Array;
45
- };
46
- export type VisualizerHttpRequest = {
47
- method?: string;
48
- url?: string;
49
- };
50
- export type VisualizerHttpResponseWriter = {
51
- writeHead(statusCode: number, headers?: Record<string, string>): unknown;
52
- end(data?: Uint8Array): unknown;
53
- };
54
- export type VisualizerRouteContext = {
55
- request: VisualizerHttpRequest;
56
- url: URL;
57
- cliContext: CliContext;
58
- session: VisualizerSession;
59
- };
60
- export type VisualizerRoute = {
61
- method: "GET" | "POST";
62
- path: string;
63
- auth: "none" | "session";
64
- handle(context: VisualizerRouteContext): Promise<VisualizerHttpResponse> | VisualizerHttpResponse;
65
- };
@@ -1,65 +0,0 @@
1
- import type { URL } from "node:url";
2
- import type { CliContext } from "../cli/context.js";
3
- import type { LiteFsmProjectGraphExportDocument } from "../export-graph/export-document.js";
4
- import type { VisualizerSession } from "./session.js";
5
- export type VisualizeOptions = {
6
- entry: string;
7
- tsconfig?: string;
8
- port: number;
9
- noOpen: boolean;
10
- };
11
- export type VisualizerHostCapabilities = {
12
- mode: "local";
13
- canReadFiles: boolean;
14
- canWriteFiles: boolean;
15
- canApplyPatch: boolean;
16
- projectRoot: string;
17
- };
18
- export type VisualizerSessionResponse = {
19
- ok: true;
20
- sessionId: string;
21
- capabilities: VisualizerHostCapabilities;
22
- entry: {
23
- path: string;
24
- tsconfigPath?: string;
25
- };
26
- projectRoot: string;
27
- exportDocument: LiteFsmProjectGraphExportDocument;
28
- };
29
- export type VisualizerSourceResponse = {
30
- ok: true;
31
- fileName: string;
32
- language: "ts";
33
- hash: string;
34
- text: string;
35
- };
36
- export type VisualizerErrorResponse = {
37
- ok: false;
38
- code: string;
39
- message: string;
40
- };
41
- export type VisualizerHttpResponse = {
42
- status: number;
43
- headers?: Record<string, string>;
44
- body?: string | Uint8Array;
45
- };
46
- export type VisualizerHttpRequest = {
47
- method?: string;
48
- url?: string;
49
- };
50
- export type VisualizerHttpResponseWriter = {
51
- writeHead(statusCode: number, headers?: Record<string, string>): unknown;
52
- end(data?: Uint8Array): unknown;
53
- };
54
- export type VisualizerRouteContext = {
55
- request: VisualizerHttpRequest;
56
- url: URL;
57
- cliContext: CliContext;
58
- session: VisualizerSession;
59
- };
60
- export type VisualizerRoute = {
61
- method: "GET" | "POST";
62
- path: string;
63
- auth: "none" | "session";
64
- handle(context: VisualizerRouteContext): Promise<VisualizerHttpResponse> | VisualizerHttpResponse;
65
- };
File without changes