From 9e9190d68548319a6e4cc31c8d3aafeaaff4af23 Mon Sep 17 00:00:00 2001 From: joshua-dean Date: Sun, 18 Oct 2026 23:34:37 -0500 Subject: [PATCH 1/4] Return `ulabel_init` --- CHANGELOG.md | 4 ++++ api_spec.md | 5 +++++ index.d.ts | 2 +- src/index.js | 8 +++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9835a102..2f3c1d83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented here. +## [Unreleased] +#### Changed +- `init()` now returns the `ulabel_init`; typed `Promise` + ## [0.29.1] - Oct 12th, 2026 #### Fixed - `set_annotations()` / `set_annotations_batch()` could paint a frame with no annotations on heavy images. The outgoing annotations now stay on screen until the new ones are drawn. diff --git a/api_spec.md b/api_spec.md index 7a8df0b6..d07891af 100644 --- a/api_spec.md +++ b/api_spec.md @@ -35,6 +35,11 @@ Note that in order to begin the session, you must thereafter call ulabel.init(() => {/* behavior on ready */}) ``` +`init()` returns a `Promise` that: + +- Resolves when initialization finishes (after the callback) +- Rejects if initialization fails (e.g. the image fails to decode) + `ULabel` is the only name that `ulabel.js` will add to the global namespace. > ULabel is designed for **a single instance per page**. Toolbox handlers, id dialogs, and global keybinds bind to shared DOM ids and delegated selectors on `document`, so mounting more than one `ULabel` simultaneously is not supported. diff --git a/index.d.ts b/index.d.ts index 2b5aacac..34041fd9 100644 --- a/index.d.ts +++ b/index.d.ts @@ -507,7 +507,7 @@ export class ULabel { * @link https://github.com/SenteraLLC/ulabel/blob/main/api_spec.md#display-utility-functions */ public version(): string; - public init(callback: () => void): void; + public init(callback: () => void): Promise; public after_init(): void; public show_initial_crop(): void; public show_whole_image(): void; diff --git a/src/index.js b/src/index.js index 9736d6e7..ea6b8bb2 100644 --- a/src/index.js +++ b/src/index.js @@ -844,8 +844,14 @@ export class ULabel { this._owned_container = null; } + /** + * Initialize the session, then call the user callback. + * + * @param {() => void} callback User-provided callback to run after initialization. + * @returns {Promise} Resolves when initialization finishes; rejects if it fails. + */ init(callback) { - ulabel_init(this, callback); + return ulabel_init(this, callback); } /** From 8d84af2aee18c84764632e7e1a36e95d18b41cfe Mon Sep 17 00:00:00 2001 From: joshua-dean Date: Mon, 19 Oct 2026 22:40:41 -0500 Subject: [PATCH 2/4] Note on resolving amongst destruction --- api_spec.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api_spec.md b/api_spec.md index d07891af..6373bc11 100644 --- a/api_spec.md +++ b/api_spec.md @@ -39,6 +39,8 @@ ulabel.init(() => {/* behavior on ready */}) - Resolves when initialization finishes (after the callback) - Rejects if initialization fails (e.g. the image fails to decode) +- Resolves early without calling the callback if [`destroy()`](#destroy) + runs mid-init; check `ulabel.is_destroyed` after awaiting `ULabel` is the only name that `ulabel.js` will add to the global namespace. From 3a279b6eb00cfaea7078d410d7b62480d6e71b5d Mon Sep 17 00:00:00 2001 From: joshua-dean Date: Mon, 19 Oct 2026 22:42:28 -0500 Subject: [PATCH 3/4] Note rejection on cb failure --- api_spec.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api_spec.md b/api_spec.md index 6373bc11..06889884 100644 --- a/api_spec.md +++ b/api_spec.md @@ -38,9 +38,10 @@ ulabel.init(() => {/* behavior on ready */}) `init()` returns a `Promise` that: - Resolves when initialization finishes (after the callback) -- Rejects if initialization fails (e.g. the image fails to decode) - Resolves early without calling the callback if [`destroy()`](#destroy) runs mid-init; check `ulabel.is_destroyed` after awaiting +- Rejects if initialization fails (e.g. the image fails to decode) +- Rejects if the callback fails `ULabel` is the only name that `ulabel.js` will add to the global namespace. From 1bbcc3381a4061a1f53ff0f6ff44e1dc9698564a Mon Sep 17 00:00:00 2001 From: joshua-dean Date: Tue, 20 Oct 2026 20:23:21 -0500 Subject: [PATCH 4/4] Bump minor and sync --- CHANGELOG.md | 2 +- package-lock.json | 4 ++-- package.json | 2 +- src/version.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f3c1d83..66c837b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented here. -## [Unreleased] +## [0.30.0] - Oct 20th, 2026 #### Changed - `init()` now returns the `ulabel_init`; typed `Promise` diff --git a/package-lock.json b/package-lock.json index ffddee06..d85d8aff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ulabel", - "version": "0.29.1", + "version": "0.30.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ulabel", - "version": "0.29.1", + "version": "0.30.0", "license": "MIT", "devDependencies": { "@eslint/config-inspector": "^1.3.0", diff --git a/package.json b/package.json index f00a9169..1c5b46d4 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ulabel", "description": "An image annotation tool.", - "version": "0.29.1", + "version": "0.30.0", "main": "dist/ulabel.min.js", "module": "dist/ulabel.min.js", "types": "dist/index.d.ts", diff --git a/src/version.js b/src/version.js index 7b8493b2..e1e7a4da 100644 --- a/src/version.js +++ b/src/version.js @@ -1 +1 @@ -export const ULABEL_VERSION = "0.29.1"; +export const ULABEL_VERSION = "0.30.0";