@inlaylab/opaline-svelte 0.0.0-stage → 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Inlaylab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,22 @@
1
- # Temporary Holding Version
1
+ # @inlaylab/opaline-svelte
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Seeded avatars for Svelte 5 and SvelteKit. Built with runes, SSR-safe.
4
+
5
+ ```sh
6
+ npm i @inlaylab/opaline-svelte
7
+ ```
8
+
9
+ ```svelte
10
+ <script>
11
+ import { Avatar } from '@inlaylab/opaline-svelte'
12
+ import { clay } from '@inlaylab/opaline/clay'
13
+ </script>
14
+
15
+ <Avatar seed={user.email} look={clay} src={user.photo} alt={user.name} />
16
+ ```
17
+
18
+ Props: `seed`, `look`, `size`, `src`, `alt`, and every core option.
19
+
20
+ Same seed, same avatar: from 1.0, the same seed and options give a byte-identical SVG in every 1.x release.
21
+
22
+ [Playground and docs](https://inlaylab.github.io/Opaline/) · [GitHub](https://github.com/Inlaylab/Opaline) · MIT for code and art.
@@ -0,0 +1,26 @@
1
+ <script lang="ts">
2
+ import { createAvatar } from '@inlaylab/opaline'
3
+ import Photo from './Photo.svelte'
4
+ import type { AvatarProps } from './types.js'
5
+
6
+ let { look, size = 64, src, alt, ...options }: AvatarProps = $props()
7
+ // $props.id() matches on server and client, so hydration keeps the same gradient IDs.
8
+ const instance = $props.id()
9
+ // Safe to inject: the core escapes every input that reaches the SVG.
10
+ const svg = $derived(createAvatar(look, { ...options, size, instance }).svg)
11
+ </script>
12
+
13
+ <span
14
+ data-opaline=""
15
+ style="display:inline-block;width:{size}px;height:{size}px;position:relative"
16
+ role={alt ? 'img' : undefined}
17
+ aria-label={alt || undefined}
18
+ aria-hidden={alt ? undefined : 'true'}
19
+ >
20
+ <span style="display:contents">{@html svg}</span>
21
+ {#if src}
22
+ {#key src}
23
+ <Photo {src} />
24
+ {/key}
25
+ {/if}
26
+ </span>
@@ -0,0 +1,4 @@
1
+ import type { AvatarProps } from './types.js';
2
+ declare const Avatar: import("svelte").Component<AvatarProps, {}, "">;
3
+ type Avatar = ReturnType<typeof Avatar>;
4
+ export default Avatar;
@@ -0,0 +1,25 @@
1
+ <script lang="ts">
2
+ import { onMount } from 'svelte'
3
+
4
+ let { src }: { src: string } = $props()
5
+ let status = $state<'loading' | 'loaded' | 'error'>('loading')
6
+ let img = $state<HTMLImageElement>()
7
+
8
+ onMount(() => {
9
+ // With SSR the image can finish before hydration, so its load event is missed.
10
+ if (img?.complete) status = img.naturalWidth > 0 ? 'loaded' : 'error'
11
+ })
12
+ </script>
13
+
14
+ <!-- The photo stays hidden until it loads; a failed load leaves the generated avatar. -->
15
+ {#if status !== 'error'}
16
+ <img
17
+ bind:this={img}
18
+ {src}
19
+ alt=""
20
+ style="position:absolute;inset:0;width:100%;height:100%;object-fit:cover;border-radius:inherit"
21
+ hidden={status !== 'loaded'}
22
+ onload={() => (status = 'loaded')}
23
+ onerror={() => (status = 'error')}
24
+ />
25
+ {/if}
@@ -0,0 +1,6 @@
1
+ type $$ComponentProps = {
2
+ src: string;
3
+ };
4
+ declare const Photo: import("svelte").Component<$$ComponentProps, {}, "">;
5
+ type Photo = ReturnType<typeof Photo>;
6
+ export default Photo;
@@ -0,0 +1,2 @@
1
+ export { default as Avatar } from './Avatar.svelte';
2
+ export type { AvatarProps } from './types.js';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default as Avatar } from './Avatar.svelte';
@@ -0,0 +1,11 @@
1
+ import type { AuraOptions, ClayOptions, Style } from '@inlaylab/opaline';
2
+ export type AvatarProps = {
3
+ seed: string | number | null | undefined;
4
+ /** The style object, e.g. `morph` from `@inlaylab/opaline/morph`. */
5
+ look: Style<any>;
6
+ size?: number;
7
+ /** Photo to show over the generated avatar once it loads. */
8
+ src?: string;
9
+ /** Accessible name. Without it the avatar is decorative and hidden from assistive tech. */
10
+ alt?: string;
11
+ } & ClayOptions & AuraOptions;
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,64 @@
1
1
  {
2
2
  "name": "@inlaylab/opaline-svelte",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "Seeded avatars for Svelte 5: an SSR-safe Avatar component.",
5
+ "keywords": [
6
+ "avatar",
7
+ "avatars",
8
+ "svg",
9
+ "seed",
10
+ "deterministic",
11
+ "identicon",
12
+ "profile-picture",
13
+ "placeholder",
14
+ "svelte",
15
+ "svelte5",
16
+ "sveltekit",
17
+ "ssr"
18
+ ],
19
+ "homepage": "https://inlaylab.github.io/Opaline/",
20
+ "bugs": {
21
+ "url": "https://github.com/Inlaylab/Opaline/issues"
22
+ },
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/Inlaylab/Opaline.git",
27
+ "directory": "packages/svelte"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "type": "module",
33
+ "sideEffects": false,
34
+ "svelte": "./dist/index.js",
35
+ "exports": {
36
+ ".": {
37
+ "types": "./dist/index.d.ts",
38
+ "svelte": "./dist/index.js"
39
+ }
40
+ },
41
+ "files": [
42
+ "dist"
43
+ ],
44
+ "peerDependencies": {
45
+ "svelte": ">=5.20"
46
+ },
47
+ "dependencies": {
48
+ "@inlaylab/opaline": "1.0.0"
49
+ },
50
+ "devDependencies": {
51
+ "@inlaylab/opaline-contract": "0.0.0",
52
+ "@sveltejs/package": "^3.0.2",
53
+ "@sveltejs/vite-plugin-svelte": "^7.3.1",
54
+ "@vitest/browser-playwright": "^5.1.0",
55
+ "playwright": "^1.64.1",
56
+ "svelte": "^5.57.3",
57
+ "svelte-check": "^4.7.8"
58
+ },
59
+ "scripts": {
60
+ "build": "svelte-package -i src/lib -o dist",
61
+ "test": "vitest run",
62
+ "lint": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings && prettier --check . --ignore-path ../../.prettierignore"
63
+ }
6
64
  }