@timo9378/flow2code 0.1.1 → 0.1.3
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 +56 -56
- package/LICENSE +21 -21
- package/README.md +230 -223
- package/dist/cli.js +61 -2
- package/dist/server.d.ts +27 -27
- package/dist/server.js +876 -4
- package/out/404.html +1 -1
- package/out/__next.__PAGE__.txt +4 -4
- package/out/__next._full.txt +13 -13
- package/out/__next._head.txt +4 -4
- package/out/__next._index.txt +6 -6
- package/out/__next._tree.txt +2 -2
- package/out/_next/static/chunks/{41ec06cb3e44c96a.js → 5f1a9fec0e69c483.js} +2 -2
- package/out/_next/static/chunks/6b84376656bd9887.js +1 -0
- package/out/_next/static/chunks/993eabba22c07d39.js +54 -0
- package/out/_next/static/chunks/a6dad97d9634a72d.js.map +1 -1
- package/out/_next/static/chunks/ab8888d4b78b94be.js +5 -0
- package/out/_next/static/chunks/acf223168ac429f7.js +1 -0
- package/out/_next/static/chunks/{8486af13ea541d4d.js → b112c2f519e4b429.js} +1 -1
- package/out/_next/static/chunks/{4b43c69e91d19eee.js → b163b5d7cccbcf42.js} +1 -1
- package/out/_next/static/chunks/b6e8711267bccbbd.js +1 -0
- package/out/_next/static/chunks/c8a26302d935bf6e.css +1 -0
- package/out/_next/static/chunks/fbca595129527827.js +1 -0
- package/out/_next/static/chunks/{turbopack-b95472a0b02a2729.js → turbopack-576234c945ffdc44.js} +1 -1
- package/out/_not-found/__next._full.txt +11 -11
- package/out/_not-found/__next._head.txt +4 -4
- package/out/_not-found/__next._index.txt +6 -6
- package/out/_not-found/{__next._not-found.__PAGE__.txt → __next._not-found/__PAGE__.txt} +2 -2
- package/out/_not-found/__next._not-found.txt +3 -3
- package/out/_not-found/__next._tree.txt +2 -2
- package/out/_not-found.html +1 -1
- package/out/_not-found.txt +11 -11
- package/out/index.html +2 -2
- package/out/index.txt +13 -13
- package/package.json +123 -121
- package/scripts/postinstall.cjs +23 -0
- package/out/_next/static/chunks/3638bc7cb3d72bbe.js +0 -379
- package/out/_next/static/chunks/46e882944a7f3aed.js +0 -1
- package/out/_next/static/chunks/59b058cf94cc555e.js +0 -1
- package/out/_next/static/chunks/5c37aae6b3fd1bfe.js +0 -52
- package/out/_next/static/chunks/6e36daee8960e188.js +0 -5
- package/out/_next/static/chunks/80a5431d4e78c469.js +0 -1
- package/out/_next/static/chunks/8a38426c5ed81587.js +0 -1
- package/out/_next/static/chunks/8b2510d8037d3419.css +0 -1
- /package/out/_next/static/{MU8PWJNAi-sgHZxErePm1 → gs3QpnA696kN6tOSlwt6o}/_buildManifest.js +0 -0
- /package/out/_next/static/{MU8PWJNAi-sgHZxErePm1 → gs3QpnA696kN6tOSlwt6o}/_clientMiddlewareManifest.json +0 -0
- /package/out/_next/static/{MU8PWJNAi-sgHZxErePm1 → gs3QpnA696kN6tOSlwt6o}/_ssgManifest.js +0 -0
package/dist/cli.js
CHANGED
|
@@ -3792,10 +3792,55 @@ function handleImportOpenAPI(body) {
|
|
|
3792
3792
|
};
|
|
3793
3793
|
}
|
|
3794
3794
|
}
|
|
3795
|
+
function handleDecompile(body) {
|
|
3796
|
+
try {
|
|
3797
|
+
const { code, fileName, functionName } = body;
|
|
3798
|
+
if (!code || typeof code !== "string") {
|
|
3799
|
+
return { status: 400, body: { success: false, error: "Missing 'code' string in request body" } };
|
|
3800
|
+
}
|
|
3801
|
+
if (code.trim().length === 0) {
|
|
3802
|
+
return { status: 400, body: { success: false, error: "Code is empty" } };
|
|
3803
|
+
}
|
|
3804
|
+
const result = decompile(code, {
|
|
3805
|
+
fileName: fileName ?? "input.ts",
|
|
3806
|
+
functionName,
|
|
3807
|
+
audit: true
|
|
3808
|
+
});
|
|
3809
|
+
if (!result.success) {
|
|
3810
|
+
return {
|
|
3811
|
+
status: 422,
|
|
3812
|
+
body: {
|
|
3813
|
+
success: false,
|
|
3814
|
+
errors: result.errors ?? ["Decompile failed"],
|
|
3815
|
+
confidence: result.confidence
|
|
3816
|
+
}
|
|
3817
|
+
};
|
|
3818
|
+
}
|
|
3819
|
+
return {
|
|
3820
|
+
status: 200,
|
|
3821
|
+
body: {
|
|
3822
|
+
success: true,
|
|
3823
|
+
ir: result.ir,
|
|
3824
|
+
confidence: result.confidence,
|
|
3825
|
+
errors: result.errors ?? [],
|
|
3826
|
+
audit: result.audit ?? []
|
|
3827
|
+
}
|
|
3828
|
+
};
|
|
3829
|
+
} catch (err) {
|
|
3830
|
+
return {
|
|
3831
|
+
status: 500,
|
|
3832
|
+
body: {
|
|
3833
|
+
success: false,
|
|
3834
|
+
error: `Decompile error: ${err instanceof Error ? err.message : String(err)}`
|
|
3835
|
+
}
|
|
3836
|
+
};
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3795
3839
|
var init_handlers = __esm({
|
|
3796
3840
|
"src/server/handlers.ts"() {
|
|
3797
3841
|
"use strict";
|
|
3798
3842
|
init_compiler();
|
|
3843
|
+
init_decompiler();
|
|
3799
3844
|
init_validator();
|
|
3800
3845
|
init_security();
|
|
3801
3846
|
init_converter();
|
|
@@ -3807,6 +3852,7 @@ var init_handlers = __esm({
|
|
|
3807
3852
|
var server_exports = {};
|
|
3808
3853
|
__export(server_exports, {
|
|
3809
3854
|
handleCompile: () => handleCompile,
|
|
3855
|
+
handleDecompile: () => handleDecompile,
|
|
3810
3856
|
handleGenerate: () => handleGenerate,
|
|
3811
3857
|
handleImportOpenAPI: () => handleImportOpenAPI,
|
|
3812
3858
|
startServer: () => startServer
|
|
@@ -3956,6 +4002,11 @@ async function handleRequest(req, res, staticDir, projectRoot) {
|
|
|
3956
4002
|
sendJson(res, result.status, result.body);
|
|
3957
4003
|
return;
|
|
3958
4004
|
}
|
|
4005
|
+
if (pathname === "/api/decompile") {
|
|
4006
|
+
const result = handleDecompile(body);
|
|
4007
|
+
sendJson(res, result.status, result.body);
|
|
4008
|
+
return;
|
|
4009
|
+
}
|
|
3959
4010
|
sendJson(res, 404, { error: `Unknown API route: ${pathname}` });
|
|
3960
4011
|
return;
|
|
3961
4012
|
}
|
|
@@ -3983,6 +4034,7 @@ function startServer(options = {}) {
|
|
|
3983
4034
|
res.end("Internal Server Error");
|
|
3984
4035
|
});
|
|
3985
4036
|
});
|
|
4037
|
+
const hasUI = existsSync3(join3(staticDir, "index.html"));
|
|
3986
4038
|
server.listen(port, host, () => {
|
|
3987
4039
|
const url = `http://localhost:${port}`;
|
|
3988
4040
|
if (options.onReady) {
|
|
@@ -3993,8 +4045,15 @@ function startServer(options = {}) {
|
|
|
3993
4045
|
console.log(` \u251C\u2500 Local: ${url}`);
|
|
3994
4046
|
console.log(` \u251C\u2500 API: ${url}/api/compile`);
|
|
3995
4047
|
console.log(` \u251C\u2500 Static: ${staticDir}`);
|
|
3996
|
-
console.log(` \u2514\u2500 Project: ${projectRoot}
|
|
3997
|
-
|
|
4048
|
+
console.log(` \u2514\u2500 Project: ${projectRoot}`);
|
|
4049
|
+
if (!hasUI) {
|
|
4050
|
+
console.log();
|
|
4051
|
+
console.log(` \u26A0\uFE0F UI files not found (out/index.html missing).`);
|
|
4052
|
+
console.log(` The API endpoints still work, but the visual editor won't load.`);
|
|
4053
|
+
console.log(` To fix: run "pnpm build:ui" in the flow2code source directory,`);
|
|
4054
|
+
console.log(` or reinstall from npm: npm i @timo9378/flow2code@latest`);
|
|
4055
|
+
}
|
|
4056
|
+
console.log();
|
|
3998
4057
|
}
|
|
3999
4058
|
});
|
|
4000
4059
|
return server;
|
package/dist/server.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import type { FlowIR } from "./compiler.js";
|
|
2
|
-
import type { Server } from "node:http";
|
|
3
|
-
|
|
4
|
-
export interface ApiResponse {
|
|
5
|
-
status: number;
|
|
6
|
-
body: Record<string, unknown>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface CompileRequest {
|
|
10
|
-
ir?: FlowIR;
|
|
11
|
-
write?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ServerOptions {
|
|
15
|
-
port?: number;
|
|
16
|
-
host?: string;
|
|
17
|
-
staticDir?: string;
|
|
18
|
-
/** User project root directory (defaults to process.cwd()) */
|
|
19
|
-
projectRoot?: string;
|
|
20
|
-
/** Callback after server starts */
|
|
21
|
-
onReady?: (url: string) => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export declare function handleCompile(body: CompileRequest, projectRoot: string): ApiResponse;
|
|
25
|
-
export declare function handleGenerate(body: { prompt?: string }): Promise<ApiResponse>;
|
|
26
|
-
export declare function handleImportOpenAPI(body: { spec?: unknown; filter?: { tags?: string[]; paths?: string[] } }): ApiResponse;
|
|
27
|
-
export declare function startServer(options?: ServerOptions): Server;
|
|
1
|
+
import type { FlowIR } from "./compiler.js";
|
|
2
|
+
import type { Server } from "node:http";
|
|
3
|
+
|
|
4
|
+
export interface ApiResponse {
|
|
5
|
+
status: number;
|
|
6
|
+
body: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface CompileRequest {
|
|
10
|
+
ir?: FlowIR;
|
|
11
|
+
write?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ServerOptions {
|
|
15
|
+
port?: number;
|
|
16
|
+
host?: string;
|
|
17
|
+
staticDir?: string;
|
|
18
|
+
/** User project root directory (defaults to process.cwd()) */
|
|
19
|
+
projectRoot?: string;
|
|
20
|
+
/** Callback after server starts */
|
|
21
|
+
onReady?: (url: string) => void;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export declare function handleCompile(body: CompileRequest, projectRoot: string): ApiResponse;
|
|
25
|
+
export declare function handleGenerate(body: { prompt?: string }): Promise<ApiResponse>;
|
|
26
|
+
export declare function handleImportOpenAPI(body: { spec?: unknown; filter?: { tags?: string[]; paths?: string[] } }): ApiResponse;
|
|
27
|
+
export declare function startServer(options?: ServerOptions): Server;
|