@shayc/open-board-format 0.1.4 → 0.1.5

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/CHANGELOG.md +6 -0
  2. package/README.md +52 -34
  3. package/package.json +8 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @shayc/open-board-format
2
2
 
3
+ ## 0.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 222eda9: Rewrite the README for clarity: sharper overview that maps each entry point to its input shape, new Errors and Security sections, and a note that validation preserves unknown fields (vendor extensions survive a parse/stringify round trip). Also sort `package.json` keywords.
8
+
3
9
  ## 0.1.4
4
10
 
5
11
  ### Patch Changes
package/README.md CHANGED
@@ -1,20 +1,12 @@
1
- # @shayc/open-board-format
1
+ # `@shayc/open-board-format`
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@shayc/open-board-format)](https://www.npmjs.com/package/@shayc/open-board-format)
4
- [![license](https://img.shields.io/npm/l/@shayc/open-board-format)](LICENSE)
5
-
6
- A type-safe toolkit to parse, validate, and create Open Board Format (OBF/OBZ) files for Augmentative and Alternative Communication (AAC) applications.
7
-
8
- [Open Board Format](https://www.openboardformat.org/) is an open standard for representing AAC communication boards. It defines two file types:
9
-
10
- - **OBF** (`.obf`) — A JSON file describing a single communication board (buttons, images, sounds, grid layout, metadata).
11
- - **OBZ** (`.obz`) — A ZIP archive containing one or more `.obf` boards along with their associated media and a `manifest.json`.
3
+ A TypeScript toolkit for [Open Board Format](https://www.openboardformat.org/) — the open standard for Augmentative and Alternative Communication (AAC) boards. Parse, validate, and create OBF boards and OBZ packages, all backed by [Zod](https://zod.dev/) schemas with full TypeScript types inferred.
12
4
 
13
- ## Features
5
+ [![npm version](https://img.shields.io/npm/v/@shayc/open-board-format)](https://www.npmjs.com/package/@shayc/open-board-format)
6
+ [![CI](https://github.com/shayc/open-board-format/actions/workflows/ci.yml/badge.svg)](https://github.com/shayc/open-board-format/actions/workflows/ci.yml)
7
+ [![License: MIT](https://img.shields.io/npm/l/@shayc/open-board-format.svg)](LICENSE)
14
8
 
15
- - **Parse & Validate:** Parse and validate OBF boards from JSON strings, objects, or `File` handles.
16
- - **Create & Extract:** Serialize boards to JSON, and create or extract OBZ packages (ZIP archives with boards, images, and sounds).
17
- - **Zod Schemas:** Every OBF type has a corresponding [Zod](https://zod.dev/) schema for runtime validation or API contracts, with full TypeScript types inferred directly.
9
+ OBF (`.obf`) is a JSON file describing a single communication board — buttons, images, sounds, grid layout, metadata. OBZ (`.obz`) is a ZIP archive bundling one or more `.obf` boards with their media and a `manifest.json`.
18
10
 
19
11
  ## Install
20
12
 
@@ -24,21 +16,32 @@ npm install @shayc/open-board-format
24
16
 
25
17
  ## Quick start
26
18
 
27
- ### Parse a single board (OBF)
28
-
29
19
  ```ts
30
- import { parseOBF, validateOBF, loadOBF } from "@shayc/open-board-format";
20
+ import { parseOBF } from "@shayc/open-board-format";
31
21
 
32
- // Parse from a JSON string
33
22
  const board = parseOBF(jsonString);
34
- console.log(board.name); // "My Board"
23
+ console.log(board.id, board.buttons.length);
24
+ ```
35
25
 
36
- // Validate an unknown object (throws on failure)
37
- const validated = validateOBF(untrustedData);
26
+ `parseOBF` throws on invalid input; the returned value is a fully typed `OBFBoard`. For other input shapes (already-parsed object, browser `File`, OBZ archive), see [Overview](#overview).
38
27
 
39
- // Load from a browser File object
40
- const fromFile = await loadOBF(file);
41
- ```
28
+ ## Overview
29
+
30
+ Two file types; pick the entry point by what you have:
31
+
32
+ - **OBF** is a single board (a JSON object). Use `parseOBF` for a JSON string, `validateOBF` for an already-parsed object, `loadOBF` for a browser `File`. `stringifyOBF` serializes back out.
33
+ - **OBZ** is a package of boards plus media (a ZIP archive). Use `loadOBZ` for a `File`, `extractOBZ` for an `ArrayBuffer`, `createOBZ` to build a new one.
34
+
35
+ Every OBF type ships with a matching `*Schema` Zod schema (e.g. `OBFBoardSchema`, `OBFManifestSchema`), so you can validate inline with `safeParse` or wire the schema straight into an API contract — the TypeScript types are inferred from those schemas.
36
+
37
+ Validation preserves unknown fields rather than stripping them, so vendor extensions allowed by the OBF spec survive a `parseOBF` → `stringifyOBF` round trip.
38
+
39
+ ## Requirements
40
+
41
+ - **Module format:** ESM only.
42
+ - **Runtime:** browser or Node 22+ — works against `File`, `ArrayBuffer`, and `Blob`.
43
+
44
+ ## Examples
42
45
 
43
46
  ### Extract an OBZ package
44
47
 
@@ -51,7 +54,6 @@ const { manifest, boards, resources } = await loadOBZ(file);
51
54
  // Or from an ArrayBuffer (e.g. fetch response)
52
55
  const parsed = await extractOBZ(buffer);
53
56
 
54
- // Access boards and resources
55
57
  const homeBoard = parsed.boards.get("1");
56
58
  const imageBytes = parsed.resources.get("images/logo.png");
57
59
  ```
@@ -76,7 +78,7 @@ const resources = new Map([["images/logo.png", pngBytes]]);
76
78
  const blob = await createOBZ(boards, "board-1", resources);
77
79
  ```
78
80
 
79
- ### Use Zod schemas directly
81
+ ### Validate with Zod directly
80
82
 
81
83
  ```ts
82
84
  import { OBFBoardSchema } from "@shayc/open-board-format";
@@ -142,18 +144,34 @@ if (result.success) {
142
144
  | `OBFLocalizedStrings` | Key-value string translations |
143
145
  | `OBFStrings` | Multi-locale string translations |
144
146
 
145
- ## Development
147
+ ## Errors
146
148
 
147
- ```bash
148
- npm install # Install dependencies
149
- npm test # Run tests (vitest)
150
- npm run build # Build for production (tsdown)
151
- npm run typecheck # Type-check without emitting
152
- ```
149
+ All failures throw plain `Error`. The message identifies what failed, typically with one of these prefixes:
150
+
151
+ - `Invalid OBF:` schema validation rejected an OBF board.
152
+ - `Invalid OBZ:` the package was malformed (not a ZIP, missing manifest, unreadable entry).
153
+ - `Invalid manifest:` `manifest.json` failed to parse or validate.
154
+
155
+ When the root cause is a `JSON.parse` failure, the original error is preserved as `error.cause`. For finer-grained validation, drop one level down and use the Zod schemas directly with `safeParse` — the `issues` array tells you exactly which field failed.
156
+
157
+ ## Security
158
+
159
+ OBZ archives are untrusted input. This library does not enforce limits on entry size or count, and does not sanitize entry paths — if you write extracted resources to disk, validate paths yourself first to avoid directory traversal. For stronger guarantees against zip-bomb-style payloads, run extraction in a sandboxed context (Web Worker, isolated process).
160
+
161
+ Found a security issue? Open a private advisory at [github.com/shayc/open-board-format/security/advisories/new](https://github.com/shayc/open-board-format/security/advisories/new).
162
+
163
+ ## Versioning
164
+
165
+ Semver; see [CHANGELOG.md](CHANGELOG.md).
166
+
167
+ ## Contributing
168
+
169
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup (Node 22+, Vitest, the changeset workflow).
153
170
 
154
171
  ## Related
155
172
 
156
- - [Open Board Format specification](https://www.openboardformat.org/docs) — Official standard and format documentation
173
+ - [Open Board Format specification](https://www.openboardformat.org/docs) — the official standard and format documentation.
174
+ - [AAC Board AI](https://github.com/shayc/aac-board-ai) — an offline-first AAC web app built on this package, using on-device browser AI for grammar, tone, and translation ([live app](https://aacboard.app)).
157
175
 
158
176
  ## License
159
177
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shayc/open-board-format",
3
- "version": "0.1.4",
4
- "description": "Parse, validate, and create Open Board Format (OBF/OBZ) files for AAC applications.",
3
+ "version": "0.1.5",
4
+ "description": "A TypeScript toolkit for Open Board Format the open standard for Augmentative and Alternative Communication (AAC) boards.",
5
5
  "license": "MIT",
6
6
  "author": "Shay Cojocaru <shayc@outlook.com>",
7
7
  "homepage": "https://github.com/shayc/open-board-format#readme",
@@ -14,8 +14,12 @@
14
14
  },
15
15
  "keywords": [
16
16
  "aac",
17
- "open-board-format",
18
- "communication-board"
17
+ "aac-board",
18
+ "assistive-technology",
19
+ "communication-board",
20
+ "obf",
21
+ "obz",
22
+ "open-board-format"
19
23
  ],
20
24
  "type": "module",
21
25
  "sideEffects": false,