@luma.gl/core 9.3.0-alpha.4 → 9.3.0-alpha.8

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 (252) hide show
  1. package/dist/adapter/canvas-context.d.ts +6 -182
  2. package/dist/adapter/canvas-context.d.ts.map +1 -1
  3. package/dist/adapter/canvas-context.js +5 -481
  4. package/dist/adapter/canvas-context.js.map +1 -1
  5. package/dist/adapter/canvas-observer.d.ts +32 -0
  6. package/dist/adapter/canvas-observer.d.ts.map +1 -0
  7. package/dist/adapter/canvas-observer.js +90 -0
  8. package/dist/adapter/canvas-observer.js.map +1 -0
  9. package/dist/adapter/canvas-surface.d.ts +150 -0
  10. package/dist/adapter/canvas-surface.d.ts.map +1 -0
  11. package/dist/adapter/canvas-surface.js +392 -0
  12. package/dist/adapter/canvas-surface.js.map +1 -0
  13. package/dist/adapter/device.d.ts +76 -11
  14. package/dist/adapter/device.d.ts.map +1 -1
  15. package/dist/adapter/device.js +180 -9
  16. package/dist/adapter/device.js.map +1 -1
  17. package/dist/adapter/luma.js +1 -1
  18. package/dist/adapter/presentation-context.d.ts +11 -0
  19. package/dist/adapter/presentation-context.d.ts.map +1 -0
  20. package/dist/adapter/presentation-context.js +12 -0
  21. package/dist/adapter/presentation-context.js.map +1 -0
  22. package/dist/adapter/resources/buffer.d.ts +1 -1
  23. package/dist/adapter/resources/buffer.d.ts.map +1 -1
  24. package/dist/adapter/resources/buffer.js +14 -6
  25. package/dist/adapter/resources/buffer.js.map +1 -1
  26. package/dist/adapter/resources/command-buffer.d.ts +3 -1
  27. package/dist/adapter/resources/command-buffer.d.ts.map +1 -1
  28. package/dist/adapter/resources/command-buffer.js +3 -1
  29. package/dist/adapter/resources/command-buffer.js.map +1 -1
  30. package/dist/adapter/resources/command-encoder.d.ts +25 -2
  31. package/dist/adapter/resources/command-encoder.d.ts.map +1 -1
  32. package/dist/adapter/resources/command-encoder.js +68 -2
  33. package/dist/adapter/resources/command-encoder.js.map +1 -1
  34. package/dist/adapter/resources/compute-pipeline.d.ts +2 -2
  35. package/dist/adapter/resources/compute-pipeline.d.ts.map +1 -1
  36. package/dist/adapter/resources/fence.d.ts +1 -1
  37. package/dist/adapter/resources/fence.d.ts.map +1 -1
  38. package/dist/adapter/resources/fence.js +3 -1
  39. package/dist/adapter/resources/fence.js.map +1 -1
  40. package/dist/adapter/resources/framebuffer.d.ts +1 -1
  41. package/dist/adapter/resources/framebuffer.d.ts.map +1 -1
  42. package/dist/adapter/resources/query-set.d.ts +17 -1
  43. package/dist/adapter/resources/query-set.d.ts.map +1 -1
  44. package/dist/adapter/resources/query-set.js.map +1 -1
  45. package/dist/adapter/resources/render-pipeline.d.ts +28 -10
  46. package/dist/adapter/resources/render-pipeline.d.ts.map +1 -1
  47. package/dist/adapter/resources/render-pipeline.js +21 -2
  48. package/dist/adapter/resources/render-pipeline.js.map +1 -1
  49. package/dist/adapter/resources/resource.d.ts +8 -0
  50. package/dist/adapter/resources/resource.d.ts.map +1 -1
  51. package/dist/adapter/resources/resource.js +240 -14
  52. package/dist/adapter/resources/resource.js.map +1 -1
  53. package/dist/adapter/resources/shared-render-pipeline.d.ts +22 -0
  54. package/dist/adapter/resources/shared-render-pipeline.d.ts.map +1 -0
  55. package/dist/adapter/resources/shared-render-pipeline.js +25 -0
  56. package/dist/adapter/resources/shared-render-pipeline.js.map +1 -0
  57. package/dist/adapter/resources/texture-view.d.ts +1 -1
  58. package/dist/adapter/resources/texture-view.d.ts.map +1 -1
  59. package/dist/adapter/resources/texture.d.ts +82 -15
  60. package/dist/adapter/resources/texture.d.ts.map +1 -1
  61. package/dist/adapter/resources/texture.js +186 -33
  62. package/dist/adapter/resources/texture.js.map +1 -1
  63. package/dist/adapter/types/attachments.d.ts +1 -1
  64. package/dist/adapter/types/attachments.d.ts.map +1 -1
  65. package/dist/adapter/types/buffer-layout.d.ts +1 -1
  66. package/dist/adapter/types/buffer-layout.d.ts.map +1 -1
  67. package/dist/adapter/types/parameters.d.ts +3 -1
  68. package/dist/adapter/types/parameters.d.ts.map +1 -1
  69. package/dist/adapter/types/parameters.js +1 -0
  70. package/dist/adapter/types/parameters.js.map +1 -1
  71. package/dist/adapter/types/shader-layout.d.ts +10 -6
  72. package/dist/adapter/types/shader-layout.d.ts.map +1 -1
  73. package/dist/adapter/types/uniforms.d.ts +6 -0
  74. package/dist/adapter/types/uniforms.d.ts.map +1 -1
  75. package/dist/adapter-utils/bind-groups.d.ts +9 -0
  76. package/dist/adapter-utils/bind-groups.d.ts.map +1 -0
  77. package/dist/adapter-utils/bind-groups.js +41 -0
  78. package/dist/adapter-utils/bind-groups.js.map +1 -0
  79. package/dist/adapter-utils/get-attribute-from-layouts.d.ts +2 -2
  80. package/dist/adapter-utils/get-attribute-from-layouts.d.ts.map +1 -1
  81. package/dist/adapter-utils/get-attribute-from-layouts.js +6 -6
  82. package/dist/adapter-utils/get-attribute-from-layouts.js.map +1 -1
  83. package/dist/dist.dev.js +1934 -415
  84. package/dist/dist.min.js +6 -6
  85. package/dist/factories/bind-group-factory.d.ts +20 -0
  86. package/dist/factories/bind-group-factory.d.ts.map +1 -0
  87. package/dist/factories/bind-group-factory.js +79 -0
  88. package/dist/factories/bind-group-factory.js.map +1 -0
  89. package/dist/factories/core-module-state.d.ts +7 -0
  90. package/dist/factories/core-module-state.d.ts.map +1 -0
  91. package/dist/{shadertypes/data-types/shader-types.js → factories/core-module-state.js} +1 -1
  92. package/dist/factories/core-module-state.js.map +1 -0
  93. package/dist/factories/pipeline-factory.d.ts +54 -0
  94. package/dist/factories/pipeline-factory.d.ts.map +1 -0
  95. package/dist/factories/pipeline-factory.js +270 -0
  96. package/dist/factories/pipeline-factory.js.map +1 -0
  97. package/dist/factories/shader-factory.d.ts +20 -0
  98. package/dist/factories/shader-factory.d.ts.map +1 -0
  99. package/dist/factories/shader-factory.js +84 -0
  100. package/dist/factories/shader-factory.js.map +1 -0
  101. package/dist/index.cjs +1858 -409
  102. package/dist/index.cjs.map +4 -4
  103. package/dist/index.d.ts +25 -14
  104. package/dist/index.d.ts.map +1 -1
  105. package/dist/index.js +15 -9
  106. package/dist/index.js.map +1 -1
  107. package/dist/portable/uniform-block.d.ts +1 -1
  108. package/dist/portable/uniform-block.d.ts.map +1 -1
  109. package/dist/portable/uniform-buffer-layout.d.ts +20 -15
  110. package/dist/portable/uniform-buffer-layout.d.ts.map +1 -1
  111. package/dist/portable/uniform-buffer-layout.js +188 -43
  112. package/dist/portable/uniform-buffer-layout.js.map +1 -1
  113. package/dist/portable/uniform-store.d.ts +5 -6
  114. package/dist/portable/uniform-store.d.ts.map +1 -1
  115. package/dist/portable/uniform-store.js +6 -3
  116. package/dist/portable/uniform-store.js.map +1 -1
  117. package/dist/shadertypes/data-types/data-type-decoder.d.ts +20 -0
  118. package/dist/shadertypes/data-types/data-type-decoder.d.ts.map +1 -0
  119. package/dist/shadertypes/data-types/data-type-decoder.js +79 -0
  120. package/dist/shadertypes/data-types/data-type-decoder.js.map +1 -0
  121. package/dist/shadertypes/data-types/data-types.d.ts +31 -12
  122. package/dist/shadertypes/data-types/data-types.d.ts.map +1 -1
  123. package/dist/{image-utils → shadertypes/image-types}/image-types.d.ts +0 -6
  124. package/dist/shadertypes/image-types/image-types.d.ts.map +1 -0
  125. package/dist/shadertypes/image-types/image-types.js.map +1 -0
  126. package/dist/shadertypes/shader-types/shader-type-decoder.d.ts +41 -0
  127. package/dist/shadertypes/shader-types/shader-type-decoder.d.ts.map +1 -0
  128. package/dist/shadertypes/{data-types/decode-shader-types.js → shader-types/shader-type-decoder.js} +43 -4
  129. package/dist/shadertypes/shader-types/shader-type-decoder.js.map +1 -0
  130. package/dist/shadertypes/shader-types/shader-types.d.ts +101 -0
  131. package/dist/shadertypes/shader-types/shader-types.d.ts.map +1 -0
  132. package/dist/shadertypes/shader-types/shader-types.js +30 -0
  133. package/dist/shadertypes/shader-types/shader-types.js.map +1 -0
  134. package/dist/shadertypes/texture-types/pixel-utils.d.ts.map +1 -0
  135. package/dist/shadertypes/texture-types/pixel-utils.js.map +1 -0
  136. package/dist/shadertypes/{textures → texture-types}/texture-format-decoder.d.ts +1 -0
  137. package/dist/shadertypes/texture-types/texture-format-decoder.d.ts.map +1 -0
  138. package/dist/shadertypes/{textures → texture-types}/texture-format-decoder.js +55 -9
  139. package/dist/shadertypes/texture-types/texture-format-decoder.js.map +1 -0
  140. package/dist/shadertypes/texture-types/texture-format-generics.d.ts +34 -0
  141. package/dist/shadertypes/texture-types/texture-format-generics.d.ts.map +1 -0
  142. package/dist/shadertypes/texture-types/texture-format-generics.js.map +1 -0
  143. package/dist/shadertypes/texture-types/texture-format-table.d.ts.map +1 -0
  144. package/dist/shadertypes/{textures → texture-types}/texture-format-table.js +10 -9
  145. package/dist/shadertypes/texture-types/texture-format-table.js.map +1 -0
  146. package/dist/shadertypes/{textures → texture-types}/texture-formats.d.ts +10 -3
  147. package/dist/shadertypes/texture-types/texture-formats.d.ts.map +1 -0
  148. package/dist/shadertypes/{textures → texture-types}/texture-formats.js +1 -0
  149. package/dist/shadertypes/texture-types/texture-formats.js.map +1 -0
  150. package/dist/shadertypes/{textures → texture-types}/texture-layout.d.ts +1 -1
  151. package/dist/shadertypes/texture-types/texture-layout.d.ts.map +1 -0
  152. package/dist/shadertypes/texture-types/texture-layout.js.map +1 -0
  153. package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts +24 -0
  154. package/dist/shadertypes/vertex-types/vertex-format-decoder.d.ts.map +1 -0
  155. package/dist/shadertypes/vertex-types/vertex-format-decoder.js +106 -0
  156. package/dist/shadertypes/vertex-types/vertex-format-decoder.js.map +1 -0
  157. package/dist/shadertypes/vertex-types/vertex-formats.d.ts +50 -0
  158. package/dist/shadertypes/vertex-types/vertex-formats.d.ts.map +1 -0
  159. package/dist/shadertypes/vertex-types/vertex-formats.js.map +1 -0
  160. package/dist/utils/array-equal.d.ts +1 -1
  161. package/dist/utils/array-equal.d.ts.map +1 -1
  162. package/dist/utils/array-equal.js +15 -9
  163. package/dist/utils/array-equal.js.map +1 -1
  164. package/dist/utils/stats-manager.d.ts.map +1 -1
  165. package/dist/utils/stats-manager.js +61 -1
  166. package/dist/utils/stats-manager.js.map +1 -1
  167. package/package.json +3 -3
  168. package/src/adapter/canvas-context.ts +7 -623
  169. package/src/adapter/canvas-observer.ts +130 -0
  170. package/src/adapter/canvas-surface.ts +521 -0
  171. package/src/adapter/device.ts +287 -21
  172. package/src/adapter/presentation-context.ts +16 -0
  173. package/src/adapter/resources/buffer.ts +13 -5
  174. package/src/adapter/resources/command-buffer.ts +3 -1
  175. package/src/adapter/resources/command-encoder.ts +94 -3
  176. package/src/adapter/resources/compute-pipeline.ts +2 -2
  177. package/src/adapter/resources/fence.ts +3 -1
  178. package/src/adapter/resources/framebuffer.ts +1 -1
  179. package/src/adapter/resources/query-set.ts +17 -1
  180. package/src/adapter/resources/render-pipeline.ts +52 -16
  181. package/src/adapter/resources/resource.ts +284 -14
  182. package/src/adapter/resources/shared-render-pipeline.ts +40 -0
  183. package/src/adapter/resources/texture-view.ts +1 -1
  184. package/src/adapter/resources/texture.ts +273 -43
  185. package/src/adapter/types/attachments.ts +1 -1
  186. package/src/adapter/types/buffer-layout.ts +1 -1
  187. package/src/adapter/types/parameters.ts +4 -1
  188. package/src/adapter/types/shader-layout.ts +15 -9
  189. package/src/adapter/types/uniforms.ts +12 -0
  190. package/src/adapter-utils/bind-groups.ts +71 -0
  191. package/src/adapter-utils/get-attribute-from-layouts.ts +8 -11
  192. package/src/factories/bind-group-factory.ts +139 -0
  193. package/src/factories/core-module-state.ts +11 -0
  194. package/src/factories/pipeline-factory.ts +328 -0
  195. package/src/factories/shader-factory.ts +103 -0
  196. package/src/index.ts +54 -26
  197. package/src/portable/uniform-block.ts +1 -1
  198. package/src/portable/uniform-buffer-layout.ts +269 -62
  199. package/src/portable/uniform-store.ts +14 -11
  200. package/src/shadertypes/data-types/data-type-decoder.ts +105 -0
  201. package/src/shadertypes/data-types/data-types.ts +100 -48
  202. package/src/{image-utils → shadertypes/image-types}/image-types.ts +0 -7
  203. package/src/shadertypes/{data-types/decode-shader-types.ts → shader-types/shader-type-decoder.ts} +88 -14
  204. package/src/shadertypes/shader-types/shader-types.ts +207 -0
  205. package/src/shadertypes/{textures → texture-types}/texture-format-decoder.ts +75 -9
  206. package/src/shadertypes/{textures → texture-types}/texture-format-generics.ts +42 -48
  207. package/src/shadertypes/{textures → texture-types}/texture-format-table.ts +10 -9
  208. package/src/shadertypes/{textures → texture-types}/texture-formats.ts +20 -3
  209. package/src/shadertypes/vertex-types/vertex-format-decoder.ts +131 -0
  210. package/src/shadertypes/vertex-types/vertex-formats.ts +183 -0
  211. package/src/utils/array-equal.ts +21 -9
  212. package/src/utils/stats-manager.ts +76 -2
  213. package/dist/image-utils/image-types.d.ts.map +0 -1
  214. package/dist/image-utils/image-types.js.map +0 -1
  215. package/dist/shadertypes/data-types/decode-shader-types.d.ts +0 -17
  216. package/dist/shadertypes/data-types/decode-shader-types.d.ts.map +0 -1
  217. package/dist/shadertypes/data-types/decode-shader-types.js.map +0 -1
  218. package/dist/shadertypes/data-types/shader-types.d.ts +0 -43
  219. package/dist/shadertypes/data-types/shader-types.d.ts.map +0 -1
  220. package/dist/shadertypes/data-types/shader-types.js.map +0 -1
  221. package/dist/shadertypes/textures/pixel-utils.d.ts.map +0 -1
  222. package/dist/shadertypes/textures/pixel-utils.js.map +0 -1
  223. package/dist/shadertypes/textures/texture-format-decoder.d.ts.map +0 -1
  224. package/dist/shadertypes/textures/texture-format-decoder.js.map +0 -1
  225. package/dist/shadertypes/textures/texture-format-generics.d.ts +0 -33
  226. package/dist/shadertypes/textures/texture-format-generics.d.ts.map +0 -1
  227. package/dist/shadertypes/textures/texture-format-generics.js.map +0 -1
  228. package/dist/shadertypes/textures/texture-format-table.d.ts.map +0 -1
  229. package/dist/shadertypes/textures/texture-format-table.js.map +0 -1
  230. package/dist/shadertypes/textures/texture-formats.d.ts.map +0 -1
  231. package/dist/shadertypes/textures/texture-formats.js.map +0 -1
  232. package/dist/shadertypes/textures/texture-layout.d.ts.map +0 -1
  233. package/dist/shadertypes/textures/texture-layout.js.map +0 -1
  234. package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts +0 -18
  235. package/dist/shadertypes/vertex-arrays/decode-vertex-format.d.ts.map +0 -1
  236. package/dist/shadertypes/vertex-arrays/decode-vertex-format.js +0 -100
  237. package/dist/shadertypes/vertex-arrays/decode-vertex-format.js.map +0 -1
  238. package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts +0 -27
  239. package/dist/shadertypes/vertex-arrays/vertex-formats.d.ts.map +0 -1
  240. package/dist/shadertypes/vertex-arrays/vertex-formats.js.map +0 -1
  241. package/src/shadertypes/data-types/shader-types.ts +0 -94
  242. package/src/shadertypes/vertex-arrays/decode-vertex-format.ts +0 -124
  243. package/src/shadertypes/vertex-arrays/vertex-formats.ts +0 -91
  244. /package/dist/{image-utils → shadertypes/image-types}/image-types.js +0 -0
  245. /package/dist/shadertypes/{textures → texture-types}/pixel-utils.d.ts +0 -0
  246. /package/dist/shadertypes/{textures → texture-types}/pixel-utils.js +0 -0
  247. /package/dist/shadertypes/{textures → texture-types}/texture-format-generics.js +0 -0
  248. /package/dist/shadertypes/{textures → texture-types}/texture-format-table.d.ts +0 -0
  249. /package/dist/shadertypes/{textures → texture-types}/texture-layout.js +0 -0
  250. /package/dist/shadertypes/{vertex-arrays → vertex-types}/vertex-formats.js +0 -0
  251. /package/src/shadertypes/{textures → texture-types}/pixel-utils.ts +0 -0
  252. /package/src/shadertypes/{textures → texture-types}/texture-layout.ts +0 -0
@@ -1,488 +1,12 @@
1
1
  // luma.gl
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
- import { isBrowser } from '@probe.gl/env';
5
- import { uid } from "../utils/uid.js";
6
- import { withResolvers } from "../utils/promise-utils.js";
7
- import { assertDefined } from "../utils/assert.js";
4
+ import { CanvasSurface } from "./canvas-surface.js";
8
5
  /**
9
- * Manages a canvas. Supports both HTML or offscreen canvas
10
- * - Creates a new canvas or looks up a canvas from the DOM
11
- * - Provides check for DOM loaded
12
- * @todo commit() @see https://github.com/w3ctag/design-reviews/issues/288
13
- * @todo transferControlToOffscreen: @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/transferControlToOffscreen
6
+ * Manages a renderable backend canvas. Supports both HTML or offscreen canvas
7
+ * and returns backend framebuffers sourced from the canvas itself.
14
8
  */
15
- export class CanvasContext {
16
- static isHTMLCanvas(canvas) {
17
- return typeof HTMLCanvasElement !== 'undefined' && canvas instanceof HTMLCanvasElement;
18
- }
19
- static isOffscreenCanvas(canvas) {
20
- return typeof OffscreenCanvas !== 'undefined' && canvas instanceof OffscreenCanvas;
21
- }
22
- static defaultProps = {
23
- id: undefined,
24
- canvas: null,
25
- width: 800,
26
- height: 600,
27
- useDevicePixels: true,
28
- autoResize: true,
29
- container: null,
30
- visible: true,
31
- alphaMode: 'opaque',
32
- colorSpace: 'srgb',
33
- trackPosition: false
34
- };
35
- id;
36
- props;
37
- canvas;
38
- /** Handle to HTML canvas */
39
- htmlCanvas;
40
- /** Handle to wrapped OffScreenCanvas */
41
- offscreenCanvas;
42
- type;
43
- /** Promise that resolved once the resize observer has updated the pixel size */
44
- initialized;
45
- isInitialized = false;
46
- /** Visibility is automatically updated (via an IntersectionObserver) */
47
- isVisible = true;
48
- /** Width of canvas in CSS units (tracked by a ResizeObserver) */
49
- cssWidth;
50
- /** Height of canvas in CSS units (tracked by a ResizeObserver) */
51
- cssHeight;
52
- /** Device pixel ratio. Automatically updated via media queries */
53
- devicePixelRatio;
54
- /** Exact width of canvas in physical pixels (tracked by a ResizeObserver) */
55
- devicePixelWidth;
56
- /** Exact height of canvas in physical pixels (tracked by a ResizeObserver) */
57
- devicePixelHeight;
58
- /** Width of drawing buffer: automatically tracks this.pixelWidth if props.autoResize is true */
59
- drawingBufferWidth;
60
- /** Height of drawing buffer: automatically tracks this.pixelHeight if props.autoResize is true */
61
- drawingBufferHeight;
62
- /** Resolves when the canvas is initialized, i.e. when the ResizeObserver has updated the pixel size */
63
- _initializedResolvers = withResolvers();
64
- /** ResizeObserver to track canvas size changes */
65
- _resizeObserver;
66
- /** IntersectionObserver to track canvas visibility changes */
67
- _intersectionObserver;
68
- _observeDevicePixelRatioTimeout = null;
69
- /** Position of the canvas in the document, updated by a timer */
70
- _position = [0, 0];
71
- /** Whether this canvas context has been destroyed */
72
- destroyed = false;
73
- /** Whether the drawing buffer size needs to be resized (deferred resizing to avoid flicker) */
74
- _needsDrawingBufferResize = true;
75
- toString() {
76
- return `${this[Symbol.toStringTag]}(${this.id})`;
77
- }
78
- constructor(props) {
79
- this.props = { ...CanvasContext.defaultProps, ...props };
80
- props = this.props;
81
- this.initialized = this._initializedResolvers.promise;
82
- // Create a canvas element if needed
83
- if (!isBrowser()) {
84
- // TODO - does this prevent app from using jsdom style polyfills?
85
- this.canvas = { width: props.width || 1, height: props.height || 1 };
86
- }
87
- else if (!props.canvas) {
88
- this.canvas = createCanvasElement(props);
89
- }
90
- else if (typeof props.canvas === 'string') {
91
- this.canvas = getCanvasFromDOM(props.canvas);
92
- }
93
- else {
94
- this.canvas = props.canvas;
95
- }
96
- if (CanvasContext.isHTMLCanvas(this.canvas)) {
97
- this.id = props.id || this.canvas.id;
98
- this.type = 'html-canvas';
99
- this.htmlCanvas = this.canvas;
100
- }
101
- else if (CanvasContext.isOffscreenCanvas(this.canvas)) {
102
- this.id = props.id || 'offscreen-canvas';
103
- this.type = 'offscreen-canvas';
104
- this.offscreenCanvas = this.canvas;
105
- }
106
- else {
107
- // TODO - Node.js support is currently untested (was used for headless-gl in luma v8)
108
- this.id = props.id || 'node-canvas-context';
109
- this.type = 'node';
110
- }
111
- // Initialize size variables to some sane values (these will be updated by ResizeObserver)
112
- this.cssWidth = this.htmlCanvas?.clientWidth || this.canvas.width;
113
- this.cssHeight = this.htmlCanvas?.clientHeight || this.canvas.height;
114
- this.devicePixelWidth = this.canvas.width;
115
- this.devicePixelHeight = this.canvas.height;
116
- this.drawingBufferWidth = this.canvas.width;
117
- this.drawingBufferHeight = this.canvas.height;
118
- this.devicePixelRatio = globalThis.devicePixelRatio || 1;
119
- this._position = [0, 0];
120
- if (CanvasContext.isHTMLCanvas(this.canvas)) {
121
- // Track visibility changes
122
- this._intersectionObserver = new IntersectionObserver(entries => this._handleIntersection(entries));
123
- this._intersectionObserver.observe(this.canvas);
124
- // Track size changes
125
- this._resizeObserver = new ResizeObserver(entries => this._handleResize(entries));
126
- try {
127
- this._resizeObserver.observe(this.canvas, { box: 'device-pixel-content-box' });
128
- }
129
- catch {
130
- // Safari fallback
131
- this._resizeObserver.observe(this.canvas, { box: 'content-box' });
132
- }
133
- // Track device pixel ratio changes.
134
- // Defer call to after construction completes to ensure `this.device` is available.
135
- this._observeDevicePixelRatioTimeout = setTimeout(() => this._observeDevicePixelRatio(), 0);
136
- // Track top/left position changes
137
- if (this.props.trackPosition) {
138
- this._trackPosition();
139
- }
140
- }
141
- }
142
- destroy() {
143
- if (!this.destroyed) {
144
- this.destroyed = true;
145
- if (this._observeDevicePixelRatioTimeout) {
146
- clearTimeout(this._observeDevicePixelRatioTimeout);
147
- this._observeDevicePixelRatioTimeout = null;
148
- }
149
- // @ts-expect-error Clear the device to make sure we don't access it after destruction.
150
- this.device = null;
151
- // Disconnect observers to prevent callbacks from firing after destruction
152
- this._resizeObserver?.disconnect();
153
- this._intersectionObserver?.disconnect();
154
- }
155
- }
156
- setProps(props) {
157
- if ('useDevicePixels' in props) {
158
- this.props.useDevicePixels = props.useDevicePixels || false;
159
- this._updateDrawingBufferSize();
160
- }
161
- return this;
162
- }
163
- /** Returns a framebuffer with properly resized current 'swap chain' textures */
164
- getCurrentFramebuffer(options) {
165
- this._resizeDrawingBufferIfNeeded();
166
- return this._getCurrentFramebuffer(options);
167
- }
168
- // SIZE METHODS
169
- /**
170
- * Returns the size covered by the canvas in CSS pixels
171
- * @note This can be different from the actual device pixel size of a canvas due to DPR scaling, and rounding to integer pixels
172
- * @note This is independent of the canvas' internal drawing buffer size (.width, .height).
173
- */
174
- getCSSSize() {
175
- return [this.cssWidth, this.cssHeight];
176
- }
177
- getPosition() {
178
- return this._position;
179
- }
180
- /**
181
- * Returns the size covered by the canvas in actual device pixels.
182
- * @note This can be different from the 'CSS' size of a canvas due to DPR scaling, and rounding to integer pixels
183
- * @note This is independent of the canvas' internal drawing buffer size (.width, .height).
184
- */
185
- getDevicePixelSize() {
186
- return [this.devicePixelWidth, this.devicePixelHeight];
187
- }
188
- /** Get the drawing buffer size (number of pixels GPU is rendering into, can be different from CSS size) */
189
- getDrawingBufferSize() {
190
- return [this.drawingBufferWidth, this.drawingBufferHeight];
191
- }
192
- /** Returns the biggest allowed framebuffer size. @todo Allow the application to limit this? */
193
- getMaxDrawingBufferSize() {
194
- const maxTextureDimension = this.device.limits.maxTextureDimension2D;
195
- return [maxTextureDimension, maxTextureDimension];
196
- }
197
- /**
198
- * Update the canvas drawing buffer size.
199
- * @note - Called automatically if props.autoResize is true.
200
- * @note - Defers update of drawing buffer size until framebuffer is requested to avoid flicker
201
- * (resizing clears the drawing buffer)!
202
- */
203
- setDrawingBufferSize(width, height) {
204
- width = Math.floor(width);
205
- height = Math.floor(height);
206
- if (this.drawingBufferWidth === width && this.drawingBufferHeight === height) {
207
- return;
208
- }
209
- // TODO(ib) - temporarily makes drawingBufferWidth/Height out of sync with canvas.width/height, could that cause issues?
210
- this.drawingBufferWidth = width;
211
- this.drawingBufferHeight = height;
212
- this._needsDrawingBufferResize = true;
213
- }
214
- /**
215
- * Returns the current DPR (number of physical pixels per CSS pixel), if props.useDevicePixels is true
216
- * @note This can be a fractional (non-integer) number, e.g. when the user zooms in the browser.
217
- * @note This function handles the non-HTML canvas cases
218
- */
219
- getDevicePixelRatio() {
220
- const dpr = typeof window !== 'undefined' && window.devicePixelRatio;
221
- return dpr || 1;
222
- }
223
- // DEPRECATED METHODS
224
- /**
225
- * Maps CSS pixel position to device pixel position
226
- */
227
- cssToDevicePixels(cssPixel, yInvert = true) {
228
- const ratio = this.cssToDeviceRatio();
229
- const [width, height] = this.getDrawingBufferSize();
230
- return scalePixels(cssPixel, ratio, width, height, yInvert);
231
- }
232
- /** @deprecated - use .getDevicePixelSize() */
233
- getPixelSize() {
234
- return this.getDevicePixelSize();
235
- }
236
- /** @deprecated - TODO which values should we use for aspect */
237
- getAspect() {
238
- const [width, height] = this.getDevicePixelSize();
239
- return width / height;
240
- }
241
- /** @deprecated Returns multiplier need to convert CSS size to Device size */
242
- cssToDeviceRatio() {
243
- try {
244
- const [drawingBufferWidth] = this.getDrawingBufferSize();
245
- const [cssWidth] = this.getCSSSize();
246
- return cssWidth ? drawingBufferWidth / cssWidth : 1;
247
- }
248
- catch {
249
- return 1;
250
- }
251
- }
252
- /** @deprecated Use canvasContext.setDrawingBufferSize() */
253
- resize(size) {
254
- this.setDrawingBufferSize(size.width, size.height);
255
- }
256
- // IMPLEMENTATION
257
- /**
258
- * Allows subclass constructor to override the canvas id for auto created canvases.
259
- * This can really help when debugging DOM in apps that create multiple devices
260
- */
261
- _setAutoCreatedCanvasId(id) {
262
- if (this.htmlCanvas?.id === 'lumagl-auto-created-canvas') {
263
- this.htmlCanvas.id = id;
264
- }
265
- }
266
- /** reacts to an observed intersection */
267
- _handleIntersection(entries) {
268
- if (this.destroyed) {
269
- return;
270
- }
271
- const entry = entries.find(entry_ => entry_.target === this.canvas);
272
- if (!entry) {
273
- return;
274
- }
275
- // TODO - store intersection rectangle?
276
- const isVisible = entry.isIntersecting;
277
- if (this.isVisible !== isVisible) {
278
- this.isVisible = isVisible;
279
- this.device.props.onVisibilityChange(this);
280
- }
281
- }
282
- /**
283
- * Reacts to an observed resize by using the most accurate pixel size information the browser can provide
284
- * @see https://web.dev/articles/device-pixel-content-box
285
- * @see https://webgpufundamentals.org/webgpu/lessons/webgpu-resizing-the-canvas.html
286
- */
287
- _handleResize(entries) {
288
- if (this.destroyed) {
289
- return;
290
- }
291
- const entry = entries.find(entry_ => entry_.target === this.canvas);
292
- if (!entry) {
293
- return;
294
- }
295
- const contentBoxSize = assertDefined(entry.contentBoxSize?.[0]);
296
- // Update CSS size using content box size
297
- this.cssWidth = contentBoxSize.inlineSize;
298
- this.cssHeight = contentBoxSize.blockSize;
299
- // Update our drawing buffer size variables, saving the old values for logging
300
- const oldPixelSize = this.getDevicePixelSize();
301
- // Use the most accurate drawing buffer size information the current browser can provide
302
- // Note: content box sizes are guaranteed to be integers
303
- // Note: Safari falls back to contentBoxSize
304
- const devicePixelWidth = entry.devicePixelContentBoxSize?.[0]?.inlineSize ||
305
- contentBoxSize.inlineSize * devicePixelRatio;
306
- const devicePixelHeight = entry.devicePixelContentBoxSize?.[0]?.blockSize ||
307
- contentBoxSize.blockSize * devicePixelRatio;
308
- // Make sure we don't overflow the maximum supported texture size
309
- const [maxDevicePixelWidth, maxDevicePixelHeight] = this.getMaxDrawingBufferSize();
310
- this.devicePixelWidth = Math.max(1, Math.min(devicePixelWidth, maxDevicePixelWidth));
311
- this.devicePixelHeight = Math.max(1, Math.min(devicePixelHeight, maxDevicePixelHeight));
312
- this._updateDrawingBufferSize();
313
- // Inform the device
314
- this.device.props.onResize(this, { oldPixelSize });
315
- }
316
- /** Initiate a deferred update for the canvas drawing buffer size */
317
- _updateDrawingBufferSize() {
318
- // Update the canvas drawing buffer size
319
- if (this.props.autoResize) {
320
- if (typeof this.props.useDevicePixels === 'number') {
321
- const dpr = this.props.useDevicePixels;
322
- this.setDrawingBufferSize(this.cssWidth * dpr, this.cssHeight * dpr);
323
- }
324
- else if (this.props.useDevicePixels) {
325
- this.setDrawingBufferSize(this.devicePixelWidth, this.devicePixelHeight);
326
- }
327
- else {
328
- this.setDrawingBufferSize(this.cssWidth, this.cssHeight);
329
- }
330
- }
331
- // Resolve the initialized promise
332
- this._initializedResolvers.resolve();
333
- this.isInitialized = true;
334
- this.updatePosition();
335
- }
336
- /** Perform a deferred resize of the drawing buffer if needed */
337
- _resizeDrawingBufferIfNeeded() {
338
- if (this._needsDrawingBufferResize) {
339
- this._needsDrawingBufferResize = false;
340
- const sizeChanged = this.drawingBufferWidth !== this.canvas.width ||
341
- this.drawingBufferHeight !== this.canvas.height;
342
- if (sizeChanged) {
343
- // Update the canvas size
344
- this.canvas.width = this.drawingBufferWidth;
345
- this.canvas.height = this.drawingBufferHeight;
346
- // Inform the subclass: WebGPU needs to call canvascontext.configure()
347
- this._configureDevice();
348
- }
349
- }
350
- }
351
- /** Monitor DPR changes */
352
- _observeDevicePixelRatio() {
353
- if (this.destroyed) {
354
- return;
355
- }
356
- const oldRatio = this.devicePixelRatio;
357
- this.devicePixelRatio = window.devicePixelRatio;
358
- this.updatePosition();
359
- // Inform the device
360
- this.device.props.onDevicePixelRatioChange?.(this, { oldRatio });
361
- // Set up a one time query against the current resolution.
362
- matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener('change', () => this._observeDevicePixelRatio(), { once: true });
363
- }
364
- /** Start tracking positions with a timer */
365
- _trackPosition(intervalMs = 100) {
366
- const intervalId = setInterval(() => {
367
- if (this.destroyed) {
368
- clearInterval(intervalId);
369
- }
370
- else {
371
- this.updatePosition();
372
- }
373
- }, intervalMs);
374
- }
375
- /**
376
- * Calculated the absolute position of the canvas
377
- * @note - getBoundingClientRect() is normally cheap but can be expensive
378
- * if called before browser has finished a reflow. Should not be the case here.
379
- */
380
- updatePosition() {
381
- if (this.destroyed) {
382
- return;
383
- }
384
- const newRect = this.htmlCanvas?.getBoundingClientRect();
385
- if (newRect) {
386
- // We only track position since we rely on the more precise ResizeObserver for size
387
- const position = [newRect.left, newRect.top];
388
- this._position ??= position;
389
- const positionChanged = position[0] !== this._position[0] || position[1] !== this._position[1];
390
- if (positionChanged) {
391
- const oldPosition = this._position;
392
- this._position = position;
393
- this.device.props.onPositionChange?.(this, { oldPosition });
394
- }
395
- }
396
- }
397
- }
398
- // HELPER FUNCTIONS
399
- /** Get a container element from a string or DOM element */
400
- function getContainer(container) {
401
- if (typeof container === 'string') {
402
- const element = document.getElementById(container);
403
- if (!element) {
404
- throw new Error(`${container} is not an HTML element`);
405
- }
406
- return element;
407
- }
408
- if (container) {
409
- return container;
410
- }
411
- return document.body;
412
- }
413
- /** Get a Canvas element from DOM id */
414
- function getCanvasFromDOM(canvasId) {
415
- const canvas = document.getElementById(canvasId);
416
- if (!CanvasContext.isHTMLCanvas(canvas)) {
417
- throw new Error('Object is not a canvas element');
418
- }
419
- return canvas;
420
- }
421
- /** Create a new canvas */
422
- function createCanvasElement(props) {
423
- const { width, height } = props;
424
- const newCanvas = document.createElement('canvas');
425
- newCanvas.id = uid('lumagl-auto-created-canvas');
426
- newCanvas.width = width || 1;
427
- newCanvas.height = height || 1;
428
- newCanvas.style.width = Number.isFinite(width) ? `${width}px` : '100%';
429
- newCanvas.style.height = Number.isFinite(height) ? `${height}px` : '100%';
430
- if (!props?.visible) {
431
- newCanvas.style.visibility = 'hidden';
432
- }
433
- // Insert the canvas in the DOM
434
- const container = getContainer(props?.container || null);
435
- container.insertBefore(newCanvas, container.firstChild);
436
- return newCanvas;
437
- }
438
- /**
439
- * Scales pixels linearly, handles edge cases
440
- * @param pixel
441
- * @param ratio
442
- * @param width
443
- * @param height
444
- * @param yInvert
445
- * @returns
446
- */
447
- function scalePixels(pixel, ratio, width, height, yInvert) {
448
- const point = pixel;
449
- const x = scaleX(point[0], ratio, width);
450
- let y = scaleY(point[1], ratio, height, yInvert);
451
- // Find boundaries of next pixel to provide valid range of device pixel locations
452
- let t = scaleX(point[0] + 1, ratio, width);
453
- // If next pixel's position is clamped to boundary, use it as is, otherwise subtract 1 for current pixel boundary
454
- const xHigh = t === width - 1 ? t : t - 1;
455
- t = scaleY(point[1] + 1, ratio, height, yInvert);
456
- let yHigh;
457
- if (yInvert) {
458
- // If next pixel's position is clamped to boundary, use it as is, otherwise clamp it to valid range
459
- t = t === 0 ? t : t + 1;
460
- // swap y and yHigh
461
- yHigh = y;
462
- y = t;
463
- }
464
- else {
465
- // If next pixel's position is clamped to boundary, use it as is, otherwise clamp it to valid range
466
- yHigh = t === height - 1 ? t : t - 1;
467
- // y remains same
468
- }
469
- return {
470
- x,
471
- y,
472
- // when ratio < 1, current css pixel and next css pixel may point to same device pixel, set width/height to 1 in those cases.
473
- width: Math.max(xHigh - x + 1, 1),
474
- height: Math.max(yHigh - y + 1, 1)
475
- };
476
- }
477
- function scaleX(x, ratio, width) {
478
- // since we are rounding to nearest, when ratio > 1, edge pixels may point to out of bounds value, clamp to the limit
479
- const r = Math.min(Math.round(x * ratio), width - 1);
480
- return r;
481
- }
482
- function scaleY(y, ratio, height, yInvert) {
483
- // since we are rounding to nearest, when ratio > 1, edge pixels may point to out of bounds value, clamp to the limit
484
- return yInvert
485
- ? Math.max(0, height - 1 - Math.round(y * ratio))
486
- : Math.min(Math.round(y * ratio), height - 1);
9
+ export class CanvasContext extends CanvasSurface {
10
+ static defaultProps = CanvasSurface.defaultProps;
487
11
  }
488
12
  //# sourceMappingURL=canvas-context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"canvas-context.js","sourceRoot":"","sources":["../../src/adapter/canvas-context.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,SAAS,EAAC,MAAM,eAAe,CAAC;AAIxC,OAAO,EAAC,GAAG,EAAC,wBAAqB;AACjC,OAAO,EAAC,aAAa,EAAC,kCAA+B;AACrD,OAAO,EAAC,aAAa,EAAC,2BAAwB;AAiC9C;;;;;;GAMG;AACH,MAAM,OAAgB,aAAa;IACjC,MAAM,CAAC,YAAY,CAAC,MAAe;QACjC,OAAO,OAAO,iBAAiB,KAAK,WAAW,IAAI,MAAM,YAAY,iBAAiB,CAAC;IACzF,CAAC;IAED,MAAM,CAAC,iBAAiB,CAAC,MAAe;QACtC,OAAO,OAAO,eAAe,KAAK,WAAW,IAAI,MAAM,YAAY,eAAe,CAAC;IACrF,CAAC;IAED,MAAM,CAAC,YAAY,GAAiC;QAClD,EAAE,EAAE,SA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CAAC,CAAC,GAAG,KAAK,CAAC,CAAC;QACjD,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC"}
1
+ {"version":3,"file":"canvas-context.js","sourceRoot":"","sources":["../../src/adapter/canvas-context.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,aAAa,EAAC,4BAAyB;AAE/C;;;GAGG;AACH,MAAM,OAAgB,aAAc,SAAQ,aAAa;IACvD,MAAM,CAAU,YAAY,GAAG,aAAa,CAAC,YAAY,CAAC"}
@@ -0,0 +1,32 @@
1
+ type CanvasObserverProps = {
2
+ canvas?: HTMLCanvasElement;
3
+ trackPosition: boolean;
4
+ onResize: (entries: ResizeObserverEntry[]) => void;
5
+ onIntersection: (entries: IntersectionObserverEntry[]) => void;
6
+ onDevicePixelRatioChange: () => void;
7
+ onPositionChange: () => void;
8
+ };
9
+ /**
10
+ * Internal DOM observer orchestration for HTML canvas surfaces.
11
+ *
12
+ * CanvasSurface owns the tracked state and device callback dispatch. This helper only manages
13
+ * browser observers, timers, and polling loops, then reports events through callbacks.
14
+ */
15
+ export declare class CanvasObserver {
16
+ readonly props: CanvasObserverProps;
17
+ private _resizeObserver;
18
+ private _intersectionObserver;
19
+ private _observeDevicePixelRatioTimeout;
20
+ private _observeDevicePixelRatioMediaQuery;
21
+ private readonly _handleDevicePixelRatioChange;
22
+ private _trackPositionInterval;
23
+ private _started;
24
+ get started(): boolean;
25
+ constructor(props: CanvasObserverProps);
26
+ start(): void;
27
+ stop(): void;
28
+ private _refreshDevicePixelRatio;
29
+ private _trackPosition;
30
+ }
31
+ export {};
32
+ //# sourceMappingURL=canvas-observer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas-observer.d.ts","sourceRoot":"","sources":["../../src/adapter/canvas-observer.ts"],"names":[],"mappings":"AAIA,KAAK,mBAAmB,GAAG;IACzB,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,CAAC,OAAO,EAAE,mBAAmB,EAAE,KAAK,IAAI,CAAC;IACnD,cAAc,EAAE,CAAC,OAAO,EAAE,yBAAyB,EAAE,KAAK,IAAI,CAAC;IAC/D,wBAAwB,EAAE,MAAM,IAAI,CAAC;IACrC,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B,CAAC;AAEF;;;;;GAKG;AACH,qBAAa,cAAc;IACzB,QAAQ,CAAC,KAAK,EAAE,mBAAmB,CAAC;IAEpC,OAAO,CAAC,eAAe,CAA6B;IACpD,OAAO,CAAC,qBAAqB,CAAmC;IAChE,OAAO,CAAC,+BAA+B,CAA8C;IACrF,OAAO,CAAC,kCAAkC,CAA+B;IACzE,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAAyC;IACvF,OAAO,CAAC,sBAAsB,CAA+C;IAC7E,OAAO,CAAC,QAAQ,CAAS;IAEzB,IAAI,OAAO,IAAI,OAAO,CAErB;gBAEW,KAAK,EAAE,mBAAmB;IAItC,KAAK,IAAI,IAAI;IAyBb,IAAI,IAAI,IAAI;IA6BZ,OAAO,CAAC,wBAAwB;IAqBhC,OAAO,CAAC,cAAc;CAgBvB"}
@@ -0,0 +1,90 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ /**
5
+ * Internal DOM observer orchestration for HTML canvas surfaces.
6
+ *
7
+ * CanvasSurface owns the tracked state and device callback dispatch. This helper only manages
8
+ * browser observers, timers, and polling loops, then reports events through callbacks.
9
+ */
10
+ export class CanvasObserver {
11
+ props;
12
+ _resizeObserver;
13
+ _intersectionObserver;
14
+ _observeDevicePixelRatioTimeout = null;
15
+ _observeDevicePixelRatioMediaQuery = null;
16
+ _handleDevicePixelRatioChange = () => this._refreshDevicePixelRatio();
17
+ _trackPositionInterval = null;
18
+ _started = false;
19
+ get started() {
20
+ return this._started;
21
+ }
22
+ constructor(props) {
23
+ this.props = props;
24
+ }
25
+ start() {
26
+ if (this._started || !this.props.canvas) {
27
+ return;
28
+ }
29
+ this._started = true;
30
+ this._intersectionObserver ||= new IntersectionObserver(entries => this.props.onIntersection(entries));
31
+ this._resizeObserver ||= new ResizeObserver(entries => this.props.onResize(entries));
32
+ this._intersectionObserver.observe(this.props.canvas);
33
+ try {
34
+ this._resizeObserver.observe(this.props.canvas, { box: 'device-pixel-content-box' });
35
+ }
36
+ catch {
37
+ this._resizeObserver.observe(this.props.canvas, { box: 'content-box' });
38
+ }
39
+ this._observeDevicePixelRatioTimeout = setTimeout(() => this._refreshDevicePixelRatio(), 0);
40
+ if (this.props.trackPosition) {
41
+ this._trackPosition();
42
+ }
43
+ }
44
+ stop() {
45
+ if (!this._started) {
46
+ return;
47
+ }
48
+ this._started = false;
49
+ if (this._observeDevicePixelRatioTimeout) {
50
+ clearTimeout(this._observeDevicePixelRatioTimeout);
51
+ this._observeDevicePixelRatioTimeout = null;
52
+ }
53
+ if (this._observeDevicePixelRatioMediaQuery) {
54
+ this._observeDevicePixelRatioMediaQuery.removeEventListener('change', this._handleDevicePixelRatioChange);
55
+ this._observeDevicePixelRatioMediaQuery = null;
56
+ }
57
+ if (this._trackPositionInterval) {
58
+ clearInterval(this._trackPositionInterval);
59
+ this._trackPositionInterval = null;
60
+ }
61
+ this._resizeObserver?.disconnect();
62
+ this._intersectionObserver?.disconnect();
63
+ }
64
+ _refreshDevicePixelRatio() {
65
+ if (!this._started) {
66
+ return;
67
+ }
68
+ this.props.onDevicePixelRatioChange();
69
+ this._observeDevicePixelRatioMediaQuery?.removeEventListener('change', this._handleDevicePixelRatioChange);
70
+ this._observeDevicePixelRatioMediaQuery = matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
71
+ this._observeDevicePixelRatioMediaQuery.addEventListener('change', this._handleDevicePixelRatioChange, { once: true });
72
+ }
73
+ _trackPosition(intervalMs = 100) {
74
+ if (this._trackPositionInterval) {
75
+ return;
76
+ }
77
+ this._trackPositionInterval = setInterval(() => {
78
+ if (!this._started) {
79
+ if (this._trackPositionInterval) {
80
+ clearInterval(this._trackPositionInterval);
81
+ this._trackPositionInterval = null;
82
+ }
83
+ }
84
+ else {
85
+ this.props.onPositionChange();
86
+ }
87
+ }, intervalMs);
88
+ }
89
+ }
90
+ //# sourceMappingURL=canvas-observer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canvas-observer.js","sourceRoot":"","sources":["../../src/adapter/canvas-observer.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,oCAAoC;AAWpC;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAChB,KAAK,CAAsB;IAE5B,eAAe,CAA6B;IAC5C,qBAAqB,CAAmC;IACxD,+BAA+B,GAAyC,IAAI,CAAC;IAC7E,kCAAkC,GAA0B,IAAI,CAAC;IACxD,6BAA6B,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,wBAAwB,EAAE,CAAC;IAC/E,sBAAsB,GAA0C,IAAI,CAAC;IACrE,QAAQ,GAAG,KAAK,CAAC;IAEzB,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,YAAY,KAA0B;QACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACxC,OAAO;QACT,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,qBAAqB,KAAK,IAAI,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAChE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CACnC,CAAC;QACF,IAAI,CAAC,eAAe,KAAK,IAAI,cAAc,CAAC,OAAO,C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