@mui/x-charts-premium 9.7.0 → 9.9.0

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 (230) hide show
  1. package/BarChartPremium/BarChartPremium.d.mts +1 -1
  2. package/BarChartPremium/BarChartPremium.d.ts +1 -1
  3. package/BarChartPremium/BarChartPremium.js +14 -3
  4. package/BarChartPremium/BarChartPremium.mjs +14 -3
  5. package/BarChartPremium/RangeBar/AnimatedRangeBarElement.d.mts +2 -1
  6. package/BarChartPremium/RangeBar/AnimatedRangeBarElement.d.ts +2 -1
  7. package/BarChartPremium/RangeBar/FocusedRangeBar.d.mts +1 -1
  8. package/BarChartPremium/RangeBar/FocusedRangeBar.d.ts +1 -1
  9. package/BarChartPremium/RangeBar/seriesConfig/index.js +2 -2
  10. package/BarChartPremium/RangeBar/seriesConfig/index.mjs +2 -2
  11. package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.d.mts +2 -3
  12. package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.d.ts +2 -3
  13. package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.js +12 -15
  14. package/BarChartPremium/RangeBar/seriesConfig/tooltipPosition.mjs +11 -14
  15. package/BarChartPremium/webgl/BarWebGLProgram.d.mts +4 -5
  16. package/BarChartPremium/webgl/BarWebGLProgram.d.ts +4 -5
  17. package/BarChartPremium/webgl/BarWebGLProgram.js +24 -65
  18. package/BarChartPremium/webgl/BarWebGLProgram.mjs +24 -65
  19. package/BarChartPremium/webgl/shaders.d.mts +1 -1
  20. package/BarChartPremium/webgl/shaders.d.ts +1 -1
  21. package/BarChartPremium/webgl/shaders.js +2 -15
  22. package/BarChartPremium/webgl/shaders.mjs +3 -15
  23. package/CHANGELOG.md +249 -1
  24. package/CandlestickChart/CandlestickPlot.d.mts +2 -1
  25. package/CandlestickChart/CandlestickPlot.d.ts +2 -1
  26. package/CandlestickChart/seriesConfig/OHLCTooltipContent.d.mts +2 -1
  27. package/CandlestickChart/seriesConfig/OHLCTooltipContent.d.ts +2 -1
  28. package/CandlestickChart/seriesConfig/index.js +2 -2
  29. package/CandlestickChart/seriesConfig/index.mjs +2 -2
  30. package/CandlestickChart/seriesConfig/tooltipPosition.d.mts +2 -3
  31. package/CandlestickChart/seriesConfig/tooltipPosition.d.ts +2 -3
  32. package/CandlestickChart/seriesConfig/tooltipPosition.js +10 -14
  33. package/CandlestickChart/seriesConfig/tooltipPosition.mjs +10 -14
  34. package/ChartsDataProviderPremium/ChartsDataProviderPremium.d.mts +1 -1
  35. package/ChartsDataProviderPremium/ChartsDataProviderPremium.d.ts +1 -1
  36. package/ChartsDataProviderPremium/ChartsDataProviderPremium.js +2 -2
  37. package/ChartsDataProviderPremium/ChartsDataProviderPremium.mjs +2 -2
  38. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.d.mts +1 -1
  39. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.d.ts +1 -1
  40. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.js +2 -2
  41. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.mjs +2 -2
  42. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.d.mts +4 -3
  43. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.d.ts +4 -3
  44. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.js +2 -1
  45. package/ChartsGeoDataProviderPremium/ChartsGeoDataProviderPremium.plugins.mjs +2 -1
  46. package/ChartsGeoDataProviderPremium/index.d.mts +2 -1
  47. package/ChartsGeoDataProviderPremium/index.d.ts +2 -1
  48. package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.d.mts +2 -1
  49. package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.d.ts +2 -1
  50. package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.js +2 -2
  51. package/ChartsRadialDataProviderPremium/ChartsRadialDataProviderPremium.mjs +2 -2
  52. package/ChartsRenderer/components/PaletteOption.d.mts +1 -1
  53. package/ChartsRenderer/components/PaletteOption.d.ts +1 -1
  54. package/ChartsZoomSlider/internals/previews/CandlestickPreviewPlot.d.mts +2 -1
  55. package/ChartsZoomSlider/internals/previews/CandlestickPreviewPlot.d.ts +2 -1
  56. package/ChartsZoomSlider/internals/previews/RangeBarPreviewPlot.d.mts +1 -1
  57. package/ChartsZoomSlider/internals/previews/RangeBarPreviewPlot.d.ts +1 -1
  58. package/HeatmapPremium/HeatmapPlotPremium.d.mts +1 -1
  59. package/HeatmapPremium/HeatmapPlotPremium.d.ts +1 -1
  60. package/HeatmapPremium/webgl/HeatmapWebGLProgram.js +12 -37
  61. package/HeatmapPremium/webgl/HeatmapWebGLProgram.mjs +12 -37
  62. package/HeatmapPremium/webgl/shaders.d.mts +3 -3
  63. package/HeatmapPremium/webgl/shaders.d.ts +3 -3
  64. package/HeatmapPremium/webgl/shaders.js +12 -15
  65. package/HeatmapPremium/webgl/shaders.mjs +13 -15
  66. package/HeatmapPremium/webgl/useHeatmapPlotData.js +3 -8
  67. package/HeatmapPremium/webgl/useHeatmapPlotData.mjs +3 -8
  68. package/Map/FocusedMapShape.d.mts +2 -1
  69. package/Map/FocusedMapShape.d.ts +2 -1
  70. package/Map/FocusedMapShape.js +5 -1
  71. package/Map/FocusedMapShape.mjs +5 -1
  72. package/Map/GeoDataPlot.d.mts +1 -1
  73. package/Map/GeoDataPlot.d.ts +1 -1
  74. package/Map/Graticule.d.mts +1 -1
  75. package/Map/Graticule.d.ts +1 -1
  76. package/Map/MapImagePlot.d.mts +39 -0
  77. package/Map/MapImagePlot.d.ts +39 -0
  78. package/Map/MapImagePlot.js +138 -0
  79. package/Map/MapImagePlot.mjs +132 -0
  80. package/Map/MapShape.d.mts +2 -2
  81. package/Map/MapShape.d.ts +2 -2
  82. package/Map/MapShape.js +6 -6
  83. package/Map/MapShape.mjs +6 -6
  84. package/Map/MapShapePlot.d.mts +9 -1
  85. package/Map/MapShapePlot.d.ts +9 -1
  86. package/Map/MapShapePlot.js +17 -5
  87. package/Map/MapShapePlot.mjs +17 -5
  88. package/Map/index.d.mts +2 -3
  89. package/Map/index.d.ts +2 -3
  90. package/Map/index.js +11 -0
  91. package/Map/index.mjs +1 -0
  92. package/Map/reprojectEquirectangularImage.d.mts +60 -0
  93. package/Map/reprojectEquirectangularImage.d.ts +60 -0
  94. package/Map/reprojectEquirectangularImage.js +116 -0
  95. package/Map/reprojectEquirectangularImage.mjs +110 -0
  96. package/Map/seriesConfig/descriptionGetter.js +5 -1
  97. package/Map/seriesConfig/descriptionGetter.mjs +5 -1
  98. package/Map/seriesConfig/getColor.js +18 -6
  99. package/Map/seriesConfig/getColor.mjs +18 -6
  100. package/Map/seriesConfig/highlight.d.mts +10 -0
  101. package/Map/seriesConfig/highlight.d.ts +10 -0
  102. package/Map/seriesConfig/highlight.js +52 -0
  103. package/Map/seriesConfig/highlight.mjs +45 -0
  104. package/Map/seriesConfig/identifierCleaner.d.mts +3 -0
  105. package/Map/seriesConfig/identifierCleaner.d.ts +3 -0
  106. package/Map/seriesConfig/identifierCleaner.js +14 -0
  107. package/Map/seriesConfig/identifierCleaner.mjs +8 -0
  108. package/Map/seriesConfig/identifierSerializer.d.mts +3 -0
  109. package/Map/seriesConfig/identifierSerializer.d.ts +3 -0
  110. package/Map/seriesConfig/identifierSerializer.js +12 -0
  111. package/Map/seriesConfig/identifierSerializer.mjs +6 -0
  112. package/Map/seriesConfig/index.js +8 -6
  113. package/Map/seriesConfig/index.mjs +7 -5
  114. package/Map/seriesConfig/keyboardFocusHandler.d.mts +0 -6
  115. package/Map/seriesConfig/keyboardFocusHandler.d.ts +0 -6
  116. package/Map/seriesConfig/keyboardFocusHandler.js +40 -7
  117. package/Map/seriesConfig/keyboardFocusHandler.mjs +41 -8
  118. package/Map/seriesConfig/seriesProcessor.js +11 -2
  119. package/Map/seriesConfig/seriesProcessor.mjs +11 -2
  120. package/Map/seriesConfig/tooltip.js +8 -4
  121. package/Map/seriesConfig/tooltip.mjs +8 -4
  122. package/Map/seriesConfig/tooltipPosition.d.mts +8 -3
  123. package/Map/seriesConfig/tooltipPosition.d.ts +8 -3
  124. package/Map/seriesConfig/tooltipPosition.js +15 -27
  125. package/Map/seriesConfig/tooltipPosition.mjs +16 -27
  126. package/RadialBarChart/RadialBarElement.d.mts +1 -1
  127. package/RadialBarChart/RadialBarElement.d.ts +1 -1
  128. package/RadialBarChart/seriesConfig/index.js +2 -2
  129. package/RadialBarChart/seriesConfig/index.mjs +2 -2
  130. package/RadialBarChart/seriesConfig/tooltipPosition.d.mts +2 -3
  131. package/RadialBarChart/seriesConfig/tooltipPosition.d.ts +2 -3
  132. package/RadialBarChart/seriesConfig/tooltipPosition.js +4 -6
  133. package/RadialBarChart/seriesConfig/tooltipPosition.mjs +2 -5
  134. package/RadialLineChart/RadialArea.d.mts +2 -1
  135. package/RadialLineChart/RadialArea.d.ts +2 -1
  136. package/RadialLineChart/RadialAreaPlot.d.mts +1 -1
  137. package/RadialLineChart/RadialAreaPlot.d.ts +1 -1
  138. package/RadialLineChart/RadialLine.d.mts +1 -1
  139. package/RadialLineChart/RadialLine.d.ts +1 -1
  140. package/RadialLineChart/RadialLineHighlightElement.d.mts +1 -1
  141. package/RadialLineChart/RadialLineHighlightElement.d.ts +1 -1
  142. package/RadialLineChart/RadialLineHighlightPlot.d.mts +1 -1
  143. package/RadialLineChart/RadialLineHighlightPlot.d.ts +1 -1
  144. package/RadialLineChart/RadialLinePlot.d.mts +1 -1
  145. package/RadialLineChart/RadialLinePlot.d.ts +1 -1
  146. package/RadialLineChart/RadialMarkPlot.d.mts +1 -1
  147. package/RadialLineChart/RadialMarkPlot.d.ts +1 -1
  148. package/RadialLineChart/seriesConfig/index.js +2 -2
  149. package/RadialLineChart/seriesConfig/index.mjs +2 -2
  150. package/RadialLineChart/seriesConfig/tooltipPosition.d.mts +2 -3
  151. package/RadialLineChart/seriesConfig/tooltipPosition.d.ts +2 -3
  152. package/RadialLineChart/seriesConfig/tooltipPosition.js +4 -6
  153. package/RadialLineChart/seriesConfig/tooltipPosition.mjs +2 -5
  154. package/ScatterChartPremium/ScatterPlotPremium.d.mts +2 -1
  155. package/ScatterChartPremium/ScatterPlotPremium.d.ts +2 -1
  156. package/ScatterChartPremium/webgl/ScatterWebGLPlot.d.mts +2 -1
  157. package/ScatterChartPremium/webgl/ScatterWebGLPlot.d.ts +2 -1
  158. package/ScatterChartPremium/webgl/ScatterWebGLProgram.d.mts +0 -2
  159. package/ScatterChartPremium/webgl/ScatterWebGLProgram.d.ts +0 -2
  160. package/ScatterChartPremium/webgl/ScatterWebGLProgram.js +23 -81
  161. package/ScatterChartPremium/webgl/ScatterWebGLProgram.mjs +23 -81
  162. package/index.js +1 -1
  163. package/index.mjs +1 -1
  164. package/internals/createGetVisibleCoordinate.d.mts +14 -0
  165. package/internals/createGetVisibleCoordinate.d.ts +14 -0
  166. package/internals/createGetVisibleCoordinate.js +66 -0
  167. package/internals/createGetVisibleCoordinate.mjs +60 -0
  168. package/internals/plugins/useGeoProjection/factories.d.mts +3 -0
  169. package/internals/plugins/useGeoProjection/factories.d.ts +3 -0
  170. package/internals/plugins/useGeoProjection/factories.js +29 -0
  171. package/internals/plugins/useGeoProjection/factories.mjs +23 -0
  172. package/internals/plugins/useGeoProjection/projection.utils.d.mts +17 -0
  173. package/internals/plugins/useGeoProjection/projection.utils.d.ts +17 -0
  174. package/internals/plugins/useGeoProjection/projection.utils.js +67 -0
  175. package/internals/plugins/useGeoProjection/projection.utils.mjs +59 -0
  176. package/internals/plugins/useGeoProjection/useGeoProjection.js +7 -40
  177. package/internals/plugins/useGeoProjection/useGeoProjection.mjs +7 -40
  178. package/internals/plugins/useGeoProjection/useGeoProjection.selectors.d.mts +47 -11
  179. package/internals/plugins/useGeoProjection/useGeoProjection.selectors.d.ts +47 -11
  180. package/internals/plugins/useGeoProjection/useGeoProjection.selectors.js +118 -8
  181. package/internals/plugins/useGeoProjection/useGeoProjection.selectors.mjs +117 -8
  182. package/internals/plugins/useGeoProjection/useGeoProjection.types.d.mts +63 -2
  183. package/internals/plugins/useGeoProjection/useGeoProjection.types.d.ts +63 -2
  184. package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.d.mts +11 -0
  185. package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.d.ts +11 -0
  186. package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.js +65 -0
  187. package/internals/plugins/useGeoProjectionZoom/gestureHooks/usePanOnDrag.mjs +58 -0
  188. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.d.mts +13 -0
  189. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.d.ts +13 -0
  190. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.js +62 -0
  191. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnPinch.mjs +56 -0
  192. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.d.mts +13 -0
  193. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.d.ts +13 -0
  194. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.js +64 -0
  195. package/internals/plugins/useGeoProjectionZoom/gestureHooks/useZoomOnWheel.mjs +58 -0
  196. package/internals/plugins/useGeoProjectionZoom/index.d.mts +2 -0
  197. package/internals/plugins/useGeoProjectionZoom/index.d.ts +2 -0
  198. package/internals/plugins/useGeoProjectionZoom/index.js +12 -0
  199. package/internals/plugins/useGeoProjectionZoom/index.mjs +1 -0
  200. package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.d.mts +31 -0
  201. package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.d.ts +31 -0
  202. package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.js +187 -0
  203. package/internals/plugins/useGeoProjectionZoom/mapZoom.utils.mjs +177 -0
  204. package/internals/plugins/useGeoProjectionZoom/rotationMath.d.mts +23 -0
  205. package/internals/plugins/useGeoProjectionZoom/rotationMath.d.ts +23 -0
  206. package/internals/plugins/useGeoProjectionZoom/rotationMath.js +190 -0
  207. package/internals/plugins/useGeoProjectionZoom/rotationMath.mjs +182 -0
  208. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.d.mts +3 -0
  209. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.d.ts +3 -0
  210. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.js +174 -0
  211. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.mjs +166 -0
  212. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.d.mts +152 -0
  213. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.d.ts +152 -0
  214. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.js +5 -0
  215. package/internals/plugins/useGeoProjectionZoom/useGeoProjectionZoom.types.mjs +1 -0
  216. package/models/seriesType/mapShape.d.mts +2 -1
  217. package/models/seriesType/mapShape.d.ts +2 -1
  218. package/package.json +6 -6
  219. package/utils/webgl/glsl.d.mts +15 -0
  220. package/utils/webgl/glsl.d.ts +15 -0
  221. package/utils/webgl/glsl.js +34 -0
  222. package/utils/webgl/glsl.mjs +28 -0
  223. package/utils/webgl/instancedAttribute.d.mts +28 -0
  224. package/utils/webgl/instancedAttribute.d.ts +28 -0
  225. package/utils/webgl/instancedAttribute.js +57 -0
  226. package/utils/webgl/instancedAttribute.mjs +50 -0
  227. package/utils/webgl/utils.d.mts +21 -2
  228. package/utils/webgl/utils.d.ts +21 -2
  229. package/utils/webgl/utils.js +44 -8
  230. package/utils/webgl/utils.mjs +41 -7
@@ -0,0 +1,28 @@
1
+ import type { GrowableBuffer } from "./utils.js";
2
+ export interface InstancedAttribute {
3
+ buffer: GrowableBuffer;
4
+ location: number;
5
+ size: number;
6
+ glType: GLenum;
7
+ normalized: boolean;
8
+ }
9
+ /**
10
+ * Creates a per-instance vertex attribute backed by a fresh grow-only GPU buffer.
11
+ *
12
+ * The caller MUST have the owning VAO bound when calling this — the
13
+ * vertexAttribPointer + vertexAttribDivisor calls register the binding into
14
+ * that VAO and the program then references it on each draw.
15
+ */
16
+ export declare function createInstancedAttribute(gl: WebGL2RenderingContext, program: WebGLProgram, name: string, size: number, glType?: GLenum, normalized?: boolean): InstancedAttribute;
17
+ /**
18
+ * Wires up a per-instance vertex attribute that reads from an existing GrowableBuffer.
19
+ * Use this when the same buffer must back the same-named attribute in multiple
20
+ * VAOs (e.g. two shader-program variants over the same data).
21
+ *
22
+ * The caller MUST have the owning VAO bound when calling this.
23
+ *
24
+ * If the attribute is missing from the program (typo, or optimized out by the
25
+ * compiler), `getAttribLocation` returns -1. We skip the GL setup in that case to
26
+ * avoid `INVALID_VALUE` errors from `enableVertexAttribArray(-1)` and warn in dev.
27
+ */
28
+ export declare function bindInstancedAttribute(gl: WebGL2RenderingContext, program: WebGLProgram, name: string, buffer: GrowableBuffer, size: number, glType?: GLenum, normalized?: boolean): InstancedAttribute;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.bindInstancedAttribute = bindInstancedAttribute;
7
+ exports.createInstancedAttribute = createInstancedAttribute;
8
+ var _utils = require("./utils");
9
+ /**
10
+ * Creates a per-instance vertex attribute backed by a fresh grow-only GPU buffer.
11
+ *
12
+ * The caller MUST have the owning VAO bound when calling this — the
13
+ * vertexAttribPointer + vertexAttribDivisor calls register the binding into
14
+ * that VAO and the program then references it on each draw.
15
+ */
16
+ function createInstancedAttribute(gl, program, name, size, glType = gl.FLOAT, normalized = false) {
17
+ const buffer = (0, _utils.createGrowableBuffer)(gl);
18
+ return bindInstancedAttribute(gl, program, name, buffer, size, glType, normalized);
19
+ }
20
+
21
+ /**
22
+ * Wires up a per-instance vertex attribute that reads from an existing GrowableBuffer.
23
+ * Use this when the same buffer must back the same-named attribute in multiple
24
+ * VAOs (e.g. two shader-program variants over the same data).
25
+ *
26
+ * The caller MUST have the owning VAO bound when calling this.
27
+ *
28
+ * If the attribute is missing from the program (typo, or optimized out by the
29
+ * compiler), `getAttribLocation` returns -1. We skip the GL setup in that case to
30
+ * avoid `INVALID_VALUE` errors from `enableVertexAttribArray(-1)` and warn in dev.
31
+ */
32
+ function bindInstancedAttribute(gl, program, name, buffer, size, glType = gl.FLOAT, normalized = false) {
33
+ const location = gl.getAttribLocation(program, name);
34
+ if (location === -1) {
35
+ if (process.env.NODE_ENV !== 'production') {
36
+ console.warn(`WebGL attribute "${name}" not found in shader program (misspelled or optimized out).`);
37
+ }
38
+ return {
39
+ buffer,
40
+ location,
41
+ size,
42
+ glType,
43
+ normalized
44
+ };
45
+ }
46
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer.buffer);
47
+ gl.enableVertexAttribArray(location);
48
+ gl.vertexAttribPointer(location, size, glType, normalized, 0, 0);
49
+ gl.vertexAttribDivisor(location, 1);
50
+ return {
51
+ buffer,
52
+ location,
53
+ size,
54
+ glType,
55
+ normalized
56
+ };
57
+ }
@@ -0,0 +1,50 @@
1
+ import { createGrowableBuffer } from "./utils.mjs";
2
+ /**
3
+ * Creates a per-instance vertex attribute backed by a fresh grow-only GPU buffer.
4
+ *
5
+ * The caller MUST have the owning VAO bound when calling this — the
6
+ * vertexAttribPointer + vertexAttribDivisor calls register the binding into
7
+ * that VAO and the program then references it on each draw.
8
+ */
9
+ export function createInstancedAttribute(gl, program, name, size, glType = gl.FLOAT, normalized = false) {
10
+ const buffer = createGrowableBuffer(gl);
11
+ return bindInstancedAttribute(gl, program, name, buffer, size, glType, normalized);
12
+ }
13
+
14
+ /**
15
+ * Wires up a per-instance vertex attribute that reads from an existing GrowableBuffer.
16
+ * Use this when the same buffer must back the same-named attribute in multiple
17
+ * VAOs (e.g. two shader-program variants over the same data).
18
+ *
19
+ * The caller MUST have the owning VAO bound when calling this.
20
+ *
21
+ * If the attribute is missing from the program (typo, or optimized out by the
22
+ * compiler), `getAttribLocation` returns -1. We skip the GL setup in that case to
23
+ * avoid `INVALID_VALUE` errors from `enableVertexAttribArray(-1)` and warn in dev.
24
+ */
25
+ export function bindInstancedAttribute(gl, program, name, buffer, size, glType = gl.FLOAT, normalized = false) {
26
+ const location = gl.getAttribLocation(program, name);
27
+ if (location === -1) {
28
+ if (process.env.NODE_ENV !== 'production') {
29
+ console.warn(`WebGL attribute "${name}" not found in shader program (misspelled or optimized out).`);
30
+ }
31
+ return {
32
+ buffer,
33
+ location,
34
+ size,
35
+ glType,
36
+ normalized
37
+ };
38
+ }
39
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer.buffer);
40
+ gl.enableVertexAttribArray(location);
41
+ gl.vertexAttribPointer(location, size, glType, normalized, 0, 0);
42
+ gl.vertexAttribDivisor(location, 1);
43
+ return {
44
+ buffer,
45
+ location,
46
+ size,
47
+ glType,
48
+ normalized
49
+ };
50
+ }
@@ -1,7 +1,6 @@
1
1
  export declare function compileShader(gl: WebGL2RenderingContext, shaderSource: string, shaderType: WebGL2RenderingContext['FRAGMENT_SHADER'] | WebGL2RenderingContext['VERTEX_SHADER']): WebGLShader;
2
2
  export declare function uploadQuadBuffer(gl: WebGL2RenderingContext): WebGLBuffer;
3
3
  export declare function bindQuadBuffer(gl: WebGL2RenderingContext, program: WebGLProgram, quadBuffer: WebGLBuffer): void;
4
- export declare function attachShader(gl: WebGL2RenderingContext, program: WebGLProgram, shaderSource: string, shaderType: WebGL2RenderingContext['FRAGMENT_SHADER'] | WebGL2RenderingContext['VERTEX_SHADER']): WebGLShader;
5
4
  export type GrowableBuffer = {
6
5
  buffer: WebGLBuffer;
7
6
  capacity: number;
@@ -18,4 +17,24 @@ export declare function uploadGrowableBuffer(gl: WebGL2RenderingContext, target:
18
17
  /**
19
18
  * Logs WebGL errors to the console in development mode.
20
19
  */
21
- export declare function logWebGLErrors(gl: WebGL2RenderingContext): void;
20
+ export declare function logWebGLErrors(gl: WebGL2RenderingContext): void;
21
+ /** Enables the standard non-premultiplied src-alpha blending used by all premium WebGL renderers. */
22
+ export declare function setupStandardBlending(gl: WebGL2RenderingContext): void;
23
+ /**
24
+ * Returns `existing` when it's large enough to hold `length` elements, otherwise
25
+ * allocates a fresh typed array via `Ctor`. Lets consumers keep one ref per
26
+ * pool and short-circuit growth checks inline.
27
+ */
28
+ export declare function ensurePool<T extends {
29
+ length: number;
30
+ }>(existing: T | null | undefined, length: number, Ctor: new (length: number) => T): T;
31
+ export interface LinkedProgram {
32
+ program: WebGLProgram;
33
+ /** The vertex + fragment shaders that were attached. Hold them so dispose() can delete them. */
34
+ shaders: WebGLShader[];
35
+ }
36
+ /**
37
+ * Compiles vertex + fragment shaders, attaches them, links the program, and returns
38
+ * both the program and its shaders. Logs link/compile diagnostics in dev when linking fails.
39
+ */
40
+ export declare function linkProgram(gl: WebGL2RenderingContext, vertexShaderSource: string, fragmentShaderSource: string): LinkedProgram;
@@ -1,7 +1,6 @@
1
1
  export declare function compileShader(gl: WebGL2RenderingContext, shaderSource: string, shaderType: WebGL2RenderingContext['FRAGMENT_SHADER'] | WebGL2RenderingContext['VERTEX_SHADER']): WebGLShader;
2
2
  export declare function uploadQuadBuffer(gl: WebGL2RenderingContext): WebGLBuffer;
3
3
  export declare function bindQuadBuffer(gl: WebGL2RenderingContext, program: WebGLProgram, quadBuffer: WebGLBuffer): void;
4
- export declare function attachShader(gl: WebGL2RenderingContext, program: WebGLProgram, shaderSource: string, shaderType: WebGL2RenderingContext['FRAGMENT_SHADER'] | WebGL2RenderingContext['VERTEX_SHADER']): WebGLShader;
5
4
  export type GrowableBuffer = {
6
5
  buffer: WebGLBuffer;
7
6
  capacity: number;
@@ -18,4 +17,24 @@ export declare function uploadGrowableBuffer(gl: WebGL2RenderingContext, target:
18
17
  /**
19
18
  * Logs WebGL errors to the console in development mode.
20
19
  */
21
- export declare function logWebGLErrors(gl: WebGL2RenderingContext): void;
20
+ export declare function logWebGLErrors(gl: WebGL2RenderingContext): void;
21
+ /** Enables the standard non-premultiplied src-alpha blending used by all premium WebGL renderers. */
22
+ export declare function setupStandardBlending(gl: WebGL2RenderingContext): void;
23
+ /**
24
+ * Returns `existing` when it's large enough to hold `length` elements, otherwise
25
+ * allocates a fresh typed array via `Ctor`. Lets consumers keep one ref per
26
+ * pool and short-circuit growth checks inline.
27
+ */
28
+ export declare function ensurePool<T extends {
29
+ length: number;
30
+ }>(existing: T | null | undefined, length: number, Ctor: new (length: number) => T): T;
31
+ export interface LinkedProgram {
32
+ program: WebGLProgram;
33
+ /** The vertex + fragment shaders that were attached. Hold them so dispose() can delete them. */
34
+ shaders: WebGLShader[];
35
+ }
36
+ /**
37
+ * Compiles vertex + fragment shaders, attaches them, links the program, and returns
38
+ * both the program and its shaders. Logs link/compile diagnostics in dev when linking fails.
39
+ */
40
+ export declare function linkProgram(gl: WebGL2RenderingContext, vertexShaderSource: string, fragmentShaderSource: string): LinkedProgram;
@@ -3,11 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.attachShader = attachShader;
7
6
  exports.bindQuadBuffer = bindQuadBuffer;
8
7
  exports.compileShader = compileShader;
9
8
  exports.createGrowableBuffer = createGrowableBuffer;
9
+ exports.ensurePool = ensurePool;
10
+ exports.linkProgram = linkProgram;
10
11
  exports.logWebGLErrors = logWebGLErrors;
12
+ exports.setupStandardBlending = setupStandardBlending;
11
13
  exports.uploadGrowableBuffer = uploadGrowableBuffer;
12
14
  exports.uploadQuadBuffer = uploadQuadBuffer;
13
15
  function compileShader(gl, shaderSource, shaderType) {
@@ -29,13 +31,6 @@ function bindQuadBuffer(gl, program, quadBuffer) {
29
31
  gl.enableVertexAttribArray(aPosition);
30
32
  gl.vertexAttribPointer(aPosition, 2, gl.FLOAT, false, 0, 0);
31
33
  }
32
- function attachShader(gl, program, shaderSource, shaderType) {
33
- const shader = gl.createShader(shaderType);
34
- gl.shaderSource(shader, shaderSource);
35
- gl.compileShader(shader);
36
- gl.attachShader(program, shader);
37
- return shader;
38
- }
39
34
  function createGrowableBuffer(gl) {
40
35
  return {
41
36
  buffer: gl.createBuffer(),
@@ -77,4 +72,45 @@ function logWebGLErrors(gl) {
77
72
  error = gl.getError();
78
73
  }
79
74
  }
75
+ }
76
+
77
+ /** Enables the standard non-premultiplied src-alpha blending used by all premium WebGL renderers. */
78
+ function setupStandardBlending(gl) {
79
+ gl.enable(gl.BLEND);
80
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
81
+ }
82
+
83
+ /**
84
+ * Returns `existing` when it's large enough to hold `length` elements, otherwise
85
+ * allocates a fresh typed array via `Ctor`. Lets consumers keep one ref per
86
+ * pool and short-circuit growth checks inline.
87
+ */
88
+ function ensurePool(existing, length, Ctor) {
89
+ if (existing != null && existing.length >= length) {
90
+ return existing;
91
+ }
92
+ return new Ctor(length);
93
+ }
94
+ /**
95
+ * Compiles vertex + fragment shaders, attaches them, links the program, and returns
96
+ * both the program and its shaders. Logs link/compile diagnostics in dev when linking fails.
97
+ */
98
+ function linkProgram(gl, vertexShaderSource, fragmentShaderSource) {
99
+ const program = gl.createProgram();
100
+ const vertexShader = compileShader(gl, vertexShaderSource, gl.VERTEX_SHADER);
101
+ const fragmentShader = compileShader(gl, fragmentShaderSource, gl.FRAGMENT_SHADER);
102
+ gl.attachShader(program, vertexShader);
103
+ gl.attachShader(program, fragmentShader);
104
+ gl.linkProgram(program);
105
+ if (process.env.NODE_ENV !== 'production' && !gl.getProgramParameter(program, gl.LINK_STATUS)) {
106
+ // WebGL best-practices: consult compile/link status only in dev mode
107
+ // https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#dont_check_shader_compile_status_unless_linking_fails
108
+ console.error(`Program linking failed: ${gl.getProgramInfoLog(program)}`);
109
+ console.error(`Vertex shader info-log: ${gl.getShaderInfoLog(vertexShader)}`);
110
+ console.error(`Fragment shader info-log: ${gl.getShaderInfoLog(fragmentShader)}`);
111
+ }
112
+ return {
113
+ program,
114
+ shaders: [vertexShader, fragmentShader]
115
+ };
80
116
  }
@@ -17,13 +17,6 @@ export function bindQuadBuffer(gl, program, quadBuffer) {
17
17
  gl.enableVertexAttribArray(aPosition);
18
18
  gl.vertexAttribPointer(aPosition, 2, gl.FLOAT, false, 0, 0);
19
19
  }
20
- export function attachShader(gl, program, shaderSource, shaderType) {
21
- const shader = gl.createShader(shaderType);
22
- gl.shaderSource(shader, shaderSource);
23
- gl.compileShader(shader);
24
- gl.attachShader(program, shader);
25
- return shader;
26
- }
27
20
  export function createGrowableBuffer(gl) {
28
21
  return {
29
22
  buffer: gl.createBuffer(),
@@ -65,4 +58,45 @@ export function logWebGLErrors(gl) {
65
58
  error = gl.getError();
66
59
  }
67
60
  }
61
+ }
62
+
63
+ /** Enables the standard non-premultiplied src-alpha blending used by all premium WebGL renderers. */
64
+ export function setupStandardBlending(gl) {
65
+ gl.enable(gl.BLEND);
66
+ gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
67
+ }
68
+
69
+ /**
70
+ * Returns `existing` when it's large enough to hold `length` elements, otherwise
71
+ * allocates a fresh typed array via `Ctor`. Lets consumers keep one ref per
72
+ * pool and short-circuit growth checks inline.
73
+ */
74
+ export function ensurePool(existing, length, Ctor) {
75
+ if (existing != null && existing.length >= length) {
76
+ return existing;
77
+ }
78
+ return new Ctor(length);
79
+ }
80
+ /**
81
+ * Compiles vertex + fragment shaders, attaches them, links the program, and returns
82
+ * both the program and its shaders. Logs link/compile diagnostics in dev when linking fails.
83
+ */
84
+ export function linkProgram(gl, vertexShaderSource, fragmentShaderSource) {
85
+ const program = gl.createProgram();
86
+ const vertexShader = compileShader(gl, vertexShaderSource, gl.VERTEX_SHADER);
87
+ const fragmentShader = compileShader(gl, fragmentShaderSource, gl.FRAGMENT_SHADER);
88
+ gl.attachShader(program, vertexShader);
89
+ gl.attachShader(program, fragmentShader);
90
+ gl.linkProgram(program);
91
+ if (process.env.NODE_ENV !== 'production' && !gl.getProgramParameter(program, gl.LINK_STATUS)) {
92
+ // WebGL best-practices: consult compile/link status only in dev mode
93
+ // https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices#dont_check_shader_compile_status_unless_linking_fails
94
+ console.error(`Program linking failed: ${gl.getProgramInfoLog(program)}`);
95
+ console.error(`Vertex shader info-log: ${gl.getShaderInfoLog(vertexShader)}`);
96
+ console.error(`Fragment shader info-log: ${gl.getShaderInfoLog(fragmentShader)}`);
97
+ }
98
+ return {
99
+ program,
100
+ shaders: [vertexShader, fragmentShader]
101
+ };
68
102
  }