Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented here.

## [unreleased]

## [0.23.7] - July 21st, 2026
- Ship generated `.d.ts` declarations (`dist/types/`) and a generated type entry (`dist/index.d.ts`) instead of pointing consumers' type resolution at the raw `.ts` source. This stops downstream TypeScript projects from compiling ULabel's source under their own (stricter) `tsconfig`.
- Stop publishing the `src/` directory in the npm package (`files` now ships `dist/` only).

## [0.23.6] - May 11th, 2026
- Fix `AnnotationList` class ordering to match the `AnnotationID` toolbox item ordering, which is based on the configured class definition order in the subtask's `classes` array
- Add local storage of checkbox options for the `AnnotationList` toolbox item
Expand Down
13 changes: 13 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,17 @@ export default [
"@typescript-eslint/no-unused-expressions": "off",
},
},
{
// Node-specific config for build/release tooling scripts
files: ["scripts/**/*.{js,mjs,cjs}"],
languageOptions: {
globals: {
...globals.node,
},
},
rules: {
// Build scripts use CommonJS require()
"@typescript-eslint/no-require-imports": "off",
},
},
];
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 8 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
{
"name": "ulabel",
"description": "An image annotation tool.",
"version": "0.23.6",
"version": "0.23.7",
"main": "dist/ulabel.min.js",
"module": "dist/ulabel.min.js",
"types": "index.d.ts",
"types": "dist/index.d.ts",
"files": [
"dist/",
"src/",
"index.d.ts"
"dist/"
],
"exports": {
".": {
"types": "./index.d.ts",
"types": "./dist/index.d.ts",
"default": "./dist/ulabel.min.js"
},
"./min": {
"types": "./index.d.ts",
"types": "./dist/index.d.ts",
"default": "./dist/ulabel.min.js"
},
"./debug": {
"types": "./index.d.ts",
"types": "./dist/index.d.ts",
"default": "./dist/ulabel.js"
}
},
Expand All @@ -33,8 +31,8 @@
"test:e2e": "playwright test",
"demo": "node demo.js",
"clean": "node -e \"require('fs').rmSync('dist', {recursive: true, force: true})\"",
"build": "npm run clean && tsc && webpack --mode production",
"build-dev": "npm run clean && tsc && webpack --mode development",
"build": "npm run clean && tsc && tsc -p tsconfig.types.json && node scripts/emit-type-shims.js && webpack --mode production",
"build-dev": "npm run clean && tsc && tsc -p tsconfig.types.json && node scripts/emit-type-shims.js && webpack --mode development",
"build-and-demo": "npm run build && npm run demo",
"build-dev-and-demo": "npm run build-dev && npm run demo",
"build-and-test": "npm run build && npm run test:both",
Expand Down
39 changes: 39 additions & 0 deletions scripts/emit-type-shims.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Build helper: assemble the published type declarations under dist/.
//
// The hand-written root index.d.ts is the source of truth for the public API,
// but it imports the concrete classes from ./src/* (so ULabel's own source
// build type-checks against a single identity). Publishing it as-is would drag
// raw .ts source into consumers, so instead we:
//
// 1. Emit generated declarations from src into dist/types/ (see
// tsconfig.types.json), and
// 2. Write a published entry dist/index.d.ts that is the root index.d.ts with
// its "./src/" imports rewritten to the generated "./types/" siblings.
//
// The generated declarations preserve their source import specifiers, so files
// under dist/types/ still reference "..", "../index" and "../src/index" (which
// point at the root index.d.ts / src bridge in the source tree). We add small
// shims so those specifiers resolve to the published entry within dist/.

const fs = require("fs");
const path = require("path");

const root_dir = path.resolve(__dirname, "..");
const dist_dir = path.join(root_dir, "dist");
const types_dir = path.join(dist_dir, "types");
const src_dir = path.join(dist_dir, "src");

fs.mkdirSync(types_dir, { recursive: true });
fs.mkdirSync(src_dir, { recursive: true });

// Published entry: root index.d.ts with concrete-class imports repointed at the
// generated declarations. Nothing here resolves back into raw .ts source.
const root_types = fs.readFileSync(path.join(root_dir, "index.d.ts"), "utf8");
const published_entry = root_types.replace(/\.\/src\//g, "./types/");
fs.writeFileSync(path.join(dist_dir, "index.d.ts"), published_entry);

// Shims so generated declarations resolve to the published entry:
// - dist/types/*.d.ts import shared types from ".." and ULabel from "../index".
// - dist/types/**/*.d.ts import ULabel from "../src/index" (and "../../src/index").
fs.writeFileSync(path.join(types_dir, "index.d.ts"), "export * from \"..\";\n");
fs.writeFileSync(path.join(src_dir, "index.d.ts"), "export * from \"../index\";\n");
2 changes: 1 addition & 1 deletion src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
ULabelAction,
ULabelActionRaw,
ULabelActionType,
} from "..";
} from "../index";
// Import ULabel from ../src/index - TypeScript will find ../src/index.d.ts for types
// and resolve to ../src/index.js at runtime after compilation
import { ULabel } from "../src/index";
Expand Down
2 changes: 1 addition & 1 deletion src/annotation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type {
ULabelClassificationPayload,
ULabelContainingBox,
ULabelSpatialType,
} from "..";
} from "../index";
import { GeometricUtils } from "./geometric_utils";
import { log_message, LogLevel } from "./error_logging";

Expand Down
2 changes: 1 addition & 1 deletion src/annotation_operators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
FilterDistanceOverride,
ValidDeprecatedBy,
ClassDefinition,
} from "..";
} from "../index";
// Import ULabel from ../src/index - TypeScript will find ../src/index.d.ts for types
import { ULabel } from "../src/index";

Expand Down
2 changes: 1 addition & 1 deletion src/canvas_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* TODO (joshua-dean): Pull the rest of the canvas functions into here
*/

import type { ULabel, ULabelSubtasks } from "..";
import type { ULabel, ULabelSubtasks } from "../index";
import { NONSPATIAL_MODES } from "./annotation";
import { Configuration, DEFAULT_N_ANNOS_PER_CANVAS, TARGET_MAX_N_CANVASES_PER_SUBTASK } from "./configuration";

Expand Down
2 changes: 1 addition & 1 deletion src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
RecolorActiveConfig,
ULabelSubmitButton,
AnnoScalingMode,
} from "..";
} from "../index";
import {
ModeSelectionToolboxItem,
ZoomPanToolboxItem,
Expand Down
2 changes: 1 addition & 1 deletion src/html_builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SliderInfo } from "..";
import type { SliderInfo } from "../index";
// Import ULabel from ../src/index - TypeScript will find ../src/index.d.ts for types
import { ULabel } from "../src/index";
import { Toolbox, ZoomPanToolboxItem } from "./toolbox";
Expand Down
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Type declarations for src/index.js
// Re-export the ULabel class type from the root index.d.ts
export { ULabel } from "..";
export { ULabel } from "../index";
2 changes: 1 addition & 1 deletion src/listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Long handlers are broken out into separate functions.
*/

import type { ULabel } from "..";
import type { ULabel } from "../index";
import { NightModeCookie } from "./cookies";
import { DELETE_CLASS_ID, DELETE_MODES, NONSPATIAL_MODES } from "./annotation";
import { set_local_storage_item } from "./utilities";
Expand Down
2 changes: 1 addition & 1 deletion src/overlays.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AbstractPoint, DistanceFromPolylineClasses, Offset } from "..";
import type { AbstractPoint, DistanceFromPolylineClasses, Offset } from "../index";
import { ULabelAnnotation } from "./annotation";
import { get_annotation_class_id } from "./annotation_operators";
import { log_message, LogLevel } from "./error_logging";
Expand Down
2 changes: 1 addition & 1 deletion src/subtask.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ULabelSpatialType, ClassDefinition, ULabelAction, ULabelActionCandidate } from "..";
import type { ULabelSpatialType, ClassDefinition, ULabelAction, ULabelActionCandidate } from "../index";
import { ULabelAnnotation } from "./annotation";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/toolbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
FilterDistanceConfig,
RecolorActiveConfig,
ValidDeprecatedBy,
} from "..";
} from "../index";
// Import ULabel from ../src/index - TypeScript will find ../src/index.d.ts for types
import { ULabel } from "../src/index";
import { DEFAULT_FILTER_DISTANCE_CONFIG } from "./configuration";
Expand Down
2 changes: 1 addition & 1 deletion src/toolbox_items/submit_buttons.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ULabelSubmitButton } from "../..";
import type { ULabelSubmitButton } from "../../index";
// Import ULabel from ../../src/index - TypeScript will find ../../src/index.d.ts for types
import { ULabel } from "../../src/index";
import { ULabelAnnotation, DELETE_MODES, NONSPATIAL_MODES } from "../annotation";
Expand Down
2 changes: 1 addition & 1 deletion src/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const ULABEL_VERSION = "0.23.6";
export const ULABEL_VERSION = "0.23.7";
1 change: 1 addition & 0 deletions tests/types/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"noEmit": true,
"esModuleInterop": true,
"skipLibCheck": true,
"strict": true,
"types": ["jquery"]
},
"files": ["index.test-d.ts"]
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
},
"exclude": [
"tests/types",
"dist",
],
}
16 changes: 16 additions & 0 deletions tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"emitDeclarationOnly": true,
"outDir": "./dist/types",
"rootDir": "./src"
},
"include": [
"src/**/*.ts"
],
"exclude": [
"tests",
"dist"
]
}
Loading