@octane-xplat/canvas 0.7.3 → 0.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.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # `@octane-xplat/canvas`
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
+ ```sh
8
+ pnpm add @octane-xplat/canvas
9
+ ```
10
+
11
+ ```tsx
12
+ import { Canvas, getGPU } from '@octane-xplat/canvas'
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
+ />
22
+ ```
23
+
24
+ Pass `context` to have the leaf resolve it before `onReady`, or omit it and
25
+ call `getContext` yourself — one kind per canvas, decided on first call.
26
+ `onReady` fires after mount on web and on the plugin's `ready` event on
27
+ native (earlier `getContext` calls can return null). For WebGPU,
28
+ `getGPU()` normalizes adapter/device acquisition across targets.
29
+
30
+ Per-target limits are recorded in
31
+ [known limits](../../docs/known-limits.md). Exercised by
32
+ [`CanvasDemo`](../demos/src/CanvasDemo.tsrx) (including a WGSL path).
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 1,
3
- "buildId": "52898de3-47ca-49b9-afa9-cd2f6663022d",
3
+ "buildId": "e47818f6-941f-444d-a9f5-bc088c04955c",
4
4
  "mode": "production",
5
5
  "capabilities": {
6
6
  "independentHydration": false
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 1,
3
- "buildId": "708787e6-81a1-49bc-a39c-d2481b54b95c",
3
+ "buildId": "41f644fb-4d8e-4f30-9e04-959bb6263619",
4
4
  "mode": "production",
5
5
  "capabilities": {
6
6
  "independentHydration": false
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "name": "@octane-xplat/canvas",
3
- "version": "0.7.3",
3
+ "version": "0.9.0",
4
4
  "description": "Canvas/GPU surface for Octane xplat — web <canvas> + @nativescript/canvas (2D, WebGL/WebGL2, WebGPU/WGSL)",
5
5
  "keywords": [
6
- "octane",
7
- "xplat",
8
- "cross-platform",
9
6
  "canvas",
7
+ "cross-platform",
8
+ "gpu",
9
+ "graphics",
10
+ "nativescript",
11
+ "octane",
10
12
  "webgl",
11
13
  "webgl2",
12
14
  "webgpu",
13
15
  "wgsl",
14
- "gpu",
15
- "graphics",
16
- "nativescript"
16
+ "xplat"
17
17
  ],
18
- "license": "MIT",
19
18
  "homepage": "https://github.com/octane-xplat/octane-xplat/tree/main/packages/canvas",
19
+ "license": "MIT",
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "git+https://github.com/octane-xplat/octane-xplat.git",
22
+ "url": "https://github.com/octane-xplat/octane-xplat",
23
23
  "directory": "packages/canvas"
24
24
  },
25
25
  "files": [
@@ -43,10 +43,11 @@
43
43
  "@nativescript/canvas": "3.0.0-alpha.15"
44
44
  },
45
45
  "devDependencies": {
46
- "@nativescript-community/octane": "0.2.1",
46
+ "@nativescript-community/octane": "0.2.4",
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
51
  "typescript": "5.9.3",
51
52
  "vite": "8.3.0"
52
53
  },
@@ -64,6 +65,9 @@
64
65
  }
65
66
  },
66
67
  "scripts": {
67
- "build": "vite build && vite build --mode native && tsc -p tsconfig.types.json && node ../../scripts/check-native-dist.mjs"
68
+ "build": "vite build && vite build --mode native && pnpm typegen && node ../../scripts/check-native-dist.mjs",
69
+ "typegen": "tsc -p tsconfig.types.json",
70
+ "test:packed": "node tests/packed-consumer.mjs",
71
+ "pack:check": "tsrx-typegen --pack-check"
68
72
  }
69
73
  }
package/src/gpu.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { GPU } from '@nativescript/canvas';
1
+ import { GPU } from '@nativescript/canvas'
2
2
 
3
3
  /** getGPU — returns the plugin's GPU shim (wgpu over Metal/Vulkan). Same
4
4
  * spec-shaped surface as web's `navigator.gpu`: `requestAdapter()` +
5
5
  * `getPreferredCanvasFormat()`. */
6
6
  export function getGPU(): any {
7
- return new GPU();
7
+ return new GPU()
8
8
  }
package/src/gpu.web.ts CHANGED
@@ -3,5 +3,5 @@
3
3
  * returned object is spec-shaped: `requestAdapter()` +
4
4
  * `getPreferredCanvasFormat()`. */
5
5
  export function getGPU(): any {
6
- return (globalThis.navigator as any)?.gpu ?? null;
6
+ return (globalThis.navigator as any)?.gpu ?? null
7
7
  }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // Platform barrels — explicit .tsrx leaf imports (moduleSuffixes don't
2
2
  // reach .tsrx; same convention as @octane-xplat/ui index.*.ts).
3
- export { Canvas } from './Canvas.tsrx';
4
- export { getGPU } from './gpu';
5
- export type { CanvasProps, CanvasContextKind, CanvasReady } from './props';
3
+ export { Canvas } from './Canvas.tsrx'
4
+ export { getGPU } from './gpu'
5
+ export type { CanvasProps, CanvasContextKind, CanvasReady } from './props'
package/src/index.web.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // Platform barrels — explicit .tsrx leaf imports (moduleSuffixes don't
2
2
  // reach .tsrx; same convention as @octane-xplat/ui index.*.ts).
3
- export { Canvas } from './Canvas.web.tsrx';
4
- export { getGPU } from './gpu.web';
5
- export type { CanvasProps, CanvasContextKind, CanvasReady } from './props';
3
+ export { Canvas } from './Canvas.web.tsrx'
4
+ export { getGPU } from './gpu.web'
5
+ export type { CanvasProps, CanvasContextKind, CanvasReady } from './props'
package/src/props.ts CHANGED
@@ -1,33 +1,28 @@
1
- export type CanvasContextKind =
2
- | '2d'
3
- | 'webgl'
4
- | 'webgl2'
5
- | 'webgpu'
6
- | 'bitmaprenderer';
1
+ export type CanvasContextKind = '2d' | 'webgl' | 'webgl2' | 'webgpu' | 'bitmaprenderer'
7
2
 
8
3
  export interface CanvasReady {
9
4
  /** HTMLCanvasElement on web, the plugin's Canvas view on native —
10
5
  * both expose `getContext()`. */
11
- canvas: any;
6
+ canvas: any
12
7
  /** The resolved context for the `context` prop, or null when that
13
8
  * kind is unsupported/unavailable. WebGPU still needs a device —
14
9
  * `getGPU()` normalizes adapter/device acquisition. */
15
- context: any;
10
+ context: any
16
11
  }
17
12
 
18
13
  export interface CanvasProps {
19
- className?: any;
20
- style?: any;
21
- id?: string;
14
+ className?: any
15
+ style?: any
16
+ id?: string
22
17
  /** Context kind resolved before `onReady` fires. Omit to defer
23
18
  * `getContext` to user code (only one kind per canvas — call once). */
24
- context?: CanvasContextKind;
19
+ context?: CanvasContextKind
25
20
  /** Web: after mount. Native: the plugin's `ready` event (fires when the
26
21
  * GPU surface exists — earlier `getContext` calls can return null). */
27
- onReady?: (ready: CanvasReady) => void;
22
+ onReady?: (ready: CanvasReady) => void
28
23
  /** Numeric values map to the element's width/height — on web that is
29
24
  * the canvas *drawing buffer* size (pair with style for display
30
25
  * size), on native dip size. */
31
- width?: string | number;
32
- height?: string | number;
26
+ width?: string | number
27
+ height?: string | number
33
28
  }
package/types/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // props.ts (tsrx-tsc can't emit .tsrx declarations; see ui/types/index.d.ts
3
3
  // for the same pattern).
4
4
  import type { UniversalComponent } from 'octane/universal'
5
- import type { CanvasProps } from './props'
5
+ import type { CanvasProps } from './props.js'
6
6
 
7
7
  export declare const Canvas: UniversalComponent<CanvasProps>
8
8
 
@@ -10,4 +10,4 @@ export declare const Canvas: UniversalComponent<CanvasProps>
10
10
  * GPU shim on native — or null where WebGPU is unavailable. */
11
11
  export declare function getGPU(): any
12
12
 
13
- export type { CanvasProps, CanvasContextKind, CanvasReady } from './props'
13
+ export type { CanvasProps, CanvasContextKind, CanvasReady } from './props.js'