@evjs/build-tools 0.0.1-rc.17 → 0.0.1-rc.27
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/README.md +4 -4
- package/esm/index.d.ts +2 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/routes.d.ts +19 -0
- package/esm/routes.d.ts.map +1 -0
- package/esm/routes.js +88 -0
- package/esm/routes.js.map +1 -0
- package/esm/types.d.ts +6 -6
- package/esm/types.js +6 -6
- package/esm/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
|
|
34
34
|
// Generate server entry source
|
|
35
35
|
const entrySource = generateServerEntry(
|
|
36
|
-
{ appFactory: "@evjs/
|
|
36
|
+
{ appFactory: "@evjs/server#createApp" },
|
|
37
37
|
["/path/to/api/users.server.ts"],
|
|
38
38
|
);
|
|
39
39
|
|
|
@@ -67,9 +67,9 @@ All generated code passes through `emitCode()` — a SWC `parseSync → printSyn
|
|
|
67
67
|
All runtime identifiers (module paths, function names, property names) are centralized in a single `RUNTIME` constant — no hardcoded strings in templates:
|
|
68
68
|
|
|
69
69
|
```ts
|
|
70
|
-
RUNTIME.serverModule // "@evjs/
|
|
71
|
-
RUNTIME.appModule // "@evjs/
|
|
72
|
-
RUNTIME.clientTransportModule // "@evjs/
|
|
70
|
+
RUNTIME.serverModule // "@evjs/server/register"
|
|
71
|
+
RUNTIME.appModule // "@evjs/server"
|
|
72
|
+
RUNTIME.clientTransportModule // "@evjs/client/transport"
|
|
73
73
|
RUNTIME.registerServerFn // "registerServerFn"
|
|
74
74
|
RUNTIME.clientCall // "__fn_call"
|
|
75
75
|
RUNTIME.clientRegister // "__fn_register"
|
package/esm/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Bundler-agnostic build utilities for the ev framework.
|
|
3
3
|
*/
|
|
4
4
|
export { generateServerEntry } from "./entry.js";
|
|
5
|
+
export type { ExtractedRoute } from "./routes.js";
|
|
6
|
+
export { extractRoutes } from "./routes.js";
|
|
5
7
|
export type { TransformResult } from "./transforms/index.js";
|
|
6
8
|
export { transformServerFile } from "./transforms/index.js";
|
|
7
9
|
export type { ServerEntryConfig, TransformOptions } from "./types.js";
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EACL,eAAe,EACf,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EACL,eAAe,EACf,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Bundler-agnostic build utilities for the ev framework.
|
|
3
3
|
*/
|
|
4
4
|
export { generateServerEntry } from "./entry.js";
|
|
5
|
+
export { extractRoutes } from "./routes.js";
|
|
5
6
|
export { transformServerFile } from "./transforms/index.js";
|
|
6
7
|
export { detectUseServer, hashString, makeFnId, makeModuleId, parseModuleRef, } from "./utils.js";
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EACL,eAAe,EACf,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EACL,eAAe,EACf,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/esm/routes.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Route metadata extracted from a createRoute() call. */
|
|
2
|
+
export interface ExtractedRoute {
|
|
3
|
+
/** Route path (e.g. "/", "/posts/$postId"). */
|
|
4
|
+
path: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Extract route metadata from source code by scanning for createRoute() calls.
|
|
8
|
+
*
|
|
9
|
+
* Only collects routes that have a `path` property — pathless layouts (using `id`)
|
|
10
|
+
* are skipped since they don't represent navigable URLs.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* extractRoutes('export const r = createRoute({ path: "/foo" })')
|
|
15
|
+
* // => [{ path: "/foo" }]
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractRoutes(source: string): ExtractedRoute[];
|
|
19
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AASA,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC7B,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE,CAmB9D"}
|
package/esm/routes.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { parseSync } from "@swc/core";
|
|
2
|
+
/**
|
|
3
|
+
* Extract route metadata from source code by scanning for createRoute() calls.
|
|
4
|
+
*
|
|
5
|
+
* Only collects routes that have a `path` property — pathless layouts (using `id`)
|
|
6
|
+
* are skipped since they don't represent navigable URLs.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* extractRoutes('export const r = createRoute({ path: "/foo" })')
|
|
11
|
+
* // => [{ path: "/foo" }]
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export function extractRoutes(source) {
|
|
15
|
+
let ast;
|
|
16
|
+
try {
|
|
17
|
+
ast = parseSync(source, {
|
|
18
|
+
syntax: "typescript",
|
|
19
|
+
tsx: true,
|
|
20
|
+
target: "esnext",
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return [];
|
|
25
|
+
}
|
|
26
|
+
const routes = [];
|
|
27
|
+
for (const item of ast.body) {
|
|
28
|
+
collectFromItem(item, routes);
|
|
29
|
+
}
|
|
30
|
+
return routes;
|
|
31
|
+
}
|
|
32
|
+
/** Walk a top-level module item looking for createRoute calls. */
|
|
33
|
+
function collectFromItem(item, routes) {
|
|
34
|
+
// export const fooRoute = createRoute({ ... })
|
|
35
|
+
if (item.type === "ExportDeclaration") {
|
|
36
|
+
const decl = item.declaration;
|
|
37
|
+
if (decl.type === "VariableDeclaration") {
|
|
38
|
+
for (const d of decl.declarations) {
|
|
39
|
+
if (d.init) {
|
|
40
|
+
tryExtractFromExpr(d.init, routes);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
// const fooRoute = createRoute({ ... })
|
|
47
|
+
if (item.type === "VariableDeclaration") {
|
|
48
|
+
for (const d of item.declarations) {
|
|
49
|
+
if (d.init) {
|
|
50
|
+
tryExtractFromExpr(d.init, routes);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** If the expression is a createRoute() call, extract route metadata. */
|
|
56
|
+
function tryExtractFromExpr(expr, routes) {
|
|
57
|
+
if (!isCreateRouteCall(expr))
|
|
58
|
+
return;
|
|
59
|
+
const call = expr;
|
|
60
|
+
if (call.arguments.length === 0)
|
|
61
|
+
return;
|
|
62
|
+
const arg = call.arguments[0].expression;
|
|
63
|
+
if (arg.type !== "ObjectExpression")
|
|
64
|
+
return;
|
|
65
|
+
for (const prop of arg.properties) {
|
|
66
|
+
if (prop.type !== "KeyValueProperty")
|
|
67
|
+
continue;
|
|
68
|
+
const key = getPropertyName(prop);
|
|
69
|
+
if (key === "path" && prop.value.type === "StringLiteral") {
|
|
70
|
+
routes.push({ path: prop.value.value });
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function isCreateRouteCall(expr) {
|
|
76
|
+
if (expr.type !== "CallExpression")
|
|
77
|
+
return false;
|
|
78
|
+
const callee = expr.callee;
|
|
79
|
+
return callee.type === "Identifier" && callee.value === "createRoute";
|
|
80
|
+
}
|
|
81
|
+
function getPropertyName(kv) {
|
|
82
|
+
if (kv.key.type === "Identifier")
|
|
83
|
+
return kv.key.value;
|
|
84
|
+
if (kv.key.type === "StringLiteral")
|
|
85
|
+
return kv.key.value;
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../src/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAetC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc;IAC1C,IAAI,GAAiC,CAAC;IACtC,IAAI,CAAC;QACH,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE;YACtB,MAAM,EAAE,YAAY;YACpB,GAAG,EAAE,IAAI;YACT,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAAqB,EAAE,CAAC;IAEpC,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QAC5B,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,kEAAkE;AAClE,SAAS,eAAe,CAAC,IAAgB,EAAE,MAAwB;IACjE,+CAA+C;IAC/C,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC;QAC9B,IAAI,IAAI,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;YACxC,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;oBACX,kBAAkB,C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O,KAAK,CAAC;IACjD,MAAM,MAAM,GAAI,IAAuB,CAAC,MAAM,CAAC;IAC/C,OAAO,MAAM,CAAC,IAAI,KAAK,YAAY,IAAI,MAAM,CAAC,KAAK,KAAK,aAAa,CAAC;AACxE,CAAC;AAED,SAAS,eAAe,CAAC,EAAoB;IAC3C,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC;IACtD,IAAI,EAAE,CAAC,GAAG,CAAC,IAAI,KAAK,eAAe;QAAE,OAAO,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC;IACzD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/esm/types.d.ts
CHANGED
|
@@ -23,19 +23,19 @@ export interface TransformOptions {
|
|
|
23
23
|
* Runtime identifiers used in generated code.
|
|
24
24
|
*
|
|
25
25
|
* These are build-time constants — the actual module paths and function names
|
|
26
|
-
* that appear in codegen output. They must stay in sync with the `@evjs/
|
|
27
|
-
* package exports.
|
|
26
|
+
* that appear in codegen output. They must stay in sync with the `@evjs/client`
|
|
27
|
+
* and `@evjs/server` package exports.
|
|
28
28
|
*
|
|
29
29
|
* Note: `DEFAULT_ENDPOINT` (the default HTTP path for server functions) is a runtime
|
|
30
|
-
* concern and lives in `@evjs/
|
|
30
|
+
* concern and lives in `@evjs/shared/src/constants.ts`, not here.
|
|
31
31
|
*/
|
|
32
32
|
export declare const RUNTIME: {
|
|
33
33
|
/** Module path for server-side function registration (no Hono dependency). */
|
|
34
|
-
readonly serverModule: "@evjs/
|
|
34
|
+
readonly serverModule: "@evjs/server/register";
|
|
35
35
|
/** Module path for the server app factory (Hono app + server function handler). */
|
|
36
|
-
readonly appModule: "@evjs/
|
|
36
|
+
readonly appModule: "@evjs/server";
|
|
37
37
|
/** Module path for client-side transport stubs. */
|
|
38
|
-
readonly clientTransportModule: "@evjs/
|
|
38
|
+
readonly clientTransportModule: "@evjs/client/transport";
|
|
39
39
|
/** Server function registration call name. */
|
|
40
40
|
readonly registerServerFn: "registerServerFn";
|
|
41
41
|
/** Client-side server function call name. */
|
package/esm/types.js
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* Runtime identifiers used in generated code.
|
|
3
3
|
*
|
|
4
4
|
* These are build-time constants — the actual module paths and function names
|
|
5
|
-
* that appear in codegen output. They must stay in sync with the `@evjs/
|
|
6
|
-
* package exports.
|
|
5
|
+
* that appear in codegen output. They must stay in sync with the `@evjs/client`
|
|
6
|
+
* and `@evjs/server` package exports.
|
|
7
7
|
*
|
|
8
8
|
* Note: `DEFAULT_ENDPOINT` (the default HTTP path for server functions) is a runtime
|
|
9
|
-
* concern and lives in `@evjs/
|
|
9
|
+
* concern and lives in `@evjs/shared/src/constants.ts`, not here.
|
|
10
10
|
*/
|
|
11
11
|
export const RUNTIME = {
|
|
12
12
|
/** Module path for server-side function registration (no Hono dependency). */
|
|
13
|
-
serverModule: "@evjs/
|
|
13
|
+
serverModule: "@evjs/server/register",
|
|
14
14
|
/** Module path for the server app factory (Hono app + server function handler). */
|
|
15
|
-
appModule: "@evjs/
|
|
15
|
+
appModule: "@evjs/server",
|
|
16
16
|
/** Module path for client-side transport stubs. */
|
|
17
|
-
clientTransportModule: "@evjs/
|
|
17
|
+
clientTransportModule: "@evjs/client/transport",
|
|
18
18
|
/** Server function registration call name. */
|
|
19
19
|
registerServerFn: "registerServerFn",
|
|
20
20
|
/** Client-side server function call name. */
|
package/esm/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAuBA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,8EAA8E;IAC9E,YAAY,EAAE
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAuBA;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,8EAA8E;IAC9E,YAAY,EAAE,uBAAuB;IACrC,mFAAmF;IACnF,SAAS,EAAE,cAAc;IACzB,mDAAmD;IACnD,qBAAqB,EAAE,wBAAwB;IAC/C,8CAA8C;IAC9C,gBAAgB,EAAE,kBAAkB;IACpC,6CAA6C;IAC7C,UAAU,EAAE,WAAW;IACvB,mDAAmD;IACnD,cAAc,EAAE,eAAe;CACvB,CAAC"}
|