@valbuild/core 0.111.0 → 0.117.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/CHANGELOG.md ADDED
@@ -0,0 +1,56 @@
1
+ # @valbuild/core
2
+
3
+ ## 0.117.0
4
+
5
+ ### Patch Changes
6
+
7
+ - [#581](https://github.com/valbuild/val/pull/581) [`d94a40f`](https://github.com/valbuild/val/commit/d94a40f8bd11027636d183e293aced820b6f341f) Thanks [@freekh](https://github.com/freekh)! - Images no longer show a validation warning in the editor when nothing is wrong
8
+ with them.
9
+
10
+ Every `s.image()` carrying width, height or a mime type used to be marked in VS
11
+ Code with "Found image metadata, but it could not be validated", whether or not
12
+ the metadata was correct — so the warning sat on every image in the project and
13
+ never went away, not even after applying its own quick fix.
14
+
15
+ That message was never a finding. `@valbuild/core` cannot read files, so it
16
+ cannot answer whether stored dimensions match the image, and it hands the
17
+ question on as an `image:check-metadata` fix instead. `val validate` has always
18
+ resolved that by reading the file and comparing; the language server now does
19
+ the same, and reports only what actually disagrees:
20
+
21
+ ```
22
+ Image width is incorrect! Found: 800. Expected: 944
23
+ ```
24
+
25
+ An image whose metadata is right gets nothing. A missing `width`, `height` or
26
+ `mimeType` is reported, as is a stale one, with the quick fix still offered. A
27
+ file that is not on disk is still reported as a missing file rather than as a
28
+ metadata problem.
29
+
30
+ The four messages involved say what they mean now, in the editor and in
31
+ `val validate` alike:
32
+
33
+ - "Image metadata has not been checked against the file." (was "Found image
34
+ metadata, but it could not be validated. An image must have a width (positive
35
+ number), a height (positive number) and a mime type." — which described a
36
+ check that never ran)
37
+ - "Image metadata is missing: width, height and mimeType." (was "Could not
38
+ validate Image metadata.")
39
+ - "File mimeType has not been checked against the file." (was "Found mimeType,
40
+ but it could not be validated.")
41
+ - "File metadata is missing: mimeType." (was "Missing File mimeType.")
42
+
43
+ Also fixes an `s.file()` whose `mimeType` is missing: it reported "Mime type and
44
+ file extension not matching. Mime type is 'undefined'" with no fix attached, so
45
+ no quick fix was offered and the `file:add-metadata` case was unreachable. It
46
+ now reports the missing mime type and offers to add it.
47
+
48
+ - [#579](https://github.com/valbuild/val/pull/579) [`b2812ae`](https://github.com/valbuild/val/commit/b2812ae4ee03e005ecead3365f49c625e536f94d) Thanks [@freekh](https://github.com/freekh)! - Every release now ships a changelog. Each package's `CHANGELOG.md` records what
49
+ changed under the version that shipped it — with a link to the pull request, the
50
+ commit and the author — and the same entry becomes the body of the GitHub
51
+ Release for the tag. The file is included in the npm tarball, so it is also
52
+ readable from an installed copy.
53
+
54
+ Up to now those changelogs were generated empty, and the GitHub Releases with
55
+ them, so there was no record of what any given version contained. Releases from
56
+ this one on have one; earlier versions stay blank.
@@ -31,7 +31,7 @@ import { ModulePath, SourcePath, getValPath, isVal } from "./val/index.js";
31
31
  import { createValPathOfItem } from "./selector/SelectorProxy.js";
32
32
  import { Operation } from "./patch/index.js";
33
33
  import { initSchema } from "./initSchema.js";
34
- import { getMimeType, mimeTypeToFileExt, filenameToMimeType } from "./mimeType/index.js";
34
+ import { getMimeType, mimeTypeToFileExt, filenameToMimeType, mimeTypeMatchesAccept } from "./mimeType/index.js";
35
35
  import { type ImageMetadata } from "./schema/image.js";
36
36
  import { type FileMetadata } from "./schema/file.js";
37
37
  import { isJson, getJsonImport, resolveJsonValues } from "./source/json.js";
@@ -114,6 +114,7 @@ declare const Internal: {
114
114
  getMimeType: typeof getMimeType;
115
115
  mimeTypeToFileExt: typeof mimeTypeToFileExt;
116
116
  filenameToMimeType: typeof filenameToMimeType;
117
+ mimeTypeMatchesAccept: typeof mimeTypeMatchesAccept;
117
118
  EXT_TO_MIME_TYPES: Record<string, string>;
118
119
  MIME_TYPES_TO_EXT: {
119
120
  [k: string]: string;
@@ -1,3 +1,17 @@
1
1
  export declare function getMimeType(base64Url: string): string | undefined;
2
2
  export declare function mimeTypeToFileExt(mimeType: string): string;
3
3
  export declare function filenameToMimeType(filename: string): string | undefined;
4
+ /**
5
+ * Whether `mimeType` satisfies an `accept` string.
6
+ *
7
+ * `accept` is the HTML file-input syntax: a comma-separated list of exact mime
8
+ * types (`image/png`), type wildcards (`image` followed by `/` and a star) or
9
+ * the catch-all star-slash-star.
10
+ *
11
+ * This lived in three places - `ImageSchema`, `FileSchema` and the media
12
+ * branch of `RecordSchema` - which is how the third copy grew a redundant
13
+ * `image` wildcard case that the general wildcard branch already covered.
14
+ * Anything that has to decide whether an `accept` is satisfied, validation and
15
+ * editor tooling alike, should call this.
16
+ */
17
+ export declare function mimeTypeMatchesAccept(mimeType: string, accept: string): boolean;