-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bindgen): Generate browser ESM bundle
- Loading branch information
Showing
8 changed files
with
234 additions
and
57 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
:root { | ||
font-family: Inter, Avenir, Helvetica, Arial, sans-serif; | ||
font-size: 16px; | ||
line-height: 20px; | ||
font-weight: 400; | ||
|
||
color-scheme: light dark; | ||
color: rgba(255, 255, 255, 0.87); | ||
background-color: #242424; | ||
|
||
font-synthesis: none; | ||
text-rendering: optimizeLegibility; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
-webkit-text-size-adjust: 100%; | ||
} | ||
|
||
a { | ||
font-weight: 500; | ||
color: #646cff; | ||
text-decoration: inherit; | ||
} | ||
a:hover { | ||
color: #535bf2; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
display: flex; | ||
place-items: center; | ||
min-width: 320px; | ||
min-height: 100vh; | ||
} | ||
|
||
h1 { | ||
font-size: 3.2em; | ||
line-height: 1.1; | ||
} | ||
|
||
li { | ||
text-align: left; | ||
} | ||
|
||
#app { | ||
max-width: 1280px; | ||
margin: 0 auto; | ||
padding: 2rem; | ||
text-align: center; | ||
} | ||
|
||
.logo { | ||
height: 12em; | ||
padding: 1.1em; | ||
will-change: filter; | ||
} | ||
.logo:hover { | ||
filter: drop-shadow(0 0 2em #646cffaa); | ||
} | ||
.logo.vanilla:hover { | ||
filter: drop-shadow(0 0 2em #3178c6aa); | ||
} | ||
|
||
.card { | ||
padding: 2em; | ||
} | ||
|
||
.read-the-docs { | ||
color: #888; | ||
} | ||
|
||
@media (prefers-color-scheme: light) { | ||
:root { | ||
color: #213547; | ||
background-color: #ffffff; | ||
} | ||
a:hover { | ||
color: #747bff; | ||
} | ||
button { | ||
background-color: #f9f9f9; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as <bindgenPackageNameCamelCase> from '../<bindgenPackageName>.js' | ||
console.log('demo stuff') | ||
|
||
const packageFunctions = [] | ||
for (const [key, val] of Object.entries(<bindgenPackageNameCamelCase>)) { | ||
if (typeof val == 'function') { | ||
packageFunctions.push(key) | ||
} | ||
} | ||
|
||
const pipelineFunctionsList = document.getElementById('pipeline-functions-list') | ||
pipelineFunctionsList.innerHTML = ` | ||
<li> | ||
${packageFunctions.join('</li>\n<li>')} | ||
</li> | ||
` | ||
console.log(packageFunctions) | ||
console.log(<bindgenPackageNameCamelCase>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/demo/logo.svg" /> | ||
<link rel="stylesheet" href="/demo/style.css" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title><bindgenPackageName></title> | ||
</head> | ||
<body> | ||
<div id="app"> | ||
<a href="https://wasm.itk.org/" target="_blank"> | ||
<img src="/demo/logo.svg" class="logo vanilla" alt="ITK Wasm logo" /> | ||
</a> | ||
<h1><bindgenPackageName></h1> | ||
package | ||
<div class="card"> | ||
<h2>functions</h2> | ||
<ul id="pipeline-functions-list"> | ||
|
||
</ul> | ||
</div> | ||
<p class="read-the-docs"> | ||
Click on the ITK Wasm logo to learn more | ||
</p> | ||
</div> | ||
|
||
<script type="module" src="/demo/app.js"></script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { nodeResolve } from '@rollup/plugin-node-resolve' | ||
import copy from 'rollup-plugin-copy' | ||
import typescript from '@rollup/plugin-typescript' | ||
import commonjs from '@rollup/plugin-commonjs' | ||
import nodePolyfills from 'rollup-plugin-polyfill-node' | ||
import ignore from 'rollup-plugin-ignore' | ||
import { terser } from 'rollup-plugin-terser' | ||
import packageJson from './package.json' assert { type: 'json' } | ||
import json from '@rollup/plugin-json' | ||
|
||
export default { | ||
input: './src/index.ts', | ||
output: [ | ||
{ | ||
file: `./dist/${packageJson.name}.js`, | ||
format: 'es', | ||
sourcemap: true, | ||
// plugins: [terser(),], | ||
}, | ||
], | ||
plugins: [ | ||
copy({ | ||
targets: [ | ||
{ src: 'node_modules/itk-wasm/dist/web-workers/bundles/pipeline.worker.js', dest: 'dist/pipelines/web-workers/' }, | ||
{ src: 'node_modules/itk-wasm/dist/web-workers/min-bundles/pipeline.worker.js', dest: 'dist/pipelines/web-workers/', rename: 'pipeline.min.worker.js' }, | ||
], | ||
hook: 'writeBundle' | ||
}), | ||
ignore(['crypto']), | ||
nodeResolve({ | ||
preferBuiltins: false, | ||
browser: true, | ||
}), | ||
commonjs({ | ||
transformMixedEsModules: true | ||
}), | ||
nodePolyfills(), | ||
typescript(), | ||
json(), | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters