@lukso/transaction-view-headless 0.2.2-dev.a8c9315

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 (76) hide show
  1. package/.turbo/turbo-build.log +51 -0
  2. package/CHANGELOG.md +88 -0
  3. package/COMPONENT_ARCHITECTURE.md +190 -0
  4. package/COMPONENT_CONVERSION_ANALYSIS.md +371 -0
  5. package/CONTEXT_VARIANT_GUIDE.md +425 -0
  6. package/LAZY_LOADING_GUIDE.md +534 -0
  7. package/LICENSE +201 -0
  8. package/PLAYBACK_EXAMPLES.md +658 -0
  9. package/PLAYBACK_GUIDE.md +402 -0
  10. package/README.md +43 -0
  11. package/REGISTRY_SUMMARY.md +638 -0
  12. package/SUFFERING_ECONOMICS.md +346 -0
  13. package/SUFFERING_ECONOMICS.zip +0 -0
  14. package/VIEW_REGISTRATION_GUIDE.md +795 -0
  15. package/dist/composables/index.cjs +1321 -0
  16. package/dist/composables/index.cjs.map +1 -0
  17. package/dist/composables/index.d.cts +6 -0
  18. package/dist/composables/index.d.ts +6 -0
  19. package/dist/composables/index.js +1276 -0
  20. package/dist/composables/index.js.map +1 -0
  21. package/dist/index-CMLU1hKL.d.ts +374 -0
  22. package/dist/index-CSDjhiKV.d.cts +374 -0
  23. package/dist/index.cjs +1534 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +93 -0
  26. package/dist/index.d.ts +93 -0
  27. package/dist/index.js +1463 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/registry/index.cjs +522 -0
  30. package/dist/registry/index.cjs.map +1 -0
  31. package/dist/registry/index.d.cts +46 -0
  32. package/dist/registry/index.d.ts +46 -0
  33. package/dist/registry/index.js +487 -0
  34. package/dist/registry/index.js.map +1 -0
  35. package/dist/types/index.cjs +19 -0
  36. package/dist/types/index.cjs.map +1 -0
  37. package/dist/types/index.d.cts +203 -0
  38. package/dist/types/index.d.ts +203 -0
  39. package/dist/types/index.js +1 -0
  40. package/dist/types/index.js.map +1 -0
  41. package/dist/utils/index.cjs +217 -0
  42. package/dist/utils/index.cjs.map +1 -0
  43. package/dist/utils/index.d.cts +47 -0
  44. package/dist/utils/index.d.ts +47 -0
  45. package/dist/utils/index.js +188 -0
  46. package/dist/utils/index.js.map +1 -0
  47. package/dist/view-loader-dD86QAlQ.d.cts +121 -0
  48. package/dist/view-loader-ii8AxiQR.d.ts +121 -0
  49. package/package.json +64 -0
  50. package/publish.log +0 -0
  51. package/src/composables/index.ts +59 -0
  52. package/src/composables/use-image-loader.ts +315 -0
  53. package/src/composables/use-transaction-playback.ts +396 -0
  54. package/src/composables/use-transaction-view.ts +309 -0
  55. package/src/config/lukso-config.ts +171 -0
  56. package/src/examples/context-aware-views.ts +300 -0
  57. package/src/examples/example-views.ts +197 -0
  58. package/src/examples/lit-plus-rn-strategy.ts +448 -0
  59. package/src/examples/lsp7-custom-matcher-examples.ts +174 -0
  60. package/src/examples/opt-in-context-examples.ts +372 -0
  61. package/src/examples/optimized-view-definitions.ts +408 -0
  62. package/src/examples/vue-to-lit-compilation.ts +358 -0
  63. package/src/hooks/useAddressQuery.ts +135 -0
  64. package/src/hooks/useAddressResolution.ts +437 -0
  65. package/src/index.ts +36 -0
  66. package/src/registry/index.ts +13 -0
  67. package/src/registry/view-loader.ts +305 -0
  68. package/src/registry/view-registry.ts +135 -0
  69. package/src/types/index.ts +16 -0
  70. package/src/types/view-contexts.ts +72 -0
  71. package/src/types/view-matching.ts +173 -0
  72. package/src/utils/context-matcher.ts +165 -0
  73. package/src/utils/index.ts +5 -0
  74. package/src/utils/view-matcher.ts +338 -0
  75. package/tsconfig.json +20 -0
  76. package/tsup.config.ts +34 -0
@@ -0,0 +1,371 @@
1
+ # Vue to Lit + React Native Component Conversion Analysis
2
+
3
+ ## Current Vue Component Architecture Analysis
4
+
5
+ ### Transaction Components (`components/transactions/`)
6
+
7
+ **Main Transaction Views:**
8
+ - `LSP7Transfer.vue` - Token transfer view
9
+ - `LSP8Transfer.vue` - NFT transfer view
10
+ - `SetData.vue` - Data setting operations
11
+ - `SetDataBatch.vue` - Batch data operations
12
+ - Plus ~15 other transaction types
13
+
14
+ **Transaction Helpers (`TransactionIFrame/helpers/`):**
15
+ - `DigitalAssetInfo.vue` - Asset card with image, name, amount
16
+ - `AddressBox.vue` - Address display boxes
17
+ - `TokenBalance.vue` - Token amount formatting
18
+ - `Title.vue` - Transaction titles with icons
19
+ - `BackPanelAsset.vue` - Expandable asset details
20
+
21
+ ### Shared Components (`components/shared/`)
22
+
23
+ **Core Display Components:**
24
+ - `AddressView.vue` - Universal address display with profiles
25
+ - `FormattedTokenAmount.vue` - Smart token amount formatting
26
+ - `ProfileCard.vue` - Universal Profile cards
27
+ - `Picture.vue` - Image handling with fallbacks
28
+ - `UserName.vue` - Profile name display
29
+
30
+ **UI Components:**
31
+ - `Button.vue`, `IconButton.vue` - Buttons
32
+ - `Tooltip/` - Tooltip system
33
+ - `Modal/` - Modal dialogs
34
+ - `Spinner.vue`, `Skeleton.vue` - Loading states
35
+ - `SvgIcon.vue` - Icon system
36
+
37
+ ## Key Architectural Patterns Identified
38
+
39
+ ### 1. **LUKSO Web Components Integration**
40
+ ```vue
41
+ <!-- Current: Vue wraps LUKSO web components -->
42
+ <lukso-profile
43
+ :profile-address="address"
44
+ :profile-url="image?.src"
45
+ size="x-small"
46
+ has-identicon
47
+ />
48
+ <lukso-username
49
+ :name="name"
50
+ :address="address"
51
+ max-width="500"
52
+ />
53
+ ```
54
+
55
+ ### 2. **Complex Async Data Loading**
56
+ ```javascript
57
+ // Current: Vue composables with async image loading
58
+ const assetImage = computedAsync(async () => {
59
+ const imageGroup = props.address?.images?.[0] || []
60
+ return await getImage(imageGroup, { width: 120, height: 120 })
61
+ })
62
+ ```
63
+
64
+ ### 3. **Business Logic Dependencies**
65
+ - Heavy reliance on `~/lib/decoder/types`
66
+ - GraphQL image resolution via `~/lib/graphql`
67
+ - Token conversion utilities
68
+ - Profile/asset data models
69
+
70
+ ### 4. **Styling System**
71
+ - SCSS with design system variables (`var(--neutral-90)`)
72
+ - Typography mixins (`@extend %paragraph-inter-12-medium`)
73
+ - Responsive design patterns
74
+
75
+ ## Conversion Strategy
76
+
77
+ ### Phase 1: Extract Business Logic to decoder-headless
78
+
79
+ **Move to decoder-headless composables:**
80
+ ```typescript
81
+ // @lukso/transaction-view-headless/src/composables/use-asset-info.ts
82
+ export function useAssetInfo(address: string) {
83
+ // Extract image loading, profile resolution, etc.
84
+ return {
85
+ assetImage: async () => getImage(...),
86
+ profileData: async () => resolveProfile(...),
87
+ tokenMetadata: async () => getTokenMetadata(...)
88
+ }
89
+ }
90
+ ```
91
+
92
+ **Benefits:**
93
+ - ✅ Shared between Lit and React Native
94
+ - ✅ Framework-agnostic business logic
95
+ - ✅ Consistent data handling
96
+
97
+ ### Phase 2: Lit Component Conversion
98
+
99
+ **Transaction Views → Lit Components:**
100
+ ```typescript
101
+ // @lukso/decoder-web-components/src/lsp7-transfer-view.ts
102
+ @customElement('lsp7-transfer-view')
103
+ export class LSP7TransferView extends LitElement {
104
+ @property({ type: Object }) transaction!: DecoderResult
105
+ @property({ type: Boolean }) showActions = false
106
+ @property({ type: String }) context = 'detail'
107
+
108
+ private assetInfo = new TaskController(this, {
109
+ task: ([transaction]) => this.loadAssetInfo(transaction),
110
+ args: () => [this.transaction]
111
+ })
112
+
113
+ render() {
114
+ return html`
115
+ <div class="lsp7-transfer">
116
+ <transaction-title title="Transfer Token" icon="transfer">
117
+ <div class="lsp-tag">LSP7-DigitalAsset</div>
118
+ </transaction-title>
119
+
120
+ <digital-asset-info
121
+ .transaction=${this.transaction}
122
+ .assetData=${this.assetInfo.value}
123
+ @toggle-panel=${this.handleTogglePanel}
124
+ ></digital-asset-info>
125
+
126
+ ${this.showActions ? html`
127
+ <div class="actions">
128
+ <button @click=${this.handleReject}>Reject</button>
129
+ <button @click=${this.handleApprove}>Approve</button>
130
+ </div>
131
+ ` : ''}
132
+ </div>
133
+ `
134
+ }
135
+ }
136
+ ```
137
+
138
+ **Shared Components → Lit Components:**
139
+ ```typescript
140
+ // @lukso/decoder-web-components/src/shared/address-display.ts
141
+ @customElement('address-display')
142
+ export class AddressDisplay extends LitElement {
143
+ @property() address!: string
144
+ @property({ type: Object }) resolved?: ProfileData
145
+ @property({ type: Boolean }) hasSquareIcon = false
146
+ @property({ type: String }) size = 'small'
147
+
148
+ render() {
149
+ return html`
150
+ <div class="address-display">
151
+ <lukso-profile
152
+ profile-address=${this.address}
153
+ profile-url=${this.resolved?.image?.src}
154
+ size=${this.size}
155
+ has-identicon
156
+ ?is-square=${this.hasSquareIcon}
157
+ ></lukso-profile>
158
+ <lukso-username
159
+ name=${this.resolved?.name || 'Anonymous'}
160
+ address=${this.address}
161
+ max-width="200"
162
+ size=${this.size}
163
+ ></lukso-username>
164
+ </div>
165
+ `
166
+ }
167
+ }
168
+ ```
169
+
170
+ ### Phase 3: React Native Component Conversion
171
+
172
+ **Transaction Views → React Native:**
173
+ ```tsx
174
+ // @lukso/decoder-rn-views/src/LSP7Transfer.tsx
175
+ export function LSP7Transfer({
176
+ transaction,
177
+ showActions = false,
178
+ onApprove,
179
+ onReject
180
+ }: LSP7TransferProps) {
181
+ const { assetImage, profileData, isLoading } = useAssetInfo(transaction)
182
+
183
+ return (
184
+ <View style={styles.container}>
185
+ <TransactionTitle
186
+ title="Transfer Token"
187
+ icon="transfer"
188
+ tag="LSP7-DigitalAsset"
189
+ />
190
+
191
+ <DigitalAssetInfo
192
+ transaction={transaction}
193
+ assetData={assetImage}
194
+ profileData={profileData}
195
+ isLoading={isLoading}
196
+ onTogglePanel={handleTogglePanel}
197
+ />
198
+
199
+ {showActions && (
200
+ <View style={styles.actions}>
201
+ <Button variant="secondary" onPress={onReject}>
202
+ Reject
203
+ </Button>
204
+ <Button variant="primary" onPress={onApprove}>
205
+ Approve
206
+ </Button>
207
+ </View>
208
+ )}
209
+ </View>
210
+ )
211
+ }
212
+ ```
213
+
214
+ **Shared Components → React Native:**
215
+ ```tsx
216
+ // @lukso/decoder-rn-views/src/shared/AddressDisplay.tsx
217
+ export function AddressDisplay({
218
+ address,
219
+ resolved,
220
+ hasSquareIcon = false,
221
+ size = 'small',
222
+ onPress
223
+ }: AddressDisplayProps) {
224
+ return (
225
+ <TouchableOpacity style={styles.container} onPress={onPress}>
226
+ <ProfileImage
227
+ address={address}
228
+ imageUrl={resolved?.image?.src}
229
+ size={size}
230
+ hasSquareIcon={hasSquareIcon}
231
+ />
232
+ <Text style={[styles.name, sizeStyles[size]]}>
233
+ {resolved?.name || 'Anonymous'}
234
+ </Text>
235
+ <Text style={[styles.address, sizeStyles[size]]}>
236
+ {formatAddress(address)}
237
+ </Text>
238
+ </TouchableOpacity>
239
+ )
240
+ }
241
+ ```
242
+
243
+ ## Component Dependency Analysis
244
+
245
+ ### Critical Shared Dependencies
246
+
247
+ **1. LUKSO Web Components (`@lukso/web-components`)**
248
+ - Used extensively in Vue components
249
+ - Need Lit equivalents: `<lukso-profile>`, `<lukso-username>`
250
+ - React Native needs native replacements
251
+
252
+ **2. Image Processing System**
253
+ - `getImage()` with width/height/dpr optimization
254
+ - IPFS image resolution
255
+ - Fallback handling for missing images
256
+
257
+ **3. Token Amount Formatting**
258
+ - Complex BigNumber calculations
259
+ - Locale-aware formatting
260
+ - Special handling for LYX/LYXt
261
+ - Tooltip for truncated values
262
+
263
+ **4. Profile/Asset Resolution**
264
+ - GraphQL queries for metadata
265
+ - Universal Profile data structure
266
+ - Asset metadata (LSP4, LSP8)
267
+
268
+ ### Component Conversion Priority
269
+
270
+ **High Priority (Core Transaction Views):**
271
+ 1. `LSP7Transfer` - Most common transaction
272
+ 2. `LSP8Transfer` - NFT transfers
273
+ 3. `SetData` - Universal Profile updates
274
+ 4. `ExecuteBatch` - Complex transactions
275
+ 5. `GenericTransaction` - Fallback view
276
+
277
+ **Medium Priority (Shared Components):**
278
+ 1. `AddressDisplay` - Universal address component
279
+ 2. `DigitalAssetInfo` - Asset information card
280
+ 3. `FormattedTokenAmount` - Token amount display
281
+ 4. `TransactionTitle` - Standard transaction headers
282
+ 5. `ProfileImage` - Profile avatar handling
283
+
284
+ **Low Priority (UI Components):**
285
+ 1. `Button`, `IconButton` - Basic UI elements
286
+ 2. `Tooltip`, `Modal` - Interaction components
287
+ 3. `Spinner`, `Skeleton` - Loading states
288
+ 4. `SvgIcon` - Icon system
289
+
290
+ ## Migration Challenges & Solutions
291
+
292
+ ### Challenge 1: LUKSO Web Components Dependency
293
+ **Problem:** Vue components heavily use `@lukso/web-components`
294
+ **Solution:**
295
+ - Lit: Continue using LUKSO web components (compatible)
296
+ - React Native: Implement native equivalents (`ProfileImage`, `UserName`)
297
+
298
+ ### Challenge 2: Complex Async Data Loading
299
+ **Problem:** `computedAsync` and Vue reactivity for data fetching
300
+ **Solution:**
301
+ - Move to decoder-headless composables
302
+ - Lit: Use `@lit/task` for async operations
303
+ - React Native: Use standard React hooks (`useEffect`, `useState`)
304
+
305
+ ### Challenge 3: Styling System Migration
306
+ **Problem:** SCSS variables and mixins
307
+ **Solution:**
308
+ - Lit: Convert to CSS custom properties and CSS-in-JS
309
+ - React Native: Create StyleSheet equivalents
310
+
311
+ ### Challenge 4: Business Logic Extraction
312
+ **Problem:** Vue components have embedded business logic
313
+ **Solution:**
314
+ - Extract to decoder-headless composables
315
+ - Components become pure presentation layer
316
+ - Shared logic between Lit and React Native
317
+
318
+ ## Implementation Roadmap
319
+
320
+ ### Week 1-2: Business Logic Extraction
321
+ - [ ] Extract image loading to `useImageLoader`
322
+ - [ ] Extract profile resolution to `useProfileResolver`
323
+ - [ ] Extract token formatting to `useTokenFormatter`
324
+ - [ ] Extract transaction parsing to `useTransactionParser`
325
+
326
+ ### Week 3-4: Lit Components (Transaction Views)
327
+ - [ ] `lsp7-transfer-view`
328
+ - [ ] `lsp8-transfer-view`
329
+ - [ ] `set-data-view`
330
+ - [ ] `execute-batch-view`
331
+ - [ ] `generic-transaction-view`
332
+
333
+ ### Week 5-6: Lit Components (Shared)
334
+ - [ ] `address-display`
335
+ - [ ] `digital-asset-info`
336
+ - [ ] `formatted-token-amount`
337
+ - [ ] `transaction-title`
338
+ - [ ] `profile-image`
339
+
340
+ ### Week 7-8: React Native Components (Transaction Views)
341
+ - [ ] `LSP7Transfer`
342
+ - [ ] `LSP8Transfer`
343
+ - [ ] `SetData`
344
+ - [ ] `ExecuteBatch`
345
+ - [ ] `GenericTransaction`
346
+
347
+ ### Week 9-10: React Native Components (Shared)
348
+ - [ ] `AddressDisplay`
349
+ - [ ] `DigitalAssetInfo`
350
+ - [ ] `FormattedTokenAmount`
351
+ - [ ] `TransactionTitle`
352
+ - [ ] `ProfileImage`
353
+
354
+ ## Success Metrics
355
+
356
+ 1. **Functionality Parity**: All Vue component features replicated
357
+ 2. **Performance**: Lit components load <100ms, RN components <50ms render
358
+ 3. **Bundle Size**: Lit components <50KB gzipped per component
359
+ 4. **Type Safety**: 100% TypeScript coverage
360
+ 5. **Test Coverage**: >90% for business logic, >80% for components
361
+
362
+ ## Conclusion
363
+
364
+ The Vue components provide an excellent template for the Lit and React Native implementations. The key to success is:
365
+
366
+ 1. **Extract business logic first** - Move complex data fetching to decoder-headless
367
+ 2. **Preserve component interfaces** - Same props/events between frameworks
368
+ 3. **Maintain LUKSO compatibility** - Continue using LUKSO web components where possible
369
+ 4. **Progressive migration** - Start with core transaction views, add shared components as needed
370
+
371
+ The existing Vue components are well-structured and will convert cleanly to our optimized architecture! 🎯