Skip to content

Commit

Permalink
chore: Remove references to observable-md
Browse files Browse the repository at this point in the history
Update tests and web component.

Signed-off-by: Gordon Smith <[email protected]>
  • Loading branch information
GordonSmith committed Feb 16, 2024
1 parent 4c775be commit f33cdaf
Show file tree
Hide file tree
Showing 36 changed files with 6,528 additions and 3,528 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

strategy:
fail-fast: false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/npmPublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "16"
node-version: "20"
registry-url: "https://registry.npmjs.org"
scope: "@hpcc-js"
- run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ossar-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Open Source Static Analysis Runner

# OSSAR runs on windows-latest.
# ubuntu-latest and macos-latest support coming soon
# ubuntu-22.04 and macos-latest support coming soon
runs-on: windows-latest

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/releaseOnTag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
name: Release
jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/testPullRequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

strategy:
matrix:
node: ["16"]
node: ["20", "18", "16"]
fail-fast: false

steps:
Expand All @@ -29,10 +29,10 @@ jobs:
- run: npm run build-gallery
- run: npm run build-test
- run: sudo apt-get update
- run: wget https://github.com/hpcc-systems/HPCC-Platform/releases/download/community_9.0.14-1/hpccsystems-platform-community_9.0.14-1focal_amd64_withsymbols.deb
- run: wget https://github.com/hpcc-systems/HPCC-Platform/releases/download/community_9.4.34-1/hpccsystems-platform-community_9.4.34-1jammy_amd64_withsymbols.deb
- name: Install HPCC Platform
continue-on-error: true
run: sudo apt install -f ./hpccsystems-platform-community_9.0.14-1focal_amd64_withsymbols.deb
run: sudo apt install -f ./hpccsystems-platform-community_9.4.34-1jammy_amd64_withsymbols.deb
- run: sudo /etc/init.d/hpcc-init start
- run: npm run test
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "16.x"
node-version: "20"
registry-url: "https://registry.npmjs.org"
scope: "@hpcc-js"
- run: npm ci
Expand Down
52 changes: 52 additions & 0 deletions components/observable/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Dev",
"type": "chrome",
"request": "launch",
"url": "file:///${workspaceRoot}/index.html",
"runtimeArgs": [
"--allow-file-access-from-files",
"--disable-web-security"
],
"webRoot": "${workspaceRoot}"
},
{
"name": "lws",
"type": "chrome",
"request": "launch",
"url": "http://localhost:8080/../packages/graph/index.html",
"runtimeArgs": [
"--allow-file-access-from-files",
"--disable-web-security"
],
"webRoot": "${workspaceRoot}"
},
{
"type": "chrome",
"request": "launch",
"name": "index.md",
"url": "${workspaceFolder}/../../website/index.html?debug=1#packages/graph/docs/index.md",
"runtimeArgs": [
"--allow-file-access-from-files",
"--disable-web-security"
],
"webRoot": "${workspaceFolder}/../../website"
},
{
"type": "chrome",
"request": "launch",
"name": "http index.md",
"url": "http://localhost:8080/${workspaceFolder}/../../website/index.html?debug=1#packages/graph/docs/index.md",
"runtimeArgs": [
"--allow-file-access-from-files",
"--disable-web-security"
],
"webRoot": "${workspaceFolder}/../../website"
}
]
}
File renamed without changes.
5 changes: 3 additions & 2 deletions components/observable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
"update": "npx --yes npm-check-updates -u -t minor"
},
"dependencies": {
"@hpcc-js/observable-md": "^2.54.18",
"@hpcc-js/wc-core": "^0.4.10",
"@hpcc-js/observablehq-compiler": "^1.2.10",
"@observablehq/runtime": "5.9.7",
"tslib": "2.6.2"
},
"repository": {
Expand All @@ -46,4 +47,4 @@
"url": "https://github.com/hpcc-systems/Visualization/issues"
},
"homepage": "https://github.com/hpcc-systems/Visualization#readme"
}
}
87 changes: 10 additions & 77 deletions components/observable/src/observable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ChangeMap, HPCCResizeElement, css, customElement, display, html, ref, attribute, property, WebComponent } from "@hpcc-js/wc-core";
import { OJSRuntime, OMDRuntime, OJSRuntimeError, OJSSyntaxError } from "@hpcc-js/observable-md";
import { compile, ojs2notebook, omd2notebook } from "@hpcc-js/observablehq-compiler";
import { Inspector, Library, Runtime } from "@observablehq/runtime";
import { IObserverHandle } from "@hpcc-js/util";

const template = html<HPCCObservableElement>`\
Expand Down Expand Up @@ -71,13 +72,6 @@ export class HPCCObservableElement extends HPCCResizeElement {

@property _content: string = "";

private _watcher: IObserverHandle;

private _errors: OJSRuntimeError[] = [];
protected errors(): OJSRuntimeError[] {
return this._errors;
}

protected _div: HTMLDivElement;
protected _slot: HTMLSlotElement;

Expand Down Expand Up @@ -105,80 +99,19 @@ export class HPCCObservableElement extends HPCCResizeElement {
if (changes._content) {
this._div.innerHTML = "";

const context = this;
const runtimeUpdated = throttle(function () {
context.runtimeUpdated();
}, 500);

const runtime = this.mode === "observablescript" ? new OJSRuntime(this._div, this.plugins) : new OMDRuntime(this._div, this.plugins);
if (this._watcher) {
this._watcher.release();
}

this._watcher = runtime.watch(async () => {
const vars = runtime.latest();
this._errors = vars.map(n => {
const { start, end } = n.variable.pos();
return new OJSRuntimeError(n.type, start, end, stringify(n.value));
const nb = this.mode === "observablescript" ? ojs2notebook(this._content) : omd2notebook(this._content);
compile(nb).then(compiledNB => {
const library = new Library();
const runtime = new Runtime(library);
compiledNB(runtime, name => {
const div = document.createElement("div");
this._div.appendChild(div);
return new Inspector(div);
});
runtimeUpdated();
});

runtime.evaluate("", this._content, ".")
.catch((e: OJSSyntaxError) => {
this._errors = [new OJSRuntimeError("error", e.start, e.end, e.message)];
this.runtimeUpdated();
});
}
}

// Events ---
runtimeUpdated() {
}

}

function throttle(func, interval) {
let timeout;
return function (this) {
const context = this;
const args = arguments;
const later = function () {
timeout = false;
};
if (!timeout) {
func.apply(context, args);
timeout = true;
setTimeout(later, interval);
}
};
}

function stringify(value: any): string {
if (value instanceof Element) {
return value.outerHTML;
}
const type = typeof value;
switch (type) {
case "function":
return "ƒ()";
case "object":
if (Array.isArray(value)) {
return "[Array]";
}
break;
case "string":
case "number":
case "bigint":
case "boolean":
case "symbol":
case "undefined":
break;
}
if (value?.toString) {
return value.toString();
}
return value;
}

declare global {
Expand Down
4 changes: 2 additions & 2 deletions demos/gallery/samples/chart/Contour/Basic.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { randomNormal as d3RandomNormal } from "d3-random";
import { range as d3Range } from "d3-array";
import { range as d3Range } from "@hpcc-js/common";
import { Contour } from "@hpcc-js/chart";
import { randomNormal as d3RandomNormal } from "d3-random";

const randomX = d3RandomNormal(200, 80);
const randomY = d3RandomNormal(200, 80);
Expand Down
4 changes: 2 additions & 2 deletions demos/gallery/samples/chart/Hex Bin/Random Data.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { randomNormal as d3RandomNormal } from "d3-random";
import { range as d3Range } from "d3-array";
import { range as d3Range } from "@hpcc-js/common";
import { HexBin } from "@hpcc-js/chart";
import { randomNormal as d3RandomNormal } from "d3-random";

const randomX = d3RandomNormal(200, 80);
const randomY = d3RandomNormal(200, 80);
Expand Down
2 changes: 1 addition & 1 deletion demos/gallery/samples/chart/Layered/Contour and Scatter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { range as d3Range } from "@hpcc-js/common";
import { Contour, Scatter, XYAxis } from "@hpcc-js/chart";
import { randomNormal as d3RandomNormal } from "d3-random";
import { range as d3Range } from "d3-array";

const randomX = d3RandomNormal(200, 80);
const randomY = d3RandomNormal(2000, 20);
Expand Down
2 changes: 1 addition & 1 deletion demos/gallery/samples/chart/Layered/Hex Bin and Scatter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { range as d3Range } from "@hpcc-js/common";
import { HexBin, Scatter, XYAxis } from "@hpcc-js/chart";
import { randomNormal as d3RandomNormal } from "d3-random";
import { range as d3Range } from "d3-array";

const randomX = d3RandomNormal(200, 80);
const randomY = d3RandomNormal(2000, 20);
Expand Down
4 changes: 2 additions & 2 deletions demos/gallery/samples/chart/Scatter/Scatter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { randomNormal as d3RandomNormal } from "d3-random";
import { range as d3Range } from "d3-array";
import { range as d3Range } from "@hpcc-js/common";
import { Scatter } from "@hpcc-js/chart";
import { randomNormal as d3RandomNormal } from "d3-random";

const randomX = d3RandomNormal(200, 80);
const randomY = d3RandomNormal(200, 80);
Expand Down
2 changes: 1 addition & 1 deletion demos/gallery/systemjs.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"plugin-json": "https://cdn.jsdelivr.net/npm/[email protected]/json.js",
"plugin-babel": "https://cdn.jsdelivr.net/npm/[email protected]/plugin-babel.js",
"systemjs-babel-build": "https://cdn.jsdelivr.net/npm/[email protected]/systemjs-babel-browser.js",
"d3-array": "https://cdn.jsdelivr.net/npm/d3-array@1.2.1/build/d3-array.js",
"d3-array": "https://cdn.jsdelivr.net/npm/d3-array@^1/dist/d3-array.js",
"d3-fetch": "https://cdn.jsdelivr.net/npm/[email protected]/dist/d3-fetch.min.js",
"d3-random": "https://cdn.jsdelivr.net/npm/[email protected]/build/d3-random.js",
"@hpcc-js/chart": "https://cdn.jsdelivr.net/npm/@hpcc-js/[email protected]/dist/index.min.js",
Expand Down
1 change: 0 additions & 1 deletion demos/storyboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"@hpcc-js/layout": "^2.49.13",
"@hpcc-js/map": "^2.77.12",
"@hpcc-js/marshaller": "^2.25.31",
"@hpcc-js/observable-md": "^2.54.14",
"@hpcc-js/other": "^2.15.13",
"@hpcc-js/phosphor": "^2.17.0",
"@hpcc-js/util": "^2.50.6"
Expand Down
Loading

0 comments on commit f33cdaf

Please sign in to comment.