8000 feat: expose the compiler function (#1116) · gosling-lang/gosling.js@34beae8 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 34beae8

Browse files
authored
feat: expose the compiler function (#1116)
* feat: expose the compiler function * chore: add a default templates to compiler param
1 parent d941f27 commit 34beae8

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/compiler/compile.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import type { GoslingSpec, TemplateTrackDef, VisUnitApiData } from '@gosling-lang/gosling-schema';
22
import type { HiGlassSpec } from '@gosling-lang/higlass-schema';
33
import { traverseToFixSpecDownstream } from './spec-preprocess';
4-
import { replaceTrackTemplates } from '../core/utils/template';
4+
import { GoslingTemplates, replaceTrackTemplates } from '../core/utils/template';
55
import { getRelativeTrackInfo, type Size } from './bounding-box';
66
import type { CompleteThemeDeep } from '../core/utils/theme';
77
import type { UrlToFetchOptions } from 'src/core/gosling-component';
88
import { renderHiGlass as createHiGlassModels } from './create-higlass-models';
99
import { manageResponsiveSpecs } from './responsive';
1010
import type { IdTable } from '../api/track-and-view-ids';
11+
import { getTheme } from '@gosling-lang/gosling-theme';
1112

1213
/** The callback function called everytime after the spec has been compiled */
1314
export type CompileCallback = (
@@ -18,15 +19,18 @@ export type CompileCallback = (
1819
idTable: IdTable
1920
) => void;
2021

22+
/**
23+
* Process the Gosling specification, including normalization and filling in defaults.
24+
*/
2125
export function compile(
2226
spec: GoslingSpec,
2327
callback: CompileCallback,
24-
templates: TemplateTrackDef[],
25-
theme: Required<CompleteThemeDeep>,
28+
templates: TemplateTrackDef[] = GoslingTemplates,
29+
theme: Required<CompleteThemeDeep> = getTheme('light'),
2630
containerStatus: {
2731
containerSize?: { width: number; height: number };
2832
containerParentSize?: { width: number; height: number };
29-
},
33+
} = {},
3034
urlToFetchOptions?: UrlToFetchOptions
3135
) {
3236
// Make sure to keep the original spec as-is

src/exported-utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ export { sanitizeChrName } from './data-fetchers/utils';
1010
// These are experimental and may be removed in the future
1111
export { convertToFlatTracks as _convertToFlatTracks } from './compiler/spec-preprocess';
1212
export { spreadTracksByData as _spreadTracksByData } from './core/utils/overlay';
13+
export { compile as _compile } from './compiler/compile';

0 commit comments

Comments
 (0)
0