From 7ea04f0bf171c483837202ba51b589a72237bfe7 Mon Sep 17 00:00:00 2001 From: Ron Pechuk Date: Wed, 12 Feb 2025 15:36:52 -0800 Subject: [PATCH] fix: Change core type export to index-types.ts pattern --- packages/core/package.json | 2 +- packages/core/src/index-types.ts | 2 ++ packages/core/src/index.js | 15 --------------- packages/core/src/types.ts | 5 ++++- packages/inputs/src/Menu.js | 5 +---- packages/inputs/src/Search.js | 5 +---- packages/inputs/src/Slider.js | 5 +---- packages/inputs/src/Table.js | 5 +---- packages/plot/src/interactors/Highlight.js | 5 +---- packages/plot/src/interactors/Interval1D.js | 5 +---- packages/plot/src/interactors/Interval2D.js | 5 +---- packages/plot/src/interactors/Nearest.js | 5 +---- packages/plot/src/interactors/PanZoom.js | 5 +---- packages/plot/src/interactors/Region.js | 5 +---- packages/plot/src/interactors/Toggle.js | 5 +---- 15 files changed, 18 insertions(+), 61 deletions(-) create mode 100644 packages/core/src/index-types.ts diff --git a/packages/core/package.json b/packages/core/package.json index d70dc874..4090c750 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -16,7 +16,7 @@ "module": "src/index.js", "jsdelivr": "dist/mosaic-core.min.js", "unpkg": "dist/mosaic-core.min.js", - "types": "dist/types/index.d.ts", + "types": "dist/types/index-types.d.ts", "repository": { "type": "git", "url": "https://github.com/uwdata/mosaic.git" diff --git a/packages/core/src/index-types.ts b/packages/core/src/index-types.ts new file mode 100644 index 00000000..fd48ba7e --- /dev/null +++ b/packages/core/src/index-types.ts @@ -0,0 +1,2 @@ +export * from './index.js'; +export * from './types.js'; diff --git a/packages/core/src/index.js b/packages/core/src/index.js index 94ad4506..3a075e89 100644 --- a/packages/core/src/index.js +++ b/packages/core/src/index.js @@ -25,18 +25,3 @@ export { toDataColumns } from './util/to-data-columns.js'; export { queryFieldInfo } from './util/field-info.js'; export { jsType } from './util/js-type.js'; export { isActivatable } from './util/is-activatable.js'; - -/** - * @typedef {import('./util/selection-types.js').ClauseMetadata} ClauseMetadata - * @typedef {import('./util/selection-types.js').PointMetadata} PointMetadata - * @typedef {import('./util/selection-types.js').MatchMethod} MatchMethod - * @typedef {import('./util/selection-types.js').MatchMetadata} MatchMetadata - * @typedef {import('./util/selection-types.js').ScaleType} ScaleType - * @typedef {import('./util/selection-types.js').Extent} Extent - * @typedef {import('./util/selection-types.js').Scale} Scale - * @typedef {import('./util/selection-types.js').BinMethod} BinMethod - * @typedef {import('./util/selection-types.js').IntervalMetadata} IntervalMetadata - * @typedef {import('./util/selection-types.js').SelectionClause} SelectionClause - * - * @typedef {import('./Activatable.js').Activatable} Activatable - */ diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 13832895..f146cdb3 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -1,5 +1,8 @@ import type { DescribeQuery, ExprNode, Query } from '@uwdata/mosaic-sql'; +export * from './util/selection-types.js'; +export * from './Activatable.js'; + /** Query type accepted by a coordinator. */ export type QueryType = | string @@ -51,4 +54,4 @@ export interface ColumnDescription { column_name: string, column_type: string, null: 'YES' | 'NO' -} +} \ No newline at end of file diff --git a/packages/inputs/src/Menu.js b/packages/inputs/src/Menu.js index a030ce8b..e9a40d64 100644 --- a/packages/inputs/src/Menu.js +++ b/packages/inputs/src/Menu.js @@ -2,10 +2,6 @@ import { MosaicClient, Param, isParam, isSelection, clausePoint } from '@uwdata/ import { Query } from '@uwdata/mosaic-sql'; import { input } from './input.js'; -/** - * @typedef {import('@uwdata/mosaic-core').Activatable} Activatable - */ - const isObject = v => { return v && typeof v === 'object' && !Array.isArray(v); }; @@ -15,6 +11,7 @@ export const menu = options => input(Menu, options); /** * A HTML select based dropdown menu input. * + * @import {Activatable} from '@uwdata/mosaic-core' * @implements {Activatable} */ export class Menu extends MosaicClient { diff --git a/packages/inputs/src/Search.js b/packages/inputs/src/Search.js index 91953aa2..c24bbd5c 100644 --- a/packages/inputs/src/Search.js +++ b/packages/inputs/src/Search.js @@ -2,10 +2,6 @@ import { MosaicClient, Param, isParam, isSelection, clauseMatch } from '@uwdata/ import { Query } from '@uwdata/mosaic-sql'; import { input } from './input.js'; -/** - * @typedef {import('@uwdata/mosaic-core').Activatable} Activatable - */ - let _id = 0; export const search = options => input(Search, options); @@ -13,6 +9,7 @@ export const search = options => input(Search, options); /** * A HTML input based text search input. * + * @import {Activatable} from '@uwdata/mosaic-core' * @implements {Activatable} */ export class Search extends MosaicClient { diff --git a/packages/inputs/src/Slider.js b/packages/inputs/src/Slider.js index a9bcc818..9e827de3 100644 --- a/packages/inputs/src/Slider.js +++ b/packages/inputs/src/Slider.js @@ -2,10 +2,6 @@ import { MosaicClient, Param, clauseInterval, clausePoint, isParam, isSelection import { Query, max, min } from '@uwdata/mosaic-sql'; import { input } from './input.js'; -/** - * @typedef {import('@uwdata/mosaic-core').Activatable} Activatable - */ - let _id = 0; export const slider = options => input(Slider, options); @@ -13,6 +9,7 @@ export const slider = options => input(Slider, options); /** * A HTML range based slider input. * + * @import {Activatable} from '@uwdata/mosaic-core' * @implements {Activatable} */ export class Slider extends MosaicClient { diff --git a/packages/inputs/src/Table.js b/packages/inputs/src/Table.js index 1a28fd3a..4fe0a34b 100644 --- a/packages/inputs/src/Table.js +++ b/packages/inputs/src/Table.js @@ -3,10 +3,6 @@ import { Query, desc } from '@uwdata/mosaic-sql'; import { formatDate, formatLocaleAuto, formatLocaleNumber } from './util/format.js'; import { input } from './input.js'; -/** - * @typedef {import('@uwdata/mosaic-core').Activatable} Activatable - */ - let _id = -1; export const table = options => input(Table, options); @@ -15,6 +11,7 @@ export const table = options => input(Table, options); /** * A HTML table based table component. * + * @import {Activatable} from '@uwdata/mosaic-core' * @implements {Activatable} */ export class Table extends MosaicClient { diff --git a/packages/plot/src/interactors/Highlight.js b/packages/plot/src/interactors/Highlight.js index 6b805bd7..a2de0a28 100644 --- a/packages/plot/src/interactors/Highlight.js +++ b/packages/plot/src/interactors/Highlight.js @@ -3,10 +3,6 @@ import { and, isAggregateExpression } from '@uwdata/mosaic-sql'; import { getDatum } from './util/get-datum.js'; import { sanitizeStyles } from './util/sanitize-styles.js'; -/** - * @typedef {import('@uwdata/mosaic-core').Activatable} Activatable - */ - function configureMark(mark) { const { channels } = mark; const dims = new Set; @@ -39,6 +35,7 @@ function configureMark(mark) { } /** + * @import {Activatable} from '@uwdata/mosaic-core' * @implements {Activatable} */ export class Highlight { diff --git a/packages/plot/src/interactors/Interval1D.js b/packages/plot/src/interactors/Interval1D.js index bc6fe556..50825feb 100644 --- a/packages/plot/src/interactors/Interval1D.js +++ b/packages/plot/src/interactors/Interval1D.js @@ -7,10 +7,7 @@ import { invert } from './util/invert.js'; import { sanitizeStyles } from './util/sanitize-styles.js'; /** - * @typedef {import('@uwdata/mosaic-core').Activatable} Activatable - */ - -/** + * @import {Activatable} from '@uwdata/mosaic-core' * @implements {Activatable} */ export class Interval1D { diff --git a/packages/plot/src/interactors/Interval2D.js b/packages/plot/src/interactors/Interval2D.js index 82fc12cd..3b6a630e 100644 --- a/packages/plot/src/interactors/Interval2D.js +++ b/packages/plot/src/interactors/Interval2D.js @@ -7,10 +7,7 @@ import { invert } from './util/invert.js'; import { sanitizeStyles } from './util/sanitize-styles.js'; /** - * @typedef {import('@uwdata/mosaic-core').Activatable} Activatable - */ - -/** + * @import {Activatable} from '@uwdata/mosaic-core' * @implements {Activatable} */ export class Interval2D { diff --git a/packages/plot/src/interactors/Nearest.js b/packages/plot/src/interactors/Nearest.js index 021a71bd..fe6fcceb 100644 --- a/packages/plot/src/interactors/Nearest.js +++ b/packages/plot/src/interactors/Nearest.js @@ -3,10 +3,7 @@ import { select, pointer, min } from 'd3'; import { getField } from './util/get-field.js'; /** - * @typedef {import('@uwdata/mosaic-core').Activatable} Activatable - */ - -/** + * @import {Activatable} from '@uwdata/mosaic-core' * @implements {Activatable} */ export class Nearest { diff --git a/packages/plot/src/interactors/PanZoom.js b/packages/plot/src/interactors/PanZoom.js index ed25dc40..d83f147e 100644 --- a/packages/plot/src/interactors/PanZoom.js +++ b/packages/plot/src/interactors/PanZoom.js @@ -2,13 +2,10 @@ import { Selection, clauseInterval } from '@uwdata/mosaic-core'; import { select, zoom, ZoomTransform } from 'd3'; import { getField } from './util/get-field.js'; -/** - * @typedef {import('@uwdata/mosaic-core').Activatable} Activatable - */ - const asc = (a, b) => a - b; /** + * @import {Activatable} from '@uwdata/mosaic-core' * @implements {Activatable} */ export class PanZoom { diff --git a/packages/plot/src/interactors/Region.js b/packages/plot/src/interactors/Region.js index dfcdbcde..8a616682 100644 --- a/packages/plot/src/interactors/Region.js +++ b/packages/plot/src/interactors/Region.js @@ -9,10 +9,7 @@ import { neqSome } from './util/neq.js'; import { getDatum } from './util/get-datum.js'; /** - * @typedef {import('@uwdata/mosaic-core').Activatable} Activatable - */ - -/** + * @import {Activatable} from '@uwdata/mosaic-core' * @implements {Activatable} */ export class Region { diff --git a/packages/plot/src/interactors/Toggle.js b/packages/plot/src/interactors/Toggle.js index 0932baaf..0f8d60bd 100644 --- a/packages/plot/src/interactors/Toggle.js +++ b/packages/plot/src/interactors/Toggle.js @@ -3,10 +3,7 @@ import { getDatum } from './util/get-datum.js'; import { neq, neqSome } from './util/neq.js'; /** - * @typedef {import('@uwdata/mosaic-core').Activatable} Activatable - */ - -/** + * @import {Activatable} from '@uwdata/mosaic-core' * @implements {Activatable} */ export class Toggle {