@@ -4,6 +4,8 @@ import { FilterDistanceOverlay } from "./src/overlays";
44import { ULabelSubtask } from "./src/subtask" ;
55import { Toolbox , AnnotationResizeItem } from "./src/toolbox" ;
66
7+ export { ULabelAnnotation , AllowedToolboxItem , Configuration , FilterDistanceOverlay , ULabelSubtask , Toolbox , AnnotationResizeItem } ;
8+
79export type DistanceFromPolyline = {
810 distance : number ;
911 polyline_id ?: string ;
@@ -15,7 +17,7 @@ export type DistanceFromPolyline = {
1517 */
1618export type DistanceFromPolylineClasses = {
1719 closest_row : DistanceFromPolyline ;
18- [ key : number ] : DistanceFromPolyline ;
20+ [ key : string ] : DistanceFromPolyline ;
1921} ;
2022
2123export type AbstractPoint = {
@@ -63,7 +65,7 @@ export type ClassDefinition = {
6365 name : string ;
6466 id : number ;
6567 color : string ;
66- keybind ? : string ;
68+ keybind : string | null ;
6769} ;
6870
6971export type SliderInfo = {
@@ -133,7 +135,7 @@ export type ULabelAnnotations = { [key: string]: ULabelAnnotation[] };
133135
134136export type ULabelSubmitData = {
135137 annotations : ULabelAnnotations ;
136- task_meta : object ;
138+ task_meta : object | null ;
137139} ;
138140export type ULabelSubmitHandler = ( submitData : ULabelSubmitData ) => void ;
139141
@@ -239,6 +241,23 @@ export type ULabelActionCandidate = {
239241
240242export type ULabelSubtasks = { [ key : string ] : ULabelSubtask } ;
241243
244+ export type ULabelConstructorArgs = {
245+ container_id : string ;
246+ image_data : string | string [ ] ;
247+ username : string ;
248+ submit_buttons : ULabelSubmitButton [ ] ;
249+ subtasks : ULabelSubtasks ;
250+ task_meta ?: object ;
251+ annotation_meta ?: object ;
252+ px_per_px ?: number ;
253+ initial_crop ?: InitialCrop ;
254+ initial_line_size ?: number ;
255+ instructions_url ?: string ;
256+ toolbox_order ?: AllowedToolboxItem [ ] ;
257+ /** @deprecated Use top-level properties instead. */
258+ config_data ?: object ;
259+ } ;
260+
242261export class ULabel {
243262 subtasks : ULabelSubtasks ;
244263 state : {
@@ -256,6 +275,9 @@ export class ULabel {
256275 anno_scaling_mode : AnnoScalingMode ;
257276 // Keybind editing state
258277 is_editing_keybind : boolean ;
278+ // Original keybind storage
279+ original_config_keybinds ?: { [ config_key : string ] : string } ;
280+ original_class_keybinds ?: { [ class_id : number ] : string | null } ;
259281 // Render state
260282 // TODO (joshua-dean): this is never assigned, is it used?
261283 demo_canvas_context : CanvasRenderingContext2D ;
@@ -272,9 +294,13 @@ export class ULabel {
272294 begining_time : number ;
273295 is_init : boolean ;
274296 resize_observers : ResizeObserver [ ] ;
297+
275298 /**
276299 * @link https://github.com/SenteraLLC/ulabel/blob/main/api_spec.md#ulabel-constructor
277300 */
301+ constructor ( kwargs : ULabelConstructorArgs ) ;
302+
303+ /** @deprecated Pass a single kwargs object instead of positional arguments. */
278304 constructor (
279305 container_id : string ,
280306 image_data : string | string [ ] ,
@@ -294,6 +320,7 @@ export class ULabel {
294320 /**
295321 * @link https://github.com/SenteraLLC/ulabel/blob/main/api_spec.md#display-utility-functions
296322 */
323+ public version ( ) : string ;
297324 public init ( callback : ( ) => void ) : void ;
298325 public after_init ( ) : void ;
299326 public show_initial_crop ( ) : void ;
@@ -309,22 +336,22 @@ export class ULabel {
309336 public switch_to_next_subtask ( ) : void ;
310337
311338 // Annotations
312- public get_annotations ( subtask : ULabelSubtask ) : ULabelAnnotation [ ] ;
313- public set_annotations ( annotations : ULabelAnnotation [ ] , subtask : ULabelSubtask ) ;
314- public set_saved ( saved : boolean ) ;
339+ public get_annotations ( subtask : string ) : ULabelAnnotation [ ] ;
340+ public set_annotations ( annotations : ULabelAnnotation [ ] , subtask : string ) : void ;
341+ public set_saved ( saved : boolean ) : void ;
315342 public draw_annotation_from_id ( id : string , offset ?: Offset , subtask ?: string ) : void ;
316343 public redraw_annotation ( annotation_id : string , subtask ?: string , offset ?: Offset ) : void ;
317344 public redraw_all_annotations (
318- subtask ?: string , // TODO (joshua-dean): THIS IS SUBTASK KEY, NAME PROPERLY
319- offset ?: number ,
345+ subtask ?: string ,
346+ offset ?: number | null ,
320347 spatial_only ?: boolean ,
321- ) ;
322- public redraw_multiple_spatial_annotations ( annotation_ids : string [ ] , subtask ?: string , offset ?: Offset ) ;
348+ ) : void ;
349+ public redraw_multiple_spatial_annotations ( annotation_ids : string [ ] , subtask ?: string , offset ?: Offset ) : void ;
323350 public clear_nonspatial_annotation ( annotation_id : string ) : void ;
324351 public show_annotation_mode (
325- target_jq ?: JQuery < HTMLElement > , // TODO (joshua-dean): validate this type
326- ) ;
327- public update_frame ( delta ?: number , new_frame ?: number ) : void ;
352+ target_jq ?: JQuery < HTMLElement > | null , // TODO (joshua-dean): validate this type
353+ ) : void ;
354+ public update_frame ( delta ?: number | null , new_frame ?: number | null ) : void ;
328355 public rebuild_containing_box ( actid : string , ignore_final ?: boolean , subtask ?: string ) : void ;
329356 public update_filter_distance_during_polyline_move (
330357 annotation_id : string ,
@@ -341,7 +368,7 @@ export class ULabel {
341368 public get_keypoint_slider_value ( ) : number | null ;
342369 public get_distance_filter_value ( ) : DistanceFromPolylineClasses | null ;
343370 public fly_to_next_annotation ( increment : number , max_zoom ?: number ) : boolean ;
344- public fly_to_annotation_id ( annotation_id : string , subtask_key ?: string , max_zoom ?: number ) : boolean ;
371+ public fly_to_annotation_id ( annotation_id : string , subtask_key ?: string | null , max_zoom ?: number ) : boolean ;
345372 public fly_to_annotation ( annotation : ULabelAnnotation , subtask_key ?: string , max_zoom ?: number ) : boolean ;
346373
347374 // Brush
@@ -361,9 +388,10 @@ export class ULabel {
361388 public remove_listeners ( ) : void ;
362389
363390 // Static functions
391+ static version ( ) : string ;
364392 static get_time ( ) : string ;
365- static get_allowed_toolbox_item_enum ( ) : AllowedToolboxItem ;
366- static get_resize_toolbox_item ( ) : AnnotationResizeItem ;
393+ static get_allowed_toolbox_item_enum ( ) : typeof AllowedToolboxItem ;
394+ static get_resize_toolbox_item ( ) : typeof AnnotationResizeItem ;
367395 static process_classes ( ulabel_obj : ULabel , arg1 : string , subtask_obj : ULabelSubtask ) : void ;
368396 static build_id_dialogs ( ulabel_obj : ULabel ) : void ;
369397
@@ -375,8 +403,8 @@ export class ULabel {
375403
376404 // Annotation lifecycle
377405 // TODO (joshua-dean): type for redo_payload
378- public begin_annotation ( mouse_event : JQuery . TriggeredEvent , annotation_id ?: string , redo_payload ?: object ) : void ;
379- public continue_annotation ( mouse_event : JQuery . TriggeredEvent , is_click ?: boolean , annotation_id ?: string , redo_payload ?: object ) : void ;
406+ public begin_annotation ( mouse_event : JQuery . TriggeredEvent | null | undefined , annotation_id ?: string | null , redo_payload ?: object | null ) : void ;
407+ public continue_annotation ( mouse_event : JQuery . TriggeredEvent | null | undefined , is_click ?: boolean , annotation_id ?: string | null , redo_payload ?: object | null ) : void ;
380408 public delete_annotation (
381409 annotation_id : string ,
382410 redoing ?: boolean ,
@@ -468,14 +496,14 @@ export class ULabel {
468496
469497 // Edit suggestions
470498 public suggest_edits (
471- mouse_event ?: JQuery . TriggeredEvent ,
472- nonspatial_id ?: string ,
499+ mouse_event ?: JQuery . TriggeredEvent | null ,
500+ nonspatial_id ?: string | null ,
473501 force_refresh ?: boolean ,
474502 ) : void ;
475503 public show_global_edit_suggestion (
476504 annid : string ,
477- offset ?: Offset ,
478- nonspatial_id ?: string ,
505+ offset ?: Offset | null ,
506+ nonspatial_id ?: string | null ,
479507 ) : void ;
480508 public hide_global_edit_suggestion ( ) : void ;
481509 public hide_edit_suggestion ( ) : void ;
@@ -485,7 +513,7 @@ export class ULabel {
485513 annid : string ,
486514 access_str : string ,
487515 as_though_pre_splice : boolean ,
488- ) ;
516+ ) : unknown ;
489517
490518 // Drawing
491519 public rezoom (
@@ -537,3 +565,5 @@ declare global {
537565 replaceLowerConcat ( before : string , after : string , concat_string ?: string ) : string ;
538566 }
539567}
568+
569+ export default ULabel ;
0 commit comments