Skip to content

Commit

Permalink
feat: pass baseurl through to default tooltip handler (#1286)
Browse files Browse the repository at this point in the history
* feat: pass baseurl through to default tooltip handler

* chore: update deps
  • Loading branch information
domoritz authored Dec 19, 2023
1 parent c9a2352 commit e3e703d
Show file tree
Hide file tree
Showing 4 changed files with 141 additions and 100 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"browser-sync": "^2.29.3",
"concurrently": "^8.2.2",
"del-cli": "^5.1.0",
"eslint": "^8.55.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-prettier": "^5.0.1",
Expand All @@ -70,7 +70,7 @@
"postinstall-postinstall": "^2.1.0",
"prettier": "^3.1.1",
"release-it": "^17.0.1",
"rollup": "4.8.0",
"rollup": "4.9.1",
"rollup-plugin-bundle-size": "^1.0.3",
"rollup-plugin-ts": "^3.4.5",
"sass": "^1.69.5",
Expand All @@ -90,7 +90,7 @@
"vega-interpreter": "^1.0.5",
"vega-schema-url-parser": "^2.2.0",
"vega-themes": "^2.14.0",
"vega-tooltip": "^0.33.0"
"vega-tooltip": "^0.34.0"
},
"bundledDependencies": [
"yallist"
Expand Down
8 changes: 5 additions & 3 deletions src/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,12 @@ async function _embed(
});

if (opts.tooltip !== false) {
const handler = isTooltipHandler(opts.tooltip)
? opts.tooltip
const {loader: loader_, tooltip} = opts;
const baseURL = loader_ && !isLoader(loader_) ? loader_?.baseURL : undefined;
const handler = isTooltipHandler(tooltip)
? tooltip
: // user provided boolean true or tooltip options
new Handler(opts.tooltip === true ? {} : opts.tooltip).call;
new Handler({baseURL, ...(tooltip === true ? {} : tooltip)}).call;

view.tooltip(handler);
}
Expand Down
39 changes: 39 additions & 0 deletions test-baseurl.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Vega-Embed for Vega-Lite</title>

<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-lite@5"></script>
<script src="build/vega-embed.js"></script>
</head>

<body>
<div id="vis"></div>
<script>
async function run() {
const spec = {
$schema: "https://vega.github.io/schema/vega-lite/v5.json",
view: { stroke: null },
data: {
values: [{ image: "data/ffox.png" }, { image: "data/gimp.png" }, { image: "data/7zip.png" }],
},
mark: "text",
encoding: {
text: { field: "image" },
y: { field: "image", axis: null },
tooltip: [{ field: "image" }],
},
};
const result = await vegaEmbed("#vis", spec, {
loader: { baseURL: "https://vega.github.io/vega-datasets/" },
});

console.log(result);
}
run();
</script>
</body>
</html>
188 changes: 94 additions & 94 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1071,10 +1071,10 @@
minimatch "^3.1.2"
strip-json-comments "^3.1.1"

"@eslint/js@8.55.0":
version "8.55.0"
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.55.0.tgz#b721d52060f369aa259cf97392403cb9ce892ec6"
integrity sha512-qQfo2mxH5yVom1kacMtZZJFVdW+E70mqHMJvVg6WTLo+VBuQJ4TojZlfWBjK0ve5BdEeNAVxOsl/nvNMpJOaJA==
"@eslint/js@8.56.0":
version "8.56.0"
resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.56.0.tgz#ef20350fec605a7f7035a01764731b2de0f3782b"
integrity sha512-gMsVel9D7f2HLkBma9VbtzZRehRogVRfbr++f06nL2vnCGCNlzOD+/MUov/F4p8myyAHspEhVobgjpX64q5m6A==

"@humanwhocodes/config-array@^0.11.13":
version "0.11.13"
Expand Down Expand Up @@ -1573,70 +1573,70 @@
estree-walker "^2.0.2"
picomatch "^2.3.1"

"@rollup/rollup-android-arm-eabi@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.8.0.tgz#0e42b155630adaaec0f659f979ece4b7d3391329"
integrity sha512-zdTObFRoNENrdPpnTNnhOljYIcOX7aI7+7wyrSpPFFIOf/nRdedE6IYsjaBE7tjukphh1tMTojgJ7p3lKY8x6Q==

"@rollup/rollup-android-arm64@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.8.0.tgz#6c9fe8f9eb0cd9029be93b822b1a1c2d6b31c275"
integrity sha512-aiItwP48BiGpMFS9Znjo/xCNQVwTQVcRKkFKsO81m8exrGjHkCBDvm9PHay2kpa8RPnZzzKcD1iQ9KaLY4fPQQ==

"@rollup/rollup-darwin-arm64@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.8.0.tgz#7dcb1317a8089762c1f7e437c1e1d695b787b70f"
integrity sha512-zhNIS+L4ZYkYQUjIQUR6Zl0RXhbbA0huvNIWjmPc2SL0cB1h5Djkcy+RZ3/Bwszfb6vgwUvcVJYD6e6Zkpsi8g==

"@rollup/rollup-darwin-x64@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.8.0.tgz#91d7d31d22607c4fcccce9126457d6785c57f7c7"
integrity sha512-A/FAHFRNQYrELrb/JHncRWzTTXB2ticiRFztP4ggIUAfa9Up1qfW8aG2w/mN9jNiZ+HB0t0u0jpJgFXG6BfRTA==

"@rollup/rollup-linux-arm-gnueabihf@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.8.0.tgz#f2015d6e4ff41417f2e2c55b3d9625346e355c57"
integrity sha512-JsidBnh3p2IJJA4/2xOF2puAYqbaczB3elZDT0qHxn362EIoIkq7hrR43Xa8RisgI6/WPfvb2umbGsuvf7E37A==

"@rollup/rollup-linux-arm64-gnu@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.8.0.tgz#95207444b78f235c9de62797ec2a3dcd18daf473"
integrity sha512-hBNCnqw3EVCkaPB0Oqd24bv8SklETptQWcJz06kb9OtiShn9jK1VuTgi7o4zPSt6rNGWQOTDEAccbk0OqJmS+g==

"@rollup/rollup-linux-arm64-musl@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.8.0.tgz#bc994c676fd3aae14aaa905040fdcde461e41ce5"
integrity sha512-Fw9ChYfJPdltvi9ALJ9wzdCdxGw4wtq4t1qY028b2O7GwB5qLNSGtqMsAel1lfWTZvf4b6/+4HKp0GlSYg0ahA==

"@rollup/rollup-linux-riscv64-gnu@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.8.0.tgz#67984f1d1f663610f4e1f6e638a2b07169562448"
integrity sha512-BH5xIh7tOzS9yBi8dFrCTG8Z6iNIGWGltd3IpTSKp6+pNWWO6qy8eKoRxOtwFbMrid5NZaidLYN6rHh9aB8bEw==

"@rollup/rollup-linux-x64-gnu@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.8.0.tgz#48e09a455d543be986003c7c2ea37c16ff4a53d5"
integrity sha512-PmvAj8k6EuWiyLbkNpd6BLv5XeYFpqWuRvRNRl80xVfpGXK/z6KYXmAgbI4ogz7uFiJxCnYcqyvZVD0dgFog7Q==

"@rollup/rollup-linux-x64-musl@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.8.0.tgz#df8d0966b02d1bdc6447b5eb58fa18666da1f3e8"
integrity sha512-mdxnlW2QUzXwY+95TuxZ+CurrhgrPAMveDWI97EQlA9bfhR8tw3Pt7SUlc/eSlCNxlWktpmT//EAA8UfCHOyXg==

"@rollup/rollup-win32-arm64-msvc@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.8.0.tgz#7cce8efc5c9239a1bafe7ac2a52743bc5734471f"
integrity sha512-ge7saUz38aesM4MA7Cad8CHo0Fyd1+qTaqoIo+Jtk+ipBi4ATSrHWov9/S4u5pbEQmLjgUjB7BJt+MiKG2kzmA==

"@rollup/rollup-win32-ia32-msvc@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.8.0.tgz#794ef4058d04f97447e4434c083b1309b2be73c2"
integrity sha512-p9E3PZlzurhlsN5h9g7zIP1DnqKXJe8ZUkFwAazqSvHuWfihlIISPxG9hCHCoA+dOOspL/c7ty1eeEVFTE0UTw==

"@rollup/rollup-win32-x64-msvc@4.8.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.8.0.tgz#05057436705f0be9203c30612a48225ec70af741"
integrity sha512-kb4/auKXkYKqlUYTE8s40FcJIj5soOyRLHKd4ugR0dCq0G2EfcF54eYcfQiGkHzjidZ40daB4ulsFdtqNKZtBg==
"@rollup/rollup-android-arm-eabi@4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.9.1.tgz#beaf518ee45a196448e294ad3f823d2d4576cf35"
integrity sha512-6vMdBZqtq1dVQ4CWdhFwhKZL6E4L1dV6jUjuBvsavvNJSppzi6dLBbuV+3+IyUREaj9ZFvQefnQm28v4OCXlig==

"@rollup/rollup-android-arm64@4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.9.1.tgz#6f76cfa759c2d0fdb92122ffe28217181a1664eb"
integrity sha512-Jto9Fl3YQ9OLsTDWtLFPtaIMSL2kwGyGoVCmPC8Gxvym9TCZm4Sie+cVeblPO66YZsYH8MhBKDMGZ2NDxuk/XQ==

"@rollup/rollup-darwin-arm64@4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.9.1.tgz#9aaefe33a5481d66322d1c62f368171c03eabe2b"
integrity sha512-LtYcLNM+bhsaKAIGwVkh5IOWhaZhjTfNOkGzGqdHvhiCUVuJDalvDxEdSnhFzAn+g23wgsycmZk1vbnaibZwwA==

"@rollup/rollup-darwin-x64@4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.9.1.tgz#707dcaadcdc6bd3fd6c69f55d9456cd4446306a3"
integrity sha512-KyP/byeXu9V+etKO6Lw3E4tW4QdcnzDG/ake031mg42lob5tN+5qfr+lkcT/SGZaH2PdW4Z1NX9GHEkZ8xV7og==

"@rollup/rollup-linux-arm-gnueabihf@4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.9.1.tgz#7a4dbbd1dd98731d88a55aefcef0ec4c578fa9c7"
integrity sha512-Yqz/Doumf3QTKplwGNrCHe/B2p9xqDghBZSlAY0/hU6ikuDVQuOUIpDP/YcmoT+447tsZTmirmjgG3znvSCR0Q==

"@rollup/rollup-linux-arm64-gnu@4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.9.1.tgz#967ba8e6f68a5f21bd00cd97773dcdd6107e94ed"
integrity sha512-u3XkZVvxcvlAOlQJ3UsD1rFvLWqu4Ef/Ggl40WAVCuogf4S1nJPHh5RTgqYFpCOvuGJ7H5yGHabjFKEZGExk5Q==

"@rollup/rollup-linux-arm64-musl@4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.9.1.tgz#d3a4e1c9f21eef3b9f4e4989f334a519a1341462"
integrity sha512-0XSYN/rfWShW+i+qjZ0phc6vZ7UWI8XWNz4E/l+6edFt+FxoEghrJHjX1EY/kcUGCnZzYYRCl31SNdfOi450Aw==

"@rollup/rollup-linux-riscv64-gnu@4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.9.1.tgz#415c0533bb752164effd05f5613858e8f6779bc9"
integrity sha512-LmYIO65oZVfFt9t6cpYkbC4d5lKHLYv5B4CSHRpnANq0VZUQXGcCPXHzbCXCz4RQnx7jvlYB1ISVNCE/omz5cw==

"@rollup/rollup-linux-x64-gnu@4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.9.1.tgz#0983385dd753a2e0ecaddea7a81dd37fea5114f5"
integrity sha512-kr8rEPQ6ns/Lmr/hiw8sEVj9aa07gh1/tQF2Y5HrNCCEPiCBGnBUt9tVusrcBBiJfIt1yNaXN6r1CCmpbFEDpg==

"@rollup/rollup-linux-x64-musl@4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.9.1.tgz#eb7494ebc5199cbd2e5c38c2b8acbe2603f35e03"
integrity sha512-t4QSR7gN+OEZLG0MiCgPqMWZGwmeHhsM4AkegJ0Kiy6TnJ9vZ8dEIwHw1LcZKhbHxTY32hp9eVCMdR3/I8MGRw==

"@rollup/rollup-win32-arm64-msvc@4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.9.1.tgz#5bebc66e3a7f82d4b9aa9ff448e7fc13a69656e9"
integrity sha512-7XI4ZCBN34cb+BH557FJPmh0kmNz2c25SCQeT9OiFWEgf8+dL6ZwJ8f9RnUIit+j01u07Yvrsuu1rZGxJCc51g==

"@rollup/rollup-win32-ia32-msvc@4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.9.1.tgz#34156ebf8b4de3b20e6497260fe519a30263f8cf"
integrity sha512-yE5c2j1lSWOH5jp+Q0qNL3Mdhr8WuqCNVjc6BxbVfS5cAS6zRmdiw7ktb8GNpDCEUJphILY6KACoFoRtKoqNQg==

"@rollup/rollup-win32-x64-msvc@4.9.1":
version "4.9.1"
resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.9.1.tgz#d146db7a5949e10837b323ce933ed882ac878262"
integrity sha512-PyJsSsafjmIhVgaI1Zdj7m8BB8mMckFah/xbpplObyHfiXzKcI5UOUXRyOdHW7nz4DpMCuzLnF7v5IWHenCwYA==

"@sinclair/typebox@^0.27.8":
version "0.27.8"
Expand Down Expand Up @@ -3794,15 +3794,15 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800"
integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==

eslint@^8.55.0:
version "8.55.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.55.0.tgz#078cb7b847d66f2c254ea1794fa395bf8e7e03f8"
integrity sha512-iyUUAM0PCKj5QpwGfmCAG9XXbZCWsqP/eWAWrG/W0umvjuLRBECwSFdt+rCntju0xEH7teIABPwXpahftIaTdA==
eslint@^8.56.0:
version "8.56.0"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.56.0.tgz#4957ce8da409dc0809f99ab07a1b94832ab74b15"
integrity sha512-Go19xM6T9puCOWntie1/P997aXxFsOi37JIHRWI514Hc6ZnaHGKY9xFhrU65RT6CcBEzZoGG1e6Nq+DT04ZtZQ==
dependencies:
"@eslint-community/eslint-utils" "^4.2.0"
"@eslint-community/regexpp" "^4.6.1"
"@eslint/eslintrc" "^2.1.4"
"@eslint/js" "8.55.0"
"@eslint/js" "8.56.0"
"@humanwhocodes/config-array" "^0.11.13"
"@humanwhocodes/module-importer" "^1.0.1"
"@nodelib/fs.walk" "^1.2.8"
Expand Down Expand Up @@ -7035,24 +7035,24 @@ rollup-plugin-ts@^3.4.5:
ts-clone-node "^3.0.0"
tslib "^2.6.1"

rollup@4.8.0:
version "4.8.0"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.8.0.tgz#365c34e85f1ed034de974dab934c1663cc69b754"
integrity sha512-NpsklK2fach5CdI+PScmlE5R4Ao/FSWtF7LkoIrHDxPACY/xshNasPsbpG0VVHxUTbf74tJbVT4PrP8JsJ6ZDA==
rollup@4.9.1:
version "4.9.1"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.9.1.tgz#351d6c03e4e6bcd7a0339df3618d2aeeb108b507"
integrity sha512-pgPO9DWzLoW/vIhlSoDByCzcpX92bKEorbgXuZrqxByte3JFk2xSW2JEeAcyLc9Ru9pqcNNW+Ob7ntsk2oT/Xw==
optionalDependencies:
"@rollup/rollup-android-arm-eabi" "4.8.0"
"@rollup/rollup-android-arm64" "4.8.0"
"@rollup/rollup-darwin-arm64" "4.8.0"
"@rollup/rollup-darwin-x64" "4.8.0"
"@rollup/rollup-linux-arm-gnueabihf" "4.8.0"
"@rollup/rollup-linux-arm64-gnu" "4.8.0"
"@rollup/rollup-linux-arm64-musl" "4.8.0"
"@rollup/rollup-linux-riscv64-gnu" "4.8.0"
"@rollup/rollup-linux-x64-gnu" "4.8.0"
"@rollup/rollup-linux-x64-musl" "4.8.0"
"@rollup/rollup-win32-arm64-msvc" "4.8.0"
"@rollup/rollup-win32-ia32-msvc" "4.8.0"
"@rollup/rollup-win32-x64-msvc" "4.8.0"
"@rollup/rollup-android-arm-eabi" "4.9.1"
"@rollup/rollup-android-arm64" "4.9.1"
"@rollup/rollup-darwin-arm64" "4.9.1"
"@rollup/rollup-darwin-x64" "4.9.1"
"@rollup/rollup-linux-arm-gnueabihf" "4.9.1"
"@rollup/rollup-linux-arm64-gnu" "4.9.1"
"@rollup/rollup-linux-arm64-musl" "4.9.1"
"@rollup/rollup-linux-riscv64-gnu" "4.9.1"
"@rollup/rollup-linux-x64-gnu" "4.9.1"
"@rollup/rollup-linux-x64-musl" "4.9.1"
"@rollup/rollup-win32-arm64-msvc" "4.9.1"
"@rollup/rollup-win32-ia32-msvc" "4.9.1"
"@rollup/rollup-win32-x64-msvc" "4.9.1"
fsevents "~2.3.2"

run-applescript@^5.0.0:
Expand Down Expand Up @@ -8298,10 +8298,10 @@ vega-time@^2.1.1, vega-time@~2.1.1:
d3-time "^3.1.0"
vega-util "^1.17.1"

vega-tooltip@^0.33.0:
version "0.33.0"
resolved "https://registry.yarnpkg.com/vega-tooltip/-/vega-tooltip-0.33.0.tgz#32bcaad713171d2ae00b47189e6334a318566739"
integrity sha512-jMcvH2lP20UfyvO2KAEdloiwRyasikaiLuNFhzwrrzf2RamGTxP4G7B2OZ2QENfrGUH05Z9ei5tn/eErdzOaZQ==
vega-tooltip@^0.34.0:
version "0.34.0"
resolved "https://registry.yarnpkg.com/vega-tooltip/-/vega-tooltip-0.34.0.tgz#e0aa4d9c9bcf155e257650ba7e670fad7b1ff5ab"
integrity sha512-TtxwkcLZ5aWQTvKGlfWDou8tISGuxmqAW1AgGZjrDpf75qsXvgtbPdRAAls2LZMqDxpr5T1kMEZs9XbSpiI8yw==
dependencies:
vega-util "^1.17.2"

Expand Down

0 comments on commit e3e703d

Please sign in to comment.