Skip to content

Commit

Permalink
Merge pull request #791 from vega/next
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz authored Nov 15, 2021
2 parents 52c4895 + 99751ea commit 9d21b33
Show file tree
Hide file tree
Showing 11 changed files with 1,651 additions and 2,304 deletions.
30 changes: 14 additions & 16 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: weekly
day: sunday
time: "23:00"
timezone: PST8PDT
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
day: sunday
time: "23:00"
timezone: PST8PDT
open-pull-requests-limit: 10
- package-ecosystem: npm
directory: "/"
schedule:
interval: weekly
day: sunday
time: "23:00"
timezone: PST8PDT
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
day: sunday
time: "23:00"
timezone: PST8PDT
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-node@v2.4.1
with:
registry-url: "https://registry.npmjs.org"
node-version: "15"
node-version: "16"

- name: Install Node dependencies
run: yarn --frozen-lockfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v2.4.1
with:
node-version: "15"
node-version: "16"

- name: Install Node dependencies
run: yarn --frozen-lockfile
Expand Down
2 changes: 1 addition & 1 deletion build-style.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash

printf "// generated with build-style.sh\nexport default \`" > src/style.ts
node-sass vega-embed.scss >> src/style.ts
yarn sass vega-embed.scss >> src/style.ts
echo "\`;" >> src/style.ts
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,26 @@
"build-es5"
],
"devDependencies": {
"@auto-it/conventional-commits": "^10.32.0",
"@auto-it/first-time-contributor": "^10.32.0",
"@auto-it/conventional-commits": "^10.32.2",
"@auto-it/first-time-contributor": "^10.32.2",
"@rollup/plugin-commonjs": "21.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@types/semver": "^7.3.8",
"@wessberg/rollup-plugin-ts": "^1.3.14",
"auto": "^10.32.0",
"browser-sync": "^2.27.5",
"concurrently": "^6.2.1",
"@rollup/plugin-node-resolve": "^13.0.6",
"@types/semver": "^7.3.9",
"rollup-plugin-ts": "^1.4.7",
"auto": "^10.32.2",
"browser-sync": "^2.27.7",
"concurrently": "^6.4.0",
"del-cli": "^4.0.1",
"jest-canvas-mock": "^2.3.1",
"node-sass": "^6.0.1",
"sass": "^1.43.4",
"rollup-plugin-bundle-size": "^1.0.3",
"rollup-plugin-terser": "^7.0.2",
"rollup": "2.58.1",
"typescript": "^4.4.3",
"vega-lite-dev-config": "^0.18.0",
"rollup": "2.60.0",
"typescript": "^4.4.4",
"vega-lite-dev-config": "^0.20.0",
"vega-lite": "^5.0.0",
"vega": "^5.19.1"
"vega": "^5.21.0"
},
"peerDependencies": {
"vega": "^5.20.2",
Expand Down
6 changes: 3 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import ts from '@wessberg/rollup-plugin-ts';
import ts from 'rollup-plugin-ts';
import bundleSize from 'rollup-plugin-bundle-size';
import {terser} from 'rollup-plugin-terser';

Expand All @@ -17,8 +17,8 @@ const plugins = (browserslist, declaration) => [
declaration,
declarationMap: declaration,
}),
transpiler: "babel",
babelConfig: {"presets": ["@babel/preset-env"]},
transpiler: 'babel',
babelConfig: {presets: ['@babel/preset-env']},
browserslist,
}),
bundleSize(),
Expand Down
34 changes: 13 additions & 21 deletions src/embed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {applyPatch, Operation} from 'fast-json-patch';
import stringify from 'json-stringify-pretty-compact';
import {satisfies} from 'semver';
// need this import because of https://github.com/npm/node-semver/issues/381
import satisfies from 'semver/functions/satisfies';
import * as vegaImport from 'vega';
import {
AutoSize,
Expand Down Expand Up @@ -37,8 +38,8 @@ export let vegaLite = vegaLiteImport;

// For backwards compatibility with Vega-Lite before v4.
const w = (typeof window !== 'undefined' ? window : undefined) as any;
if (vegaLite === undefined && w?.['vl']?.compile) {
vegaLite = w['vl'];
if (vegaLite === undefined && w?.vl?.compile) {
vegaLite = w.vl;
}

export interface Actions {
Expand Down Expand Up @@ -205,7 +206,7 @@ function createLoader(opts?: Loader | LoaderOptions) {
}

function embedOptionsFromUsermeta(parsedSpec: VisualizationSpec) {
return (parsedSpec.usermeta && (parsedSpec.usermeta as any)['embedOptions']) ?? {};
return (parsedSpec.usermeta && (parsedSpec.usermeta as any).embedOptions) ?? {};
}

/**
Expand Down Expand Up @@ -261,11 +262,9 @@ async function loadOpts(opt: EmbedOptions, loader: Loader): Promise<EmbedOptions

function getRoot(el: Element) {
const possibleRoot = el.getRootNode ? el.getRootNode() : document;
if (possibleRoot instanceof ShadowRoot) {
return {root: possibleRoot, rootContainer: possibleRoot};
} else {
return {root: document, rootContainer: document.head ?? document.body};
}
return possibleRoot instanceof ShadowRoot
? {root: possibleRoot, rootContainer: possibleRoot}
: {root: document, rootContainer: document.head ?? document.body};
}

async function _embed(
Expand Down Expand Up @@ -333,11 +332,7 @@ async function _embed(

const patch = opts.patch;
if (patch) {
if (patch instanceof Function) {
vgSpec = patch(vgSpec);
} else {
vgSpec = applyPatch(vgSpec, patch, true, false).newDocument;
}
vgSpec = patch instanceof Function ? patch(vgSpec) : applyPatch(vgSpec, patch, true, false).newDocument;
}

// Set locale. Note that this is a global setting.
Expand Down Expand Up @@ -378,13 +373,10 @@ async function _embed(
});

if (opts.tooltip !== false) {
let handler: TooltipHandler;
if (isTooltipHandler(opts.tooltip)) {
handler = opts.tooltip;
} else {
// user provided boolean true or tooltip options
handler = new Handler(opts.tooltip === true ? {} : opts.tooltip).call;
}
const handler = isTooltipHandler(opts.tooltip)
? opts.tooltip
: // user provided boolean true or tooltip options
new Handler(opts.tooltip === true ? {} : opts.tooltip).call;

view.tooltip(handler);
}
Expand Down
2 changes: 1 addition & 1 deletion src/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {MessageData} from './types';
export default function (window: Window, url: string, data: MessageData) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const editor = window.open(url)!;
const wait = 10000;
const wait = 10_000;
const step = 250;
const {origin} = new URL(url);
// eslint-disable-next-line no-bitwise
Expand Down
2 changes: 1 addition & 1 deletion test-vl.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
};

const spec = {
$schema: "https://vega.github.io/schema/vega-lite/v4.json",
$schema: "https://vega.github.io/schema/vega-lite/v5.json",
data: {
values: [
{ a: "A", b: 28 },
Expand Down
11 changes: 11 additions & 0 deletions test/embed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,17 @@ test('Should warn about incompatible Vega and Vega-Lite versions', async () => {
{}
);

await embed(
el,
{
// should not cause a warning
$schema: 'https://vega.github.io/schema/vega-lite/v5.json',
mark: 'bar',
encoding: {},
},
{}
);

await embed(
el,
{
Expand Down
Loading

0 comments on commit 9d21b33

Please sign in to comment.