Skip to content

Commit

Permalink
Merge branch 'master' into feature/hide-cross-section-opaque
Browse files Browse the repository at this point in the history
  • Loading branch information
seankmartin committed Feb 5, 2025
2 parents 247f8e7 + 79a71c6 commit 286909f
Show file tree
Hide file tree
Showing 1,121 changed files with 34,763 additions and 9,341 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
cache: "npm"
cache-dependency-path: |
package-lock.json
examples/**/package-lock.json
# uv required for javascript tests
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
# go needed for fake_gcs_server used by the javascript tests
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: "stable"
- run: npm install
- run: npm run format:fix
- name: Check for dirty working directory
Expand All @@ -54,7 +63,6 @@ jobs:
- run: npm run build-package
- run: npm publish --dry-run
working-directory: dist/package
- uses: ./.github/actions/setup-firefox
- name: Run JavaScript tests (including WebGL)
run: npm test
if: ${{ runner.os != 'macOS' }}
Expand Down Expand Up @@ -99,7 +107,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
Expand Down Expand Up @@ -146,7 +154,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
cache: "npm"
- name: Set up Python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -221,7 +229,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
registry-url: "https://registry.npmjs.org"
- uses: actions/download-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
node-version:
- "20.x"
- "22.x"
runs-on: ubuntu-latest

steps:
Expand Down
61 changes: 61 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["import", "typescript", "oxc", "unicorn", "promise", "vitest"],
"env": {
"browser": true
},
"settings": {},
"rules": {
// Seems to be buggy
"no-loss-of-precision": "off",
"import/no-cycle": "error",
"import/first": "error",
"no-unsafe-finally": "off",
"require-yield": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-inferrable-types": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-empty-interface": "off",
"erasing-op": "off",
"no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"ignoreRestSiblings": true
}
],
"no-new-array": "off",
"no-document-cookie": "off",
"@typescript-eslint/consistent-type-imports": "error"
},
"overrides": [
{
"files": ["*.test.ts", "*.spec.ts"],
"rules": {
"@typescript-eslint/no-explicit-any": "off"
}
}
],
"ignorePatterns": [
"**/node_modules",
"**/dist",
"**/python",
"templates/neuroglancer/sliceview",
"src/third_party/jpgjs/jpg.js",
"**/templates",
"**/build",
"**/.tox",
"**/.nox",
"**/.venv",
"lib",
"**/python",
"**/config",
"**/typings",
"src/mesh/draco/stub.js",
"**/tsconfig.tsbuildinfo",
"examples"
]
}
6 changes: 5 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
/templates/
/python/
/third_party/jpgjs/jpg.js
/testdata/*.json
/testdata/
zarr.json
.parcel-cache
dist
/lib
/docs/_build/
/.ruff_cache
package.json
package-lock.json
.venv
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

Neuroglancer is a WebGL-based viewer for volumetric data. It is capable of displaying arbitrary (non axis-aligned) cross-sectional views of volumetric data, as well as 3-D meshes and line-segment based models (skeletons).

Refer to the documentation website at https://neuroglancer-docs.web.app for more details.

This is not an official Google product.

# Examples
Expand Down Expand Up @@ -157,6 +159,7 @@ There is a Google Group/mailing list for discussion related to Neuroglancer:

# Related Projects

- [Panel-Neuroglancer](https://github.com/panel-extensions/panel-neuroglancer) - Integrate Neuroglancer into Jupyter notebook workflows and Python web apps with this HoloViz Panel extension.
- [TensorStore](https://github.com/google/tensorstore) - C++ and Python library for efficiently
reading and writing multi-dimensional arrays in formats supported by Neuroglancer.
- [4Quant/neuroglancer-docker](https://github.com/4Quant/neuroglancer-docker) - Example setup for
Expand Down
15 changes: 12 additions & 3 deletions build_tools/after-version-change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ await Promise.all(
await execFileAsync("npm", ["install", "--no-audit", "--no-fund"], {
cwd: exampleDir,
});
await execFileAsync("git", ["add", "package-lock.json"], {
cwd: exampleDir,
});
}),
);

await execFileAsync(
"git",
[
"add",
...(await glob("examples/*/*/package-lock.json", {
absolute: false,
cwd: rootDir,
})),
],
{ cwd: rootDir },
);
2 changes: 2 additions & 0 deletions build_tools/build-package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ async function buildPackage(options: {
outbase: srcDir,
bundle: false,
outdir: libDir,
target: "es2022",
});

let compilerOptionsFromConfigFile: ts.CompilerOptions = {};
Expand Down Expand Up @@ -122,6 +123,7 @@ async function buildPackage(options: {
const { postpack } = packageJson["scripts"];
delete packageJson["scripts"];
packageJson["scripts"] = { postpack };
packageJson["files"] = ["lib/**/*"];
} else {
delete packageJson["private"];
packageJson["scripts"] = {};
Expand Down
164 changes: 84 additions & 80 deletions build_tools/update-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,70 +17,100 @@ const imports: Record<string, any> = {};
imports["#src/third_party/jpgjs/jpg.js"] = "./src/third_party/jpgjs/jpg.js";
imports["#src/*.js"] = "./src/*.ts";
imports["#src/*"] = "./src/*";
imports["#tests/fixtures/msw"] = {
node: "./tests/fixtures/msw_node.ts",
default: "./tests/fixtures/msw_browser.ts",
};
imports["#tests/fixtures/gl"] = {
node: "./tests/fixtures/gl_node.ts",
default: "./tests/fixtures/gl_browser.ts",
};
imports["#tests/*.js"] = "./tests/*.ts";
imports["#testdata/*"] = "./testdata/*";

const datasourceDir = path.resolve(rootDir, "src", "datasource");
const layerDir = path.resolve(rootDir, "src", "layer");

const datasources = (
await fs.promises.readdir(datasourceDir, { withFileTypes: true })
)
.filter((e) => e.isDirectory())
.map((e) => e.name);

const layers = (await fs.promises.readdir(layerDir, { withFileTypes: true }))
.filter((e) => e.isDirectory())
.map((e) => e.name);

const datasourceKeys = {
backend: "backend",
async_computation: "async_computation",
register_default: "frontend",
register_credentials_provider: "frontend",
} as const;
async function listSubdirs(dir: string): Promise<string[]> {
return (await fs.promises.readdir(dir, { withFileTypes: true }))
.filter((e) => e.isDirectory())
.map((e) => e.name);
}

const datasourceModules = Object.fromEntries(
Object.values(datasourceKeys).map((key) => [key, new Array<string>()]),
);
async function writeModule(modulePath: string, imports: string[]) {
await fs.promises.writeFile(
modulePath,
"// DO NOT EDIT: Generated by config/update_conditions.ts\n" +
imports.map((name) => `import ${JSON.stringify(name)};\n`).join(""),
{ encoding: "utf-8" },
);
}

for (const datasource of datasources) {
for (const [filePrefix, moduleKind] of Object.entries(datasourceKeys)) {
const sourcePrefix = `./src/datasource/${datasource}/${filePrefix}`;
if (
await fs.promises
.stat(path.resolve(rootDir, `${sourcePrefix}.ts`))
.catch(() => undefined)
) {
const source = sourcePrefix + JS_EXT;
const conditions: Record<string, string> = {};
if (datasource === "python") {
conditions["neuroglancer/python"] = source;
conditions.default = NOOP;
} else {
if (filePrefix === "register_credentials_provider") {
conditions["neuroglancer/python"] = NOOP;
async function handleDrivers(
kind: string,
moduleMap: Record<string, string[]>,
) {
const driverDir = path.resolve(rootDir, "src", kind);
const drivers = await listSubdirs(driverDir);
const modules: Record<string, string[]> = {};
for (const driver of drivers) {
for (const [filePrefix, moduleKinds] of Object.entries(moduleMap)) {
const sourcePrefix = `./src/${kind}/${driver}/${filePrefix}`;
if (
await fs.promises
.stat(path.resolve(rootDir, `${sourcePrefix}.ts`))
.catch(() => undefined)
) {
const source = sourcePrefix + JS_EXT;
const conditions: Record<string, string> = {};
if (driver === "python") {
conditions["neuroglancer/python"] = source;
conditions.default = NOOP;
} else {
if (filePrefix === "register_credentials_provider") {
conditions["neuroglancer/python"] = NOOP;
}
conditions[`neuroglancer/${kind}/${driver}:enabled`] = source;
conditions[`neuroglancer/${kind}:none_by_default`] = NOOP;
conditions[`neuroglancer/${kind}/${driver}:disabled`] = NOOP;
conditions.default = source;
}
let moduleId = `#${kind}/${driver}`;
if (filePrefix !== "index") {
moduleId += `/${filePrefix}`;
}
imports[moduleId] = conditions;
for (const moduleKind of moduleKinds) {
if (modules[moduleKind] === undefined) {
modules[moduleKind] = [];
}
modules[moduleKind].push(moduleId);
}
conditions[`neuroglancer/datasource/${datasource}:enabled`] = source;
conditions["neuroglancer/datasource:none_by_default"] = NOOP;
conditions[`neuroglancer/datasource/${datasource}:disabled`] = source;
conditions.default = source;
}
const moduleId = `#datasource/${datasource}/${filePrefix}`;
imports[moduleId] = conditions;
datasourceModules[moduleKind].push(moduleId);
}
}
for (const [moduleKind, moduleIds] of Object.entries(modules)) {
await writeModule(
path.resolve(driverDir, `enabled_${moduleKind}_modules.ts`),
moduleIds,
);
}
}

for (const layer of layers) {
const source = `./src/layer/${layer}/index` + JS_EXT;
imports[`#layer/${layer}`] = {
[`neuroglancer/layer/${layer}:enabled`]: source,
"neuroglancer/layer:none_by_default": NOOP,
[`neuroglancer/layer/${layer}:enabled`]: source,
default: source,
};
}
await handleDrivers("datasource", {
backend: ["backend"],
async_computation: ["async_computation"],
register_default: ["frontend"],
register_credentials_provider: ["frontend"],
});

await handleDrivers("kvstore", {
register: ["frontend", "backend"],
register_frontend: ["frontend"],
register_backend: ["backend"],
register_credentials_provider: ["frontend"],
});

await handleDrivers("layer", {
index: ["frontend"],
});

// main entrypoint.
imports["#main"] = {
Expand All @@ -94,32 +124,6 @@ imports["#python_integration_build"] = {
default: NOOP,
};

async function writeModule(modulePath: string, imports: string[]) {
await fs.promises.writeFile(
modulePath,
"// DO NOT EDIT: Generated by config/update_conditions.ts\n" +
imports.map((name) => `import ${JSON.stringify(name)};\n`).join(""),
{ encoding: "utf-8" },
);
}

for (const [moduleKind, moduleIds] of Object.entries(datasourceModules)) {
await writeModule(
path.resolve(
rootDir,
"src",
"datasource",
`enabled_${moduleKind}_modules.ts`,
),
moduleIds,
);
}

await writeModule(
path.resolve(rootDir, "src", "layer", "enabled_frontend_modules.ts"),
layers.map((name) => `#layer/${name}`),
);

packageJson.imports = imports;

packageJson.exports = {
Expand Down
Loading

0 comments on commit 286909f

Please sign in to comment.