jsxpression 0.1.13 → 0.1.15

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 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
@@ -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;AACzD,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,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;AACzD,OAAO,EAAE,QAAQ,EAA6C,MAAM,eAAe,CAAC;AAEpF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,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>): string;
58
59
  //# sourceMappingURL=render.d.ts.map
@@ -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,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,WAAe,EAAE,GAAE,aAAa,CAAC,CAAC,CAAM,GAAG,MAAM,CAOnH"}
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,14 @@ 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(compile(ast), schema, options);
51
+ return evaluate(compileInternal(ast), schema, options);
52
+ }
53
+ export function compile(source, schema, { minSeverity = 3 } = {}) {
54
+ const ast = parse(source);
55
+ const report = analyze(ast, schema);
56
+ if (report.hasIssues(minSeverity)) {
57
+ throw AnalysisError.fromReport(report);
58
+ }
59
+ return compileInternal(ast);
52
60
  }
53
61
  //# 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,E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AAM,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,CAAU,MAAc,EAAE,MAAc,EAAE,EAAE,WAAW,GAAG,CAAC,KAAuB,EAAE;IACzG,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,CAAC;QAClC,MAAM,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACzC,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.13",
3
+ "version": "0.1.15",
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": "41b060f45b13519f14478cd4ebe70e8f3874968c"
29
+ "gitHead": "b488708345c01b260b88113fca5edee60ec774e6"
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,14 @@ export function render<T = any>(
71
71
  throw AnalysisError.fromReport(report);
72
72
  }
73
73
 
74
- return evaluate(compile(ast), schema, options) as T;
74
+ return evaluate(compileInternal(ast), schema, options) as T;
75
+ }
76
+
77
+ export function compile<T = any>(source: string, schema: Schema, { minSeverity = 3 }: RenderOptions<T> = {}): string {
78
+ const ast = parse(source);
79
+ const report = analyze(ast, schema);
80
+ if (report.hasIssues(minSeverity)) {
81
+ throw AnalysisError.fromReport(report);
82
+ }
83
+ return compileInternal(ast);
75
84
  }