Skip to content

Commit

Permalink
fix: add better typing to ast-to-dom and InstantiateContext constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
rpechuk committed Feb 21, 2025
1 parent 22c2c77 commit 529c325
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/spec/src/ast-to-dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import { error } from './util.js';
/**
* Generate a running web application (DOM content) for a Mosaic spec AST.
* @param {SpecNode} ast Mosaic AST root node.
* @param {object} [options] Instantiation options.
* @param {string} [options.baseURL] The base URL for loading data files.
* @param {any[]} [options.plotDefaults] Array of default plot attributes.
* @param {Map<string, Param>} [options.params] A map of predefined Params/Selections.
* @param {ConstructorParameters<typeof InstantiateContext>[0]} [options] Instantiation options.
* @returns {Promise<{
* element: HTMLElement | SVGSVGElement;
* params: Map<string, Param | Selection>;
Expand Down Expand Up @@ -54,6 +51,14 @@ export async function astToDOM(ast, options) {
}

export class InstantiateContext {
/**
* Create a new InstantiateContext instance.
* @param {object} options Optional instantiation options.
* @param {string} [options.baseURL] The base URL for loading data files.
* @param {any[]} [options.plotDefaults] Array of default plot attributes.
* @param {Map<string, Param>} [options.params] A map of predefined Params/Selections.
* @param {ReturnType<typeof createAPIContext>} [options.api] The context to be used for vgplot API methods.
*/
constructor({
api = createAPIContext(),
plotDefaults = [],
Expand Down

0 comments on commit 529c325

Please sign in to comment.