Skip to content

Commit

Permalink
Bundle assets
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatanklosko committed Feb 1, 2024
1 parent d5d76e7 commit dab662c
Show file tree
Hide file tree
Showing 6 changed files with 1,584 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ kino_vega_lite-*.tar

# Temporary files, for example, from tests.
/tmp/

# Node modules.
assets/*/node_modules/
11 changes: 5 additions & 6 deletions lib/assets/vega_lite/main.js → assets/vega_lite/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import "https://cdn.jsdelivr.net/npm/[email protected]";
import "https://cdn.jsdelivr.net/npm/[email protected]";
import "https://cdn.jsdelivr.net/npm/[email protected]";
import vegaEmbed from "vega-embed";
import { changeset } from "vega";

// See https://github.com/vega/vega-lite/blob/b61b13c2cbd4ecde0448544aff6cdaea721fd22a/src/compile/data/assemble.ts#L228-L231
const DEFAULT_DATASET_NAME = "source_0";
Expand Down Expand Up @@ -167,16 +166,16 @@ export function init(ctx, data) {

function buildChangeset(currentData, newData, window) {
if (window === 0) {
return vega.changeset().remove(currentData);
return changeset().remove(currentData);
} else if (window) {
const toInsert = newData.slice(-window);
const freeSpace = Math.max(window - toInsert.length, 0);
const toRemove =
freeSpace === 0 ? currentData : currentData.slice(0, -freeSpace);

return vega.changeset().remove(toRemove).insert(toInsert);
return changeset().remove(toRemove).insert(toInsert);
} else {
return vega.changeset().insert(newData);
return changeset().insert(newData);
}
}

Expand Down
Loading

0 comments on commit dab662c

Please sign in to comment.