@inlaylab/opaline-vue 0.0.0-stage → 1.1.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,24 @@
1
- # Temporary Holding Version
1
+ # @inlaylab/opaline-vue
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 Vue 3 and Nuxt. SSR-safe.
4
+
5
+ ```sh
6
+ npm i @inlaylab/opaline-vue
7
+ ```
8
+
9
+ ```vue
10
+ <script setup>
11
+ import { Avatar } from '@inlaylab/opaline-vue'
12
+ import { clay } from '@inlaylab/opaline/clay'
13
+ </script>
14
+
15
+ <template>
16
+ <Avatar :seed="user.email" :look="clay" :src="user.photo" :alt="user.name" />
17
+ </template>
18
+ ```
19
+
20
+ Props: `seed`, `look`, `size`, `src`, `alt`, and every core option. If you mount several Vue apps on one page, give each `app.config.idPrefix` so their gradient IDs cannot clash.
21
+
22
+ Same seed, same avatar: from 1.0, the same seed and options give a byte-identical SVG in every 1.x release.
23
+
24
+ [Playground and docs](https://inlaylab.github.io/Opaline/) · [GitHub](https://github.com/Inlaylab/Opaline) · MIT for code and art.
@@ -0,0 +1,49 @@
1
+ import { AuraOptions, ClayOptions, InitialsOptions, Style } from "@inlaylab/opaline";
2
+ import { PropType } from "vue";
3
+ type AvatarProps = {
4
+ seed: string | number | null | undefined;
5
+ /** The style object, e.g. `morph` from `@inlaylab/opaline/morph`. */
6
+ look: Style<any>;
7
+ size?: number;
8
+ /** Photo to show over the generated avatar once it loads. */
9
+ src?: string;
10
+ /** Accessible name. Without it the avatar is decorative and hidden from assistive tech. */
11
+ alt?: string;
12
+ } & ClayOptions & AuraOptions & InitialsOptions;
13
+ export declare const Avatar: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
14
+ seed: {
15
+ type: PropType<AvatarProps["seed"]>;
16
+ default: undefined;
17
+ };
18
+ look: {
19
+ type: PropType<Style<any>>;
20
+ required: true;
21
+ };
22
+ size: {
23
+ type: NumberConstructor;
24
+ default: number;
25
+ };
26
+ src: StringConstructor;
27
+ alt: StringConstructor;
28
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
29
+ [key: string]: any;
30
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
31
+ seed: {
32
+ type: PropType<AvatarProps["seed"]>;
33
+ default: undefined;
34
+ };
35
+ look: {
36
+ type: PropType<Style<any>>;
37
+ required: true;
38
+ };
39
+ size: {
40
+ type: NumberConstructor;
41
+ default: number;
42
+ };
43
+ src: StringConstructor;
44
+ alt: StringConstructor;
45
+ }>> & Readonly<{}>, {
46
+ seed: string | number | null | undefined;
47
+ size: number;
48
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
49
+ export type { AvatarProps };
package/dist/index.js ADDED
@@ -0,0 +1,88 @@
1
+ import { createAvatar } from "@inlaylab/opaline";
2
+ import { computed, defineComponent, h, onMounted, ref, useId } from "vue";
3
+ // src/photo.ts
4
+ const STYLE = {
5
+ position: "absolute",
6
+ inset: 0,
7
+ width: "100%",
8
+ height: "100%",
9
+ objectFit: "cover",
10
+ borderRadius: "inherit"
11
+ };
12
+ /** The photo stays hidden until it loads; a failed load leaves the generated avatar. */
13
+ const Photo = defineComponent({
14
+ props: { src: {
15
+ type: String,
16
+ required: true
17
+ } },
18
+ setup(props) {
19
+ const state = ref("loading");
20
+ const img = ref();
21
+ onMounted(() => {
22
+ if (img.value?.complete) state.value = img.value.naturalWidth > 0 ? "loaded" : "error";
23
+ });
24
+ return () => state.value === "error" ? null : h("img", {
25
+ ref: img,
26
+ src: props.src,
27
+ alt: "",
28
+ style: STYLE,
29
+ hidden: state.value !== "loaded",
30
+ onLoad: () => state.value = "loaded",
31
+ onError: () => state.value = "error"
32
+ });
33
+ }
34
+ });
35
+ // src/avatar.ts
36
+ const Avatar = defineComponent({
37
+ name: "OpalineAvatar",
38
+ inheritAttrs: false,
39
+ props: {
40
+ seed: {
41
+ type: [
42
+ String,
43
+ Number,
44
+ null
45
+ ],
46
+ default: void 0
47
+ },
48
+ look: {
49
+ type: Object,
50
+ required: true
51
+ },
52
+ size: {
53
+ type: Number,
54
+ default: 64
55
+ },
56
+ src: String,
57
+ alt: String
58
+ },
59
+ setup(props, { attrs }) {
60
+ const instance = useId();
61
+ const svg = computed(() => createAvatar(props.look, {
62
+ ...attrs,
63
+ seed: props.seed,
64
+ size: props.size,
65
+ instance
66
+ }).svg);
67
+ return () => h("span", {
68
+ "data-opaline": "",
69
+ style: {
70
+ display: "inline-block",
71
+ width: `${props.size}px`,
72
+ height: `${props.size}px`,
73
+ position: "relative"
74
+ },
75
+ ...props.alt ? {
76
+ role: "img",
77
+ "aria-label": props.alt
78
+ } : { "aria-hidden": "true" }
79
+ }, [h("span", {
80
+ style: { display: "contents" },
81
+ innerHTML: svg.value
82
+ }), props.src ? h(Photo, {
83
+ key: props.src,
84
+ src: props.src
85
+ }) : null]);
86
+ }
87
+ });
88
+ export { Avatar };
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "@inlaylab/opaline-vue",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.1.0",
4
+ "description": "Seeded avatars for Vue 3: 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
+ "vue",
15
+ "vue3",
16
+ "nuxt",
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/vue"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "type": "module",
33
+ "sideEffects": false,
34
+ "exports": {
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.js"
38
+ }
39
+ },
40
+ "files": [
41
+ "dist"
42
+ ],
43
+ "peerDependencies": {
44
+ "vue": ">=3.5"
45
+ },
46
+ "dependencies": {
47
+ "@inlaylab/opaline": "1.1.0"
48
+ },
49
+ "devDependencies": {
50
+ "@inlaylab/opaline-contract": "0.0.0",
51
+ "@vitest/browser-playwright": "^5.1.0",
52
+ "playwright": "^1.64.1",
53
+ "vue": "^3.5.44"
54
+ },
55
+ "scripts": {
56
+ "build": "tsdown",
57
+ "test": "vitest run",
58
+ "lint": "tsc -p tsconfig.json && prettier --check . --ignore-path ../../.prettierignore"
59
+ }
6
60
  }