@happyvertical/smrt-assets-local 0.40.13 → 0.40.15

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/README.md +100 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # @happyvertical/smrt-assets-local
2
+
3
+ Local image processing for the s-m-r-t asset runtime. It extracts normalized image
4
+ metadata and generates deterministic WebP variants with Sharp, while asset
5
+ identity, storage, tenancy, and publishing policy remain owned by
6
+ [`@happyvertical/smrt-assets`](../assets/README.md).
7
+
8
+ Choose this adapter for local development, single-node deployments, and apps
9
+ that need practical image handling without a media-asset-management service.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pnpm add @happyvertical/smrt-assets @happyvertical/smrt-assets-local
15
+ ```
16
+
17
+ `sharp` is installed by this adapter and is not pulled into core s-m-r-t asset
18
+ consumers.
19
+
20
+ ## Quick start
21
+
22
+ ```ts
23
+ import { createAssetRuntime } from '@happyvertical/smrt-assets';
24
+ import { createLocalAssetProcessor } from '@happyvertical/smrt-assets-local';
25
+
26
+ const runtime = await createAssetRuntime({
27
+ db: 'assets.db',
28
+ storage: './data/assets',
29
+ capabilityProviders: [createLocalAssetProcessor()],
30
+ });
31
+
32
+ const source = await runtime.storeSourceAsset(
33
+ 'photo.png',
34
+ imageBytes,
35
+ { mimeType: 'image/png', typeSlug: 'image' },
36
+ );
37
+
38
+ const processed = await runtime.processAsset(source, {
39
+ variants: [{ variant: 'thumb' }, { variant: 'card' }],
40
+ });
41
+
42
+ console.log(processed.metadata, processed.variants);
43
+ ```
44
+
45
+ The processor saves normalized metadata onto the source asset and creates
46
+ derived assets linked back to that source.
47
+
48
+ ## Standard variants
49
+
50
+ | Name | Size | Fit |
51
+ | --- | --- | --- |
52
+ | `thumb` | 160×160 | `cover` |
53
+ | `card` | 480×270 | `cover` |
54
+ | `preview` | 960×960 | `inside` |
55
+ | `publish` | 1200×630 | `cover` |
56
+
57
+ Override presets or output quality when creating the processor:
58
+
59
+ ```ts
60
+ const processor = createLocalAssetProcessor({
61
+ quality: 85,
62
+ variants: {
63
+ card: { width: 640, height: 360, fit: 'cover' },
64
+ },
65
+ });
66
+ ```
67
+
68
+ Unknown variant names must provide explicit `width` and `height`. Repeated
69
+ requests reuse a matching derived asset when the source version and parameters
70
+ have not changed.
71
+
72
+ ## Metadata
73
+
74
+ `extractAssetImageMetadataFromBuffer()` normalizes orientation before reporting
75
+ dimensions and returns stable metadata for MIME type, dimensions, captured time,
76
+ and GPS coordinates when available. GPS values retain enough precision for
77
+ nearby-photo search.
78
+
79
+ Non-image assets are explicitly skipped so a later registered provider can
80
+ handle them.
81
+
82
+ ## Public API
83
+
84
+ | Export | Purpose |
85
+ | --- | --- |
86
+ | `createLocalAssetProcessor()` | Create an asset capability provider |
87
+ | `extractAssetImageMetadataFromBuffer()` | Extract normalized image metadata |
88
+ | `normalizeAssetImageMetadata()` | Normalize raw Sharp/EXIF metadata |
89
+ | `LocalAssetProcessorOptions` | Configure variant presets and quality |
90
+
91
+ ## Development
92
+
93
+ ```bash
94
+ pnpm --filter @happyvertical/smrt-assets-local test
95
+ pnpm --filter @happyvertical/smrt-assets-local typecheck
96
+ pnpm --filter @happyvertical/smrt-assets-local build
97
+ ```
98
+
99
+ See [`AGENTS.md`](./AGENTS.md) for determinism, metadata, and provider-boundary
100
+ requirements.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happyvertical/smrt-assets-local",
3
- "version": "0.40.13",
3
+ "version": "0.40.15",
4
4
  "description": "Local image metadata and variant processor for SMRT assets",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -19,14 +19,14 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "sharp": "^0.35.3",
22
- "@happyvertical/smrt-assets": "0.40.13"
22
+ "@happyvertical/smrt-assets": "0.40.15"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@happyvertical/sql": "^0.80.2",
26
26
  "@types/node": "24.13.2",
27
27
  "typescript": "5.9.3",
28
28
  "vitest": "4.1.10",
29
- "@happyvertical/smrt-core": "0.40.13"
29
+ "@happyvertical/smrt-core": "0.40.15"
30
30
  },
31
31
  "publishConfig": {
32
32
  "registry": "https://registry.npmjs.org",