@octane-xplat/canvas 0.9.0 → 0.10.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.
package/README.md CHANGED
@@ -1,24 +1,30 @@
1
1
  # `@octane-xplat/canvas`
2
2
 
3
- A GPU/canvas surface for Octane xplat apps: the DOM `<canvas>` on web and
4
- `@nativescript/canvas` on iOS/Android — 2D, WebGL/WebGL2, and
5
- WebGPU/WGSL context kinds behind one `getContext` contract.
6
-
7
3
  ```sh
8
4
  pnpm add @octane-xplat/canvas
9
5
  ```
10
6
 
7
+ A GPU/canvas surface for Octane xplat apps: the DOM `<canvas>` on web and
8
+ `@nativescript/canvas` on iOS/Android — 2D, WebGL/WebGL2, and
9
+ WebGPU/WGSL context kinds behind one `getContext` contract.
10
+
11
11
  ```tsx
12
- import { Canvas, getGPU } from '@octane-xplat/canvas'
12
+ import { Canvas } from '@octane-xplat/canvas'
13
13
 
14
- ;<Canvas
15
- context="webgl"
16
- width={640} // numeric size = drawing-buffer/dip size, not display size
17
- height={480}
18
- onReady={({ canvas, context }) => {
19
- // context is null when that kind is unavailable on this target
20
- }}
21
- />
14
+ export function Drawing() {
15
+ return (
16
+ <Canvas
17
+ context="2d"
18
+ width={640}
19
+ height={480}
20
+ onReady={({ context }) => {
21
+ if (!context) return
22
+ context.fillStyle = '#2563eb'
23
+ context.fillRect(0, 0, 80, 80)
24
+ }}
25
+ />
26
+ )
27
+ }
22
28
  ```
23
29
 
24
30
  Pass `context` to have the leaf resolve it before `onReady`, or omit it and
@@ -27,6 +33,24 @@ call `getContext` yourself — one kind per canvas, decided on first call.
27
33
  native (earlier `getContext` calls can return null). For WebGPU,
28
34
  `getGPU()` normalizes adapter/device acquisition across targets.
29
35
 
36
+ ```tsx
37
+ import { Canvas, getGPU } from '@octane-xplat/canvas'
38
+
39
+ export function DeferredCanvas() {
40
+ return (
41
+ <Canvas
42
+ onReady={({ canvas }) => {
43
+ const context = canvas.getContext('2d')
44
+ if (context) context.fillRect(0, 0, 20, 20)
45
+ }}
46
+ />
47
+ )
48
+ }
49
+ const gpu = getGPU()
50
+ const adapter = await gpu?.requestAdapter()
51
+ const device = await adapter?.requestDevice()
52
+ ```
53
+
30
54
  Per-target limits are recorded in
31
- [known limits](../../docs/known-limits.md). Exercised by
55
+ [known limits](../../docs/verify/known-limits.md). Exercised by
32
56
  [`CanvasDemo`](../demos/src/CanvasDemo.tsrx) (including a WGSL path).
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 1,
3
- "buildId": "e47818f6-941f-444d-a9f5-bc088c04955c",
3
+ "buildId": "266c5beb-953a-44be-a98f-964cada3fb26",
4
4
  "mode": "production",
5
5
  "capabilities": {
6
6
  "independentHydration": false
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 1,
3
- "buildId": "41f644fb-4d8e-4f30-9e04-959bb6263619",
3
+ "buildId": "03fdb1cd-295a-4650-8734-16e8c367bd74",
4
4
  "mode": "production",
5
5
  "capabilities": {
6
6
  "independentHydration": false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octane-xplat/canvas",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Canvas/GPU surface for Octane xplat — web <canvas> + @nativescript/canvas (2D, WebGL/WebGL2, WebGPU/WGSL)",
5
5
  "keywords": [
6
6
  "canvas",
@@ -47,7 +47,7 @@
47
47
  "@nativescript/core": "9.1.2",
48
48
  "@octanejs/vite-plugin": "0.1.61",
49
49
  "octane": "0.6.3",
50
- "tsrx-typegen": "0.2.1",
50
+ "tsrx-typegen": "0.2.2",
51
51
  "typescript": "5.9.3",
52
52
  "vite": "8.3.0"
53
53
  },