jsxpression 0.1.24 → 0.1.26
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/lib/analyze/data/analyze.js +1 -1
- package/lib/analyze/data/analyze.js.map +1 -1
- package/lib/codegen/schema/data-types.d.ts.map +1 -1
- package/lib/codegen/schema/data-types.js +2 -34
- package/lib/codegen/schema/data-types.js.map +1 -1
- package/package.json +2 -2
- package/src/analyze/data/analyze.ts +1 -1
- package/src/codegen/schema/data-types.ts +2 -38
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnalysisReport } from "../analysis-report.js";
|
|
2
2
|
import { ValidationContext } from "../validation-context.js";
|
|
3
|
-
import { analyzeDataAccess } from "./data-access.js";
|
|
4
3
|
import { analyzeMethodCalls } from "./method-calls.js";
|
|
4
|
+
import { analyzeDataAccess } from "./data-access.js";
|
|
5
5
|
export function analyzeData(ast, schema) {
|
|
6
6
|
const validationContext = new ValidationContext();
|
|
7
7
|
return new AnalysisReport().merge(analyzeMethodCalls(ast, schema, validationContext), analyzeDataAccess(ast, schema, validationContext));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyze.js","sourceRoot":"","sources":["../../../src/analyze/data/analyze.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"analyze.js","sourceRoot":"","sources":["../../../src/analyze/data/analyze.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,UAAU,WAAW,CAAC,GAAY,EAAE,MAAc;IACtD,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAElD,OAAO,IAAI,cAAc,EAAE,CAAC,KAAK,CAC/B,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAClD,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAClD,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-types.d.ts","sourceRoot":"","sources":["../../../src/codegen/schema/data-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG9C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"data-types.d.ts","sourceRoot":"","sources":["../../../src/codegen/schema/data-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAG9C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAkBvD"}
|
|
@@ -2,17 +2,14 @@ import { mapSchemaTypeToTypeScript } from "./utils.js";
|
|
|
2
2
|
export function declareDataTypes(schema) {
|
|
3
3
|
let output = `declare global {\n`;
|
|
4
4
|
if (schema.data) {
|
|
5
|
-
output += generateDataObjectComment(schema.data, " ");
|
|
6
|
-
//output += ` const data: {\n`;
|
|
7
5
|
Object.entries(schema.data).forEach(([dataKey, dataSchema]) => {
|
|
8
|
-
output += generateNestedPropertyJSDoc(dataKey, dataSchema, "
|
|
6
|
+
output += generateNestedPropertyJSDoc(dataKey, dataSchema, " ");
|
|
9
7
|
const type = mapSchemaTypeToTypeScript(dataSchema);
|
|
10
8
|
const indentedType = type.includes("\n") ? type.replace(/\n/g, "\n ").replace(/\n {4}$/, "\n ") : type;
|
|
11
9
|
output += ` ${dataKey}: ${indentedType};\n`;
|
|
12
10
|
});
|
|
13
|
-
output += ` };\n`;
|
|
14
11
|
}
|
|
15
|
-
|
|
12
|
+
output += `}\n\n`;
|
|
16
13
|
output += `export {};\n`;
|
|
17
14
|
return output;
|
|
18
15
|
}
|
|
@@ -63,33 +60,4 @@ function generateNestedPropertyJSDoc(propertyName, propertySchema, indent = "")
|
|
|
63
60
|
output += `${indent} */\n`;
|
|
64
61
|
return output;
|
|
65
62
|
}
|
|
66
|
-
function generateDataObjectComment(dataSchema, indent = "") {
|
|
67
|
-
const comments = [];
|
|
68
|
-
comments.push("Data object for JSX expressions");
|
|
69
|
-
comments.push("");
|
|
70
|
-
Object.entries(dataSchema).forEach(([dataKey, schema]) => {
|
|
71
|
-
if (schema.description) {
|
|
72
|
-
comments.push(`@property ${dataKey} ${schema.description}`);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
const desc = dataKey.charAt(0).toUpperCase() +
|
|
76
|
-
dataKey
|
|
77
|
-
.slice(1)
|
|
78
|
-
.replace(/([A-Z])/g, " $1")
|
|
79
|
-
.toLowerCase();
|
|
80
|
-
comments.push(`@property ${dataKey} ${desc}`);
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
let output = `${indent}/**\n`;
|
|
84
|
-
comments.forEach((comment) => {
|
|
85
|
-
if (comment === "") {
|
|
86
|
-
output += `${indent} *\n`;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
output += `${indent} * ${comment}\n`;
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
output += `${indent} */\n`;
|
|
93
|
-
return output;
|
|
94
|
-
}
|
|
95
63
|
//# sourceMappingURL=data-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-types.js","sourceRoot":"","sources":["../../../src/codegen/schema/data-types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvD,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,IAAI,MA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AC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAClD,OAAO,GAAG,MAAM,OAAO,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;IAC5C,CAAC;IAED,IAAI,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;YACnB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC;QAC5B,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,GAAG,MAAM,MAAM,OAAO,IAAI,CAAC;QACvC,CAAC;IACH,CAAC,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC;IAE3B,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsxpression",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"description": "Validate and safely render JSX expressions",
|
|
5
5
|
"author": "Divid AB <info@divid.se>",
|
|
6
6
|
"repository": "https://github.com/dividab/abstract-visuals/tree/master/packages/jsxpression",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"acorn-jsx": "5.3.2",
|
|
27
27
|
"acorn-walk": "8.3.4"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "1933d888af0c6bbbd2e6acf502e0352e3223de98"
|
|
30
30
|
}
|
|
@@ -2,8 +2,8 @@ import { Program } from "acorn";
|
|
|
2
2
|
import { Schema } from "../../schema.js";
|
|
3
3
|
import { AnalysisReport } from "../analysis-report.js";
|
|
4
4
|
import { ValidationContext } from "../validation-context.js";
|
|
5
|
-
import { analyzeDataAccess } from "./data-access.js";
|
|
6
5
|
import { analyzeMethodCalls } from "./method-calls.js";
|
|
6
|
+
import { analyzeDataAccess } from "./data-access.js";
|
|
7
7
|
|
|
8
8
|
export function analyzeData(ast: Program, schema: Schema): AnalysisReport {
|
|
9
9
|
const validationContext = new ValidationContext();
|
|
@@ -5,20 +5,17 @@ export function declareDataTypes(schema: Schema): string {
|
|
|
5
5
|
let output = `declare global {\n`;
|
|
6
6
|
|
|
7
7
|
if (schema.data) {
|
|
8
|
-
output += generateDataObjectComment(schema.data, " ");
|
|
9
|
-
//output += ` const data: {\n`;
|
|
10
8
|
Object.entries(schema.data).forEach(([dataKey, dataSchema]) => {
|
|
11
|
-
output += generateNestedPropertyJSDoc(dataKey, dataSchema, "
|
|
9
|
+
output += generateNestedPropertyJSDoc(dataKey, dataSchema, " ");
|
|
12
10
|
|
|
13
11
|
const type = mapSchemaTypeToTypeScript(dataSchema);
|
|
14
12
|
|
|
15
13
|
const indentedType = type.includes("\n") ? type.replace(/\n/g, "\n ").replace(/\n {4}$/, "\n ") : type;
|
|
16
14
|
output += ` ${dataKey}: ${indentedType};\n`;
|
|
17
15
|
});
|
|
18
|
-
output += ` };\n`;
|
|
19
16
|
}
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
output += `}\n\n`;
|
|
22
19
|
output += `export {};\n`;
|
|
23
20
|
|
|
24
21
|
return output;
|
|
@@ -74,36 +71,3 @@ function generateNestedPropertyJSDoc(propertyName: string, propertySchema: any,
|
|
|
74
71
|
|
|
75
72
|
return output;
|
|
76
73
|
}
|
|
77
|
-
|
|
78
|
-
function generateDataObjectComment(dataSchema: any, indent: string = ""): string {
|
|
79
|
-
const comments: string[] = [];
|
|
80
|
-
|
|
81
|
-
comments.push("Data object for JSX expressions");
|
|
82
|
-
comments.push("");
|
|
83
|
-
|
|
84
|
-
Object.entries(dataSchema).forEach(([dataKey, schema]: [string, any]) => {
|
|
85
|
-
if (schema.description) {
|
|
86
|
-
comments.push(`@property ${dataKey} ${schema.description}`);
|
|
87
|
-
} else {
|
|
88
|
-
const desc =
|
|
89
|
-
dataKey.charAt(0).toUpperCase() +
|
|
90
|
-
dataKey
|
|
91
|
-
.slice(1)
|
|
92
|
-
.replace(/([A-Z])/g, " $1")
|
|
93
|
-
.toLowerCase();
|
|
94
|
-
comments.push(`@property ${dataKey} ${desc}`);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
let output = `${indent}/**\n`;
|
|
99
|
-
comments.forEach((comment) => {
|
|
100
|
-
if (comment === "") {
|
|
101
|
-
output += `${indent} *\n`;
|
|
102
|
-
} else {
|
|
103
|
-
output += `${indent} * ${comment}\n`;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
output += `${indent} */\n`;
|
|
107
|
-
|
|
108
|
-
return output;
|
|
109
|
-
}
|