@nomideusz/svelte-media 0.6.0 → 1.0.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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 1.0.0 — the promise, sized to the proven surface. Two production apps
8
+ consume the validation, media store, env adapters, storage keys,
9
+ remote-image fetching and serving daily; 53 tests cover them; that API is
10
+ now stable, and anything that breaks a consumer costs a major.
11
+
12
+ **Breaking: `ImageUpload` and `ImageGallery` leave the public API.** In two
13
+ consuming apps neither was ever rendered, and this package's own changelog
14
+ records that surface shipping broken twice precisely because nothing
15
+ consumed it (a `config` prop that was never read; a build failure nobody
16
+ hit). A 1.0 must not promise stability on components without a single real
17
+ consumer. The files remain in-repo for the demo; if an app one day wants
18
+ them, re-exporting is an additive minor made against a component that
19
+ consumer actually exercises.
20
+
3
21
  ## 0.6.0 — 2026-08-14
4
22
 
5
23
  Second pass of the same job 0.5.0 started: the parts of "handling images" both
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">let { images, getUrl, onDelete, size = "thumbnail" } = $props();
2
2
  let expanded = $state(null);
3
+ export {};
3
4
  </script>
4
5
 
5
6
  {#if images.length > 0}
@@ -1,36 +1,30 @@
1
1
  <script lang="ts">import { validateImageFile } from "../core/media.js";
2
- let {
3
- onUpload,
4
- onError,
5
- maxFiles = 1,
6
- accept = "image/jpeg,image/png,image/webp",
7
- config
8
- } = $props();
2
+ let { onUpload, onError, maxFiles = 1, accept = "image/jpeg,image/png,image/webp", config } = $props();
9
3
  let dragging = $state(false);
10
4
  let uploading = $state(false);
11
5
  let input;
12
6
  async function handleFiles(files) {
13
- if (!files || files.length === 0) return;
14
- uploading = true;
15
- try {
16
- for (const file of Array.from(files).slice(0, maxFiles)) {
17
- const validation = validateImageFile(file, config);
18
- if (!validation.valid) {
19
- onError?.(validation.error ?? "Invalid file");
20
- continue;
21
- }
22
- await onUpload(file);
23
- }
24
- } catch (e) {
25
- onError?.(e instanceof Error ? e.message : "Upload failed");
26
- } finally {
27
- uploading = false;
28
- }
7
+ if (!files || files.length === 0) return;
8
+ uploading = true;
9
+ try {
10
+ for (const file of Array.from(files).slice(0, maxFiles)) {
11
+ const validation = validateImageFile(file, config);
12
+ if (!validation.valid) {
13
+ onError?.(validation.error ?? "Invalid file");
14
+ continue;
15
+ }
16
+ await onUpload(file);
17
+ }
18
+ } catch (e) {
19
+ onError?.(e instanceof Error ? e.message : "Upload failed");
20
+ } finally {
21
+ uploading = false;
22
+ }
29
23
  }
30
24
  function onDrop(e) {
31
- e.preventDefault();
32
- dragging = false;
33
- handleFiles(e.dataTransfer?.files ?? null);
25
+ e.preventDefault();
26
+ dragging = false;
27
+ handleFiles(e.dataTransfer?.files ?? null);
34
28
  }
35
29
  </script>
36
30
 
@@ -1,6 +1,10 @@
1
1
  // Caching images that come from somewhere else — a paid photo API, a partner
2
2
  // CDN, a scraper. Server-only (sharp).
3
3
  //
4
+ // kit 3 claims any file named `remote.*` as a remote-functions module
5
+ // (pattern /[/.]remote\.[^/]+$/) and rejects its plain exports — hence
6
+ // `remote-images`, not `remote`.
7
+ //
4
8
  // Extracted from yoga's Google Places hero proxy, which was paying Google per
5
9
  // origin miss until it grew a bucket cache, a stampede lock and a transcode
6
10
  // step around it. All three are storage plumbing, not Places knowledge: what
@@ -1,5 +1,5 @@
1
1
  import type { ImageSize, MediaConfig, StorageAdapter, StorageObject, StoredMedia, ValidationResult } from './types.js';
2
- import { type CachedImageOptions, type ImageBytes } from './remote.js';
2
+ import { type CachedImageOptions, type ImageBytes } from './remote-images.js';
3
3
  export interface MediaStoreConfig<TDerived = never> extends MediaConfig<TDerived> {
4
4
  adapter: StorageAdapter;
5
5
  /**
@@ -1,7 +1,7 @@
1
1
  import { validateImageFile, variantKey } from './media.js';
2
2
  import { processAndStore, deleteMediaByKey } from './process.js';
3
3
  import { serveMedia } from './serve.js';
4
- import { cachedImage } from './remote.js';
4
+ import { cachedImage } from './remote-images.js';
5
5
  export function createMediaStore(config) {
6
6
  const { adapter, basePath, ...media } = config;
7
7
  const signer = adapter.getSignedUrl?.bind(adapter);
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" preserve="true" />
1
2
  export type ImageSize = 'original' | 'thumbnail' | 'medium' | 'large';
2
3
  /** What `StorageAdapter.get` resolves for an existing object. */
3
4
  export interface StorageObject {
@@ -1,2 +1,3 @@
1
1
  // packages/svelte-media/src/lib/core/types.ts
2
+ /// <reference types="node" preserve="true" />
2
3
  export {};
package/dist/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
1
  export type { StorageAdapter, S3Adapter, S3Config, StorageObject, StoredMedia, ImageSize, MediaConfig, ValidationResult, ValidationConfig, ValidationErrorCode, DeriveSource, } from './core/types.js';
2
2
  export { validateImageFile, MediaValidationError, generateMediaKey, getStorageKey, variantKey, sizeForWidth, parseStorageKey, IMAGE_SIZES, SIZE_PREFIXES, SIZE_QUALITY, DEFAULT_MAX_SIZE, DEFAULT_ALLOWED_TYPES, } from './core/media.js';
3
- export { default as ImageUpload } from './components/ImageUpload.svelte';
4
- export { default as ImageGallery } from './components/ImageGallery.svelte';
package/dist/index.js CHANGED
@@ -2,5 +2,7 @@
2
2
  // node:fs and Buffer, so they live behind '@nomideusz/svelte-media/server' —
3
3
  // importing them here would break any browser bundle that touches a component.
4
4
  export { validateImageFile, MediaValidationError, generateMediaKey, getStorageKey, variantKey, sizeForWidth, parseStorageKey, IMAGE_SIZES, SIZE_PREFIXES, SIZE_QUALITY, DEFAULT_MAX_SIZE, DEFAULT_ALLOWED_TYPES, } from './core/media.js';
5
- export { default as ImageUpload } from './components/ImageUpload.svelte';
6
- export { default as ImageGallery } from './components/ImageGallery.svelte';
5
+ // ImageUpload / ImageGallery left the public API at 1.0: in two consuming
6
+ // apps neither was ever rendered, and this package's own changelog records
7
+ // the surface shipping broken twice precisely because nothing consumed it.
8
+ // The files remain for the demo; re-exporting later is an additive minor.
@@ -3,8 +3,8 @@ export { createS3Adapter } from '../core/adapter.js';
3
3
  export { createLocalAdapter } from '../core/local-adapter.js';
4
4
  export { adapterFromEnv } from '../core/env.js';
5
5
  export type { EnvAdapterOptions, EnvSource } from '../core/env.js';
6
- export { cachedImage, fetchImage, toWebp } from '../core/remote.js';
7
- export type { CachedImageOptions, FetchImageOptions, ImageBytes } from '../core/remote.js';
6
+ export { cachedImage, fetchImage, toWebp } from '../core/remote-images.js';
7
+ export type { CachedImageOptions, FetchImageOptions, ImageBytes } from '../core/remote-images.js';
8
8
  export { processAndStore, deleteMedia, deleteMediaByKey, getMediaUrl } from '../core/process.js';
9
9
  export { serveMedia } from '../core/serve.js';
10
10
  export { createMediaStore } from '../core/store.js';
@@ -2,7 +2,7 @@
2
2
  export { createS3Adapter } from '../core/adapter.js';
3
3
  export { createLocalAdapter } from '../core/local-adapter.js';
4
4
  export { adapterFromEnv } from '../core/env.js';
5
- export { cachedImage, fetchImage, toWebp } from '../core/remote.js';
5
+ export { cachedImage, fetchImage, toWebp } from '../core/remote-images.js';
6
6
  export { processAndStore, deleteMedia, deleteMediaByKey, getMediaUrl } from '../core/process.js';
7
7
  export { serveMedia } from '../core/serve.js';
8
8
  export { createMediaStore } from '../core/store.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nomideusz/svelte-media",
3
- "version": "0.6.0",
3
+ "version": "1.0.0",
4
4
  "description": "Image upload, processing, and S3-compatible storage for Svelte 5 apps.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -24,19 +24,12 @@
24
24
  "!dist/**/*.test.*",
25
25
  "!dist/**/*.spec.*"
26
26
  ],
27
- "scripts": {
28
- "dev": "vite dev",
29
- "build": "vite build",
30
- "package": "svelte-kit sync && svelte-package",
31
- "prepublishOnly": "npm run package",
32
- "preview": "vite preview",
33
- "prepare": "svelte-kit sync || echo ''",
34
- "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
35
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
36
- "test": "vitest run --passWithNoTests",
37
- "test:watch": "vitest"
27
+ "imports": {
28
+ "#lib": "./src/lib",
29
+ "#lib/*": "./src/lib/*"
38
30
  },
39
31
  "peerDependencies": {
32
+ "@types/node": ">=20",
40
33
  "svelte": "^5.0.0"
41
34
  },
42
35
  "dependencies": {
@@ -46,15 +39,16 @@
46
39
  "sharp": "^0.34.5"
47
40
  },
48
41
  "devDependencies": {
49
- "@sveltejs/adapter-auto": "^7.0.1",
50
- "@sveltejs/kit": "^2.70.2",
51
- "@sveltejs/package": "^2.5.8",
52
- "@sveltejs/vite-plugin-svelte": "^6.2.4",
42
+ "@sveltejs/adapter-auto": "8.0.0-next.3",
43
+ "@sveltejs/adapter-vercel": "7.0.0-next.6",
44
+ "@sveltejs/kit": "3.0.0-next.23",
45
+ "@sveltejs/package": "3.0.0-next.7",
46
+ "@sveltejs/vite-plugin-svelte": "^7.3.0",
53
47
  "@types/node": "^25.9.4",
54
48
  "svelte": "^5.56.9",
55
49
  "svelte-check": "^4.7.1",
56
- "typescript": "^5.9.3",
57
- "vite": "^7.3.6",
50
+ "typescript": "^6.0.3",
51
+ "vite": "^8.2.1",
58
52
  "vitest": "^4.1.10"
59
53
  },
60
54
  "keywords": [
@@ -69,5 +63,20 @@
69
63
  "type": "git",
70
64
  "url": "https://github.com/nomideusz/svelte-media"
71
65
  },
72
- "homepage": "https://svelte-media-gamma.vercel.app/"
73
- }
66
+ "homepage": "https://svelte-media-gamma.vercel.app/",
67
+ "peerDependenciesMeta": {
68
+ "@types/node": {
69
+ "optional": true
70
+ }
71
+ },
72
+ "scripts": {
73
+ "dev": "vite dev",
74
+ "build": "vite build",
75
+ "package": "svelte-kit sync && svelte-package",
76
+ "preview": "vite preview",
77
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
78
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
79
+ "test": "vitest run --passWithNoTests",
80
+ "test:watch": "vitest"
81
+ }
82
+ }
File without changes