Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add improved TypeScript support. #355

Merged
merged 26 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ee72568
chore: Update TypeScript, add some jsdoc typings, address TS errors.
jheer Apr 1, 2024
ce98e35
feat: Add initial TS types for JSON specs.
jheer Apr 1, 2024
02256d4
test: Add TypeScript spec tests.
jheer Apr 1, 2024
4d6afe3
feat: Incremental progress on JSON specification types.
jheer Apr 2, 2024
f4645bc
docs: add types for setPlot and plot attributes (#353)
domoritz Apr 2, 2024
278991c
Use jsconfig and fix types
domoritz Apr 2, 2024
1ed053d
Enable checks for spec js
domoritz Apr 2, 2024
955db5b
Fix type errors with ASTNode
domoritz Apr 2, 2024
1fb10d8
Disable js tests in spec package
domoritz Apr 2, 2024
a546021
fix: Remove invalid plot attribute.
jheer Apr 3, 2024
1c8a9e2
feat: Publish types from mosaic-spec.
jheer Apr 3, 2024
bbd54f8
feat: Add spec interactor typings.
jheer Apr 3, 2024
93ed3c6
feat: Document spec transform types.
jheer Apr 3, 2024
f94eb5f
feat: Document more spec typings.
jheer Apr 3, 2024
875bae2
feat: Types and documentation for plot attributes.
jheer Apr 4, 2024
a10aace
Merge branch 'jh/spec-types' of github.com:uwdata/mosaic into jh/spec…
jheer Apr 4, 2024
b2670eb
feat: Initial progress towards spec mark types.
jheer Apr 4, 2024
f20b208
feat: Add Area and Line mark types.
jheer Apr 4, 2024
decc112
feat: Add more mark typings.
jheer Apr 5, 2024
8c5f77c
feat: Add vector and hexgrid mark typings.
jheer Apr 5, 2024
f21548c
feat: Add geo mark typings.
jheer Apr 5, 2024
0de518d
feat: Add delaunay mark types.
jheer Apr 5, 2024
71b3fd3
feat: Add arrow and link mark types.
jheer Apr 5, 2024
8459980
chore: Add missing outer mark doc comments.
jheer Apr 5, 2024
fd10c13
feat: Add spec types for image, raster, regression.
jheer Apr 5, 2024
e4015ac
feat: Finish spec typings.
jheer Apr 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- name: Build
run: npm run docs:build

- uses: actions/configure-pages@v4
- uses: actions/configure-pages@v5
- uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist
Expand Down
13 changes: 13 additions & 0 deletions bin/prepare-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ import { parse } from 'yaml';
const specDir = join('specs', 'yaml');
const esmTestDir = join('specs', 'esm');
const jsonTestDir = join('specs', 'json');
const tsTestDir = join('specs', 'ts');

const docsDir = 'docs';
const yamlDocsDir = join(docsDir, 'public', 'specs', 'yaml');
const jsonDocsDir = join(docsDir, 'public', 'specs', 'json');
const esmDocsDir = join(docsDir, 'public', 'specs', 'esm');
const exampleDir = join(docsDir, 'examples');

const specToTS = spec => {
return `import { Spec } from '@uwdata/mosaic-spec';

export const spec : Spec = ${JSON.stringify(spec, 0, 2)};
`;
}

const files = await Promise.allSettled((await readdir(specDir))
.filter(name => extname(name) === '.yaml')
.map(async name => {
Expand All @@ -43,6 +51,11 @@ const files = await Promise.allSettled((await readdir(specDir))
resolve(jsonTestDir, `${base}.json`),
JSON.stringify(ast.toJSON(), 0, 2)
),
// write TS JSON spec to tests
writeFile(
resolve(tsTestDir, `${base}.ts`),
specToTS(spec)
),
// copy YAML file to docs
copyFile(file, resolve(yamlDocsDir, `${base}.yaml`)),
// write JSON spec to docs
Expand Down
2 changes: 1 addition & 1 deletion docs/public/specs/esm/axes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as vg from "@uwdata/vgplot";

export default vg.plot(
vg.gridY({strokeDasharray: [0.75, 2], strokeOpacity: 1}),
vg.gridY({strokeDasharray: "0.75 2", strokeOpacity: 1}),
vg.axisY({anchor: "left", tickSize: 0, dx: 38, dy: -4, lineAnchor: "bottom"}),
vg.axisY({
anchor: "right",
Expand Down
2 changes: 1 addition & 1 deletion docs/public/specs/esm/seattle-temp.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default vg.plot(
),
vg.ruleY(
[15],
{strokeOpacity: 0.5, strokeDasharray: [5, 5]}
{strokeOpacity: 0.5, strokeDasharray: "5 5"}
),
vg.xTickFormat("%b"),
vg.yLabel("Temperature Range (°C)"),
Expand Down
1 change: 0 additions & 1 deletion docs/public/specs/esm/voronoi.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default vg.vconcat(
stroke: "white",
strokeWidth: 1,
strokeOpacity: 0.5,
inset: 1,
fill: "species",
fillOpacity: 0.2
}
Expand Down
5 changes: 1 addition & 4 deletions docs/public/specs/json/axes.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"plot": [
{
"mark": "gridY",
"strokeDasharray": [
0.75,
2
],
"strokeDasharray": "0.75 2",
"strokeOpacity": 1
},
{
Expand Down
5 changes: 1 addition & 4 deletions docs/public/specs/json/seattle-temp.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@
15
],
"strokeOpacity": 0.5,
"strokeDasharray": [
5,
5
]
"strokeDasharray": "5 5"
}
],
"xTickFormat": "%b",
Expand Down
1 change: 0 additions & 1 deletion docs/public/specs/json/voronoi.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"stroke": "white",
"strokeWidth": 1,
"strokeOpacity": 0.5,
"inset": 1,
"fill": "species",
"fillOpacity": 0.2
},
Expand Down
2 changes: 1 addition & 1 deletion docs/public/specs/yaml/axes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ meta:
scale attributes such as `xAxis`, `yGrid`, etc. Just add data!
plot:
- mark: gridY
strokeDasharray: [0.75, 2] # dashed
strokeDasharray: 0.75 2 # dashed
strokeOpacity: 1 # opaque
- mark: axisY
anchor: left
Expand Down
2 changes: 1 addition & 1 deletion docs/public/specs/yaml/seattle-temp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ plot:
- mark: ruleY
data: [15]
strokeOpacity: 0.5
strokeDasharray: [5, 5]
strokeDasharray: 5 5
xTickFormat: '%b'
yLabel: Temperature Range (°C)
width: 680
Expand Down
1 change: 0 additions & 1 deletion docs/public/specs/yaml/voronoi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ vconcat:
stroke: white
strokeWidth: 1
strokeOpacity: 0.5
inset: 1
fill: species
fillOpacity: 0.2
- mark: hull
Expand Down
Loading