@pezkuwi/vue-identicon 3.16.8 → 3.17.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/{cjs → build}/Identicon.d.ts +2 -2
- package/build/Identicon.js +117 -0
- package/build/README.md +37 -0
- package/{bundle-pezkuwi-vue-identicon.js → build/bundle-pezkuwi-vue-identicon.js} +16 -14
- package/build/bundle.js +2 -0
- package/build/cjs/Identicon.d.ts +28 -0
- package/build/cjs/Identicon.js +121 -0
- package/build/cjs/bundle.d.ts +2 -0
- package/build/cjs/bundle.js +7 -0
- package/build/cjs/icons/Beachball.js +21 -0
- package/build/cjs/icons/Empty.js +16 -0
- package/build/cjs/icons/Jdenticon.js +19 -0
- package/{icons/Polkadot.d.ts → build/cjs/icons/Pezkuwi.d.ts} +3 -3
- package/build/cjs/icons/Pezkuwi.js +24 -0
- package/{icons → build/cjs/icons}/index.d.ts +1 -1
- package/build/cjs/icons/index.js +7 -0
- package/build/cjs/index.js +7 -0
- package/build/cjs/packageInfo.js +4 -0
- package/build/cjs/util.js +15 -0
- package/build/icons/Beachball.d.ts +17 -0
- package/build/icons/Beachball.js +18 -0
- package/build/icons/Empty.d.ts +11 -0
- package/build/icons/Empty.js +13 -0
- package/build/icons/Jdenticon.d.ts +14 -0
- package/build/icons/Jdenticon.js +15 -0
- package/build/icons/Pezkuwi.d.ts +17 -0
- package/build/icons/Pezkuwi.js +21 -0
- package/build/icons/index.d.ts +4 -0
- package/build/icons/index.js +4 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +4 -0
- package/build/package.json +213 -0
- package/build/packageDetect.d.ts +1 -0
- package/build/packageDetect.js +4 -0
- package/build/packageInfo.d.ts +6 -0
- package/build/packageInfo.js +1 -0
- package/build/util.d.ts +6 -0
- package/build/util.js +12 -0
- package/{Identicon.d.ts → build-tsc/Identicon.d.ts} +2 -2
- package/{cjs/icons/Polkadot.d.ts → build-tsc/icons/Pezkuwi.d.ts} +3 -3
- package/{cjs → build-tsc}/icons/index.d.ts +1 -1
- package/{cjs → build-tsc-cjs}/Identicon.js +12 -6
- package/{cjs/icons/Polkadot.js → build-tsc-cjs/icons/Pezkuwi.js} +5 -5
- package/{cjs → build-tsc-cjs}/icons/index.js +1 -1
- package/build-tsc-cjs/packageDetect.js +6 -0
- package/{cjs → build-tsc-cjs}/packageInfo.js +1 -1
- package/{Identicon.js → build-tsc-esm/Identicon.js} +13 -7
- package/{icons/Polkadot.js → build-tsc-esm/icons/Pezkuwi.js} +5 -5
- package/{icons → build-tsc-esm/icons}/index.js +1 -1
- package/{packageInfo.js → build-tsc-esm/packageInfo.js} +1 -1
- package/index.html +17 -0
- package/package.json +6 -181
- package/src/Identicon.ts +149 -0
- package/src/bundle.ts +5 -0
- package/src/icons/Beachball.ts +32 -0
- package/src/icons/Empty.ts +17 -0
- package/src/icons/Jdenticon.ts +27 -0
- package/src/icons/Pezkuwi.ts +38 -0
- package/src/icons/index.ts +7 -0
- package/src/index.ts +10 -0
- package/src/packageDetect.ts +12 -0
- package/src/packageInfo.ts +6 -0
- package/src/util.ts +17 -0
- package/tsconfig.build.json +11 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- /package/{LICENSE → build/LICENSE} +0 -0
- /package/{cjs → build}/bundle.d.ts +0 -0
- /package/{icons → build/cjs/icons}/Beachball.d.ts +0 -0
- /package/{icons → build/cjs/icons}/Empty.d.ts +0 -0
- /package/{icons → build/cjs/icons}/Jdenticon.d.ts +0 -0
- /package/{index.d.ts → build/cjs/index.d.ts} +0 -0
- /package/{cjs → build/cjs}/package.json +0 -0
- /package/{packageDetect.d.ts → build/cjs/packageDetect.d.ts} +0 -0
- /package/{cjs → build/cjs}/packageDetect.js +0 -0
- /package/{packageInfo.d.ts → build/cjs/packageInfo.d.ts} +0 -0
- /package/{util.d.ts → build/cjs/util.d.ts} +0 -0
- /package/{bundle.d.ts → build-tsc/bundle.d.ts} +0 -0
- /package/{cjs → build-tsc}/icons/Beachball.d.ts +0 -0
- /package/{cjs → build-tsc}/icons/Empty.d.ts +0 -0
- /package/{cjs → build-tsc}/icons/Jdenticon.d.ts +0 -0
- /package/{cjs → build-tsc}/index.d.ts +0 -0
- /package/{cjs → build-tsc}/packageDetect.d.ts +0 -0
- /package/{cjs → build-tsc}/packageInfo.d.ts +0 -0
- /package/{cjs → build-tsc}/util.d.ts +0 -0
- /package/{cjs → build-tsc-cjs}/bundle.js +0 -0
- /package/{cjs → build-tsc-cjs}/icons/Beachball.js +0 -0
- /package/{cjs → build-tsc-cjs}/icons/Empty.js +0 -0
- /package/{cjs → build-tsc-cjs}/icons/Jdenticon.js +0 -0
- /package/{cjs → build-tsc-cjs}/index.js +0 -0
- /package/{cjs → build-tsc-cjs}/util.js +0 -0
- /package/{bundle.js → build-tsc-esm/bundle.js} +0 -0
- /package/{icons → build-tsc-esm/icons}/Beachball.js +0 -0
- /package/{icons → build-tsc-esm/icons}/Empty.js +0 -0
- /package/{icons → build-tsc-esm/icons}/Jdenticon.js +0 -0
- /package/{index.js → build-tsc-esm/index.js} +0 -0
- /package/{packageDetect.js → build-tsc-esm/packageDetect.js} +0 -0
- /package/{util.js → build-tsc-esm/util.js} +0 -0
|
@@ -8,7 +8,7 @@ interface Data {
|
|
|
8
8
|
iconSize: number;
|
|
9
9
|
isAlternativeIcon: boolean;
|
|
10
10
|
publicKey: string;
|
|
11
|
-
type: 'beachball' | 'empty' | 'jdenticon' | '
|
|
11
|
+
type: 'beachball' | 'empty' | 'jdenticon' | 'pezkuwi' | 'bizinikiwi';
|
|
12
12
|
}
|
|
13
13
|
export declare function encodeAccount(value: string | Uint8Array, prefix?: Prefix): Account;
|
|
14
14
|
/**
|
|
@@ -16,7 +16,7 @@ export declare function encodeAccount(value: string | Uint8Array, prefix?: Prefi
|
|
|
16
16
|
* @description The main Identicon component, taking a number of properties
|
|
17
17
|
* @example
|
|
18
18
|
* ```html
|
|
19
|
-
* <Identicon :size="128" :theme="
|
|
19
|
+
* <Identicon :size="128" :theme="pezkuwi" :value="..." />
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export declare const Identicon: import("vue").DefineComponent<string[], {}, Data, {}, {
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { isHex, isU8a, u8aToHex } from '@pezkuwi/util';
|
|
3
|
+
import { decodeAddress, encodeAddress, isEthereumAddress } from '@pezkuwi/util-crypto';
|
|
4
|
+
import { Beachball, Empty, Jdenticon, Pezkuwi } from './icons/index.js';
|
|
5
|
+
import { adaptVNodeAttrs } from './util.js';
|
|
6
|
+
const DEFAULT_SIZE = 64;
|
|
7
|
+
function resolvePublicKey(value, prefix) {
|
|
8
|
+
if (isHex(value) && isEthereumAddress(value)) {
|
|
9
|
+
return value.padEnd(66, '0');
|
|
10
|
+
}
|
|
11
|
+
return isU8a(value) || isHex(value)
|
|
12
|
+
? encodeAddress(value, prefix)
|
|
13
|
+
: value;
|
|
14
|
+
}
|
|
15
|
+
export function encodeAccount(value, prefix) {
|
|
16
|
+
try {
|
|
17
|
+
const address = resolvePublicKey(value, prefix);
|
|
18
|
+
const publicKey = u8aToHex(decodeAddress(address, false, prefix));
|
|
19
|
+
return { address, publicKey };
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return { address: '', publicKey: '0x' };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @name Identicon
|
|
27
|
+
* @description The main Identicon component, taking a number of properties
|
|
28
|
+
* @example
|
|
29
|
+
* ```html
|
|
30
|
+
* <Identicon :size="128" :theme="pezkuwi" :value="..." />
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export const Identicon = defineComponent({
|
|
34
|
+
components: {
|
|
35
|
+
Beachball,
|
|
36
|
+
Empty,
|
|
37
|
+
Jdenticon,
|
|
38
|
+
Pezkuwi
|
|
39
|
+
},
|
|
40
|
+
created: function () {
|
|
41
|
+
this.createData();
|
|
42
|
+
},
|
|
43
|
+
data: function () {
|
|
44
|
+
return {
|
|
45
|
+
address: '',
|
|
46
|
+
iconSize: DEFAULT_SIZE,
|
|
47
|
+
isAlternativeIcon: false,
|
|
48
|
+
publicKey: '0x',
|
|
49
|
+
type: 'empty'
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
methods: {
|
|
53
|
+
createData: function () {
|
|
54
|
+
this.iconSize = this.size || DEFAULT_SIZE;
|
|
55
|
+
this.type = this.theme;
|
|
56
|
+
this.isAlternativeIcon = this.isAlternative || false;
|
|
57
|
+
this.recodeAddress();
|
|
58
|
+
},
|
|
59
|
+
recodeAddress: function () {
|
|
60
|
+
const { address, publicKey } = encodeAccount(this.value);
|
|
61
|
+
this.address = address;
|
|
62
|
+
this.publicKey = publicKey;
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
props: ['prefix', 'isAlternative', 'size', 'theme', 'value'],
|
|
66
|
+
render() {
|
|
67
|
+
const { address, iconSize, isAlternativeIcon, publicKey, type } = this.$data;
|
|
68
|
+
if (type === 'empty') {
|
|
69
|
+
return h(Empty, {
|
|
70
|
+
...adaptVNodeAttrs({
|
|
71
|
+
key: address,
|
|
72
|
+
size: iconSize
|
|
73
|
+
})
|
|
74
|
+
}, []);
|
|
75
|
+
}
|
|
76
|
+
else if (type === 'jdenticon') {
|
|
77
|
+
return h(Jdenticon, {
|
|
78
|
+
...adaptVNodeAttrs({
|
|
79
|
+
key: address,
|
|
80
|
+
publicKey,
|
|
81
|
+
size: iconSize
|
|
82
|
+
})
|
|
83
|
+
}, []);
|
|
84
|
+
}
|
|
85
|
+
else if (type === 'bizinikiwi') {
|
|
86
|
+
return h(Jdenticon, {
|
|
87
|
+
...adaptVNodeAttrs({
|
|
88
|
+
key: address,
|
|
89
|
+
publicKey,
|
|
90
|
+
size: iconSize
|
|
91
|
+
})
|
|
92
|
+
}, []);
|
|
93
|
+
}
|
|
94
|
+
const cmp = type.charAt(0).toUpperCase() + type.slice(1);
|
|
95
|
+
if (['Beachball', 'Pezkuwi'].includes(cmp)) {
|
|
96
|
+
const component = cmp === 'Beachball'
|
|
97
|
+
? Beachball
|
|
98
|
+
: Pezkuwi;
|
|
99
|
+
return h(component, {
|
|
100
|
+
...adaptVNodeAttrs({
|
|
101
|
+
address,
|
|
102
|
+
isAlternative: isAlternativeIcon,
|
|
103
|
+
key: address,
|
|
104
|
+
size: iconSize
|
|
105
|
+
})
|
|
106
|
+
}, []);
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
return h(cmp, {}, []);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
watch: {
|
|
113
|
+
value: function () {
|
|
114
|
+
this.recodeAddress();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
});
|
package/build/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# @pezkuwi/vue-identicon
|
|
2
|
+
|
|
3
|
+
A generic identity icon that can render icons based on an address.
|
|
4
|
+
|
|
5
|
+
## Usage Examples
|
|
6
|
+
|
|
7
|
+
To install the component, do `yarn add @pezkuwi/vue-identicon` and then use it with `import Identicon from '@pezkuwi/vue-identicon';`
|
|
8
|
+
|
|
9
|
+
Inside a Vue component, you can now render any account with the associated icon, with associated props -
|
|
10
|
+
|
|
11
|
+
- `value` - the address you wish to display
|
|
12
|
+
- `size` (optional, defaults to `64`) - the size in pixels
|
|
13
|
+
- `theme` (optional, defaults to `substrate`) - the theme to use, one of
|
|
14
|
+
- `polkadot` or
|
|
15
|
+
- `substrate` (equivalent to `jdenticon`) or
|
|
16
|
+
- `beachball` or
|
|
17
|
+
- `empty` (displays nothing)
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
<template>
|
|
21
|
+
<Identicon
|
|
22
|
+
:size="128"
|
|
23
|
+
:theme="'polkadot'"
|
|
24
|
+
:value="'5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'"
|
|
25
|
+
/>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
import Identicon from '@pezkuwi/vue-identicon';
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
...
|
|
33
|
+
components: { Identicon }
|
|
34
|
+
...
|
|
35
|
+
};
|
|
36
|
+
</script>
|
|
37
|
+
```
|
|
@@ -208,7 +208,7 @@
|
|
|
208
208
|
});
|
|
209
209
|
return scheme.colors.map((_, i) => palette[scheme.colors[i < 18 ? (i + rot) % 18 : 18]]);
|
|
210
210
|
}
|
|
211
|
-
function
|
|
211
|
+
function pezkuwiIcon(address, { isAlternative }) {
|
|
212
212
|
const xy = getCircleXY(isAlternative);
|
|
213
213
|
let colors;
|
|
214
214
|
try {
|
|
@@ -228,7 +228,6 @@
|
|
|
228
228
|
const { address, isAlternative, size } = this.$props;
|
|
229
229
|
return vue.h({
|
|
230
230
|
template: beachballIcon(address, {
|
|
231
|
-
isAlternative,
|
|
232
231
|
size
|
|
233
232
|
}).outerHTML
|
|
234
233
|
});
|
|
@@ -713,10 +712,7 @@
|
|
|
713
712
|
}
|
|
714
713
|
}
|
|
715
714
|
const SVG_CONSTANTS = {
|
|
716
|
-
P: "http://www.w3.org/2000/svg"
|
|
717
|
-
R: "width",
|
|
718
|
-
S: "height",
|
|
719
|
-
};
|
|
715
|
+
P: "http://www.w3.org/2000/svg"};
|
|
720
716
|
class SvgWriter {
|
|
721
717
|
constructor(iconSize) {
|
|
722
718
|
this.k = iconSize;
|
|
@@ -765,11 +761,11 @@
|
|
|
765
761
|
: { attrs: data };
|
|
766
762
|
}
|
|
767
763
|
|
|
768
|
-
const
|
|
764
|
+
const Pezkuwi = vue.defineComponent({
|
|
769
765
|
props: ['address', 'isAlternative', 'size'],
|
|
770
766
|
render() {
|
|
771
767
|
const { address, isAlternative, size } = this.$props;
|
|
772
|
-
const circles =
|
|
768
|
+
const circles = pezkuwiIcon(address, { isAlternative }).map(({ cx, cy, fill, r }) => vue.h('circle', { ...adaptVNodeAttrs({ cx, cy, fill, r }) }, []));
|
|
773
769
|
return vue.h('svg', {
|
|
774
770
|
...adaptVNodeAttrs({
|
|
775
771
|
height: size,
|
|
@@ -804,7 +800,7 @@
|
|
|
804
800
|
Beachball,
|
|
805
801
|
Empty,
|
|
806
802
|
Jdenticon,
|
|
807
|
-
|
|
803
|
+
Pezkuwi
|
|
808
804
|
},
|
|
809
805
|
created: function () {
|
|
810
806
|
this.createData();
|
|
@@ -851,14 +847,20 @@
|
|
|
851
847
|
})
|
|
852
848
|
}, []);
|
|
853
849
|
}
|
|
854
|
-
else if (type === '
|
|
855
|
-
|
|
850
|
+
else if (type === 'bizinikiwi') {
|
|
851
|
+
return vue.h(Jdenticon, {
|
|
852
|
+
...adaptVNodeAttrs({
|
|
853
|
+
key: address,
|
|
854
|
+
publicKey,
|
|
855
|
+
size: iconSize
|
|
856
|
+
})
|
|
857
|
+
}, []);
|
|
856
858
|
}
|
|
857
859
|
const cmp = type.charAt(0).toUpperCase() + type.slice(1);
|
|
858
|
-
if (['Beachball', '
|
|
860
|
+
if (['Beachball', 'Pezkuwi'].includes(cmp)) {
|
|
859
861
|
const component = cmp === 'Beachball'
|
|
860
862
|
? Beachball
|
|
861
|
-
:
|
|
863
|
+
: Pezkuwi;
|
|
862
864
|
return vue.h(component, {
|
|
863
865
|
...adaptVNodeAttrs({
|
|
864
866
|
address,
|
|
@@ -879,7 +881,7 @@
|
|
|
879
881
|
}
|
|
880
882
|
});
|
|
881
883
|
|
|
882
|
-
const packageInfo = { name: '@pezkuwi/vue-identicon', path: (({ url: (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('bundle-pezkuwi-vue-identicon.js', document.baseURI).href)) }) && (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('bundle-pezkuwi-vue-identicon.js', document.baseURI).href))) ? new URL((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('bundle-pezkuwi-vue-identicon.js', document.baseURI).href))).pathname.substring(0, new URL((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.src || new URL('bundle-pezkuwi-vue-identicon.js', document.baseURI).href))).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '3.
|
|
884
|
+
const packageInfo = { name: '@pezkuwi/vue-identicon', path: (({ url: (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bundle-pezkuwi-vue-identicon.js', document.baseURI).href)) }) && (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bundle-pezkuwi-vue-identicon.js', document.baseURI).href))) ? new URL((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bundle-pezkuwi-vue-identicon.js', document.baseURI).href))).pathname.substring(0, new URL((typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('bundle-pezkuwi-vue-identicon.js', document.baseURI).href))).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '3.17.0' };
|
|
883
885
|
|
|
884
886
|
exports.Identicon = Identicon;
|
|
885
887
|
exports.packageInfo = packageInfo;
|
package/build/bundle.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Prefix } from '@pezkuwi/util-crypto/address/types';
|
|
2
|
+
interface Account {
|
|
3
|
+
address: string;
|
|
4
|
+
publicKey: string;
|
|
5
|
+
}
|
|
6
|
+
interface Data {
|
|
7
|
+
address: string;
|
|
8
|
+
iconSize: number;
|
|
9
|
+
isAlternativeIcon: boolean;
|
|
10
|
+
publicKey: string;
|
|
11
|
+
type: 'beachball' | 'empty' | 'jdenticon' | 'pezkuwi' | 'bizinikiwi';
|
|
12
|
+
}
|
|
13
|
+
export declare function encodeAccount(value: string | Uint8Array, prefix?: Prefix): Account;
|
|
14
|
+
/**
|
|
15
|
+
* @name Identicon
|
|
16
|
+
* @description The main Identicon component, taking a number of properties
|
|
17
|
+
* @example
|
|
18
|
+
* ```html
|
|
19
|
+
* <Identicon :size="128" :theme="pezkuwi" :value="..." />
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const Identicon: import("vue").DefineComponent<string[], {}, Data, {}, {
|
|
23
|
+
createData: () => void;
|
|
24
|
+
recodeAddress: () => void;
|
|
25
|
+
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<string[]>>, {
|
|
26
|
+
[x: number]: string;
|
|
27
|
+
}>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Identicon = void 0;
|
|
4
|
+
exports.encodeAccount = encodeAccount;
|
|
5
|
+
const vue_1 = require("vue");
|
|
6
|
+
const util_1 = require("@pezkuwi/util");
|
|
7
|
+
const util_crypto_1 = require("@pezkuwi/util-crypto");
|
|
8
|
+
const index_js_1 = require("./icons/index.js");
|
|
9
|
+
const util_js_1 = require("./util.js");
|
|
10
|
+
const DEFAULT_SIZE = 64;
|
|
11
|
+
function resolvePublicKey(value, prefix) {
|
|
12
|
+
if ((0, util_1.isHex)(value) && (0, util_crypto_1.isEthereumAddress)(value)) {
|
|
13
|
+
return value.padEnd(66, '0');
|
|
14
|
+
}
|
|
15
|
+
return (0, util_1.isU8a)(value) || (0, util_1.isHex)(value)
|
|
16
|
+
? (0, util_crypto_1.encodeAddress)(value, prefix)
|
|
17
|
+
: value;
|
|
18
|
+
}
|
|
19
|
+
function encodeAccount(value, prefix) {
|
|
20
|
+
try {
|
|
21
|
+
const address = resolvePublicKey(value, prefix);
|
|
22
|
+
const publicKey = (0, util_1.u8aToHex)((0, util_crypto_1.decodeAddress)(address, false, prefix));
|
|
23
|
+
return { address, publicKey };
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return { address: '', publicKey: '0x' };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @name Identicon
|
|
31
|
+
* @description The main Identicon component, taking a number of properties
|
|
32
|
+
* @example
|
|
33
|
+
* ```html
|
|
34
|
+
* <Identicon :size="128" :theme="pezkuwi" :value="..." />
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
exports.Identicon = (0, vue_1.defineComponent)({
|
|
38
|
+
components: {
|
|
39
|
+
Beachball: index_js_1.Beachball,
|
|
40
|
+
Empty: index_js_1.Empty,
|
|
41
|
+
Jdenticon: index_js_1.Jdenticon,
|
|
42
|
+
Pezkuwi: index_js_1.Pezkuwi
|
|
43
|
+
},
|
|
44
|
+
created: function () {
|
|
45
|
+
this.createData();
|
|
46
|
+
},
|
|
47
|
+
data: function () {
|
|
48
|
+
return {
|
|
49
|
+
address: '',
|
|
50
|
+
iconSize: DEFAULT_SIZE,
|
|
51
|
+
isAlternativeIcon: false,
|
|
52
|
+
publicKey: '0x',
|
|
53
|
+
type: 'empty'
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
methods: {
|
|
57
|
+
createData: function () {
|
|
58
|
+
this.iconSize = this.size || DEFAULT_SIZE;
|
|
59
|
+
this.type = this.theme;
|
|
60
|
+
this.isAlternativeIcon = this.isAlternative || false;
|
|
61
|
+
this.recodeAddress();
|
|
62
|
+
},
|
|
63
|
+
recodeAddress: function () {
|
|
64
|
+
const { address, publicKey } = encodeAccount(this.value);
|
|
65
|
+
this.address = address;
|
|
66
|
+
this.publicKey = publicKey;
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
props: ['prefix', 'isAlternative', 'size', 'theme', 'value'],
|
|
70
|
+
render() {
|
|
71
|
+
const { address, iconSize, isAlternativeIcon, publicKey, type } = this.$data;
|
|
72
|
+
if (type === 'empty') {
|
|
73
|
+
return (0, vue_1.h)(index_js_1.Empty, {
|
|
74
|
+
...(0, util_js_1.adaptVNodeAttrs)({
|
|
75
|
+
key: address,
|
|
76
|
+
size: iconSize
|
|
77
|
+
})
|
|
78
|
+
}, []);
|
|
79
|
+
}
|
|
80
|
+
else if (type === 'jdenticon') {
|
|
81
|
+
return (0, vue_1.h)(index_js_1.Jdenticon, {
|
|
82
|
+
...(0, util_js_1.adaptVNodeAttrs)({
|
|
83
|
+
key: address,
|
|
84
|
+
publicKey,
|
|
85
|
+
size: iconSize
|
|
86
|
+
})
|
|
87
|
+
}, []);
|
|
88
|
+
}
|
|
89
|
+
else if (type === 'bizinikiwi') {
|
|
90
|
+
return (0, vue_1.h)(index_js_1.Jdenticon, {
|
|
91
|
+
...(0, util_js_1.adaptVNodeAttrs)({
|
|
92
|
+
key: address,
|
|
93
|
+
publicKey,
|
|
94
|
+
size: iconSize
|
|
95
|
+
})
|
|
96
|
+
}, []);
|
|
97
|
+
}
|
|
98
|
+
const cmp = type.charAt(0).toUpperCase() + type.slice(1);
|
|
99
|
+
if (['Beachball', 'Pezkuwi'].includes(cmp)) {
|
|
100
|
+
const component = cmp === 'Beachball'
|
|
101
|
+
? index_js_1.Beachball
|
|
102
|
+
: index_js_1.Pezkuwi;
|
|
103
|
+
return (0, vue_1.h)(component, {
|
|
104
|
+
...(0, util_js_1.adaptVNodeAttrs)({
|
|
105
|
+
address,
|
|
106
|
+
isAlternative: isAlternativeIcon,
|
|
107
|
+
key: address,
|
|
108
|
+
size: iconSize
|
|
109
|
+
})
|
|
110
|
+
}, []);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
return (0, vue_1.h)(cmp, {}, []);
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
watch: {
|
|
117
|
+
value: function () {
|
|
118
|
+
this.recodeAddress();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.packageInfo = exports.Identicon = void 0;
|
|
4
|
+
var Identicon_js_1 = require("./Identicon.js");
|
|
5
|
+
Object.defineProperty(exports, "Identicon", { enumerable: true, get: function () { return Identicon_js_1.Identicon; } });
|
|
6
|
+
var packageInfo_js_1 = require("./packageInfo.js");
|
|
7
|
+
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Beachball = void 0;
|
|
4
|
+
const vue_1 = require("vue");
|
|
5
|
+
const ui_shared_1 = require("@pezkuwi/ui-shared");
|
|
6
|
+
/**
|
|
7
|
+
* @name Beachball
|
|
8
|
+
* @description The Beachball identicon
|
|
9
|
+
*/
|
|
10
|
+
exports.Beachball = (0, vue_1.defineComponent)({
|
|
11
|
+
props: ['address', 'size', 'isAlternative'],
|
|
12
|
+
render() {
|
|
13
|
+
const { address, isAlternative, size } = this.$props;
|
|
14
|
+
return (0, vue_1.h)({
|
|
15
|
+
template: (0, ui_shared_1.beachballIcon)(address, {
|
|
16
|
+
isAlternative,
|
|
17
|
+
size
|
|
18
|
+
}).outerHTML
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Empty = void 0;
|
|
4
|
+
const vue_1 = require("vue");
|
|
5
|
+
/**
|
|
6
|
+
* @name Empty
|
|
7
|
+
* @description An empty identicon
|
|
8
|
+
*/
|
|
9
|
+
exports.Empty = (0, vue_1.defineComponent)({
|
|
10
|
+
props: ['size'],
|
|
11
|
+
template: `
|
|
12
|
+
<svg :height="size" :width="size" viewBox="0 0 64 64">
|
|
13
|
+
<circle cx="50%" cy="50%" fill="#eee" r="50%" />
|
|
14
|
+
</svg>
|
|
15
|
+
`
|
|
16
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Jdenticon = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const jdenticon = tslib_1.__importStar(require("jdenticon"));
|
|
6
|
+
const vue_1 = require("vue");
|
|
7
|
+
/**
|
|
8
|
+
* @name Jdenticon
|
|
9
|
+
* @description The substrate default via Jdenticon
|
|
10
|
+
*/
|
|
11
|
+
exports.Jdenticon = (0, vue_1.defineComponent)({
|
|
12
|
+
props: ['publicKey', 'size'],
|
|
13
|
+
render() {
|
|
14
|
+
const { publicKey, size } = this.$props;
|
|
15
|
+
return (0, vue_1.h)({
|
|
16
|
+
template: jdenticon.toSvg(publicKey.substring(2), size)
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @name
|
|
3
|
-
* @description The
|
|
2
|
+
* @name Pezkuwi
|
|
3
|
+
* @description The Pezkuwi default identicon
|
|
4
4
|
*/
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const Pezkuwi: import("vue").DefineComponent<Readonly<{
|
|
6
6
|
address?: any;
|
|
7
7
|
size?: any;
|
|
8
8
|
isAlternative?: any;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pezkuwi = void 0;
|
|
4
|
+
const vue_1 = require("vue");
|
|
5
|
+
const ui_shared_1 = require("@pezkuwi/ui-shared");
|
|
6
|
+
const util_js_1 = require("../util.js");
|
|
7
|
+
/**
|
|
8
|
+
* @name Pezkuwi
|
|
9
|
+
* @description The Pezkuwi default identicon
|
|
10
|
+
*/
|
|
11
|
+
exports.Pezkuwi = (0, vue_1.defineComponent)({
|
|
12
|
+
props: ['address', 'isAlternative', 'size'],
|
|
13
|
+
render() {
|
|
14
|
+
const { address, isAlternative, size } = this.$props;
|
|
15
|
+
const circles = (0, ui_shared_1.pezkuwiIcon)(address, { isAlternative }).map(({ cx, cy, fill, r }) => (0, vue_1.h)('circle', { ...(0, util_js_1.adaptVNodeAttrs)({ cx, cy, fill, r }) }, []));
|
|
16
|
+
return (0, vue_1.h)('svg', {
|
|
17
|
+
...(0, util_js_1.adaptVNodeAttrs)({
|
|
18
|
+
height: size,
|
|
19
|
+
viewBox: '0 0 64 64',
|
|
20
|
+
width: size
|
|
21
|
+
})
|
|
22
|
+
}, circles);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./Beachball.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./Empty.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./Jdenticon.js"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./Pezkuwi.js"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
require("./packageDetect.js");
|
|
5
|
+
const bundle_js_1 = require("./bundle.js");
|
|
6
|
+
tslib_1.__exportStar(require("./bundle.js"), exports);
|
|
7
|
+
exports.default = bundle_js_1.Identicon;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.adaptVNodeAttrs = adaptVNodeAttrs;
|
|
4
|
+
const vue_1 = require("vue");
|
|
5
|
+
const isV3 = vue_1.version.startsWith('3.');
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*
|
|
9
|
+
* Adjust attributes to be usable in both Vue 2 and Vue 3 components.
|
|
10
|
+
*/
|
|
11
|
+
function adaptVNodeAttrs(data) {
|
|
12
|
+
return isV3
|
|
13
|
+
? data
|
|
14
|
+
: { attrs: data };
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name Beachball
|
|
3
|
+
* @description The Beachball identicon
|
|
4
|
+
*/
|
|
5
|
+
export declare const Beachball: import("vue").DefineComponent<Readonly<{
|
|
6
|
+
address?: any;
|
|
7
|
+
size?: any;
|
|
8
|
+
isAlternative?: any;
|
|
9
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<Readonly<{
|
|
10
|
+
address?: any;
|
|
11
|
+
size?: any;
|
|
12
|
+
isAlternative?: any;
|
|
13
|
+
}>>>, {
|
|
14
|
+
readonly address?: any;
|
|
15
|
+
readonly size?: any;
|
|
16
|
+
readonly isAlternative?: any;
|
|
17
|
+
}>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineComponent, h } from 'vue';
|
|
2
|
+
import { beachballIcon } from '@pezkuwi/ui-shared';
|
|
3
|
+
/**
|
|
4
|
+
* @name Beachball
|
|
5
|
+
* @description The Beachball identicon
|
|
6
|
+
*/
|
|
7
|
+
export const Beachball = defineComponent({
|
|
8
|
+
props: ['address', 'size', 'isAlternative'],
|
|
9
|
+
render() {
|
|
10
|
+
const { address, isAlternative, size } = this.$props;
|
|
11
|
+
return h({
|
|
12
|
+
template: beachballIcon(address, {
|
|
13
|
+
isAlternative,
|
|
14
|
+
size
|
|
15
|
+
}).outerHTML
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name Empty
|
|
3
|
+
* @description An empty identicon
|
|
4
|
+
*/
|
|
5
|
+
export declare const Empty: import("vue").DefineComponent<Readonly<{
|
|
6
|
+
size?: any;
|
|
7
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<Readonly<{
|
|
8
|
+
size?: any;
|
|
9
|
+
}>>>, {
|
|
10
|
+
readonly size?: any;
|
|
11
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineComponent } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* @name Empty
|
|
4
|
+
* @description An empty identicon
|
|
5
|
+
*/
|
|
6
|
+
export const Empty = defineComponent({
|
|
7
|
+
props: ['size'],
|
|
8
|
+
template: `
|
|
9
|
+
<svg :height="size" :width="size" viewBox="0 0 64 64">
|
|
10
|
+
<circle cx="50%" cy="50%" fill="#eee" r="50%" />
|
|
11
|
+
</svg>
|
|
12
|
+
`
|
|
13
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @name Jdenticon
|
|
3
|
+
* @description The substrate default via Jdenticon
|
|
4
|
+
*/
|
|
5
|
+
export declare const Jdenticon: import("vue").DefineComponent<Readonly<{
|
|
6
|
+
size?: any;
|
|
7
|
+
publicKey?: any;
|
|
8
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, Readonly<import("vue").ExtractPropTypes<Readonly<{
|
|
9
|
+
size?: any;
|
|
10
|
+
publicKey?: any;
|
|
11
|
+
}>>>, {
|
|
12
|
+
readonly size?: any;
|
|
13
|
+
readonly publicKey?: any;
|
|
14
|
+
}>;
|