Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 7 compression plugins #35

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},

"typescript.tsdk": "node_modules/typescript/lib",
Expand Down
4 changes: 3 additions & 1 deletion app/Viewer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { App } from '@h5web/app';
import { H5WasmProvider } from '@h5web/h5wasm';
import { suspend } from 'suspend-react';
import { getExportURL } from './utils';
import { getExportURL, getPlugin } from './utils';
import { type FileInfo } from '../src/models.js';

interface Props {
Expand All @@ -10,6 +10,7 @@ interface Props {

function Viewer(props: Props) {
const { fileInfo } = props;
const { supportedPlugins } = fileInfo;

const buffer = suspend(async () => {
const res = await fetch(fileInfo.uri);
Expand All @@ -21,6 +22,7 @@ function Viewer(props: Props) {
filename={fileInfo.name}
buffer={buffer}
getExportURL={getExportURL}
getPlugin={async (name) => getPlugin(supportedPlugins[name])}
>
<App />
</H5WasmProvider>
Expand Down
11 changes: 11 additions & 0 deletions app/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,14 @@ export const getExportURL: GetExportURL = (

return undefined;
};

export async function getPlugin(
url: string | undefined
): Promise<ArrayBuffer | undefined> {
if (!url) {
return undefined;
}

const response = await fetch(url);
return response.arrayBuffer();
}
18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@
"Visualization"
],
"engines": {
"node": "18.x",
"pnpm": ">=8.6.0",
"vscode": ">=1.47.0"
"node": "20.x",
"pnpm": "8.x",
"vscode": ">=1.86.0"
},
"activationEvents": [
"onCustomEditor:h5web.viewer"
],
axelboc marked this conversation as resolved.
Show resolved Hide resolved
"contributes": {
"customEditors": [
{
Expand Down Expand Up @@ -59,25 +56,26 @@
"scripts": {
"build": "pnpm build:app && pnpm build:extension --minify",
"build:app": "vite build",
"build:extension": "esbuild ./src/extension.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node",
"build:extension": "esbuild ./src/extension.ts --bundle --outfile=out/main.js --external:vscode --loader:.so=file --format=cjs --platform=node",
"watch": "pnpm build:extension --sourcemap --watch",
"prettier": "prettier . --cache --check",
"vscode:prepublish": "pnpm build",
"pub": "pnpx vsce publish --no-dependencies"
},
"dependencies": {
"@h5web/app": "10.0.0",
"@h5web/h5wasm": "10.0.0",
"@h5web/app": "10.1.0",
"@h5web/h5wasm": "10.1.0",
"@react-hookz/web": "15.0.1",
"axios": "0.27.2",
"h5wasm-plugins": "0.0.3",
"normalize.css": "8.0.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-error-boundary": "3.1.4",
"suspend-react": "0.0.8"
},
"devDependencies": {
"@types/node": "^18.15.11",
"@types/node": "^20.10.5",
"@types/react": "^18.2.25",
"@types/react-dom": "^18.2.10",
"@types/vscode": "~1.47.0",
Expand Down
Loading
Loading