Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ impl IntersectionObserverHandle {
) -> Self {
clone!(session, renderer, presentation);
let _callback = Closure::new(move |xs: js_sys::Array| {
// https://stackoverflow.com/questions/53862160/intersectionobserver-multiple-entries
let intersect = xs
.get(0)
.pop()
.unchecked_into::<IntersectionObserverEntry>()
.is_intersecting();

Expand All @@ -49,6 +50,7 @@ impl IntersectionObserverHandle {
session,
renderer,
};

ApiFuture::spawn(state.set_pause(intersect));
});

Expand Down
9 changes: 8 additions & 1 deletion rust/perspective-viewer/src/rust/renderer/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,14 @@ pub impl LocalKey<Rc<RefCell<Vec<PluginRecord>>>> {
.unwrap_or_else(|| "Custom".to_owned()),
priority: plugin_inst.priority().unwrap_or_default(),
};

let mut plugins = plugin.borrow_mut();
if let Some(first) = plugins.first()
&& first.tag_name.as_str() == "perspective-viewer-plugin"
{
plugins.clear();
}

plugins.push(record);
plugins.sort_by(|a, b| Ord::cmp(&b.priority, &a.priority));
});
Expand All @@ -121,7 +128,7 @@ fn register_default() {
name: "Debug".to_owned(),
category: "Custom".to_owned(),
tag_name: "perspective-viewer-plugin".to_owned(),
priority: 0,
priority: -1,
})
}
})
Expand Down
11 changes: 11 additions & 0 deletions rust/perspective-viewer/test/html/superstore_lazy_viewer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!doctype html>
<html>
<head>
<script type="module" src="/node_modules/@perspective-dev/viewer/dist/cdn/perspective-viewer.js"></script>
<script type="module" src="/node_modules/@perspective-dev/test/load-viewer.js"></script>
<link rel="stylesheet" href="../css/demo.css" />
<link rel="stylesheet" href="/node_modules/@perspective-dev/viewer/dist/css/pro.css" />
<link rel="stylesheet" href="/node_modules/@fontsource/roboto-mono/400.css" />
</head>
<body></body>
</html>
20 changes: 12 additions & 8 deletions rust/perspective-viewer/test/js/viewnotfound.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
import { test, expect } from "@perspective-dev/test";

test("View conflation is silenced", async ({ page }) => {
await page.goto("/rust/perspective-viewer/test/html/superstore.html");
await page.goto(
"/rust/perspective-viewer/test/html/superstore_lazy_viewer.html",
);

await page.evaluate(async () => {
while (!window["__TEST_PERSPECTIVE_READY__"]) {
await new Promise((x) => setTimeout(x, 10));
Expand Down Expand Up @@ -53,30 +56,31 @@ test("View conflation is silenced", async ({ page }) => {

customElements.define("pause-plugin", PausePlugin);
const Viewer = customElements.get("perspective-viewer");
await Viewer.registerPlugin("pause-plugin");
Viewer.registerPlugin("pause-plugin");

// use a new viewer because only new viewers get loaded with the registered plugin
const viewer = document.createElement("perspective-viewer");
document.body.append(viewer);
const table = worker.table("a,b,c\n1,2,3", { name: "A" });
worker.table("a,b,c\n1,2,3", { name: "A" });

await viewer.load(table);
await viewer.restore({ plugin: "pause-plugin" });
await viewer.load(worker);
await viewer.restore({ table: "A", plugin: "pause-plugin" });
is_paused = true;

// Change in 4.1.0 - empty restore now does not render
const restore_task = viewer.restore({ plugin: "pause-plugin" });
const restore_task = viewer.restore({
plugin: "pause-plugin",
});

while (!resolve) {
await new Promise((x) => setTimeout(x, 0));
}

const load_task = viewer.load(table);
await new Promise((x) => setTimeout(x, 0));
resolve();
resolve = undefined;
is_paused = false;
await restore_task;
await load_task;
});

expect(vnf).toBeFalsy();
Expand Down
22 changes: 22 additions & 0 deletions tools/test/load-viewer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
// ┃ This file is part of the Perspective library, distributed under the terms ┃
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

import "/node_modules/@perspective-dev/viewer/dist/cdn/perspective-viewer.js";
import perspective from "/node_modules/@perspective-dev/client/dist/cdn/perspective.js";

async function load() {
const worker = await perspective.worker();
window.__TEST_WORKER__ = worker;
}

await load();
window.__TEST_PERSPECTIVE_READY__ = true;
Loading