open-board-format 1.0.4 → 1.0.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 (2) hide show
  1. package/dist/index.mjs +62 -6
  2. package/package.json +7 -7
package/dist/index.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  import { z } from "zod";
2
2
  import { unzip as unzip$1, zip as zip$1 } from "fflate";
3
-
4
3
  //#region src/schema.ts
5
4
  /**
6
5
  * Open Board Format (OBF) Zod Schemas
@@ -59,11 +58,17 @@ const OBFButtonActionSchema = z.union([OBFSpellingActionSchema, OBFSpecialtyActi
59
58
  * License terms and attribution for a resource.
60
59
  */
61
60
  const OBFLicenseSchema = z.object({
61
+ /** Type of the license, e.g., 'CC-BY-SA'. */
62
62
  type: z.string(),
63
+ /** URL to the license terms. */
63
64
  copyright_notice_url: OBFOptionalUrlSchema,
65
+ /** Source URL of the resource. */
64
66
  source_url: OBFOptionalUrlSchema,
67
+ /** Name of the author. */
65
68
  author_name: z.string().optional(),
69
+ /** URL of the author's webpage. */
66
70
  author_url: OBFOptionalUrlSchema,
71
+ /** Email address of the author. */
67
72
  author_email: OBFOptionalEmailSchema
68
73
  });
69
74
  /**
@@ -75,19 +80,28 @@ const OBFLicenseSchema = z.object({
75
80
  * 3. url
76
81
  */
77
82
  const OBFMediaSchema = z.object({
83
+ /** Unique identifier for the media resource. */
78
84
  id: OBFIDSchema,
85
+ /** Data URI containing the media data. */
79
86
  data: z.string().optional(),
87
+ /** Path to the media file within an .obz package. */
80
88
  path: z.string().optional(),
89
+ /** Data URL to fetch the media programmatically. */
81
90
  data_url: OBFOptionalUrlSchema,
91
+ /** URL to the media resource. */
82
92
  url: OBFOptionalUrlSchema,
93
+ /** MIME type of the media, e.g., 'image/png', 'audio/mpeg'. */
83
94
  content_type: z.string().optional(),
95
+ /** Licensing information for the media. */
84
96
  license: OBFLicenseSchema.optional()
85
97
  });
86
98
  /**
87
99
  * Reference to a symbol in a proprietary symbol set (e.g., SymbolStix).
88
100
  */
89
101
  const OBFSymbolInfoSchema = z.object({
102
+ /** Name of the symbol set, e.g., 'symbolstix'. */
90
103
  set: z.string(),
104
+ /** Filename of the symbol within the set. */
91
105
  filename: z.string()
92
106
  });
93
107
  /**
@@ -101,8 +115,11 @@ const OBFSymbolInfoSchema = z.object({
101
115
  * 4. `symbol`
102
116
  */
103
117
  const OBFImageSchema = OBFMediaSchema.and(z.object({
118
+ /** Information about a symbol from a proprietary symbol set. */
104
119
  symbol: OBFSymbolInfoSchema.optional(),
120
+ /** Width of the image in pixels. */
105
121
  width: z.number().optional(),
122
+ /** Height of the image in pixels. */
106
123
  height: z.number().optional()
107
124
  }));
108
125
  /**
@@ -113,69 +130,111 @@ const OBFSoundSchema = OBFMediaSchema;
113
130
  * Reference to another board, resolved by ID, path, or URL.
114
131
  */
115
132
  const OBFLoadBoardSchema = z.object({
133
+ /** Unique identifier of the board to load. */
116
134
  id: OBFOptionalIDSchema,
135
+ /** Name of the board to load. */
117
136
  name: z.string().optional(),
137
+ /** Data URL to fetch the board programmatically. */
118
138
  data_url: OBFOptionalUrlSchema,
139
+ /** URL to access the board via a web browser. */
119
140
  url: OBFOptionalUrlSchema,
141
+ /** Path to the board within an .obz package. */
120
142
  path: z.string().optional()
121
143
  });
122
144
  /**
123
145
  * Interactive element on a board, optionally linked to images, sounds, and actions.
124
146
  */
125
147
  const OBFButtonSchema = z.object({
148
+ /** Unique identifier for the button. */
126
149
  id: OBFIDSchema,
150
+ /** Label text displayed on the button. */
127
151
  label: z.string().optional(),
152
+ /** Alternative text for vocalization when the button is activated. */
128
153
  vocalization: z.string().optional(),
154
+ /** Identifier of the image associated with the button. */
129
155
  image_id: OBFOptionalIDSchema,
156
+ /** Identifier of the sound associated with the button. */
130
157
  sound_id: OBFOptionalIDSchema,
158
+ /** Action associated with the button. */
131
159
  action: OBFButtonActionSchema.optional(),
160
+ /** List of multiple actions for the button, executed in order. */
132
161
  actions: z.array(OBFButtonActionSchema).optional(),
162
+ /** Information to load another board when this button is activated. */
133
163
  load_board: OBFLoadBoardSchema.optional(),
164
+ /** Background color of the button in 'rgb' or 'rgba' format. */
134
165
  background_color: z.string().optional(),
166
+ /** Border color of the button in 'rgb' or 'rgba' format. */
135
167
  border_color: z.string().optional(),
168
+ /** Vertical position for absolute positioning (0.0 to 1.0). */
136
169
  top: z.number().min(0).max(1).optional(),
170
+ /** Horizontal position for absolute positioning (0.0 to 1.0). */
137
171
  left: z.number().min(0).max(1).optional(),
172
+ /** Width of the button for absolute positioning (0.0 to 1.0). */
138
173
  width: z.number().min(0).max(1).optional(),
174
+ /** Height of the button for absolute positioning (0.0 to 1.0). */
139
175
  height: z.number().min(0).max(1).optional()
140
176
  });
141
177
  /**
142
178
  * Row-and-column layout that arranges buttons by their IDs.
143
179
  */
144
180
  const OBFGridSchema = z.object({
181
+ /** Number of rows in the grid. */
145
182
  rows: z.number().int().min(1),
183
+ /** Number of columns in the grid. */
146
184
  columns: z.number().int().min(1),
185
+ /**
186
+ * 2D array representing the order of buttons by their IDs.
187
+ * Each sub-array corresponds to a row, and each element is a button ID or null for empty slots.
188
+ */
147
189
  order: z.array(z.array(z.union([OBFIDSchema, z.null()])))
148
190
  }).refine((g) => g.order.length === g.rows, { message: "Grid order length must match rows" }).refine((g) => g.order.every((row) => row.length === g.columns), { message: "Each grid row must have length equal to columns" });
149
191
  /**
150
192
  * Root object of an `.obf` file: the complete definition of a single communication board.
151
193
  */
152
194
  const OBFBoardSchema = z.object({
195
+ /** Format version of the Open Board Format, e.g., 'open-board-0.1'. */
153
196
  format: OBFFormatVersionSchema,
197
+ /** Unique identifier for the board. */
154
198
  id: OBFIDSchema,
199
+ /** Locale of the board as a BCP 47 language tag, e.g., 'en', 'en-US'. */
155
200
  locale: OBFLocaleCodeSchema.optional(),
201
+ /** List of buttons on the board. */
156
202
  buttons: z.array(OBFButtonSchema),
203
+ /** URL where the board can be accessed or downloaded. */
157
204
  url: OBFOptionalUrlSchema,
205
+ /** Name of the board. */
158
206
  name: z.string().optional(),
207
+ /** Description of the board in HTML format. */
159
208
  description_html: z.string().optional(),
209
+ /** Grid layout information for arranging buttons. */
160
210
  grid: OBFGridSchema,
211
+ /** List of images used in the board. */
161
212
  images: z.array(OBFImageSchema).optional(),
213
+ /** List of sounds used in the board. */
162
214
  sounds: z.array(OBFSoundSchema).optional(),
215
+ /** Licensing information for the board. */
163
216
  license: OBFLicenseSchema.optional(),
217
+ /** String translations for multiple locales. */
164
218
  strings: OBFStringsSchema.optional()
165
219
  });
166
220
  /**
167
221
  * Table of contents for an `.obz` package, mapping resource IDs to their archive paths.
168
222
  */
169
223
  const OBFManifestSchema = z.object({
224
+ /** Format version of the Open Board Format, e.g., 'open-board-0.1'. */
170
225
  format: OBFFormatVersionSchema,
226
+ /** Path to the root board within the .obz package. */
171
227
  root: z.string(),
228
+ /** Mapping of IDs to paths for boards, images, and sounds. */
172
229
  paths: z.object({
230
+ /** Mapping of board IDs to their file paths. */
173
231
  boards: z.record(z.string(), z.string()),
232
+ /** Mapping of image IDs to their file paths. */
174
233
  images: z.record(z.string(), z.string()),
234
+ /** Mapping of sound IDs to their file paths. */
175
235
  sounds: z.record(z.string(), z.string()).optional()
176
236
  })
177
237
  });
178
-
179
238
  //#endregion
180
239
  //#region src/obf.ts
181
240
  const UTF8_BOM = "";
@@ -245,7 +304,6 @@ function validateOBF(data) {
245
304
  function stringifyOBF(board) {
246
305
  return JSON.stringify(board, null, 2);
247
306
  }
248
-
249
307
  //#endregion
250
308
  //#region src/zip.ts
251
309
  /**
@@ -313,7 +371,6 @@ function isZip(archive) {
313
371
  const bytes = new Uint8Array(archive);
314
372
  return bytes.length >= ZIP_MAGIC.length && ZIP_MAGIC.every((byte, index) => bytes[index] === byte);
315
373
  }
316
-
317
374
  //#endregion
318
375
  //#region src/obz.ts
319
376
  /**
@@ -419,6 +476,5 @@ function extractBoards(manifest, entries) {
419
476
  }
420
477
  return boards;
421
478
  }
422
-
423
479
  //#endregion
424
- export { OBFBoardSchema, OBFButtonActionSchema, OBFButtonSchema, OBFFormatVersionSchema, OBFGridSchema, OBFIDSchema, OBFImageSchema, OBFLicenseSchema, OBFLoadBoardSchema, OBFLocaleCodeSchema, OBFLocalizedStringsSchema, OBFManifestSchema, OBFMediaSchema, OBFSoundSchema, OBFSpecialtyActionSchema, OBFSpellingActionSchema, OBFStringsSchema, OBFSymbolInfoSchema, createOBZ, extractOBZ, isZip, loadOBF, loadOBZ, parseManifest, parseOBF, stringifyOBF, unzip, validateOBF, zip };
480
+ export { OBFBoardSchema, OBFButtonActionSchema, OBFButtonSchema, OBFFormatVersionSchema, OBFGridSchema, OBFIDSchema, OBFImageSchema, OBFLicenseSchema, OBFLoadBoardSchema, OBFLocaleCodeSchema, OBFLocalizedStringsSchema, OBFManifestSchema, OBFMediaSchema, OBFSoundSchema, OBFSpecialtyActionSchema, OBFSpellingActionSchema, OBFStringsSchema, OBFSymbolInfoSchema, createOBZ, extractOBZ, isZip, loadOBF, loadOBZ, parseManifest, parseOBF, stringifyOBF, unzip, validateOBF, zip };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "open-board-format",
3
3
  "type": "module",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "description": "Parse, validate, and create Open Board Format (OBF/OBZ) files for AAC applications.",
6
6
  "author": "Shay Cojocaru <shayc@outlook.com>",
7
7
  "license": "MIT",
@@ -35,14 +35,14 @@
35
35
  "prepublishOnly": "npm run build"
36
36
  },
37
37
  "devDependencies": {
38
- "@types/node": "^25.3.0",
39
- "bumpp": "^10.4.1",
40
- "tsdown": "^0.20.3",
41
- "typescript": "^5.9.3",
42
- "vitest": "^4.0.18"
38
+ "@types/node": "^25.7.0",
39
+ "bumpp": "^11.1.0",
40
+ "tsdown": "^0.22.0",
41
+ "typescript": "~6.0.3",
42
+ "vitest": "^4.1.6"
43
43
  },
44
44
  "dependencies": {
45
45
  "fflate": "^0.8.2",
46
- "zod": "^4.3.6"
46
+ "zod": "^4.4.3"
47
47
  }
48
48
  }