@dreamkit/dev 0.0.11 → 0.0.13
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-solid-server-action.d.ts","sourceRoot":"","sources":["../../src/transforms/to-solid-server-action.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,mBAAmB,
|
|
1
|
+
{"version":3,"file":"to-solid-server-action.d.ts","sourceRoot":"","sources":["../../src/transforms/to-solid-server-action.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,mBAAmB,oDAgF9B,CAAC"}
|
|
@@ -25,6 +25,21 @@ export const toSolidServerAction = defineTransform({
|
|
|
25
25
|
clientApiLoc.push(path.node.loc);
|
|
26
26
|
});
|
|
27
27
|
programPath.traverse({
|
|
28
|
+
VariableDeclaration(path) {
|
|
29
|
+
const [dec] = path.node.declarations;
|
|
30
|
+
const init = dec.init;
|
|
31
|
+
if (path.parent.type === "Program" &&
|
|
32
|
+
dec.id.type === "Identifier" &&
|
|
33
|
+
init?.type === "CallExpression") {
|
|
34
|
+
const first = getFirstChain(init);
|
|
35
|
+
if (clientApiLoc.includes(first?.value.object.loc)) {
|
|
36
|
+
changes++;
|
|
37
|
+
const replaced = createServerAction(programPath, dec.id.name, init, false);
|
|
38
|
+
const index = programPath.node.body.findIndex((node) => node === path.node);
|
|
39
|
+
programPath.node.body.splice(index, 1, ...replaced);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
28
43
|
ExportNamedDeclaration(path) {
|
|
29
44
|
if (path.node.declaration) {
|
|
30
45
|
if (path.node.declaration.type === "VariableDeclaration") {
|
package/lib/utils/ast.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as lexer from "es-module-lexer";
|
|
|
6
6
|
export declare function parseCode(input: string | string[]): t.Statement[];
|
|
7
7
|
export type ParseFileResult = ParseResult<t.File>;
|
|
8
8
|
export declare function parseFile(code: string): ParseResult<t.File>;
|
|
9
|
-
export declare function tryGenerate(ast: ParseFileResult | undefined, log?: boolean): import("@babel/generator").GeneratorResult | undefined;
|
|
9
|
+
export declare function tryGenerate(ast: ParseFileResult | undefined, log?: boolean | string): import("@babel/generator").GeneratorResult | undefined;
|
|
10
10
|
export type Chain = {
|
|
11
11
|
rootName: string;
|
|
12
12
|
calls: {
|
package/lib/utils/ast.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/utils/ast.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAC;AAIzC,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,iBAIjD;AAED,MAAM,MAAM,eAAe,GAAG,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAElD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,uBAKrC;AAED,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/utils/ast.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAC;AAIzC,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,iBAIjD;AAED,MAAM,MAAM,eA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gBAAgB,CAC9B,KAAK,EAAE,CAAC,CAAC,UAAU,GAAG,MAAM,EAC5B,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,CAAC,CAAC,UAAU,EAAO,oBAqB1B;AAED,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EACzC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,EAC5B,UAAU,EAAE,CAAC,EAAE,EACf,MAAM,EAAE,MAAM,GACb;KAAG,CAAC,IAAI,CAAC,GAAG,MAAM;CAAE,CAkBtB"}
|
package/lib/utils/ast.js
CHANGED
|
@@ -17,8 +17,14 @@ export function parseFile(code) {
|
|
|
17
17
|
export function tryGenerate(ast, log) {
|
|
18
18
|
if (ast) {
|
|
19
19
|
const generated = generator(ast);
|
|
20
|
-
if (log)
|
|
21
|
-
|
|
20
|
+
if (log) {
|
|
21
|
+
if (typeof log === "string") {
|
|
22
|
+
console.log({ id: log, ...generated });
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
console.log(generated);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
22
28
|
return generated;
|
|
23
29
|
}
|
|
24
30
|
}
|
|
@@ -98,7 +104,10 @@ export async function analyzeModule(path) {
|
|
|
98
104
|
export function findExportedNames(ast) {
|
|
99
105
|
return ast.program.body
|
|
100
106
|
.map((stm) => {
|
|
101
|
-
if (stm.type === "
|
|
107
|
+
if (stm.type === "ExportDefaultDeclaration") {
|
|
108
|
+
return "default";
|
|
109
|
+
}
|
|
110
|
+
else if (stm.type === "ExportNamedDeclaration" && stm.declaration) {
|
|
102
111
|
if (stm.declaration.type === "VariableDeclaration") {
|
|
103
112
|
const [dec] = stm.declaration.declarations;
|
|
104
113
|
if (dec.id.type === "Identifier")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamkit/dev",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Development tools for DreamKit.",
|
|
5
5
|
"homepage": "https://dreamkit.dev",
|
|
6
6
|
"repository": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"rollup": "^4.26.0",
|
|
46
46
|
"vite-plugin-solid": "^2.10.2",
|
|
47
47
|
"vite-tsconfig-paths": "^5.1.2",
|
|
48
|
-
"@dreamkit/app": "0.0.
|
|
48
|
+
"@dreamkit/app": "0.0.6",
|
|
49
49
|
"@dreamkit/schema": "0.0.4"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|