@vardum/shared 0.2.0 → 0.3.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/README.md CHANGED
@@ -4,6 +4,15 @@ Wire types and the accepted-format tables shared by the Vardum API, dashboard,
4
4
  CLI and MCP server. Published because `@vardum/cli` and `@vardum/mcp` depend on
5
5
  it at runtime; it carries no dependencies of its own.
6
6
 
7
+ This README describes shared **0.3.0**. It adds the exported `mediaStem` and `mediaOutputPath`
8
+ helpers used by the CLI and API for consistent media names and output suffixes.
9
+ The published client baseline uses shared **0.2.0**; see
10
+ [release compatibility](https://github.com/f-tuma/vardum/blob/main/docs/npm-release.md#compatibility)
11
+ for the corresponding CLI/MCP versions and unreleased candidates.
12
+
13
+ CLI 0.7.0 and MCP 0.3.0 retain `workspace:^` dependencies in source; the release
14
+ archives require `@vardum/shared: ^0.3.0`, which npm resolves transitively.
15
+
7
16
  ```ts
8
17
  import { mimeForFilename, supportedMimeTypes, type VardManifest } from "@vardum/shared";
9
18
  ```
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./mime.js";
2
+ export * from "./naming.js";
2
3
  export * from "./wire.js";
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./mime.js";
2
+ export * from "./naming.js";
2
3
  export * from "./wire.js";
package/dist/mime.js CHANGED
@@ -48,7 +48,9 @@ export const extensionMimeTypes = {
48
48
  };
49
49
  export function mimeForFilename(filename) {
50
50
  const extension = filename.toLowerCase().match(/\.([^.]+)$/)?.[1];
51
- return (extension && extensionMimeTypes[extension]) || null;
51
+ return extension && Object.hasOwn(extensionMimeTypes, extension)
52
+ ? extensionMimeTypes[extension]
53
+ : null;
52
54
  }
53
55
  /** Value for a file input's accept attribute, e.g. ".avif,.gif,…". */
54
56
  export const uploadAccept = Object.keys(extensionMimeTypes)
@@ -0,0 +1,4 @@
1
+ /** Strip the final supported media suffix, never dots in a directory or stem. */
2
+ export declare function mediaStem(path: string): string;
3
+ /** Project files keep one suffix for their output format; library names do not. */
4
+ export declare function mediaOutputPath(path: string, mimeType: string): string;
package/dist/naming.js ADDED
@@ -0,0 +1,22 @@
1
+ import { mimeForFilename } from "./mime.js";
2
+ /** Strip the final supported media suffix, never dots in a directory or stem. */
3
+ export function mediaStem(path) {
4
+ const start = path.lastIndexOf("/") + 1;
5
+ const dot = path.lastIndexOf(".");
6
+ return dot > start && mimeForFilename(path.slice(start))
7
+ ? path.slice(0, dot)
8
+ : path;
9
+ }
10
+ const mimeExtensions = {
11
+ "image/avif": "avif", "image/gif": "gif", "image/jpeg": "jpg",
12
+ "image/png": "png", "image/svg+xml": "svg", "image/tiff": "tiff",
13
+ "image/webp": "webp", "video/mp4": "mp4", "video/webm": "webm",
14
+ "video/quicktime": "mov", "video/x-msvideo": "avi", "video/mpeg": "mpeg",
15
+ };
16
+ /** Project files keep one suffix for their output format; library names do not. */
17
+ export function mediaOutputPath(path, mimeType) {
18
+ const extension = Object.hasOwn(mimeExtensions, mimeType)
19
+ ? mimeExtensions[mimeType]
20
+ : undefined;
21
+ return extension ? `${mediaStem(path)}.${extension}` : path;
22
+ }
package/dist/wire.d.ts CHANGED
@@ -20,6 +20,8 @@ export type VardItem = {
20
20
  transformation: Transformation | null;
21
21
  versionId: string | null;
22
22
  sourceChecksum: string | null;
23
+ /** Original selected version's type, before any output transformation. */
24
+ sourceMimeType?: string | null;
23
25
  mimeType: string | null;
24
26
  size: number | null;
25
27
  fingerprint: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vardum/shared",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Shared Vardum wire types and accepted-format tables",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,12 +22,12 @@
22
22
  },
23
23
  "repository": {
24
24
  "type": "git",
25
- "url": "git+https://github.com/frgtn-dot-dev/vardum.git",
25
+ "url": "git+https://github.com/f-tuma/vardum.git",
26
26
  "directory": "packages/shared"
27
27
  },
28
- "homepage": "https://github.com/frgtn-dot-dev/vardum/tree/main/packages/shared#readme",
28
+ "homepage": "https://github.com/f-tuma/vardum/tree/main/packages/shared#readme",
29
29
  "bugs": {
30
- "url": "https://github.com/frgtn-dot-dev/vardum/issues"
30
+ "url": "https://github.com/f-tuma/vardum/issues"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsc -p tsconfig.json",