@quick-threejs/reactive 0.1.41 → 0.1.43

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.
@@ -2940,9 +2940,23 @@ function We(e, t) {
2940
2940
  }
2941
2941
  }
2942
2942
  class ei extends cr {
2943
+ /**
2944
+ * Constructs a new font loader.
2945
+ *
2946
+ * @param {LoadingManager} [manager] - The loading manager.
2947
+ */
2943
2948
  constructor(t) {
2944
2949
  super(t);
2945
2950
  }
2951
+ /**
2952
+ * Starts loading from the given URL and passes the loaded font
2953
+ * to the `onLoad()` callback.
2954
+ *
2955
+ * @param {string} url - The path/URL of the file to be loaded. This can also be a data URI.
2956
+ * @param {function(Font)} onLoad - Executed when the loading process has been finished.
2957
+ * @param {onProgressCallback} onProgress - Executed while the loading is in progress.
2958
+ * @param {onErrorCallback} onError - Executed when errors occur.
2959
+ */
2946
2960
  load(t, r, n, i) {
2947
2961
  const o = this, s = new fr(this.manager);
2948
2962
  s.setPath(this.path), s.setRequestHeader(this.requestHeader), s.setWithCredentials(this.withCredentials), s.load(t, function(c) {
@@ -2950,14 +2964,33 @@ class ei extends cr {
2950
2964
  r && r(d);
2951
2965
  }, n, i);
2952
2966
  }
2967
+ /**
2968
+ * Parses the given font data and returns the resulting font.
2969
+ *
2970
+ * @param {Object} json - The raw font data as a JSON object.
2971
+ * @return {Font} The font.
2972
+ */
2953
2973
  parse(t) {
2954
2974
  return new Rn(t);
2955
2975
  }
2956
2976
  }
2957
2977
  class Rn {
2978
+ /**
2979
+ * Constructs a new font.
2980
+ *
2981
+ * @param {Object} data - The font data as JSON.
2982
+ */
2958
2983
  constructor(t) {
2959
2984
  this.isFont = !0, this.type = "Font", this.data = t;
2960
2985
  }
2986
+ /**
2987
+ * Generates geometry shapes from the given text and size. The result of this method
2988
+ * should be used with {@link ShapeGeometry} to generate the actual geometry data.
2989
+ *
2990
+ * @param {string} text - The text.
2991
+ * @param {number} [size=100] - The text size.
2992
+ * @return {Array<Shape>} An array of shapes representing the text.
2993
+ */
2961
2994
  generateShapes(t, r = 100) {
2962
2995
  const n = [], i = Pn(t, r, this.data);
2963
2996
  for (let o = 0, s = i.length; o < s; o++)
@@ -3035,16 +3068,16 @@ export {
3035
3068
  zr as e,
3036
3069
  qn as f,
3037
3070
  Ln as g,
3038
- jn as h,
3071
+ Ar as h,
3039
3072
  Zn as i,
3040
- Pt as j,
3041
- Xn as k,
3042
- Kn as l,
3073
+ jn as j,
3074
+ Pt as k,
3075
+ Xn as l,
3043
3076
  Ht as m,
3044
- Bn as n,
3045
- zn as o,
3046
- Fn as p,
3047
- Ar as q,
3077
+ Kn as n,
3078
+ Bn as o,
3079
+ zn as p,
3080
+ Fn as q,
3048
3081
  Dr as r,
3049
3082
  Yn as s,
3050
3083
  Gn as t,
@@ -1,5 +1,5 @@
1
1
  import { DefaultCameraType } from '../enums';
2
- import { ContainerizedApp, Module, LoaderSource } from '../interfaces';
2
+ import { ContainerizedApp, Module, LoaderSource, OffscreenCanvasStb } from '../interfaces';
3
3
  import { RegisterModule } from '../../core/register/register.module';
4
4
  /**
5
5
  * @description {@link RegisterModule} initialization properties.
@@ -17,6 +17,12 @@ export declare class RegisterPropsBlueprint {
17
17
  * @default true
18
18
  */
19
19
  initOnConstruct?: boolean;
20
+ /**
21
+ * @description Initialize the app on main thread.
22
+ *
23
+ * @default false
24
+ */
25
+ mainThread?: boolean;
20
26
  /**
21
27
  * @description App `canvas` element reference.
22
28
  *
@@ -118,6 +124,8 @@ export declare class RegisterPropsBlueprint {
118
124
  * @description {@link AppModule} initialization properties.
119
125
  */
120
126
  export declare class LaunchAppProps<M extends Module> {
127
+ /** @description App `canvas` element reference. */
128
+ canvas?: OffscreenCanvasStb | HTMLCanvasElement;
121
129
  /** @description Handler triggered when the app is ready. */
122
130
  onReady?: (workerApp: ContainerizedApp<M>) => unknown;
123
131
  }
@@ -1,4 +1,4 @@
1
- export interface OffscreenCanvasWithStyle extends OffscreenCanvas {
1
+ export interface OffscreenCanvasStb extends OffscreenCanvas {
2
2
  style: Partial<CSSStyleDeclaration> & {
3
3
  width: CSSStyleDeclaration["width"];
4
4
  height: CSSStyleDeclaration["height"];
@@ -1,3 +1,4 @@
1
+ import { OffscreenCanvasStb } from 'main';
1
2
  import { RegisterPropsBlueprint } from '../blueprints/props.blueprint';
2
3
  export interface AppModulePropsMessageEvent extends MessageEvent<Omit<RegisterPropsBlueprint, "canvas" | "location" | "loaderDataSources"> & {
3
4
  /**
@@ -5,6 +6,6 @@ export interface AppModulePropsMessageEvent extends MessageEvent<Omit<RegisterPr
5
6
  *
6
7
  * @default `undefined`
7
8
  */
8
- canvas?: OffscreenCanvas;
9
+ canvas?: OffscreenCanvasStb | HTMLCanvasElement;
9
10
  }> {
10
11
  }
@@ -1,6 +1,6 @@
1
1
  import { WorkerThreadModule } from '@quick-threejs/worker';
2
2
  import { Observable } from 'rxjs';
3
- import { AppModulePropsMessageEvent, Module, AppProxyEventHandlersBlueprint } from '../../common';
3
+ import { AppModulePropsMessageEvent, Module, AppProxyEventHandlersBlueprint, OffscreenCanvasStb } from '../../common';
4
4
  import { AppController } from './app.controller';
5
5
  import { AppService } from './app.service';
6
6
  import { TimerModule } from './timer/timer.module';
@@ -23,7 +23,7 @@ export declare class AppModule extends AppProxyEventHandlersBlueprint implements
23
23
  constructor(_controller: AppController, _service: AppService, timer: TimerModule, sizes: SizesModule, camera: CameraModule, world: WorldModule, renderer: RendererModule, loader: LoaderModule, debug: DebugModule);
24
24
  private _initProxyEvents;
25
25
  getProxyReceiver(): import('@quick-threejs/utils').ProxyReceiver<Record<string, unknown>>;
26
- getCanvas(): import('../../common').OffscreenCanvasWithStyle | undefined;
26
+ getCanvas(): OffscreenCanvasStb | HTMLCanvasElement | undefined;
27
27
  getIsInitialized(): boolean;
28
28
  getBeforeStep$(): Observable<import('@quick-threejs/utils').NonNever<{
29
29
  readonly frame: number;
@@ -1,9 +1,9 @@
1
1
  import { ProxyReceiver } from '@quick-threejs/utils';
2
- import { OffscreenCanvasWithStyle } from '../../common/interfaces';
2
+ import { OffscreenCanvasStb } from '../../common/interfaces';
3
3
  export declare class AppService {
4
4
  private _canvas?;
5
5
  readonly proxyReceiver: ProxyReceiver<Record<string, unknown>>;
6
6
  isInitialized: boolean;
7
- get canvas(): OffscreenCanvasWithStyle | undefined;
8
- set canvas(canvas: OffscreenCanvasWithStyle | OffscreenCanvas);
7
+ get canvas(): OffscreenCanvasStb | HTMLCanvasElement | undefined;
8
+ set canvas(canvas: HTMLCanvasElement | OffscreenCanvasStb);
9
9
  }
@@ -1,12 +1,12 @@
1
1
  import { Vector2Like } from 'three';
2
- import { Module, OffscreenCanvasWithStyle } from '../../../common/interfaces';
2
+ import { Module, OffscreenCanvasStb } from '../../../common/interfaces';
3
3
  import { RendererService } from './renderer.service';
4
4
  import { RendererController } from './renderer.controller';
5
5
  export declare class RendererModule implements Module {
6
6
  private readonly _controller;
7
7
  private readonly _service;
8
8
  constructor(_controller: RendererController, _service: RendererService);
9
- init(canvas: OffscreenCanvasWithStyle): void;
9
+ init(canvas: OffscreenCanvasStb): void;
10
10
  enabled(value?: boolean): boolean;
11
11
  instance(): import('three').WebGLRenderer | undefined;
12
12
  setSize(value: Vector2Like): void;
@@ -1,5 +1,5 @@
1
1
  import { WebGLRenderer } from 'three';
2
- import { OffscreenCanvasWithStyle } from '../../../common/interfaces';
2
+ import { OffscreenCanvasStb } from '../../../common/interfaces';
3
3
  import { WorldService } from '../world/world.service';
4
4
  import { CameraService } from '../camera/camera.service';
5
5
  import { SizesService } from '../sizes/sizes.service';
@@ -11,7 +11,7 @@ export declare class RendererService {
11
11
  enabled: boolean;
12
12
  instance?: WebGLRenderer;
13
13
  constructor(_worldService: WorldService, _cameraService: CameraService, _sizesService: SizesService);
14
- setWebGLRenderer(canvas: OffscreenCanvasWithStyle): void;
14
+ setWebGLRenderer(canvas: OffscreenCanvasStb | HTMLCanvasElement): void;
15
15
  setSize(width: number, height: number): void;
16
16
  render(): void;
17
17
  }
@@ -1,12 +1,12 @@
1
1
  import { SizesService } from './sizes.service';
2
2
  import { SizesController } from './sizes.controller';
3
3
  import { Module } from '../../../common/interfaces/module.interface';
4
- import { OffscreenCanvasWithStyle } from '../../../common/interfaces/canvas.interface';
4
+ import { OffscreenCanvasStb } from '../../../common/interfaces/canvas.interface';
5
5
  export declare class SizesModule implements Module {
6
6
  private readonly _controller;
7
7
  private readonly _service;
8
8
  constructor(_controller: SizesController, _service: SizesService);
9
- init(canvas: OffscreenCanvasWithStyle): void;
9
+ init(canvas: OffscreenCanvasStb | HTMLCanvasElement): void;
10
10
  dispose(): void;
11
11
  aspect(value?: number): number;
12
12
  enabled(value?: boolean): boolean;
@@ -1,4 +1,4 @@
1
- import { OffscreenCanvasWithStyle } from '../../../common/interfaces/canvas.interface';
1
+ import { OffscreenCanvasStb } from '../../../common/interfaces/canvas.interface';
2
2
  export declare class SizesService {
3
3
  width: number;
4
4
  height: number;
@@ -6,5 +6,5 @@ export declare class SizesService {
6
6
  pixelRatio: number;
7
7
  frustrum: number;
8
8
  enabled: boolean;
9
- init(canvas: OffscreenCanvasWithStyle, enabled?: boolean): void;
9
+ init(canvas: OffscreenCanvasStb | HTMLCanvasElement, enabled?: boolean): void;
10
10
  }
@@ -1,5 +1,5 @@
1
1
  import { DependencyContainer } from 'tsyringe';
2
- import { Module, RegisterPropsBlueprint, RegisterProxyEventHandlersBlueprint } from '../../common';
2
+ import { Module, RegisterPropsBlueprint, RegisterProxyEventHandlersBlueprint, OffscreenCanvasStb } from '../../common';
3
3
  import { ExposedAppModule } from '../app/app.worker';
4
4
  import { RegisterService } from './register.service';
5
5
  import { RegisterController } from './register.controller';
@@ -15,15 +15,17 @@ export declare class RegisterModule extends RegisterProxyEventHandlersBlueprint
15
15
  private readonly _subscriptions;
16
16
  private _initialized;
17
17
  constructor(_service: RegisterService, _controller: RegisterController, _loaderController: LoaderController, container: DependencyContainer, props: RegisterPropsBlueprint, loader: LoaderModule);
18
+ private get currentWorker();
18
19
  private _initCanvas;
19
- private _initService;
20
+ private _initServiceWorker;
20
21
  private _initEvents;
21
- private _initWorkerThread;
22
- private _initObservableProxyEvents;
22
+ private _initOnMainThread;
23
+ private _initOnWorkerThread;
24
+ private _initObservables;
23
25
  private _initLoader;
24
26
  init(): Promise<void>;
25
27
  getCanvas(): HTMLCanvasElement | undefined;
26
- getOffscreenCanvas(): OffscreenCanvas | undefined;
28
+ getOffscreenCanvas(): OffscreenCanvasStb | undefined;
27
29
  getThread(): import('threads').ModuleThread<ExposedAppModule> | undefined;
28
30
  getWorker(): import('threads/dist/types/master').Worker | undefined;
29
31
  getWorkerPool(): import('@quick-threejs/worker').WorkerPool;
@@ -1,11 +1,11 @@
1
1
  import { WorkerPool, WorkerThreadResolution } from '@quick-threejs/worker';
2
- import { RegisterPropsBlueprint } from '../../common';
2
+ import { OffscreenCanvasStb, RegisterPropsBlueprint } from '../../common';
3
3
  import { ExposedAppModule } from '../app/app.worker';
4
4
  export declare class RegisterService {
5
5
  private readonly _props;
6
6
  readonly workerPool: WorkerPool;
7
7
  canvas?: HTMLCanvasElement;
8
- offscreenCanvas?: OffscreenCanvas;
8
+ offscreenCanvas?: OffscreenCanvasStb;
9
9
  worker?: WorkerThreadResolution<ExposedAppModule>["worker"];
10
10
  thread?: WorkerThreadResolution<ExposedAppModule>["thread"];
11
11
  constructor(_props: RegisterPropsBlueprint);