@talismn/orb 0.3.4 → 0.3.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/orb",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "author": "Talisman",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "publishConfig": {
@@ -10,38 +10,47 @@
10
10
  "repository": {
11
11
  "directory": "packages/orb",
12
12
  "type": "git",
13
- "url": "https://github.com/talismansociety/talisman.git"
13
+ "url": "https://github.com/TalismanSociety/talisman.git"
14
14
  },
15
- "type": "module",
16
- "main": "dist/talismn-orb.cjs.js",
17
- "module": "dist/talismn-orb.esm.js",
15
+ "main": "./dist/index.js",
16
+ "module": "./dist/index.mjs",
18
17
  "dependencies": {
19
18
  "blueimp-md5": "2.19.0",
20
19
  "color": "4.2.3",
21
- "@talismn/crypto": "0.2.3"
20
+ "@talismn/crypto": "0.3.1"
22
21
  },
23
22
  "devDependencies": {
24
23
  "@types/react": "18.3.12",
25
24
  "@types/react-dom": "18.3.1",
26
- "eslint": "^8.57.1",
27
25
  "react": "18.3.1",
28
26
  "react-dom": "18.3.1",
29
27
  "typescript": "^5.6.3",
30
- "@talismn/tsconfig": "0.0.3",
31
- "@talismn/eslint-config": "0.0.3"
28
+ "@talismn/tsconfig": "0.0.4"
32
29
  },
33
30
  "peerDependencies": {
34
31
  "react": "*",
35
32
  "react-dom": "*"
36
33
  },
37
- "preconstruct": {
38
- "globals": {
39
- "react": "React",
40
- "react-dom": "ReactDOM"
34
+ "types": "./dist/index.d.ts",
35
+ "exports": {
36
+ ".": {
37
+ "@talismn/source": "./src/index.ts",
38
+ "import": {
39
+ "types": "./dist/index.d.mts",
40
+ "default": "./dist/index.mjs"
41
+ },
42
+ "require": {
43
+ "types": "./dist/index.d.ts",
44
+ "default": "./dist/index.js"
45
+ }
41
46
  }
42
47
  },
48
+ "files": [
49
+ "dist"
50
+ ],
43
51
  "scripts": {
44
- "lint": "eslint src --max-warnings 0",
45
- "clean": "rm -rf dist .turbo node_modules"
52
+ "clean": "rm -rf dist .turbo node_modules",
53
+ "build": "tsup --silent",
54
+ "typecheck": "tsc --noEmit"
46
55
  }
47
56
  }
package/CHANGELOG.md DELETED
@@ -1,61 +0,0 @@
1
- # @talismn/orb
2
-
3
- ## 0.3.4
4
-
5
- ### Patch Changes
6
-
7
- - 72acc04: chore: tidied up tsconfig.json
8
- - Updated dependencies [72acc04]
9
- - @talismn/crypto@0.2.3
10
-
11
- ## 0.3.3
12
-
13
- ### Patch Changes
14
-
15
- - Updated dependencies [e399b86]
16
- - @talismn/crypto@0.2.2
17
-
18
- ## 0.3.2
19
-
20
- ### Patch Changes
21
-
22
- - f0a103b: feat: updates for solana
23
- - Updated dependencies [a922bed]
24
- - Updated dependencies [f0a103b]
25
- - @talismn/crypto@0.2.1
26
-
27
- ## 0.3.1
28
-
29
- ### Patch Changes
30
-
31
- - 78f3616: bump pjs and papi deps
32
-
33
- ## 0.3.0
34
-
35
- ### Minor Changes
36
-
37
- - 59a150b: Show polkadot icon logo on polkadot account orbs
38
- - a8f7c1e: remove @polkadot/util-crypto dependency
39
-
40
- ### Patch Changes
41
-
42
- - 96cd696: class on orb type svg
43
- - 64e4344: bump deps
44
- - a25771e: prettier fix
45
- - c4d5967: bump typescript version
46
- - 620b7eb: Dependency updates
47
- - f78c909: Remove dependency on `nanoid`
48
- - f44f560: feat: azns lookups
49
- - 05ca588: feat: migrated to pnpm
50
-
51
- ## 0.2.0
52
-
53
- ### Minor Changes
54
-
55
- - b920ab98: Added GPL licence
56
-
57
- ## 0.1.0
58
-
59
- ### Minor Changes
60
-
61
- - 308da9f7: init
@@ -1,3 +0,0 @@
1
- import { FC } from "react";
2
- import { TalismanOrbProps } from "./types";
3
- export declare const TalismanOrb: FC<TalismanOrbProps>;
@@ -1,5 +0,0 @@
1
- import { AccountPlatform } from "@talismn/crypto";
2
- import { FC } from "react";
3
- export declare const TalismanOrbLogo: FC<{
4
- platform: AccountPlatform;
5
- }>;
@@ -1,3 +0,0 @@
1
- import { FC } from "react";
2
- import { TalismanOrbProps } from "./types";
3
- export declare const TalismanOrbRectangle: FC<TalismanOrbProps>;
@@ -1,4 +0,0 @@
1
- export * from "./types";
2
- export * from "./useTalismanOrb";
3
- export * from "./TalismanOrb";
4
- export * from "./TalismanOrbRectangle";
@@ -1,6 +0,0 @@
1
- export type TalismanOrbProps = {
2
- seed: string;
3
- width?: number;
4
- height?: number;
5
- className?: string;
6
- };
@@ -1,10 +0,0 @@
1
- export declare const useTalismanOrb: (seed: string) => {
2
- id: string;
3
- bgColor1: string;
4
- bgColor2: string;
5
- glowColor: string;
6
- transform: string;
7
- cx: number;
8
- cy: number;
9
- platform: import("@talismn/crypto").AccountPlatform;
10
- };
@@ -1,2 +0,0 @@
1
- export * from "./components";
2
- export * from "./util";
@@ -1,4 +0,0 @@
1
- /**
2
- * Returns a base64 encoded data url for the Talisman Orb svg
3
- */
4
- export declare const getTalismanOrbDataUrl: (address: string) => `data:image/svg+xml;base64,${string}`;
@@ -1 +0,0 @@
1
- export * from "./getTalismanOrbDataUrl";
@@ -1 +0,0 @@
1
- export * from "./declarations/src/index";
@@ -1,291 +0,0 @@
1
- 'use strict';
2
-
3
- var crypto = require('@talismn/crypto');
4
- var md5 = require('blueimp-md5');
5
- var Color = require('color');
6
- var react = require('react');
7
- var jsxRuntime = require('react/jsx-runtime');
8
- var ReactDOMServer = require('react-dom/server');
9
-
10
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
-
12
- var md5__default = /*#__PURE__*/_interopDefault(md5);
13
- var Color__default = /*#__PURE__*/_interopDefault(Color);
14
- var ReactDOMServer__default = /*#__PURE__*/_interopDefault(ReactDOMServer);
15
-
16
- const djb2 = str => {
17
- let hash = 5381;
18
- for (let i = 0; i < str.length; i++) hash = (hash << 5) + hash + str.charCodeAt(i);
19
- return hash;
20
- };
21
- const valueFromHash = (hash, max) => {
22
- return (max + djb2(hash)) % max;
23
- };
24
- const colorFromHash = hash => {
25
- const hue = valueFromHash(hash, 360);
26
- return Color__default.default.hsv(hue, 100, 100);
27
- };
28
- const rotateText = (text, nbChars = 0) => text.slice(nbChars) + text.slice(0, nbChars);
29
- const useTalismanOrb = seed => {
30
- const id = react.useId();
31
- return react.useMemo(() => {
32
- try {
33
- // those break if seed is empty or an invalid address
34
-
35
- // eslint-disable-next-line no-var
36
- var platform = crypto.getAccountPlatformFromAddress(seed);
37
-
38
- // seed may be specific to a ss58 prefix, get the base address
39
- // eslint-disable-next-line no-var
40
- var address = crypto.normalizeAddress(seed);
41
- } catch (err) {
42
- platform = "polkadot";
43
- address = seed;
44
- }
45
-
46
- // derive 3 hashs from the seed, used to generate the 3 colors
47
- const hash1 = md5__default.default(address);
48
- const hash2 = rotateText(hash1, 1);
49
- const hash3 = rotateText(hash1, 2);
50
-
51
- // the 2 darkest ones will be used as gradient BG
52
- // the lightest one will be used as gradient circle, to mimic a 3D lighting effect
53
- const colors = [colorFromHash(hash1), colorFromHash(hash2), colorFromHash(hash3)].sort((c1, c2) => c1.lightness() - c2.lightness());
54
-
55
- // random location in top left corner, avoid beeing to close from the center
56
- const dotX = 10 + valueFromHash(hash1, 10);
57
- const dotY = 10 + valueFromHash(hash2, 10);
58
-
59
- // global rotation
60
- const rotation = valueFromHash(hash1, 360);
61
- return {
62
- id,
63
- //multiple avatars should cohabit on the same page
64
- bgColor1: colors[0].hex(),
65
- bgColor2: colors[1].hex(),
66
- glowColor: colors[2].hex(),
67
- transform: `rotate(${rotation} 32 32)`,
68
- cx: dotX,
69
- cy: dotY,
70
- platform
71
- };
72
- }, [id, seed]);
73
- };
74
-
75
- const TalismanOrbLogo = ({
76
- platform
77
- }) => {
78
- switch (platform) {
79
- case "ethereum":
80
- return /*#__PURE__*/jsxRuntime.jsxs("g", {
81
- opacity: "0.75",
82
- transform: "scale(0.7) translate(14 14)",
83
- className: "orb-type",
84
- children: [/*#__PURE__*/jsxRuntime.jsx("path", {
85
- d: "M12.8101 32.76L32.0001 44.62L51.1901 32.76L32.0001 -0.0699997L12.8101 32.76Z",
86
- fill: "white"
87
- }), /*#__PURE__*/jsxRuntime.jsx("path", {
88
- d: "M12.8101 36.48L32.0001 48.43L51.1901 36.48L32.0001 63.93L12.8101 36.48Z",
89
- fill: "white"
90
- })]
91
- });
92
- case "polkadot":
93
- return /*#__PURE__*/jsxRuntime.jsxs("g", {
94
- opacity: "0.75",
95
- transform: "scale(2.2) translate(4.5 3.9)",
96
- className: "orb-type",
97
- children: [/*#__PURE__*/jsxRuntime.jsx("path", {
98
- d: "M9.99937 4.4612C12.1176 4.4612 13.8347 3.46253 13.8347 2.2306C13.8347 0.998674 12.1176 0 9.99937 0C7.88119 0 6.16406 0.998674 6.16406 2.2306C6.16406 3.46253 7.88119 4.4612 9.99937 4.4612Z",
99
- fill: "white"
100
- }), /*#__PURE__*/jsxRuntime.jsx("path", {
101
- d: "M9.99937 21.2683C12.1176 21.2683 13.8347 20.2697 13.8347 19.0377C13.8347 17.8058 12.1176 16.8071 9.99937 16.8071C7.88119 16.8071 6.16406 17.8058 6.16406 19.0377C6.16406 20.2697 7.88119 21.2683 9.99937 21.2683Z",
102
- fill: "white"
103
- }), /*#__PURE__*/jsxRuntime.jsx("path", {
104
- d: "M4.65427 7.54892C5.71336 5.71457 5.70649 3.72787 4.63892 3.11149C3.57135 2.49511 1.84735 3.48246 0.788259 5.31681C-0.270832 7.15115 -0.263958 9.13786 0.803612 9.75424C1.87118 10.3706 3.59518 9.38326 4.65427 7.54892Z",
105
- fill: "white"
106
- }), /*#__PURE__*/jsxRuntime.jsx("path", {
107
- d: "M19.2083 15.9515C20.2674 14.1171 20.2611 12.1307 19.1943 11.5148C18.1274 10.8988 16.404 11.8865 15.3449 13.7209C14.2858 15.5552 14.2921 17.5416 15.3589 18.1575C16.4258 18.7735 18.1492 17.7858 19.2083 15.9515Z",
108
- fill: "white"
109
- }), /*#__PURE__*/jsxRuntime.jsx("path", {
110
- d: "M4.6399 18.1571C5.70747 17.5407 5.71434 15.554 4.65525 13.7196C3.59616 11.8853 1.87216 10.8979 0.804589 11.5143C-0.262981 12.1307 -0.269855 14.1174 0.789235 15.9517C1.84833 17.7861 3.57233 18.7734 4.6399 18.1571Z",
111
- fill: "white"
112
- }), /*#__PURE__*/jsxRuntime.jsx("path", {
113
- d: "M19.1952 9.75475C20.2621 9.13878 20.2684 7.15241 19.2093 5.31807C18.1502 3.48372 16.4268 2.49603 15.3599 3.11199C14.2931 3.72796 14.2868 5.71433 15.3459 7.54867C16.405 9.38302 18.1284 10.3707 19.1952 9.75475Z",
114
- fill: "white"
115
- })]
116
- });
117
- case "solana":
118
- return /*#__PURE__*/jsxRuntime.jsx("g", {
119
- opacity: "0.75",
120
- className: "orb-type",
121
- transform: "scale(0.45) translate(37.5, 37.5)",
122
- children: /*#__PURE__*/jsxRuntime.jsx("path", {
123
- d: "M70.6648 50.1769L58.9393 62.775C58.6844 63.0486 58.376 63.2668 58.0332 63.4159C57.6905 63.5651 57.3208 63.6419 56.9472 63.6417H1.36128C1.09605 63.6417 0.836598 63.5641 0.614804 63.4184C0.393011 63.2727 0.218536 63.0652 0.112817 62.8215C0.00709765 62.5779 -0.0252603 62.3085 0.0197186 62.0467C0.0646974 61.7848 0.185054 61.5418 0.366 61.3476L12.1006 48.7496C12.3548 48.4766 12.6623 48.2589 13.0039 48.1098C13.3455 47.9607 13.714 47.8834 14.0866 47.8828H69.6695C69.9348 47.8828 70.1942 47.9604 70.416 48.1062C70.6378 48.2519 70.8123 48.4593 70.918 48.703C71.0237 48.9467 71.0561 49.216 71.0111 49.4778C70.9661 49.7397 70.8458 49.9827 70.6648 50.1769V50.1769ZM58.9393 24.8081C58.6844 24.5345 58.376 24.3163 58.0332 24.1672C57.6905 24.0181 57.3208 23.9412 56.9472 23.9414H1.36128C1.09605 23.9414 0.836598 24.019 0.614804 24.1647C0.393011 24.3105 0.218536 24.5179 0.112817 24.7616C0.00709765 25.0053 -0.0252603 25.2746 0.0197186 25.5364C0.0646974 25.7983 0.185054 26.0413 0.366 26.2355L12.1006 38.8336C12.3548 39.1065 12.6623 39.3242 13.0039 39.4733C13.3455 39.6224 13.714 39.6997 14.0866 39.7003H69.6695C69.9348 39.7003 70.1942 39.6227 70.416 39.477C70.6378 39.3313 70.8123 39.1238 70.918 38.8801C71.0237 38.6365 71.0561 38.3671 71.0111 38.1053C70.9661 37.8434 70.8458 37.6004 70.6648 37.4062L58.9393 24.8081ZM1.36128 15.7589H56.9472C57.3208 15.7591 57.6905 15.6822 58.0332 15.5331C58.376 15.384 58.6844 15.1658 58.9393 14.8922L70.6648 2.29413C70.8458 2.09986 70.9661 1.85688 71.0111 1.59502C71.0561 1.33317 71.0237 1.06385 70.918 0.820169C70.8123 0.576485 70.6378 0.369047 70.416 0.223341C70.1942 0.0776352 69.9348 8.97308e-06 69.6695 0L14.0866 0C13.714 0.000635258 13.3455 0.077888 13.0039 0.226975C12.6623 0.376063 12.3548 0.593811 12.1006 0.866739L0.369025 13.4648C0.188254 13.6588 0.0679503 13.9016 0.0228694 14.1631C-0.0222115 14.4247 0.00988974 14.6938 0.115236 14.9373C0.220583 15.1809 0.394595 15.3884 0.615931 15.5343C0.837268 15.6802 1.09631 15.7583 1.36128 15.7589V15.7589Z",
124
- fill: "white"
125
- })
126
- });
127
- default:
128
- return null;
129
- }
130
- };
131
-
132
- const TalismanOrb = ({
133
- seed,
134
- width = "1em",
135
- height = "1em",
136
- className
137
- }) => {
138
- const {
139
- id,
140
- bgColor1,
141
- bgColor2,
142
- transform,
143
- glowColor,
144
- cx,
145
- cy,
146
- platform
147
- } = useTalismanOrb(seed);
148
- return /*#__PURE__*/jsxRuntime.jsxs("svg", {
149
- width: width,
150
- height: height,
151
- viewBox: `0 0 64 64`,
152
- className: className,
153
- version: "1.1",
154
- xmlns: "http://www.w3.org/2000/svg",
155
- children: [/*#__PURE__*/jsxRuntime.jsxs("defs", {
156
- children: [/*#__PURE__*/jsxRuntime.jsxs("linearGradient", {
157
- id: `${id}-bg`,
158
- children: [/*#__PURE__*/jsxRuntime.jsx("stop", {
159
- offset: "20%",
160
- stopColor: bgColor1
161
- }), /*#__PURE__*/jsxRuntime.jsx("stop", {
162
- offset: "100%",
163
- stopColor: bgColor2
164
- })]
165
- }), /*#__PURE__*/jsxRuntime.jsxs("radialGradient", {
166
- id: `${id}-circle`,
167
- children: [/*#__PURE__*/jsxRuntime.jsx("stop", {
168
- offset: "10%",
169
- stopColor: glowColor
170
- }), /*#__PURE__*/jsxRuntime.jsx("stop", {
171
- offset: "100%",
172
- stopColor: "transparent"
173
- })]
174
- }), /*#__PURE__*/jsxRuntime.jsx("clipPath", {
175
- id: `${id}-clip`,
176
- children: /*#__PURE__*/jsxRuntime.jsx("circle", {
177
- cx: "32",
178
- cy: "32",
179
- r: "32"
180
- })
181
- })]
182
- }), /*#__PURE__*/jsxRuntime.jsxs("g", {
183
- clipPath: `url(#${id}-clip)`,
184
- children: [/*#__PURE__*/jsxRuntime.jsxs("g", {
185
- transform: transform,
186
- children: [/*#__PURE__*/jsxRuntime.jsx("rect", {
187
- fill: `url(#${id}-bg)`,
188
- x: 0,
189
- y: 0,
190
- width: 64,
191
- height: 64
192
- }), /*#__PURE__*/jsxRuntime.jsx("circle", {
193
- fill: `url(#${id}-circle)`,
194
- cx: cx,
195
- cy: cy,
196
- r: 45,
197
- opacity: 0.7
198
- })]
199
- }), /*#__PURE__*/jsxRuntime.jsx(TalismanOrbLogo, {
200
- platform: platform
201
- })]
202
- })]
203
- });
204
- };
205
-
206
- const TalismanOrbRectangle = ({
207
- width,
208
- height,
209
- seed,
210
- className
211
- }) => {
212
- const {
213
- id,
214
- bgColor1,
215
- bgColor2,
216
- transform,
217
- glowColor,
218
- cx,
219
- cy
220
- } = useTalismanOrb(seed);
221
- return /*#__PURE__*/jsxRuntime.jsxs("svg", {
222
- width: width,
223
- height: height,
224
- viewBox: `0 0 64 64`,
225
- preserveAspectRatio: "none",
226
- className: className,
227
- version: "1.1",
228
- xmlns: "http://www.w3.org/2000/svg",
229
- children: [/*#__PURE__*/jsxRuntime.jsxs("defs", {
230
- children: [/*#__PURE__*/jsxRuntime.jsxs("linearGradient", {
231
- id: `${id}-bg`,
232
- children: [/*#__PURE__*/jsxRuntime.jsx("stop", {
233
- offset: "20%",
234
- stopColor: bgColor1
235
- }), /*#__PURE__*/jsxRuntime.jsx("stop", {
236
- offset: "100%",
237
- stopColor: bgColor2
238
- })]
239
- }), /*#__PURE__*/jsxRuntime.jsxs("radialGradient", {
240
- id: `${id}-circle`,
241
- children: [/*#__PURE__*/jsxRuntime.jsx("stop", {
242
- offset: "10%",
243
- stopColor: glowColor
244
- }), /*#__PURE__*/jsxRuntime.jsx("stop", {
245
- offset: "100%",
246
- stopColor: "transparent"
247
- })]
248
- }), /*#__PURE__*/jsxRuntime.jsx("clipPath", {
249
- id: `${id}-clip`,
250
- children: /*#__PURE__*/jsxRuntime.jsx("circle", {
251
- cx: "32",
252
- cy: "32",
253
- r: "48"
254
- })
255
- })]
256
- }), /*#__PURE__*/jsxRuntime.jsx("g", {
257
- clipPath: `url(#${id}-clip)`,
258
- children: /*#__PURE__*/jsxRuntime.jsxs("g", {
259
- transform: transform,
260
- children: [/*#__PURE__*/jsxRuntime.jsx("rect", {
261
- fill: `url(#${id}-bg)`,
262
- x: -16,
263
- y: -16,
264
- width: 96,
265
- height: 96
266
- }), /*#__PURE__*/jsxRuntime.jsx("circle", {
267
- fill: `url(#${id}-circle)`,
268
- cx: cx,
269
- cy: cy,
270
- r: 45,
271
- opacity: 0.7
272
- })]
273
- })
274
- })]
275
- });
276
- };
277
-
278
- const getTalismanOrbDataUrl = address => {
279
- // render the TalismanOrb component and output the SVG as text
280
- const svg = ReactDOMServer__default.default.renderToStaticMarkup(/*#__PURE__*/jsxRuntime.jsx(TalismanOrb, {
281
- seed: address
282
- }));
283
-
284
- // convert to data url
285
- return `data:image/svg+xml;base64,${Buffer.from(svg).toString("base64")}`;
286
- };
287
-
288
- exports.TalismanOrb = TalismanOrb;
289
- exports.TalismanOrbRectangle = TalismanOrbRectangle;
290
- exports.getTalismanOrbDataUrl = getTalismanOrbDataUrl;
291
- exports.useTalismanOrb = useTalismanOrb;
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./talismn-orb.cjs.prod.js");
5
- } else {
6
- module.exports = require("./talismn-orb.cjs.dev.js");
7
- }