-
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(compress-stringify): Initial bindgen output
- Loading branch information
Showing
25 changed files
with
813 additions
and
0 deletions.
There are no files selected for viewing
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
Empty file.
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,6 @@ | ||
node_modules | ||
.DS_Store | ||
test | ||
cypress | ||
dist/index.html | ||
dist/demo |
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,151 @@ | ||
# itk-compress-stringify | ||
|
||
[![npm version](https://badge.fury.io/js/itk-compress-stringify.svg)](https://www.npmjs.com/package/itk-compress-stringify) | ||
|
||
Zstandard compression and decompression and base64 encoding and decoding in WebAssembly. | ||
|
||
## Installation | ||
|
||
```sh | ||
npm install itk-compress-stringify | ||
``` | ||
|
||
## Usage | ||
|
||
### Browser interface | ||
|
||
Import: | ||
|
||
```js | ||
import { | ||
compressStringify, | ||
parseStringDecompress, | ||
} from "itk-compress-stringify" | ||
``` | ||
|
||
#### compressStringify | ||
|
||
*Given a binary, compress and optionally base64 encode.* | ||
|
||
```ts | ||
async function compressStringify( | ||
webWorker: null | Worker, | ||
input: Uint8Array, | ||
options: CompressStringifyOptions = {} | ||
) : Promise<CompressStringifyResult> | ||
``` | ||
|
||
| Parameter | Type | Description | | ||
| :-------: | :----------: | :----------- | | ||
| `input` | *Uint8Array* | Input binary | | ||
|
||
**`CompressStringifyOptions` interface:** | ||
|
||
| Property | Type | Description | | ||
| :----------------: | :-------: | :------------------------------- | | ||
| `stringify` | *boolean* | Stringify the output | | ||
| `compressionLevel` | *number* | Compression level, typically 1-9 | | ||
| `dataUrlPrefix` | *string* | dataURL prefix | | ||
|
||
**`CompressStringifyResult` interface:** | ||
|
||
| Property | Type | Description | | ||
| :-----------: | :----------: | :----------------------------- | | ||
| **webWorker** | *Worker* | WebWorker used for computation | | ||
| `output` | *Uint8Array* | Output compressed binary | | ||
|
||
#### parseStringDecompress | ||
|
||
*Given a binary or string produced with CompressedStringify, decompress and optionally base64 decode.* | ||
|
||
```ts | ||
async function parseStringDecompress( | ||
webWorker: null | Worker, | ||
input: Uint8Array, | ||
options: ParseStringDecompressOptions = {} | ||
) : Promise<ParseStringDecompressResult> | ||
``` | ||
|
||
| Parameter | Type | Description | | ||
| :-------: | :----------: | :--------------- | | ||
| `input` | *Uint8Array* | Compressed input | | ||
|
||
**`ParseStringDecompressOptions` interface:** | ||
|
||
| Property | Type | Description | | ||
| :-----------: | :-------: | :------------------------------------------ | | ||
| `parseString` | *boolean* | Parse the input string before decompression | | ||
|
||
**`ParseStringDecompressResult` interface:** | ||
|
||
| Property | Type | Description | | ||
| :-----------: | :----------: | :----------------------------- | | ||
| **webWorker** | *Worker* | WebWorker used for computation | | ||
| `output` | *Uint8Array* | Output decompressed binary | | ||
|
||
### Node interface | ||
|
||
Import: | ||
|
||
```js | ||
import { | ||
compressStringifyNode, | ||
parseStringDecompressNode, | ||
} from "itk-compress-stringify" | ||
``` | ||
|
||
#### compressStringifyNode | ||
|
||
*Given a binary, compress and optionally base64 encode.* | ||
|
||
```ts | ||
async function compressStringifyNode( | ||
input: Uint8Array, | ||
options: CompressStringifyOptions = {} | ||
) : Promise<CompressStringifyNodeResult> | ||
``` | ||
|
||
| Parameter | Type | Description | | ||
| :-------: | :----------: | :----------- | | ||
| `input` | *Uint8Array* | Input binary | | ||
|
||
**`CompressStringifyNodeOptions` interface:** | ||
|
||
| Property | Type | Description | | ||
| :----------------: | :-------: | :------------------------------- | | ||
| `stringify` | *boolean* | Stringify the output | | ||
| `compressionLevel` | *number* | Compression level, typically 1-9 | | ||
| `dataUrlPrefix` | *string* | dataURL prefix | | ||
|
||
**`CompressStringifyNodeResult` interface:** | ||
|
||
| Property | Type | Description | | ||
| :------: | :----------: | :----------------------- | | ||
| `output` | *Uint8Array* | Output compressed binary | | ||
|
||
#### parseStringDecompressNode | ||
|
||
*Given a binary or string produced with CompressedStringify, decompress and optionally base64 decode.* | ||
|
||
```ts | ||
async function parseStringDecompressNode( | ||
input: Uint8Array, | ||
options: ParseStringDecompressOptions = {} | ||
) : Promise<ParseStringDecompressNodeResult> | ||
``` | ||
|
||
| Parameter | Type | Description | | ||
| :-------: | :----------: | :--------------- | | ||
| `input` | *Uint8Array* | Compressed input | | ||
|
||
**`ParseStringDecompressNodeOptions` interface:** | ||
|
||
| Property | Type | Description | | ||
| :-----------: | :-------: | :------------------------------------------ | | ||
| `parseString` | *boolean* | Parse the input string before decompression | | ||
|
||
**`ParseStringDecompressNodeResult` interface:** | ||
|
||
| Property | Type | Description | | ||
| :------: | :----------: | :------------------------- | | ||
| `output` | *Uint8Array* | Output decompressed binary | |
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 itkCompressStringify from '../itk-compress-stringify.js' | ||
console.log('demo stuff') | ||
|
||
const packageFunctions = [] | ||
for (const [key, val] of Object.entries(itkCompressStringify)) { | ||
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(itkCompressStringify) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions
82
packages/compress-stringify/typescript/dist/demo/style.css
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,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>itk-compress-stringify</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>itk-compress-stringify</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> |
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,29 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>itk-compress-stringify</title> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | ||
<meta name="description" content="Zstandard compression and decompression and base64 encoding and decoding in WebAssembly."> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> | ||
<link rel="stylesheet" media="(prefers-color-scheme: dark)" href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple-dark.css"> | ||
<link rel="stylesheet" media="(prefers-color-scheme: light)" href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple.css"> | ||
</head> | ||
<body> | ||
<div id="app">Loading...</div> | ||
<script> | ||
window.$docsify = { | ||
logo: 'dist/demo/logo.svg', | ||
name: 'itk-compress-stringify', | ||
repo: '' | ||
} | ||
</script> | ||
<!-- Docsify v4 --> | ||
<script src="https://cdn.jsdelivr.net/npm/docsify@4"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1/components/prism-typescript.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/js/docsify-themeable.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/docsify@4/lib/plugins/search.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/docsify@4/lib/plugins/zoom-image.min.js"></script> | ||
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script> | ||
</body> | ||
</html> |
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,50 @@ | ||
{ | ||
"name": "itk-compress-stringify", | ||
"version": "0.1.0", | ||
"description": "Zstandard compression and decompression and base64 encoding and decoding in WebAssembly.", | ||
"type": "module", | ||
"module": "./dist/itk-compress-stringify.js", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"browser": "./dist/itk-compress-stringify.js", | ||
"node": "./dist/itk-compress-stringify.node.js", | ||
"default": "./dist/itk-compress-stringify.js" | ||
} | ||
}, | ||
"scripts": { | ||
"start": "http-server ./dist/ -c-1", | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"build": "npm run build:tsc && npm run build:node && npm run build:browser", | ||
"build:node": "rollup -c ./rollup.node.config.js", | ||
"build:browser": "rollup -c ./rollup.browser.config.js", | ||
"build:tsc": "tsc --pretty" | ||
}, | ||
"keywords": [ | ||
"itk", | ||
"wasm", | ||
"webassembly", | ||
"wasi" | ||
], | ||
"author": "", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"itk-wasm": "^1.0.0-b.53" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^24.0.0", | ||
"@rollup/plugin-json": "^6.0.0", | ||
"@rollup/plugin-node-resolve": "^15.0.1", | ||
"@rollup/plugin-typescript": "^10.0.1", | ||
"http-server": "^14.1.1", | ||
"rollup": "^3.9.0", | ||
"rollup-plugin-copy": "^3.4.0", | ||
"rollup-plugin-ignore": "^1.0.10", | ||
"rollup-plugin-polyfill-node": "^0.11.0", | ||
"typescript": "^4.9.4" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/InsightSoftwareConsortium/itk-wasm" | ||
} | ||
} |
Oops, something went wrong.