@bevelo/canvas 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bevelo contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,46 @@
1
- # Temporary Holding Version
1
+ # @bevelo/canvas
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A canvas engine over a document port. The host supplies the document (any store that
4
+ answers `list`, `get`, `has`, `set` and `subscribe`) and a renderer; the engine owns the
5
+ camera, culling, hit testing and dirty-rect repaints. A tool layer (`createCanvasSession`)
6
+ turns pointer input into document writes for select, pen, shapes, text, connectors and
7
+ more. There is no storage, no sync, no frame loop and no history: those stay with the host.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ pnpm add @bevelo/canvas
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { createCanvasEngine, drawRect, memoryDocument, type MemoryElement } from "@bevelo/canvas";
19
+
20
+ const document = memoryDocument<MemoryElement>({
21
+ elements: [{ id: "a", order: "V", bounds: { x: 40, y: 40, width: 120, height: 80 } }],
22
+ });
23
+
24
+ const engine = createCanvasEngine({
25
+ document,
26
+ canvas: globalThis.document.querySelector("canvas")!,
27
+ renderer: {
28
+ draw: (ctx, element) => drawRect(ctx, element.bounds, { fill: "#e2e2e0", stroke: "#171717", strokeWidth: 1 }),
29
+ },
30
+ });
31
+
32
+ engine.paint(); // call again after each change
33
+ engine.hitAt({ x: 60, y: 60 }); // "a"
34
+ ```
35
+
36
+ `memoryDocument` is the canonical implementation of the port; an adapter over a real
37
+ store can run the same conformance suite (`test/conformance.ts`).
38
+
39
+ ## Stability
40
+
41
+ The whole package is `@experimental` and may change in any minor release.
42
+
43
+ ## Docs
44
+
45
+ Source and examples live in the repository at https://github.com/bevelo/bevelo
46
+ (`examples/experiments/canvas`).