@quillmark/quiver 0.21.0 → 0.22.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/dist/build.js CHANGED
@@ -8,7 +8,7 @@
8
8
  import { QuiverError } from './errors.js';
9
9
  import { packFiles } from './bundle.js';
10
10
  import { NAME_DIGEST_LENGTH } from './digest.js';
11
- import { POINTER_FORMAT } from './format.js';
11
+ import { MANIFEST_VERSION, POINTER_FORMAT } from './format.js';
12
12
  /** Font file extensions recognised by the builder (case-insensitive). */
13
13
  const FONT_EXT = /\.(ttf|otf|woff|woff2)$/i;
14
14
  /** The two trees a build owns beside its output: where a generation is assembled, and
@@ -155,8 +155,9 @@ export async function buildQuiver(sourceDir, outDir) {
155
155
  }
156
156
  }
157
157
  const manifest = {
158
- version: 1,
158
+ version: MANIFEST_VERSION,
159
159
  name: meta.name,
160
+ ...(meta.description === undefined ? {} : { description: meta.description }),
160
161
  quills: manifestQuills
161
162
  };
162
163
  const manifestJson = JSON.stringify(manifest, null, 2);
@@ -9,7 +9,7 @@ import { QuiverError } from './errors.js';
9
9
  import { unpackFiles } from './bundle.js';
10
10
  import { isCanonicalSemver, compareSemver } from './semver.js';
11
11
  import { NAME_DIGEST_LENGTH, sha256Hex } from './digest.js';
12
- import { POINTER_FORMAT } from './format.js';
12
+ import { MANIFEST_VERSION, POINTER_FORMAT } from './format.js';
13
13
  import { createQuiver } from './quiver.js';
14
14
  /**
15
15
  * Fetch, then check the bytes against the digest their name carries. That
@@ -142,13 +142,21 @@ function parseManifest(raw) {
142
142
  throw new QuiverError('quiver_invalid', 'Manifest must be a JSON object');
143
143
  }
144
144
  const obj = parsed;
145
- assertNoUnknownKeys(obj, ['version', 'name', 'quills'], 'manifest');
146
- if (obj['version'] !== 1) {
147
- throw new QuiverError('quiver_invalid', `Manifest version must be 1, got ${String(obj['version'])}`);
145
+ assertNoUnknownKeys(obj, ['version', 'name', 'description', 'quills'], 'manifest');
146
+ const version = obj['version'];
147
+ if (typeof version !== 'number' || !Number.isInteger(version) || version < 1) {
148
+ throw new QuiverError('quiver_invalid', `Manifest version must be a positive integer, got ${JSON.stringify(version)}`);
149
+ }
150
+ if (version > MANIFEST_VERSION) {
151
+ throw new QuiverError('quiver_invalid', `This quiver's manifest is version ${version} and this loader reads ${MANIFEST_VERSION}. ` +
152
+ `Upgrade @quillmark/quiver, or for a served client the client itself, which carries the copy that reads this.`);
148
153
  }
149
154
  if (typeof obj['name'] !== 'string' || obj['name'].length === 0) {
150
155
  throw new QuiverError('quiver_invalid', 'Manifest must have a non-empty string "name" field');
151
156
  }
157
+ if (obj['description'] !== undefined && typeof obj['description'] !== 'string') {
158
+ throw new QuiverError('quiver_invalid', `Manifest "description" must be a string if present, got ${typeof obj['description']}`);
159
+ }
152
160
  if (!Array.isArray(obj['quills'])) {
153
161
  throw new QuiverError('quiver_invalid', 'Manifest must have a "quills" array');
154
162
  }
@@ -188,8 +196,8 @@ function parseManifest(raw) {
188
196
  });
189
197
  }
190
198
  return {
191
- version: 1,
192
199
  name: obj['name'],
200
+ description: obj['description'],
193
201
  quills
194
202
  };
195
203
  }
@@ -245,5 +253,5 @@ export async function loadBuiltQuiver(transport) {
245
253
  }
246
254
  index.set(key, entry);
247
255
  }
248
- return createQuiver(manifest.name, catalogOf(index), new BuiltLoader(transport, index));
256
+ return createQuiver(manifest.name, manifest.description, catalogOf(index), new BuiltLoader(transport, index));
249
257
  }
package/dist/format.d.ts CHANGED
@@ -9,3 +9,13 @@
9
9
  * `version` instead.
10
10
  */
11
11
  export declare const POINTER_FORMAT = 1;
12
+ /**
13
+ * The manifest's shape, stated in the document and refused to be read past. Version 2
14
+ * carries the quiver's `description`; version 1 is the same document without it.
15
+ *
16
+ * The manifest is closed, so a field added to it is a field an older reader rejects as an
17
+ * unknown key, naming neither what happened nor what to do. The version is what that
18
+ * reader reads first instead, and a manifest above its own is refused with the upgrade
19
+ * named.
20
+ */
21
+ export declare const MANIFEST_VERSION = 2;
package/dist/format.js CHANGED
@@ -9,3 +9,13 @@
9
9
  * `version` instead.
10
10
  */
11
11
  export const POINTER_FORMAT = 1;
12
+ /**
13
+ * The manifest's shape, stated in the document and refused to be read past. Version 2
14
+ * carries the quiver's `description`; version 1 is the same document without it.
15
+ *
16
+ * The manifest is closed, so a field added to it is a field an older reader rejects as an
17
+ * unknown key, naming neither what happened nor what to do. The version is what that
18
+ * reader reads first instead, and a manifest above its own is refused with the upgrade
19
+ * named.
20
+ */
21
+ export const MANIFEST_VERSION = 2;
package/dist/node.js CHANGED
@@ -34,7 +34,7 @@ export async function fromDir(pathOrFileUrl) {
34
34
  ? fileURLToPath(new URL('.', pathOrFileUrl))
35
35
  : pathOrFileUrl;
36
36
  const { meta, catalog } = await scanSourceQuiver(dir);
37
- return createQuiver(meta.name, catalog, new SourceLoader(dir));
37
+ return createQuiver(meta.name, meta.description, catalog, new SourceLoader(dir));
38
38
  }
39
39
  /**
40
40
  * Loads a packed (build-output) quiver from a local directory containing
package/dist/quiver.d.ts CHANGED
@@ -17,10 +17,12 @@ export interface QuiverLoader {
17
17
  * Exported as `createQuiver` for this package's loaders and reachable from no
18
18
  * entry in `exports`, so a consumer holds the factories and nothing else.
19
19
  */
20
- declare let create: (name: string, catalog: Map<string, string[]>, loader: QuiverLoader) => Quiver;
20
+ declare let create: (name: string, description: string | undefined, catalog: Map<string, string[]>, loader: QuiverLoader) => Quiver;
21
21
  export declare class Quiver {
22
22
  #private;
23
23
  readonly name: string;
24
+ /** What `Quiver.yaml` says the collection is; `undefined` where the field is absent. */
25
+ readonly description: string | undefined;
24
26
  /**
25
27
  * Private constructor. A Quiver comes from a factory (`Quiver.fromBuiltUrl`,
26
28
  * `Quiver.fromBuiltFiles`, or `fromDir` / `fromBuiltDir` from
package/dist/quiver.js CHANGED
@@ -19,6 +19,8 @@ import { matchesSemverSelector, chooseHighestVersion } from './semver.js';
19
19
  let create;
20
20
  export class Quiver {
21
21
  name;
22
+ /** What `Quiver.yaml` says the collection is; `undefined` where the field is absent. */
23
+ description;
22
24
  #catalog;
23
25
  #loader;
24
26
  /**
@@ -33,13 +35,14 @@ export class Quiver {
33
35
  * `Quiver.fromBuiltFiles`, or `fromDir` / `fromBuiltDir` from
34
36
  * `@quillmark/quiver/node`), which is what names the thing being read.
35
37
  */
36
- constructor(name, catalog, loader) {
38
+ constructor(name, description, catalog, loader) {
37
39
  this.name = name;
40
+ this.description = description;
38
41
  this.#catalog = new Map(catalog);
39
42
  this.#loader = loader;
40
43
  }
41
44
  static {
42
- create = (name, catalog, loader) => new Quiver(name, catalog, loader);
45
+ create = (name, description, catalog, loader) => new Quiver(name, description, catalog, loader);
43
46
  }
44
47
  /**
45
48
  * Browser-safe factory. Loads build output from an HTTP/HTTPS URL.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillmark/quiver",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "A quiver of Quillmark quills: load one, pack one, hand out quills.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "author": "Quillmark Contributors",
23
23
  "engines": {
24
- "node": ">=22"
24
+ "node": ">=24"
25
25
  },
26
26
  "exports": {
27
27
  ".": {
@@ -42,7 +42,7 @@
42
42
  "NOTICE"
43
43
  ],
44
44
  "peerDependencies": {
45
- "@quillmark/wasm": ">=0.103.0-0"
45
+ "@quillmark/wasm": ">=0.104.0-0"
46
46
  },
47
47
  "dependencies": {
48
48
  "fflate": "^0.8.2",