laymur 0.13.7 → 0.14.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.
@@ -1,4 +1,4 @@
1
- import type { Vector2Like } from "three";
1
+ import type { Vector2Like } from "../math";
2
2
  import { UIArea } from "./UIArea";
3
3
  /** Polygonal interaction area using ray casting */
4
4
  export declare class UIAreaPolygon extends UIArea {
@@ -1,5 +1,4 @@
1
1
  import { UILayer } from "../layers/UILayer/UILayer";
2
- export declare const EPSILON = 0.000001;
3
2
  /**
4
3
  * Validates value is finite number within safe range.
5
4
  * @param value Number to validate
@@ -1,13 +1,31 @@
1
+ import { CanvasTexture } from "three";
1
2
  /** Canvas type that works both in main thread and workers */
2
- export type UICanvas = OffscreenCanvas | HTMLCanvasElement;
3
+ export type UICanvas = HTMLCanvasElement | OffscreenCanvas;
3
4
  /** 2D rendering context type for UICanvas */
4
- export type UICanvasRenderingContext2D = OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D;
5
+ export type UICanvasRenderingContext2D = CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
5
6
  /**
6
- * Creates a canvas with OffscreenCanvas fallback to HTMLCanvasElement.
7
- * Uses OffscreenCanvas when available, falls back to HTMLCanvasElement otherwise.
7
+ * Creates a canvas using OffscreenCanvas if available, otherwise falls back to HTMLCanvasElement.
8
8
  *
9
9
  * @param width - Canvas width in pixels
10
10
  * @param height - Canvas height in pixels
11
11
  * @returns Canvas instance
12
12
  */
13
13
  export declare function createCanvas(width: number, height: number): UICanvas;
14
+ /**
15
+ * Gets the 2D rendering context for a UICanvas.
16
+ *
17
+ * @param canvas - Canvas instance
18
+ * @returns 2D rendering context or null
19
+ */
20
+ export declare function getCanvas2DContext(canvas: UICanvas): UICanvasRenderingContext2D | null;
21
+ /**
22
+ * Creates a CanvasTexture with maximum WebGL1/WebGL2 compatibility.
23
+ * - ClampToEdge wrapping (required for NPOT in WebGL1)
24
+ * - Linear filtering without mipmaps (NPOT-safe)
25
+ * - RGBA/UnsignedByte format (no extensions needed)
26
+ * - sRGB colorspace only if supported
27
+ *
28
+ * @param canvas - Source canvas
29
+ * @returns Configured CanvasTexture
30
+ */
31
+ export declare function createCanvasTexture(canvas: UICanvas): CanvasTexture;
@@ -1,6 +1,6 @@
1
- import type { Vector2Like } from "three";
2
1
  import { Vector2 } from "three";
3
2
  import { UIProgressMaskFunction } from "./UIProgressMaskFunction";
3
+ import { type Vector2Like } from "../math";
4
4
  /** Linear directional progress fill */
5
5
  export declare class UIProgressMaskFunctionDirectional extends UIProgressMaskFunction {
6
6
  /** Fill direction as normalized vector */
@@ -0,0 +1,5 @@
1
+ export declare const EPSILON = 0.000001;
2
+ export interface Vector2Like {
3
+ readonly x: number;
4
+ readonly y: number;
5
+ }
@@ -0,0 +1,3 @@
1
+ export declare const WEBGL2_SUPPORTED: boolean;
2
+ export declare const OFFSCREEN_CANVAS_SUPPORTED: boolean;
3
+ export declare const SRGB_SUPPORTED: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laymur",
3
- "version": "0.13.7",
3
+ "version": "0.14.0",
4
4
  "description": "Constraint-based UI library for Three.js mobile advertisements",
5
5
  "scripts": {
6
6
  "clean": "rm -rf dist",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "type": "module",
49
49
  "peerDependencies": {
50
- "three": ">=0.175.0 <0.180.0"
50
+ "three": ">=0.157.0 <0.180.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@babel/core": "^7.28.6",
@@ -57,7 +57,7 @@
57
57
  "@rollup/plugin-replace": "^6.0.3",
58
58
  "@rollup/plugin-terser": "^0.4.4",
59
59
  "@types/node": "^25.0.2",
60
- "@types/three": "^0.175.0",
60
+ "@types/three": "^0.157.0",
61
61
  "@typescript-eslint/eslint-plugin": "^8.32.0",
62
62
  "@typescript-eslint/parser": "^8.32.0",
63
63
  "eslint": "^9.26.0",
@@ -1 +0,0 @@
1
- export declare const SRGB_SUPPORTED: boolean;