@micrio/client 5.5.6 → 6.0.1

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
@@ -14,6 +14,10 @@ declare module '@micrio/client' {
14
14
  export const loadTexture: (src: string) => Promise<TextureBitmap>;
15
15
  /** Type for error codes */
16
16
  export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
17
+ /**
18
+ * Calculates the positive modulo (floored division remainder).
19
+ */
20
+ export const mod: (n: number, m?: number) => number;
17
21
  /**
18
22
  * Converts seconds into a human-readable time string (hh?:mm:ss).
19
23
  * @param s Time in seconds. Can be negative for remaining time display.
@@ -182,6 +186,9 @@ declare module '@micrio/client' {
182
186
  readonly center: Models.Camera.Coords;
183
187
  /** CORRECT view: [x0, y0, width, height] */
184
188
  private readonly view;
189
+ private _getXY;
190
+ private _getCoo;
191
+ private _setMinScale;
185
192
  /**
186
193
  * Gets the current image view rectangle.
187
194
  * @returns A copy of the current screen viewport array, or undefined if not initialized.
@@ -207,7 +214,7 @@ declare module '@micrio/client' {
207
214
  noLimit?: boolean;
208
215
  /** If true (for 360), corrects the view based on the `trueNorth` setting. */
209
216
  correctNorth?: boolean;
210
- /** If true, prevents triggering a Wasm render after setting the view. */
217
+ /** If true, prevents triggering a render after setting the view. */
211
218
  noRender?: boolean;
212
219
  /** If provided, interprets `view` relative to this sub-area instead of the full image. */
213
220
  area?: Models.Camera.ViewRect;
@@ -265,33 +272,14 @@ declare module '@micrio/client' {
265
272
  setScale: (s: number) => void;
266
273
  /** Gets the scale at which the image fully covers the viewport. */
267
274
  getCoverScale: () => number;
268
- /**
269
- * Gets the minimum allowed zoom scale for the image.
270
- * @returns The minimum scale.
271
- */
272
275
  getMinScale: () => number;
273
- /**
274
- * Sets the minimum allowed zoom scale.
275
- * @param s The minimum scale to set.
276
- */
277
276
  setMinScale(s: number): void;
278
- /**
279
- * Sets the minimum screen size the image should occupy when zooming out (0-1).
280
- * Allows zooming out further than the image boundaries, creating margins.
281
- * Note: Does not work with albums.
282
- * @param s The minimum screen size fraction (0-1).
283
- */
284
277
  setMinScreenSize(s: number): void;
285
- /** Returns true if the camera is currently zoomed in to its maximum limit. */
286
278
  isZoomedIn: () => boolean;
287
- /**
288
- * Returns true if the camera is currently zoomed out to its minimum limit.
289
- * @param full If true, checks against the absolute minimum scale (ignoring `setMinScreenSize`).
290
- */
291
279
  isZoomedOut: (full?: boolean) => boolean;
292
280
  /**
293
281
  * Sets a rectangular limit for camera navigation within the image.
294
- * @param l The viewport limit rectangle [x0, y0, x1, y1].
282
+ * @param v The viewport limit rectangle [x0, y0, x1, y1].
295
283
  */
296
284
  setLimit(v: Models.Camera.ViewRect): void;
297
285
  /**
@@ -299,14 +287,12 @@ declare module '@micrio/client' {
299
287
  * @param b If true, limits the view to cover the screen.
300
288
  */
301
289
  setCoverLimit(b: boolean): void;
302
- /** Gets whether the cover limit is currently enabled. */
303
290
  getCoverLimit: () => boolean;
304
- /**
305
- * Limits the horizontal and vertical viewing range for 360 images.
306
- * @param xPerc The horizontal arc limit as a percentage (0-1, where 1 = 360°). 0 disables horizontal limit.
307
- * @param yPerc The vertical arc limit as a percentage (0-1, where 1 = 180°). 0 disables vertical limit.
308
- */
291
+ stop(): void;
292
+ pause(): void;
293
+ resume(): void;
309
294
  set360RangeLimit(xPerc?: number, yPerc?: number): void;
295
+ aniIsKinetic(): boolean;
310
296
  /**
311
297
  * Animates the camera smoothly to a target viewport.
312
298
  * @param view The target viewport as either a View [x0, y0, x1, y1] or View {centerX, centerY, width, height}.
@@ -354,11 +340,11 @@ declare module '@micrio/client' {
354
340
  * @param duration Forced duration in ms (0 for instant).
355
341
  * @param x Screen pixel X-coordinate for zoom focus (optional, defaults to center).
356
342
  * @param y Screen pixel Y-coordinate for zoom focus (optional, defaults to center).
357
- * @param speed Animation speed multiplier (optional).
343
+ * @param _speed Animation speed multiplier (optional).
358
344
  * @param noLimit If true, allows zooming beyond image boundaries.
359
345
  * @returns A Promise that resolves when the zoom animation completes.
360
346
  */
361
- zoom: (delta: number, duration?: number, x?: number | undefined, y?: number | undefined, speed?: number, noLimit?: boolean) => Promise<void>;
347
+ zoom: (delta: number, duration?: number, x?: number | undefined, y?: number | undefined, _speed?: number, noLimit?: boolean) => Promise<void>;
362
348
  /**
363
349
  * Zooms in by a specified factor.
364
350
  * @param factor Zoom factor (e.g., 1 = standard zoom step).
@@ -386,29 +372,12 @@ declare module '@micrio/client' {
386
372
  render?: boolean;
387
373
  noLimit?: boolean;
388
374
  }): void;
389
- /** Stops any currently running camera animation immediately. */
390
- stop(): void;
391
- /** Pauses the current camera animation. */
392
- pause(): void;
393
- /** Resumes a paused camera animation. */
394
- resume(): void;
395
- /** Returns true if the camera is currently performing a kinetic pan/zoom (coasting). */
396
- aniIsKinetic(): boolean;
397
375
  /** Gets the current viewing direction (yaw) in 360 mode.
398
376
  * @returns The current yaw in radians.
399
377
  */
400
378
  getDirection: () => number;
401
- /**
402
- * Sets the viewing direction (yaw and optionally pitch) instantly in 360 mode.
403
- * @param yaw The target yaw in radians.
404
- * @param pitch Optional target pitch in radians.
405
- */
406
- setDirection(yaw: number, pitch?: number): void;
407
- /**
408
- * Gets the current viewing pitch in 360 mode.
409
- * @returns The current pitch in radians.
410
- */
411
379
  getPitch: () => number;
380
+ setDirection(yaw: number, pitch?: number): void;
412
381
  /**
413
382
  * Sets the rendering area for this image within the main canvas.
414
383
  * Used for split-screen and potentially other layout effects. Animates by default.
@@ -420,7 +389,7 @@ declare module '@micrio/client' {
420
389
  direct?: boolean;
421
390
  /** If true, prevents dispatching view updates during the animation. */
422
391
  noDispatch?: boolean;
423
- /** If true, prevents triggering a Wasm render after setting the area. */
392
+ /** If true, prevents triggering a render after setting the area. */
424
393
  noRender?: boolean;
425
394
  }): void;
426
395
  /** Sets the 3D rotation for an embedded image (used for placing embeds in 360 space). */
@@ -431,52 +400,90 @@ declare module '@micrio/client' {
431
400
  getOmniFrame(rot?: number): number | undefined;
432
401
  /** [Omni] Gets the screen coordinates [x, y, scale, depth] for given 3D object coordinates. */
433
402
  getOmniXY(x: number, y: number, z: number): Float64Array;
434
- /** [Omni] Applies Omni-specific camera settings (distance, FoV, angle) to Wasm. */
403
+ /** [Omni] Applies Omni-specific camera settings (distance, FoV, angle) to the engine canvas. */
435
404
  setOmniSettings(): void;
436
405
  }
437
406
  /**
438
- * The main WebAssembly controller class. Handles interaction between JavaScript
439
- * and the compiled C++ core of Micrio. Accessed via `micrio.wasm`.
407
+ * The main Micrio compute controller class. Handles the engine lifecycle,
408
+ * render loop, tile management, and WebGL integration.
409
+ * Accessed via `micrio.engine`.
440
410
  */
441
- export class Wasm {
411
+ export class Engine {
442
412
  micrio: HTMLMicrioElement;
443
- /** Flag indicating if the Wasm module has been loaded and initialized. */
444
413
  ready: boolean;
445
- /** Shared WebAssembly memory instance. */
446
- private memory;
447
414
  /** Forget in-memory tiles after X seconds not drawn */
448
415
  private deleteAfterSeconds;
449
- /**
450
- * Creates the Wasm controller instance.
451
- * @param micrio The main HTMLMicrioElement instance.
452
- */
416
+ preventDirectionSet: boolean;
417
+ /** Shared Float32Array for standard tile vertex data. */
418
+ _vertexBuffer: Float32Array;
419
+ /** Static Float32Array holding texture coordinates for a standard quad. */
420
+ static readonly _textureBuffer: Float32Array;
421
+ /** Shared Float32Array for 360 tile vertex data. */
422
+ _vertexBuffer360: Float32Array;
423
+ /** Static Float32Array holding texture coordinates for the 360 sphere. */
424
+ static _textureBuffer360: Float32Array;
425
+ /** Flag indicating if the current context is a gallery. */
426
+ private isGallery;
427
+ private now;
428
+ private raf;
429
+ private drawing;
453
430
  constructor(micrio: HTMLMicrioElement);
454
431
  /**
455
- * Loads and instantiates the WebAssembly module.
456
- * @returns A Promise that resolves when the Wasm module is ready.
457
- * @throws Error if WebAssembly binary loading or instantiation fails
458
- */
432
+ * Initializes the engine (replaces WebAssembly loading).
433
+ * @throws Error if engine initialization fails
434
+ */
459
435
  load(): Promise<void>;
436
+ private _hostDrawQuad;
437
+ private _hostGetTileOpacity;
438
+ private _hostSetTileOpacity;
439
+ private _hostSetMatrix;
440
+ private _hostSetViewport;
441
+ private _hostAniDone;
442
+ private _hostAniAbort;
443
+ private _hostViewSet;
444
+ private _hostViewportSet;
445
+ private _hostSetCanvasVisible;
446
+ private _hostSetImageVisible;
460
447
  /** Unbinds event listeners, stops rendering, and cleans up resources. */
461
448
  unbind(): void;
462
449
  /**
463
- * Sets the currently active canvas/image instance in the Wasm module.
464
- * Handles adding the canvas to Wasm if it's not already initialized.
465
- * @param canvas The MicrioImage instance to set as active.
466
- */
450
+ * Sets the currently active canvas/image instance in the engine.
451
+ */
467
452
  setCanvas(canvas?: MicrioImage): void;
468
- /** Removes a canvas instance from the Wasm module. */
453
+ /** Removes a canvas instance from the engine. */
469
454
  removeCanvas(c: MicrioImage): void;
470
- /** Requests the next animation frame to trigger the `draw` method. */
455
+ /** Requests the next animation frame. */
471
456
  render(): void;
457
+ /**
458
+ * Callback for the engine to request drawing a tile.
459
+ * @returns True if the tile texture is ready and drawn, false otherwise.
460
+ */
461
+ private drawTile;
472
462
  /** Add a child image to the current canvas, either embed or independent canvas */
473
463
  private addImage;
474
- /** Add a child independent canvas to the current canvas, used for grid images
475
- * @param image The image
476
- * @param parent The parent image
477
- * @returns Promise when the image is added
478
- */
464
+ /** Add a child independent canvas to the current canvas */
479
465
  addChild: (image: MicrioImage, parent: MicrioImage) => Promise<void>;
466
+ setZIndex(ptr: number, z: number): void;
467
+ setGridTransitionDuration(dur: number): void;
468
+ setGridTransitionTimingFunction(fn: number): void;
469
+ setCrossfadeDuration(dur: number): void;
470
+ fadeTo(ptr: number, opacity: number, direct: boolean): void;
471
+ fadeIn(ptr: number): void;
472
+ fadeOut(ptr: number): void;
473
+ areaAnimating(ptr: number): boolean;
474
+ getActiveImageIdx(ptr: number): number;
475
+ setNoPinchPan(v: boolean): void;
476
+ setIsSwipe(v: boolean): void;
477
+ ease(p: number): number;
478
+ panStart(ptr: number): void;
479
+ panStop(ptr: number): void;
480
+ pinchStart(ptr: number): void;
481
+ pinch(ptr: number, x0: number, y0: number, x1: number, y1: number): void;
482
+ pinchStop(ptr: number, t: number): void;
483
+ setLimited(ptr: number, v: boolean): void;
484
+ set360Orientation(d: number, dX: number, dY: number): void;
485
+ setCanvasArea(w: number, h: number): void;
486
+ setImageVideoPlaying(ptr: number, playing: boolean): void;
480
487
  }
481
488
  /**
482
489
  * Handles swipe gestures for navigating image sequences, particularly for
@@ -488,7 +495,7 @@ declare module '@micrio/client' {
488
495
  private length;
489
496
  goto: (i: number) => void;
490
497
  private opts;
491
- /** Getter for the current active image/frame index from the Wasm module. */
498
+ /** Getter for the current active image/frame index from the engine. */
492
499
  get currentIndex(): number;
493
500
  /**
494
501
  * Creates a GallerySwiper instance.
@@ -644,7 +651,7 @@ declare module '@micrio/client' {
644
651
  /**
645
652
  * Represents and controls a single Micrio image instance within the viewer.
646
653
  * This class manages the image's metadata (info), cultural data (data),
647
- * settings, camera, state, and interactions with the WebAssembly module
654
+ * settings, camera, state, and interactions with the compute engine
648
655
  * for rendering and processing. It handles loading image tiles, embeds,
649
656
  * markers, tours, and galleries associated with the image.
650
657
  *
@@ -652,7 +659,7 @@ declare module '@micrio/client' {
652
659
  * @author Marcel Duin <marcel@micr.io>
653
660
  */
654
661
  export class MicrioImage {
655
- wasm: Wasm;
662
+ engine: Engine;
656
663
  private attr;
657
664
  opts: {
658
665
  /** Optional sub area [x0, y0, x1, y1] defining placement within a parent canvas (for embeds/galleries). */
@@ -2132,19 +2139,19 @@ declare module '@micrio/client' {
2132
2139
  /** A numeric array or Float64Array used for camera geometry. */
2133
2140
  type CameraArray = number[] | Float64Array;
2134
2141
  /** A viewport rectangle `[x0, y0, x1, y1]` (corners). */
2135
- export type ViewRect = CameraArray;
2142
+ type ViewRect = CameraArray;
2136
2143
  /** An area definition `[x0, y0, width, height]` (origin + size). */
2137
- export type View = CameraArray;
2144
+ type View = CameraArray;
2138
2145
  /** Coordinate tuple, [x, y, scale] */
2139
- export type Coords = [number, number, number?] | Float64Array;
2146
+ type Coords = [number, number, number?] | Float64Array;
2140
2147
  /** A 360 vector for use in Spaces */
2141
- export type Vector = {
2148
+ type Vector = {
2142
2149
  direction: number;
2143
2150
  distanceX: number;
2144
2151
  distanceY: number;
2145
2152
  };
2146
- export type TimingFunction = ('ease' | 'ease-in' | 'ease-out' | 'linear');
2147
- export interface AnimationOptions {
2153
+ type TimingFunction = ('ease' | 'ease-in' | 'ease-out' | 'linear');
2154
+ interface AnimationOptions {
2148
2155
  /** Animation duration in ms */
2149
2156
  duration?: number;
2150
2157
  /** Limit the viewport to fill the screen */
@@ -2154,7 +2161,6 @@ declare module '@micrio/client' {
2154
2161
  /** Transition timing function */
2155
2162
  timingFunction?: TimingFunction;
2156
2163
  }
2157
- export {};
2158
2164
  }
2159
2165
  namespace Embeds {
2160
2166
  interface EmbedOptions {
@@ -2462,7 +2468,7 @@ declare module '@micrio/client' {
2462
2468
  */
2463
2469
  getRatio: (s?: Partial<Models.ImageInfo.Settings>) => number;
2464
2470
  /**
2465
- * Sets virtual offset margins in the Wasm controller.
2471
+ * Sets virtual offset margins in the engine controller.
2466
2472
  * This likely affects how viewports are calculated or limited.
2467
2473
  * @param width The horizontal offset margin in pixels.
2468
2474
  * @param height The vertical offset margin in pixels.
@@ -2931,7 +2937,7 @@ declare module '@micrio/client' {
2931
2937
  /**
2932
2938
  * The main Micrio custom HTML element `<micr-io>`.
2933
2939
  * This class acts as the central controller for the Micrio viewer, managing
2934
- * the WebGL canvas, WebAssembly module, Svelte UI, state, events, and image loading.
2940
+ * the WebGL canvas, compute engine, Svelte UI, state, events, and image loading.
2935
2941
  *
2936
2942
  * It orchestrates the interaction between different parts of the library and
2937
2943
  * exposes methods and properties for controlling the viewer.
@@ -2946,7 +2952,7 @@ declare module '@micrio/client' {
2946
2952
  * </script>
2947
2953
  * ```
2948
2954
  *
2949
- * [[include:./ts/element.md]]
2955
+ * {@include ./element.md}
2950
2956
  *
2951
2957
  * @author Marcel Duin <marcel@micr.io>
2952
2958
  */
@@ -3025,7 +3031,7 @@ declare module '@micrio/client' {
3025
3031
  /**
3026
3032
  * Closes an opened MicrioImage.
3027
3033
  * For split-screen images, it triggers the split-end transition.
3028
- * For main images, it removes the canvas from the Wasm controller.
3034
+ * For main images, it removes the canvas from the engine.
3029
3035
  * @param img The {@link MicrioImage} instance to close.
3030
3036
  */
3031
3037
  close(img: MicrioImage): void;
@@ -3071,20 +3077,20 @@ declare module '@micrio/client' {
3071
3077
  * Handles HLS playback via hls.js if necessary.
3072
3078
  */
3073
3079
  export class GLEmbedVideo {
3074
- private wasm;
3080
+ private engine;
3075
3081
  private image;
3076
3082
  private embed;
3077
3083
  private paused;
3078
3084
  private moved;
3079
3085
  /**
3080
3086
  * Creates a GLEmbedVideo instance.
3081
- * @param wasm The Wasm controller instance.
3087
+ * @param engine The Engine controller instance.
3082
3088
  * @param image The parent MicrioImage instance where the video is embedded.
3083
3089
  * @param embed The embed data object.
3084
3090
  * @param paused Initial paused state (e.g., due to pause-on-zoom).
3085
- * @param moved Callback function to notify when position/state changes (triggers Wasm render).
3091
+ * @param moved Callback function to notify when position/state changes (triggers Engine render).
3086
3092
  */
3087
- constructor(wasm: Wasm, image: MicrioImage, embed: Models.ImageData.Embed, paused: boolean, // Initial paused state
3093
+ constructor(engine: Engine, image: MicrioImage, embed: Models.ImageData.Embed, paused: boolean, // Initial paused state
3088
3094
  moved: () => void);
3089
3095
  /** Cleans up resources when the parent Embed component is unmounted. */
3090
3096
  unmount(): void;
@@ -3264,7 +3270,7 @@ declare module '@micrio/client' {
3264
3270
  export { Router } from "ts/nav/router";
3265
3271
  export { Grid } from "ts/nav/grid";
3266
3272
  export { GallerySwiper } from "ts/nav/swiper";
3267
- export { Wasm } from "ts/render/wasm";
3273
+ export { Engine } from "ts/render/engine";
3268
3274
  export { WebGL } from "ts/render/webgl";
3269
3275
  export { Canvas } from "ts/render/canvas";
3270
3276
  export { PostProcessor } from "ts/render/postprocess";