@pezkuwi/reactnative-identicon 3.16.6

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.
Files changed (80) hide show
  1. package/README.md +30 -0
  2. package/build/Identicon.d.ts +20 -0
  3. package/build/Identicon.js +46 -0
  4. package/build/LICENSE +201 -0
  5. package/build/README.md +30 -0
  6. package/build/bundle.d.ts +2 -0
  7. package/build/bundle.js +2 -0
  8. package/build/cjs/Identicon.d.ts +20 -0
  9. package/build/cjs/Identicon.js +50 -0
  10. package/build/cjs/bundle.d.ts +2 -0
  11. package/build/cjs/bundle.js +7 -0
  12. package/build/cjs/icons/Empty.d.ts +3 -0
  13. package/build/cjs/icons/Empty.js +11 -0
  14. package/build/cjs/icons/Polkadot.d.ts +3 -0
  15. package/build/cjs/icons/Polkadot.js +16 -0
  16. package/build/cjs/icons/index.d.ts +2 -0
  17. package/build/cjs/icons/index.js +8 -0
  18. package/build/cjs/index.d.ts +4 -0
  19. package/build/cjs/index.js +7 -0
  20. package/build/cjs/package.json +3 -0
  21. package/build/cjs/packageDetect.d.ts +1 -0
  22. package/build/cjs/packageDetect.js +6 -0
  23. package/build/cjs/packageInfo.d.ts +6 -0
  24. package/build/cjs/packageInfo.js +4 -0
  25. package/build/cjs/types.d.ts +6 -0
  26. package/build/cjs/types.js +2 -0
  27. package/build/icons/Empty.d.ts +3 -0
  28. package/build/icons/Empty.js +7 -0
  29. package/build/icons/Polkadot.d.ts +3 -0
  30. package/build/icons/Polkadot.js +12 -0
  31. package/build/icons/index.d.ts +2 -0
  32. package/build/icons/index.js +2 -0
  33. package/build/index.d.ts +4 -0
  34. package/build/index.js +4 -0
  35. package/build/package.json +186 -0
  36. package/build/packageDetect.d.ts +1 -0
  37. package/build/packageDetect.js +4 -0
  38. package/build/packageInfo.d.ts +6 -0
  39. package/build/packageInfo.js +1 -0
  40. package/build/types.d.ts +6 -0
  41. package/build/types.js +1 -0
  42. package/build-tsc/Identicon.d.ts +20 -0
  43. package/build-tsc/bundle.d.ts +2 -0
  44. package/build-tsc/icons/Empty.d.ts +3 -0
  45. package/build-tsc/icons/Polkadot.d.ts +3 -0
  46. package/build-tsc/icons/index.d.ts +2 -0
  47. package/build-tsc/index.d.ts +4 -0
  48. package/build-tsc/packageDetect.d.ts +1 -0
  49. package/build-tsc/packageInfo.d.ts +6 -0
  50. package/build-tsc/types.d.ts +6 -0
  51. package/build-tsc-cjs/Identicon.js +50 -0
  52. package/build-tsc-cjs/bundle.js +7 -0
  53. package/build-tsc-cjs/icons/Empty.js +11 -0
  54. package/build-tsc-cjs/icons/Polkadot.js +16 -0
  55. package/build-tsc-cjs/icons/index.js +8 -0
  56. package/build-tsc-cjs/index.js +7 -0
  57. package/build-tsc-cjs/packageDetect.js +6 -0
  58. package/build-tsc-cjs/packageInfo.js +4 -0
  59. package/build-tsc-cjs/types.js +2 -0
  60. package/build-tsc-esm/Identicon.js +46 -0
  61. package/build-tsc-esm/bundle.js +2 -0
  62. package/build-tsc-esm/icons/Empty.js +7 -0
  63. package/build-tsc-esm/icons/Polkadot.js +12 -0
  64. package/build-tsc-esm/icons/index.js +2 -0
  65. package/build-tsc-esm/index.js +4 -0
  66. package/build-tsc-esm/packageDetect.js +4 -0
  67. package/build-tsc-esm/packageInfo.js +1 -0
  68. package/build-tsc-esm/types.js +1 -0
  69. package/package.json +39 -0
  70. package/src/Identicon.tsx +81 -0
  71. package/src/bundle.ts +5 -0
  72. package/src/icons/Empty.tsx +27 -0
  73. package/src/icons/Polkadot.tsx +43 -0
  74. package/src/icons/index.ts +5 -0
  75. package/src/index.ts +10 -0
  76. package/src/packageDetect.ts +12 -0
  77. package/src/packageInfo.ts +6 -0
  78. package/src/types.ts +9 -0
  79. package/tsconfig.build.json +11 -0
  80. package/tsconfig.build.tsbuildinfo +1 -0
@@ -0,0 +1,186 @@
1
+ {
2
+ "author": "Jaco Greeff <jacogr@gmail.com>",
3
+ "bugs": "https://github.com/pezkuwichain/ui/issues",
4
+ "description": "Renders an SVG picture representing an address",
5
+ "engines": {
6
+ "node": ">=18"
7
+ },
8
+ "homepage": "https://github.com/pezkuwichain/ui/tree/master/packages/reactnative-identicon#readme",
9
+ "license": "Apache-2.0",
10
+ "name": "@pezkuwi/reactnative-identicon",
11
+ "repository": {
12
+ "directory": "packages/reactnative-identicon",
13
+ "type": "git",
14
+ "url": "https://github.com/pezkuwichain/ui.git"
15
+ },
16
+ "sideEffects": [
17
+ "./packageDetect.js",
18
+ "./cjs/packageDetect.js"
19
+ ],
20
+ "type": "module",
21
+ "version": "3.16.6",
22
+ "main": "./cjs/index.js",
23
+ "module": "./index.js",
24
+ "types": "./index.d.ts",
25
+ "exports": {
26
+ "./cjs/package.json": "./cjs/package.json",
27
+ "./cjs/*": "./cjs/*.js",
28
+ ".": {
29
+ "module": {
30
+ "types": "./index.d.ts",
31
+ "default": "./index.js"
32
+ },
33
+ "require": {
34
+ "types": "./cjs/index.d.ts",
35
+ "default": "./cjs/index.js"
36
+ },
37
+ "default": {
38
+ "types": "./index.d.ts",
39
+ "default": "./index.js"
40
+ }
41
+ },
42
+ "./bundle": {
43
+ "module": {
44
+ "types": "./bundle.d.ts",
45
+ "default": "./bundle.js"
46
+ },
47
+ "require": {
48
+ "types": "./cjs/bundle.d.ts",
49
+ "default": "./cjs/bundle.js"
50
+ },
51
+ "default": {
52
+ "types": "./bundle.d.ts",
53
+ "default": "./bundle.js"
54
+ }
55
+ },
56
+ "./icons": {
57
+ "module": {
58
+ "types": "./icons/index.d.ts",
59
+ "default": "./icons/index.js"
60
+ },
61
+ "require": {
62
+ "types": "./cjs/icons/index.d.ts",
63
+ "default": "./cjs/icons/index.js"
64
+ },
65
+ "default": {
66
+ "types": "./icons/index.d.ts",
67
+ "default": "./icons/index.js"
68
+ }
69
+ },
70
+ "./icons/Empty": {
71
+ "module": {
72
+ "types": "./icons/Empty.d.ts",
73
+ "default": "./icons/Empty.js"
74
+ },
75
+ "require": {
76
+ "types": "./cjs/icons/Empty.d.ts",
77
+ "default": "./cjs/icons/Empty.js"
78
+ },
79
+ "default": {
80
+ "types": "./icons/Empty.d.ts",
81
+ "default": "./icons/Empty.js"
82
+ }
83
+ },
84
+ "./icons/Polkadot": {
85
+ "module": {
86
+ "types": "./icons/Polkadot.d.ts",
87
+ "default": "./icons/Polkadot.js"
88
+ },
89
+ "require": {
90
+ "types": "./cjs/icons/Polkadot.d.ts",
91
+ "default": "./cjs/icons/Polkadot.js"
92
+ },
93
+ "default": {
94
+ "types": "./icons/Polkadot.d.ts",
95
+ "default": "./icons/Polkadot.js"
96
+ }
97
+ },
98
+ "./Identicon": {
99
+ "module": {
100
+ "types": "./Identicon.d.ts",
101
+ "default": "./Identicon.js"
102
+ },
103
+ "require": {
104
+ "types": "./cjs/Identicon.d.ts",
105
+ "default": "./cjs/Identicon.js"
106
+ },
107
+ "default": {
108
+ "types": "./Identicon.d.ts",
109
+ "default": "./Identicon.js"
110
+ }
111
+ },
112
+ "./package.json": {
113
+ "require": "./cjs/package.json",
114
+ "default": "./package.json"
115
+ },
116
+ "./packageDetect": {
117
+ "module": {
118
+ "types": "./packageDetect.d.ts",
119
+ "default": "./packageDetect.js"
120
+ },
121
+ "require": {
122
+ "types": "./cjs/packageDetect.d.ts",
123
+ "default": "./cjs/packageDetect.js"
124
+ },
125
+ "default": {
126
+ "types": "./packageDetect.d.ts",
127
+ "default": "./packageDetect.js"
128
+ }
129
+ },
130
+ "./packageInfo.js": {
131
+ "module": {
132
+ "types": "./packageInfo.d.ts",
133
+ "default": "./packageInfo.js"
134
+ },
135
+ "require": {
136
+ "types": "./cjs/packageInfo.d.ts",
137
+ "default": "./cjs/packageInfo.js"
138
+ },
139
+ "default": {
140
+ "types": "./packageInfo.d.ts",
141
+ "default": "./packageInfo.js"
142
+ }
143
+ },
144
+ "./packageInfo": {
145
+ "module": {
146
+ "types": "./packageInfo.d.ts",
147
+ "default": "./packageInfo.js"
148
+ },
149
+ "require": {
150
+ "types": "./cjs/packageInfo.d.ts",
151
+ "default": "./cjs/packageInfo.js"
152
+ },
153
+ "default": {
154
+ "types": "./packageInfo.d.ts",
155
+ "default": "./packageInfo.js"
156
+ }
157
+ },
158
+ "./types": {
159
+ "module": {
160
+ "types": "./types.d.ts",
161
+ "default": "./types.js"
162
+ },
163
+ "require": {
164
+ "types": "./cjs/types.d.ts",
165
+ "default": "./cjs/types.js"
166
+ },
167
+ "default": {
168
+ "types": "./types.d.ts",
169
+ "default": "./types.js"
170
+ }
171
+ }
172
+ },
173
+ "dependencies": {
174
+ "@pezkuwi/ui-shared": "3.16.6",
175
+ "@pezkuwi/util": "^14.0.5",
176
+ "@pezkuwi/util-crypto": "^14.0.5",
177
+ "react-native-svg": "^14.1.0",
178
+ "tslib": "^2.8.1"
179
+ },
180
+ "peerDependencies": {
181
+ "@pezkuwi/util": "*",
182
+ "@pezkuwi/util-crypto": "*",
183
+ "react": "*",
184
+ "react-native": "*"
185
+ }
186
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { packageInfo as sharedInfo } from '@pezkuwi/ui-shared/packageInfo';
2
+ import { detectPackage } from '@pezkuwi/util';
3
+ import { packageInfo } from './packageInfo.js';
4
+ detectPackage(packageInfo, null, [sharedInfo]);
@@ -0,0 +1,6 @@
1
+ export declare const packageInfo: {
2
+ name: string;
3
+ path: string;
4
+ type: string;
5
+ version: string;
6
+ };
@@ -0,0 +1 @@
1
+ export const packageInfo = { name: '@pezkuwi/reactnative-identicon', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '3.16.6' };
@@ -0,0 +1,6 @@
1
+ export interface Props {
2
+ address: string;
3
+ isAlternative?: boolean;
4
+ publicKey: string;
5
+ size: number;
6
+ }
package/build/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { Prefix } from '@pezkuwi/util-crypto/address/types';
2
+ import React from 'react';
3
+ interface Props {
4
+ prefix?: Prefix;
5
+ size?: number;
6
+ theme?: 'polkadot';
7
+ value?: string | Uint8Array | null;
8
+ }
9
+ interface State {
10
+ address: string;
11
+ publicKey: string;
12
+ }
13
+ export default class IdentityIcon extends React.PureComponent<Props, State> {
14
+ state: State;
15
+ private static prefix?;
16
+ static setDefaultPrefix(prefix: Prefix): void;
17
+ static getDerivedStateFromProps({ prefix, value }: Props, prevState: State): State | null;
18
+ render(): React.ReactNode;
19
+ }
20
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './icons/index.js';
2
+ export { packageInfo } from './packageInfo.js';
@@ -0,0 +1,3 @@
1
+ import type { Props } from '../types.js';
2
+ import React from 'react';
3
+ export default function Empty({ size }: Props): React.ReactElement<Props>;
@@ -0,0 +1,3 @@
1
+ import type { Props } from '../types.js';
2
+ import React from 'react';
3
+ export default function Identicon({ address, isAlternative, size }: Props): React.ReactElement<Props>;
@@ -0,0 +1,2 @@
1
+ export { default as Empty } from './Empty.js';
2
+ export { default as Polkadot } from './Polkadot.js';
@@ -0,0 +1,4 @@
1
+ import './packageDetect.js';
2
+ import Identicon from './Identicon.js';
3
+ export * from './bundle.js';
4
+ export default Identicon;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export declare const packageInfo: {
2
+ name: string;
3
+ path: string;
4
+ type: string;
5
+ version: string;
6
+ };
@@ -0,0 +1,6 @@
1
+ export interface Props {
2
+ address: string;
3
+ isAlternative?: boolean;
4
+ publicKey: string;
5
+ size: number;
6
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
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 Fallback = index_js_1.Polkadot;
10
+ const DEFAULT_SIZE = 64;
11
+ const DEFAULT_THEME = 'polkadot';
12
+ const Components = {
13
+ polkadot: index_js_1.Polkadot
14
+ };
15
+ class IdentityIcon extends react_1.default.PureComponent {
16
+ state = {
17
+ address: '',
18
+ publicKey: '0x'
19
+ };
20
+ static prefix = undefined;
21
+ static setDefaultPrefix(prefix) {
22
+ IdentityIcon.prefix = prefix;
23
+ }
24
+ static getDerivedStateFromProps({ prefix = IdentityIcon.prefix, value }, prevState) {
25
+ try {
26
+ const address = (0, util_1.isU8a)(value) || (0, util_1.isHex)(value)
27
+ ? (0, util_crypto_1.encodeAddress)(value, prefix)
28
+ : (value || '');
29
+ const publicKey = (0, util_1.u8aToHex)((0, util_crypto_1.decodeAddress)(address, true, prefix));
30
+ return address === prevState.address
31
+ ? null
32
+ : { address, publicKey };
33
+ }
34
+ catch {
35
+ return {
36
+ address: '',
37
+ publicKey: '0x'
38
+ };
39
+ }
40
+ }
41
+ render() {
42
+ const { size = DEFAULT_SIZE, theme = DEFAULT_THEME } = this.props;
43
+ const { address, publicKey } = this.state;
44
+ const Component = !address
45
+ ? index_js_1.Empty
46
+ : Components[theme] || Fallback;
47
+ return ((0, jsx_runtime_1.jsx)(Component, { address: address, publicKey: publicKey, size: size }));
48
+ }
49
+ }
50
+ exports.default = IdentityIcon;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.packageInfo = void 0;
4
+ const tslib_1 = require("tslib");
5
+ tslib_1.__exportStar(require("./icons/index.js"), exports);
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,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = Empty;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = tslib_1.__importDefault(require("react"));
7
+ const react_native_1 = require("react-native");
8
+ const react_native_svg_1 = require("react-native-svg");
9
+ function Empty({ size }) {
10
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, { children: (0, jsx_runtime_1.jsx)(react_native_svg_1.Svg, { height: size, viewBox: '0 0 64 64', width: size, children: (0, jsx_runtime_1.jsx)(react_native_svg_1.Circle, { cx: '32', cy: '32', fill: '#eee', r: '32' }) }) }));
11
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = Identicon;
4
+ const tslib_1 = require("tslib");
5
+ const jsx_runtime_1 = require("react/jsx-runtime");
6
+ const react_1 = tslib_1.__importStar(require("react"));
7
+ const react_native_1 = require("react-native");
8
+ const react_native_svg_1 = require("react-native-svg");
9
+ const ui_shared_1 = require("@pezkuwi/ui-shared");
10
+ function renderCircle({ cx, cy, fill, r }, key) {
11
+ return ((0, jsx_runtime_1.jsx)(react_native_svg_1.Circle, { cx: cx, cy: cy, fill: fill, r: r }, key));
12
+ }
13
+ function Identicon({ address, isAlternative = false, size }) {
14
+ const circles = (0, react_1.useMemo)(() => (0, ui_shared_1.polkadotIcon)(address, { isAlternative }), [address, isAlternative]);
15
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, { children: (0, jsx_runtime_1.jsx)(react_native_svg_1.Svg, { height: size, id: address, viewBox: '0 0 64 64', width: size, children: circles.map(renderCircle) }) }));
16
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Polkadot = exports.Empty = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var Empty_js_1 = require("./Empty.js");
6
+ Object.defineProperty(exports, "Empty", { enumerable: true, get: function () { return tslib_1.__importDefault(Empty_js_1).default; } });
7
+ var Polkadot_js_1 = require("./Polkadot.js");
8
+ Object.defineProperty(exports, "Polkadot", { enumerable: true, get: function () { return tslib_1.__importDefault(Polkadot_js_1).default; } });
@@ -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 Identicon_js_1 = tslib_1.__importDefault(require("./Identicon.js"));
6
+ tslib_1.__exportStar(require("./bundle.js"), exports);
7
+ exports.default = Identicon_js_1.default;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const packageInfo_1 = require("@pezkuwi/ui-shared/packageInfo");
4
+ const util_1 = require("@pezkuwi/util");
5
+ const packageInfo_js_1 = require("./packageInfo.js");
6
+ (0, util_1.detectPackage)(packageInfo_js_1.packageInfo, null, [packageInfo_1.packageInfo]);
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.packageInfo = void 0;
4
+ exports.packageInfo = { name: '@pezkuwi/reactnative-identicon', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '3.16.6' };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { isHex, isU8a, u8aToHex } from '@pezkuwi/util';
4
+ import { decodeAddress, encodeAddress } from '@pezkuwi/util-crypto';
5
+ import { Empty, Polkadot } from './icons/index.js';
6
+ const Fallback = Polkadot;
7
+ const DEFAULT_SIZE = 64;
8
+ const DEFAULT_THEME = 'polkadot';
9
+ const Components = {
10
+ polkadot: Polkadot
11
+ };
12
+ export default class IdentityIcon extends React.PureComponent {
13
+ state = {
14
+ address: '',
15
+ publicKey: '0x'
16
+ };
17
+ static prefix = undefined;
18
+ static setDefaultPrefix(prefix) {
19
+ IdentityIcon.prefix = prefix;
20
+ }
21
+ static getDerivedStateFromProps({ prefix = IdentityIcon.prefix, value }, prevState) {
22
+ try {
23
+ const address = isU8a(value) || isHex(value)
24
+ ? encodeAddress(value, prefix)
25
+ : (value || '');
26
+ const publicKey = u8aToHex(decodeAddress(address, true, prefix));
27
+ return address === prevState.address
28
+ ? null
29
+ : { address, publicKey };
30
+ }
31
+ catch {
32
+ return {
33
+ address: '',
34
+ publicKey: '0x'
35
+ };
36
+ }
37
+ }
38
+ render() {
39
+ const { size = DEFAULT_SIZE, theme = DEFAULT_THEME } = this.props;
40
+ const { address, publicKey } = this.state;
41
+ const Component = !address
42
+ ? Empty
43
+ : Components[theme] || Fallback;
44
+ return (_jsx(Component, { address: address, publicKey: publicKey, size: size }));
45
+ }
46
+ }
@@ -0,0 +1,2 @@
1
+ export * from './icons/index.js';
2
+ export { packageInfo } from './packageInfo.js';
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { View } from 'react-native';
4
+ import { Circle, Svg } from 'react-native-svg';
5
+ export default function Empty({ size }) {
6
+ return (_jsx(View, { children: _jsx(Svg, { height: size, viewBox: '0 0 64 64', width: size, children: _jsx(Circle, { cx: '32', cy: '32', fill: '#eee', r: '32' }) }) }));
7
+ }
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useMemo } from 'react';
3
+ import { View } from 'react-native';
4
+ import { Circle as SvgCircle, Svg } from 'react-native-svg';
5
+ import { polkadotIcon } from '@pezkuwi/ui-shared';
6
+ function renderCircle({ cx, cy, fill, r }, key) {
7
+ return (_jsx(SvgCircle, { cx: cx, cy: cy, fill: fill, r: r }, key));
8
+ }
9
+ export default function Identicon({ address, isAlternative = false, size }) {
10
+ const circles = useMemo(() => polkadotIcon(address, { isAlternative }), [address, isAlternative]);
11
+ return (_jsx(View, { children: _jsx(Svg, { height: size, id: address, viewBox: '0 0 64 64', width: size, children: circles.map(renderCircle) }) }));
12
+ }
@@ -0,0 +1,2 @@
1
+ export { default as Empty } from './Empty.js';
2
+ export { default as Polkadot } from './Polkadot.js';
@@ -0,0 +1,4 @@
1
+ import './packageDetect.js';
2
+ import Identicon from './Identicon.js';
3
+ export * from './bundle.js';
4
+ export default Identicon;
@@ -0,0 +1,4 @@
1
+ import { packageInfo as sharedInfo } from '@pezkuwi/ui-shared/packageInfo';
2
+ import { detectPackage } from '@pezkuwi/util';
3
+ import { packageInfo } from './packageInfo.js';
4
+ detectPackage(packageInfo, null, [sharedInfo]);
@@ -0,0 +1 @@
1
+ export const packageInfo = { name: '@pezkuwi/reactnative-identicon', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '3.16.6' };
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "author": "Jaco Greeff <jacogr@gmail.com>",
3
+ "bugs": "https://github.com/pezkuwichain/ui/issues",
4
+ "description": "Renders an SVG picture representing an address",
5
+ "engines": {
6
+ "node": ">=18"
7
+ },
8
+ "homepage": "https://github.com/pezkuwichain/ui/tree/master/packages/reactnative-identicon#readme",
9
+ "license": "Apache-2.0",
10
+ "name": "@pezkuwi/reactnative-identicon",
11
+ "repository": {
12
+ "directory": "packages/reactnative-identicon",
13
+ "type": "git",
14
+ "url": "https://github.com/pezkuwichain/ui.git"
15
+ },
16
+ "sideEffects": [
17
+ "./packageDetect.js",
18
+ "./packageDetect.cjs"
19
+ ],
20
+ "type": "module",
21
+ "version": "3.16.6",
22
+ "main": "index.js",
23
+ "dependencies": {
24
+ "@pezkuwi/ui-shared": "3.16.6",
25
+ "@pezkuwi/util": "^14.0.5",
26
+ "@pezkuwi/util-crypto": "^14.0.5",
27
+ "react-native-svg": "^14.1.0",
28
+ "tslib": "^2.8.1"
29
+ },
30
+ "devDependencies": {
31
+ "@types/react-native": "^0.72.8"
32
+ },
33
+ "peerDependencies": {
34
+ "@pezkuwi/util": "*",
35
+ "@pezkuwi/util-crypto": "*",
36
+ "react": "*",
37
+ "react-native": "*"
38
+ }
39
+ }
@@ -0,0 +1,81 @@
1
+ // Copyright 2017-2025 @pezkuwi/reactnative-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Prefix } from '@pezkuwi/util-crypto/address/types';
5
+ import type { Props as ComponentProps } from './types.js';
6
+
7
+ import React from 'react';
8
+
9
+ import { isHex, isU8a, u8aToHex } from '@pezkuwi/util';
10
+ import { decodeAddress, encodeAddress } from '@pezkuwi/util-crypto';
11
+
12
+ import { Empty, Polkadot } from './icons/index.js';
13
+
14
+ const Fallback = Polkadot;
15
+
16
+ interface Props {
17
+ prefix?: Prefix;
18
+ size?: number;
19
+ theme?: 'polkadot';
20
+ value?: string | Uint8Array | null;
21
+ }
22
+
23
+ interface State {
24
+ address: string;
25
+ publicKey: string;
26
+ }
27
+
28
+ const DEFAULT_SIZE = 64;
29
+ const DEFAULT_THEME = 'polkadot';
30
+
31
+ const Components: Record<string, React.ComponentType<ComponentProps>> = {
32
+ polkadot: Polkadot
33
+ };
34
+
35
+ export default class IdentityIcon extends React.PureComponent<Props, State> {
36
+ public override state: State = {
37
+ address: '',
38
+ publicKey: '0x'
39
+ };
40
+
41
+ private static prefix?: Prefix = undefined;
42
+
43
+ public static setDefaultPrefix (prefix: Prefix): void {
44
+ IdentityIcon.prefix = prefix;
45
+ }
46
+
47
+ public static getDerivedStateFromProps ({ prefix = IdentityIcon.prefix, value }: Props, prevState: State): State | null {
48
+ try {
49
+ const address = isU8a(value) || isHex(value)
50
+ ? encodeAddress(value, prefix)
51
+ : (value || '');
52
+ const publicKey = u8aToHex(decodeAddress(address, true, prefix));
53
+
54
+ return address === prevState.address
55
+ ? null
56
+ : { address, publicKey };
57
+ } catch {
58
+ return {
59
+ address: '',
60
+ publicKey: '0x'
61
+ };
62
+ }
63
+ }
64
+
65
+ public override render (): React.ReactNode {
66
+ const { size = DEFAULT_SIZE, theme = DEFAULT_THEME } = this.props;
67
+ const { address, publicKey } = this.state;
68
+
69
+ const Component = !address
70
+ ? Empty
71
+ : Components[theme] || Fallback;
72
+
73
+ return (
74
+ <Component
75
+ address={address}
76
+ publicKey={publicKey}
77
+ size={size}
78
+ />
79
+ );
80
+ }
81
+ }
package/src/bundle.ts ADDED
@@ -0,0 +1,5 @@
1
+ // Copyright 2017-2025 @pezkuwi/reactnative-identicon authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './icons/index.js';
5
+ export { packageInfo } from './packageInfo.js';