@hivemindhq/core 0.4.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/README.md +224 -0
- package/dist/chunk-2RGM3KJL.js +351 -0
- package/dist/chunk-2RGM3KJL.js.map +1 -0
- package/dist/chunk-E5TTKYNS.js +55 -0
- package/dist/chunk-E5TTKYNS.js.map +1 -0
- package/dist/chunk-ERZSVDIB.js +270 -0
- package/dist/chunk-ERZSVDIB.js.map +1 -0
- package/dist/chunk-H4RMZQ2Z.js +213 -0
- package/dist/chunk-H4RMZQ2Z.js.map +1 -0
- package/dist/chunk-K7EIJSYQ.js +3 -0
- package/dist/chunk-K7EIJSYQ.js.map +1 -0
- package/dist/chunk-OJF67RNM.js +3 -0
- package/dist/chunk-OJF67RNM.js.map +1 -0
- package/dist/chunk-P5E2XNDI.js +2758 -0
- package/dist/chunk-P5E2XNDI.js.map +1 -0
- package/dist/chunk-T2XWV636.js +137 -0
- package/dist/chunk-T2XWV636.js.map +1 -0
- package/dist/chunk-VIRNUAYY.js +11 -0
- package/dist/chunk-VIRNUAYY.js.map +1 -0
- package/dist/components/index.d.ts +277 -0
- package/dist/components/index.js +6 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/ui/index.d.ts +396 -0
- package/dist/components/ui/index.js +6 -0
- package/dist/components/ui/index.js.map +1 -0
- package/dist/hooks/index.d.ts +27 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/toast-D090UYOq.d.ts +19 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.d.ts +573 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/package.json +107 -0
- package/tailwind.config.js +96 -0
|
@@ -0,0 +1,573 @@
|
|
|
1
|
+
import { ClassValue } from 'clsx';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Combines class names using clsx and merges Tailwind classes intelligently.
|
|
6
|
+
* This is the standard utility for conditional and merged class names.
|
|
7
|
+
*
|
|
8
|
+
* @param inputs - Class values to combine (strings, objects, arrays)
|
|
9
|
+
* @returns Merged class string with Tailwind conflicts resolved
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* cn('px-4 py-2', isActive && 'bg-blue-500', { 'opacity-50': isDisabled })
|
|
13
|
+
* // Returns: "px-4 py-2 bg-blue-500" (if isActive is true, isDisabled is false)
|
|
14
|
+
*/
|
|
15
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Formatting utilities for display purposes
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Options for formatting crypto amounts.
|
|
22
|
+
*/
|
|
23
|
+
interface FormatCryptoAmountOptions {
|
|
24
|
+
/** Maximum significant digits before truncation (default: 10) */
|
|
25
|
+
maxSignificantDigits?: number;
|
|
26
|
+
/** Use compact notation for large numbers (default: false) */
|
|
27
|
+
compact?: boolean;
|
|
28
|
+
/** Locale for number formatting (default: 'en-US') */
|
|
29
|
+
locale?: string;
|
|
30
|
+
/** Minimum decimal places to show (default: 0) */
|
|
31
|
+
minDecimals?: number;
|
|
32
|
+
/** Maximum decimal places to show (default: 6) */
|
|
33
|
+
maxDecimals?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Result of formatting a crypto amount.
|
|
37
|
+
*/
|
|
38
|
+
interface FormattedCryptoAmount {
|
|
39
|
+
/** The display string (may be truncated) */
|
|
40
|
+
display: string;
|
|
41
|
+
/** The full value string (for tooltips) */
|
|
42
|
+
fullValue: string;
|
|
43
|
+
/** Whether the display was truncated */
|
|
44
|
+
isTruncated: boolean;
|
|
45
|
+
/** The numeric value (for calculations) */
|
|
46
|
+
numericValue: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Formats a raw crypto amount (in wei/smallest unit) for display.
|
|
50
|
+
*
|
|
51
|
+
* Handles:
|
|
52
|
+
* - Conversion from smallest unit to readable format
|
|
53
|
+
* - Truncation of excessive precision with tooltip support
|
|
54
|
+
* - Compact notation for large amounts (1.5M, 2.3B)
|
|
55
|
+
* - Locale-aware number formatting
|
|
56
|
+
*
|
|
57
|
+
* @param value - Raw amount as string or bigint (e.g., "1500000000000000000" for 1.5 tokens)
|
|
58
|
+
* @param decimals - Token decimals (default: 18)
|
|
59
|
+
* @param options - Formatting options
|
|
60
|
+
* @returns Formatted amount with display string and metadata
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* formatCryptoAmount("1500000000000000000", 18)
|
|
64
|
+
* // Returns: { display: "1.5", fullValue: "1.5", isTruncated: false, numericValue: 1.5 }
|
|
65
|
+
*
|
|
66
|
+
* formatCryptoAmount("12345678901234567890123", 18, { maxSignificantDigits: 6 })
|
|
67
|
+
* // Returns: { display: "12345.6...", fullValue: "12345.678901234567890123", isTruncated: true, ... }
|
|
68
|
+
*/
|
|
69
|
+
declare function formatCryptoAmount(value: string | bigint, decimals?: number, options?: FormatCryptoAmountOptions): FormattedCryptoAmount;
|
|
70
|
+
/**
|
|
71
|
+
* Truncates a numeric string to a maximum number of significant digits.
|
|
72
|
+
* Leading zeros in decimals don't count toward the limit.
|
|
73
|
+
*
|
|
74
|
+
* @param value - The numeric string to truncate
|
|
75
|
+
* @param maxDigits - Maximum significant digits to keep
|
|
76
|
+
* @returns Object with truncated string and whether truncation occurred
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* truncateSignificantDigits("123456789012", 10)
|
|
80
|
+
* // Returns: { truncated: "1234567890…", isTruncated: true }
|
|
81
|
+
*
|
|
82
|
+
* truncateSignificantDigits("0.0000123456789", 10)
|
|
83
|
+
* // Returns: { truncated: "0.0000123456789", isTruncated: false }
|
|
84
|
+
* // (leading zeros don't count, only 9 significant digits)
|
|
85
|
+
*/
|
|
86
|
+
declare function truncateSignificantDigits(value: string, maxDigits: number): {
|
|
87
|
+
truncated: string;
|
|
88
|
+
isTruncated: boolean;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Truncates an address or ID for display.
|
|
92
|
+
* Shows first N characters after optional prefix.
|
|
93
|
+
*
|
|
94
|
+
* @param value - The full address or ID string
|
|
95
|
+
* @param chars - Number of characters to show (default: 5)
|
|
96
|
+
* @param prefix - Prefix to skip (default: '0x')
|
|
97
|
+
* @returns Truncated string
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* truncateId('0x123456789098765432') // Returns: '12345'
|
|
101
|
+
* truncateId('0x123456789098765432', 8) // Returns: '12345678'
|
|
102
|
+
*/
|
|
103
|
+
declare function truncateId(value: string, chars?: number, prefix?: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* Converts an IPFS URI to an HTTP gateway URL.
|
|
106
|
+
*
|
|
107
|
+
* @param uri - The IPFS URI (ipfs://... format)
|
|
108
|
+
* @param gateway - The gateway to use (default: ipfs.io)
|
|
109
|
+
* @returns HTTP URL for the content
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ipfsToHttp('ipfs://QmHash123') // Returns: 'https://ipfs.io/ipfs/QmHash123'
|
|
113
|
+
*/
|
|
114
|
+
declare function ipfsToHttp(uri: string | undefined | null, gateway?: string): string | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Formats a number with compact notation (K, M, B, etc.)
|
|
117
|
+
*
|
|
118
|
+
* @param value - The number to format
|
|
119
|
+
* @param decimals - Maximum decimal places (default: 2)
|
|
120
|
+
* @returns Formatted string
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* formatCompact(1500) // Returns: '1.5K'
|
|
124
|
+
* formatCompact(2500000) // Returns: '2.5M'
|
|
125
|
+
*/
|
|
126
|
+
declare function formatCompact(value: number, decimals?: number): string;
|
|
127
|
+
/**
|
|
128
|
+
* Strengthens/normalizes an image URL to ensure it's displayable.
|
|
129
|
+
* Handles IPFS URIs, raw IPFS hashes, and validates HTTP URLs.
|
|
130
|
+
*
|
|
131
|
+
* @param url - The image URL to process
|
|
132
|
+
* @returns A normalized HTTP(S) URL
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* strengthenImageUrl('ipfs://QmHash123') // Returns: 'https://ipfs.io/ipfs/QmHash123'
|
|
136
|
+
* strengthenImageUrl('QmHash123') // Returns: 'https://ipfs.io/ipfs/QmHash123'
|
|
137
|
+
* strengthenImageUrl('https://example.com/img.png') // Returns: 'https://example.com/img.png'
|
|
138
|
+
*/
|
|
139
|
+
declare function strengthenImageUrl(url?: string): string;
|
|
140
|
+
/**
|
|
141
|
+
* Ellipsizes a string by showing characters from start and end with '...' in middle.
|
|
142
|
+
*
|
|
143
|
+
* @param str - The string to ellipsize
|
|
144
|
+
* @param length - Total visible characters (split between start and end)
|
|
145
|
+
* @returns Ellipsized string or original if shorter than length
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ellipsizeString('0x1234567890abcdef', 8) // Returns: '0x12...cdef'
|
|
149
|
+
*/
|
|
150
|
+
declare function ellipsizeString(str: string | undefined | null, length: number): string;
|
|
151
|
+
/**
|
|
152
|
+
* Ellipsizes a hex string (0x-prefixed) preserving the prefix.
|
|
153
|
+
*
|
|
154
|
+
* @param hex - The hex string to ellipsize (must start with 0x)
|
|
155
|
+
* @param length - Visible characters in the payload (default: 12)
|
|
156
|
+
* @returns Ellipsized hex string
|
|
157
|
+
* @throws Error if hex doesn't start with 0x
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ellipsizeHex('0x1234567890abcdef1234567890abcdef') // Returns: '0x123456...abcdef'
|
|
161
|
+
*/
|
|
162
|
+
declare function ellipsizeHex(hex: string, length?: number): string;
|
|
163
|
+
/**
|
|
164
|
+
* Truncates a string to a specified length, adding '...' at the end.
|
|
165
|
+
*
|
|
166
|
+
* @param str - The string to truncate
|
|
167
|
+
* @param length - Maximum length before truncation
|
|
168
|
+
* @returns Truncated string with '...' or original if shorter
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* truncateString('Hello World', 5) // Returns: 'Hello...'
|
|
172
|
+
*/
|
|
173
|
+
declare function truncateString(str: string | undefined | null, length: number): string;
|
|
174
|
+
/**
|
|
175
|
+
* Intelligently shortens a label based on its type (hex, URL, IPFS, DID, etc.)
|
|
176
|
+
* This is the main utility for displaying atom/entity labels in the UI.
|
|
177
|
+
*
|
|
178
|
+
* @param label - The label to shorten
|
|
179
|
+
* @param length - Maximum length for generic strings (default: 50)
|
|
180
|
+
* @returns Shortened label appropriate for its type
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* shortenLabel('0x1234567890abcdef...') // Returns: '0x1234...cdef'
|
|
184
|
+
* shortenLabel('https://example.com/page') // Returns: 'example.com/page'
|
|
185
|
+
* shortenLabel('ipfs://bafkre...') // Returns: 'bafkre...xyz'
|
|
186
|
+
*/
|
|
187
|
+
declare function shortenLabel(label: string | null | undefined, length?: number): string;
|
|
188
|
+
/**
|
|
189
|
+
* Capitalizes the first letter of a string.
|
|
190
|
+
*
|
|
191
|
+
* @param str - The string to capitalize
|
|
192
|
+
* @returns String with first letter capitalized
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* capitalizeFirstLetter('hello') // Returns: 'Hello'
|
|
196
|
+
*/
|
|
197
|
+
declare function capitalizeFirstLetter(str: string): string;
|
|
198
|
+
/**
|
|
199
|
+
* Capitalizes the first letter of each word in a phrase.
|
|
200
|
+
*
|
|
201
|
+
* @param phrase - The phrase to capitalize
|
|
202
|
+
* @returns Phrase with each word capitalized
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* capitalize('hello world') // Returns: 'Hello World'
|
|
206
|
+
*/
|
|
207
|
+
declare function capitalize(phrase: string): string;
|
|
208
|
+
/**
|
|
209
|
+
* Converts seconds to a compact human-readable format (e.g., "5d", "3h", "10m").
|
|
210
|
+
*
|
|
211
|
+
* @param seconds - Number of seconds
|
|
212
|
+
* @returns Compact time string
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* secondsToHms(3700) // Returns: '1h'
|
|
216
|
+
* secondsToHms(90) // Returns: '1m'
|
|
217
|
+
*/
|
|
218
|
+
declare function secondsToHms(seconds: number): string;
|
|
219
|
+
/**
|
|
220
|
+
* Formats a date as a human-readable "time ago" string.
|
|
221
|
+
* Handles various date input formats including Unix timestamps.
|
|
222
|
+
*
|
|
223
|
+
* @param date - Date object, ISO string, or Unix timestamp (10 or 13 digits)
|
|
224
|
+
* @param ago - Whether to append "ago" suffix (default: true)
|
|
225
|
+
* @returns Human-readable time difference string
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* timeAgo(new Date(Date.now() - 3600000)) // Returns: '1h ago'
|
|
229
|
+
* timeAgo('1703001600', false) // Returns: '5d'
|
|
230
|
+
*/
|
|
231
|
+
declare function timeAgo(date: Date | string, ago?: boolean): string;
|
|
232
|
+
/**
|
|
233
|
+
* Converts seconds to a descriptive duration string (e.g., "5 d", "3 h").
|
|
234
|
+
*
|
|
235
|
+
* @param inputVar - Seconds as number or string
|
|
236
|
+
* @returns Duration string with space before unit
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* secondsToDhms(90000) // Returns: '1 d'
|
|
240
|
+
*/
|
|
241
|
+
declare function secondsToDhms(inputVar: string | number): string;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Atom-related utility functions for Intuition protocol
|
|
245
|
+
*/
|
|
246
|
+
/**
|
|
247
|
+
* All possible atom types from the Intuition protocol.
|
|
248
|
+
* These correspond to the PostgreSQL enum and Rust AtomType.
|
|
249
|
+
*/
|
|
250
|
+
declare const ATOM_TYPES: readonly ["Account", "Book", "ByteObject", "Caip10", "FollowAction", "JsonObject", "Keywords", "LikeAction", "Organization", "OrganizationPredicate", "Person", "PersonPredicate", "TextObject", "Thing", "ThingPredicate", "Unknown"];
|
|
251
|
+
type AtomType = typeof ATOM_TYPES[number];
|
|
252
|
+
/**
|
|
253
|
+
* Shape of atom data that can be passed to getAtomType.
|
|
254
|
+
* Supports various atom object shapes from GraphQL responses.
|
|
255
|
+
*/
|
|
256
|
+
interface AtomTypeInput {
|
|
257
|
+
/** Direct type field from GraphQL (primary source) */
|
|
258
|
+
type?: string;
|
|
259
|
+
/** Alternate naming used in some contexts */
|
|
260
|
+
atomType?: string;
|
|
261
|
+
/** Value object with typed sub-objects (secondary source) */
|
|
262
|
+
value?: {
|
|
263
|
+
thing?: unknown;
|
|
264
|
+
person?: unknown;
|
|
265
|
+
organization?: unknown;
|
|
266
|
+
book?: unknown;
|
|
267
|
+
account?: unknown;
|
|
268
|
+
text_object?: unknown;
|
|
269
|
+
json_object?: unknown;
|
|
270
|
+
byte_object?: unknown;
|
|
271
|
+
};
|
|
272
|
+
/** Raw atom data string for pattern detection (tertiary source) */
|
|
273
|
+
data?: string;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Extracts the atom type from an atom object using a cascade/fallback strategy:
|
|
277
|
+
*
|
|
278
|
+
* 1. **Primary**: Direct `type` or `atomType` field from GraphQL
|
|
279
|
+
* 2. **Secondary**: Inferred from populated `value.*` sub-objects
|
|
280
|
+
* 3. **Tertiary**: Pattern detection from `data` string
|
|
281
|
+
*
|
|
282
|
+
* @param atom - Atom object with type information
|
|
283
|
+
* @returns The atom type string, or undefined if not determinable
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* // From GraphQL type field
|
|
287
|
+
* getAtomType({ type: 'Person' }) // Returns: 'Person'
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* // From value sub-object
|
|
291
|
+
* getAtomType({ value: { person: { name: 'Vitalik' } } }) // Returns: 'Person'
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* // From text_object value (plain text atoms)
|
|
295
|
+
* getAtomType({ value: { text_object: { data: 'Revel8' } } }) // Returns: 'TextObject'
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* // From data pattern
|
|
299
|
+
* getAtomType({ data: '0x1234...5678' }) // Returns: 'Account'
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* // Plain text detection
|
|
303
|
+
* getAtomType({ data: 'Revel8' }) // Returns: 'TextObject'
|
|
304
|
+
* getAtomType({ data: 'Kylan Hurt' }) // Returns: 'TextObject'
|
|
305
|
+
*/
|
|
306
|
+
declare function getAtomType(atom: AtomTypeInput): AtomType | undefined;
|
|
307
|
+
/**
|
|
308
|
+
* Formats an atom type for display purposes.
|
|
309
|
+
* Converts internal type names to user-friendly labels.
|
|
310
|
+
*
|
|
311
|
+
* @param type - The atom type string
|
|
312
|
+
* @returns Formatted display string
|
|
313
|
+
*
|
|
314
|
+
* @example
|
|
315
|
+
* formatAtomType('TextObject') // Returns: 'Text'
|
|
316
|
+
* formatAtomType('PersonPredicate') // Returns: 'Person Predicate'
|
|
317
|
+
* formatAtomType('FollowAction') // Returns: 'Follow'
|
|
318
|
+
*/
|
|
319
|
+
declare function formatAtomType(type: string | undefined): string;
|
|
320
|
+
/**
|
|
321
|
+
* Checks if an atom type is a predicate type.
|
|
322
|
+
* Predicates are used as the middle component of triples.
|
|
323
|
+
*
|
|
324
|
+
* @param type - The atom type to check
|
|
325
|
+
* @returns True if the type is a predicate
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* isPredicateType('ThingPredicate') // Returns: true
|
|
329
|
+
* isPredicateType('Person') // Returns: false
|
|
330
|
+
*/
|
|
331
|
+
declare function isPredicateType(type: string | undefined): boolean;
|
|
332
|
+
/**
|
|
333
|
+
* Checks if an atom type represents a structured entity (Person, Organization, Thing).
|
|
334
|
+
* These types typically have rich metadata from schema.org.
|
|
335
|
+
*
|
|
336
|
+
* @param type - The atom type to check
|
|
337
|
+
* @returns True if the type is a structured entity
|
|
338
|
+
*/
|
|
339
|
+
declare function isEntityType(type: string | undefined): boolean;
|
|
340
|
+
/**
|
|
341
|
+
* Checks if an atom type is a raw data type (TextObject, JsonObject, ByteObject).
|
|
342
|
+
* These types contain data without schema.org structure.
|
|
343
|
+
*
|
|
344
|
+
* @param type - The atom type to check
|
|
345
|
+
* @returns True if the type is a raw data type
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* isRawDataType('TextObject') // Returns: true
|
|
349
|
+
* isRawDataType('Person') // Returns: false
|
|
350
|
+
*/
|
|
351
|
+
declare function isRawDataType(type: string | undefined): boolean;
|
|
352
|
+
/**
|
|
353
|
+
* Checks if an atom type is plain text (TextObject).
|
|
354
|
+
* Plain text atoms contain simple strings like names, labels, or concepts.
|
|
355
|
+
*
|
|
356
|
+
* @param type - The atom type to check
|
|
357
|
+
* @returns True if the type is TextObject
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* isPlainTextType('TextObject') // Returns: true
|
|
361
|
+
* isPlainTextType('Person') // Returns: false
|
|
362
|
+
*/
|
|
363
|
+
declare function isPlainTextType(type: string | undefined): boolean;
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Shared type definitions for atom search functionality
|
|
367
|
+
* Used by both revel8-explorer and intuition-extension
|
|
368
|
+
*/
|
|
369
|
+
/**
|
|
370
|
+
* Vault data from GraphQL response
|
|
371
|
+
*/
|
|
372
|
+
interface AtomVault {
|
|
373
|
+
market_cap?: string;
|
|
374
|
+
total_shares?: string;
|
|
375
|
+
current_share_price?: string;
|
|
376
|
+
position_count?: number;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Value sub-objects from GraphQL - resolved IPFS/schema.org data
|
|
380
|
+
*/
|
|
381
|
+
interface AtomValue {
|
|
382
|
+
thing?: {
|
|
383
|
+
name?: string;
|
|
384
|
+
description?: string;
|
|
385
|
+
image?: string;
|
|
386
|
+
url?: string;
|
|
387
|
+
};
|
|
388
|
+
person?: {
|
|
389
|
+
name?: string;
|
|
390
|
+
description?: string;
|
|
391
|
+
image?: string;
|
|
392
|
+
url?: string;
|
|
393
|
+
};
|
|
394
|
+
organization?: {
|
|
395
|
+
name?: string;
|
|
396
|
+
description?: string;
|
|
397
|
+
image?: string;
|
|
398
|
+
url?: string;
|
|
399
|
+
};
|
|
400
|
+
account?: {
|
|
401
|
+
label?: string;
|
|
402
|
+
id?: string;
|
|
403
|
+
};
|
|
404
|
+
text_object?: {
|
|
405
|
+
data?: string;
|
|
406
|
+
};
|
|
407
|
+
json_object?: {
|
|
408
|
+
data?: unknown;
|
|
409
|
+
};
|
|
410
|
+
byte_object?: {
|
|
411
|
+
data?: string;
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Creator information
|
|
416
|
+
*/
|
|
417
|
+
interface AtomCreator {
|
|
418
|
+
id: string;
|
|
419
|
+
label?: string;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Raw atom shape from GraphQL response
|
|
423
|
+
* This matches what the API returns - use directly without transformation
|
|
424
|
+
*/
|
|
425
|
+
interface GraphQLAtom {
|
|
426
|
+
term_id: string;
|
|
427
|
+
label?: string;
|
|
428
|
+
data?: string;
|
|
429
|
+
type?: string;
|
|
430
|
+
emoji?: string;
|
|
431
|
+
image?: string;
|
|
432
|
+
created_at?: string;
|
|
433
|
+
creator?: AtomCreator;
|
|
434
|
+
term?: {
|
|
435
|
+
vaults?: AtomVault[];
|
|
436
|
+
};
|
|
437
|
+
value?: AtomValue;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Ranked atom with search scores
|
|
441
|
+
* Extends GraphQLAtom with computed ranking fields
|
|
442
|
+
*/
|
|
443
|
+
interface RankedAtom extends GraphQLAtom {
|
|
444
|
+
/** Match quality score based on search term relevance */
|
|
445
|
+
matchScore: number;
|
|
446
|
+
/** Stake amount for primary sorting */
|
|
447
|
+
stakeScore: number;
|
|
448
|
+
/** Whether this is an exact label match */
|
|
449
|
+
isExactMatch: boolean;
|
|
450
|
+
/** Whether this is an exact term_id match */
|
|
451
|
+
isExactTermIdMatch: boolean;
|
|
452
|
+
/** Combined score for debugging/display */
|
|
453
|
+
totalScore: number;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Summary of search results for display
|
|
457
|
+
*/
|
|
458
|
+
interface SearchSummary {
|
|
459
|
+
totalMatches: number;
|
|
460
|
+
totalStaked: string;
|
|
461
|
+
totalPositions: number;
|
|
462
|
+
topMatches: RankedAtom[];
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Complete search result
|
|
466
|
+
*/
|
|
467
|
+
interface SearchResult<T extends GraphQLAtom = GraphQLAtom> {
|
|
468
|
+
matches: T[];
|
|
469
|
+
summary: SearchSummary;
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Atom search ranking utilities
|
|
474
|
+
* Provides stake-first ranking with relevance as secondary sort
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* import { rankAtoms } from '@revel8/core'
|
|
478
|
+
* const rankedResults = rankAtoms(response.data.atoms, searchTerm)
|
|
479
|
+
*/
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Calculate match score between text and search term
|
|
483
|
+
* Used for relevance ranking in search results
|
|
484
|
+
*
|
|
485
|
+
* @param text - The text to check for matches
|
|
486
|
+
* @param searchTerm - The search term to match against
|
|
487
|
+
* @returns Score from 0-100 based on match quality
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
* calculateMatchScore('Vitalik Buterin', 'vitalik') // 90 (starts with)
|
|
491
|
+
* calculateMatchScore('About Vitalik', 'vitalik') // ~47 (contains at position 6)
|
|
492
|
+
* calculateMatchScore('Vitalik', 'vitalik') // 100 (exact match)
|
|
493
|
+
*/
|
|
494
|
+
declare function calculateMatchScore(text: string, searchTerm: string): number;
|
|
495
|
+
/**
|
|
496
|
+
* Rank and sort atoms by stake amount with relevance as secondary sort
|
|
497
|
+
*
|
|
498
|
+
* Algorithm:
|
|
499
|
+
* 1. Exact term_id matches always come first
|
|
500
|
+
* 2. Primary sort: By stake (market_cap, highest first)
|
|
501
|
+
* 3. Secondary sort: By match quality score
|
|
502
|
+
*
|
|
503
|
+
* @param atoms - Array of atoms from GraphQL response
|
|
504
|
+
* @param searchTerm - The search term used for relevance scoring
|
|
505
|
+
* @returns Sorted array with ranking metadata added
|
|
506
|
+
*
|
|
507
|
+
* @example
|
|
508
|
+
* const atoms = response.data.atoms
|
|
509
|
+
* const ranked = rankAtoms(atoms, 'vitalik')
|
|
510
|
+
* // Returns atoms sorted by stake, with matchScore, stakeScore, etc. added
|
|
511
|
+
*/
|
|
512
|
+
declare function rankAtoms<T extends GraphQLAtom>(atoms: T[], searchTerm: string): (T & RankedAtom)[];
|
|
513
|
+
/**
|
|
514
|
+
* Get the display name for an atom
|
|
515
|
+
* Checks value sub-objects first, falls back to label, then data
|
|
516
|
+
*
|
|
517
|
+
* @param atom - The atom to get display name for
|
|
518
|
+
* @returns The best display name available
|
|
519
|
+
*/
|
|
520
|
+
declare function getAtomDisplayName(atom: GraphQLAtom): string;
|
|
521
|
+
/**
|
|
522
|
+
* Get the description for an atom from value sub-objects
|
|
523
|
+
*
|
|
524
|
+
* @param atom - The atom to get description for
|
|
525
|
+
* @returns The description if available, empty string otherwise
|
|
526
|
+
*/
|
|
527
|
+
declare function getAtomDescription(atom: GraphQLAtom): string;
|
|
528
|
+
/**
|
|
529
|
+
* Get the image URL for an atom from value sub-objects
|
|
530
|
+
* Handles IPFS URLs by converting to gateway URLs
|
|
531
|
+
*
|
|
532
|
+
* @param atom - The atom to get image for
|
|
533
|
+
* @returns The image URL or empty string
|
|
534
|
+
*/
|
|
535
|
+
declare function getAtomImage(atom: GraphQLAtom): string;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Format stake amount for display (converts from wei to TRUST with suffixes)
|
|
539
|
+
*
|
|
540
|
+
* @param marketCap - The market cap in wei (18 decimals)
|
|
541
|
+
* @returns Formatted string like "1.5K", "2.3M", etc.
|
|
542
|
+
*
|
|
543
|
+
* @example
|
|
544
|
+
* formatStake('1000000000000000000') // "1"
|
|
545
|
+
* formatStake('1500000000000000000000') // "1.5K"
|
|
546
|
+
* formatStake('2300000000000000000000000') // "2.3M"
|
|
547
|
+
*/
|
|
548
|
+
declare function formatStake(marketCap: string | number | undefined): string;
|
|
549
|
+
/**
|
|
550
|
+
* Highlight matching text in search results
|
|
551
|
+
* Returns React elements with highlighted portions
|
|
552
|
+
*
|
|
553
|
+
* @param text - The text to highlight
|
|
554
|
+
* @param searchTerm - The search term to highlight
|
|
555
|
+
* @returns React elements with matching text highlighted
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
* highlightMatch('Vitalik Buterin', 'vitalik')
|
|
559
|
+
* // Returns: [<strong>Vitalik</strong>, ' Buterin']
|
|
560
|
+
*/
|
|
561
|
+
declare function highlightMatch(text: string, searchTerm: string): React__default.ReactNode;
|
|
562
|
+
/**
|
|
563
|
+
* Format a term_id for display (first 5 characters after 0x)
|
|
564
|
+
*
|
|
565
|
+
* @param termId - The full term_id (e.g., "0x123456789...")
|
|
566
|
+
* @returns Shortened display format (e.g., "12345")
|
|
567
|
+
*
|
|
568
|
+
* @example
|
|
569
|
+
* formatTermId('0x123456789098765432') // "12345"
|
|
570
|
+
*/
|
|
571
|
+
declare function formatTermId(termId: string): string;
|
|
572
|
+
|
|
573
|
+
export { ATOM_TYPES, type AtomCreator, type AtomType, type AtomTypeInput, type AtomValue, type AtomVault, type FormatCryptoAmountOptions, type FormattedCryptoAmount, type GraphQLAtom, type RankedAtom, type SearchResult, type SearchSummary, calculateMatchScore, capitalize, capitalizeFirstLetter, cn, ellipsizeHex, ellipsizeString, formatAtomType, formatCompact, formatCryptoAmount, formatStake, formatTermId, getAtomDescription, getAtomDisplayName, getAtomImage, getAtomType, highlightMatch, ipfsToHttp, isEntityType, isPlainTextType, isPredicateType, isRawDataType, rankAtoms, secondsToDhms, secondsToHms, shortenLabel, strengthenImageUrl, timeAgo, truncateId, truncateSignificantDigits, truncateString };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ATOM_TYPES, calculateMatchScore, formatAtomType, formatStake, formatTermId, getAtomDescription, getAtomDisplayName, getAtomImage, getAtomType, highlightMatch, isEntityType, isPlainTextType, isPredicateType, isRawDataType, rankAtoms } from '../chunk-H4RMZQ2Z.js';
|
|
2
|
+
export { capitalize, capitalizeFirstLetter, ellipsizeHex, ellipsizeString, formatCompact, formatCryptoAmount, ipfsToHttp, secondsToDhms, secondsToHms, shortenLabel, strengthenImageUrl, timeAgo, truncateId, truncateSignificantDigits, truncateString } from '../chunk-ERZSVDIB.js';
|
|
3
|
+
export { cn } from '../chunk-VIRNUAYY.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/package.json
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hivemindhq/core",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Shared components, utilities, and types for hivemindhq applications",
|
|
5
|
+
"author": "Kylan Hurt <kylan@hivemindhq.io>",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "./dist/index.js",
|
|
9
|
+
"module": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./utils": {
|
|
17
|
+
"types": "./dist/utils/index.d.ts",
|
|
18
|
+
"import": "./dist/utils/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./hooks": {
|
|
21
|
+
"types": "./dist/hooks/index.d.ts",
|
|
22
|
+
"import": "./dist/hooks/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./components/ui": {
|
|
25
|
+
"types": "./dist/components/ui/index.d.ts",
|
|
26
|
+
"import": "./dist/components/ui/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./components": {
|
|
29
|
+
"types": "./dist/components/index.d.ts",
|
|
30
|
+
"import": "./dist/components/index.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"tailwind.config.js"
|
|
36
|
+
],
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup",
|
|
39
|
+
"dev": "tsup --watch",
|
|
40
|
+
"clean": "rm -rf dist",
|
|
41
|
+
"typecheck": "tsc --noEmit",
|
|
42
|
+
"prepublishOnly": "pnpm run build"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
46
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
47
|
+
"tailwindcss": "^3.0.0 || ^4.0.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"tailwindcss": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@hookform/resolvers": "^3.0.0 || ^4.0.0 || ^5.0.0",
|
|
56
|
+
"@radix-ui/react-avatar": "^1.1.0",
|
|
57
|
+
"@radix-ui/react-checkbox": "^1.1.0",
|
|
58
|
+
"@radix-ui/react-collapsible": "^1.1.0",
|
|
59
|
+
"@radix-ui/react-dialog": "^1.1.0",
|
|
60
|
+
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
61
|
+
"@radix-ui/react-label": "^2.1.0",
|
|
62
|
+
"@radix-ui/react-popover": "^1.1.0",
|
|
63
|
+
"@radix-ui/react-progress": "^1.1.0",
|
|
64
|
+
"@radix-ui/react-radio-group": "^1.2.0",
|
|
65
|
+
"@radix-ui/react-scroll-area": "^1.2.0",
|
|
66
|
+
"@radix-ui/react-select": "^2.1.0",
|
|
67
|
+
"@radix-ui/react-separator": "^1.1.0",
|
|
68
|
+
"@radix-ui/react-slot": "^1.1.0",
|
|
69
|
+
"@radix-ui/react-switch": "^1.1.0",
|
|
70
|
+
"@radix-ui/react-tabs": "^1.1.0",
|
|
71
|
+
"@radix-ui/react-toast": "^1.2.0",
|
|
72
|
+
"@radix-ui/react-toggle": "^1.1.0",
|
|
73
|
+
"@radix-ui/react-toggle-group": "^1.1.0",
|
|
74
|
+
"@radix-ui/react-tooltip": "^1.1.0",
|
|
75
|
+
"class-variance-authority": "^0.7.0",
|
|
76
|
+
"clsx": "^2.1.0",
|
|
77
|
+
"cmdk": "^1.0.0",
|
|
78
|
+
"embla-carousel-react": "^8.0.0",
|
|
79
|
+
"lucide-react": "^0.400.0",
|
|
80
|
+
"next-themes": "^0.3.0 || ^0.4.0",
|
|
81
|
+
"react-hook-form": "^7.50.0",
|
|
82
|
+
"recharts": "^2.10.0",
|
|
83
|
+
"sonner": "^1.5.0 || ^2.0.0",
|
|
84
|
+
"tailwind-merge": "^2.5.0 || ^3.0.0",
|
|
85
|
+
"zod": "^3.22.0 || ^4.0.0"
|
|
86
|
+
},
|
|
87
|
+
"devDependencies": {
|
|
88
|
+
"@types/react": "^18.0.0 || ^19.0.0",
|
|
89
|
+
"@types/react-dom": "^18.0.0 || ^19.0.0",
|
|
90
|
+
"react": "^19.0.0",
|
|
91
|
+
"react-dom": "^19.0.0",
|
|
92
|
+
"tsup": "^8.0.0",
|
|
93
|
+
"typescript": "^5.0.0"
|
|
94
|
+
},
|
|
95
|
+
"keywords": [
|
|
96
|
+
"hive mind",
|
|
97
|
+
"hivemind",
|
|
98
|
+
"intuition",
|
|
99
|
+
"web3",
|
|
100
|
+
"components",
|
|
101
|
+
"react"
|
|
102
|
+
],
|
|
103
|
+
"repository": {
|
|
104
|
+
"type": "git",
|
|
105
|
+
"url": "https://github.com/hivemindhq-io/core.git"
|
|
106
|
+
}
|
|
107
|
+
}
|