Skip to content

Commit

Permalink
Merge pull request #4296 from GordonSmith/HTML_REACT_PREACT
Browse files Browse the repository at this point in the history
fix: Remove preact references from html
  • Loading branch information
GordonSmith authored Nov 13, 2024
2 parents f297d81 + c78df51 commit 9ac09fb
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 5 deletions.
8 changes: 6 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/html/esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ await Promise.all([
},
external: [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.peerDependencies),
]
})
]);
82 changes: 82 additions & 0 deletions packages/html/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<!DOCTYPE html>
<html>

<head>
<title>Home</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f0f0f0;
}

h1 {
text-align: center;
margin-top: 50px;
}

#placeholder {
width: 100%;
height: 500px;
background-color: #fff;
margin-top: 20px;
}
</style>
<script type="importmap">
{
"imports": {
"@observablehq/runtime": "https://cdn.jsdelivr.net/npm/@observablehq/[email protected]/dist/runtime.js",

"@hpcc-js/util": "../util/dist/index.js",
"@hpcc-js/common": "../common/dist/index.js",
"@hpcc-js/api": "../api/dist/index.js",
"@hpcc-js/chart": "../chart/dist/index.js",
"@hpcc-js/comms": "../comms/dist/index.js",
"@hpcc-js/observablehq-compiler": "../observablehq-compiler/dist/index.js",
"@hpcc-js/html": "../comms/html/index.js",
"@hpcc-js/react": "../react/dist/index.js",
"react":"../../node_modules/react/umd/react.development.js",
"react-dom/client":"../../node_modules/react-dom/client.js",
"preact":"../../node_modules/preact/dist/preact.module.js",
"preact/compat":"../../node_modules/preact/compat/dist/compat.module.js",
"preact/hooks":"../../node_modules/preact/hooks/dist/hooks.module.js",
"react":"../../node_modules/preact/compat/dist/compat.module.js",
"react-dom/client":"../../node_modules/preact/compat/client.mjs"
}
}
</script>
<link rel="stylesheet" href="../common/dist/index.css">
<link rel="stylesheet" href="./dist/index.css">
</head>

<body onresize="doResize()">
<h1>ESM Quick Test</h1>
<div id="placeholder"></div>
<script type="module">
import { HTMLAdapter, SVGAdapter, Span, Text, LabelledRect, TextLine, Circle, Square, Rectangle, Shape } from "@hpcc-js/react";

window.__widget = new SVGAdapter(Text)
.target("placeholder")
.prop("text", "red")
.render()
;

setTimeout(() => {
window.__widget
.prop("text", "gggg Hello\nWorld 2 yyyy")
.render()
;
}, 1000);
</script>
<script>
function doResize() {
window.__widget
?.resize()
?.render()
;
}
</script>
</body>

</html>
8 changes: 7 additions & 1 deletion packages/html/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@
"devDependencies": {
"@hpcc-js/esbuild-plugins": "^1.2.0",
"d3-format": "^1",
"d3-selection": "^1"
"d3-selection": "^1",
"react": "18.3.1",
"react-dom": "18.3.1"
},
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/html/src/VizComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from "@hpcc-js/preact-shim";
import React from "react";
import { JSXWidget } from "./JSXWidget.ts";

export class VizComponent extends JSXWidget.Component<any, any> {
Expand Down
2 changes: 1 addition & 1 deletion packages/html/src/VizInstance.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from "@hpcc-js/preact-shim";
import React from "react";
import { JSXWidget } from "./JSXWidget.ts";

export class VizInstance extends JSXWidget.Component<any, any> {
Expand Down

0 comments on commit 9ac09fb

Please sign in to comment.