@toonstrip/core 0.1.0 → 0.1.2

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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -0
  3. package/package.json +27 -13
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Daniel Kim
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 ADDED
@@ -0,0 +1,71 @@
1
+ # @toonstrip/core
2
+
3
+ The framework-agnostic rendering engine: draws a single `Panel` (from
4
+ `@toonstrip/schema`) onto a `CanvasRenderingContext2D` — figures, poses,
5
+ speech/thought/caption balloons, backdrops, camera framing, and strip layout.
6
+ No DOM dependency; runs in Node via `@napi-rs/canvas` or in a browser.
7
+
8
+ Part of [toonstrip](https://github.com/dkdev24/toonstrip), a
9
+ framework-embeddable comic-strip renderer. Most consumers want
10
+ `@toonstrip/element` (a ready-made `<comic-strip>` custom element) rather
11
+ than calling this package directly — reach for `core` when you're rendering
12
+ outside the DOM (a Node script, a build-time static fallback) or building
13
+ your own embed.
14
+
15
+ ## Install
16
+
17
+ ```
18
+ npm install @toonstrip/core @toonstrip/schema
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```ts
24
+ import { createCanvas, loadImage } from "@napi-rs/canvas";
25
+ import { layoutStrip, renderPanel, type Cast } from "@toonstrip/core";
26
+ import { loadCastManifest } from "@toonstrip/pack-comic-chat";
27
+ import type { Panel } from "@toonstrip/schema";
28
+
29
+ const manifest = loadCastManifest();
30
+ const dan = manifest.cast.dan;
31
+ const pastoral = manifest.backdrops.find((b) => b.id === "pastoral")!;
32
+
33
+ const cast: Cast = {
34
+ manifest: { version: 1, cast: { dan }, backdrops: [pastoral] },
35
+ sheets: new Map([["dan", await loadImage(dan.sheet)]]),
36
+ backdrops: new Map([["pastoral", await loadImage(pastoral.file)]]),
37
+ };
38
+
39
+ const panel: Panel = {
40
+ backdrop: "pastoral",
41
+ camera: "medium",
42
+ bodies: [{ character: "dan", emotion: { angle: 0, intensity: 0.5 } }],
43
+ speakers: [{ speaker: "dan", balloon: "speech", text: "Rendered from a Node script." }],
44
+ };
45
+
46
+ const { panelWidth, panelHeight } = layoutStrip(900);
47
+ const canvas = createCanvas(panelWidth, panelHeight);
48
+ const ctx = canvas.getContext("2d") as unknown as CanvasRenderingContext2D;
49
+ renderPanel(ctx, panel, cast, panelWidth, panelHeight);
50
+ ```
51
+
52
+ A `Cast` is a resolved asset pack: the `CastManifest` (character/backdrop
53
+ metadata) plus loaded `sheets`/`backdrops` images, keyed by id. Building one
54
+ from a pack package or from files fetched over the network is the caller's
55
+ job — `@toonstrip/pack-comic-chat` and `@toonstrip/element`'s `load-pack.ts`
56
+ are the two existing examples.
57
+
58
+ ## What's exported
59
+
60
+ - `renderPanel(ctx, panel, cast, width, height, options?)` — draws one panel
61
+ - `layoutStrip(containerWidth)` — column count + per-panel size for a strip
62
+ at a given container width (drives responsive relayout)
63
+ - `selectFigures`, `figureFor`, pose-selection helpers — for a caller that
64
+ needs to advance pose cycles without drawing (e.g. a virtualized strip)
65
+ - Balloon measurement/drawing primitives (`measureBalloon`, `drawBalloon`,
66
+ `layoutBalloons`) if you're composing a custom render path
67
+ - `Cast`, `Figure`, `PoseCycle` and the rest of the type surface
68
+
69
+ ## License
70
+
71
+ MIT
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@toonstrip/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
+ "description": "Framework-agnostic canvas rendering engine for toonstrip comic strips.",
4
5
  "license": "MIT",
5
6
  "type": "module",
6
7
  "main": "./dist/index.js",
@@ -8,23 +9,36 @@
8
9
  "files": [
9
10
  "dist"
10
11
  ],
11
- "scripts": {
12
- "build": "tsc -p tsconfig.json",
13
- "test": "vitest run",
14
- "lint": "tsc -p tsconfig.json --noEmit",
15
- "example:render-fixture": "node --experimental-strip-types examples/render-fixture.ts"
16
- },
17
12
  "dependencies": {
18
- "@toonstrip/schema": "workspace:*",
19
- "@napi-rs/canvas": "^0.1.65"
13
+ "@napi-rs/canvas": "^0.1.65",
14
+ "@toonstrip/schema": "0.1.1"
20
15
  },
21
16
  "devDependencies": {
22
- "@toonstrip/pack-comic-chat": "workspace:*",
23
- "@toonstrip/pack-example": "workspace:*",
24
17
  "typescript": "^5.6.3",
25
- "vitest": "^2.1.4"
18
+ "vitest": "^2.1.4",
19
+ "@toonstrip/pack-example": "0.1.1",
20
+ "@toonstrip/pack-comic-chat": "0.1.1"
26
21
  },
27
22
  "publishConfig": {
28
23
  "access": "public"
24
+ },
25
+ "keywords": [
26
+ "toonstrip",
27
+ "comic",
28
+ "canvas",
29
+ "rendering"
30
+ ],
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/dkdev24/toonstrip.git",
34
+ "directory": "packages/core"
35
+ },
36
+ "homepage": "https://github.com/dkdev24/toonstrip#readme",
37
+ "bugs": "https://github.com/dkdev24/toonstrip/issues",
38
+ "scripts": {
39
+ "build": "tsc -p tsconfig.json",
40
+ "test": "vitest run",
41
+ "lint": "tsc -p tsconfig.json --noEmit",
42
+ "example:render-fixture": "node --experimental-strip-types examples/render-fixture.ts"
29
43
  }
30
- }
44
+ }