Skip to content

Commit

Permalink
Add stub types to make screen compatible with react-tela render()
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Feb 18, 2024
1 parent 74f074d commit aaa1024
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/famous-dodos-glow.md
@@ -0,0 +1,5 @@
---
'nxjs-runtime': patch
---

Add stub types to make `screen` compatible with react-tela `render()`
32 changes: 32 additions & 0 deletions packages/runtime/src/canvas/canvas-rendering-context-2d.ts
Expand Up @@ -51,6 +51,38 @@ export class CanvasRenderingContext2D {
return ctx;
}

// TODO: implement
declare direction: string;
declare fontKerning: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/clip) */
clip(fillRule?: CanvasFillRule): void;
clip(path: Path2D, fillRule?: CanvasFillRule): void;
clip(path: unknown, fillRule?: unknown) {
stub();
}
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/isPointInPath) */
isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean;
isPointInPath(
path: Path2D,
x: number,
y: number,
fillRule?: CanvasFillRule
): boolean;
isPointInPath(
path: unknown,
x: unknown,
y: unknown,
fillRule?: unknown
): boolean {
stub();
}
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/isPointInStroke) */
isPointInStroke(x: number, y: number): boolean;
isPointInStroke(path: Path2D, x: number, y: number): boolean;
isPointInStroke(path: unknown, x: unknown, y?: unknown): boolean {
stub();
}

/**
* A read-only reference to the {@link Screen | `Canvas`} object
* that is associated with the context.
Expand Down
Expand Up @@ -51,6 +51,38 @@ export class OffscreenCanvasRenderingContext2D {
return ctx;
}

// TODO: implement
declare direction: string;
declare fontKerning: string;
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/clip) */
clip(fillRule?: CanvasFillRule): void;
clip(path: Path2D, fillRule?: CanvasFillRule): void;
clip(path: unknown, fillRule?: unknown) {
stub();
}
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/isPointInPath) */
isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean;
isPointInPath(
path: Path2D,
x: number,
y: number,
fillRule?: CanvasFillRule
): boolean;
isPointInPath(
path: unknown,
x: unknown,
y: unknown,
fillRule?: unknown
): boolean {
stub();
}
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/isPointInStroke) */
isPointInStroke(x: number, y: number): boolean;
isPointInStroke(path: Path2D, x: number, y: number): boolean;
isPointInStroke(path: unknown, x: unknown, y?: unknown): boolean {
stub();
}

/**
* A read-only reference to the {@link OffscreenCanvas | `OffscreenCanvas`} object
* that is associated with the context.
Expand Down

0 comments on commit aaa1024

Please sign in to comment.