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

Perspective Virtual API (JavaScript) #2615

Merged
merged 5 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Move cargo workspace to project root & update build scripts
Signed-off-by: Andrew Stein <steinlink@gmail.com>
  • Loading branch information
texodus committed May 23, 2024
commit 1bafbc5a764496234def82da37cc370a4165767c
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[alias]
bundle = "run -p perspective-bundle --"
bundle = "run -p perspective-bundle"

[build]
rustflags = ["--cfg=web_sys_unstable_apis"]
target-dir = "rust/target"

[target.wasm32-unknown-unknown]
runner = 'wasm-bindgen-test-runner'
Expand Down
19 changes: 18 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ flycheck_*.el
*.app

# Build artifacts
build
rust/target*
/docs/build
/packages/*/build
/python/*/build
/examples/*/build
CMakeCache.txt
CMakeFiles
cmake_install.cmake
Expand Down Expand Up @@ -123,6 +127,8 @@ target.vscode
!.vscode/settings.default.json
!.vscode/tasks.json

.llvm

# docs
website/translated_docs
website/build/
Expand Down Expand Up @@ -223,3 +229,14 @@ testenv
.clangd
.llvm/
examples/blocks/src/nypd/nypdccrb.arrow
.clangd
rust/perspective/build
rust/perspective-viewer/build
rust/perspective-client/src/rust/proto.rs
.vscode/vscode.css
rust/perspective/src/ts/ts-rs
rust/perspective-viewer/src/ts/ts-rs
rust/perspective-js/build
rust/perspective-js/src/ts/ts-rs
rust/perspective-server/cpp
rust/perspective-server/cmake
8 changes: 4 additions & 4 deletions .vscode/settings.default.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"cmake.configureOnOpen": true,
"cmake.sourceDirectory": "${workspaceFolder}/cpp/perspective/",
"cmake.buildDirectory": "${workspaceFolder}/cpp/perspective/dist/vscode",
"cmake.buildEnvironment": {
"PSP_ENABLE_WASM": "1"
},
"python.formatting.provider": "black",
"rust-analyzer.linkedProjects": [
"${workspaceFolder}/rust/perspective-viewer/Cargo.toml"
],
"rust-analyzer.server.extraEnv": {
"RA_LOG": "rust_analyzer::reload=info",
"CARGO_TARGET_DIR": "${workspaceFolder}/perspective-viewer/dist/analyzer"
},
"rust-analyzer.check.extraArgs": ["--target-dir=rust/target/vscode"],
"rust-analyzer.rustfmt.overrideCommand": [
"cargo",
"run",
Expand All @@ -21,5 +20,6 @@
"rust-analyzer.check.command": "clippy",
"playwright.env": {
"TZ": "UTC"
}
},
"clangd.arguments": ["--enable-config"]
}
34 changes: 34 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
# ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
# ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
# ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
# ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
# ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
# ┃ 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). ┃
# ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

[workspace]
resolver = "2"
members = [
"rust/lint",
"rust/bootstrap",
"rust/bootstrap-runtime",
"rust/perspective-viewer",
"rust/bundle",
"rust/perspective-client",
"rust/perspective-js",
]

[profile.dev]
panic = "abort"
opt-level = "s"

[profile.release]
panic = "abort"
opt-level = "z"
codegen-units = 1
lto = true
strip = true
2 changes: 1 addition & 1 deletion examples/blocks/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const replacements = {
"perspective-viewer-d3fc/dist/cdn/perspective-viewer-d3fc.js": `perspective-viewer-d3fc@${version}/dist/cdn/perspective-viewer-d3fc.js`,
"perspective-workspace/dist/cdn/perspective-workspace.js": `perspective-workspace@${version}/dist/cdn/perspective-workspace.js`,
"perspective/dist/cdn/perspective.cpp.wasm": `perspective@${version}/dist/cdn/perspective.cpp.wasm`,
"perspective-viewer/dist/cdn/perspective_bg.wasm": `perspective-viewer@${version}/dist/cdn/perspective_bg.wasm`,
"perspective-viewer/dist/cdn/perspective.rx.wasm": `perspective-viewer@${version}/dist/cdn/perspective.rx.wasm`,
"perspective/dist/cdn/perspective.worker.js": `perspective@${version}/dist/cdn/perspective.worker.js`,
};

Expand Down
3 changes: 2 additions & 1 deletion examples/blocks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"version": "2.10.1",
"description": "A collection of simple client-side Perspective examples for `http://bl.ocks.org`.",
"scripts": {
"start": "mkdirp dist && node server.mjs"
"start": "mkdirp dist && node --experimental-modules server.mjs",
"repl": "node --experimental-repl-await"
},
"main": "index.mjs",
"keywords": [],
Expand Down
1 change: 1 addition & 0 deletions examples/blocks/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

import "source-map-support/register.js";
import fs from "fs";
import { WebSocketServer } from "@finos/perspective";
import { dist_examples } from "./index.mjs";
Expand Down
2 changes: 1 addition & 1 deletion examples/blocks/src/citibike/citibike.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function get_feed(feedname, callback) {
}

// Create a new Perspective WebWorker instance.
const worker = perspective.worker();
const worker = await perspective.worker();

// Use Perspective WebWorker's table to infer the feed's schema.
async function get_schema(feed) {
Expand Down
2 changes: 1 addition & 1 deletion examples/blocks/src/covid/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<script type="module">
import { worker } from "/node_modules/@finos/perspective/dist/cdn/perspective.js";

const WORKER = worker();
const WORKER = await worker();
const REQ = fetch("https://api.covidtracking.com/v1/states/daily.csv");

const LAYOUT = {
Expand Down
37 changes: 15 additions & 22 deletions examples/blocks/src/editable/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,27 @@
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />

<script type="module" src="/node_modules/@finos/perspective/dist/cdn/perspective.js"></script>
<script type="module" src="/node_modules/@finos/perspective-viewer/dist/cdn/perspective-viewer.js"></script>
<script type="module" src="/node_modules/@finos/perspective-viewer-datagrid/dist/cdn/perspective-viewer-datagrid.js"></script>
<script type="module" src="/node_modules/@finos/perspective-viewer-d3fc/dist/cdn/perspective-viewer-d3fc.js"></script>

<link rel="stylesheet" crossorigin="anonymous" href="/node_modules/@finos/perspective-viewer/dist/css/themes.css" />

<link rel="preload" href="/node_modules/@finos/perspective/dist/cdn/perspective.cpp.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective-viewer/dist/cdn/perspective_bg.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective/dist/cdn/perspective-server.js" as="fetch" type="application/javascript" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective/dist/cdn/perspective-server.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective-viewer/dist/cdn/perspective-viewer.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/superstore-arrow/superstore.lz4.arrow" as="fetch" type="arraybuffer" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective/dist/cdn/perspective.worker.js" as="fetch" type="application/javascript" crossorigin="anonymous" />

<script type="module">
import { worker } from "/node_modules/@finos/perspective/dist/cdn/perspective.js";

const WORKER = worker();
const REQ = fetch("/node_modules/superstore-arrow/superstore.lz4.arrow");

async function load() {
const resp = await REQ;
const arrow = await resp.arrayBuffer();
const el = document.getElementsByTagName("perspective-viewer")[0];
const table = WORKER.table(arrow);
el.load(table);
el.restore({ settings: true, plugin_config: { editable: true } });
}
<link rel="stylesheet" crossorigin="anonymous" href="/node_modules/@finos/perspective-viewer/dist/css/themes.css" />

load();
<script type="module">
import perspective from "/node_modules/@finos/perspective/dist/cdn/perspective.js";

const worker = await perspective.websocket("ws://localhost:3000/ws");
const resp = await fetch("/node_modules/superstore-arrow/superstore.lz4.arrow");
const arrow = await resp.arrayBuffer();
const viewer = document.getElementsByTagName("perspective-viewer")[0];
const table = worker.table(arrow);
viewer.load(table);
viewer.restore({ settings: true, plugin_config: { editable: true } });
</script>

<style>
Expand All @@ -54,6 +47,6 @@
</head>

<body>
<perspective-viewer editable> </perspective-viewer>
<perspective-viewer></perspective-viewer>
</body>
</html>
2 changes: 1 addition & 1 deletion examples/blocks/src/evictions/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<script type="module">
import { worker } from "/node_modules/@finos/perspective/dist/cdn/perspective.js";

const WORKER = worker();
const WORKER = await worker();
const URL = `https://data.sfgov.org/resource/5cei-gny5.csv?$limit=50000`;

async function get_evictions() {
Expand Down
4 changes: 2 additions & 2 deletions examples/blocks/src/file/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

import perspective from "/node_modules/@finos/perspective/dist/cdn/perspective.js";

window.addEventListener("DOMContentLoaded", function () {
const worker = perspective.worker();
window.addEventListener("DOMContentLoaded", async function () {
const worker = await perspective.worker();

// Get `dropArea` element from the DOM.
var dropArea = document.getElementById("drop-area");
Expand Down
63 changes: 10 additions & 53 deletions examples/blocks/src/market/index.html
Original file line number Diff line number Diff line change
@@ -1,66 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta
name="viewport"
content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"
/>
<link
rel="preload"
href="/node_modules/@finos/perspective-viewer/dist/cdn/perspective_bg.wasm"
as="fetch"
type="application/wasm"
crossorigin="anonymous"
/>
<link
rel="preload"
href="/node_modules/@finos/perspective/dist/cdn/perspective.js"
as="script"
type="application/javascript"
crossorigin="anonymous"
/>
<link
rel="preload"
href="/node_modules/@finos/perspective/dist/cdn/perspective.cpp.wasm"
as="fetch"
type="application/wasm"
crossorigin="anonymous"
/>
<link
rel="preload"
href="/node_modules/@finos/perspective/dist/cdn/perspective.worker.js"
as="fetch"
type="application/javascript"
crossorigin="anonymous"
/>
<script
type="module"
src="/node_modules/@finos/perspective-viewer/dist/cdn/perspective-viewer.js"
></script>
<script
type="module"
src="/node_modules/@finos/perspective-viewer-datagrid/dist/cdn/perspective-viewer-datagrid.js"
></script>
<script
type="module"
src="/node_modules/@finos/perspective-viewer-d3fc/dist/cdn/perspective-viewer-d3fc.js"
></script>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
<link rel="preload" href="/node_modules/@finos/perspective-viewer/dist/cdn/perspective.rx.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective/dist/cdn/perspective.js" as="script" type="application/javascript" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective/dist/cdn/perspective.cpp.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective/dist/cdn/perspective.worker.js" as="fetch" type="application/javascript" crossorigin="anonymous" />
<script type="module" src="/node_modules/@finos/perspective-viewer/dist/cdn/perspective-viewer.js"></script>
<script type="module" src="/node_modules/@finos/perspective-viewer-datagrid/dist/cdn/perspective-viewer-datagrid.js"></script>
<script type="module" src="/node_modules/@finos/perspective-viewer-d3fc/dist/cdn/perspective-viewer-d3fc.js"></script>
<script type="module" src="market.js"></script>
<link rel="stylesheet" href="index.css" />
<link
rel="stylesheet"
crossorigin="anonymous"
href="/node_modules/@finos/perspective-viewer/dist/css/themes.css"
/>
<link rel="stylesheet" crossorigin="anonymous" href="/node_modules/@finos/perspective-viewer/dist/css/themes.css" />
</head>
<body>
<div id="app">
<div id="header">
<a href="https://perspective.finos.org">
<img
height="12"
src="https://raw.githubusercontent.com/finos/perspective/master/docs/static/svg/perspective-logo-dark.svg"
/>
<img height="12" src="https://raw.githubusercontent.com/finos/perspective/master/docs/static/svg/perspective-logo-dark.svg" />
</a>
<label>Market Simulation Demo</label>
<select></select>
Expand Down
2 changes: 1 addition & 1 deletion examples/blocks/src/nypd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
<link rel="preload" href="/node_modules/@finos/perspective-viewer/dist/cdn/perspective_bg.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective-viewer/dist/cdn/perspective.rx.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective/dist/cdn/perspective.js" as="script" type="application/javascript" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective/dist/cdn/perspective.cpp.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
<script type="module" src="/node_modules/@finos/perspective-viewer/dist/cdn/perspective-viewer.js"></script>
Expand Down
6 changes: 3 additions & 3 deletions examples/blocks/src/raycasting/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

<link rel="stylesheet" crossorigin="anonymous" href="/node_modules/@finos/perspective-viewer/dist/css/themes.css" />

<link rel="preload" href="/node_modules/@finos/perspective/dist/cdn/perspective.cpp.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective-viewer/dist/cdn/perspective_bg.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective/dist/cdn/perspective.worker.js" as="fetch" type="application/javascript" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective/dist/cdn/perspective-server.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective-viewer/dist/cdn/perspective-viewer.wasm" as="fetch" type="application/wasm" crossorigin="anonymous" />
<link rel="preload" href="/node_modules/@finos/perspective/dist/cdn/perspective-server.js" as="fetch" type="application/javascript" crossorigin="anonymous" />

<script type="module" src="index.js"></script>
<link rel="stylesheet" href="index.css" />
Expand Down
16 changes: 7 additions & 9 deletions examples/blocks/src/raycasting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,10 @@ const LAYOUT = {
theme: "Pro Dark",
};

window.addEventListener("DOMContentLoaded", async function () {
const heatmap_plugin = await window.viewer.getPlugin("Heatmap");
heatmap_plugin.max_cells = 100000;
const worker = perspective.worker();
const index = new Array(Math.pow(RESOLUTION, 2)).fill(0);
const table = worker.table({ index });
window.viewer.load(table);
await window.viewer.restore(LAYOUT);
});
const heatmap_plugin = await window.viewer.getPlugin("Heatmap");
heatmap_plugin.max_cells = 100000;
const worker = await perspective.worker();
const index = new Array(Math.pow(RESOLUTION, 2)).fill(0);
const table = worker.table({ index });
window.viewer.load(table);
await window.viewer.restore(LAYOUT);
Loading