@micrio/client 5.4.16 → 5.4.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/micrio.min.d.ts CHANGED
@@ -4,7 +4,7 @@ declare module '@micrio/client' {
4
4
  * Defines the current version of the Micrio library.
5
5
  * This constant is used internally and exposed statically via `HTMLMicrioElement.VERSION`.
6
6
  */
7
- export const VERSION = "5.4.16";
7
+ export const VERSION = "5.4.17";
8
8
  /**
9
9
  * Loads an image texture asynchronously. Adds the request to the queue
10
10
  * and returns a Promise that resolves with the TextureBitmap or rejects on error.
@@ -12,6 +12,12 @@ declare module '@micrio/client' {
12
12
  * @returns A Promise resolving to the loaded TextureBitmap.
13
13
  */
14
14
  export const loadTexture: (src: string) => Promise<TextureBitmap>;
15
+ /**
16
+ * Converts seconds into a human-readable time string (hh?:mm:ss).
17
+ * @param s Time in seconds. Can be negative for remaining time display.
18
+ * @returns Formatted time string (e.g., "1:23", "1:05:09", "-0:15").
19
+ */
20
+ export function parseTime(s: number): string;
15
21
  export type PREDEFINED = [string, Models.ImageInfo.ImageInfo, Models.ImageData.ImageData | undefined];
16
22
  /** Enum for identifying media type. */
17
23
  export enum MediaType {
@@ -27,59 +33,32 @@ declare module '@micrio/client' {
27
33
  YouTube = 1,
28
34
  Vimeo = 2
29
35
  }
36
+ export { isLegacyViews };
30
37
  /**
31
- * Converts seconds into a human-readable time string (hh?:mm:ss).
32
- * @param s Time in seconds. Can be negative for remaining time display.
33
- * @returns Formatted time string (e.g., "1:23", "1:05:09", "-0:15").
34
- */
35
- export function parseTime(s: number): string;
36
- export const isLegacyViews: (i: Models.ImageInfo.ImageInfo) => boolean;
37
- /**
38
- * Decodes a character from a Micrio ID into its numeric value (used for V4 short IDs).
39
- * @private
40
- */
41
- export const getIdVal: (a: string) => number;
42
- /** Checks if an ID likely belongs to the V5 format (6 or 7 characters). */
43
- export const idIsV5: (id: string) => boolean;
44
- /** Clamps a view rectangle the image bounds [0, 0, 1, 1]. */
45
- export const limitView: (v: Models.Camera.View) => Models.Camera.View;
46
- /**
47
- * Calculates the 3D vector and navigation parameters between two images in a 360 space.
48
- * Used for smooth transitions between waypoints.
49
- * @private
50
- * @param micrio The main HTMLMicrioElement instance.
51
- * @param targetId The ID of the target image.
52
- * @returns An object containing the vector, normalized vector, direction, and transition parameters, or undefined if calculation fails.
38
+ * Global utility functions used throughout the Micrio application.
39
+ * Re-exports all utility modules for convenient importing.
40
+ * @author Marcel Duin <marcel@micr.io>
53
41
  */
54
- export function getSpaceVector(micrio: HTMLMicrioElement, targetId: string): {
55
- vector: Models.Camera.Vector;
56
- directionX: number;
57
- v: Models.Spaces.DirectionVector;
58
- vN: Models.Spaces.DirectionVector;
59
- } | undefined;
42
+ export { MicrioError } from "ts/utils/error";
43
+ export { pyth, mod, limitView } from "ts/utils/math";
44
+ export { clone, deepCopy } from "ts/utils/object";
45
+ export { createGUID, slugify, parseTime } from "ts/utils/string";
46
+ export { Browser } from "ts/utils/browser";
47
+ export { sleep, notypecheck, loadScript } from "ts/utils/dom";
48
+ export { once, after } from "ts/utils/store";
49
+ export { View } from "ts/utils/view";
50
+ export { sanitizeAsset, isLegacyViews, sanitizeImageInfo, sanitizeImageData, sanitizeSpaceData, sanitizeMarker, sanitizeVideoTour } from "ts/utils/sanitize";
51
+ export { jsonCache, fetchJson, isFetching, getLocalData, fetchInfo, fetchAlbumInfo } from "ts/utils/fetch";
52
+ export { loadSerialTour } from "ts/utils/tour";
53
+ export { getIdVal, idIsV5 } from "ts/utils/id";
54
+ export { getSpaceVector } from "ts/utils/space";
55
+ export { hasNativeHLS } from "ts/utils/media";
60
56
  /**
61
- * Checks if the browser natively supports HLS video playback via the `<video>` element.
62
- * @private
63
- * @param video Optional HTMLVideoElement to check (defaults to creating a temporary one).
64
- * @returns True if native HLS support is detected.
57
+ * Global utility functions used throughout the Micrio application.
58
+ * This file re-exports all utilities from the modular utils/ directory.
59
+ * @author Marcel Duin <marcel@micr.io>
65
60
  */
66
- export const hasNativeHLS: (video?: HTMLMediaElement) => boolean;
67
- export const View: {
68
- /** Casts a legacy view array ([x0, y0, x1, y1]) to [x0,y0,width,height]. */
69
- fromLegacy: (v?: Models.Camera.ViewRect | Models.Camera.View) => Models.Camera.View | undefined;
70
- toCenterJSON: (v: Models.Camera.View) => {
71
- centerX: number;
72
- centerY: number;
73
- width: number;
74
- height: number;
75
- };
76
- rectToCenterJSON: (v: Models.Camera.View) => {
77
- centerX: number;
78
- centerY: number;
79
- width: number;
80
- height: number;
81
- };
82
- };
61
+ export * from "ts/utils/index";
83
62
  /**
84
63
  * Defines various enums used throughout the Micrio application,
85
64
  * primarily for standardizing action types and option values.
@@ -413,6 +392,7 @@ declare module '@micrio/client' {
413
392
  /**
414
393
  * Loads and instantiates the WebAssembly module.
415
394
  * @returns A Promise that resolves when the Wasm module is ready.
395
+ * @throws Error if WebAssembly binary loading or instantiation fails
416
396
  */
417
397
  load(): Promise<void>;
418
398
  /** Unbinds event listeners, stops rendering, and cleans up resources. */
@@ -2325,6 +2305,326 @@ declare module '@micrio/client' {
2325
2305
  /** Disposes WebGL resources used by the PostProcessor. */
2326
2306
  dispose(): void;
2327
2307
  }
2308
+ /** Type alias for common event types handled. */
2309
+ export type AllEvents = WheelEvent | MouseEvent | TouchEvent;
2310
+ /** Internal state variables used by the Events controller. */
2311
+ export type EventStateVars = {
2312
+ /** Dragging state */
2313
+ drag: {
2314
+ /** Previous pointer coordinates [x, y] during drag. */
2315
+ prev: number[] | undefined;
2316
+ /** Start coordinates and timestamp [x, y, time] of the drag. */
2317
+ start: number[];
2318
+ };
2319
+ /** Double-tap state */
2320
+ dbltap: {
2321
+ /** Timestamp of the last tap. */
2322
+ lastTapped: number;
2323
+ };
2324
+ /** Pinching state */
2325
+ pinch: {
2326
+ /** The image being pinched (relevant for split-screen). */
2327
+ image: MicrioImage | undefined;
2328
+ /** Initial distance between pinch points. */
2329
+ sDst: number;
2330
+ /** Was panning active before pinching started? */
2331
+ wasPanning: boolean;
2332
+ };
2333
+ /** State for debouncing 'update' events. */
2334
+ updates: {
2335
+ /** Timeout ID for the debounced update. */
2336
+ to: number;
2337
+ /** Stack of event types that triggered the update. */
2338
+ stack: string[];
2339
+ };
2340
+ };
2341
+ /** Flag indicating if passive event listeners are supported (assumed true). */
2342
+ export const supportsPassive = true;
2343
+ /** Event listener options for passive listeners. */
2344
+ export const eventPassive: AddEventListenerOptions;
2345
+ /** Event listener options for passive, capturing listeners. */
2346
+ export const eventPassiveCapture: AddEventListenerOptions;
2347
+ /** Event listener options for non-passive listeners (allowing preventDefault). */
2348
+ export const noEventPassive: AddEventListenerOptions;
2349
+ /** Utility function to stop event propagation and prevent default browser behavior. */
2350
+ export function cancelPrevent(e: AllEvents): void;
2351
+ /**
2352
+ * Context object providing access to shared state for event handlers.
2353
+ * This is passed to each handler module to avoid circular dependencies.
2354
+ */
2355
+ export interface EventContext {
2356
+ /** The main Micrio element */
2357
+ micrio: HTMLMicrioElement;
2358
+ /** The canvas element where events are captured */
2359
+ el: HTMLCanvasElement;
2360
+ /** Whether events are currently enabled */
2361
+ isEnabled(): boolean;
2362
+ /** Whether the user is currently panning */
2363
+ isPanning(): boolean;
2364
+ /** Whether the user is currently pinching */
2365
+ isPinching(): boolean;
2366
+ /** Set panning state */
2367
+ setPanning(value: boolean): void;
2368
+ /** Set pinching state */
2369
+ setPinching(value: boolean): void;
2370
+ /** Get/set wheeling state */
2371
+ isWheeling(): boolean;
2372
+ setWheeling(value: boolean): void;
2373
+ /** Whether Ctrl/Cmd key is required for wheel zoom */
2374
+ isControlZoom(): boolean;
2375
+ /** Whether two fingers are required for touch panning */
2376
+ isTwoFingerPan(): boolean;
2377
+ /** Event state variables */
2378
+ vars: EventStateVars;
2379
+ /** Get visible images */
2380
+ getVisible(): MicrioImage[] | undefined;
2381
+ /** Get image under coordinates */
2382
+ getImage(c: {
2383
+ x: number;
2384
+ y: number;
2385
+ }): MicrioImage | undefined;
2386
+ /** Dispatch custom event */
2387
+ dispatch<K extends keyof Models.MicrioEventDetails>(type: K, detail?: Models.MicrioEventDetails[K]): void;
2388
+ /** Active pointers map for pinch detection */
2389
+ activePointers: Map<number, {
2390
+ x: number;
2391
+ y: number;
2392
+ }>;
2393
+ /** Captured pointer ID for dragging */
2394
+ capturedPointerId: number | undefined;
2395
+ setCapturedPointerId(id: number | undefined): void;
2396
+ /** Current pinch factor */
2397
+ pinchFactor: number | undefined;
2398
+ setPinchFactor(value: number | undefined): void;
2399
+ /** Previous scale during gestures */
2400
+ pScale: number;
2401
+ setPScale(value: number): void;
2402
+ /** Has used Ctrl for zoom */
2403
+ hasUsedCtrl: boolean;
2404
+ setHasUsedCtrl(value: boolean): void;
2405
+ /** Has touch support */
2406
+ hasTouch: boolean;
2407
+ }
2408
+ /**
2409
+ * Drag/pan event handler module.
2410
+ * Handles pointer down/move/up events for panning the image.
2411
+ */
2412
+ export class DragHandler {
2413
+ private ctx;
2414
+ private hooked;
2415
+ constructor(ctx: EventContext);
2416
+ /** Hooks pointer down/move/up listeners for drag panning. */
2417
+ hook(): void;
2418
+ /** Unhooks pointer listeners for drag panning. */
2419
+ unhook(): void;
2420
+ /**
2421
+ * Handles the start of a drag/pan operation (pointerdown).
2422
+ * @param e The PointerEvent.
2423
+ * @param force If true, forces drag start even if target isn't the canvas.
2424
+ */
2425
+ start(e: PointerEvent, force?: boolean): void;
2426
+ /**
2427
+ * Handles pointer movement during a drag/pan operation.
2428
+ * @param e The PointerEvent.
2429
+ */
2430
+ private move;
2431
+ /**
2432
+ * Handles the end of a drag/pan operation (pointerup).
2433
+ * @param e Optional PointerEvent.
2434
+ * @param noKinetic If true, prevents kinetic coasting animation.
2435
+ * @param noDispatch If true, suppresses the 'panend' event.
2436
+ */
2437
+ stop(e?: PointerEvent, noKinetic?: boolean, noDispatch?: boolean): void;
2438
+ }
2439
+ /**
2440
+ * Touch pinch event handler module (iOS).
2441
+ * Handles touchstart/touchmove/touchend events for pinch-to-zoom gestures.
2442
+ */
2443
+ export class PinchHandler {
2444
+ private ctx;
2445
+ private dragHandler;
2446
+ constructor(ctx: EventContext, dragHandler: DragHandler);
2447
+ /** Hooks touch pinch event listeners (iOS only). */
2448
+ hook(): void;
2449
+ /** Unhooks touch pinch event listeners. */
2450
+ unhook(): void;
2451
+ /**
2452
+ * Handles the start of a touch pinch gesture (touchstart with two fingers).
2453
+ * @param e The TouchEvent.
2454
+ */
2455
+ start(e: TouchEvent | Event): void;
2456
+ /**
2457
+ * Handles touch movement during a pinch gesture.
2458
+ * @param e The TouchEvent.
2459
+ */
2460
+ private move;
2461
+ /**
2462
+ * Handles the end of a touch pinch gesture (touchend).
2463
+ * @param e The TouchEvent or MouseEvent.
2464
+ */
2465
+ stop(e: MouseEvent | TouchEvent): void;
2466
+ }
2467
+ /**
2468
+ * Pointer-based pinch event handler module.
2469
+ * Handles pointerdown/pointermove/pointerup events for pinch-to-zoom gestures.
2470
+ * Works on Windows touchscreens, Android, and other platforms supporting Pointer Events.
2471
+ */
2472
+ export class PointerPinchHandler {
2473
+ private ctx;
2474
+ private dragHandler;
2475
+ constructor(ctx: EventContext, dragHandler: DragHandler);
2476
+ /** Hooks pointer pinch event listeners. */
2477
+ hook(): void;
2478
+ /** Unhooks pointer pinch event listeners. */
2479
+ unhook(): void;
2480
+ /**
2481
+ * Handles pointer down for multi-touch pinch detection.
2482
+ * @param e The PointerEvent.
2483
+ */
2484
+ start(e: PointerEvent): void;
2485
+ /**
2486
+ * Handles pointer move during a multi-touch pinch gesture.
2487
+ * @param e The PointerEvent.
2488
+ */
2489
+ private move;
2490
+ /**
2491
+ * Handles pointer up/cancel - always called to track active pointers.
2492
+ * Also ends pinch gesture when needed.
2493
+ * @param e The PointerEvent.
2494
+ */
2495
+ end(e: PointerEvent): void;
2496
+ }
2497
+ /**
2498
+ * macOS trackpad gesture event handler module.
2499
+ * Handles gesturestart/gesturechange/gestureend events for trackpad pinch-to-zoom.
2500
+ */
2501
+ export class GestureHandler {
2502
+ private ctx;
2503
+ constructor(ctx: EventContext);
2504
+ /** Hooks macOS gesture event listeners. */
2505
+ hook(): void;
2506
+ /** Unhooks macOS gesture event listeners. */
2507
+ unhook(): void;
2508
+ /**
2509
+ * GestureEvent interface for macOS trackpad gestures.
2510
+ * @param e The Event object.
2511
+ * @returns Gesture data or null if not a gesture event.
2512
+ */
2513
+ private getGestureEvent;
2514
+ /**
2515
+ * Handles macOS trackpad gesture events.
2516
+ * Translates gesture scale into zoom actions.
2517
+ * @param e The GestureEvent.
2518
+ */
2519
+ private handle;
2520
+ }
2521
+ /**
2522
+ * Mouse wheel/scroll event handler module.
2523
+ * Handles wheel events for zooming and panning.
2524
+ */
2525
+ export class WheelHandler {
2526
+ private ctx;
2527
+ /** Flag indicating if scroll listeners are attached. */
2528
+ hooked: boolean;
2529
+ /** Timeout ID for debouncing the 'wheelend' event. */
2530
+ private wheelEndTo;
2531
+ constructor(ctx: EventContext);
2532
+ /** Hooks mouse wheel/scroll event listeners. */
2533
+ hook(): void;
2534
+ /** Unhooks mouse wheel/scroll event listeners. */
2535
+ unhook(): void;
2536
+ /**
2537
+ * Handles mouse wheel events for zooming.
2538
+ * @param e The WheelEvent.
2539
+ * @param force Force handling even if conditions normally prevent it.
2540
+ * @param offX Optional X offset for zoom focus.
2541
+ */
2542
+ handle(e: WheelEvent | Event, force?: boolean, offX?: number): void;
2543
+ /** Clears the wheeling state after a short delay. */
2544
+ private end;
2545
+ }
2546
+ /**
2547
+ * Keyboard event handler module.
2548
+ * Handles keydown events for keyboard navigation (arrows, +/-).
2549
+ */
2550
+ export class KeyboardHandler {
2551
+ private ctx;
2552
+ constructor(ctx: EventContext);
2553
+ /** Hooks keyboard event listeners. */
2554
+ hook(): void;
2555
+ /** Unhooks keyboard event listeners. */
2556
+ unhook(): void;
2557
+ /**
2558
+ * Handles keydown events for keyboard navigation.
2559
+ * @param e The KeyboardEvent.
2560
+ */
2561
+ private handle;
2562
+ }
2563
+ /**
2564
+ * Double-tap/click event handler module.
2565
+ * Handles double-tap (touch) and double-click (mouse) events for zooming.
2566
+ */
2567
+ export class DoubleTapHandler {
2568
+ private ctx;
2569
+ constructor(ctx: EventContext);
2570
+ /** Hooks double-tap event listener (mobile). */
2571
+ hookTap(): void;
2572
+ /** Unhooks double-tap event listener. */
2573
+ unhookTap(): void;
2574
+ /** Hooks double-click event listener (desktop). */
2575
+ hookClick(): void;
2576
+ /** Unhooks double-click event listener. */
2577
+ unhookClick(): void;
2578
+ /**
2579
+ * Handles double-tap detection on touch devices.
2580
+ * @param e The TouchEvent.
2581
+ */
2582
+ private tap;
2583
+ /**
2584
+ * Handles double-click (mouse) or double-tap (touch) events for zooming.
2585
+ * Zooms in if zoomed out, zooms out fully otherwise.
2586
+ * @param e The MouseEvent or TouchEvent.
2587
+ */
2588
+ private click;
2589
+ }
2590
+ /**
2591
+ * List of internal Micrio event types that should trigger a debounced 'update' event.
2592
+ * The 'update' event signals that the overall state relevant for external integrations might have changed.
2593
+ * @readonly
2594
+ */
2595
+ export const UpdateEvents: (keyof Models.MicrioEventMap)[];
2596
+ /**
2597
+ * Update event handler module.
2598
+ * Manages debounced 'update' event dispatching when internal state changes.
2599
+ */
2600
+ export class UpdateHandler {
2601
+ private ctx;
2602
+ constructor(ctx: EventContext);
2603
+ /** Hooks listeners for events that should trigger a debounced 'update' event. */
2604
+ hook(): void;
2605
+ /** Unhooks listeners for the debounced 'update' event. */
2606
+ unhook(): void;
2607
+ /**
2608
+ * Event listener callback that queues the event type and triggers the debounced dispatch.
2609
+ * @param e The Event object.
2610
+ */
2611
+ private handleEvent;
2612
+ /**
2613
+ * Dispatches the 'update' event with the accumulated event types and current state.
2614
+ * Clears the event stack.
2615
+ */
2616
+ private dispatch;
2617
+ }
2618
+ export { DragHandler } from "ts/events/drag";
2619
+ export { PinchHandler } from "ts/events/pinch";
2620
+ export { PointerPinchHandler } from "ts/events/pointer-pinch";
2621
+ export { GestureHandler } from "ts/events/gesture";
2622
+ export { WheelHandler } from "ts/events/wheel";
2623
+ export { KeyboardHandler } from "ts/events/keyboard";
2624
+ export { DoubleTapHandler } from "ts/events/doubletap";
2625
+ export { UpdateHandler, UpdateEvents } from "ts/events/update";
2626
+ export { type AllEvents, type EventStateVars, type EventContext, supportsPassive, eventPassive, eventPassiveCapture, noEventPassive, cancelPrevent, } from "ts/events/shared";
2627
+ export { UpdateEvents } from "ts/events/index";
2328
2628
  /**
2329
2629
  * Handles user input events (mouse, touch, keyboard, wheel, gestures) for the Micrio viewer.
2330
2630
  * Translates browser events into camera movements (pan, zoom), dispatches custom Micrio events,
@@ -2332,13 +2632,35 @@ declare module '@micrio/client' {
2332
2632
  * Accessed via `micrio.events`.
2333
2633
  * @author Marcel Duin <marcel@micr.io>
2334
2634
  */
2335
- export class Events {
2635
+ export class Events implements EventContext {
2336
2636
  /** Writable Svelte store indicating if event handling is currently enabled. Set to false during tours or animations. */
2337
2637
  enabled: Writable<boolean>;
2338
2638
  /** Getter for the current value of the {@link enabled} store. */
2339
2639
  get $enabled(): boolean;
2340
2640
  /** Current pinch zoom factor relative to the start of the pinch. Undefined when not pinching. */
2341
2641
  pinchFactor: number | undefined;
2642
+ private dragHandler;
2643
+ private pinchHandler;
2644
+ private pointerPinchHandler;
2645
+ private gestureHandler;
2646
+ private wheelHandler;
2647
+ private keyboardHandler;
2648
+ private doubleTapHandler;
2649
+ private updateHandler;
2650
+ isEnabled(): boolean;
2651
+ isPanning(): boolean;
2652
+ isPinching(): boolean;
2653
+ setPanning(value: boolean): void;
2654
+ setPinching(value: boolean): void;
2655
+ isWheeling(): boolean;
2656
+ setWheeling(value: boolean): void;
2657
+ isControlZoom(): boolean;
2658
+ isTwoFingerPan(): boolean;
2659
+ getVisible(): MicrioImage[] | undefined;
2660
+ setCapturedPointerId(id: number | undefined): void;
2661
+ setPinchFactor(value: number | undefined): void;
2662
+ setPScale(value: number): void;
2663
+ setHasUsedCtrl(value: boolean): void;
2342
2664
  /**
2343
2665
  * Checks if the user is currently interacting with the map via panning, pinching, or wheeling.
2344
2666
  * @returns True if the user is actively navigating.