mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-07 10:18:11 +08:00
chore: type general utils (#2381)
* type camera
* type reducer store
* type actionhelpers
* type catchErrorsWrap callsite
* missed camera member var
* type nameCreators
* type makeContinousDimensionName callsite
* type promise limit
* type quantile
* type range
* introduce TypedArray + NumericArray
* type range
* cleanup test
* fix call sites
* type plimit call site
* finish typing camera
* use our TypedArray
* type scientific and sigFig utils and callsites
* simple typings
* type catLabelSort
* type callsite
* type
* callsites
* type camera methods
* swap back to strings, set defaults accordingly
* partially type centroid
* explicit tuple and undefined check
* fix references to this
* call constructor with new and casting
* Revert "introduce TypedArray + NumericArray"
This reverts commit cf21538717.
* explicit tuple
* generics and import fixes
* add unsigned 8 clamped arrray
* back to literals
* use arraytypes
* fix return state
* type more actions
* Update client/src/util/actionHelpers.ts
Co-authored-by: Timmy Huang <tihuan@users.noreply.github.com>
* properly type dispatch
* properly type thunk
* use new dispatch
* remove nullish coallescer
* use AppDispatch
* generic jsonrequest
* use dispatch again
* lint
Co-authored-by: Timmy Huang <tihuan@users.noreply.github.com>
This commit is contained in:
co-authored by
Timmy Huang
parent
45cecad76a
commit
08b03ace60
@@ -94,10 +94,12 @@ export async function getAllCategoriesAndCounts(category: any) {
|
|||||||
.querySelector("[data-testclass='categorical-value']")
|
.querySelector("[data-testclass='categorical-value']")
|
||||||
.getAttribute("aria-label");
|
.getAttribute("aria-label");
|
||||||
|
|
||||||
const count = (row.querySelector(
|
const count = (
|
||||||
"[data-testclass='categorical-value-count']"
|
row.querySelector(
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
"[data-testclass='categorical-value-count']"
|
||||||
) as any).innerText;
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
||||||
|
) as any
|
||||||
|
).innerText;
|
||||||
|
|
||||||
return [cat, count];
|
return [cat, count];
|
||||||
})
|
})
|
||||||
@@ -194,8 +196,7 @@ export async function expandCategory(category: any) {
|
|||||||
if (notExpanded) await clickOn(`${category}:category-expand`);
|
if (notExpanded) await clickOn(`${category}:category-expand`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
export async function clip(min = "0", max = "100"): Promise<void> {
|
||||||
export async function clip(min = 0, max = 100) {
|
|
||||||
await clickOn("visualization-settings");
|
await clickOn("visualization-settings");
|
||||||
await clearInputAndTypeInto("clip-min-input", min);
|
await clearInputAndTypeInto("clip-min-input", min);
|
||||||
await clearInputAndTypeInto("clip-max-input", max);
|
await clearInputAndTypeInto("clip-max-input", max);
|
||||||
|
|||||||
@@ -199,7 +199,6 @@ describe("clipping", () => {
|
|||||||
test("clip continuous", async () => {
|
test("clip continuous", async () => {
|
||||||
await goToPage(appUrlBase);
|
await goToPage(appUrlBase);
|
||||||
|
|
||||||
// @ts-expect-error ts-migrate(2345) FIXME: Argument of type 'string' is not assignable to par... Remove this comment to see the full error message
|
|
||||||
await clip(data.clip.min, data.clip.max);
|
await clip(data.clip.min, data.clip.max);
|
||||||
const histBrushableAreaId = `histogram-${data.clip.metadata}-plot-brushable-area`;
|
const histBrushableAreaId = `histogram-${data.clip.metadata}-plot-brushable-area`;
|
||||||
const coords = await calcDragCoordinates(
|
const coords = await calcDragCoordinates(
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ describe("PromiseLimit", () => {
|
|||||||
running -= 1;
|
running -= 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 1.
|
await Promise.all(range(10).map(() => plimit.add(() => callback())));
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
||||||
await Promise.all(range(10).map((i: any) => plimit.add(() => callback(i))));
|
|
||||||
|
|
||||||
expect(maxRunning).toEqual(2);
|
expect(maxRunning).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,20 +6,14 @@ describe("range", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("range(stop)", () => {
|
test("range(stop)", () => {
|
||||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 1.
|
|
||||||
expect(range(3)).toMatchObject([0, 1, 2]);
|
expect(range(3)).toMatchObject([0, 1, 2]);
|
||||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 1.
|
|
||||||
expect(range(0)).toMatchObject([]);
|
expect(range(0)).toMatchObject([]);
|
||||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 1.
|
|
||||||
expect(range(1)).toMatchObject([0]);
|
expect(range(1)).toMatchObject([0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("range(start,stop)", () => {
|
test("range(start,stop)", () => {
|
||||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
|
|
||||||
expect(range(0, 0)).toMatchObject([]);
|
expect(range(0, 0)).toMatchObject([]);
|
||||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
|
|
||||||
expect(range(0, 2)).toMatchObject([0, 1]);
|
expect(range(0, 2)).toMatchObject([0, 1]);
|
||||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 3 arguments, but got 2.
|
|
||||||
expect(range(4, 8)).toMatchObject([4, 5, 6, 7]);
|
expect(range(4, 8)).toMatchObject([4, 5, 6, 7]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,10 @@
|
|||||||
action creators related to embeddings choice
|
action creators related to embeddings choice
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { Action, ActionCreator } from "redux";
|
||||||
|
import { ThunkAction } from "redux-thunk";
|
||||||
import { AnnoMatrixObsCrossfilter } from "../annoMatrix";
|
import { AnnoMatrixObsCrossfilter } from "../annoMatrix";
|
||||||
|
import type { AppDispatch, RootState } from "../reducers";
|
||||||
import { _setEmbeddingSubset } from "../util/stateManager/viewStackHelpers";
|
import { _setEmbeddingSubset } from "../util/stateManager/viewStackHelpers";
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
||||||
@@ -29,30 +32,26 @@ export async function _switchEmbedding(
|
|||||||
return [annoMatrix, obsCrossfilter];
|
return [annoMatrix, obsCrossfilter];
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export const layoutChoiceAction: ActionCreator<
|
||||||
export const layoutChoiceAction = (newLayoutChoice: any) => async (
|
ThunkAction<Promise<void>, RootState, never, Action<"set layout choice">>
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
> =
|
||||||
dispatch: any,
|
(newLayoutChoice: string) =>
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
async (dispatch: AppDispatch, getState: () => RootState): Promise<void> => {
|
||||||
getState: any
|
/*
|
||||||
) => {
|
|
||||||
/*
|
|
||||||
On layout choice, make sure we have selected all on the previous layout, AND the new
|
On layout choice, make sure we have selected all on the previous layout, AND the new
|
||||||
layout.
|
layout.
|
||||||
*/
|
*/
|
||||||
const {
|
const { annoMatrix: prevAnnoMatrix, obsCrossfilter: prevCrossfilter } =
|
||||||
annoMatrix: prevAnnoMatrix,
|
getState();
|
||||||
obsCrossfilter: prevCrossfilter,
|
const [annoMatrix, obsCrossfilter] = await _switchEmbedding(
|
||||||
} = getState();
|
prevAnnoMatrix,
|
||||||
const [annoMatrix, obsCrossfilter] = await _switchEmbedding(
|
prevCrossfilter,
|
||||||
prevAnnoMatrix,
|
newLayoutChoice
|
||||||
prevCrossfilter,
|
);
|
||||||
newLayoutChoice
|
dispatch({
|
||||||
);
|
type: "set layout choice",
|
||||||
dispatch({
|
layoutChoice: newLayoutChoice,
|
||||||
type: "set layout choice",
|
obsCrossfilter,
|
||||||
layoutChoice: newLayoutChoice,
|
annoMatrix,
|
||||||
obsCrossfilter,
|
});
|
||||||
annoMatrix,
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|||||||
+102
-98
@@ -1,3 +1,4 @@
|
|||||||
|
import type { Config } from "../globals";
|
||||||
import * as globals from "../globals";
|
import * as globals from "../globals";
|
||||||
import { AnnoMatrixLoader, AnnoMatrixObsCrossfilter } from "../annoMatrix";
|
import { AnnoMatrixLoader, AnnoMatrixObsCrossfilter } from "../annoMatrix";
|
||||||
import {
|
import {
|
||||||
@@ -11,6 +12,9 @@ import * as annoActions from "./annotation";
|
|||||||
import * as viewActions from "./viewStack";
|
import * as viewActions from "./viewStack";
|
||||||
import * as embActions from "./embedding";
|
import * as embActions from "./embedding";
|
||||||
import * as genesetActions from "./geneset";
|
import * as genesetActions from "./geneset";
|
||||||
|
import { AppDispatch, RootState } from "../reducers";
|
||||||
|
import { EmbeddingSchema, Schema } from "../common/types/schema";
|
||||||
|
import { UserInfoPayload } from "../reducers/userInfo";
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
||||||
function setGlobalConfig(config: any) {
|
function setGlobalConfig(config: any) {
|
||||||
@@ -36,35 +40,34 @@ async function userColorsFetchAndLoad(dispatch: any) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function schemaFetch() {
|
async function schemaFetch(): Promise<{ schema: Schema }> {
|
||||||
return fetchJson("schema");
|
return fetchJson<{ schema: Schema }>("schema");
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
async function configFetch(dispatch: AppDispatch): Promise<Config> {
|
||||||
async function configFetch(dispatch: any) {
|
const response = await fetchJson<{ config: globals.Config }>("config");
|
||||||
return fetchJson("config").then((response) => {
|
const config = { ...globals.configDefaults, ...response.config };
|
||||||
const config = { ...globals.configDefaults, ...response.config };
|
|
||||||
|
|
||||||
setGlobalConfig(config);
|
setGlobalConfig(config);
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: "configuration load complete",
|
type: "configuration load complete",
|
||||||
config,
|
config,
|
||||||
});
|
|
||||||
return config;
|
|
||||||
});
|
});
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
async function userInfoFetch(dispatch: AppDispatch): Promise<UserInfoPayload> {
|
||||||
async function userInfoFetch(dispatch: any) {
|
return fetchJson<{ userinfo: UserInfoPayload }>("userinfo").then(
|
||||||
return fetchJson("userinfo").then((response) => {
|
(response) => {
|
||||||
const { userinfo: userInfo } = response || {};
|
const { userinfo: userInfo } = response || {};
|
||||||
dispatch({
|
dispatch({
|
||||||
type: "userInfo load complete",
|
type: "userInfo load complete",
|
||||||
userInfo,
|
userInfo,
|
||||||
});
|
});
|
||||||
return userInfo;
|
return userInfo;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
||||||
@@ -104,17 +107,17 @@ function prefetchEmbeddings(annoMatrix: any) {
|
|||||||
/*
|
/*
|
||||||
Application bootstrap
|
Application bootstrap
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
const doInitialDataLoad = (): ((
|
||||||
const doInitialDataLoad = () =>
|
dispatch: AppDispatch,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
getState: () => RootState
|
||||||
catchErrorsWrap(async (dispatch: any) => {
|
) => void) =>
|
||||||
|
catchErrorsWrap(async (dispatch: AppDispatch) => {
|
||||||
dispatch({ type: "initial data load start" });
|
dispatch({ type: "initial data load start" });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [config, schema] = await Promise.all([
|
const [config, schema] = await Promise.all([
|
||||||
configFetch(dispatch),
|
configFetch(dispatch),
|
||||||
// @ts-expect-error ts-migrate(2554) FIXME: Expected 0 arguments, but got 1.
|
schemaFetch(),
|
||||||
schemaFetch(dispatch),
|
|
||||||
userColorsFetchAndLoad(dispatch),
|
userColorsFetchAndLoad(dispatch),
|
||||||
userInfoFetch(dispatch),
|
userInfoFetch(dispatch),
|
||||||
]);
|
]);
|
||||||
@@ -137,8 +140,7 @@ const doInitialDataLoad = () =>
|
|||||||
const layoutSchema = schema?.schema?.layout?.obs ?? [];
|
const layoutSchema = schema?.schema?.layout?.obs ?? [];
|
||||||
if (
|
if (
|
||||||
defaultEmbedding &&
|
defaultEmbedding &&
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
layoutSchema.some((s: EmbeddingSchema) => s.name === defaultEmbedding)
|
||||||
layoutSchema.some((s: any) => s.name === defaultEmbedding)
|
|
||||||
) {
|
) {
|
||||||
dispatch(embActions.layoutChoiceAction(defaultEmbedding));
|
dispatch(embActions.layoutChoiceAction(defaultEmbedding));
|
||||||
}
|
}
|
||||||
@@ -188,87 +190,89 @@ const dispatchDiffExpErrors = (dispatch: any, response: any) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const requestDifferentialExpression = (
|
const requestDifferentialExpression =
|
||||||
|
(
|
||||||
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
||||||
|
set1: any,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
||||||
|
set2: any,
|
||||||
|
num_genes = 50
|
||||||
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
||||||
|
) =>
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
||||||
set1: any,
|
async (dispatch: any, getState: any) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
dispatch({ type: "request differential expression started" });
|
||||||
set2: any,
|
try {
|
||||||
num_genes = 50
|
/*
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
|
||||||
) => async (dispatch: any, getState: any) => {
|
|
||||||
dispatch({ type: "request differential expression started" });
|
|
||||||
try {
|
|
||||||
/*
|
|
||||||
Steps:
|
Steps:
|
||||||
1. get the most differentially expressed genes
|
1. get the most differentially expressed genes
|
||||||
2. get expression data for each
|
2. get expression data for each
|
||||||
*/
|
*/
|
||||||
const { annoMatrix } = getState();
|
const { annoMatrix } = getState();
|
||||||
const varIndexName = annoMatrix.schema.annotations.var.index;
|
const varIndexName = annoMatrix.schema.annotations.var.index;
|
||||||
|
|
||||||
// Legal values are null, Array or TypedArray. Null is initial state.
|
// Legal values are null, Array or TypedArray. Null is initial state.
|
||||||
if (!set1) set1 = [];
|
if (!set1) set1 = [];
|
||||||
if (!set2) set2 = [];
|
if (!set2) set2 = [];
|
||||||
|
|
||||||
// These lines ensure that we convert any TypedArray to an Array.
|
// These lines ensure that we convert any TypedArray to an Array.
|
||||||
// This is necessary because JSON.stringify() does some very strange
|
// This is necessary because JSON.stringify() does some very strange
|
||||||
// things with TypedArrays (they are marshalled to JSON objects, rather
|
// things with TypedArrays (they are marshalled to JSON objects, rather
|
||||||
// than being marshalled as a JSON array).
|
// than being marshalled as a JSON array).
|
||||||
set1 = Array.isArray(set1) ? set1 : Array.from(set1);
|
set1 = Array.isArray(set1) ? set1 : Array.from(set1);
|
||||||
set2 = Array.isArray(set2) ? set2 : Array.from(set2);
|
set2 = Array.isArray(set2) ? set2 : Array.from(set2);
|
||||||
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${globals.API.prefix}${globals.API.version}diffexp/obs`,
|
`${globals.API.prefix}${globals.API.version}diffexp/obs`,
|
||||||
{
|
{
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: new Headers({
|
headers: new Headers({
|
||||||
Accept: "application/json",
|
Accept: "application/json",
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
}),
|
}),
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
mode: "topN",
|
mode: "topN",
|
||||||
count: num_genes,
|
count: num_genes,
|
||||||
set1: { filter: { obs: { index: set1 } } },
|
set1: { filter: { obs: { index: set1 } } },
|
||||||
set2: { filter: { obs: { index: set2 } } },
|
set2: { filter: { obs: { index: set2 } } },
|
||||||
}),
|
}),
|
||||||
credentials: "include",
|
credentials: "include",
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!res.ok || res.headers.get("Content-Type") !== "application/json") {
|
||||||
|
return dispatchDiffExpErrors(dispatch, res);
|
||||||
}
|
}
|
||||||
);
|
|
||||||
|
|
||||||
if (!res.ok || res.headers.get("Content-Type") !== "application/json") {
|
const response = await res.json();
|
||||||
return dispatchDiffExpErrors(dispatch, res);
|
const varIndex = await annoMatrix.fetch("var", varIndexName);
|
||||||
|
const diffexpLists = { negative: [], positive: [] };
|
||||||
|
for (const polarity of Object.keys(diffexpLists)) {
|
||||||
|
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
||||||
|
diffexpLists[polarity] = response[polarity].map((v: any) => [
|
||||||
|
varIndex.at(v[0], varIndexName),
|
||||||
|
...v.slice(1),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* then send the success case action through */
|
||||||
|
return dispatch({
|
||||||
|
type: "request differential expression success",
|
||||||
|
data: diffexpLists,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return dispatch({
|
||||||
|
type: "request differential expression error",
|
||||||
|
error,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const response = await res.json();
|
function fetchJson<T>(pathAndQuery: string): Promise<T> {
|
||||||
const varIndex = await annoMatrix.fetch("var", varIndexName);
|
return doJsonRequest<T>(
|
||||||
const diffexpLists = { negative: [], positive: [] };
|
|
||||||
for (const polarity of Object.keys(diffexpLists)) {
|
|
||||||
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
||||||
diffexpLists[polarity] = response[polarity].map((v: any) => [
|
|
||||||
varIndex.at(v[0], varIndexName),
|
|
||||||
...v.slice(1),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* then send the success case action through */
|
|
||||||
return dispatch({
|
|
||||||
type: "request differential expression success",
|
|
||||||
data: diffexpLists,
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
return dispatch({
|
|
||||||
type: "request differential expression error",
|
|
||||||
error,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
||||||
function fetchJson(pathAndQuery: any) {
|
|
||||||
return doJsonRequest(
|
|
||||||
`${globals.API.prefix}${globals.API.version}${pathAndQuery}`
|
`${globals.API.prefix}${globals.API.version}${pathAndQuery}`
|
||||||
);
|
) as Promise<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|||||||
@@ -80,10 +80,10 @@ export function normalizeWritableCategoricalSchema(
|
|||||||
) {
|
) {
|
||||||
/*
|
/*
|
||||||
Ensure all enum writable / categorical schema have a categories array, that
|
Ensure all enum writable / categorical schema have a categories array, that
|
||||||
the categories array contains all unique values in the data array, AND that
|
the categories array contains all unique values in the data array, AND that
|
||||||
the array is UI sorted.
|
the array is UI sorted.
|
||||||
*/
|
*/
|
||||||
const categorySet = new Set(
|
const categorySet = new Set<string>(
|
||||||
col.summarizeCategorical().categories.concat(colSchema.categories ?? [])
|
col.summarizeCategorical().categories.concat(colSchema.categories ?? [])
|
||||||
);
|
);
|
||||||
if (!categorySet.has(unassignedCategoryLabel)) {
|
if (!categorySet.has(unassignedCategoryLabel)) {
|
||||||
@@ -118,7 +118,7 @@ export function normalizeCategorical(
|
|||||||
|
|
||||||
// consolidate all categories from data and schema into a single list
|
// consolidate all categories from data and schema into a single list
|
||||||
const colDataSummary = col.summarizeCategorical();
|
const colDataSummary = col.summarizeCategorical();
|
||||||
const allCategories = new Set(
|
const allCategories = new Set<string>(
|
||||||
colDataSummary.categories.concat(colSchema.categories ?? [])
|
colDataSummary.categories.concat(colSchema.categories ?? [])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
export type TypedArray =
|
export type TypedArray =
|
||||||
| Int8Array
|
| Int8Array
|
||||||
| Uint8Array
|
| Uint8Array
|
||||||
|
| Uint8ClampedArray
|
||||||
| Int16Array
|
| Int16Array
|
||||||
| Uint16Array
|
| Uint16Array
|
||||||
| Int32Array
|
| Int32Array
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { useEffect, useRef, useState } from "react";
|
|||||||
import { interpolateCool } from "d3-scale-chromatic";
|
import { interpolateCool } from "d3-scale-chromatic";
|
||||||
import * as d3 from "d3";
|
import * as d3 from "d3";
|
||||||
|
|
||||||
|
import { AxisDomain } from "d3";
|
||||||
import maybeScientific from "../../util/maybeScientific";
|
import maybeScientific from "../../util/maybeScientific";
|
||||||
import clamp from "../../util/clamp";
|
import clamp from "../../util/clamp";
|
||||||
|
|
||||||
@@ -120,8 +121,12 @@ const Histogram = ({
|
|||||||
d3
|
d3
|
||||||
.axisBottom(x)
|
.axisBottom(x)
|
||||||
.ticks(4)
|
.ticks(4)
|
||||||
// @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call.
|
.tickFormat(
|
||||||
.tickFormat(d3.format(maybeScientific(x)))
|
d3.format(maybeScientific(x)) as (
|
||||||
|
dv: AxisDomain,
|
||||||
|
i: number
|
||||||
|
) => string
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
/* Y AXIS */
|
/* Y AXIS */
|
||||||
|
|||||||
@@ -26,8 +26,10 @@ export const keepAroundErrorToast = (message: any) =>
|
|||||||
/*
|
/*
|
||||||
a hard network error
|
a hard network error
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export const postNetworkErrorToast = (
|
||||||
export const postNetworkErrorToast = (message: any, key = undefined) =>
|
message: string,
|
||||||
|
key: string | undefined = undefined
|
||||||
|
): string =>
|
||||||
ToastTopCenter.show(
|
ToastTopCenter.show(
|
||||||
{
|
{
|
||||||
message,
|
message,
|
||||||
|
|||||||
+14
-1
@@ -8,11 +8,24 @@ export const overflowCategoryLabel = ": all other labels";
|
|||||||
/* default "unassigned" value for user-created categorical metadata */
|
/* default "unassigned" value for user-created categorical metadata */
|
||||||
export const unassignedCategoryLabel = "unassigned";
|
export const unassignedCategoryLabel = "unassigned";
|
||||||
|
|
||||||
|
/* rough shape of config object */
|
||||||
|
export interface Config {
|
||||||
|
features: Record<string, unknown>;
|
||||||
|
displayNames: Record<string, unknown>;
|
||||||
|
parameters: {
|
||||||
|
"disable-diffexp"?: boolean;
|
||||||
|
"diffexp-may-be-slow"?: boolean;
|
||||||
|
default_embedding?: string;
|
||||||
|
[key: string]: unknown;
|
||||||
|
};
|
||||||
|
links: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
these are default values for configuration the CLI may supply.
|
these are default values for configuration the CLI may supply.
|
||||||
See the REST API and CLI specs for more info.
|
See the REST API and CLI specs for more info.
|
||||||
*/
|
*/
|
||||||
export const configDefaults = {
|
export const configDefaults: Config = {
|
||||||
features: {},
|
features: {},
|
||||||
displayNames: {},
|
displayNames: {},
|
||||||
parameters: {
|
parameters: {
|
||||||
|
|||||||
@@ -1,7 +1,23 @@
|
|||||||
|
import type { Action } from "redux";
|
||||||
|
|
||||||
import { makeContinuousDimensionName } from "../util/nameCreators";
|
import { makeContinuousDimensionName } from "../util/nameCreators";
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
import type { ContinuousNamespace } from "../util/nameCreators";
|
||||||
const ContinuousSelection = (state = {}, action: any) => {
|
|
||||||
|
export interface ContinuousSelectionAction extends Action<string> {
|
||||||
|
continuousNamespace: ContinuousNamespace;
|
||||||
|
selection: string;
|
||||||
|
range: [number, number];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ContinuousSelectionState {
|
||||||
|
[name: string]: [number, number];
|
||||||
|
}
|
||||||
|
|
||||||
|
const ContinuousSelection = (
|
||||||
|
state: ContinuousSelectionState = {},
|
||||||
|
action: ContinuousSelectionAction
|
||||||
|
): ContinuousSelectionState => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case "reset subset":
|
case "reset subset":
|
||||||
case "subset to selection":
|
case "subset to selection":
|
||||||
@@ -25,7 +41,6 @@ const ContinuousSelection = (state = {}, action: any) => {
|
|||||||
action.continuousNamespace,
|
action.continuousNamespace,
|
||||||
action.selection
|
action.selection
|
||||||
);
|
);
|
||||||
// @ts-expect-error ts-migrate(2537) FIXME: Type '{}' has no matching index signature for type... Remove this comment to see the full error message
|
|
||||||
const { [name]: deletedField, ...newState } = state;
|
const { [name]: deletedField, ...newState } = state;
|
||||||
return newState;
|
return newState;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { createStore, applyMiddleware } from "redux";
|
import { createStore, applyMiddleware, AnyAction } from "redux";
|
||||||
import thunk from "redux-thunk";
|
import thunk, { ThunkDispatch } from "redux-thunk";
|
||||||
|
|
||||||
import cascadeReducers from "./cascade";
|
import cascadeReducers from "./cascade";
|
||||||
import undoable from "./undoable";
|
import undoable from "./undoable";
|
||||||
@@ -63,4 +63,8 @@ const Reducer = undoable(
|
|||||||
|
|
||||||
const store = createStore(Reducer, applyMiddleware(thunk, annoMatrixGC));
|
const store = createStore(Reducer, applyMiddleware(thunk, annoMatrixGC));
|
||||||
|
|
||||||
|
export type RootState = ReturnType<typeof store.getState>;
|
||||||
|
|
||||||
|
export type AppDispatch = ThunkDispatch<RootState, never, AnyAction>;
|
||||||
|
|
||||||
export default store;
|
export default store;
|
||||||
|
|||||||
@@ -1,5 +1,27 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
import { Action } from "redux";
|
||||||
const UserInfo = (state = {}, action: any) => {
|
|
||||||
|
export interface UserInfoAction extends Action<string>, User {
|
||||||
|
userInfo: UserInfoPayload;
|
||||||
|
error: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserInfoPayload {
|
||||||
|
is_authenticated: boolean;
|
||||||
|
username: string;
|
||||||
|
user_id: string;
|
||||||
|
email: string;
|
||||||
|
picture: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface UserInfoState extends UserInfoPayload {
|
||||||
|
loading: boolean;
|
||||||
|
error: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const UserInfo = (
|
||||||
|
state: UserInfoState,
|
||||||
|
action: UserInfoAction
|
||||||
|
): UserInfoState => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case "initial data load start":
|
case "initial data load start":
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
import sortBy from "lodash.sortby";
|
import sortBy from "lodash.sortby";
|
||||||
/* XXX: cough, cough, ... */
|
/* XXX: cough, cough, ... */
|
||||||
import { postNetworkErrorToast } from "../components/framework/toasters";
|
import { postNetworkErrorToast } from "../components/framework/toasters";
|
||||||
|
import type { AppDispatch, RootState } from "../reducers";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
dispatch an action error to the user. Currently we use
|
dispatch an action error to the user. Currently we use
|
||||||
async toasts.
|
async toasts.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
let networkErrorToastKey: string | null = null;
|
||||||
let networkErrorToastKey: any = null;
|
export const dispatchNetworkErrorMessageToUser = (message: string): void => {
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
|
||||||
export const dispatchNetworkErrorMessageToUser = (message: any) => {
|
|
||||||
if (!networkErrorToastKey) {
|
if (!networkErrorToastKey) {
|
||||||
networkErrorToastKey = postNetworkErrorToast(message);
|
networkErrorToastKey = postNetworkErrorToast(message);
|
||||||
} else {
|
} else {
|
||||||
@@ -20,12 +19,12 @@ export const dispatchNetworkErrorMessageToUser = (message: any) => {
|
|||||||
/*
|
/*
|
||||||
Catch unexpected errors and make sure we don't lose them!
|
Catch unexpected errors and make sure we don't lose them!
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export function catchErrorsWrap(
|
||||||
export function catchErrorsWrap(fn: any, dispatchToUser = false) {
|
fn: (dispatch: AppDispatch, getState: () => RootState) => Promise<void>,
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
dispatchToUser = false
|
||||||
return (dispatch: any, getState: any) => {
|
) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
return (dispatch: AppDispatch, getState: () => RootState): void => {
|
||||||
fn(dispatch, getState).catch((error: any) => {
|
fn(dispatch, getState).catch((error: Error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
if (dispatchToUser) {
|
if (dispatchToUser) {
|
||||||
dispatchNetworkErrorMessageToUser(error.message);
|
dispatchNetworkErrorMessageToUser(error.message);
|
||||||
@@ -39,8 +38,10 @@ export function catchErrorsWrap(fn: any, dispatchToUser = false) {
|
|||||||
* Wrapper to perform async fetch with some modest error handling
|
* Wrapper to perform async fetch with some modest error handling
|
||||||
* and decoding. Arguments are identical to standard fetch.
|
* and decoding. Arguments are identical to standard fetch.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export const doFetch = async (
|
||||||
export const doFetch = async (url: any, init = {}) => {
|
url: string,
|
||||||
|
init?: RequestInit
|
||||||
|
): Promise<Response> => {
|
||||||
try {
|
try {
|
||||||
// add defaults to the fetch init param.
|
// add defaults to the fetch init param.
|
||||||
init = {
|
init = {
|
||||||
@@ -48,13 +49,11 @@ export const doFetch = async (url: any, init = {}) => {
|
|||||||
credentials: "include",
|
credentials: "include",
|
||||||
...init,
|
...init,
|
||||||
};
|
};
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
const acceptType = (init.headers as Headers)?.get("Accept");
|
||||||
const acceptType = (init as any).headers?.get("Accept");
|
|
||||||
const res = await fetch(url, init);
|
const res = await fetch(url, init);
|
||||||
if (
|
if (
|
||||||
res.ok &&
|
res.ok &&
|
||||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
(!acceptType || res.headers?.get("Content-Type")?.includes(acceptType))
|
||||||
(!acceptType || res.headers.get("Content-Type").includes(acceptType))
|
|
||||||
) {
|
) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -74,8 +73,10 @@ export const doFetch = async (url: any, init = {}) => {
|
|||||||
/*
|
/*
|
||||||
Wrapper to perform an async fetch and JSON decode response.
|
Wrapper to perform an async fetch and JSON decode response.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export const doJsonRequest = async <T = unknown>(
|
||||||
export const doJsonRequest = async (url: any, init = {}) => {
|
url: string,
|
||||||
|
init?: RequestInit
|
||||||
|
): Promise<T> => {
|
||||||
const res = await doFetch(url, {
|
const res = await doFetch(url, {
|
||||||
...init,
|
...init,
|
||||||
headers: new Headers({ Accept: "application/json" }),
|
headers: new Headers({ Accept: "application/json" }),
|
||||||
@@ -86,8 +87,10 @@ export const doJsonRequest = async (url: any, init = {}) => {
|
|||||||
/*
|
/*
|
||||||
Wrapper to perform an async fetch for binary data.
|
Wrapper to perform an async fetch for binary data.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export const doBinaryRequest = async (
|
||||||
export const doBinaryRequest = async (url: any, init = {}) => {
|
url: string,
|
||||||
|
init?: RequestInit
|
||||||
|
): Promise<ArrayBuffer> => {
|
||||||
const res = await doFetch(url, {
|
const res = await doFetch(url, {
|
||||||
...init,
|
...init,
|
||||||
headers: new Headers({ Accept: "application/octet-stream" }),
|
headers: new Headers({ Accept: "application/octet-stream" }),
|
||||||
@@ -110,13 +113,11 @@ Parameters:
|
|||||||
|
|
||||||
So [1, 2, 3, 4, 10, 11, 14] -> [ [1, 4], [10, 11], 14]
|
So [1, 2, 3, 4, 10, 11, 14] -> [ [1, 4], [10, 11], 14]
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
|
||||||
export const rangeEncodeIndices = (
|
export const rangeEncodeIndices = (
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
indices: Array<number>,
|
||||||
indices: any,
|
|
||||||
minRangeLength = 3,
|
minRangeLength = 3,
|
||||||
sorted = false
|
sorted = false
|
||||||
) => {
|
): Array<number | [number, number]> => {
|
||||||
if (indices.length === 0) {
|
if (indices.length === 0) {
|
||||||
return indices;
|
return indices;
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-39
@@ -1,4 +1,5 @@
|
|||||||
import { vec2, mat3 } from "gl-matrix";
|
import { vec2, mat3 } from "gl-matrix";
|
||||||
|
import clamp from "./clamp";
|
||||||
|
|
||||||
const EPSILON = 0.000001;
|
const EPSILON = 0.000001;
|
||||||
|
|
||||||
@@ -11,56 +12,49 @@ const panBound = 0.8;
|
|||||||
const scratch0 = new Float32Array(16);
|
const scratch0 = new Float32Array(16);
|
||||||
const scratch1 = new Float32Array(16);
|
const scratch1 = new Float32Array(16);
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
||||||
function clamp(val: any, rng: any) {
|
|
||||||
return Math.max(Math.min(val, rng[1]), rng[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
class Camera {
|
class Camera {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
canvas: HTMLCanvasElement;
|
||||||
canvas: any;
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
prevEvent: {
|
||||||
prevEvent: any;
|
clientX: number;
|
||||||
|
clientY: number;
|
||||||
|
type: string;
|
||||||
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
viewMatrix: mat3;
|
||||||
viewMatrix: any;
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
viewMatrixInv: mat3;
|
||||||
viewMatrixInv: any;
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
constructor(canvas: HTMLCanvasElement) {
|
||||||
constructor(canvas: any) {
|
|
||||||
this.prevEvent = {
|
this.prevEvent = {
|
||||||
clientX: 0,
|
clientX: 0,
|
||||||
clientY: 0,
|
clientY: 0,
|
||||||
type: 0,
|
type: "",
|
||||||
};
|
};
|
||||||
this.canvas = canvas;
|
this.canvas = canvas;
|
||||||
this.viewMatrix = mat3.create();
|
this.viewMatrix = mat3.create();
|
||||||
this.viewMatrixInv = mat3.create();
|
this.viewMatrixInv = mat3.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
view() {
|
view(): mat3 {
|
||||||
return this.viewMatrix;
|
return this.viewMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
invView() {
|
invView(): mat3 {
|
||||||
return this.viewMatrixInv;
|
return this.viewMatrixInv;
|
||||||
}
|
}
|
||||||
|
|
||||||
distance() {
|
distance(): number {
|
||||||
return this.viewMatrix[0];
|
return this.viewMatrix[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
pan(dx: number, dy: number): void {
|
||||||
pan(dx: any, dy: any) {
|
|
||||||
const m = this.viewMatrix;
|
const m = this.viewMatrix;
|
||||||
const dyRange = [
|
const dyRange: [number, number] = [
|
||||||
-panBound - (m[7] + 1) / m[4],
|
-panBound - (m[7] + 1) / m[4],
|
||||||
panBound - (m[7] - 1) / m[4],
|
panBound - (m[7] - 1) / m[4],
|
||||||
];
|
];
|
||||||
const dxRange = [
|
const dxRange: [number, number] = [
|
||||||
-panBound - (m[6] + 1) / m[0],
|
-panBound - (m[6] + 1) / m[0],
|
||||||
panBound - (m[6] - 1) / m[0],
|
panBound - (m[6] - 1) / m[0],
|
||||||
];
|
];
|
||||||
@@ -74,13 +68,12 @@ class Camera {
|
|||||||
mat3.invert(this.viewMatrixInv, m);
|
mat3.invert(this.viewMatrixInv, m);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
zoomAt(d: number, x = 0, y = 0): void {
|
||||||
zoomAt(d: any, x = 0, y = 0) {
|
|
||||||
/*
|
/*
|
||||||
Camera zoom at [x,y]
|
Camera zoom at [x,y]
|
||||||
*/
|
*/
|
||||||
const m = this.viewMatrix;
|
const m = this.viewMatrix;
|
||||||
const bounds = [-panBound, panBound];
|
const bounds: [number, number] = [-panBound, panBound];
|
||||||
x = clamp(x, bounds);
|
x = clamp(x, bounds);
|
||||||
y = clamp(y, bounds);
|
y = clamp(y, bounds);
|
||||||
|
|
||||||
@@ -98,15 +91,18 @@ class Camera {
|
|||||||
Event handling
|
Event handling
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
flush(e: MouseEvent) {
|
||||||
flush(e: any) {
|
|
||||||
this.prevEvent.type = e.type;
|
this.prevEvent.type = e.type;
|
||||||
this.prevEvent.clientX = e.clientX;
|
this.prevEvent.clientX = e.clientX;
|
||||||
this.prevEvent.clientY = e.clientY;
|
this.prevEvent.clientY = e.clientY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
localPosition(
|
||||||
localPosition(target: any, canvasX: any, canvasY: any, projectionInvTF: any) {
|
target: HTMLCanvasElement,
|
||||||
|
canvasX: number,
|
||||||
|
canvasY: number,
|
||||||
|
projectionInvTF: mat3
|
||||||
|
): vec2 {
|
||||||
/*
|
/*
|
||||||
Convert mouse position to local
|
Convert mouse position to local
|
||||||
*/
|
*/
|
||||||
@@ -126,8 +122,7 @@ class Camera {
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
mousePan(e: MouseEvent, projectionTF: mat3): true {
|
||||||
mousePan(e: any, projectionTF: any) {
|
|
||||||
const projectionInvTF = mat3.invert(scratch0, projectionTF);
|
const projectionInvTF = mat3.invert(scratch0, projectionTF);
|
||||||
const pos = this.localPosition(
|
const pos = this.localPosition(
|
||||||
this.canvas,
|
this.canvas,
|
||||||
@@ -147,8 +142,7 @@ class Camera {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
wheelZoom(e: WheelEvent, projectionTF: mat3): true {
|
||||||
wheelZoom(e: any, projectionTF: any) {
|
|
||||||
const { height } = this.canvas;
|
const { height } = this.canvas;
|
||||||
const { deltaY, deltaMode, clientX, clientY } = e;
|
const { deltaY, deltaMode, clientX, clientY } = e;
|
||||||
const scale = scaleSpeed * (deltaMode === 1 ? 12 : 1) * (deltaY || 0);
|
const scale = scaleSpeed * (deltaMode === 1 ? 12 : 1) * (deltaY || 0);
|
||||||
@@ -164,8 +158,7 @@ class Camera {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
handleEvent(e: MouseEvent, projectionTF: mat3): boolean {
|
||||||
handleEvent(e: any, projectionTF: any) {
|
|
||||||
/*
|
/*
|
||||||
process the event, and return true if camera view changed
|
process the event, and return true if camera view changed
|
||||||
*/
|
*/
|
||||||
@@ -181,7 +174,7 @@ class Camera {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "wheel": {
|
case "wheel": {
|
||||||
viewChanged = this.wheelZoom(e, projectionTF);
|
viewChanged = this.wheelZoom(e as WheelEvent, projectionTF);
|
||||||
this.flush(e);
|
this.flush(e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -194,8 +187,7 @@ class Camera {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
function attachCamera(canvas: HTMLCanvasElement): Camera {
|
||||||
function attachCamera(canvas: any) {
|
|
||||||
return new Camera(canvas);
|
return new Camera(canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,24 +11,23 @@ TL;DR: sort order is:
|
|||||||
import isNumber from "is-number";
|
import isNumber from "is-number";
|
||||||
import * as globals from "../globals";
|
import * as globals from "../globals";
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
function caseInsensitiveCompare(a: string, b: string): number {
|
||||||
function caseInsensitiveCompare(a: any, b: any) {
|
|
||||||
const textA = String(a).toUpperCase();
|
const textA = String(a).toUpperCase();
|
||||||
const textB = String(b).toUpperCase();
|
const textB = String(b).toUpperCase();
|
||||||
return textA < textB ? -1 : textA > textB ? 1 : 0;
|
return textA < textB ? -1 : textA > textB ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
const catLabelSort = (
|
||||||
const catLabelSort = (isUserAnno: boolean, values: any[]): any[] => {
|
isUserAnno: boolean,
|
||||||
|
values: Array<string>
|
||||||
|
): Array<string> => {
|
||||||
/* this sort could be memoized for perf */
|
/* this sort could be memoized for perf */
|
||||||
|
|
||||||
const strings: string[] = [];
|
const strings: string[] = [];
|
||||||
const ints: number[] = [];
|
const ints: string[] = [];
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
const unassignedOrNaN: string[] = [];
|
||||||
const unassignedOrNaN: any = [];
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
values.forEach((v: string) => {
|
||||||
values.forEach((v: any) => {
|
|
||||||
if (isUserAnno && v === globals.unassignedCategoryLabel) {
|
if (isUserAnno && v === globals.unassignedCategoryLabel) {
|
||||||
unassignedOrNaN.push(v);
|
unassignedOrNaN.push(v);
|
||||||
} else if (String(v).toLowerCase() === "nan") {
|
} else if (String(v).toLowerCase() === "nan") {
|
||||||
@@ -44,8 +43,7 @@ const catLabelSort = (isUserAnno: boolean, values: any[]): any[] => {
|
|||||||
ints.sort((a, b) => +a - +b);
|
ints.sort((a, b) => +a - +b);
|
||||||
unassignedOrNaN.sort(caseInsensitiveCompare);
|
unassignedOrNaN.sort(caseInsensitiveCompare);
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
return ints.concat(strings, unassignedOrNaN);
|
||||||
return (<any>ints).concat(strings, unassignedOrNaN);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default catLabelSort;
|
export default catLabelSort;
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ label -> {
|
|||||||
const getCoordinatesByLabel = (
|
const getCoordinatesByLabel = (
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
||||||
schema: any,
|
schema: any,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
categoryName: string,
|
||||||
categoryName: any,
|
|
||||||
categoryDf: Dataframe,
|
categoryDf: Dataframe,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
||||||
layoutChoice: any,
|
layoutChoice: any,
|
||||||
@@ -73,7 +72,7 @@ const getCoordinatesByLabel = (
|
|||||||
let coords = coordsByCategoryLabel.get(label);
|
let coords = coordsByCategoryLabel.get(label);
|
||||||
if (coords === undefined) {
|
if (coords === undefined) {
|
||||||
// Get the number of cells which are in the label
|
// Get the number of cells which are in the label
|
||||||
// @ts-expect-error ts-migrate(2538) FIXME: Type 'unknown' cannot be used as an index type.
|
// @ts-expect-error ts-migrate(2538) FIXME: Blocked by StateManager/ControlsHelpers
|
||||||
const numInLabel = categoryValueCounts[labelIndex];
|
const numInLabel = categoryValueCounts[labelIndex];
|
||||||
coords = {
|
coords = {
|
||||||
hasFinite: false,
|
hasFinite: false,
|
||||||
@@ -99,7 +98,7 @@ const getCoordinatesByLabel = (
|
|||||||
return coordsByCategoryLabel;
|
return coordsByCategoryLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
calcMedianCentroid calculates the median coordinates for labels in a given category
|
calcMedianCentroid calculates the median coordinates for labels in a given category
|
||||||
|
|
||||||
label -> [x-Coordinate, y-Coordinate]
|
label -> [x-Coordinate, y-Coordinate]
|
||||||
@@ -108,8 +107,7 @@ const getCoordinatesByLabel = (
|
|||||||
const calcMedianCentroid = (
|
const calcMedianCentroid = (
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
||||||
schema: any,
|
schema: any,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
categoryName: string,
|
||||||
categoryName: any,
|
|
||||||
categoryDf: Dataframe,
|
categoryDf: Dataframe,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
||||||
layoutChoice: any,
|
layoutChoice: any,
|
||||||
@@ -151,8 +149,7 @@ const hashMedianCentroid = (
|
|||||||
// @ts-expect-error ts-migrate(6133) FIXME: 'schema' is declared but its value is never read.
|
// @ts-expect-error ts-migrate(6133) FIXME: 'schema' is declared but its value is never read.
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
||||||
schema: any,
|
schema: any,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
categoryName: string,
|
||||||
categoryName: any,
|
|
||||||
categoryDf: Dataframe,
|
categoryDf: Dataframe,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
||||||
layoutChoice: any,
|
layoutChoice: any,
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
* @returns a number
|
* @returns a number
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export default function clamp(val: number, rng: [number, number]): number {
|
||||||
export default function clamp(val: any, rng: any) {
|
|
||||||
return Math.max(Math.min(val, rng[1]), rng[0]);
|
return Math.max(Math.min(val, rng[1]), rng[0]);
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-4
@@ -1,17 +1,23 @@
|
|||||||
|
import { NumberArray } from "../common/types/arraytypes";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
clip - clip all values in a Array or TypedArray, IN PLACE.
|
clip - clip all values in a Array or TypedArray, IN PLACE.
|
||||||
|
|
||||||
Values in array are clipped if less than `lower` or greater than `upper`.
|
Values in array are clipped if less than `lower` or greater than `upper`.
|
||||||
|
|
||||||
If `setTo` is undefined, values less than `lower` will be set to `lower`,
|
If `setTo` is undefined, values less than `lower` will be set to `lower`,
|
||||||
and values greater than `upper` will be set to `upper`.
|
and values greater than `upper` will be set to `upper`.
|
||||||
|
|
||||||
If `setTo` is not undefined, values outside the [lower, upper] range will be set to
|
If `setTo` is not undefined, values outside the [lower, upper] range will be set to
|
||||||
`setTo`.
|
`setTo`.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export default function clip(
|
||||||
export default function clip(arr: any, lower: any, upper: any, setTo: any) {
|
arr: NumberArray,
|
||||||
|
lower: number,
|
||||||
|
upper: number,
|
||||||
|
setTo?: number
|
||||||
|
): NumberArray {
|
||||||
const lowerSet = setTo === undefined ? lower : setTo;
|
const lowerSet = setTo === undefined ? lower : setTo;
|
||||||
const upperSet = setTo === undefined ? upper : setTo;
|
const upperSet = setTo === undefined ? upper : setTo;
|
||||||
for (let i = 0, l = arr.length; i < l; i += 1) {
|
for (let i = 0, l = arr.length; i < l; i += 1) {
|
||||||
|
|||||||
@@ -6,8 +6,11 @@ If undefined or empty array, or array contains only non-finite numbers,
|
|||||||
will return [undefined, undefined]
|
will return [undefined, undefined]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
import type { TypedArray } from "../common/types/arraytypes";
|
||||||
function finiteExtent(tarr: any) {
|
|
||||||
|
function finiteExtent(
|
||||||
|
tarr: TypedArray
|
||||||
|
): [number, number] | [undefined, undefined] {
|
||||||
let min;
|
let min;
|
||||||
let max;
|
let max;
|
||||||
let i;
|
let i;
|
||||||
@@ -21,14 +24,17 @@ function finiteExtent(tarr: any) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (; i < tarr.length; i += 1) {
|
if (min !== undefined && max !== undefined) {
|
||||||
const val = tarr[i];
|
for (; i < tarr.length; i += 1) {
|
||||||
if (Number.isFinite(val)) {
|
const val = tarr[i];
|
||||||
if (min > val) min = val;
|
if (Number.isFinite(val)) {
|
||||||
if (max < val) max = val;
|
if (min > val) min = val;
|
||||||
|
if (max < val) max = val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return [min, max];
|
||||||
}
|
}
|
||||||
return [min, max];
|
return [undefined, undefined];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default finiteExtent;
|
export default finiteExtent;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { ScaleLinear } from "d3";
|
||||||
import significantDigits from "./significantDigits";
|
import significantDigits from "./significantDigits";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -10,14 +11,14 @@ import significantDigits from "./significantDigits";
|
|||||||
* @returns - the number formatted as scientific, if it's big enough
|
* @returns - the number formatted as scientific, if it's big enough
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export default function maybeScientific(
|
||||||
export default function maybeScientific(x: any) {
|
x: ScaleLinear<number, number, never>
|
||||||
|
): string {
|
||||||
let format = ",";
|
let format = ",";
|
||||||
const _ticks = x.ticks(4);
|
const _ticks = x.ticks(4);
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
if (x.domain().some((n: number) => Math.abs(n) >= 10000)) {
|
||||||
if (x.domain().some((n: any) => Math.abs(n) >= 10000)) {
|
/*
|
||||||
/*
|
|
||||||
heuristic: if the last tick d3 wants to render has one significant
|
heuristic: if the last tick d3 wants to render has one significant
|
||||||
digit ie., 2000, render 2e+3, but if it's anything else ie., 42000000 render
|
digit ie., 2000, render 2e+3, but if it's anything else ie., 42000000 render
|
||||||
4.20e+n
|
4.20e+n
|
||||||
|
|||||||
@@ -13,43 +13,40 @@ anno matrix namespaces. It is still used by the component tier.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
const makeDimensionName = (namespace: string, key: string): string =>
|
||||||
const makeDimensionName = (namespace: any, key: any) => `${namespace}_${key}`;
|
`${namespace}_${key}`;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export const layoutDimensionName = (key: string): string =>
|
||||||
export const layoutDimensionName = (key: any) =>
|
|
||||||
makeDimensionName("layout", key);
|
makeDimensionName("layout", key);
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
|
||||||
export const obsAnnoDimensionName = (key: any) =>
|
export const obsAnnoDimensionName = (key: string): string =>
|
||||||
makeDimensionName("obsAnno", key);
|
makeDimensionName("obsAnno", key);
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
|
||||||
export const diffexpDimensionName = (key: any) =>
|
export const diffexpDimensionName = (key: string): string =>
|
||||||
makeDimensionName("varData_diffexp", key);
|
makeDimensionName("varData_diffexp", key);
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
|
||||||
export const userDefinedDimensionName = (key: any) =>
|
export const userDefinedDimensionName = (key: string): string =>
|
||||||
makeDimensionName("varData_userDefined", key);
|
makeDimensionName("varData_userDefined", key);
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
|
||||||
export const geneSetSummaryDimensionName = (key: any) =>
|
export const geneSetSummaryDimensionName = (key: string): string =>
|
||||||
makeDimensionName("geneSetSummary", key);
|
makeDimensionName("geneSetSummary", key);
|
||||||
|
|
||||||
|
export interface ContinuousNamespace {
|
||||||
|
isObs?: boolean;
|
||||||
|
isDiffExp?: boolean;
|
||||||
|
isUserDefined?: boolean;
|
||||||
|
isGeneSetSummary?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
continuousNamespace = {
|
|
||||||
isObs: true,
|
|
||||||
isDiffExp: false,
|
|
||||||
isUserDefined: false,
|
|
||||||
isGeneSet: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
ie., makeContinuousDimensionName(continuousNamespace = {isObs: true}, "total_reads")
|
ie., makeContinuousDimensionName(continuousNamespace = {isObs: true}, "total_reads")
|
||||||
see: histogram brush, as it doesn't know what type of continuous it was with only field
|
see: histogram brush, as it doesn't know what type of continuous it was with only field
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
|
||||||
export const makeContinuousDimensionName = (
|
export const makeContinuousDimensionName = (
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
continuousNamespace: ContinuousNamespace,
|
||||||
continuousNamespace: any,
|
key: string
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
): string => {
|
||||||
key: any
|
|
||||||
) => {
|
|
||||||
let name;
|
let name;
|
||||||
if (continuousNamespace.isObs) {
|
if (continuousNamespace.isObs) {
|
||||||
name = obsAnnoDimensionName(key);
|
name = obsAnnoDimensionName(key);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
import pull from "lodash.pull";
|
import pull from "lodash.pull";
|
||||||
import uniq from "lodash.uniq";
|
import uniq from "lodash.uniq";
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export default function parseBulkGeneString(geneString: string): Array<string> {
|
||||||
export default function parseBulkGeneString(geneString: any) {
|
|
||||||
return pull(uniq(geneString.split(/[ ,]+/)), "");
|
return pull(uniq(geneString.split(/[ ,]+/)), "");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,32 +4,27 @@ import scaleRGB from "./scaleRGB";
|
|||||||
// to do this operation. This lets us have speed, but keep the pleasant ability
|
// to do this operation. This lets us have speed, but keep the pleasant ability
|
||||||
// to talk about colors by their text description eg, 'rgb(0,0,1)'
|
// to talk about colors by their text description eg, 'rgb(0,0,1)'
|
||||||
//
|
//
|
||||||
const colorCache = {};
|
const colorCache = {} as { [key: string]: [number, number, number] };
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
function parseColorName(c: string): [number, number, number] {
|
||||||
function parseColorName(c: any) {
|
|
||||||
if (c[0] !== "#") {
|
if (c[0] !== "#") {
|
||||||
const _c = c.replace(/[^\d,.]/g, "").split(",");
|
const _c = c.replace(/[^\d,.]/g, "").split(",");
|
||||||
return [scaleRGB(+_c[0]), scaleRGB(+_c[1]), scaleRGB(+_c[2])];
|
return [scaleRGB(+_c[0]), scaleRGB(+_c[1]), scaleRGB(+_c[2])];
|
||||||
}
|
}
|
||||||
const parsedHex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c);
|
const parsedHex = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(c);
|
||||||
|
if (!parsedHex || parsedHex.length < 4)
|
||||||
|
throw new Error(`Invalid hex color: ${c}`);
|
||||||
return [
|
return [
|
||||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
|
||||||
scaleRGB(parseInt(parsedHex[1], 16)),
|
scaleRGB(parseInt(parsedHex[1], 16)),
|
||||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
|
||||||
scaleRGB(parseInt(parsedHex[2], 16)),
|
scaleRGB(parseInt(parsedHex[2], 16)),
|
||||||
// @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'.
|
|
||||||
scaleRGB(parseInt(parsedHex[3], 16)),
|
scaleRGB(parseInt(parsedHex[3], 16)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export default (c: string): [number, number, number] => {
|
||||||
export default (c: any) => {
|
|
||||||
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
|
||||||
let cv = colorCache[c];
|
let cv = colorCache[c];
|
||||||
if (!cv) {
|
if (!cv) {
|
||||||
cv = parseColorName(c);
|
cv = parseColorName(c);
|
||||||
// @ts-expect-error ts-migrate(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
|
||||||
colorCache[c] = cv;
|
colorCache[c] = cv;
|
||||||
}
|
}
|
||||||
return cv;
|
return cv;
|
||||||
|
|||||||
@@ -28,37 +28,55 @@ Priority is a numeric value. Lower first. Stable ordering.
|
|||||||
|
|
||||||
import TinyQueue from "tinyqueue";
|
import TinyQueue from "tinyqueue";
|
||||||
|
|
||||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'a' implicitly has an 'any' type.
|
function compare<T>(
|
||||||
function compare(a, b) {
|
a: PromiseLimitQueueItem<T>,
|
||||||
|
b: PromiseLimitQueueItem<T>
|
||||||
|
): number {
|
||||||
const diff = a.priority - b.priority;
|
const diff = a.priority - b.priority;
|
||||||
if (diff) return diff;
|
if (diff) return diff;
|
||||||
return a.order - b.order;
|
return a.order - b.order;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class PromiseLimit {
|
interface PromiseLimitQueueItem<T> {
|
||||||
|
priority: number;
|
||||||
|
order: number;
|
||||||
|
resolve: (value: T | PromiseLike<T>) => void;
|
||||||
|
reject: (reason?: unknown) => void;
|
||||||
|
fn: (...args: Array<unknown>) => Promise<T>;
|
||||||
|
args: Array<unknown>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class PromiseLimit<T> {
|
||||||
|
queue: TinyQueue<PromiseLimitQueueItem<T>>;
|
||||||
|
|
||||||
|
maxConcurrency: number;
|
||||||
|
|
||||||
|
pending: number;
|
||||||
|
|
||||||
|
insertCounter: number;
|
||||||
|
|
||||||
constructor(maxConcurrency = 5) {
|
constructor(maxConcurrency = 5) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
this.queue = new TinyQueue<PromiseLimitQueueItem<T>>(
|
||||||
(this as any).queue = new TinyQueue([], compare);
|
new Array<PromiseLimitQueueItem<T>>(),
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
compare
|
||||||
(this as any).maxConcurrency = maxConcurrency;
|
);
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
this.maxConcurrency = maxConcurrency;
|
||||||
(this as any).pending = 0;
|
this.pending = 0;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
this.insertCounter = 0;
|
||||||
(this as any).insertCounter = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'p' implicitly has an 'any' type.
|
priorityAdd(
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
p: number,
|
||||||
priorityAdd(p, fn, ...args) {
|
fn: () => Promise<T>,
|
||||||
|
...args: Array<unknown>
|
||||||
|
): Promise<T> {
|
||||||
// p - numermic priority (lower first)
|
// p - numermic priority (lower first)
|
||||||
// fn - must return a promise
|
// fn - must return a promise
|
||||||
// args - will be passed to fn
|
// args - will be passed to fn
|
||||||
return this._push(p, fn, args);
|
return this._push(p, fn, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'fn' implicitly has an 'any' type.
|
add(fn: () => Promise<T>, ...args: Array<unknown>): Promise<T> {
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
|
||||||
add(fn, ...args) {
|
|
||||||
// fn - must return a promise
|
// fn - must return a promise
|
||||||
// args - will be passed to fn
|
// args - will be passed to fn
|
||||||
return this._push(0, fn, args);
|
return this._push(0, fn, args);
|
||||||
@@ -68,35 +86,25 @@ export default class PromiseLimit {
|
|||||||
Private below
|
Private below
|
||||||
**/
|
**/
|
||||||
|
|
||||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'priority' implicitly has an 'any' type.
|
_push(
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
priority: number,
|
||||||
_push(priority, fn, args) {
|
fn: () => Promise<T>,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
args: Array<unknown>
|
||||||
const order = (this as any).insertCount;
|
): Promise<T> {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
const order = this.insertCounter;
|
||||||
(this as any).insertCount += 1;
|
this.insertCounter += 1;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
this.queue.push({ priority, order, fn, args, resolve, reject });
|
||||||
(this as any).queue.push({ priority, order, fn, args, resolve, reject });
|
|
||||||
this._resolveNext(false);
|
this._resolveNext(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
_resolveNext = (completed = true): void => {
|
||||||
_resolveNext = (completed = true) => {
|
if (completed) this.pending -= 1;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
||||||
if (completed) (this as any).pending -= 1;
|
|
||||||
|
|
||||||
while (
|
while (this.queue.length > 0 && this.pending < this.maxConcurrency) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
const task = this.queue.pop() as PromiseLimitQueueItem<T>; // order of insertion
|
||||||
(this as any).queue.length > 0 &&
|
this.pending += 1;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
||||||
(this as any).pending < (this as any).maxConcurrency
|
|
||||||
) {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
||||||
const task = (this as any).queue.pop(); // order of insertion
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
|
||||||
(this as any).pending += 1;
|
|
||||||
const { resolve, reject, fn, args } = task;
|
const { resolve, reject, fn, args } = task;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
+21
-15
@@ -22,38 +22,44 @@ rangeFill(array, start, step) -> array
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'arr' implicitly has an 'any' type.
|
import { TypedArray, NumberArray } from "../common/types/arraytypes";
|
||||||
function _doFill(arr, start, step, count) {
|
|
||||||
|
function _doFill<T extends NumberArray>(
|
||||||
|
arr: T,
|
||||||
|
start: number,
|
||||||
|
step: number,
|
||||||
|
count: number
|
||||||
|
): T {
|
||||||
for (let idx = 0, val = start; idx < count; idx += 1, val += step) {
|
for (let idx = 0, val = start; idx < count; idx += 1, val += step) {
|
||||||
arr[idx] = val;
|
arr[idx] = val;
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'arr' implicitly has an 'any' type.
|
export function rangeFill(arr: NumberArray, start = 0, step = 1): NumberArray {
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
|
||||||
export function rangeFill(arr, start = 0, step = 1) {
|
|
||||||
return _doFill(arr, start, step, arr.length);
|
return _doFill(arr, start, step, arr.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'start' implicitly has an 'any' type.
|
export function range(
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
start: number,
|
||||||
export function range(start, stop, step) {
|
stop?: number,
|
||||||
|
step?: number
|
||||||
|
): Array<number> {
|
||||||
if (start === undefined) return [];
|
if (start === undefined) return [];
|
||||||
if (stop === undefined) {
|
if (stop === undefined) {
|
||||||
stop = start;
|
stop = start;
|
||||||
start = 0;
|
start = 0;
|
||||||
}
|
}
|
||||||
step = step || 1; // catch undefind and zero
|
step = step || 1; // catch undefined and zero
|
||||||
const len = Math.max(Math.ceil((stop - start) / step), 0);
|
const len = Math.max(Math.ceil((stop - start) / step), 0);
|
||||||
return _doFill(new Array(len), start, step, len);
|
return _doFill(new Array(len), start, step, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'start' implicitly has an 'any' type.
|
export function linspace(
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
|
start: number,
|
||||||
export function linspace(start, stop, nsteps) {
|
stop: number,
|
||||||
// @ts-expect-error ts-migrate(2363) FIXME: The right-hand side of an arithmetic operation mus... Remove this comment to see the full error message
|
nsteps: number
|
||||||
const delta = (stop - start) / (nsteps - 1).toFixed();
|
): Array<number> {
|
||||||
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'i' implicitly has an 'any' type.
|
const delta = (stop - start) / Number((nsteps - 1).toFixed());
|
||||||
return range(0, nsteps, 1).map((i) => start + i * delta);
|
return range(0, nsteps, 1).map((i) => start + i * delta);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,17 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export default function renderThrottle<T>(
|
||||||
export default function renderThrottle(callback: any) {
|
callback: (this: T) => void
|
||||||
|
): (this: T) => void {
|
||||||
/*
|
/*
|
||||||
This wraps a call to requestAnimationFrame(), enforcing a single
|
This wraps a call to requestAnimationFrame(), enforcing a single
|
||||||
render callback at any given time (ie, you can call this any number
|
render callback at any given time (ie, you can call this any number
|
||||||
of times, and it will coallesce multiple inter-frame calls into a
|
of times, and it will coallesce multiple inter-frame calls into a
|
||||||
single render).
|
single render).
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
let rafCurrentlyInProgress: number | null = null;
|
||||||
let rafCurrentlyInProgress: any = null;
|
return function f(this: T) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
if (rafCurrentlyInProgress) return; // eslint-disable-next-line @typescript-eslint/no-this-alias --- required for functionality
|
||||||
return function f(this: any) {
|
|
||||||
if (rafCurrentlyInProgress) return;
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-this-alias --- FIXME: disabled temporarily on migrate to TS.
|
|
||||||
const context = this;
|
|
||||||
rafCurrentlyInProgress = window.requestAnimationFrame(() => {
|
rafCurrentlyInProgress = window.requestAnimationFrame(() => {
|
||||||
callback.apply(context);
|
callback.call<T, never, void>(this);
|
||||||
rafCurrentlyInProgress = null;
|
rafCurrentlyInProgress = null;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,18 +6,18 @@
|
|||||||
// myScale(0) === -1
|
// myScale(0) === -1
|
||||||
// this is is equivalent to d3.scaleLinear().domain([0,1]).range([-1,1])
|
// this is is equivalent to d3.scaleLinear().domain([0,1]).range([-1,1])
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export default (
|
||||||
export default (domain: any, range: any) => {
|
domain: [number, number],
|
||||||
|
range: [number, number]
|
||||||
|
): ((value: number) => number) => {
|
||||||
const domainStart = domain[0];
|
const domainStart = domain[0];
|
||||||
const scale = (range[1] - range[0]) / (domain[1] - domain[0]);
|
const scale = (range[1] - range[0]) / (domain[1] - domain[0]);
|
||||||
const invScale = 1 / scale;
|
const invScale = 1 / scale;
|
||||||
const rangeStart = range[0];
|
const rangeStart = range[0];
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
const f = (value: number) => (value - domainStart) * scale + rangeStart;
|
||||||
const f = (value: any) => (value - domainStart) * scale + rangeStart;
|
|
||||||
|
|
||||||
// inverter
|
// inverter
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any --- FIXME: disabled temporarily on migrate to TS.
|
f.invert = (value: number) => (value - rangeStart) * invScale + domainStart;
|
||||||
f.invert = (value: any) => (value - rangeStart) * invScale + domainStart;
|
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
export default (input: number): number => {
|
||||||
export default (input: any) => {
|
|
||||||
const outputMax = 1;
|
const outputMax = 1;
|
||||||
const outputMin = 0;
|
const outputMin = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
via https://github.com/nodef/extra-number/blob/master/scripts/significantDigits.js
|
via https://github.com/nodef/extra-number/blob/master/scripts/significantDigits.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any -- - FIXME: disabled temporarily on migrate to TS.
|
const significantDigits = (n: number): number =>
|
||||||
export default (n: any) =>
|
|
||||||
n
|
n
|
||||||
.toExponential()
|
.toExponential()
|
||||||
.replace(/e[+\-0-9]*$/, "")
|
.replace(/e[+\-0-9]*$/, "")
|
||||||
.replace(/^0\.?0*|\./, "").length;
|
.replace(/^0\.?0*|\./, "").length;
|
||||||
|
|
||||||
|
export default significantDigits;
|
||||||
|
|||||||
Reference in New Issue
Block a user