@larkup/marketplace 0.1.19 → 0.1.20

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @larkup/marketplace
2
2
 
3
+ ## 0.1.20
4
+
5
+ ### Patch Changes
6
+
7
+ - 7601d83: Update Video & Audio from the Media page when an installed tool is stale, and prefer the newest marketplace catalog version so packaged ffmpeg helpers load correctly after installation.
8
+
3
9
  ## 0.1.19
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@larkup/marketplace",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -23,6 +23,46 @@ import { DEFAULT_HUB_URL } from './types';
23
23
  /** Cached registry — populated on first access. */
24
24
  let cachedRegistry: Record<string, ToolDescriptor> | null = null;
25
25
 
26
+ /**
27
+ * Compare the numeric portions of two semver versions. Marketplace manifests
28
+ * use stable releases, but accepting a suffix keeps a pre-release catalog
29
+ * entry from incorrectly outranking its corresponding stable release.
30
+ */
31
+ function compareToolVersions(left: string, right: string): number {
32
+ const parse = (version: string) => {
33
+ const [core, suffix = ''] = version.split('-', 2);
34
+ const parts = core.split('.').map((part) => Number.parseInt(part, 10) || 0);
35
+ return { parts, stable: suffix.length === 0 };
36
+ };
37
+ const a = parse(left);
38
+ const b = parse(right);
39
+ const length = Math.max(a.parts.length, b.parts.length);
40
+ for (let index = 0; index < length; index += 1) {
41
+ const difference = (a.parts[index] ?? 0) - (b.parts[index] ?? 0);
42
+ if (difference !== 0) return difference;
43
+ }
44
+ if (a.stable === b.stable) return 0;
45
+ return a.stable ? 1 : -1;
46
+ }
47
+
48
+ /**
49
+ * Merge catalog entries without allowing an older Hub response or an already
50
+ * installed package to downgrade the version users are offered.
51
+ */
52
+ export function mergeToolDescriptors(
53
+ current: Record<string, ToolDescriptor>,
54
+ incoming: Record<string, ToolDescriptor>,
55
+ ): Record<string, ToolDescriptor> {
56
+ const merged = { ...current };
57
+ for (const [id, descriptor] of Object.entries(incoming)) {
58
+ const existing = merged[id];
59
+ if (!existing || compareToolVersions(descriptor.version, existing.version) >= 0) {
60
+ merged[id] = descriptor;
61
+ }
62
+ }
63
+ return merged;
64
+ }
65
+
26
66
  /**
27
67
  * Scan workspace tool directories for `tool.manifest.json` files.
28
68
  * This is used in monorepo development and in Docker builds where
@@ -143,7 +183,7 @@ const FALLBACK_REGISTRY: Record<string, ToolDescriptor> = {
143
183
  name: 'Video & Audio',
144
184
  description: 'Index video and audio files with transcription and frame analysis.',
145
185
  category: 'media',
146
- version: '0.3.2',
186
+ version: '0.3.4',
147
187
  pricing: 'free',
148
188
  emoji: '🎬',
149
189
  icon: 'Film',
@@ -257,19 +297,19 @@ export async function buildRegistry(opts?: {
257
297
  }): Promise<Record<string, ToolDescriptor>> {
258
298
  if (cachedRegistry) return cachedRegistry;
259
299
 
260
- // Start with hardcoded fallback
261
- const registry = { ...FALLBACK_REGISTRY };
300
+ // Start with hardcoded fallback.
301
+ let registry = { ...FALLBACK_REGISTRY };
262
302
 
263
303
  // Layer Hub API catalog over the offline fallback.
264
304
  if (!opts?.skipHub) {
265
305
  const hubCatalog = await fetchHubCatalog(opts?.hubUrl);
266
- Object.assign(registry, hubCatalog);
306
+ registry = mergeToolDescriptors(registry, hubCatalog);
267
307
  }
268
308
 
269
- // Local (including installed) manifests are the source of truth. This also
270
- // prevents a stale Hub descriptor from reintroducing obsolete system deps.
309
+ // A local workspace manifest wins on equal versions, while an older
310
+ // installed package cannot hide a newer catalog release that repairs it.
271
311
  const localManifests = await discoverLocalManifests();
272
- Object.assign(registry, localManifests);
312
+ registry = mergeToolDescriptors(registry, localManifests);
273
313
 
274
314
  cachedRegistry = registry;
275
315
  return registry;