jsxpression 0.1.13 → 0.1.16
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/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/render.d.ts +1 -0
- package/lib/render.d.ts.map +1 -1
- package/lib/render.js +12 -2
- package/lib/render.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +2 -1
- package/src/render.ts +18 -2
package/lib/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ export type { Schema, PropertySchema } from "./schema.js";
|
|
|
2
2
|
export { ParseError } from "./parse/index.js";
|
|
3
3
|
export { CompilationError } from "./compile/index.js";
|
|
4
4
|
export { AnalysisError } from "./analyze/index.js";
|
|
5
|
-
export { render, type RenderOptions } from "./render.js";
|
|
5
|
+
export { render, compile, type RenderOptions } from "./render.js";
|
|
6
|
+
export { evaluate } from "./evaluate/evaluate.js";
|
|
6
7
|
export { validate, type ValidateOptions, type ValidateResult } from "./validate.js";
|
|
7
8
|
export { generateTypeScriptDefinitions } from "./codegen/index.js";
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { ParseError } from "./parse/index.js";
|
|
2
2
|
export { CompilationError } from "./compile/index.js";
|
|
3
3
|
export { AnalysisError } from "./analyze/index.js";
|
|
4
|
-
export { render } from "./render.js";
|
|
4
|
+
export { render, compile } from "./render.js";
|
|
5
|
+
export { evaluate } from "./evaluate/evaluate.js";
|
|
5
6
|
export { validate } from "./validate.js";
|
|
6
7
|
export { generateTypeScriptDefinitions } from "./codegen/index.js";
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAsB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAsB,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAA6C,MAAM,eAAe,CAAC;AAEpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC"}
|
package/lib/render.d.ts
CHANGED
|
@@ -55,4 +55,5 @@ export interface RenderOptions<T = any> extends EvaluateOptions<T> {
|
|
|
55
55
|
* ```
|
|
56
56
|
*/
|
|
57
57
|
export declare function render<T = any>(source: string, schema: Schema, { minSeverity, ...options }?: RenderOptions<T>): T;
|
|
58
|
+
export declare function compile<T = any>(source: string, schema: Schema, { minSeverity }?: RenderOptions<T>, tempSkipValidation?: boolean | undefined): string;
|
|
58
59
|
//# sourceMappingURL=render.d.ts.map
|
package/lib/render.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IAChE;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,MAAM,CAAC,CAAC,GAAG,GAAG,EAC5B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,EAAE,WAAe,EAAE,GAAG,OAAO,EAAE,GAAE,aAAa,CAAC,CAAC,CAAM,GACrD,CAAC,CASH"}
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG,CAAE,SAAQ,eAAe,CAAC,CAAC,CAAC;IAChE;;OAEG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,MAAM,CAAC,CAAC,GAAG,GAAG,EAC5B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,EAAE,WAAe,EAAE,GAAG,OAAO,EAAE,GAAE,aAAa,CAAC,CAAC,CAAM,GACrD,CAAC,CASH;AAED,wBAAgB,OAAO,CAAC,CAAC,GAAG,GAAG,EAC7B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,EAAE,WAAe,EAAE,GAAE,aAAa,CAAC,CAAC,CAAM,EAC1C,kBAAkB,CAAC,EAAE,OAAO,GAAG,SAAS,GACvC,MAAM,CASR"}
|
package/lib/render.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { compile } from "./compile/index.js";
|
|
1
|
+
import { compile as compileInternal } from "./compile/index.js";
|
|
2
2
|
import { evaluate } from "./evaluate/evaluate.js";
|
|
3
3
|
import { parse } from "./parse/index.js";
|
|
4
4
|
import { analyze, AnalysisError } from "./analyze/index.js";
|
|
@@ -48,6 +48,16 @@ export function render(source, schema, { minSeverity = 3, ...options } = {}) {
|
|
|
48
48
|
if (report.hasIssues(minSeverity)) {
|
|
49
49
|
throw AnalysisError.fromReport(report);
|
|
50
50
|
}
|
|
51
|
-
return evaluate(
|
|
51
|
+
return evaluate(compileInternal(ast), schema, options);
|
|
52
|
+
}
|
|
53
|
+
export function compile(source, schema, { minSeverity = 3 } = {}, tempSkipValidation) {
|
|
54
|
+
const ast = parse(source);
|
|
55
|
+
if (!tempSkipValidation) {
|
|
56
|
+
const report = analyze(ast, schema);
|
|
57
|
+
if (report.hasIssues(minSeverity)) {
|
|
58
|
+
throw AnalysisError.fromReport(report);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return compileInternal(ast);
|
|
52
62
|
}
|
|
53
63
|
//# sourceMappingURL=render.js.map
|
package/lib/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAmB,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAiB5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,MAAM,CACpB,MAAc,EACd,MAAc,EACd,EAAE,WAAW,GAAG,CAAC,EAAE,GAAG,OAAO,KAAuB,EAAE;IAEtD,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IAEpC,IAAI,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;QAClC,MAAM,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,CAAM,CAAC;AAC9D,CAAC;AAED,MAAM,UAAU,OAAO,CACrB,MAAc,EACd,MAAc,EACd,EAAE,WAAW,GAAG,CAAC,KAAuB,EAAE,EAC1C,kBAAwC;IAExC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,IAAI,CAAC,kBAAkB,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACpC,IAAI,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;YAClC,MAAM,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IACD,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsxpression",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
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": "4acbc3d839e9cfff1b761342a6fda68c7297943d"
|
|
30
30
|
}
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,8 @@ export { ParseError } from "./parse/index.js";
|
|
|
4
4
|
export { CompilationError } from "./compile/index.js";
|
|
5
5
|
export { AnalysisError } from "./analyze/index.js";
|
|
6
6
|
|
|
7
|
-
export { render, type RenderOptions } from "./render.js";
|
|
7
|
+
export { render, compile, type RenderOptions } from "./render.js";
|
|
8
|
+
export { evaluate } from "./evaluate/evaluate.js";
|
|
8
9
|
export { validate, type ValidateOptions, type ValidateResult } from "./validate.js";
|
|
9
10
|
|
|
10
11
|
export { generateTypeScriptDefinitions } from "./codegen/index.js";
|
package/src/render.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { compile } from "./compile/index.js";
|
|
1
|
+
import { compile as compileInternal } from "./compile/index.js";
|
|
2
2
|
import { evaluate, EvaluateOptions } from "./evaluate/evaluate.js";
|
|
3
3
|
import { parse } from "./parse/index.js";
|
|
4
4
|
import { Schema } from "./schema.js";
|
|
@@ -71,5 +71,21 @@ export function render<T = any>(
|
|
|
71
71
|
throw AnalysisError.fromReport(report);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
return evaluate(
|
|
74
|
+
return evaluate(compileInternal(ast), schema, options) as T;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function compile<T = any>(
|
|
78
|
+
source: string,
|
|
79
|
+
schema: Schema,
|
|
80
|
+
{ minSeverity = 3 }: RenderOptions<T> = {},
|
|
81
|
+
tempSkipValidation?: boolean | undefined
|
|
82
|
+
): string {
|
|
83
|
+
const ast = parse(source);
|
|
84
|
+
if (!tempSkipValidation) {
|
|
85
|
+
const report = analyze(ast, schema);
|
|
86
|
+
if (report.hasIssues(minSeverity)) {
|
|
87
|
+
throw AnalysisError.fromReport(report);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return compileInternal(ast);
|
|
75
91
|
}
|