Skip to content

Commit 2401842

Browse files
committed
wip on a repro of a bug
1 parent e7e87df commit 2401842

File tree

7 files changed

+272
-0
lines changed

7 files changed

+272
-0
lines changed

examples/workspace-repro/build.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2+
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3+
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4+
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5+
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6+
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7+
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
8+
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9+
// ┃ This file is part of the Perspective library, distributed under the terms ┃
10+
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11+
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12+
13+
import esbuild from "esbuild";
14+
import fs from "fs";
15+
import path from "path";
16+
import { fileURLToPath } from "url";
17+
import { dirname } from "path";
18+
19+
const __dirname = dirname(fileURLToPath(import.meta.url));
20+
21+
await esbuild.build({
22+
entryPoints: ["src/index.ts"],
23+
outdir: "dist",
24+
format: "esm",
25+
bundle: true,
26+
sourcemap: "linked",
27+
target: "es2022",
28+
loader: {
29+
".arrow": "file",
30+
".wasm": "file",
31+
},
32+
assetNames: "[name]",
33+
});
34+
35+
fs.writeFileSync(
36+
path.join(__dirname, "dist/index.html"),
37+
fs.readFileSync(path.join(__dirname, "src/index.html")).toString()
38+
);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2+
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3+
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4+
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5+
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6+
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7+
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
8+
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9+
// ┃ This file is part of the Perspective library, distributed under the terms ┃
10+
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11+
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12+
13+
declare module "*.wasm" {
14+
const content: string;
15+
export default content;
16+
}
17+
18+
declare module "*.arrow" {
19+
const content: string;
20+
export default content;
21+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "workspace-repro",
3+
"private": true,
4+
"version": "3.7.4",
5+
"description": "To delete",
6+
"type": "module",
7+
"scripts": {
8+
"build": "node build.js",
9+
"start": "node build.js && http-server dist"
10+
},
11+
"keywords": [],
12+
"license": "Apache-2.0",
13+
"dependencies": {
14+
"@finos/perspective": "workspace:^",
15+
"@finos/perspective-viewer": "workspace:^",
16+
"@finos/perspective-viewer-d3fc": "workspace:^",
17+
"@finos/perspective-viewer-datagrid": "workspace:^",
18+
"@finos/perspective-workspace": "workspace:^"
19+
},
20+
"devDependencies": {
21+
"esbuild": "^0.25.5",
22+
"http-server": "^14.1.1"
23+
}
24+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2+
* ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3+
* ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4+
* ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5+
* ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6+
* ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7+
* ┃ Copyright (c) 2017, the Perspective Authors. ┃
8+
* ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9+
* ┃ This file is part of the Perspective library, distributed under the terms ┃
10+
* ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11+
* ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12+
*/
13+
14+
html {
15+
height: 100%;
16+
}
17+
18+
body {
19+
margin: 0;
20+
background-color: #f0f0f0;
21+
font-family: "ui-monospace", "SFMono-Regular", "SF Mono", "Menlo",
22+
"Consolas", "Liberation Mono", monospace;
23+
height: 100%;
24+
display: flex;
25+
flex-direction: column;
26+
}
27+
28+
nav.header {
29+
display: flex;
30+
}
31+
32+
perspective-workspace {
33+
height: 100%;
34+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!--
2+
3+
Copyright (c) 2017, the Perspective Authors.
4+
5+
This file is part of the Perspective library, distributed under the terms of
6+
the Apache License 2.0. The full license can be found in the LICENSE file.
7+
-->
8+
<!DOCTYPE html>
9+
<html>
10+
<head>
11+
<meta charset="UTF-8" />
12+
<title>Perspective React Example</title>
13+
<link rel="stylesheet" href="./index.css" />
14+
<script type="module" src="./index.js"></script>
15+
</head>
16+
<body>
17+
<nav class="header">
18+
<button class="swap">Swap Tables</button>
19+
<button class="add">Add View</button>
20+
</nav>
21+
</body>
22+
</html>
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2+
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3+
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4+
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5+
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6+
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7+
// ┃ Copyright (c) 2017, the Perspective Authors. ┃
8+
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9+
// ┃ This file is part of the Perspective library, distributed under the terms ┃
10+
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11+
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12+
13+
// # [Perspective bootstrapping](https://perspective.finos.org/guide/how_to/javascript/importing.html)
14+
15+
// Here we're initializing the WASM interpreter that powers the perspective API
16+
// and viewer, as covered in the [user guide section on bundling](https://perspective.finos.org/guide/how_to/javascript/importing.html).
17+
// This example is written assuming that the bundler is configured
18+
// to treat these files as a "file" and returns a path as the default export.
19+
// Use ./build.js as an example. The type stubs are in ./globals.d.ts
20+
21+
import perspective from "@finos/perspective";
22+
import perspective_viewer from "@finos/perspective-viewer";
23+
import "@finos/perspective-viewer-datagrid";
24+
import "@finos/perspective-viewer-d3fc";
25+
26+
import SERVER_WASM from "@finos/perspective/dist/wasm/perspective-server.wasm";
27+
import CLIENT_WASM from "@finos/perspective-viewer/dist/wasm/perspective-viewer.wasm";
28+
29+
await Promise.all([
30+
perspective.init_server(fetch(SERVER_WASM)),
31+
perspective_viewer.init_client(fetch(CLIENT_WASM)),
32+
]);
33+
34+
// # Data Source
35+
36+
// Data source creates a static Web Worker instance of Perspective engine, and a
37+
// table creation function which both downloads data and loads it into the
38+
// engine.
39+
40+
import type * as psp from "@finos/perspective";
41+
import type * as pspViewer from "@finos/perspective-viewer";
42+
import * as Workspace from "@finos/perspective-workspace";
43+
44+
const CLIENT = await perspective.worker();
45+
46+
import { PerspectiveWorkspaceConfig } from "@finos/perspective-workspace";
47+
48+
import "@finos/perspective-viewer/dist/css/pro.css";
49+
import "@finos/perspective-workspace/dist/css/pro.css";
50+
import "./index.css";
51+
52+
await customElements.whenDefined("perspective-workspace");
53+
const ready = document.createElement("div");
54+
ready.innerText = "READY";
55+
document.querySelector("nav.header")?.appendChild(ready);
56+
57+
const ws = document.createElement("perspective-workspace");
58+
document.body.appendChild(ws);
59+
60+
const tablesMain: Record<string, Promise<psp.Table>> = {};
61+
const tablesSwap: Record<string, Promise<psp.Table>> = {};
62+
63+
let layout: PerspectiveWorkspaceConfig<string> = {
64+
sizes: [1],
65+
viewers: {},
66+
detail: undefined,
67+
};
68+
let swap = false;
69+
70+
function swapTables() {
71+
console.warn("DDD VR Swapping");
72+
swap = !swap;
73+
ws.replaceTables(swap ? tablesMain : tablesSwap);
74+
}
75+
76+
function addViewer() {
77+
console.warn("DDD VR Adding");
78+
const name = window.crypto.randomUUID().slice(0, 7);
79+
tablesMain[name] = CLIENT.table("a,b,c\n1,2,3");
80+
tablesSwap[name] = CLIENT.table("a,b,c\n4,5,6\n7,8,9");
81+
ws.addTable(name, swap ? tablesMain[name] : tablesSwap[name]);
82+
layout = Workspace.addViewer(layout, { table: name, title: name });
83+
ws.restore(layout);
84+
}
85+
86+
document.querySelector("button.swap")?.addEventListener("click", () => {
87+
swapTables();
88+
});
89+
document.querySelector("button.add")?.addEventListener("click", () => {
90+
addViewer();
91+
});
92+
93+
addViewer();
94+
swapTables();
95+
addViewer();
96+
swapTables();
97+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"compilerOptions": {
3+
"moduleResolution": "bundler",
4+
"target": "ESNext",
5+
"module": "ESNext",
6+
"lib": [
7+
"ES2020",
8+
"dom"
9+
],
10+
"strict": true,
11+
"alwaysStrict": true,
12+
"noImplicitAny": true,
13+
"noImplicitReturns": true,
14+
"noImplicitThis": true,
15+
"noImplicitUseStrict": false,
16+
"noUnusedLocals": false,
17+
"strictNullChecks": true,
18+
"skipLibCheck": false,
19+
"removeComments": false,
20+
"jsx": "react-jsx",
21+
"allowSyntheticDefaultImports": true,
22+
"esModuleInterop": true,
23+
"forceConsistentCasingInFileNames": true,
24+
"importHelpers": false,
25+
"noEmitHelpers": true,
26+
"inlineSourceMap": false,
27+
"sourceMap": true,
28+
"emitDecoratorMetadata": false,
29+
"experimentalDecorators": true,
30+
"downlevelIteration": true,
31+
"pretty": true
32+
},
33+
"exclude": [
34+
"node_modules"
35+
]
36+
}

0 commit comments

Comments
 (0)