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

beta-0.9 #115

Merged
merged 4 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
254 changes: 226 additions & 28 deletions apps/client/package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"lru-cache": "^10.2.0",
"lz-string": "^1.4.4",
"mitt": "^3.0.1",
"numcodecs": "^0.3.2",
"papaparse": "^5.3.2",
"pinia": "^2.0.28",
"quasar": "^2.11.5",
Expand Down Expand Up @@ -85,7 +86,7 @@
"prettier": "^2.7.1",
"sass": "^1.32.12",
"typescript": "~4.7.4",
"vite": "^4.0.5",
"vite": "^5.4.6",
"vue-tsc": "^1.0.12"
}
}
2 changes: 1 addition & 1 deletion apps/client/src/components/AggregateLineChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
TextLayer,
} from '@deck.gl/layers/typed';
import type { PixelData, PixelSource } from '@vivjs/types';
import { Pool } from 'geotiff';
import Pool from '../util/Pool';
import {
loadOmeTiff,
getChannelStats,
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/components/CellTrackView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useImageViewerStoreUntrracked } from '@/stores/imageViewerStoreUntrrack
import { useDatasetSelectionStore } from '@/stores/datasetSelectionStore';
import { useEventBusStore } from '@/stores/eventBusStore';
import { clamp } from 'lodash-es';
import { Pool } from 'geotiff';
import Pool from '../util/Pool';
import type { Feature } from 'geojson';
import {
expandHeight,
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/components/ImageViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useDataPointSelectionUntrracked } from '@/stores/dataPointSelectionUntr
import { useSegmentationStore } from '@/stores/segmentationStore';
import { useEventBusStore } from '@/stores/eventBusStore';
import { clamp } from 'lodash-es';
import { Pool } from 'geotiff';
import Pool from '../util/Pool';
import { useLooneageViewStore } from '@/stores/looneageViewStore';
import { useGlobalSettings } from '@/stores/globalSettings';

Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/components/LooneageViewGL.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
import { isEqual } from 'lodash-es';
import { useGlobalSettings } from '@/stores/globalSettings';

import { Pool } from 'geotiff';
import Pool from '../util/Pool';
import type { Feature } from 'geojson';
import { flextree, type LayoutNode } from 'd3-flextree';
import { hierarchy } from 'd3-hierarchy';
Expand Down
1 change: 1 addition & 0 deletions apps/client/src/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'numcodecs';
16 changes: 16 additions & 0 deletions apps/client/src/util/Pool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Modified from: https://github.com/hms-dbmi/viv

import { Pool } from 'geotiff';
import DecodeWorker from './decoder.worker?worker';

// https://developer.mozilla.org/en-US/docs/Web/API/NavigatorConcurrentHardware/hardwareConcurrency
// We need to give a different way of getting this for safari, so 4 is probably a safe bet
// for parallel processing in the meantime. More can't really hurt since they'll just block
// each other and not the UI thread, which is the real benefit.
const defaultPoolSize = globalThis?.navigator?.hardwareConcurrency ?? 4;

export default class extends Pool {
constructor() {
super(defaultPoolSize, () => new DecodeWorker());
}
}
37 changes: 37 additions & 0 deletions apps/client/src/util/decoder.worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Modified from https://github.com/hms-dbmi/viv

import { getDecoder, addDecoder } from 'geotiff';
import ZstdDecoder from './zstd-decoder';

addDecoder(50000, () => ZstdDecoder);

// @ts-expect-error - We are in a worker context
const worker: ServiceWorker = self;

interface WorkerData {
id: number;
fileDirectory: string;
buffer: ArrayBuffer;
}

async function decodeBuffer(e: MessageEvent<WorkerData>): Promise<void> {
try {
const { id, fileDirectory, buffer } = e.data;
const decoder = await getDecoder(fileDirectory);
const decoded = await decoder.decode(fileDirectory, buffer);
worker.postMessage({ decoded, id }, [decoded]);
} catch (error) {
if (error instanceof Error) {
console.error(`Failed: ${error.message} at ${e.data.id}`);
} else {
console.error(`Failed: Generic Error at ${e.data.id}`);
}
}
}

worker.addEventListener('message', (event: Event) => {
const messageEvent = event as MessageEvent;
decodeBuffer(messageEvent).catch((error: Error) => {
console.error(`Error during decompression: ${error.message}`);
});
});
17 changes: 17 additions & 0 deletions apps/client/src/util/zstd-decoder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { BaseDecoder } from 'geotiff';
import { Zstd } from 'numcodecs';

export default class ZstdDecoder extends BaseDecoder {
decoder: any;

constructor(_: any) {
super();
this.decoder = new Zstd();
}

async decodeBlock(buffer: ArrayBuffer) {
const bytes = new Uint8Array(buffer);
const decoded = await this.decoder.decode(bytes);
return decoded.buffer;
}
}
47 changes: 24 additions & 23 deletions apps/client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
import { fileURLToPath, URL } from 'node:url';
import path from 'path';
import { defineConfig, loadEnv } from 'vite'
import { defineConfig, loadEnv } from 'vite';

import vue from '@vitejs/plugin-vue';

import { quasar, transformAssetUrls } from '@quasar/vite-plugin';

export default defineConfig(({ command, mode }) => {
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
const env = loadEnv(mode, process.cwd(), '')
return {
// vite config
plugins: [
vue(),
// Load env file based on `mode` in the current working directory.
// Set the third parameter to '' to load all env regardless of the `VITE_` prefix.
const env = loadEnv(mode, process.cwd(), '');
return {
// vite config
plugins: [
vue(),

quasar({
sassVariables: 'src/quasar-variables.sass',
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
quasar({
sassVariables: 'src/quasar-variables.sass',
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
},
define: {
__APP_ENV__: JSON.stringify(env.APP_ENV),
},
}
})

define: {
__APP_ENV__: JSON.stringify(env.APP_ENV),
},
worker: {
format: 'es',
},
};
});
Loading
Loading