Skip to content

Commit

Permalink
chore: Apply formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
manzt committed May 13, 2024
1 parent d4f6e84 commit 8b89e1a
Show file tree
Hide file tree
Showing 25 changed files with 92 additions and 89 deletions.
7 changes: 5 additions & 2 deletions .meta-updater/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const LUMAGL_VERSION = '~8.5.21';
const MATHGL_VERSION = '^3.5.7';
const REACT_VERSION = '^16.8.0 || ^17.0.0';


/** @typedef {import('@pnpm/types').PackageManifest} PackageManifest */

/**
Expand All @@ -12,7 +11,11 @@ const REACT_VERSION = '^16.8.0 || ^17.0.0';
* @param {PackageManifest} manifest
*/
function pinVersions(manifest) {
for (const key of /** @type {const} */ (['dependencies', 'devDependencies', 'peerDependencies'])) {
for (const key of /** @type {const} */ ([
'dependencies',
'devDependencies',
'peerDependencies'
])) {
const deps = manifest[key] ?? {};
for (const name of Object.keys(deps)) {
if (name.startsWith('@deck.gl/') || name === 'deck.gl') {
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
"build": "pnpm -r --parallel build",
"clean": "pnpm -r exec -- rm -rf node_modules",
"test": "pnpm -r --parallel test",
"check-format": "prettier --check --ignore-path .gitignore tsconfig.json sites/avivator packages/",
"lint": "npm run check-format && eslint \"packages/*/src/**/*\" \"sites/avivator/src/**/*\"",
"format": "npm run check-format -- --write",
"fix": "biome check --apply .",
"version": "node ./scripts/version.mjs",
"publish": "pnpm build && pnpm changeset publish"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/extensions/prepare.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ for (const file of files) {
// find colormap name
const name = contents.match(/^vec4 (.*) \(.*\{$/m)[1];
const impl = contents
.replace(`vec4 ${name}`, "vec4 apply_cmap") // replace colormap fn name
.replace(`vec4 ${name}`, 'vec4 apply_cmap') // replace colormap fn name
.replace(/^#pragma glslify.*\n/gm, ''); // strip off glslify export

await fh.write(`export const ${name} = \`\\\n${impl}\`;\n`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import BaseExtension from './base-extension';

const _BEFORE_RENDER = "";
const _BEFORE_RENDER = '';

const _RENDER = `\
vec3 rgbCombo = vec3(0.0);
Expand All @@ -24,7 +24,7 @@ const _RENDER = `\
}
`;

const _AFTER_RENDER = "";
const _AFTER_RENDER = '';

/**
* This deck.gl extension allows for a color palette to be used for rendering in 3D with additive blending.
Expand Down
2 changes: 1 addition & 1 deletion packages/layers/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function padContrastLimits({
domain,
dtype
}) {
const maxSliderValue = (domain?.[1]) || getDtypeValues(dtype).max;
const maxSliderValue = domain?.[1] || getDtypeValues(dtype).max;
const newContrastLimits = contrastLimits.map((slider, i) =>
channelsVisible[i]
? slider
Expand Down
7 changes: 3 additions & 4 deletions packages/layers/src/xr-3d-layer/xr-3d-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ const XR3DLayer = class extends Layer {
gl.pixelStorei(GL.UNPACK_ALIGNMENT, 1);
gl.pixelStorei(GL.PACK_ALIGNMENT, 1);
const programManager = ProgramManager.getDefaultProgramManager(gl);
const processStr = "fs:DECKGL_PROCESS_INTENSITY(inout float intensity, vec2 contrastLimits, int channelIndex)";
const processStr =
'fs:DECKGL_PROCESS_INTENSITY(inout float intensity, vec2 contrastLimits, int channelIndex)';
if (!programManager._hookFunctions.includes(processStr)) {
programManager.addShaderHook(processStr);
}
Expand All @@ -151,9 +152,7 @@ const XR3DLayer = class extends Layer {
if (shaders) {
const { inject = {}, modules = [] } = shaders;
const definesInjection = inject[hookName];
const moduleDefinesInjection = modules.some(
m => m?.inject?.[hookName]
);
const moduleDefinesInjection = modules.some(m => m?.inject?.[hookName]);
return definesInjection || moduleDefinesInjection;
}
return false;
Expand Down
3 changes: 2 additions & 1 deletion packages/layers/src/xr-layer/xr-layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ const XRLayer = class extends Layer {

const mutateStr =
'fs:DECKGL_MUTATE_COLOR(inout vec4 rgba, float intensity0, float intensity1, float intensity2, float intensity3, float intensity4, float intensity5, vec2 vTexCoord)';
const processStr = "fs:DECKGL_PROCESS_INTENSITY(inout float intensity, vec2 contrastLimits, int channelIndex)";
const processStr =
'fs:DECKGL_PROCESS_INTENSITY(inout float intensity, vec2 contrastLimits, int channelIndex)';
// Only initialize shader hook functions _once globally_
// Since the program manager is shared across all layers, but many layers
// might be created, this solves the performance issue of always adding new
Expand Down
8 changes: 4 additions & 4 deletions packages/layers/tests/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,18 @@ test('getRenderingAttrs WebGL1', t => {
t.equal(
attrs.sampler,
'sampler2D',
"always return sampler2D as sampler"
'always return sampler2D as sampler'
);
t.equal(attrs.type, GL.FLOAT, "always return FLOAT as dtype");
t.equal(attrs.type, GL.FLOAT, 'always return FLOAT as dtype');
t.equal(
attrs.dataFormat,
GL.LUMINANCE,
"always return LUMINANCE as dataFormat"
'always return LUMINANCE as dataFormat'
);
t.equal(
attrs.format,
GL.LUMINANCE,
"always return LUMINANCE as format"
'always return LUMINANCE as format'
);
t.equal(
attrs.filter,
Expand Down
7 changes: 4 additions & 3 deletions packages/loaders/src/tiff/lib/indexers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ export type OmeTiffIndexer = (
* bioformats case we need to return the GeoTIFF object and the IFD index.
*/
export type OmeTiffResolver = (
sel: OmeTiffSelection) =>
| { tiff: GeoTIFF; ifdIndex: number }
| Promise<{ tiff: GeoTIFF; ifdIndex: number }>;
sel: OmeTiffSelection
) =>
| { tiff: GeoTIFF; ifdIndex: number }
| Promise<{ tiff: GeoTIFF; ifdIndex: number }>;

/*
* An "indexer" for a GeoTIFF-based source is a function that takes a
Expand Down
2 changes: 1 addition & 1 deletion packages/loaders/src/tiff/multi-tiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function assertSameResolution(images: MultiTiffImage[]) {
const height = images[0].tiff.getHeight();
for (const image of images) {
if (image.tiff.getWidth() !== width || image.tiff.getHeight() !== height) {
throw new Error("All images must have the same width and height");
throw new Error('All images must have the same width and height');
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions packages/loaders/src/zarr/pixel-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ class ZarrPixelSource<S extends string[]> implements PixelSource<S> {
// and ignored by deck.gl.
if (xStart === xStop || yStart === yStop) {
throw new BoundsCheckError('Tile slice is zero-sized.');
}if (xStart < 0 || yStart < 0 || xStop > width || yStop > height) {
}
if (xStart < 0 || yStart < 0 || xStop > width || yStop > height) {
throw new BoundsCheckError('Tile slice is out of bounds.');
}

Expand All @@ -121,7 +122,7 @@ class ZarrPixelSource<S extends string[]> implements PixelSource<S> {
private async _getRaw(
selection: (null | Slice | number)[],
// biome-ignore lint/suspicious/noExplicitAny: any is used to pass through storeOptions
getOptions?: { storeOptions?: any }
getOptions?: { storeOptions?: any }
) {
const result = await this._data.getRaw(selection, getOptions);
if (typeof result !== 'object') {
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ type WithExtensionProps<LayerProps> = LayerProps extends { extensions: unknown }
LensExtensionProps &
ColorPalette3DExtensionProps &
AdditiveColormap3DExtensionProps
// biome-ignore lint/suspicious/noExplicitAny: This is a catch-all for any other extension props
// biome-ignore lint/suspicious/noExplicitAny: This is a catch-all for any other extension props
> & { [extensionProp: string]: any }
: unknown;

Expand Down
13 changes: 6 additions & 7 deletions packages/viewers/src/VivViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,12 @@ class VivViewerWrapper extends React.PureComponent {
// Save the view state and trigger rerender.
const { views, onViewStateChange } = this.props;
viewState =
(onViewStateChange?.({
viewId,
viewState,
interactionState,
oldViewState
})) ||
viewState;
onViewStateChange?.({
viewId,
viewState,
interactionState,
oldViewState
}) || viewState;
this.setState(prevState => {
const viewStates = {};
views.forEach(view => {
Expand Down
4 changes: 2 additions & 2 deletions packages/views/tests/DetailView.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ detailViewArguments.initialViewState.id = id;

generateViewTests(DetailView, detailViewArguments);

test("DetailView layer type and props check", t => {
test('DetailView layer type and props check', t => {
const view = new DetailView(detailViewArguments);
const loader = { type: 'loads' };
const layers = view.getLayers({
Expand Down Expand Up @@ -44,7 +44,7 @@ test("DetailView layer type and props check", t => {
t.end();
});

test("DetailView does not render scale bar without physical size", t => {
test('DetailView does not render scale bar without physical size', t => {
const view = new DetailView(detailViewArguments);
const loader = { type: 'loads' };
const layers = view.getLayers({
Expand Down
8 changes: 4 additions & 4 deletions packages/views/tests/OverviewView.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const linkedViewIds = [DETAIL_VIEW_ID];

generateViewTests(OverviewView, overviewViewArguments, linkedViewIds);

test("OverviewView layer type check.", t => {
test('OverviewView layer type check.', t => {
const view = new OverviewView(overviewViewArguments);

const viewState = view.filterViewState({ viewState: overviewViewState });
Expand All @@ -50,7 +50,7 @@ test("OverviewView layer type check.", t => {
t.end();
});

test("OverviewView respects maximumHeight and minimumHeight when height > width.", t => {
test('OverviewView respects maximumHeight and minimumHeight when height > width.', t => {
const minimumHeight = 350;
let view = new OverviewView({ ...overviewViewArguments, minimumHeight });
t.equal(
Expand All @@ -68,7 +68,7 @@ test("OverviewView respects maximumHeight and minimumHeight when height > width.
t.end();
});

test("OverviewView respects maximumWidth and minimumWidth when width > height.", t => {
test('OverviewView respects maximumWidth and minimumWidth when width > height.', t => {
const minimumWidth = 350;
const loaderWidth = [
{ type: 'loads', shape: [10000, 20000] },
Expand Down Expand Up @@ -99,7 +99,7 @@ test("OverviewView respects maximumWidth and minimumWidth when width > height.",
t.end();
});

test("OverviewView maintains viewState.", t => {
test('OverviewView maintains viewState.', t => {
const view = new OverviewView(overviewViewArguments);
const viewState1 = view.filterViewState({
height: 10,
Expand Down
6 changes: 3 additions & 3 deletions packages/views/tests/SideBySideView.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { MultiscaleImageLayer, ImageLayer, ScaleBarLayer } from '@vivjs/layers';

generateViewTests(SideBySideView, defaultArguments);

test("SideBySideView layer type and props check", t => {
test('SideBySideView layer type and props check', t => {
const view = new SideBySideView(defaultArguments);
const loader = { type: 'loads' };
const layers = view.getLayers({
Expand Down Expand Up @@ -43,7 +43,7 @@ test("SideBySideView layer type and props check", t => {
t.end();
});

test("SideBySideView layer with multiscale", t => {
test('SideBySideView layer with multiscale', t => {
const view = new SideBySideView(defaultArguments);
const loader = { type: 'loads' };
const layers = view.getLayers({
Expand Down Expand Up @@ -80,7 +80,7 @@ test("SideBySideView layer with multiscale", t => {
t.end();
});

test("SideBySideView layer does not render scale bar without physical size", t => {
test('SideBySideView layer does not render scale bar without physical size', t => {
const view = new SideBySideView(defaultArguments);
const loader = { type: 'loads' };
const layers = view.getLayers({
Expand Down
12 changes: 6 additions & 6 deletions packages/views/tests/VivView.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ export function generateViewTests(ViewType, args, linkedViewIds = []) {
viewStates
});
layers?.forEach(layer => {
layer &&
t.ok(
layer.id.includes(getVivId(view.id)),
"Layer should include view's id as returned by getVivId."
);
});
layer &&
t.ok(
layer.id.includes(getVivId(view.id)),
"Layer should include view's id as returned by getVivId."
);
});
t.end();
});
}
Expand Down
9 changes: 3 additions & 6 deletions scripts/bundle-test.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as esbuild from "esbuild";
import * as esbuild from 'esbuild';

// These are necessary as long as we use `tape` for tests in the browser.
// The package relies on many node-isms and must be adapted.
Expand All @@ -8,9 +8,6 @@ import { NodeModulesPolyfillPlugin as builtins } from '@esbuild-plugins/node-mod
esbuild.build({
entryPoints: [process.argv[2]],
bundle: true,
format: "iife",
plugins: [
globals({ process: true, buffer: true }),
builtins(),
],
format: 'iife',
plugins: [globals({ process: true, buffer: true }), builtins()]
});
14 changes: 7 additions & 7 deletions scripts/bundle.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import * as esbuild from "esbuild";
import * as esbuild from 'esbuild';

esbuild.build({
entryPoints: [process.argv[2]],
outfile: './dist/index.js',
bundle: true,
format: "esm",
format: 'esm',
plugins: [
{
name: "make-all-packages-external",
name: 'make-all-packages-external',
setup(build) {
build.onResolve({ filter: /^[^\.]/ }, ({ path }) => {
return { path, external: true };
});
},
},
],
})
}
}
]
});
23 changes: 15 additions & 8 deletions scripts/version.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import * as childProcess from 'node:child_process';
import matter from 'gray-matter';

const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
const mainPackage = "@hms-dbmi/viv";
const mainPackage = '@hms-dbmi/viv';

/**
* @param {matter.GrayMatterFile<string>} changeset
*/
function getGreatestBumpType(changeset) {
const BUMP_TYPES = /** @type {const} */ (['none', 'patch', 'minor', 'major']);
const versions = Object.values(changeset.data).map(v => BUMP_TYPES.indexOf(v));
const versions = Object.values(changeset.data).map(v =>
BUMP_TYPES.indexOf(v)
);
const bumpType = BUMP_TYPES[Math.max(...versions)];
if (!bumpType) {
throw new Error(`Invalid bump type: ${bumpType}`);
Expand All @@ -27,7 +29,9 @@ function getGreatestBumpType(changeset) {
*/
function updateContentsWithAffectedPackages(changeset) {
const contentLines = changeset.content.split('\n');
const packageInfo = Object.keys(changeset.data).map(name => `\`${name}\``).join(', ');
const packageInfo = Object.keys(changeset.data)
.map(name => `\`${name}\``)
.join(', ');
contentLines[1] = `${contentLines[1]} (${packageInfo})`;
return contentLines.join('\n');
}
Expand Down Expand Up @@ -57,25 +61,28 @@ function updateContentsWithAffectedPackages(changeset) {
* ```
*
*/
function preChangesetsVersion(){
function preChangesetsVersion() {
const entries = fs.readdirSync(path.resolve(__dirname, '../.changeset'));
for (const file of entries) {
if (!file.endsWith(".md")) {
if (!file.endsWith('.md')) {
continue;
}
const filePath = path.resolve(__dirname, '../.changeset', file);
const changeset = matter.read(filePath);
changeset.content = updateContentsWithAffectedPackages(changeset);
changeset.data = { [mainPackage]: getGreatestBumpType(changeset) };
fs.writeFileSync(filePath, matter.stringify(changeset.content, changeset.data));
fs.writeFileSync(
filePath,
matter.stringify(changeset.content, changeset.data)
);
}
}

function clearChangelogs(pkgDir) {
for (const pkg of fs.readdirSync(pkgDir)) {
if (pkg === "main") continue;
if (pkg === 'main') continue;
try {
fs.unlinkSync(path.resolve(pkgDir, pkg, "CHANGELOG.md"));
fs.unlinkSync(path.resolve(pkgDir, pkg, 'CHANGELOG.md'));
} catch {
// ignore
}
Expand Down
Loading

0 comments on commit 8b89e1a

Please sign in to comment.