@pluot/react 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +51 -53
- package/dist-tsc/Pluot.d.ts.map +1 -1
- package/dist-tsc/Pluot.js +34 -39
- package/package.json +2 -2
- package/src/Pluot.jsx +41 -47
package/dist-tsc/Pluot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pluot.d.ts","sourceRoot":"","sources":["../src/Pluot.jsx"],"names":[],"mappings":"AA+CA,
|
|
1
|
+
{"version":3,"file":"Pluot.d.ts","sourceRoot":"","sources":["../src/Pluot.jsx"],"names":[],"mappings":"AA+CA,uCAoaC"}
|
package/dist-tsc/Pluot.js
CHANGED
|
@@ -228,54 +228,49 @@ export function Pluot(props) {
|
|
|
228
228
|
isRenderingRef.current = false;
|
|
229
229
|
return;
|
|
230
230
|
}
|
|
231
|
+
const frameBailedEarly = arr.at(-1) === 1;
|
|
232
|
+
const graphicsArr = arr.subarray(0, -1);
|
|
231
233
|
if (isVector) {
|
|
232
234
|
// Format: Vector (render to SVG)
|
|
233
|
-
const gContents = decompressFromUint8Array(
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return;
|
|
235
|
+
const gContents = decompressFromUint8Array(graphicsArr);
|
|
236
|
+
if (svgRef.current) {
|
|
237
|
+
svgRef.current.innerHTML = gContents;
|
|
237
238
|
}
|
|
238
|
-
svgRef.current.innerHTML = gContents;
|
|
239
|
-
// TODO: check for bailed early
|
|
240
|
-
setBailedEarly(false);
|
|
241
239
|
}
|
|
242
240
|
else {
|
|
243
241
|
// Format: Raster (render to canvas)
|
|
244
242
|
const canvas = canvasRef.current;
|
|
245
|
-
if (
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
// E.g., write to a webgl texture? or is this fast enough already?
|
|
254
|
-
const imageData = new ImageData(new Uint8ClampedArray(arr.subarray(0, -1)), width, height);
|
|
255
|
-
ctx.putImageData(imageData, 0, 0);
|
|
256
|
-
const frameBailedEarly = arr.at(-1) === 1;
|
|
257
|
-
if (frameBailedEarly) {
|
|
258
|
-
// We multiply the current timeout by two to implement an exponential backoff
|
|
259
|
-
// while the Rust side is bailing early.
|
|
260
|
-
// A downstream useEffect restarts the exponential backoff from scratch
|
|
261
|
-
// if any other plotting parameters change.
|
|
262
|
-
currentTimeout.current = Math.min(currentTimeout.current * 2, maxTimeout);
|
|
263
|
-
incBacklogIteration(); // Increment this to force a re-render.
|
|
264
|
-
setBailedEarly(true); // Update this to show the loading indicator.
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
// Successful render.
|
|
268
|
-
currentTimeout.current = minTimeout;
|
|
269
|
-
setBailedEarly(false); // Update this to hide the loading indicator.
|
|
270
|
-
// Clear the LRU cache for the store (via its store_name) corresponding to the rendered plot.
|
|
271
|
-
Object.keys(stores).forEach(storeName => {
|
|
272
|
-
const storeUsed = getStore(storeName);
|
|
273
|
-
if (storeUsed && storeUsed.clearCache && typeof storeUsed.clearCache === 'function') {
|
|
274
|
-
storeUsed.clearCache();
|
|
275
|
-
}
|
|
276
|
-
});
|
|
243
|
+
if (canvas) {
|
|
244
|
+
const ctx = canvas.getContext("2d");
|
|
245
|
+
if (ctx) {
|
|
246
|
+
// TODO: is there a more efficient way to do this?
|
|
247
|
+
// E.g., write to a webgl texture? or is this fast enough already?
|
|
248
|
+
const imageData = new ImageData(new Uint8ClampedArray(graphicsArr), width, height);
|
|
249
|
+
ctx.putImageData(imageData, 0, 0);
|
|
250
|
+
}
|
|
277
251
|
}
|
|
278
252
|
}
|
|
253
|
+
if (frameBailedEarly) {
|
|
254
|
+
// We multiply the current timeout by two to implement an exponential backoff
|
|
255
|
+
// while the Rust side is bailing early.
|
|
256
|
+
// A downstream useEffect restarts the exponential backoff from scratch
|
|
257
|
+
// if any other plotting parameters change.
|
|
258
|
+
currentTimeout.current = Math.min(currentTimeout.current * 2, maxTimeout);
|
|
259
|
+
incBacklogIteration(); // Increment this to force a re-render.
|
|
260
|
+
setBailedEarly(true); // Update this to show the loading indicator.
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
// Successful render.
|
|
264
|
+
currentTimeout.current = minTimeout;
|
|
265
|
+
setBailedEarly(false); // Update this to hide the loading indicator.
|
|
266
|
+
// Clear the LRU cache for the store (via its store_name) corresponding to the rendered plot.
|
|
267
|
+
Object.keys(stores).forEach(storeName => {
|
|
268
|
+
const storeUsed = getStore(storeName);
|
|
269
|
+
if (storeUsed && storeUsed.clearCache && typeof storeUsed.clearCache === 'function') {
|
|
270
|
+
storeUsed.clearCache();
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
}
|
|
279
274
|
setDidFirstRender(true);
|
|
280
275
|
});
|
|
281
276
|
const throttledRender = useMemo(() => throttle(renderFrame, 16, // ~60fps
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pluot/react",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.11",
|
|
5
5
|
"description": "React component for visualization with Pluot",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"author": "Mark Keller",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"mouse-wheel": "^1.0.2",
|
|
37
37
|
"lz-string": "^1.5.0",
|
|
38
38
|
"lodash-es": "^4.17.23",
|
|
39
|
-
"@pluot/core": "0.1.
|
|
39
|
+
"@pluot/core": "0.1.11"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"vitest": "^3.2.4",
|
package/src/Pluot.jsx
CHANGED
|
@@ -300,62 +300,56 @@ export function Pluot(props) {
|
|
|
300
300
|
return;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
const frameBailedEarly = arr.at(-1) === 1;
|
|
304
|
+
const graphicsArr = arr.subarray(0, -1);
|
|
305
|
+
|
|
303
306
|
if (isVector) {
|
|
304
307
|
// Format: Vector (render to SVG)
|
|
305
|
-
const gContents = decompressFromUint8Array(
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (!svgRef.current) {
|
|
310
|
-
return;
|
|
308
|
+
const gContents = decompressFromUint8Array(graphicsArr);
|
|
309
|
+
if (svgRef.current) {
|
|
310
|
+
svgRef.current.innerHTML = gContents;
|
|
311
311
|
}
|
|
312
|
-
svgRef.current.innerHTML = gContents;
|
|
313
|
-
|
|
314
|
-
// TODO: check for bailed early
|
|
315
|
-
setBailedEarly(false);
|
|
316
312
|
} else {
|
|
317
313
|
// Format: Raster (render to canvas)
|
|
318
314
|
const canvas = canvasRef.current;
|
|
319
|
-
if (
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
315
|
+
if (canvas) {
|
|
316
|
+
const ctx = canvas.getContext("2d");
|
|
317
|
+
if (ctx) {
|
|
318
|
+
// TODO: is there a more efficient way to do this?
|
|
319
|
+
// E.g., write to a webgl texture? or is this fast enough already?
|
|
320
|
+
const imageData = new ImageData(
|
|
321
|
+
new Uint8ClampedArray(graphicsArr),
|
|
322
|
+
width,
|
|
323
|
+
height,
|
|
324
|
+
);
|
|
325
|
+
ctx.putImageData(imageData, 0, 0);
|
|
326
|
+
}
|
|
325
327
|
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
// Clear the LRU cache for the store (via its store_name) corresponding to the rendered plot.
|
|
350
|
-
Object.keys(stores).forEach(storeName => {
|
|
351
|
-
const storeUsed = getStore(storeName);
|
|
352
|
-
if (storeUsed && storeUsed.clearCache && typeof storeUsed.clearCache === 'function') {
|
|
353
|
-
storeUsed.clearCache();
|
|
354
|
-
}
|
|
355
|
-
});
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (frameBailedEarly) {
|
|
331
|
+
// We multiply the current timeout by two to implement an exponential backoff
|
|
332
|
+
// while the Rust side is bailing early.
|
|
333
|
+
// A downstream useEffect restarts the exponential backoff from scratch
|
|
334
|
+
// if any other plotting parameters change.
|
|
335
|
+
currentTimeout.current = Math.min(currentTimeout.current * 2, maxTimeout);
|
|
336
|
+
incBacklogIteration(); // Increment this to force a re-render.
|
|
337
|
+
setBailedEarly(true); // Update this to show the loading indicator.
|
|
338
|
+
} else {
|
|
339
|
+
// Successful render.
|
|
340
|
+
currentTimeout.current = minTimeout;
|
|
341
|
+
setBailedEarly(false); // Update this to hide the loading indicator.
|
|
342
|
+
|
|
343
|
+
// Clear the LRU cache for the store (via its store_name) corresponding to the rendered plot.
|
|
344
|
+
Object.keys(stores).forEach(storeName => {
|
|
345
|
+
const storeUsed = getStore(storeName);
|
|
346
|
+
if (storeUsed && storeUsed.clearCache && typeof storeUsed.clearCache === 'function') {
|
|
347
|
+
storeUsed.clearCache();
|
|
348
|
+
}
|
|
349
|
+
});
|
|
356
350
|
|
|
357
|
-
}
|
|
358
351
|
}
|
|
352
|
+
|
|
359
353
|
setDidFirstRender(true);
|
|
360
354
|
});
|
|
361
355
|
|