@pezkuwi/ui-shared 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 (183) hide show
  1. package/README.md +3 -0
  2. package/build/LICENSE +201 -0
  3. package/build/README.md +3 -0
  4. package/build/bundle.d.ts +2 -0
  5. package/build/bundle.js +2 -0
  6. package/build/cjs/bundle.d.ts +2 -0
  7. package/build/cjs/bundle.js +7 -0
  8. package/build/cjs/icons/beachball/colors.d.ts +2 -0
  9. package/build/cjs/icons/beachball/colors.js +16 -0
  10. package/build/cjs/icons/beachball/container.d.ts +1 -0
  11. package/build/cjs/icons/beachball/container.js +22 -0
  12. package/build/cjs/icons/beachball/defaults.d.ts +2 -0
  13. package/build/cjs/icons/beachball/defaults.js +8 -0
  14. package/build/cjs/icons/beachball/demo.d.ts +1 -0
  15. package/build/cjs/icons/beachball/demo.js +21 -0
  16. package/build/cjs/icons/beachball/index.d.ts +2 -0
  17. package/build/cjs/icons/beachball/index.js +24 -0
  18. package/build/cjs/icons/beachball/seeder.d.ts +2 -0
  19. package/build/cjs/icons/beachball/seeder.js +21 -0
  20. package/build/cjs/icons/beachball/shape/circle.d.ts +2 -0
  21. package/build/cjs/icons/beachball/shape/circle.js +16 -0
  22. package/build/cjs/icons/beachball/shape/square.d.ts +2 -0
  23. package/build/cjs/icons/beachball/shape/square.js +19 -0
  24. package/build/cjs/icons/beachball/svg/circle.d.ts +1 -0
  25. package/build/cjs/icons/beachball/svg/circle.js +11 -0
  26. package/build/cjs/icons/beachball/svg/element.d.ts +1 -0
  27. package/build/cjs/icons/beachball/svg/element.js +12 -0
  28. package/build/cjs/icons/beachball/svg/rect.d.ts +1 -0
  29. package/build/cjs/icons/beachball/svg/rect.js +10 -0
  30. package/build/cjs/icons/beachball/svg/svg.d.ts +1 -0
  31. package/build/cjs/icons/beachball/svg/svg.js +7 -0
  32. package/build/cjs/icons/beachball/types.d.ts +2 -0
  33. package/build/cjs/icons/beachball/types.js +2 -0
  34. package/build/cjs/icons/index.d.ts +2 -0
  35. package/build/cjs/icons/index.js +7 -0
  36. package/build/cjs/icons/polkadot.d.ts +5 -0
  37. package/build/cjs/icons/polkadot.js +116 -0
  38. package/build/cjs/icons/types.d.ts +10 -0
  39. package/build/cjs/icons/types.js +2 -0
  40. package/build/cjs/index.d.ts +2 -0
  41. package/build/cjs/index.js +5 -0
  42. package/build/cjs/package.json +3 -0
  43. package/build/cjs/packageDetect.d.ts +1 -0
  44. package/build/cjs/packageDetect.js +5 -0
  45. package/build/cjs/packageInfo.d.ts +6 -0
  46. package/build/cjs/packageInfo.js +4 -0
  47. package/build/icons/beachball/README.md +19 -0
  48. package/build/icons/beachball/colors.d.ts +2 -0
  49. package/build/icons/beachball/colors.js +13 -0
  50. package/build/icons/beachball/container.d.ts +1 -0
  51. package/build/icons/beachball/container.js +19 -0
  52. package/build/icons/beachball/defaults.d.ts +2 -0
  53. package/build/icons/beachball/defaults.js +5 -0
  54. package/build/icons/beachball/demo.d.ts +1 -0
  55. package/build/icons/beachball/demo.js +19 -0
  56. package/build/icons/beachball/index.d.ts +2 -0
  57. package/build/icons/beachball/index.js +21 -0
  58. package/build/icons/beachball/seeder.d.ts +2 -0
  59. package/build/icons/beachball/seeder.js +18 -0
  60. package/build/icons/beachball/shape/circle.d.ts +2 -0
  61. package/build/icons/beachball/shape/circle.js +13 -0
  62. package/build/icons/beachball/shape/square.d.ts +2 -0
  63. package/build/icons/beachball/shape/square.js +16 -0
  64. package/build/icons/beachball/svg/circle.d.ts +1 -0
  65. package/build/icons/beachball/svg/circle.js +8 -0
  66. package/build/icons/beachball/svg/element.d.ts +1 -0
  67. package/build/icons/beachball/svg/element.js +9 -0
  68. package/build/icons/beachball/svg/rect.d.ts +1 -0
  69. package/build/icons/beachball/svg/rect.js +7 -0
  70. package/build/icons/beachball/svg/svg.d.ts +1 -0
  71. package/build/icons/beachball/svg/svg.js +4 -0
  72. package/build/icons/beachball/types.d.ts +2 -0
  73. package/build/icons/beachball/types.js +1 -0
  74. package/build/icons/index.d.ts +2 -0
  75. package/build/icons/index.js +2 -0
  76. package/build/icons/polkadot.d.ts +5 -0
  77. package/build/icons/polkadot.js +113 -0
  78. package/build/icons/types.d.ts +10 -0
  79. package/build/icons/types.js +1 -0
  80. package/build/index.d.ts +2 -0
  81. package/build/index.js +2 -0
  82. package/build/package.json +336 -0
  83. package/build/packageDetect.d.ts +1 -0
  84. package/build/packageDetect.js +3 -0
  85. package/build/packageInfo.d.ts +6 -0
  86. package/build/packageInfo.js +1 -0
  87. package/build-tsc/bundle.d.ts +2 -0
  88. package/build-tsc/icons/beachball/colors.d.ts +2 -0
  89. package/build-tsc/icons/beachball/container.d.ts +1 -0
  90. package/build-tsc/icons/beachball/defaults.d.ts +2 -0
  91. package/build-tsc/icons/beachball/demo.d.ts +1 -0
  92. package/build-tsc/icons/beachball/index.d.ts +2 -0
  93. package/build-tsc/icons/beachball/seeder.d.ts +2 -0
  94. package/build-tsc/icons/beachball/shape/circle.d.ts +2 -0
  95. package/build-tsc/icons/beachball/shape/square.d.ts +2 -0
  96. package/build-tsc/icons/beachball/svg/circle.d.ts +1 -0
  97. package/build-tsc/icons/beachball/svg/element.d.ts +1 -0
  98. package/build-tsc/icons/beachball/svg/rect.d.ts +1 -0
  99. package/build-tsc/icons/beachball/svg/svg.d.ts +1 -0
  100. package/build-tsc/icons/beachball/types.d.ts +2 -0
  101. package/build-tsc/icons/index.d.ts +2 -0
  102. package/build-tsc/icons/polkadot.d.ts +5 -0
  103. package/build-tsc/icons/types.d.ts +10 -0
  104. package/build-tsc/index.d.ts +2 -0
  105. package/build-tsc/packageDetect.d.ts +1 -0
  106. package/build-tsc/packageInfo.d.ts +6 -0
  107. package/build-tsc-cjs/bundle.js +7 -0
  108. package/build-tsc-cjs/icons/beachball/colors.js +16 -0
  109. package/build-tsc-cjs/icons/beachball/container.js +22 -0
  110. package/build-tsc-cjs/icons/beachball/defaults.js +8 -0
  111. package/build-tsc-cjs/icons/beachball/demo.js +21 -0
  112. package/build-tsc-cjs/icons/beachball/index.js +24 -0
  113. package/build-tsc-cjs/icons/beachball/seeder.js +21 -0
  114. package/build-tsc-cjs/icons/beachball/shape/circle.js +16 -0
  115. package/build-tsc-cjs/icons/beachball/shape/square.js +19 -0
  116. package/build-tsc-cjs/icons/beachball/svg/circle.js +11 -0
  117. package/build-tsc-cjs/icons/beachball/svg/element.js +12 -0
  118. package/build-tsc-cjs/icons/beachball/svg/rect.js +10 -0
  119. package/build-tsc-cjs/icons/beachball/svg/svg.js +7 -0
  120. package/build-tsc-cjs/icons/beachball/types.js +2 -0
  121. package/build-tsc-cjs/icons/index.js +7 -0
  122. package/build-tsc-cjs/icons/polkadot.js +116 -0
  123. package/build-tsc-cjs/icons/types.js +2 -0
  124. package/build-tsc-cjs/index.js +5 -0
  125. package/build-tsc-cjs/packageDetect.js +5 -0
  126. package/build-tsc-cjs/packageInfo.js +4 -0
  127. package/build-tsc-esm/bundle.js +2 -0
  128. package/build-tsc-esm/icons/beachball/colors.js +13 -0
  129. package/build-tsc-esm/icons/beachball/container.js +19 -0
  130. package/build-tsc-esm/icons/beachball/defaults.js +5 -0
  131. package/build-tsc-esm/icons/beachball/demo.js +19 -0
  132. package/build-tsc-esm/icons/beachball/index.js +21 -0
  133. package/build-tsc-esm/icons/beachball/seeder.js +18 -0
  134. package/build-tsc-esm/icons/beachball/shape/circle.js +13 -0
  135. package/build-tsc-esm/icons/beachball/shape/square.js +16 -0
  136. package/build-tsc-esm/icons/beachball/svg/circle.js +8 -0
  137. package/build-tsc-esm/icons/beachball/svg/element.js +9 -0
  138. package/build-tsc-esm/icons/beachball/svg/rect.js +7 -0
  139. package/build-tsc-esm/icons/beachball/svg/svg.js +4 -0
  140. package/build-tsc-esm/icons/beachball/types.js +1 -0
  141. package/build-tsc-esm/icons/index.js +2 -0
  142. package/build-tsc-esm/icons/polkadot.js +113 -0
  143. package/build-tsc-esm/icons/types.js +1 -0
  144. package/build-tsc-esm/index.js +2 -0
  145. package/build-tsc-esm/packageDetect.js +3 -0
  146. package/build-tsc-esm/packageInfo.js +1 -0
  147. package/package.json +37 -0
  148. package/src/bundle.ts +5 -0
  149. package/src/icons/beachball/LICENSE +16 -0
  150. package/src/icons/beachball/README.md +19 -0
  151. package/src/icons/beachball/colors.spec.ts +67 -0
  152. package/src/icons/beachball/colors.ts +28 -0
  153. package/src/icons/beachball/container.spec.ts +46 -0
  154. package/src/icons/beachball/container.ts +27 -0
  155. package/src/icons/beachball/defaults.ts +11 -0
  156. package/src/icons/beachball/demo.ts +35 -0
  157. package/src/icons/beachball/index.spec.ts +36 -0
  158. package/src/icons/beachball/index.ts +33 -0
  159. package/src/icons/beachball/seeder.spec.ts +30 -0
  160. package/src/icons/beachball/seeder.ts +30 -0
  161. package/src/icons/beachball/shape/circle.spec.ts +20 -0
  162. package/src/icons/beachball/shape/circle.ts +23 -0
  163. package/src/icons/beachball/shape/square.ts +26 -0
  164. package/src/icons/beachball/svg/circle.spec.ts +19 -0
  165. package/src/icons/beachball/svg/circle.ts +14 -0
  166. package/src/icons/beachball/svg/element.spec.ts +19 -0
  167. package/src/icons/beachball/svg/element.ts +17 -0
  168. package/src/icons/beachball/svg/rect.spec.ts +19 -0
  169. package/src/icons/beachball/svg/rect.ts +13 -0
  170. package/src/icons/beachball/svg/svg.spec.ts +19 -0
  171. package/src/icons/beachball/svg/svg.ts +10 -0
  172. package/src/icons/beachball/types.ts +6 -0
  173. package/src/icons/index.ts +5 -0
  174. package/src/icons/polkadot.spec.ts +35 -0
  175. package/src/icons/polkadot.ts +154 -0
  176. package/src/icons/types.ts +14 -0
  177. package/src/index.ts +6 -0
  178. package/src/packageDetect.ts +11 -0
  179. package/src/packageInfo.ts +6 -0
  180. package/tsconfig.build.json +12 -0
  181. package/tsconfig.build.tsbuildinfo +1 -0
  182. package/tsconfig.spec.json +16 -0
  183. package/tsconfig.spec.tsbuildinfo +1 -0
@@ -0,0 +1,154 @@
1
+ // Copyright 2018-2025 @pezkuwi/ui-shared authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Copyright 2018 Paritytech via paritytech/oo7/polkadot-identicon
5
+
6
+ // This has been converted from the original version that can be found at
7
+ //
8
+ // https://github.com/paritytech/oo7/blob/251ba2b7c45503b68eab4320c270b5afa9bccb60/packages/polkadot-identicon/src/index.jsx
9
+
10
+ import type { Circle, Options } from './types.js';
11
+
12
+ import { blake2AsU8a, decodeAddress } from '@pezkuwi/util-crypto';
13
+
14
+ interface Scheme {
15
+ freq: number;
16
+ colors: readonly number[];
17
+ }
18
+
19
+ const S = 64;
20
+ const C = S / 2;
21
+ const Z = S / 64 * 5;
22
+
23
+ const SCHEMES: readonly Scheme[] = [
24
+ /* target */ { colors: [0, 28, 0, 0, 28, 0, 0, 28, 0, 0, 28, 0, 0, 28, 0, 0, 28, 0, 1], freq: 1 },
25
+ /* cube */ { colors: [0, 1, 3, 2, 4, 3, 0, 1, 3, 2, 4, 3, 0, 1, 3, 2, 4, 3, 5], freq: 20 },
26
+ /* quazar */ { colors: [1, 2, 3, 1, 2, 4, 5, 5, 4, 1, 2, 3, 1, 2, 4, 5, 5, 4, 0], freq: 16 },
27
+ /* flower */ { colors: [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 3], freq: 32 },
28
+ /* cyclic */ { colors: [0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6], freq: 32 },
29
+ /* vmirror */ { colors: [0, 1, 2, 3, 4, 5, 3, 4, 2, 0, 1, 6, 7, 8, 9, 7, 8, 6, 10], freq: 128 },
30
+ /* hmirror */ { colors: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 8, 6, 7, 5, 3, 4, 2, 11], freq: 128 }
31
+ ];
32
+
33
+ const SCHEMES_TOTAL = SCHEMES
34
+ .map((s): number => s.freq)
35
+ .reduce((a, b): number => a + b);
36
+
37
+ const OUTER_CIRCLE: Circle = {
38
+ cx: C,
39
+ cy: C,
40
+ fill: '#eee',
41
+ r: C
42
+ };
43
+
44
+ let zeroHash: Uint8Array = new Uint8Array();
45
+
46
+ function getRotation (isSixPoint: boolean): { r: number; ro2: number; r3o4: number; ro4: number; rroot3o2: number; rroot3o4: number } {
47
+ const r = isSixPoint
48
+ ? (C / 8 * 5)
49
+ : (C / 4 * 3);
50
+ const rroot3o2 = r * Math.sqrt(3) / 2;
51
+ const ro2 = r / 2;
52
+ const rroot3o4 = r * Math.sqrt(3) / 4;
53
+ const ro4 = r / 4;
54
+ const r3o4 = r * 3 / 4;
55
+
56
+ return { r, r3o4, ro2, ro4, rroot3o2, rroot3o4 };
57
+ }
58
+
59
+ function getCircleXY (isSixPoint = false): [number, number][] {
60
+ const { r, r3o4, ro2, ro4, rroot3o2, rroot3o4 } = getRotation(isSixPoint);
61
+
62
+ return [
63
+ [C, C - r],
64
+ [C, C - ro2],
65
+ [C - rroot3o4, C - r3o4],
66
+ [C - rroot3o2, C - ro2],
67
+ [C - rroot3o4, C - ro4],
68
+ [C - rroot3o2, C],
69
+ [C - rroot3o2, C + ro2],
70
+ [C - rroot3o4, C + ro4],
71
+ [C - rroot3o4, C + r3o4],
72
+ [C, C + r],
73
+ [C, C + ro2],
74
+ [C + rroot3o4, C + r3o4],
75
+ [C + rroot3o2, C + ro2],
76
+ [C + rroot3o4, C + ro4],
77
+ [C + rroot3o2, C],
78
+ [C + rroot3o2, C - ro2],
79
+ [C + rroot3o4, C - ro4],
80
+ [C + rroot3o4, C - r3o4],
81
+ [C, C]
82
+ ];
83
+ }
84
+
85
+ function findScheme (d: number): Scheme {
86
+ let cum = 0;
87
+ const schema = SCHEMES.find((schema): boolean => {
88
+ cum += schema.freq;
89
+
90
+ return d < cum;
91
+ });
92
+
93
+ if (!schema) {
94
+ throw new Error('Unable to find schema');
95
+ }
96
+
97
+ return schema;
98
+ }
99
+
100
+ function addressToId (address: string): Uint8Array {
101
+ if (!zeroHash.length) {
102
+ zeroHash = blake2AsU8a(new Uint8Array(32), 512);
103
+ }
104
+
105
+ return blake2AsU8a(decodeAddress(address), 512).map((x, i) => (x + 256 - zeroHash[i]) % 256);
106
+ }
107
+
108
+ function getColors (address: string): string[] {
109
+ const id = addressToId(address);
110
+ const d = Math.floor((id[30] + id[31] * 256) % SCHEMES_TOTAL);
111
+ const rot = (id[28] % 6) * 3;
112
+ const sat = (Math.floor(id[29] * 70 / 256 + 26) % 80) + 30;
113
+ const scheme = findScheme(d);
114
+ const palette = Array.from(id).map((x, i): string => {
115
+ const b = (x + i % 28 * 58) % 256;
116
+
117
+ if (b === 0) {
118
+ return '#444';
119
+ } else if (b === 255) {
120
+ return 'transparent';
121
+ }
122
+
123
+ const h = Math.floor(b % 64 * 360 / 64);
124
+ const l = [53, 15, 35, 75][Math.floor(b / 64)];
125
+
126
+ return `hsl(${h}, ${sat}%, ${l}%)`;
127
+ });
128
+
129
+ return scheme.colors.map((_, i): string =>
130
+ palette[scheme.colors[i < 18 ? (i + rot) % 18 : 18]]
131
+ );
132
+ }
133
+
134
+ /**
135
+ * @description Generates an array of the circles that make up an identicon
136
+ */
137
+ export function polkadotIcon (address: string, { isAlternative }: Options): Circle[] {
138
+ const xy = getCircleXY(isAlternative);
139
+ let colors: string[];
140
+
141
+ try {
142
+ // in some cases, e.g. RN where crypto may not be initialized, chaos can
143
+ // happen when hashing, in these cases we just fill with a placeholder
144
+ colors = getColors(address);
145
+ } catch {
146
+ colors = new Array<string>(xy.length).fill('#ddd');
147
+ }
148
+
149
+ return [OUTER_CIRCLE].concat(
150
+ xy.map(([cx, cy], index): Circle => ({
151
+ cx, cy, fill: colors[index], r: Z
152
+ }))
153
+ );
154
+ }
@@ -0,0 +1,14 @@
1
+ // Copyright 2018-2025 @pezkuwi/ui-shared authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export interface Circle {
5
+ cx: number;
6
+ cy: number;
7
+ fill: string;
8
+ r: number;
9
+ }
10
+
11
+ export interface Options {
12
+ isAlternative?: boolean;
13
+ size?: number;
14
+ }
package/src/index.ts ADDED
@@ -0,0 +1,6 @@
1
+ // Copyright 2018-2025 @pezkuwi/ui-shared authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import './packageDetect.js';
5
+
6
+ export * from './bundle.js';
@@ -0,0 +1,11 @@
1
+ // Copyright 2017-2026 @pezkuwi/ui-shared authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Do not edit, auto-generated by @pezkuwi/dev
5
+ // (packageInfo imports will be kept as-is, user-editable)
6
+
7
+ import { detectPackage } from '@pezkuwi/util';
8
+
9
+ import { packageInfo } from './packageInfo.js';
10
+
11
+ detectPackage(packageInfo, null, []);
@@ -0,0 +1,6 @@
1
+ // Copyright 2017-2026 @pezkuwi/ui-shared authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Do not edit, auto-generated by @pezkuwi/dev
5
+
6
+ export const packageInfo = { name: '@pezkuwi/ui-shared', path: 'auto', type: 'auto', version: '3.16.6' };
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "baseUrl": "..",
5
+ "outDir": "./build",
6
+ "rootDir": "./src"
7
+ },
8
+ "exclude": [
9
+ "**/*.spec.ts"
10
+ ],
11
+ "references": []
12
+ }