@micrio/client 5.4.16 → 5.4.18
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 +589 -47
- package/micrio.min.js +3 -3
- package/package.json +1 -1
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.
|
|
7
|
+
export const VERSION = "5.4.18";
|
|
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,82 @@ declare module '@micrio/client' {
|
|
|
27
33
|
YouTube = 1,
|
|
28
34
|
Vimeo = 2
|
|
29
35
|
}
|
|
36
|
+
export { isLegacyViews };
|
|
30
37
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
33
|
-
* @returns Formatted time string (e.g., "1:23", "1:05:09", "-0:15").
|
|
38
|
+
* Media utilities for source parsing, type detection, and player management.
|
|
39
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
34
40
|
*/
|
|
35
|
-
|
|
36
|
-
export const
|
|
41
|
+
/** YouTube no-cookies host */
|
|
42
|
+
export const YOUTUBE_HOST = "https://www.youtube-nocookie.com";
|
|
37
43
|
/**
|
|
38
|
-
*
|
|
39
|
-
* @private
|
|
44
|
+
* Parsed media source information.
|
|
40
45
|
*/
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
export interface ParsedMediaSource {
|
|
47
|
+
/** The detected media type */
|
|
48
|
+
type: MediaType;
|
|
49
|
+
/** The frame type for iframe embeds (YouTube/Vimeo) */
|
|
50
|
+
frameType?: FrameType;
|
|
51
|
+
/** The normalized/processed source URL */
|
|
52
|
+
src?: string;
|
|
53
|
+
/** Original source URL */
|
|
54
|
+
originalSrc?: string;
|
|
55
|
+
/** YouTube video ID (if applicable) */
|
|
56
|
+
youtubeId?: string;
|
|
57
|
+
/** Vimeo video ID (if applicable) */
|
|
58
|
+
vimeoId?: string;
|
|
59
|
+
/** Vimeo hash token (if applicable) */
|
|
60
|
+
vimeoToken?: string;
|
|
61
|
+
/** Cloudflare video ID (if applicable) */
|
|
62
|
+
cloudflareId?: string;
|
|
63
|
+
/** Micrio embed data [id, width?, height?, lang?] */
|
|
64
|
+
micrioEmbed?: string[];
|
|
65
|
+
/** Start time extracted from URL (seconds) */
|
|
66
|
+
startTime?: number;
|
|
67
|
+
/** Whether the source is a Cloudflare stream */
|
|
68
|
+
isCloudflare: boolean;
|
|
69
|
+
/** M3U8 URL for HLS streams */
|
|
70
|
+
hlsSrc?: string;
|
|
71
|
+
}
|
|
46
72
|
/**
|
|
47
|
-
*
|
|
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.
|
|
73
|
+
* Parses a media source URL and determines its type and configuration.
|
|
53
74
|
*/
|
|
54
|
-
export function
|
|
55
|
-
vector: Models.Camera.Vector;
|
|
56
|
-
directionX: number;
|
|
57
|
-
v: Models.Spaces.DirectionVector;
|
|
58
|
-
vN: Models.Spaces.DirectionVector;
|
|
59
|
-
} | undefined;
|
|
75
|
+
export function parseMediaSource(src: string | undefined, tour: Models.ImageData.VideoTour | null, useNativeFrames?: boolean, currentTime?: number): ParsedMediaSource;
|
|
60
76
|
/**
|
|
61
|
-
* Checks if the browser natively supports HLS
|
|
62
|
-
* @private
|
|
63
|
-
* @param video Optional HTMLVideoElement to check (defaults to creating a temporary one).
|
|
64
|
-
* @returns True if native HLS support is detected.
|
|
77
|
+
* Checks if the browser natively supports HLS playback.
|
|
65
78
|
*/
|
|
66
|
-
export
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
};
|
|
79
|
+
export function hasNativeHLS(el?: HTMLMediaElement): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Returns a shared Audio element instance for iOS.
|
|
82
|
+
* This is a workaround for iOS audio playback restrictions where user
|
|
83
|
+
* interaction is required per audio element.
|
|
84
|
+
*/
|
|
85
|
+
export function getIOSAudioElement(): HTMLAudioElement;
|
|
86
|
+
/**
|
|
87
|
+
* Global utility functions used throughout the Micrio application.
|
|
88
|
+
* Re-exports all utility modules for convenient importing.
|
|
89
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
90
|
+
*/
|
|
91
|
+
export { MicrioError } from "ts/utils/error";
|
|
92
|
+
export { pyth, mod, limitView } from "ts/utils/math";
|
|
93
|
+
export { clone, deepCopy } from "ts/utils/object";
|
|
94
|
+
export { createGUID, slugify, parseTime } from "ts/utils/string";
|
|
95
|
+
export { Browser } from "ts/utils/browser";
|
|
96
|
+
export { sleep, notypecheck, loadScript } from "ts/utils/dom";
|
|
97
|
+
export { once, after } from "ts/utils/store";
|
|
98
|
+
export { View } from "ts/utils/view";
|
|
99
|
+
export { sanitizeAsset, isLegacyViews, sanitizeImageInfo, sanitizeImageData, sanitizeSpaceData, sanitizeMarker, sanitizeVideoTour } from "ts/utils/sanitize";
|
|
100
|
+
export { jsonCache, fetchJson, isFetching, getLocalData, fetchInfo, fetchAlbumInfo } from "ts/utils/fetch";
|
|
101
|
+
export { loadSerialTour } from "ts/utils/tour";
|
|
102
|
+
export { getIdVal, idIsV5 } from "ts/utils/id";
|
|
103
|
+
export { getSpaceVector } from "ts/utils/space";
|
|
104
|
+
export { hasNativeHLS, parseMediaSource, getIOSAudioElement, YOUTUBE_HOST } from "ts/utils/media";
|
|
105
|
+
export type { ParsedMediaSource } from "ts/utils/media";
|
|
106
|
+
/**
|
|
107
|
+
* Global utility functions used throughout the Micrio application.
|
|
108
|
+
* This file re-exports all utilities from the modular utils/ directory.
|
|
109
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
110
|
+
*/
|
|
111
|
+
export * from "ts/utils/index";
|
|
83
112
|
/**
|
|
84
113
|
* Defines various enums used throughout the Micrio application,
|
|
85
114
|
* primarily for standardizing action types and option values.
|
|
@@ -413,6 +442,7 @@ declare module '@micrio/client' {
|
|
|
413
442
|
/**
|
|
414
443
|
* Loads and instantiates the WebAssembly module.
|
|
415
444
|
* @returns A Promise that resolves when the Wasm module is ready.
|
|
445
|
+
* @throws Error if WebAssembly binary loading or instantiation fails
|
|
416
446
|
*/
|
|
417
447
|
load(): Promise<void>;
|
|
418
448
|
/** Unbinds event listeners, stops rendering, and cleans up resources. */
|
|
@@ -2325,6 +2355,326 @@ declare module '@micrio/client' {
|
|
|
2325
2355
|
/** Disposes WebGL resources used by the PostProcessor. */
|
|
2326
2356
|
dispose(): void;
|
|
2327
2357
|
}
|
|
2358
|
+
/** Type alias for common event types handled. */
|
|
2359
|
+
export type AllEvents = WheelEvent | MouseEvent | TouchEvent;
|
|
2360
|
+
/** Internal state variables used by the Events controller. */
|
|
2361
|
+
export type EventStateVars = {
|
|
2362
|
+
/** Dragging state */
|
|
2363
|
+
drag: {
|
|
2364
|
+
/** Previous pointer coordinates [x, y] during drag. */
|
|
2365
|
+
prev: number[] | undefined;
|
|
2366
|
+
/** Start coordinates and timestamp [x, y, time] of the drag. */
|
|
2367
|
+
start: number[];
|
|
2368
|
+
};
|
|
2369
|
+
/** Double-tap state */
|
|
2370
|
+
dbltap: {
|
|
2371
|
+
/** Timestamp of the last tap. */
|
|
2372
|
+
lastTapped: number;
|
|
2373
|
+
};
|
|
2374
|
+
/** Pinching state */
|
|
2375
|
+
pinch: {
|
|
2376
|
+
/** The image being pinched (relevant for split-screen). */
|
|
2377
|
+
image: MicrioImage | undefined;
|
|
2378
|
+
/** Initial distance between pinch points. */
|
|
2379
|
+
sDst: number;
|
|
2380
|
+
/** Was panning active before pinching started? */
|
|
2381
|
+
wasPanning: boolean;
|
|
2382
|
+
};
|
|
2383
|
+
/** State for debouncing 'update' events. */
|
|
2384
|
+
updates: {
|
|
2385
|
+
/** Timeout ID for the debounced update. */
|
|
2386
|
+
to: number;
|
|
2387
|
+
/** Stack of event types that triggered the update. */
|
|
2388
|
+
stack: string[];
|
|
2389
|
+
};
|
|
2390
|
+
};
|
|
2391
|
+
/** Flag indicating if passive event listeners are supported (assumed true). */
|
|
2392
|
+
export const supportsPassive = true;
|
|
2393
|
+
/** Event listener options for passive listeners. */
|
|
2394
|
+
export const eventPassive: AddEventListenerOptions;
|
|
2395
|
+
/** Event listener options for passive, capturing listeners. */
|
|
2396
|
+
export const eventPassiveCapture: AddEventListenerOptions;
|
|
2397
|
+
/** Event listener options for non-passive listeners (allowing preventDefault). */
|
|
2398
|
+
export const noEventPassive: AddEventListenerOptions;
|
|
2399
|
+
/** Utility function to stop event propagation and prevent default browser behavior. */
|
|
2400
|
+
export function cancelPrevent(e: AllEvents): void;
|
|
2401
|
+
/**
|
|
2402
|
+
* Context object providing access to shared state for event handlers.
|
|
2403
|
+
* This is passed to each handler module to avoid circular dependencies.
|
|
2404
|
+
*/
|
|
2405
|
+
export interface EventContext {
|
|
2406
|
+
/** The main Micrio element */
|
|
2407
|
+
micrio: HTMLMicrioElement;
|
|
2408
|
+
/** The canvas element where events are captured */
|
|
2409
|
+
el: HTMLCanvasElement;
|
|
2410
|
+
/** Whether events are currently enabled */
|
|
2411
|
+
isEnabled(): boolean;
|
|
2412
|
+
/** Whether the user is currently panning */
|
|
2413
|
+
isPanning(): boolean;
|
|
2414
|
+
/** Whether the user is currently pinching */
|
|
2415
|
+
isPinching(): boolean;
|
|
2416
|
+
/** Set panning state */
|
|
2417
|
+
setPanning(value: boolean): void;
|
|
2418
|
+
/** Set pinching state */
|
|
2419
|
+
setPinching(value: boolean): void;
|
|
2420
|
+
/** Get/set wheeling state */
|
|
2421
|
+
isWheeling(): boolean;
|
|
2422
|
+
setWheeling(value: boolean): void;
|
|
2423
|
+
/** Whether Ctrl/Cmd key is required for wheel zoom */
|
|
2424
|
+
isControlZoom(): boolean;
|
|
2425
|
+
/** Whether two fingers are required for touch panning */
|
|
2426
|
+
isTwoFingerPan(): boolean;
|
|
2427
|
+
/** Event state variables */
|
|
2428
|
+
vars: EventStateVars;
|
|
2429
|
+
/** Get visible images */
|
|
2430
|
+
getVisible(): MicrioImage[] | undefined;
|
|
2431
|
+
/** Get image under coordinates */
|
|
2432
|
+
getImage(c: {
|
|
2433
|
+
x: number;
|
|
2434
|
+
y: number;
|
|
2435
|
+
}): MicrioImage | undefined;
|
|
2436
|
+
/** Dispatch custom event */
|
|
2437
|
+
dispatch<K extends keyof Models.MicrioEventDetails>(type: K, detail?: Models.MicrioEventDetails[K]): void;
|
|
2438
|
+
/** Active pointers map for pinch detection */
|
|
2439
|
+
activePointers: Map<number, {
|
|
2440
|
+
x: number;
|
|
2441
|
+
y: number;
|
|
2442
|
+
}>;
|
|
2443
|
+
/** Captured pointer ID for dragging */
|
|
2444
|
+
capturedPointerId: number | undefined;
|
|
2445
|
+
setCapturedPointerId(id: number | undefined): void;
|
|
2446
|
+
/** Current pinch factor */
|
|
2447
|
+
pinchFactor: number | undefined;
|
|
2448
|
+
setPinchFactor(value: number | undefined): void;
|
|
2449
|
+
/** Previous scale during gestures */
|
|
2450
|
+
pScale: number;
|
|
2451
|
+
setPScale(value: number): void;
|
|
2452
|
+
/** Has used Ctrl for zoom */
|
|
2453
|
+
hasUsedCtrl: boolean;
|
|
2454
|
+
setHasUsedCtrl(value: boolean): void;
|
|
2455
|
+
/** Has touch support */
|
|
2456
|
+
hasTouch: boolean;
|
|
2457
|
+
}
|
|
2458
|
+
/**
|
|
2459
|
+
* Drag/pan event handler module.
|
|
2460
|
+
* Handles pointer down/move/up events for panning the image.
|
|
2461
|
+
*/
|
|
2462
|
+
export class DragHandler {
|
|
2463
|
+
private ctx;
|
|
2464
|
+
private hooked;
|
|
2465
|
+
constructor(ctx: EventContext);
|
|
2466
|
+
/** Hooks pointer down/move/up listeners for drag panning. */
|
|
2467
|
+
hook(): void;
|
|
2468
|
+
/** Unhooks pointer listeners for drag panning. */
|
|
2469
|
+
unhook(): void;
|
|
2470
|
+
/**
|
|
2471
|
+
* Handles the start of a drag/pan operation (pointerdown).
|
|
2472
|
+
* @param e The PointerEvent.
|
|
2473
|
+
* @param force If true, forces drag start even if target isn't the canvas.
|
|
2474
|
+
*/
|
|
2475
|
+
start(e: PointerEvent, force?: boolean): void;
|
|
2476
|
+
/**
|
|
2477
|
+
* Handles pointer movement during a drag/pan operation.
|
|
2478
|
+
* @param e The PointerEvent.
|
|
2479
|
+
*/
|
|
2480
|
+
private move;
|
|
2481
|
+
/**
|
|
2482
|
+
* Handles the end of a drag/pan operation (pointerup).
|
|
2483
|
+
* @param e Optional PointerEvent.
|
|
2484
|
+
* @param noKinetic If true, prevents kinetic coasting animation.
|
|
2485
|
+
* @param noDispatch If true, suppresses the 'panend' event.
|
|
2486
|
+
*/
|
|
2487
|
+
stop(e?: PointerEvent, noKinetic?: boolean, noDispatch?: boolean): void;
|
|
2488
|
+
}
|
|
2489
|
+
/**
|
|
2490
|
+
* Touch pinch event handler module (iOS).
|
|
2491
|
+
* Handles touchstart/touchmove/touchend events for pinch-to-zoom gestures.
|
|
2492
|
+
*/
|
|
2493
|
+
export class PinchHandler {
|
|
2494
|
+
private ctx;
|
|
2495
|
+
private dragHandler;
|
|
2496
|
+
constructor(ctx: EventContext, dragHandler: DragHandler);
|
|
2497
|
+
/** Hooks touch pinch event listeners (iOS only). */
|
|
2498
|
+
hook(): void;
|
|
2499
|
+
/** Unhooks touch pinch event listeners. */
|
|
2500
|
+
unhook(): void;
|
|
2501
|
+
/**
|
|
2502
|
+
* Handles the start of a touch pinch gesture (touchstart with two fingers).
|
|
2503
|
+
* @param e The TouchEvent.
|
|
2504
|
+
*/
|
|
2505
|
+
start(e: TouchEvent | Event): void;
|
|
2506
|
+
/**
|
|
2507
|
+
* Handles touch movement during a pinch gesture.
|
|
2508
|
+
* @param e The TouchEvent.
|
|
2509
|
+
*/
|
|
2510
|
+
private move;
|
|
2511
|
+
/**
|
|
2512
|
+
* Handles the end of a touch pinch gesture (touchend).
|
|
2513
|
+
* @param e The TouchEvent or MouseEvent.
|
|
2514
|
+
*/
|
|
2515
|
+
stop(e: MouseEvent | TouchEvent): void;
|
|
2516
|
+
}
|
|
2517
|
+
/**
|
|
2518
|
+
* Pointer-based pinch event handler module.
|
|
2519
|
+
* Handles pointerdown/pointermove/pointerup events for pinch-to-zoom gestures.
|
|
2520
|
+
* Works on Windows touchscreens, Android, and other platforms supporting Pointer Events.
|
|
2521
|
+
*/
|
|
2522
|
+
export class PointerPinchHandler {
|
|
2523
|
+
private ctx;
|
|
2524
|
+
private dragHandler;
|
|
2525
|
+
constructor(ctx: EventContext, dragHandler: DragHandler);
|
|
2526
|
+
/** Hooks pointer pinch event listeners. */
|
|
2527
|
+
hook(): void;
|
|
2528
|
+
/** Unhooks pointer pinch event listeners. */
|
|
2529
|
+
unhook(): void;
|
|
2530
|
+
/**
|
|
2531
|
+
* Handles pointer down for multi-touch pinch detection.
|
|
2532
|
+
* @param e The PointerEvent.
|
|
2533
|
+
*/
|
|
2534
|
+
start(e: PointerEvent): void;
|
|
2535
|
+
/**
|
|
2536
|
+
* Handles pointer move during a multi-touch pinch gesture.
|
|
2537
|
+
* @param e The PointerEvent.
|
|
2538
|
+
*/
|
|
2539
|
+
private move;
|
|
2540
|
+
/**
|
|
2541
|
+
* Handles pointer up/cancel - always called to track active pointers.
|
|
2542
|
+
* Also ends pinch gesture when needed.
|
|
2543
|
+
* @param e The PointerEvent.
|
|
2544
|
+
*/
|
|
2545
|
+
end(e: PointerEvent): void;
|
|
2546
|
+
}
|
|
2547
|
+
/**
|
|
2548
|
+
* macOS trackpad gesture event handler module.
|
|
2549
|
+
* Handles gesturestart/gesturechange/gestureend events for trackpad pinch-to-zoom.
|
|
2550
|
+
*/
|
|
2551
|
+
export class GestureHandler {
|
|
2552
|
+
private ctx;
|
|
2553
|
+
constructor(ctx: EventContext);
|
|
2554
|
+
/** Hooks macOS gesture event listeners. */
|
|
2555
|
+
hook(): void;
|
|
2556
|
+
/** Unhooks macOS gesture event listeners. */
|
|
2557
|
+
unhook(): void;
|
|
2558
|
+
/**
|
|
2559
|
+
* GestureEvent interface for macOS trackpad gestures.
|
|
2560
|
+
* @param e The Event object.
|
|
2561
|
+
* @returns Gesture data or null if not a gesture event.
|
|
2562
|
+
*/
|
|
2563
|
+
private getGestureEvent;
|
|
2564
|
+
/**
|
|
2565
|
+
* Handles macOS trackpad gesture events.
|
|
2566
|
+
* Translates gesture scale into zoom actions.
|
|
2567
|
+
* @param e The GestureEvent.
|
|
2568
|
+
*/
|
|
2569
|
+
private handle;
|
|
2570
|
+
}
|
|
2571
|
+
/**
|
|
2572
|
+
* Mouse wheel/scroll event handler module.
|
|
2573
|
+
* Handles wheel events for zooming and panning.
|
|
2574
|
+
*/
|
|
2575
|
+
export class WheelHandler {
|
|
2576
|
+
private ctx;
|
|
2577
|
+
/** Flag indicating if scroll listeners are attached. */
|
|
2578
|
+
hooked: boolean;
|
|
2579
|
+
/** Timeout ID for debouncing the 'wheelend' event. */
|
|
2580
|
+
private wheelEndTo;
|
|
2581
|
+
constructor(ctx: EventContext);
|
|
2582
|
+
/** Hooks mouse wheel/scroll event listeners. */
|
|
2583
|
+
hook(): void;
|
|
2584
|
+
/** Unhooks mouse wheel/scroll event listeners. */
|
|
2585
|
+
unhook(): void;
|
|
2586
|
+
/**
|
|
2587
|
+
* Handles mouse wheel events for zooming.
|
|
2588
|
+
* @param e The WheelEvent.
|
|
2589
|
+
* @param force Force handling even if conditions normally prevent it.
|
|
2590
|
+
* @param offX Optional X offset for zoom focus.
|
|
2591
|
+
*/
|
|
2592
|
+
handle(e: WheelEvent | Event, force?: boolean, offX?: number): void;
|
|
2593
|
+
/** Clears the wheeling state after a short delay. */
|
|
2594
|
+
private end;
|
|
2595
|
+
}
|
|
2596
|
+
/**
|
|
2597
|
+
* Keyboard event handler module.
|
|
2598
|
+
* Handles keydown events for keyboard navigation (arrows, +/-).
|
|
2599
|
+
*/
|
|
2600
|
+
export class KeyboardHandler {
|
|
2601
|
+
private ctx;
|
|
2602
|
+
constructor(ctx: EventContext);
|
|
2603
|
+
/** Hooks keyboard event listeners. */
|
|
2604
|
+
hook(): void;
|
|
2605
|
+
/** Unhooks keyboard event listeners. */
|
|
2606
|
+
unhook(): void;
|
|
2607
|
+
/**
|
|
2608
|
+
* Handles keydown events for keyboard navigation.
|
|
2609
|
+
* @param e The KeyboardEvent.
|
|
2610
|
+
*/
|
|
2611
|
+
private handle;
|
|
2612
|
+
}
|
|
2613
|
+
/**
|
|
2614
|
+
* Double-tap/click event handler module.
|
|
2615
|
+
* Handles double-tap (touch) and double-click (mouse) events for zooming.
|
|
2616
|
+
*/
|
|
2617
|
+
export class DoubleTapHandler {
|
|
2618
|
+
private ctx;
|
|
2619
|
+
constructor(ctx: EventContext);
|
|
2620
|
+
/** Hooks double-tap event listener (mobile). */
|
|
2621
|
+
hookTap(): void;
|
|
2622
|
+
/** Unhooks double-tap event listener. */
|
|
2623
|
+
unhookTap(): void;
|
|
2624
|
+
/** Hooks double-click event listener (desktop). */
|
|
2625
|
+
hookClick(): void;
|
|
2626
|
+
/** Unhooks double-click event listener. */
|
|
2627
|
+
unhookClick(): void;
|
|
2628
|
+
/**
|
|
2629
|
+
* Handles double-tap detection on touch devices.
|
|
2630
|
+
* @param e The TouchEvent.
|
|
2631
|
+
*/
|
|
2632
|
+
private tap;
|
|
2633
|
+
/**
|
|
2634
|
+
* Handles double-click (mouse) or double-tap (touch) events for zooming.
|
|
2635
|
+
* Zooms in if zoomed out, zooms out fully otherwise.
|
|
2636
|
+
* @param e The MouseEvent or TouchEvent.
|
|
2637
|
+
*/
|
|
2638
|
+
private click;
|
|
2639
|
+
}
|
|
2640
|
+
/**
|
|
2641
|
+
* List of internal Micrio event types that should trigger a debounced 'update' event.
|
|
2642
|
+
* The 'update' event signals that the overall state relevant for external integrations might have changed.
|
|
2643
|
+
* @readonly
|
|
2644
|
+
*/
|
|
2645
|
+
export const UpdateEvents: (keyof Models.MicrioEventMap)[];
|
|
2646
|
+
/**
|
|
2647
|
+
* Update event handler module.
|
|
2648
|
+
* Manages debounced 'update' event dispatching when internal state changes.
|
|
2649
|
+
*/
|
|
2650
|
+
export class UpdateHandler {
|
|
2651
|
+
private ctx;
|
|
2652
|
+
constructor(ctx: EventContext);
|
|
2653
|
+
/** Hooks listeners for events that should trigger a debounced 'update' event. */
|
|
2654
|
+
hook(): void;
|
|
2655
|
+
/** Unhooks listeners for the debounced 'update' event. */
|
|
2656
|
+
unhook(): void;
|
|
2657
|
+
/**
|
|
2658
|
+
* Event listener callback that queues the event type and triggers the debounced dispatch.
|
|
2659
|
+
* @param e The Event object.
|
|
2660
|
+
*/
|
|
2661
|
+
private handleEvent;
|
|
2662
|
+
/**
|
|
2663
|
+
* Dispatches the 'update' event with the accumulated event types and current state.
|
|
2664
|
+
* Clears the event stack.
|
|
2665
|
+
*/
|
|
2666
|
+
private dispatch;
|
|
2667
|
+
}
|
|
2668
|
+
export { DragHandler } from "ts/events/drag";
|
|
2669
|
+
export { PinchHandler } from "ts/events/pinch";
|
|
2670
|
+
export { PointerPinchHandler } from "ts/events/pointer-pinch";
|
|
2671
|
+
export { GestureHandler } from "ts/events/gesture";
|
|
2672
|
+
export { WheelHandler } from "ts/events/wheel";
|
|
2673
|
+
export { KeyboardHandler } from "ts/events/keyboard";
|
|
2674
|
+
export { DoubleTapHandler } from "ts/events/doubletap";
|
|
2675
|
+
export { UpdateHandler, UpdateEvents } from "ts/events/update";
|
|
2676
|
+
export { type AllEvents, type EventStateVars, type EventContext, supportsPassive, eventPassive, eventPassiveCapture, noEventPassive, cancelPrevent, } from "ts/events/shared";
|
|
2677
|
+
export { UpdateEvents } from "ts/events/index";
|
|
2328
2678
|
/**
|
|
2329
2679
|
* Handles user input events (mouse, touch, keyboard, wheel, gestures) for the Micrio viewer.
|
|
2330
2680
|
* Translates browser events into camera movements (pan, zoom), dispatches custom Micrio events,
|
|
@@ -2332,13 +2682,35 @@ declare module '@micrio/client' {
|
|
|
2332
2682
|
* Accessed via `micrio.events`.
|
|
2333
2683
|
* @author Marcel Duin <marcel@micr.io>
|
|
2334
2684
|
*/
|
|
2335
|
-
export class Events {
|
|
2685
|
+
export class Events implements EventContext {
|
|
2336
2686
|
/** Writable Svelte store indicating if event handling is currently enabled. Set to false during tours or animations. */
|
|
2337
2687
|
enabled: Writable<boolean>;
|
|
2338
2688
|
/** Getter for the current value of the {@link enabled} store. */
|
|
2339
2689
|
get $enabled(): boolean;
|
|
2340
2690
|
/** Current pinch zoom factor relative to the start of the pinch. Undefined when not pinching. */
|
|
2341
2691
|
pinchFactor: number | undefined;
|
|
2692
|
+
private dragHandler;
|
|
2693
|
+
private pinchHandler;
|
|
2694
|
+
private pointerPinchHandler;
|
|
2695
|
+
private gestureHandler;
|
|
2696
|
+
private wheelHandler;
|
|
2697
|
+
private keyboardHandler;
|
|
2698
|
+
private doubleTapHandler;
|
|
2699
|
+
private updateHandler;
|
|
2700
|
+
isEnabled(): boolean;
|
|
2701
|
+
isPanning(): boolean;
|
|
2702
|
+
isPinching(): boolean;
|
|
2703
|
+
setPanning(value: boolean): void;
|
|
2704
|
+
setPinching(value: boolean): void;
|
|
2705
|
+
isWheeling(): boolean;
|
|
2706
|
+
setWheeling(value: boolean): void;
|
|
2707
|
+
isControlZoom(): boolean;
|
|
2708
|
+
isTwoFingerPan(): boolean;
|
|
2709
|
+
getVisible(): MicrioImage[] | undefined;
|
|
2710
|
+
setCapturedPointerId(id: number | undefined): void;
|
|
2711
|
+
setPinchFactor(value: number | undefined): void;
|
|
2712
|
+
setPScale(value: number): void;
|
|
2713
|
+
setHasUsedCtrl(value: boolean): void;
|
|
2342
2714
|
/**
|
|
2343
2715
|
* Checks if the user is currently interacting with the map via panning, pinching, or wheeling.
|
|
2344
2716
|
* @returns True if the user is actively navigating.
|
|
@@ -2630,6 +3002,176 @@ declare module '@micrio/client' {
|
|
|
2630
3002
|
/** Cleans up resources when the parent Embed component is unmounted. */
|
|
2631
3003
|
unmount(): void;
|
|
2632
3004
|
}
|
|
3005
|
+
/**
|
|
3006
|
+
* Media player type definitions and interfaces.
|
|
3007
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3008
|
+
*/
|
|
3009
|
+
/**
|
|
3010
|
+
* Common interface for all media player adapters.
|
|
3011
|
+
* Abstracts the differences between HTML5, YouTube, Vimeo, and HLS players.
|
|
3012
|
+
*/
|
|
3013
|
+
export interface MediaPlayerAdapter {
|
|
3014
|
+
/** Play the media */
|
|
3015
|
+
play(): Promise<void>;
|
|
3016
|
+
/** Pause the media */
|
|
3017
|
+
pause(): void;
|
|
3018
|
+
/** Get current playback time in seconds */
|
|
3019
|
+
getCurrentTime(): Promise<number>;
|
|
3020
|
+
/** Set current playback time in seconds */
|
|
3021
|
+
setCurrentTime(time: number): void;
|
|
3022
|
+
/** Get total duration in seconds */
|
|
3023
|
+
getDuration(): Promise<number>;
|
|
3024
|
+
/** Check if media is currently paused */
|
|
3025
|
+
isPaused(): Promise<boolean>;
|
|
3026
|
+
/** Set muted state */
|
|
3027
|
+
setMuted(muted: boolean): void;
|
|
3028
|
+
/** Set volume (0-1) */
|
|
3029
|
+
setVolume(volume: number): void;
|
|
3030
|
+
/** Clean up resources */
|
|
3031
|
+
destroy(): void;
|
|
3032
|
+
/** Whether this adapter requires manual time updates via interval */
|
|
3033
|
+
readonly requiresTimeTick: boolean;
|
|
3034
|
+
}
|
|
3035
|
+
/**
|
|
3036
|
+
* Event callbacks for player state changes.
|
|
3037
|
+
*/
|
|
3038
|
+
export interface PlayerEventCallbacks {
|
|
3039
|
+
onPlay?: () => void;
|
|
3040
|
+
onPause?: () => void;
|
|
3041
|
+
onEnded?: () => void;
|
|
3042
|
+
onSeeking?: () => void;
|
|
3043
|
+
onSeeked?: () => void;
|
|
3044
|
+
onTimeUpdate?: (time: number) => void;
|
|
3045
|
+
onDurationChange?: (duration: number) => void;
|
|
3046
|
+
onError?: (error: Error) => void;
|
|
3047
|
+
onBuffering?: () => void;
|
|
3048
|
+
onReady?: () => void;
|
|
3049
|
+
onBlocked?: () => void;
|
|
3050
|
+
}
|
|
3051
|
+
/**
|
|
3052
|
+
* Configuration for creating a player adapter.
|
|
3053
|
+
*/
|
|
3054
|
+
export interface PlayerConfig {
|
|
3055
|
+
width: number;
|
|
3056
|
+
height: number;
|
|
3057
|
+
autoplay?: boolean;
|
|
3058
|
+
loop?: boolean;
|
|
3059
|
+
muted?: boolean;
|
|
3060
|
+
volume?: number;
|
|
3061
|
+
startTime?: number;
|
|
3062
|
+
}
|
|
3063
|
+
/**
|
|
3064
|
+
* HTML5 Media Element adapter.
|
|
3065
|
+
* Wraps native <audio> and <video> elements with a common interface.
|
|
3066
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3067
|
+
*/
|
|
3068
|
+
/**
|
|
3069
|
+
* Adapter for native HTML5 audio/video elements.
|
|
3070
|
+
*/
|
|
3071
|
+
export class HTML5PlayerAdapter implements MediaPlayerAdapter {
|
|
3072
|
+
private element;
|
|
3073
|
+
private callbacks;
|
|
3074
|
+
readonly requiresTimeTick = false;
|
|
3075
|
+
constructor(element: HTMLMediaElement, callbacks?: PlayerEventCallbacks);
|
|
3076
|
+
private attachEventListeners;
|
|
3077
|
+
play(): Promise<void>;
|
|
3078
|
+
pause(): void;
|
|
3079
|
+
getCurrentTime(): Promise<number>;
|
|
3080
|
+
setCurrentTime(time: number): void;
|
|
3081
|
+
getDuration(): Promise<number>;
|
|
3082
|
+
isPaused(): Promise<boolean>;
|
|
3083
|
+
setMuted(muted: boolean): void;
|
|
3084
|
+
setVolume(volume: number): void;
|
|
3085
|
+
destroy(): void;
|
|
3086
|
+
}
|
|
3087
|
+
/**
|
|
3088
|
+
* Adapter for HLS.js streaming video.
|
|
3089
|
+
* Extends HTML5PlayerAdapter since HLS.js attaches to a video element.
|
|
3090
|
+
*/
|
|
3091
|
+
export class HLSPlayerAdapter implements MediaPlayerAdapter {
|
|
3092
|
+
private element;
|
|
3093
|
+
private hlsSrc;
|
|
3094
|
+
private callbacks;
|
|
3095
|
+
readonly requiresTimeTick = false;
|
|
3096
|
+
private hls;
|
|
3097
|
+
private html5Adapter;
|
|
3098
|
+
private destroyed;
|
|
3099
|
+
constructor(element: HTMLVideoElement, hlsSrc: string, callbacks?: PlayerEventCallbacks);
|
|
3100
|
+
/**
|
|
3101
|
+
* Loads HLS.js and attaches to the video element.
|
|
3102
|
+
*/
|
|
3103
|
+
initialize(): Promise<void>;
|
|
3104
|
+
play(): Promise<void>;
|
|
3105
|
+
pause(): void;
|
|
3106
|
+
getCurrentTime(): Promise<number>;
|
|
3107
|
+
setCurrentTime(time: number): void;
|
|
3108
|
+
getDuration(): Promise<number>;
|
|
3109
|
+
isPaused(): Promise<boolean>;
|
|
3110
|
+
setMuted(muted: boolean): void;
|
|
3111
|
+
setVolume(volume: number): void;
|
|
3112
|
+
destroy(): void;
|
|
3113
|
+
}
|
|
3114
|
+
/**
|
|
3115
|
+
* Adapter for YouTube IFrame Player API.
|
|
3116
|
+
*/
|
|
3117
|
+
export class YouTubePlayerAdapter implements MediaPlayerAdapter {
|
|
3118
|
+
private frame;
|
|
3119
|
+
private config;
|
|
3120
|
+
private callbacks;
|
|
3121
|
+
readonly requiresTimeTick = true;
|
|
3122
|
+
private player;
|
|
3123
|
+
private destroyed;
|
|
3124
|
+
constructor(frame: HTMLIFrameElement, config: PlayerConfig, callbacks?: PlayerEventCallbacks);
|
|
3125
|
+
/**
|
|
3126
|
+
* Loads the YouTube API and initializes the player.
|
|
3127
|
+
*/
|
|
3128
|
+
initialize(): Promise<void>;
|
|
3129
|
+
private handleStateChange;
|
|
3130
|
+
play(): Promise<void>;
|
|
3131
|
+
pause(): void;
|
|
3132
|
+
getCurrentTime(): Promise<number>;
|
|
3133
|
+
setCurrentTime(time: number): void;
|
|
3134
|
+
getDuration(): Promise<number>;
|
|
3135
|
+
isPaused(): Promise<boolean>;
|
|
3136
|
+
setMuted(muted: boolean): void;
|
|
3137
|
+
setVolume(_volume: number): void;
|
|
3138
|
+
destroy(): void;
|
|
3139
|
+
}
|
|
3140
|
+
/**
|
|
3141
|
+
* Adapter for Vimeo Player API.
|
|
3142
|
+
*/
|
|
3143
|
+
export class VimeoPlayerAdapter implements MediaPlayerAdapter {
|
|
3144
|
+
private frame;
|
|
3145
|
+
private config;
|
|
3146
|
+
private callbacks;
|
|
3147
|
+
readonly requiresTimeTick = false;
|
|
3148
|
+
private player;
|
|
3149
|
+
private destroyed;
|
|
3150
|
+
constructor(frame: HTMLIFrameElement, config: PlayerConfig, callbacks?: PlayerEventCallbacks);
|
|
3151
|
+
/**
|
|
3152
|
+
* Loads the Vimeo API and initializes the player.
|
|
3153
|
+
*/
|
|
3154
|
+
initialize(): Promise<void>;
|
|
3155
|
+
play(): Promise<void>;
|
|
3156
|
+
pause(): void;
|
|
3157
|
+
getCurrentTime(): Promise<number>;
|
|
3158
|
+
setCurrentTime(time: number): void;
|
|
3159
|
+
getDuration(): Promise<number>;
|
|
3160
|
+
isPaused(): Promise<boolean>;
|
|
3161
|
+
setMuted(muted: boolean): void;
|
|
3162
|
+
setVolume(volume: number): void;
|
|
3163
|
+
destroy(): void;
|
|
3164
|
+
}
|
|
3165
|
+
/**
|
|
3166
|
+
* Media player adapters module.
|
|
3167
|
+
* Provides unified interfaces for different media player types.
|
|
3168
|
+
* @author Marcel Duin <marcel@micr.io>
|
|
3169
|
+
*/
|
|
3170
|
+
export type { MediaPlayerAdapter, PlayerEventCallbacks, PlayerConfig } from "ts/media/types";
|
|
3171
|
+
export { HTML5PlayerAdapter } from "ts/media/html5-adapter";
|
|
3172
|
+
export { YouTubePlayerAdapter } from "ts/media/youtube-adapter";
|
|
3173
|
+
export { VimeoPlayerAdapter } from "ts/media/vimeo-adapter";
|
|
3174
|
+
export { HLSPlayerAdapter } from "ts/media/hls-adapter";
|
|
2633
3175
|
}declare module "svelte/store" {
|
|
2634
3176
|
/** Callback to inform of a value updates.
|
|
2635
3177
|
*/
|