@uwdata/mosaic-spec 0.7.0 → 0.8.0

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.
Files changed (154) hide show
  1. package/dist/mosaic-schema.json +186153 -0
  2. package/dist/mosaic-spec.js +3387 -4641
  3. package/dist/mosaic-spec.min.js +23 -23
  4. package/dist/types/ast/ASTNode.d.ts +26 -0
  5. package/dist/types/ast/DataNode.d.ts +60 -0
  6. package/dist/types/ast/ExpressionNode.d.ts +15 -0
  7. package/dist/types/ast/HConcatNode.d.ts +10 -0
  8. package/dist/types/ast/HSpaceNode.d.ts +11 -0
  9. package/dist/types/ast/InputNode.d.ts +8 -0
  10. package/dist/types/ast/LiteralNode.d.ts +7 -0
  11. package/dist/types/ast/OptionsNode.d.ts +10 -0
  12. package/dist/types/ast/ParamNode.d.ts +9 -0
  13. package/dist/types/ast/ParamRefNode.d.ts +8 -0
  14. package/dist/types/ast/PlotAttributeNode.d.ts +18 -0
  15. package/dist/types/ast/PlotFromNode.d.ts +9 -0
  16. package/dist/types/ast/PlotInteractorNode.d.ts +8 -0
  17. package/dist/types/ast/PlotLegendNode.d.ts +10 -0
  18. package/dist/types/ast/PlotMarkNode.d.ts +10 -0
  19. package/dist/types/ast/PlotNode.d.ts +11 -0
  20. package/dist/types/ast/SelectionNode.d.ts +12 -0
  21. package/dist/types/ast/SpecNode.d.ts +10 -0
  22. package/dist/types/ast/TransformNode.d.ts +13 -0
  23. package/dist/types/ast/VConcatNode.d.ts +10 -0
  24. package/dist/types/ast/VSpaceNode.d.ts +11 -0
  25. package/dist/types/ast-to-dom.d.ts +38 -0
  26. package/dist/types/ast-to-esm.d.ts +64 -0
  27. package/dist/types/config/components.d.ts +4 -0
  28. package/dist/types/config/extensions.d.ts +9 -0
  29. package/dist/types/config/inputs.d.ts +5 -0
  30. package/dist/types/config/plots.d.ts +34 -0
  31. package/dist/types/config/transforms.d.ts +4 -0
  32. package/dist/types/constants.d.ts +30 -0
  33. package/dist/types/index.d.ts +29 -0
  34. package/dist/types/parse-spec.d.ts +86 -0
  35. package/dist/types/spec/CSSStyles.d.ts +3 -0
  36. package/dist/types/spec/Data.d.ts +165 -0
  37. package/dist/types/spec/Expression.d.ts +27 -0
  38. package/dist/types/spec/HConcat.d.ts +8 -0
  39. package/dist/types/spec/HSpace.d.ts +9 -0
  40. package/dist/types/spec/Input.d.ts +182 -0
  41. package/dist/types/spec/Param.d.ts +51 -0
  42. package/dist/types/spec/Plot.d.ts +14 -0
  43. package/dist/types/spec/PlotAttribute.d.ts +1522 -0
  44. package/dist/types/spec/PlotFrom.d.ts +20 -0
  45. package/dist/types/spec/PlotInteractor.d.ts +8 -0
  46. package/dist/types/spec/PlotLegend.d.ts +68 -0
  47. package/dist/types/spec/PlotMark.d.ts +26 -0
  48. package/dist/types/spec/PlotTypes.d.ts +293 -0
  49. package/dist/types/spec/Spec.d.ts +45 -0
  50. package/dist/types/spec/Transform.d.ts +278 -0
  51. package/dist/types/spec/VConcat.d.ts +8 -0
  52. package/dist/types/spec/VSpace.d.ts +9 -0
  53. package/dist/types/spec/interactors/Highlight.d.ts +37 -0
  54. package/dist/types/spec/interactors/Interval1D.d.ts +63 -0
  55. package/dist/types/spec/interactors/Interval2D.d.ts +46 -0
  56. package/dist/types/spec/interactors/Nearest.d.ts +25 -0
  57. package/dist/types/spec/interactors/PanZoom.d.ts +58 -0
  58. package/dist/types/spec/interactors/Toggle.d.ts +51 -0
  59. package/dist/types/spec/marks/Area.d.ts +139 -0
  60. package/dist/types/spec/marks/Arrow.d.ts +94 -0
  61. package/dist/types/spec/marks/Axis.d.ts +281 -0
  62. package/dist/types/spec/marks/Bar.d.ts +150 -0
  63. package/dist/types/spec/marks/Cell.d.ts +57 -0
  64. package/dist/types/spec/marks/Contour.d.ts +23 -0
  65. package/dist/types/spec/marks/Delaunay.d.ts +86 -0
  66. package/dist/types/spec/marks/DenseLine.d.ts +27 -0
  67. package/dist/types/spec/marks/Density.d.ts +121 -0
  68. package/dist/types/spec/marks/Dot.d.ts +129 -0
  69. package/dist/types/spec/marks/Frame.d.ts +21 -0
  70. package/dist/types/spec/marks/Geo.d.ts +53 -0
  71. package/dist/types/spec/marks/Hexbin.d.ts +30 -0
  72. package/dist/types/spec/marks/Hexgrid.d.ts +25 -0
  73. package/dist/types/spec/marks/Image.d.ts +89 -0
  74. package/dist/types/spec/marks/Line.d.ts +82 -0
  75. package/dist/types/spec/marks/Link.d.ts +60 -0
  76. package/dist/types/spec/marks/Marks.d.ts +890 -0
  77. package/dist/types/spec/marks/Raster.d.ts +124 -0
  78. package/dist/types/spec/marks/Rect.d.ts +166 -0
  79. package/dist/types/spec/marks/Regression.d.ts +58 -0
  80. package/dist/types/spec/marks/Rule.d.ts +100 -0
  81. package/dist/types/spec/marks/Text.d.ts +106 -0
  82. package/dist/types/spec/marks/Tick.d.ts +61 -0
  83. package/dist/types/spec/marks/Vector.d.ts +99 -0
  84. package/dist/types/util.d.ts +12 -0
  85. package/jsconfig.json +10 -0
  86. package/package.json +16 -9
  87. package/src/ast/ASTNode.js +23 -2
  88. package/src/ast/DataNode.js +79 -21
  89. package/src/ast/HSpaceNode.js +1 -1
  90. package/src/ast/InputNode.js +1 -2
  91. package/src/ast/ParamNode.js +1 -2
  92. package/src/ast/PlotAttributeNode.js +1 -2
  93. package/src/ast/PlotInteractorNode.js +1 -2
  94. package/src/ast/PlotLegendNode.js +1 -2
  95. package/src/ast/PlotMarkNode.js +3 -2
  96. package/src/ast/TransformNode.js +1 -2
  97. package/src/ast/VSpaceNode.js +1 -1
  98. package/src/ast-to-dom.js +16 -7
  99. package/src/ast-to-esm.js +41 -12
  100. package/src/config/inputs.js +1 -0
  101. package/src/config/plots.js +4 -0
  102. package/src/index.js +4 -0
  103. package/src/parse-spec.js +38 -5
  104. package/src/spec/CSSStyles.ts +9 -0
  105. package/src/spec/Data.ts +184 -0
  106. package/src/spec/Expression.ts +31 -0
  107. package/src/spec/HConcat.ts +9 -0
  108. package/src/spec/HSpace.ts +9 -0
  109. package/src/spec/Input.ts +182 -0
  110. package/src/spec/Param.ts +68 -0
  111. package/src/spec/Plot.ts +15 -0
  112. package/src/spec/PlotAttribute.ts +1783 -0
  113. package/src/spec/PlotFrom.ts +23 -0
  114. package/src/spec/PlotInteractor.ts +25 -0
  115. package/src/spec/PlotLegend.ts +70 -0
  116. package/src/spec/PlotMark.ts +51 -0
  117. package/src/spec/PlotTypes.ts +519 -0
  118. package/src/spec/Spec.ts +63 -0
  119. package/src/spec/Transform.ts +394 -0
  120. package/src/spec/VConcat.ts +9 -0
  121. package/src/spec/VSpace.ts +9 -0
  122. package/src/spec/interactors/Highlight.ts +38 -0
  123. package/src/spec/interactors/Interval1D.ts +67 -0
  124. package/src/spec/interactors/Interval2D.ts +48 -0
  125. package/src/spec/interactors/Nearest.ts +28 -0
  126. package/src/spec/interactors/PanZoom.ts +65 -0
  127. package/src/spec/interactors/Toggle.ts +56 -0
  128. package/src/spec/marks/Area.ts +154 -0
  129. package/src/spec/marks/Arrow.ts +108 -0
  130. package/src/spec/marks/Axis.ts +305 -0
  131. package/src/spec/marks/Bar.ts +160 -0
  132. package/src/spec/marks/Cell.ts +62 -0
  133. package/src/spec/marks/Contour.ts +25 -0
  134. package/src/spec/marks/Delaunay.ts +95 -0
  135. package/src/spec/marks/DenseLine.ts +30 -0
  136. package/src/spec/marks/Density.ts +145 -0
  137. package/src/spec/marks/Dot.ts +147 -0
  138. package/src/spec/marks/Frame.ts +23 -0
  139. package/src/spec/marks/Geo.ts +58 -0
  140. package/src/spec/marks/Hexbin.ts +34 -0
  141. package/src/spec/marks/Hexgrid.ts +27 -0
  142. package/src/spec/marks/Image.ts +101 -0
  143. package/src/spec/marks/Line.ts +93 -0
  144. package/src/spec/marks/Link.ts +70 -0
  145. package/src/spec/marks/Marks.ts +1062 -0
  146. package/src/spec/marks/Raster.ts +145 -0
  147. package/src/spec/marks/Rect.ts +183 -0
  148. package/src/spec/marks/Regression.ts +63 -0
  149. package/src/spec/marks/Rule.ts +113 -0
  150. package/src/spec/marks/Text.ts +122 -0
  151. package/src/spec/marks/Tick.ts +69 -0
  152. package/src/spec/marks/Vector.ts +113 -0
  153. package/src/util.js +8 -0
  154. package/tsconfig.json +11 -0
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Abstract base class for Mosaic spec AST nodes.
3
+ */
4
+ export class ASTNode {
5
+ constructor(type: any, children?: any);
6
+ /** @type {string} */
7
+ type: string;
8
+ /** @type {ASTNode[] | null} */
9
+ children: ASTNode[] | null;
10
+ /**
11
+ * Instantiate this AST node to use in a live web application.
12
+ * @param {import('../ast-to-dom.js').InstantiateContext} ctx The instantiation context.
13
+ * @returns {*} The instantiated value of this node.
14
+ */
15
+ instantiate(ctx: import('../ast-to-dom.js').InstantiateContext): any;
16
+ /**
17
+ * Generate ESM code for this AST node.
18
+ * @param {import('../ast-to-esm.js').CodegenContext} ctx The code generator context.
19
+ * @returns {string|void} The generated ESM code for the node.
20
+ */
21
+ codegen(ctx: import('../ast-to-esm.js').CodegenContext): string | void;
22
+ /**
23
+ * @returns {*} This AST node in JSON specification format.
24
+ */
25
+ toJSON(): any;
26
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Parse a data definition spec.
3
+ * @param {string} name The name of the dataset
4
+ * @param {import('../spec/Data.js').DataDefinition} spec The data definition spec.
5
+ * @param {import('../parse-spec.js').ParseContext} ctx The parser context.
6
+ * @returns {DataNode} a parsed data definition AST node
7
+ */
8
+ export function parseData(name: string, spec: import('../spec/Data.js').DataDefinition, ctx: import('../parse-spec.js').ParseContext): DataNode;
9
+ export const TABLE_DATA: "table";
10
+ export const PARQUET_DATA: "parquet";
11
+ export const CSV_DATA: "csv";
12
+ export const JSON_DATA: "json";
13
+ export const SPATIAL_DATA: "spatial";
14
+ export class DataNode extends ASTNode {
15
+ name: any;
16
+ format: any;
17
+ }
18
+ export class QueryDataNode extends DataNode {
19
+ /**
20
+ * Instantiate a table creation query.
21
+ * @param {import('../ast-to-dom.js').InstantiateContext} ctx The instantiation context.
22
+ * @returns {string|void} The instantiated query.
23
+ */
24
+ instantiateQuery(ctx: import('../ast-to-dom.js').InstantiateContext): string | void;
25
+ /**
26
+ * Code generate a table creation query.
27
+ * @param {import('../ast-to-esm.js').CodegenContext} ctx The code generator context.
28
+ * @returns {string|void} The generated query code.
29
+ */
30
+ codegenQuery(ctx: import('../ast-to-esm.js').CodegenContext): string | void;
31
+ }
32
+ export class TableDataNode extends QueryDataNode {
33
+ constructor(name: any, query: any, options: any);
34
+ query: any;
35
+ options: any;
36
+ }
37
+ export class FileDataNode extends QueryDataNode {
38
+ constructor(name: any, format: any, method: any, file: any, options: any);
39
+ file: any;
40
+ method: any;
41
+ options: any;
42
+ }
43
+ export class SpatialDataNode extends FileDataNode {
44
+ constructor(name: any, file: any, options: any);
45
+ }
46
+ export class ParquetDataNode extends FileDataNode {
47
+ constructor(name: any, file: any, options: any);
48
+ }
49
+ export class CSVDataNode extends FileDataNode {
50
+ constructor(name: any, file: any, options: any);
51
+ }
52
+ export class JSONDataNode extends FileDataNode {
53
+ constructor(name: any, file: any, options: any);
54
+ }
55
+ export class LiteralJSONDataNode extends QueryDataNode {
56
+ constructor(name: any, data: any, options: any);
57
+ data: any;
58
+ options: any;
59
+ }
60
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,15 @@
1
+ export function parseExpression(spec: any, ctx: any): ExpressionNode;
2
+ export class ExpressionNode extends ASTNode {
3
+ constructor(value: any, spans: any, params: any, label: any, aggregate: any);
4
+ value: any;
5
+ spans: any;
6
+ params: any;
7
+ label: any;
8
+ aggregate: any;
9
+ instantiate(ctx: any): any;
10
+ codegen(ctx: any): string;
11
+ toJSON(): {
12
+ [x: string]: any;
13
+ };
14
+ }
15
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,10 @@
1
+ export function parseHConcat(spec: any, ctx: any): HConcatNode;
2
+ export class HConcatNode extends ASTNode {
3
+ constructor(children: any);
4
+ instantiate(ctx: any): any;
5
+ codegen(ctx: any): string;
6
+ toJSON(): {
7
+ [x: string]: any[];
8
+ };
9
+ }
10
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,11 @@
1
+ export function parseHSpace(spec: any): HSpaceNode;
2
+ export class HSpaceNode extends ASTNode {
3
+ constructor(value: any);
4
+ value: any;
5
+ instantiate(ctx: any): any;
6
+ codegen(ctx: any): string;
7
+ toJSON(): {
8
+ [x: string]: any;
9
+ };
10
+ }
11
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,8 @@
1
+ export function parseInput(spec: any, ctx: any): InputNode;
2
+ export class InputNode extends ASTNode {
3
+ name: any;
4
+ options: any;
5
+ instantiate(ctx: any): any;
6
+ codegen(ctx: any): string;
7
+ }
8
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,7 @@
1
+ export class LiteralNode extends ASTNode {
2
+ constructor(value: any);
3
+ value: any;
4
+ instantiate(): any;
5
+ codegen(ctx: any): any;
6
+ }
7
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,10 @@
1
+ export function parseOptions(spec: any, ctx: any): OptionsNode;
2
+ export class OptionsNode extends ASTNode {
3
+ constructor(options: any);
4
+ options: any;
5
+ filter(predicate: any): OptionsNode;
6
+ instantiate(ctx: any): {};
7
+ codegen(ctx: any): string;
8
+ toJSON(): {};
9
+ }
10
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,9 @@
1
+ export function parseParam(spec: any, ctx: any): SelectionNode | ParamNode;
2
+ export class ParamNode extends ASTNode {
3
+ value: any;
4
+ date: any;
5
+ instantiate(ctx: any): any;
6
+ codegen(ctx: any): string;
7
+ }
8
+ import { SelectionNode } from './SelectionNode.js';
9
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,8 @@
1
+ export class ParamRefNode extends ASTNode {
2
+ constructor(name: any);
3
+ name: any;
4
+ instantiate(ctx: any): any;
5
+ codegen(): string;
6
+ toJSON(): string;
7
+ }
8
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,18 @@
1
+ export function parseAttribute(key: any, value: any, ctx: any): PlotAttributeNode;
2
+ export class PlotAttributeNode extends ASTNode {
3
+ name: any;
4
+ value: any;
5
+ instantiate(ctx: any): any;
6
+ codegen(ctx: any): string;
7
+ toJSON(): {
8
+ [x: number]: any;
9
+ };
10
+ }
11
+ export class PlotFixedNode extends ASTNode {
12
+ constructor();
13
+ value: string;
14
+ instantiate(ctx: any): any;
15
+ codegen(ctx: any): string;
16
+ toJSON(): string;
17
+ }
18
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,9 @@
1
+ export function parseMarkData(spec: any, ctx: any): LiteralNode | PlotFromNode;
2
+ export class PlotFromNode extends ASTNode {
3
+ table: any;
4
+ options: any;
5
+ instantiate(ctx: any): any;
6
+ codegen(ctx: any): string;
7
+ }
8
+ import { LiteralNode } from './LiteralNode.js';
9
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,8 @@
1
+ export function parseInteractor(spec: any, ctx: any): PlotInteractorNode;
2
+ export class PlotInteractorNode extends ASTNode {
3
+ name: any;
4
+ options: any;
5
+ instantiate(ctx: any): any;
6
+ codegen(ctx: any): string;
7
+ }
8
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,10 @@
1
+ export function parseLegend(spec: any, ctx: any): PlotLegendNode;
2
+ export class PlotLegendNode extends ASTNode {
3
+ constructor(key: any, name: any, options: any);
4
+ key: any;
5
+ name: any;
6
+ options: any;
7
+ instantiate(ctx: any): any;
8
+ codegen(ctx: any): string;
9
+ }
10
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,10 @@
1
+ export function parseMark(spec: any, ctx: any): PlotMarkNode;
2
+ export class PlotMarkNode extends ASTNode {
3
+ constructor(name: any, data: any, options: any);
4
+ name: any;
5
+ data: any;
6
+ options: any;
7
+ instantiate(ctx: any): any;
8
+ codegen(ctx: any): string;
9
+ }
10
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,11 @@
1
+ export function parseTopLevelMark(spec: any, ctx: any): PlotNode;
2
+ export function parsePlot(spec: any, ctx: any): PlotNode;
3
+ export class PlotNode extends ASTNode {
4
+ attributes: any;
5
+ instantiate(ctx: any): any;
6
+ codegen(ctx: any): string;
7
+ toJSON(): {
8
+ [x: string]: any[];
9
+ };
10
+ }
11
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,12 @@
1
+ export class SelectionNode extends ASTNode {
2
+ constructor(select: string, cross: any);
3
+ select: string;
4
+ cross: any;
5
+ instantiate(ctx: any): any;
6
+ codegen(ctx: any): string;
7
+ toJSON(): {
8
+ select: string;
9
+ cross: any;
10
+ };
11
+ }
12
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,10 @@
1
+ export class SpecNode extends ASTNode {
2
+ constructor(root: any, meta: any, config: any, data: any, params: any, plotDefaults: any);
3
+ root: any;
4
+ meta: any;
5
+ config: any;
6
+ data: any;
7
+ params: any;
8
+ plotDefaults: any;
9
+ }
10
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,13 @@
1
+ export function parseTransform(spec: any, ctx: any): TransformNode;
2
+ export class TransformNode extends ASTNode {
3
+ constructor(name: any, args: any, options: any);
4
+ name: any;
5
+ args: any;
6
+ options: any;
7
+ instantiate(ctx: any): any;
8
+ codegen(ctx: any): string;
9
+ toJSON(): {
10
+ [x: number]: any;
11
+ };
12
+ }
13
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,10 @@
1
+ export function parseVConcat(spec: any, ctx: any): VConcatNode;
2
+ export class VConcatNode extends ASTNode {
3
+ constructor(children: any);
4
+ instantiate(ctx: any): any;
5
+ codegen(ctx: any): string;
6
+ toJSON(): {
7
+ [x: string]: any[];
8
+ };
9
+ }
10
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,11 @@
1
+ export function parseVSpace(spec: any): VSpaceNode;
2
+ export class VSpaceNode extends ASTNode {
3
+ constructor(value: any);
4
+ value: any;
5
+ instantiate(ctx: any): any;
6
+ codegen(ctx: any): string;
7
+ toJSON(): {
8
+ [x: string]: any;
9
+ };
10
+ }
11
+ import { ASTNode } from './ASTNode.js';
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Generate a running web application (DOM content) for a Mosaic spec AST.
3
+ * @param {SpecNode} ast Mosaic AST root node.
4
+ * @param {object} [options] Instantiation options.
5
+ * @param {string} [options.baseURL] The base URL for loading data files.
6
+ * @param {any[]} [options.plotDefaults] Array of default plot attributes.
7
+ * @param {Map<string, Param>} [options.params] A map of predefined Params/Selections.
8
+ * @returns {Promise<{
9
+ * element: HTMLElement | SVGSVGElement;
10
+ * params: Map<string, Param | Selection>;
11
+ * }>} A Promise to an object with the resulting
12
+ * DOM element, and a map of named parameters (Param and Selection instances).
13
+ */
14
+ export function astToDOM(ast: SpecNode, options?: {
15
+ baseURL?: string;
16
+ plotDefaults?: any[];
17
+ params?: Map<string, Param>;
18
+ }): Promise<{
19
+ element: HTMLElement | SVGSVGElement;
20
+ params: Map<string, Param | Selection>;
21
+ }>;
22
+ export class InstantiateContext {
23
+ constructor({ api, plotDefaults, params, baseURL }?: {
24
+ api?: any;
25
+ plotDefaults?: any[];
26
+ params?: Map<any, any>;
27
+ baseURL?: any;
28
+ });
29
+ api: any;
30
+ plotDefaults: any[];
31
+ activeParams: Map<any, any>;
32
+ baseURL: any;
33
+ coordinator: any;
34
+ error(message: any, data: any): void;
35
+ }
36
+ import { SpecNode } from './ast/SpecNode.js';
37
+ import { Param } from '@uwdata/mosaic-core';
38
+ import { Selection } from '@uwdata/mosaic-core';
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Generate ESM code for a Mosaic spec AST.
3
+ * @param {SpecNode} ast Mosaic AST root node.
4
+ * @param {object} [options] Code generation options.
5
+ * @param {string} [options.baseURL] The base URL for loading data files.
6
+ * @param {string} [options.connector] A database connector to initialize.
7
+ * Valid values are 'wasm', 'socket', and 'rest'.
8
+ * If undefined, no connector code is generated.
9
+ * @param {string} [options.namespace='vg'] The vgplot API namespace object.
10
+ * @param {number} [options.depth=0] The starting indentation depth.
11
+ * @param {Map<string,string|string[]>} [options.imports] A Map of ESM
12
+ * imports to include in generated code. Keys are packages (e.g.,
13
+ * '@uwdata/vgplot') and values indicate what to import (e.g., '* as vg').
14
+ * @param {string|string[]} [options.preamble] Code to include after imports.
15
+ * @returns {string} Generated ESM code using the vgplot API.
16
+ */
17
+ export function astToESM(ast: SpecNode, options?: {
18
+ baseURL?: string;
19
+ connector?: string;
20
+ namespace?: string;
21
+ depth?: number;
22
+ imports?: Map<string, string | string[]>;
23
+ preamble?: string | string[];
24
+ }): string;
25
+ export class CodegenContext {
26
+ /**
27
+ * Create a new code generator context.
28
+ * @param {object} [options] Code generation options.
29
+ * @param {*} [options.plotDefaults] Default attributes to apply to all plots.
30
+ * @param {string} [options.baseURL] The base URL for loading data files.
31
+ * @param {string} [options.connector] A database connector to initialize.
32
+ * Valid values are 'wasm', 'socket', and 'rest'.
33
+ * If undefined, no connector code is generated.
34
+ * @param {string} [options.namespace='vg'] The vgplot API namespace object.
35
+ * @param {number} [options.depth=0] The starting indentation depth.
36
+ * @param {Map<string,string|string[]>} [options.imports] A Map of ESM
37
+ * imports to include in generated code. Keys are packages (e.g.,
38
+ * '@uwdata/vgplot') and values indicate what to import (e.g., '* as vg').
39
+ */
40
+ constructor({ plotDefaults, namespace, connector, imports, baseURL, depth }?: {
41
+ plotDefaults?: any;
42
+ baseURL?: string;
43
+ connector?: string;
44
+ namespace?: string;
45
+ depth?: number;
46
+ imports?: Map<string, string | string[]>;
47
+ });
48
+ plotDefaults: any;
49
+ namespace: string;
50
+ connector: string;
51
+ imports: Map<string, string | string[]>;
52
+ baseURL: string;
53
+ depth: number;
54
+ addImport(pkg: any, method: any): void;
55
+ setImports(pkg: any, all: any): void;
56
+ ns(): string;
57
+ indent(): void;
58
+ undent(): void;
59
+ tab(): string;
60
+ stringify(value: any): any;
61
+ maybeLineWrap(spans: any): any;
62
+ error(message: any, data: any): void;
63
+ }
64
+ import { SpecNode } from './ast/SpecNode.js';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Map of specification keys to component parsers.
3
+ */
4
+ export function componentMap(overrides?: any[]): Map<any, any>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Construct a set of database extensions to load.
3
+ * Automatically adds the spatial extension if a
4
+ * dataset with format "spatial" is loaded.
5
+ * @param {SpecNode} ast Mosaic AST root node.
6
+ * @returns {Set<string>} A set of extension names.
7
+ */
8
+ export function resolveExtensions(ast: SpecNode): Set<string>;
9
+ import { SpecNode } from '../ast/SpecNode.js';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Set of input widget type names.
3
+ * @returns {Set<string>}
4
+ */
5
+ export function inputNames(overrides?: any[]): Set<string>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Generate an object of lookup maps for vgplot components.
3
+ */
4
+ export function plotNames({ attributes, interactors, legends, marks }?: {
5
+ attributes?: Set<string>;
6
+ interactors?: Set<string>;
7
+ legends?: Set<string>;
8
+ marks?: Set<string>;
9
+ }): {
10
+ attributes: Set<string>;
11
+ interactors: Set<string>;
12
+ legends: Set<string>;
13
+ marks: Set<string>;
14
+ };
15
+ /**
16
+ * Names of attribute directive functions.
17
+ * @returns {Set<string>}
18
+ */
19
+ export function plotAttributeNames(overrides?: any[]): Set<string>;
20
+ /**
21
+ * Names interactor directive functions.
22
+ * @returns {Set<string>}
23
+ */
24
+ export function plotInteractorNames(overrides?: any[]): Set<string>;
25
+ /**
26
+ * Names of legend directive functions.
27
+ * @returns {Set<string>}
28
+ */
29
+ export function plotLegendNames(overrides?: any[]): Set<string>;
30
+ /**
31
+ * Names of mark directive functions.
32
+ * @returns {Set<string>}
33
+ */
34
+ export function plotMarkNames(overrides?: any[]): Set<string>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Valid transform method names.
3
+ */
4
+ export function transformNames(overrides?: any[]): Set<any>;
@@ -0,0 +1,30 @@
1
+ export const SPEC: "spec";
2
+ export const LITERAL: "literal";
3
+ export const DATAREF: "dataref";
4
+ export const OPTIONS: "options";
5
+ export const SELECTION: "selection";
6
+ export const PARAMREF: "paramref";
7
+ export const PARAM: "param";
8
+ export const SELECT: "select";
9
+ export const VALUE: "value";
10
+ export const CROSSFILTER: "crossfilter";
11
+ export const INTERSECT: "intersect";
12
+ export const UNION: "union";
13
+ export const SINGLE: "single";
14
+ export const DATA: "data";
15
+ export const EXPRESSION: "expression";
16
+ export const SQL: "sql";
17
+ export const AGG: "agg";
18
+ export const INPUT: "input";
19
+ export const HCONCAT: "hconcat";
20
+ export const VCONCAT: "vconcat";
21
+ export const HSPACE: "hspace";
22
+ export const VSPACE: "vspace";
23
+ export const MARK: "mark";
24
+ export const FROM: "from";
25
+ export const PLOT: "plot";
26
+ export const LEGEND: "legend";
27
+ export const ATTRIBUTE: "attribute";
28
+ export const TRANSFORM: "transform";
29
+ export const INTERACTOR: "interactor";
30
+ export const FIXED: "Fixed";
@@ -0,0 +1,29 @@
1
+ export { parseSpec } from "./parse-spec.js";
2
+ export * from "./constants.js";
3
+ export { ASTNode } from "./ast/ASTNode.js";
4
+ export { ExpressionNode } from "./ast/ExpressionNode.js";
5
+ export { HConcatNode } from "./ast/HConcatNode.js";
6
+ export { HSpaceNode } from "./ast/HSpaceNode.js";
7
+ export { InputNode } from "./ast/InputNode.js";
8
+ export { LiteralNode } from "./ast/LiteralNode.js";
9
+ export { OptionsNode } from "./ast/OptionsNode.js";
10
+ export { ParamNode } from "./ast/ParamNode.js";
11
+ export { ParamRefNode } from "./ast/ParamRefNode.js";
12
+ export { PlotFromNode } from "./ast/PlotFromNode.js";
13
+ export { PlotInteractorNode } from "./ast/PlotInteractorNode.js";
14
+ export { PlotLegendNode } from "./ast/PlotLegendNode.js";
15
+ export { PlotMarkNode } from "./ast/PlotMarkNode.js";
16
+ export { PlotNode } from "./ast/PlotNode.js";
17
+ export { SelectionNode } from "./ast/SelectionNode.js";
18
+ export { SpecNode } from "./ast/SpecNode.js";
19
+ export { TransformNode } from "./ast/TransformNode.js";
20
+ export { VConcatNode } from "./ast/VConcatNode.js";
21
+ export { VSpaceNode } from "./ast/VSpaceNode.js";
22
+ /**
23
+ * A Mosaic declarative specification.
24
+ */
25
+ export type Spec = import('./spec/Spec.js').Spec;
26
+ export { astToDOM, InstantiateContext } from "./ast-to-dom.js";
27
+ export { astToESM, CodegenContext } from "./ast-to-esm.js";
28
+ export { DataNode, QueryDataNode, TableDataNode, FileDataNode, CSVDataNode, JSONDataNode, ParquetDataNode, SpatialDataNode, LiteralJSONDataNode } from "./ast/DataNode.js";
29
+ export { PlotAttributeNode, PlotFixedNode } from "./ast/PlotAttributeNode.js";
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @typedef {{
3
+ * attributes: Set<string>;
4
+ * interactors: Set<string>;
5
+ * legends: Set<string>;
6
+ * marks: Set<string>;
7
+ * }} PlotNames names for supported plot elements
8
+ */
9
+ /**
10
+ * Parse a Mosaic specification to an AST (abstract syntax tree).
11
+ * @param {import('./spec/Spec.js').Spec} spec The input specification.
12
+ * @param {object} [options] Optional parse options object.
13
+ * @param {Map<string, Function>} [options.components] Map of component names to parse functions.
14
+ * @param {Set<string>} [options.transforms] The names of allowed transform functions.
15
+ * @param {Set<string>} [options.inputs] The names of supported input widgets.
16
+ * @param {PlotNames} [options.plot] The names of supported plot elements.
17
+ * @param {any[]} [options.params] An array of [name, node] pairs of pre-parsed
18
+ * Param or Selection AST nodes.
19
+ * @param {any[]} [options.datasets] An array of [name, node] pairs of pre-parsed
20
+ * dataset definition AST nodes.
21
+ * @returns {SpecNode} The top-level AST spec node.
22
+ */
23
+ export function parseSpec(spec: import('./spec/Spec.js').Spec, options?: {
24
+ components?: Map<string, Function>;
25
+ transforms?: Set<string>;
26
+ inputs?: Set<string>;
27
+ plot?: PlotNames;
28
+ params?: any[];
29
+ datasets?: any[];
30
+ }): SpecNode;
31
+ export class ParseContext {
32
+ /**
33
+ * Create a new parser context.
34
+ * @param {object} [options]
35
+ * @param {Map<string, Function>} [options.components] Map of component names to parse functions.
36
+ * @param {Set<string>} [options.transforms] The names of allowed transform functions.
37
+ * @param {Set<string>} [options.inputs] The names of supported input widgets.
38
+ * @param {PlotNames} [options.plot] The names of supported plot elements.
39
+ * @param {any[]} [options.params] An array of [name, node] pairs of pre-parsed
40
+ * Param or Selection AST nodes.
41
+ * @param {any[]} [options.datasets] An array of [name, node] pairs of pre-parsed
42
+ * dataset definition AST nodes.
43
+ */
44
+ constructor({ components, transforms, inputs, plot, params, datasets }?: {
45
+ components?: Map<string, Function>;
46
+ transforms?: Set<string>;
47
+ inputs?: Set<string>;
48
+ plot?: PlotNames;
49
+ params?: any[];
50
+ datasets?: any[];
51
+ });
52
+ components: Map<string, Function>;
53
+ transforms: Set<string>;
54
+ inputs: Set<string>;
55
+ plot: PlotNames;
56
+ params: Map<any, any>;
57
+ datasets: Map<any, any>;
58
+ parse(spec: any): SpecNode;
59
+ plotDefaults: import("./ast/PlotAttributeNode.js").PlotAttributeNode[];
60
+ parseComponent(spec: any): any;
61
+ /**
62
+ * Test if a value is param reference, if so, generate a paramter definition
63
+ * as needed and return a new ParamRefNode. Otherwise, return a LiteralNode.
64
+ * @param {*} value The value to test.
65
+ * @param {() => ParamNode | SelectionNode} [makeNode] A Param of Selection AST
66
+ * node constructor.
67
+ * @returns {ParamRefNode|LiteralNode} An AST node for the input value.
68
+ */
69
+ maybeParam(value: any, makeNode?: () => ParamNode | SelectionNode): ParamRefNode | LiteralNode;
70
+ maybeSelection(value: any): LiteralNode | ParamRefNode;
71
+ error(message: any, data: any): void;
72
+ }
73
+ /**
74
+ * names for supported plot elements
75
+ */
76
+ export type PlotNames = {
77
+ attributes: Set<string>;
78
+ interactors: Set<string>;
79
+ legends: Set<string>;
80
+ marks: Set<string>;
81
+ };
82
+ import { SpecNode } from './ast/SpecNode.js';
83
+ import { ParamNode } from './ast/ParamNode.js';
84
+ import { SelectionNode } from './ast/SelectionNode.js';
85
+ import { ParamRefNode } from './ast/ParamRefNode.js';
86
+ import { LiteralNode } from './ast/LiteralNode.js';
@@ -0,0 +1,3 @@
1
+ type OmittedProperties = 'parentRule' | 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty';
2
+ export type CSSStyles = Partial<Omit<CSSStyleDeclaration, OmittedProperties>>;
3
+ export {};