@windycom/plugin-devtools 3.0.2 → 3.0.3

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.
Files changed (112) hide show
  1. package/package.json +1 -1
  2. package/types/client/Calendar.d.ts +4 -0
  3. package/types/client/Color.d.ts +9 -2
  4. package/types/client/DataTiler.d.ts +2 -2
  5. package/types/client/EventManager.d.ts +69 -0
  6. package/types/client/ExternalSveltePlugin.d.ts +4 -3
  7. package/types/client/GlBuffer.d.ts +45 -0
  8. package/types/client/GlMesh.d.ts +147 -0
  9. package/types/client/GlProgram.d.ts +41 -0
  10. package/types/client/GlRenderer.d.ts +95 -0
  11. package/types/client/GlTexture.d.ts +98 -0
  12. package/types/client/GlVertexArray.d.ts +38 -0
  13. package/types/client/IDB.d.ts +25 -4
  14. package/types/client/LabelsLayer.d.ts +69 -2
  15. package/types/client/Layer.d.ts +2 -1
  16. package/types/client/MetricClasses.d.ts +1 -1
  17. package/types/client/Overlay.d.ts +1 -5
  18. package/types/client/Product.d.ts +10 -5
  19. package/types/client/ProductClasses.d.ts +7 -0
  20. package/types/client/Renderer.d.ts +16 -19
  21. package/types/client/ShaderStorage.d.ts +25 -0
  22. package/types/client/StartupElementPlugin.d.ts +8 -0
  23. package/types/client/SveltePlugin.d.ts +4 -4
  24. package/types/client/SwitchableTileCache.d.ts +104 -0
  25. package/types/client/TileLayer.d.ts +11 -2
  26. package/types/client/TileLayerCustom.d.ts +51 -0
  27. package/types/client/TileLayerMulti.d.ts +53 -0
  28. package/types/client/TileLayerPreprocessorStandalone.d.ts +45 -0
  29. package/types/client/TileLayerRenderer.d.ts +24 -0
  30. package/types/client/TileLayerUtils.d.ts +43 -0
  31. package/types/client/TilePreprocessor.d.ts +27 -0
  32. package/types/client/TopoMap.d.ts +2 -1
  33. package/types/client/WindowPlugin.d.ts +1 -3
  34. package/types/client/baseMap.d.ts +12 -2
  35. package/types/client/broadcast.d.ts +1 -1
  36. package/types/client/cityLabels.d.ts +2 -3
  37. package/types/client/colorGradients.d.ts +1 -2
  38. package/types/client/css.test.d.ts +1 -0
  39. package/types/client/customProtocol.d.ts +11 -0
  40. package/types/client/d.ts.files/GlObj.d.ts +1 -5
  41. package/types/client/d.ts.files/Metric.d.ts +2 -0
  42. package/types/client/d.ts.files/broadcast.d.ts +28 -32
  43. package/types/client/d.ts.files/dataSpecifications.d.ts +60 -42
  44. package/types/client/d.ts.files/glUtils.d.ts +71 -0
  45. package/types/client/d.ts.files/http.d.ts +0 -5
  46. package/types/client/d.ts.files/interpolatorTypes.d.ts +5 -5
  47. package/types/client/d.ts.files/lib.d.ts +1 -1
  48. package/types/client/d.ts.files/liveAlerts.d.ts +52 -0
  49. package/types/client/d.ts.files/mapUtils.d.ts +25 -0
  50. package/types/client/d.ts.files/outgoingMessages.d.ts +1 -1
  51. package/types/client/d.ts.files/plugin-params.d.ts +31 -13
  52. package/types/client/d.ts.files/plugins.d.ts +44 -29
  53. package/types/client/d.ts.files/singleclick.d.ts +4 -2
  54. package/types/client/d.ts.files/startup.d.ts +7 -52
  55. package/types/client/d.ts.files/storage.d.ts +0 -11
  56. package/types/client/d.ts.files/user.d.ts +6 -1
  57. package/types/client/embed.d.ts +2 -5
  58. package/types/client/errorLogger.d.ts +19 -0
  59. package/types/client/externalPlugins.d.ts +4 -2
  60. package/types/client/fetch.d.ts +38 -5
  61. package/types/client/format.d.ts +11 -0
  62. package/types/client/glContextUtils.d.ts +9 -0
  63. package/types/client/glStatus.d.ts +7 -0
  64. package/types/client/glUtils.d.ts +119 -0
  65. package/types/client/http.d.ts +0 -6
  66. package/types/client/idbConnection.d.ts +13 -0
  67. package/types/client/idbInstances.d.ts +36 -42
  68. package/types/client/landLayer.d.ts +3 -0
  69. package/types/client/layers.d.ts +2 -1
  70. package/types/client/lib.d.ts +11 -14
  71. package/types/client/liveAlerts.d.ts +2 -2
  72. package/types/client/location.d.ts +1 -1
  73. package/types/client/map.d.ts +95 -22
  74. package/types/client/mapUtils.d.ts +66 -0
  75. package/types/client/math.d.ts +14 -0
  76. package/types/client/mobile.d.ts +16 -34
  77. package/types/client/mobileUtils.d.ts +10 -0
  78. package/types/client/models.d.ts +1 -1
  79. package/types/client/overlays.d.ts +2 -2
  80. package/types/client/picker.d.ts +4 -8
  81. package/types/client/products.d.ts +0 -1
  82. package/types/client/promo.d.ts +1 -1
  83. package/types/client/renderUtils.d.ts +14 -0
  84. package/types/client/renderers.d.ts +5 -6
  85. package/types/client/rootScope.d.ts +9 -9
  86. package/types/client/router.d.ts +7 -2
  87. package/types/client/singleclick.d.ts +1 -1
  88. package/types/client/startup.d.ts +48 -0
  89. package/types/client/startupUtils.d.ts +19 -0
  90. package/types/client/subscription.d.ts +3 -26
  91. package/types/client/throttler.d.ts +32 -0
  92. package/types/client/tileHelpers.d.ts +35 -0
  93. package/types/client/tileLayerInterpolator.d.ts +40 -0
  94. package/types/client/tileLayerSource.d.ts +98 -0
  95. package/types/client/timestampUtils.test.d.ts +1 -0
  96. package/types/client/topMessage.d.ts +22 -0
  97. package/types/client/user.d.ts +1 -0
  98. package/types/client/userConsent.d.ts +0 -2
  99. package/types/client/userFavs.d.ts +0 -8
  100. package/types/client/utils.d.ts +62 -10
  101. package/types/client/utils.test.d.ts +1 -0
  102. package/types/iconfont.d.ts +2 -5
  103. package/types/interfaces.d.ts +121 -100
  104. package/types/lang-files.d.ts +412 -72
  105. package/types/leaflet-gl.d.ts +12773 -0
  106. package/types/types.d.ts +28 -6
  107. package/types/client/d.ts.files/CanvasLayer.d.ts +0 -70
  108. package/types/client/d.ts.files/DataTiler.d.ts +0 -45
  109. package/types/client/d.ts.files/LandMask.d.ts +0 -17
  110. package/types/client/d.ts.files/PoisOverlay.d.ts +0 -27
  111. package/types/client/d.ts.files/TileLayerCanvas.d.ts +0 -78
  112. package/types/client/d.ts.files/TileLayerMultiPatch.d.ts +0 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windycom/plugin-devtools",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "Developer tools and TS declarations for developers of Windy Plugins.",
5
5
  "main": "index.mjs",
6
6
  "module": "index.mjs",
@@ -33,6 +33,10 @@ export interface MinifestObject {
33
33
  * Main Calendar Day Object
34
34
  */
35
35
  export interface CalendarDay {
36
+ /**
37
+ * Translation ID for week day one letter/symbol abbreviation
38
+ */
39
+ displayShort: keyof LoadedTranslations;
36
40
  /**
37
41
  * Translation ID for week day abbreviation
38
42
  */
@@ -1,6 +1,6 @@
1
1
  import type { RGBA, RGBString, ColorGradient, NumValue, ColorGradientString } from '@windy/types.d';
2
- export type ColorIdent = 'temp' | 'wind' | 'rh' | 'pressure' | 'cclAltitude' | 'altitude' | 'deg0' | 'levels' | 'rain' | 'ptype' | 'rainClouds' | 'clouds' | 'lclouds' | 'hclouds' | 'mclouds' | 'cape' | 'lightDensity' | 'cbase' | 'snow' | 'rainAccu' | 'waves' | 'currents' | 'visibility' | 'gtco3' | 'aod550' | 'pm2p5' | 'no2' | 'tcso2' | 'go3' | 'cosc' | 'dust' | 'satellite' | 'radar' | 'radarPlus' | 'fog' | 'justGray' | 'efiWind' | 'efiTemp' | 'efiRain' | 'moistureAnom40' | 'moistureAnom100' | 'drought' | 'soilMoisture' | 'fwi' | 'dfm10h' | 'solarpower' | 'uvindex' | 'turbulence' | 'icing' | 'wetbulbtemp' | 'aqi' | 'dewpoint';
3
- export type PluginColorIdent = 'windDetail' | 'wavesDetail' | 'periodDetail' | 'altitudeDetail' | 'visibilityDetail' | 'dewpointSpreadDetail' | 'blitz' | 'radiation' | 'pmDetail' | 'dustDetail' | 'coscDetail' | 'no2Detail' | 'pollenDetail' | 'so2Detail' | 'aqiGradientDetail';
2
+ export type ColorIdent = 'temp' | 'wind' | 'rh' | 'pressure' | 'cclAltitude' | 'altitude' | 'deg0' | 'levels' | 'rain' | 'ptype' | 'rainClouds' | 'clouds' | 'lclouds' | 'hclouds' | 'mclouds' | 'cape' | 'lightDensity' | 'cbase' | 'snow' | 'rainAccu' | 'waves' | 'currents' | 'visibility' | 'gtco3' | 'aod550' | 'pm2p5' | 'no2' | 'tcso2' | 'go3' | 'cosc' | 'dust' | 'satellite' | 'radar' | 'fog' | 'justGray' | 'efiWind' | 'efiTemp' | 'efiRain' | 'moistureAnom40' | 'moistureAnom100' | 'drought' | 'soilMoisture' | 'fwi' | 'dfm10h' | 'solarpower' | 'wavePower' | 'uvindex' | 'turbulence' | 'icing' | 'wetbulbtemp' | 'aqi' | 'dewpoint';
3
+ export type PluginColorIdent = 'windDetail' | 'wavesDetail' | 'periodDetail' | 'altitudeDetail' | 'visibilityDetail' | 'dewpointSpreadDetail' | 'blitz' | 'radiation' | 'pmDetail' | 'dustDetail' | 'coscDetail' | 'no2Detail' | 'pollenDetail' | 'so2Detail' | 'aqiGradientDetail' | 'wavePowerDetail';
4
4
  export type AnyColorIdent = ColorIdent | PluginColorIdent | 'pressureIsolines' | 'temporary' | 'direction' | 'airgramColor' | 'tempFillColors' | 'tideGraphColors' | 'aqiFillColors';
5
5
  export interface UserColor {
6
6
  id: AnyColorIdent;
@@ -11,6 +11,12 @@ export type ColorInitParams = Pick<Color, 'ident'> & Partial<Pick<Color, 'qualit
11
11
  steps?: number;
12
12
  opaque?: boolean;
13
13
  prepare?: boolean;
14
+ /**
15
+ * Min and max gradient value override
16
+ * - used for gradients with constant min and max values
17
+ * - e.g. radar with [0,256] in all cases (gradient is not resized based on the current gradient extents)
18
+ */
19
+ minMaxValue?: [NumValue, NumValue];
14
20
  };
15
21
  export declare class Color {
16
22
  /**
@@ -37,6 +43,7 @@ export declare class Color {
37
43
  private defaultColorGradient?;
38
44
  /** Custom modified gradient */
39
45
  private customColorGradient?;
46
+ private minMaxValue?;
40
47
  /** Big interpolated RGBA Type array color table, generated when color is required */
41
48
  private colors?;
42
49
  /** Min value of associated numerical value */
@@ -1,6 +1,6 @@
1
1
  import { dataLoader } from '@windy/dataLoader';
2
- import type { FullRenderParameters } from './d.ts.files/interfaces';
3
- import type { DataTile } from './d.ts.files/dataLoader';
2
+ import type { FullRenderParameters } from '@windy/interfaces';
3
+ import type { DataTile } from '@windy/dataLoader';
4
4
  import type { ExtendedTileParams } from './DataTiler.d';
5
5
  export interface TilePoint {
6
6
  x: number;
@@ -0,0 +1,69 @@
1
+ /// <reference types="svelte" />
2
+ import store from '@windy/store';
3
+ import type { StoreTypes } from '@windy/store.d';
4
+ import type { Evented as MaplibreEvented, Listener, MapEventType, MapLayerEventType, LeafletEventHandlerFn } from '@leafletGl';
5
+ import type { Evented } from '@windy/Evented';
6
+ import type { BcastTypes } from '@windy/broadcast.d';
7
+ import type { Plugins } from '@windy/plugins.d';
8
+ import type { Readable, Subscriber } from 'svelte/store';
9
+ type MapLibreEventTypes = MapLayerEventType | MapEventType | string;
10
+ type BcastEventTypes = keyof BcastTypes<keyof Plugins>;
11
+ /**
12
+ * @class A class for managing event listeners
13
+ * - used to safely bind AND unbind listeners by storing callback references
14
+ */
15
+ export declare class EventManager {
16
+ private DOMCallbacks;
17
+ private MapLibreCallbacks;
18
+ private storeCallbacks;
19
+ private eventedCallbacks;
20
+ private broadcastCallbacks;
21
+ private mapCallbacks;
22
+ private unsubscribers;
23
+ /**
24
+ * @summary Registers specific event listener on a given DOM target with a given callback
25
+ * @param target - target to listen on
26
+ * @param topic - which event to listen for
27
+ * @param callback - callback function that should process the event
28
+ */
29
+ addDOMListener<T extends EventTarget>(target: T, topic: Parameters<T['addEventListener']>[0], callback: Parameters<T['addEventListener']>[1]): void;
30
+ /**
31
+ * @summary Registers specific event listener on a given MapLibre target with a given callback
32
+ * @param target - target to listen on
33
+ * @param topic - which event to listen for
34
+ * @param callback - callback function that should process the event
35
+ */
36
+ addMapLibreListener<T extends MapLibreEventTypes>(target: MaplibreEvented, topic: T, callback: Listener): void;
37
+ /**
38
+ * @summary Registers specific event listener on windy store with a given callback
39
+ * @param topic - which event to listen for
40
+ * @param callback - callback function that should process the event
41
+ */
42
+ addStoreListener<T extends keyof StoreTypes>(topic: T, callback: Parameters<(typeof store)['on']>[1]): void;
43
+ /**
44
+ * @summary Registers specific event listener on a given windy/evented target with a given callback
45
+ * @param target - target to listen on
46
+ * @param topic - which event to listen for
47
+ * @param callback - callback function that should process the event
48
+ */
49
+ addEventedListener<T>(target: Evented<T>, topic: keyof T, callback: (typeof this.eventedCallbacks)[string][number]['ref']): void;
50
+ /**
51
+ * @summary Registers specific event listener on windy broadcast with a given callback
52
+ * @param topic - which event to listen for
53
+ * @param callback - callback function that should process the event
54
+ */
55
+ addBroadcastListener(topic: BcastEventTypes, callback: (typeof this.broadcastCallbacks)[string][number]['ref']): void;
56
+ addMapListener(topic: string, callback: LeafletEventHandlerFn): void;
57
+ addSvelteStoreListener<T>(svelteStore: Readable<T>, callback: Subscriber<T>, onlyOnChange?: boolean): void;
58
+ /**
59
+ * Subscribe to DOM mutations using MutationObserver
60
+ *
61
+ * See https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
62
+ */
63
+ addMutationObserverListener(target: Node, options: MutationObserverInit, callback: MutationCallback): void;
64
+ /**
65
+ * @summary Cleanup method to remove (unregister) all registered listeners
66
+ */
67
+ removeListeners(): void;
68
+ }
69
+ export {};
@@ -2,7 +2,8 @@ import { SveltePlugin, type ExternalSvelteApp } from '@windy/SveltePlugin';
2
2
  import type { WindowPluginInitParams } from '@windy/WindowPlugin';
3
3
  import type { SveltePanePlugins, SveltePlugins } from '@windy/plugins.d';
4
4
  import type { CompiledExternalPluginConfig, ExternalPluginConfig, InstalledExternalPluginConfig, PluginOpeningOptions } from '@windy/interfaces';
5
- import type { PluginPane } from './Plugin';
5
+ import type { PluginPane } from '@windy/Plugin';
6
+ import type { SemVersion } from '@windy/types';
6
7
  /** Allowed params to SveltePlugin constructor (private and protected props are omitted by default) */
7
8
  export type ExternalSveltePluginInitParams<P extends keyof SveltePlugins | keyof SveltePanePlugins> = Omit<WindowPluginInitParams<P>, 'ident'> & Pick<SveltePlugin<P>, 'ident'> & Partial<SveltePlugin<P>>;
8
9
  export type LoadeExternalSveltePlugin = {
@@ -22,12 +23,12 @@ export declare class ExternalSveltePlugin extends SveltePlugin<'windy-external-p
22
23
  mobileConfig: Record<InstalledExternalPluginConfig['mobileUI'], Config2config>;
23
24
  desktopConfig: Record<InstalledExternalPluginConfig['desktopUI'], Config2config>;
24
25
  widthOfRhPane: number;
25
- version: string;
26
+ version: SemVersion;
26
27
  listenToSingleclick: ExternalPluginConfig['listenToSingleclick'];
27
28
  addToContextmenu: ExternalPluginConfig['addToContextmenu'];
28
29
  constructor(params: WindowPluginInitParams<'windy-external-plugin'>, { desktopUI, title, mobileUI, desktopWidth, routerPath, listenToSingleclick, addToContextmenu, url, version, }: InstalledExternalPluginConfig);
29
30
  open({ params, disableOpeningAnimation, qs, }: PluginOpeningOptions<'windy-external-plugin'>): Promise<void | boolean>;
30
- hasNewerVersion(latestVersion: string): boolean;
31
+ hasNewerVersion(latestVersion: SemVersion): boolean;
31
32
  showConfirmationWindow(): Promise<boolean>;
32
33
  getDayDiff(timestamp: string): number;
33
34
  uninstallPlugin(): Promise<void>;
@@ -0,0 +1,45 @@
1
+ import type { TypedArray } from '@windy/glUtils.d';
2
+ export declare enum GlBufferType {
3
+ VERTEX,
4
+ INDEX
5
+ }
6
+ export declare enum GlBufferUsage {
7
+ STATIC,
8
+ DYNAMIC
9
+ }
10
+ /**
11
+ * @class A wrapper class over WebGLBuffer
12
+ */
13
+ export declare class GlBuffer {
14
+ private static idCounter;
15
+ /** Reference to the WebGL buffer on the GPU */
16
+ protected readonly buffer: WebGLBuffer;
17
+ protected type: GlBufferType;
18
+ /** Length of uploaded data array in the buffer */
19
+ protected _dataLength: number;
20
+ /** Class instance unique id, for debug, tracks number of created instances */
21
+ protected readonly bufferId: number;
22
+ constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, type: GlBufferType);
23
+ /**
24
+ * @summary Resets buffer instance counter on plugin cleanup, used for debugging
25
+ */
26
+ static reset(): void;
27
+ /**
28
+ * @summary Binds buffer for subsequent operations
29
+ */
30
+ bind(gl: WebGLRenderingContext | WebGL2RenderingContext): void;
31
+ /**
32
+ * @summary Unbinds the buffer
33
+ */
34
+ unbind(gl: WebGLRenderingContext | WebGL2RenderingContext): void;
35
+ /**
36
+ * @summary Updates data in the GPU buffer
37
+ * @param data Data to be uploaded to the GPU buffer
38
+ * @param usage Buffer update frequency (how the buffer will be updated)
39
+ */
40
+ update(gl: WebGLRenderingContext | WebGL2RenderingContext, data: TypedArray, usage?: GlBufferUsage): void;
41
+ /** @summary Returns number of elements inside the buffer */
42
+ get length(): number;
43
+ /** @summary Deletes the WebGL buffer */
44
+ destroy(gl: WebGLRenderingContext | WebGL2RenderingContext): void;
45
+ }
@@ -0,0 +1,147 @@
1
+ import type { TypedArray } from '@windy/glUtils.d';
2
+ import type { GlProgram } from '@windy/GlProgram';
3
+ /**
4
+ * @class A class that represents abstraction of a renderable logical geometry chunk
5
+ * - (geometry with the same properties, requiring same rendering approach)
6
+ */
7
+ export declare class GlMesh {
8
+ private static numMeshes;
9
+ /**
10
+ * Array of vertex streams (Vertex Buffer Objects) used for rendering the mesh
11
+ * - GPU buffer references | Key-value map in the future (multiple geometry buffers)
12
+ */
13
+ private readonly vbos;
14
+ /** Size of the GPU buffer | Key-value map in the future (multiple geometry buffers) */
15
+ private vertexCount;
16
+ /**
17
+ * Array of vertex attributes mapping
18
+ * - one map for each vertex stream, since every stream has at least one attribute defined by layout index and size
19
+ * - maps attributes bound to the given GPU buffer (VBO)
20
+ */
21
+ private readonly attributes;
22
+ /**
23
+ * Size of all attributes for one vertex in the given vertex stream
24
+ * e.g. one vertex has Vec3 position, Vec2 uv, and Vec3 color --> stride is 3+2+3 = 8 bytes
25
+ * */
26
+ private readonly buffersStride;
27
+ /** Element Buffer Object for storing vertex indices for indexed rendering */
28
+ private ebo?;
29
+ /**
30
+ * Map of Vertex Array Objects
31
+ * VAO - represents binding of geometry layout with a given shader program
32
+ * - one VAO is for given GlProgram (not per vertex stream)
33
+ * - one VAO handles binding of all vertex streams, but for every GlProgram, new VAO should be created since each shader can have different layout
34
+ */
35
+ private readonly vaos;
36
+ private readonly meshId;
37
+ private instanceBuffer?;
38
+ private instanceAttributes?;
39
+ private instanceBufferStride;
40
+ private instancingInitialized;
41
+ private drawElementsCall;
42
+ private drawArraysCall;
43
+ private vertexDivisorCall;
44
+ /**
45
+ * @param vertexData Default vertex stream data (can be interleaved - defined by layout)
46
+ * @param indexData Optional index buffer data (in case of indexed data rendering)
47
+ * @param dynamic Signals, whether the geometry will be updated frequently or is static
48
+ */
49
+ constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, vertexData: Float32Array, indexData?: Uint16Array, dynamic?: boolean);
50
+ /**
51
+ * @summary Resets mesh instance counter on plugin cleanup, used for debugging
52
+ */
53
+ static reset(): void;
54
+ /**
55
+ * @summary Performs draw call of the mesh w.r.t. current state defined by VAO / attributes layout + given shader program
56
+ * - WARNING: this call assumes, that GlProgram.use() / gl.useProgram(programId) was already called!
57
+ * - automatically performs the appropriate call -> instanced/non-instanced + indexed/non-indexed - all based on the state given by the supplied data
58
+ * @param program Shader program used to identify the render/geometry state
59
+ * @param primType Which primitives to draw with the vertex data
60
+ * @param offset Offset in the geometry buffer (defaults to 0)
61
+ * @param count Number of vertices / elements to draw from the buffer (defaults to full size of the geometry)
62
+ * @param numInstances When instanced rendering used, signals, how many instances to draw
63
+ */
64
+ render(gl: WebGLRenderingContext | WebGL2RenderingContext, program: GlProgram, primitiveType?: GLenum, numInstances?: number): void;
65
+ /**
66
+ * @summary Creates new geometry layout binding / (new VAO if available) w.r.t. supplied shader program
67
+ * - goal: the same mesh geometry can be reused by many shaders with different layouts (we are binding to the given shader)
68
+ * - TODO: currently works with only one buffer (interleaved/joined data), extend this to support multiple buffers (streams) + per-buffer layout setup
69
+ * @param shaderProgram Shader program for which to setup the layout
70
+ * @param vertexAttribLayout Specifies, how the mesh data should be mapped to the given shader (VS)
71
+ * - e.g. {a_pos : 3, a_uv : 2} defines two attributes, first vertex position with three components, second texture coordinates vector with two components
72
+ * - the object keys must respect names of the attribute variables in the Vertex Shader
73
+ * @param vertexStreamIndex Index of vertex stream (VBO) for which the layout is being registered. Default one is 0
74
+ */
75
+ registerShaderGeometryLayout(gl: WebGLRenderingContext | WebGL2RenderingContext, shaderProgram: GlProgram, vertexAttribLayout: Record<string, number>, vertexStreamIndex?: number): void;
76
+ /**
77
+ * @summary Destructor
78
+ */
79
+ destroy(gl: WebGLRenderingContext | WebGL2RenderingContext): void;
80
+ /**
81
+ * @summary Appends vertex stream to the mesh.
82
+ * Do not forget to register vertex layout for this stream via {@link registerShaderGeometryLayout} method
83
+ * @param vertexData Typed array (Float32Array) with vertex data (position, tex. coordinates etc.)
84
+ * @param dynamic Whether the data will be updated frequently or not
85
+ * @returns Index of the newly registered vertex stream
86
+ */
87
+ addVertexStream(gl: WebGLRenderingContext | WebGL2RenderingContext, vertexData: Float32Array, dynamic?: boolean): number;
88
+ /**
89
+ * @summary Dynamically updates content of the given vertex stream. Assumes, that the layout remains the same
90
+ * @param streamIndex Which stream data to update
91
+ * @param vertexData New vertex data
92
+ */
93
+ updateVertexStream(gl: WebGLRenderingContext | WebGL2RenderingContext, streamIndex: number, vertexData: Float32Array): boolean;
94
+ /**
95
+ * @summary Initializes instancing-related methods based on used WebGL context
96
+ * - if not called explicitly, it is called during instanced rendering (however in that case we don't get the status, whether instancing is available)
97
+ * @returns Status, whether instancing was successfully initialized or whether it failed (extension not supported...)
98
+ */
99
+ initInstancing(gl: WebGL2RenderingContext | WebGLRenderingContext): boolean;
100
+ /**
101
+ * @summary Adds / updates instance data, binds instance buffer with the given shader
102
+ * - signals, that further rendering will be performed as instanced (based on thw supplied "numInstances" parameter in the render method)
103
+ * @param program Shader program used for instanced rendering
104
+ * @param instanceData Per-instance data (buffer with elements, where each element is assigned to one instance (defined by "gl.vertexAttribDivisor"))
105
+ * @returns true/false, whether update was successful (can fail, when WebGL2 not available together with 'ANGLE_instanced_arrays' extension not available)
106
+ */
107
+ setInstanceStream(gl: WebGLRenderingContext | WebGL2RenderingContext, program: GlProgram, instanceData: TypedArray, instanceAttribLayout: Record<string, [number, number]>): boolean;
108
+ /**
109
+ * @summary Dynamically updates content of the mesh instance stream.
110
+ * - Assumes, that the layout remains the same
111
+ * - Currently only one instance stream is supported
112
+ * @param instanceData New instance data
113
+ */
114
+ updateInstanceStream(gl: WebGLRenderingContext | WebGL2RenderingContext, instanceData: TypedArray): boolean;
115
+ /**
116
+ * @returns {boolean} Flag, that instance stream was already created, so subsequent data uploads should call {@link updateInstanceStream}
117
+ */
118
+ hasInstanceStream(): boolean;
119
+ /**
120
+ * @summary Binds geometry (and index if available) buffer for following operations (e.g. rendering)
121
+ * - Also used for layout definition when creating VAO {@link GlVertexArray}
122
+ */
123
+ private bindGeometry;
124
+ /**
125
+ * @summary Performs rendering of the mesh numInstances-times using WebGL2 context or WebGL1 extension
126
+ */
127
+ private renderInstanced;
128
+ }
129
+ /**
130
+ * @class A container with common geometries
131
+ */
132
+ export declare class MeshFactory {
133
+ /** 2D Quad geometry containing only unique vertices (for indexed rendering / triangle fan)
134
+ * Contains vertex coordinates + UV coordinates
135
+ * - an appropriate vertex layout should be {a_pos: 2, u_uv: 2}
136
+ */
137
+ static quadMeshUniqueVtxUv: number[];
138
+ /** 2D Quad mesh with unique vertices with only vertex positions
139
+ * - an appropriate vertex layout should be {a_pos: 2}
140
+ */
141
+ static quadMeshUniqueVtx: number[];
142
+ /** 2D Quad mesh with defined as two triangles - 6 vertices (not - unique)
143
+ * - basically geometry for drawArrays as gl.TRIANGLE
144
+ * - an appropriate vertex layout should be {a_pos: 2}
145
+ */
146
+ static quadMeshTrianglesVtx: number[];
147
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @class A wrapper class for WebGLProgram
3
+ * - used for creating shader programs (compilation of shaders, linking of shader programs etc.)
4
+ */
5
+ export declare class GlProgram {
6
+ private static numPrograms;
7
+ private _program;
8
+ /** Class instance unique id, tracks number of created instances */
9
+ private _programId;
10
+ private _programName;
11
+ private constructor();
12
+ /**
13
+ * @summary Resets program instance counter on plugin cleanup, used for debugging
14
+ */
15
+ static reset(): void;
16
+ /**
17
+ * @returns Unique program id
18
+ */
19
+ get programId(): number;
20
+ /**
21
+ * @summary Creates shader program from shader sources in strings (vertex and fragment shader source codes)
22
+ * @param vertexShaderSourceCode String with VS shader code
23
+ * @param fragmentShaderSourceCode String with FS shader code
24
+ * @param name String with program name, required for proper error reporting
25
+ * @returns {GlProgram} Created GlProgram instance
26
+ * @throws {GlError} When shader compilation fails or program linking fails
27
+ */
28
+ static constructWithSources(gl: WebGLRenderingContext, vertexShaderSourceCode: string, fragmentShaderSourceCode: string, name: string): GlProgram;
29
+ /**
30
+ * @summary Sets the program as current for rendering
31
+ */
32
+ use(gl: WebGL2RenderingContext | WebGLRenderingContext): void;
33
+ /**
34
+ * @returns {WebGLProgram} WebGLProgram handle (id)
35
+ */
36
+ getProgram(): WebGLProgram;
37
+ /**
38
+ * @summary Safely deletes the shader program including its shaders
39
+ */
40
+ destroy(gl: WebGL2RenderingContext | WebGLRenderingContext): void;
41
+ }
@@ -0,0 +1,95 @@
1
+ import { GlProgram, GlslDataType, type GlMesh } from '@windy/glUtils';
2
+ import type { UniformDataType, UniformRecord } from '@windy/glUtils.d';
3
+ import type { MapLibreMap as MaplibreGlMap } from '@leafletGl';
4
+ import type { Vector4 } from '@windy/math';
5
+ /**
6
+ * @class WebGL renderer abstraction class
7
+ * - class the should provide simple setup and usage of WebGL renderer
8
+ */
9
+ export declare class GlRenderer {
10
+ private ident;
11
+ protected static numRenderers: number;
12
+ /** List of meshes to be rendered by the renderer */
13
+ protected readonly meshes: GlMesh[];
14
+ /** Map of uniform variables used for rendering */
15
+ protected readonly uniforms: Map<string, UniformRecord>;
16
+ /** Set of uniform ids which values recently changed and therefore should be re-uploaded to the GPU */
17
+ protected readonly dirtyUniforms: Set<string>;
18
+ /** Textures must be treated separately since they must be bound each frame */
19
+ protected readonly uniformTextures: Map<string, UniformRecord>;
20
+ /** Program used for rendering */
21
+ protected program: GlProgram;
22
+ protected renderReady: boolean;
23
+ /** Color used to clear the bound framebuffer before rendering the content */
24
+ protected clearColor?: Vector4;
25
+ protected readonly rendererId: number;
26
+ constructor(ident: string);
27
+ /**
28
+ * @summary Resets renderer instance counter on plugin cleanup, used for debugging
29
+ */
30
+ static reset(): void;
31
+ /**
32
+ * @summary Initializes the renderer together with creating its shader program using the already fetched shader sources (strings)
33
+ * @param vsSrc String with source code of the Vertex Shader
34
+ * @param fsSrc String with source code of the Fragment Shader
35
+ */
36
+ initFromSources(gl: WebGLRenderingContext | WebGL2RenderingContext, vsSrc: string, fsSrc: string): void;
37
+ /**
38
+ * @summary Rerenders content into the currently bound framebuffer
39
+ * @param primitiveType Which primitives to draw (points, lines, triangles,..)
40
+ * @param numInstances If set >0, geometry is rendered as N instances
41
+ */
42
+ render(gl: WebGLRenderingContext | WebGL2RenderingContext, primitiveType?: GLenum, numInstances?: number): void;
43
+ /**
44
+ * @summary Updates value of the given uniform (global value sent to the GPU)
45
+ * @param uniformId Which uniform to update
46
+ * @param value New uniform value
47
+ */
48
+ updateUniformValue(uniformId: string, value: UniformDataType): void;
49
+ /**
50
+ * @summary Registers new uniform value to be used during rendering (uniform must be defined in the shader)
51
+ * @param uniformId Name of the uniform variable in the shader code
52
+ * @param dataType Data type of the uniform variable
53
+ * @returns {boolean} Whether the uniform was successfully registered or not
54
+ * - it can fail, for example, when the passed uniformId does not match its name defined in the program
55
+ * (or simply when it is not defined in the program)
56
+ *
57
+ */
58
+ registerUniformRecord(gl: WebGLRenderingContext | WebGL2RenderingContext, uniformId: string, dataType: GlslDataType, defaultValue?: UniformDataType): boolean;
59
+ /**
60
+ * @summary Checks whether the uniform record is already registered (to prevent multi registering)
61
+ */
62
+ isUniformRecordRegistered(uniformId: string): boolean;
63
+ /**
64
+ * @summary Adds mesh to the list of meshes to be rendered
65
+ * @param mesh
66
+ */
67
+ addMesh(mesh: GlMesh): void;
68
+ /**
69
+ * @summary Retrieves shader program owned by the renderer
70
+ */
71
+ getAttachedShader(): GlProgram;
72
+ destroy(gl: WebGLRenderingContext | WebGL2RenderingContext, map?: MaplibreGlMap): void;
73
+ /**
74
+ * @summary Sets color used for clearing the framebuffer
75
+ * @param color Values in range <0.0, 1.0>, if undefined, the color is unset
76
+ */
77
+ setClearColor(color: Vector4 | undefined): void;
78
+ /**
79
+ * @summary Clears the framebuffer with previously set clear-color
80
+ */
81
+ clear(gl: WebGLRenderingContext | WebGL2RenderingContext): void;
82
+ /**
83
+ * @summary Binds dirty uniform variables for rendering
84
+ * - dirty uniform is when its value has changed and must be re-uploaded to the GPU
85
+ * - when value does not change, there is no need to upload it in every frame
86
+ */
87
+ protected bindUniforms(gl: WebGLRenderingContext | WebGL2RenderingContext): void;
88
+ /**
89
+ * @summary Binds all textures that are registered in the shader for rendering
90
+ * - texture uniforms (more specifically texture units and textures) must be bound for every frame since it changes global WebGL state
91
+ * - texture unit id uniform is already set by "bindUniforms" method (this does not have to be updated each frame in case the texture unit does not change)
92
+ * - texture activation and binding must be preformed each frame (in case we are using multiple programs because texture binding changes global WebGL state)
93
+ */
94
+ private bindTextures;
95
+ }
@@ -0,0 +1,98 @@
1
+ import type { Vector2 } from '@windy/math';
2
+ import type { GlColorFormat } from '@windy/glUtils.d';
3
+ /**
4
+ * @class A wrapper class for WebGL Texture
5
+ */
6
+ export declare class GlTexture {
7
+ private static numTextures;
8
+ static reset(): void;
9
+ /**
10
+ * @summary Creates texture instance using remote image
11
+ * @param url Url of the image to fetch
12
+ */
13
+ static createFromUrl(gl: WebGLRenderingContext | WebGL2RenderingContext, url: string): Promise<GlTexture>;
14
+ /** Texture target (e.g. TEXTURE_2D) */
15
+ private readonly _target;
16
+ /** WebGL texture object */
17
+ private readonly _texture;
18
+ /** Class instance unique id, for debug, tracks number of created instances */
19
+ private readonly _textureId;
20
+ /** Texture color WebGL format */
21
+ private _internalFormat;
22
+ /** Current texture dimension (pixels) */
23
+ private _dimensions;
24
+ private _uvDownScale;
25
+ /** Texture uv coordinates wrapping strategy (how to handle uv coordinates out of <0.0,1.0> range) */
26
+ private wrap;
27
+ /** Texture magnification and minification filtering */
28
+ private filter;
29
+ private _usedMemory;
30
+ /**
31
+ * @param format Texture internal format (data representation, e.g. RGB, RGBA, LUMINANCE_ALPHA etc.)
32
+ * @param target Target - TEXTURE_2D, cubemap, array texture etc.
33
+ */
34
+ constructor(gl: WebGLRenderingContext | WebGL2RenderingContext, format?: GlColorFormat, target?: GLenum, fromTexture?: WebGLTexture);
35
+ /**
36
+ * @returns The original WebGL texture object handle
37
+ */
38
+ get texture(): WebGLTexture;
39
+ /**
40
+ * @returns Class instance unique identifier
41
+ */
42
+ get textureId(): number;
43
+ /**
44
+ * @returns Texture target / type (TEXTURE_2D, array texture, cubemap, etc.)
45
+ */
46
+ get target(): GLenum;
47
+ /**
48
+ * @returns {Vector2} Dimensions of the texture
49
+ */
50
+ get dimensions(): Vector2;
51
+ set format(format: GlColorFormat);
52
+ get format(): GlColorFormat;
53
+ get uvDownScale(): Vector2;
54
+ /**
55
+ * @summary Returns gpu memory size currently used by the texture (in bytes)
56
+ */
57
+ get usedMemory(): number;
58
+ /**
59
+ * @summary Uploads new image data into the texture
60
+ * @param data either HTMLImageElement or tuple of [RawData, Dimensions]
61
+ * @param wrap texture wrapping (clamp, repeat...)
62
+ * @param filter texture minification and magnification filtering (nearest, linear)
63
+ * @param premultiply flag, whether to premultiply RGB channels by Alpha channel before uploading data to the GPU (UNPACK_PREMULTIPLY_ALPHA_WEBGL)
64
+ * ToDo: mip-maps, per-coordinate wrap, per mag/min filtering
65
+ */
66
+ updateContent(gl: WebGLRenderingContext | WebGL2RenderingContext, data: HTMLImageElement | [Uint8Array, Vector2] | [Uint8ClampedArray, Vector2] | HTMLCanvasElement | ImageBitmap, wrap?: GLenum, filter?: GLenum, premultiply?: boolean): void;
67
+ /**
68
+ * @summary Binds the texture for rendering and other operations
69
+ * @param wrap Wrap settings, how to handle texture coordinates out of <0.0, 1.0> bounds (where to read)
70
+ * @param filter Texture minification and magnification filtering (nearest / interpolation)
71
+ */
72
+ bind(gl: WebGLRenderingContext | WebGL2RenderingContext, wrap?: GLenum, filter?: GLenum): void;
73
+ /**
74
+ * @summary Unbinds the texture
75
+ */
76
+ unbind(gl: WebGLRenderingContext | WebGL2RenderingContext): void;
77
+ /**
78
+ * @summary Destructor, releases WebGL texture
79
+ */
80
+ destroy(gl: WebGLRenderingContext | WebGL2RenderingContext): void;
81
+ /**
82
+ * @summary Resizes the texture with null data and/or sets new texture format
83
+ * - the reason of performing both in one method is to ideally perform both operations using single gl.texImage2D call
84
+ * @param newSize Dimensions in pixels
85
+ * @param disableDownscale Flag that disables the resize
86
+ * (since there are multiple conditions, that can lead to preventing the resize from outer scope)
87
+ * @param newFormat Optional new color format to be set to the texture
88
+ * @returns {Vector2} A rescale vector representing the factor by which the original UV coordinates should be rescaled
89
+ * in case texture down-scaling is disabled {@link disableDownscale} --> in this way the UV range is constrained only to the valid area
90
+ */
91
+ resize(gl: WebGLRenderingContext | WebGL2RenderingContext, newSize: Vector2, disableDownscale?: boolean, newFormat?: GlColorFormat): Vector2;
92
+ /**
93
+ * @summary Reallocates the texture based on the new dimensions and/or new color format
94
+ */
95
+ private reallocate;
96
+ private setupProfiling;
97
+ private updateProfilingStats;
98
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @class A wrapper class for WebGL VertexArrayObject (VAO)
3
+ */
4
+ export declare class GlVertexArray {
5
+ private static vaosCount;
6
+ private readonly vaoId;
7
+ private vao;
8
+ /**
9
+ * @summary Resets vao instance counter on plugin cleanup, used for debugging
10
+ */
11
+ static reset(): void;
12
+ /**
13
+ * @summary Tries to create WebGL VertexArrayObject
14
+ * @returns {GlVertexArray | null} GlVertexArray instance or null,
15
+ * if WebGL1 used and VAO extension (OES_vertex_array_object) is not available
16
+ */
17
+ static create(gl: WebGLRenderingContext | WebGL2RenderingContext): GlVertexArray | null;
18
+ /**
19
+ * @summary Binds the Vertex Array for rendering
20
+ * - Binds proper VAO (either by WebGL2 or by WebGL1 extension)
21
+ */
22
+ bind(gl: WebGLRenderingContext | WebGL2RenderingContext): void;
23
+ /**
24
+ * @summary Unbinds the Vertex Array
25
+ */
26
+ unbind(gl: WebGLRenderingContext | WebGL2RenderingContext): void;
27
+ /**
28
+ * @summary Destructor - releases all WebGL resources
29
+ */
30
+ destroy(gl: WebGLRenderingContext | WebGL2RenderingContext): void;
31
+ /**
32
+ * @summary Tries to initialize the WebGL/WebGL2 VertexArrayObject
33
+ * @returns {boolean} Flag whether the initialization was successful
34
+ * - it can fail in case the WebGL2 is not supported and
35
+ * the WebGL1 extension "OES_vertex_array_object" is not available
36
+ */
37
+ private init;
38
+ }