diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7176b50 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,129 @@ +name: CI + +on: [pull_request] + +concurrency: + # Cancels workflows that are already running when a new one is triggered for a branch + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm build + + format: + name: Format + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Format + run: pnpm fmt:check + + lint: + name: Lint + runs-on: ubuntu-latest + # Skip job until we get a linter added + if: false + + steps: + - uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Lint + run: echo "Add pnpm lint command here" + + test: + name: Test + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Test + run: pnpm test + + typecheck: + name: Typecheck + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm build + + - name: Typecheck + run: pnpm typecheck diff --git a/LICENSE.md b/LICENSE.md index 0745566..45200b7 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright 2024 Allen Institute +Copyright 2024 Allen Institute Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -8,4 +8,4 @@ Redistribution and use in source and binary forms, with or without modification, 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/examples/package.json b/examples/package.json index fb913ea..19aa863 100644 --- a/examples/package.json +++ b/examples/package.json @@ -64,4 +64,4 @@ "regl": "^2.1.0", "zarrita": "0.4.0-next.14" } -} \ No newline at end of file +} diff --git a/package.json b/package.json index d5007ae..e9950d9 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "build": "pnpm -r run --no-bail build", "watch": "pnpm -r run watch", "fmt": "npx prettier . --write", - "fmt:check": "npx prettier . --check" + "fmt:check": "npx prettier . --check", + "test": "pnpm -r run --no-bail test:ci", + "typecheck": "pnpm -r --no-bail run typecheck" }, "devDependencies": { "@parcel/packager-ts": "2.12.0", diff --git a/packages/dzi/package.json b/packages/dzi/package.json index dd7e021..dfdc05b 100644 --- a/packages/dzi/package.json +++ b/packages/dzi/package.json @@ -55,4 +55,4 @@ "lodash": "^4.17.21", "regl": "^2.1.0" } -} \ No newline at end of file +} diff --git a/packages/dzi/src/loader.ts b/packages/dzi/src/loader.ts index 0edda84..1ebb9b3 100644 --- a/packages/dzi/src/loader.ts +++ b/packages/dzi/src/loader.ts @@ -54,13 +54,13 @@ export function getVisibleTiles(dzi: DziImage, camera: { view: box2D; screenSize const availableTiles = tilesInLayer(dzi, layer); const baseLayer = findLargestSingleTileLayer(dzi); - const baseIndex: TileIndex = { col: 0, row: 0 } + const baseIndex: TileIndex = { col: 0, row: 0 }; const baseTile: DziTile = { index: baseIndex, layer: baseLayer, relativeLocation: Box2D.create([0, 0], [1, 1]), - url: tileUrl(dzi, baseLayer, baseIndex) - } + url: tileUrl(dzi, baseLayer, baseIndex), + }; // note that the tile boxes are in pixels relative to the layer in which they reside // the given view is assumed to be a parameter (in the space [0:1]) of the image as a whole @@ -82,7 +82,7 @@ export function getVisibleTiles(dzi: DziImage, camera: { view: box2D; screenSize // filter out tiles which are not in view }) .filter((t) => !!Box2D.intersection(t.relativeLocation, camera.view)); - return (baseLayer < layer) ? [baseTile, ...tiles] : tiles; + return baseLayer < layer ? [baseTile, ...tiles] : tiles; } /** * NOTE: THE REMAINDER OF THIS FILE IS EXPORTED ONLY FOR TESTING PURPOSES @@ -97,13 +97,13 @@ export function firstSuitableLayer(imageWidth: number, screenWidth: number) { } /** - * - * @param dzi + * + * @param dzi * @returns the index of the largest layer which contains only a single tile - * + * */ function findLargestSingleTileLayer(dzi: DziImage): number { - return Math.floor(Math.log2(dzi.tileSize)) + return Math.floor(Math.log2(dzi.tileSize)); } export function tileWithOverlap(total: number, step: number, overlap: number): Interval[] { const blocks: Interval[] = []; diff --git a/packages/dzi/src/renderer.ts b/packages/dzi/src/renderer.ts index 4962a41..1937ad0 100644 --- a/packages/dzi/src/renderer.ts +++ b/packages/dzi/src/renderer.ts @@ -45,7 +45,7 @@ export function buildDziRenderer(regl: REGL.Regl): Renderer { }, // no private resources to destroy + destroy: () => {}, // no private resources to destroy cacheKey: (item, _requestKey, _data, _settings) => `${item.url}`, fetchItemContent: fetchDziTile, getVisibleItems: (dzi, settings) => { diff --git a/packages/geometry/package.json b/packages/geometry/package.json index f7ed500..00783d6 100644 --- a/packages/geometry/package.json +++ b/packages/geometry/package.json @@ -52,4 +52,4 @@ "typescript": "^5.3.3", "vitest": "^1.4.0" } -} \ No newline at end of file +}