@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.
- package/.turbo/turbo-build.log +51 -0
- package/CHANGELOG.md +88 -0
- package/COMPONENT_ARCHITECTURE.md +190 -0
- package/COMPONENT_CONVERSION_ANALYSIS.md +371 -0
- package/CONTEXT_VARIANT_GUIDE.md +425 -0
- package/LAZY_LOADING_GUIDE.md +534 -0
- package/LICENSE +201 -0
- package/PLAYBACK_EXAMPLES.md +658 -0
- package/PLAYBACK_GUIDE.md +402 -0
- package/README.md +43 -0
- package/REGISTRY_SUMMARY.md +638 -0
- package/SUFFERING_ECONOMICS.md +346 -0
- package/SUFFERING_ECONOMICS.zip +0 -0
- package/VIEW_REGISTRATION_GUIDE.md +795 -0
- package/dist/composables/index.cjs +1321 -0
- package/dist/composables/index.cjs.map +1 -0
- package/dist/composables/index.d.cts +6 -0
- package/dist/composables/index.d.ts +6 -0
- package/dist/composables/index.js +1276 -0
- package/dist/composables/index.js.map +1 -0
- package/dist/index-CMLU1hKL.d.ts +374 -0
- package/dist/index-CSDjhiKV.d.cts +374 -0
- package/dist/index.cjs +1534 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +93 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +1463 -0
- package/dist/index.js.map +1 -0
- package/dist/registry/index.cjs +522 -0
- package/dist/registry/index.cjs.map +1 -0
- package/dist/registry/index.d.cts +46 -0
- package/dist/registry/index.d.ts +46 -0
- package/dist/registry/index.js +487 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/types/index.cjs +19 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +203 -0
- package/dist/types/index.d.ts +203 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/index.cjs +217 -0
- package/dist/utils/index.cjs.map +1 -0
- package/dist/utils/index.d.cts +47 -0
- package/dist/utils/index.d.ts +47 -0
- package/dist/utils/index.js +188 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/view-loader-dD86QAlQ.d.cts +121 -0
- package/dist/view-loader-ii8AxiQR.d.ts +121 -0
- package/package.json +64 -0
- package/publish.log +0 -0
- package/src/composables/index.ts +59 -0
- package/src/composables/use-image-loader.ts +315 -0
- package/src/composables/use-transaction-playback.ts +396 -0
- package/src/composables/use-transaction-view.ts +309 -0
- package/src/config/lukso-config.ts +171 -0
- package/src/examples/context-aware-views.ts +300 -0
- package/src/examples/example-views.ts +197 -0
- package/src/examples/lit-plus-rn-strategy.ts +448 -0
- package/src/examples/lsp7-custom-matcher-examples.ts +174 -0
- package/src/examples/opt-in-context-examples.ts +372 -0
- package/src/examples/optimized-view-definitions.ts +408 -0
- package/src/examples/vue-to-lit-compilation.ts +358 -0
- package/src/hooks/useAddressQuery.ts +135 -0
- package/src/hooks/useAddressResolution.ts +437 -0
- package/src/index.ts +36 -0
- package/src/registry/index.ts +13 -0
- package/src/registry/view-loader.ts +305 -0
- package/src/registry/view-registry.ts +135 -0
- package/src/types/index.ts +16 -0
- package/src/types/view-contexts.ts +72 -0
- package/src/types/view-matching.ts +173 -0
- package/src/utils/context-matcher.ts +165 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/view-matcher.ts +338 -0
- package/tsconfig.json +20 -0
- package/tsup.config.ts +34 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DecoderResult } from '@lukso/transaction-decoder';
|
|
2
|
+
import { ViewDefinition, ViewMatchOptions, ViewMatchCriteria, ViewMatch } from '../types/index.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Weights for different matching criteria (higher = more important)
|
|
6
|
+
* Context is optional - only weighted when both view and request specify context
|
|
7
|
+
*/
|
|
8
|
+
declare const CRITERIA_WEIGHTS: {
|
|
9
|
+
readonly recordType: 0.25;
|
|
10
|
+
readonly functionName: 0.2;
|
|
11
|
+
readonly context: 0.2;
|
|
12
|
+
readonly standard: 0.15;
|
|
13
|
+
readonly contractAddress: 0.1;
|
|
14
|
+
readonly contextRequirements: 0.05;
|
|
15
|
+
readonly chainId: 0.03;
|
|
16
|
+
readonly customMatcher: 0.02;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Calculate how well a view matches a transaction and context
|
|
20
|
+
*
|
|
21
|
+
* Context matching is opt-in:
|
|
22
|
+
* - If view specifies context criteria, request MUST provide matching context
|
|
23
|
+
* - If view has no context criteria, it matches any context (universal view)
|
|
24
|
+
* - If request has no context, context-specific views are deprioritized
|
|
25
|
+
*
|
|
26
|
+
* Note: For batch operations (executeBatch, setDataBatch, etc.), this matches
|
|
27
|
+
* against the parent transaction. Future enhancement could include matching
|
|
28
|
+
* against child transactions for more granular view selection.
|
|
29
|
+
*/
|
|
30
|
+
declare function calculateMatchScore(transaction: DecoderResult, view: ViewDefinition, options?: Pick<ViewMatchOptions, 'context' | 'contextRequirements'>): {
|
|
31
|
+
score: number;
|
|
32
|
+
matchedCriteria: (keyof ViewMatchCriteria)[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Find and score all matching views for a transaction
|
|
36
|
+
*
|
|
37
|
+
* Views are matched and sorted by:
|
|
38
|
+
* 1. Match score (how well criteria match the transaction)
|
|
39
|
+
* 2. Native framework bonus (Vue/RN get +0.15, Lit gets 0)
|
|
40
|
+
* 3. View priority (manually set priority)
|
|
41
|
+
*
|
|
42
|
+
* This ensures that native framework views are preferred when available,
|
|
43
|
+
* while Lit serves as a universal fallback.
|
|
44
|
+
*/
|
|
45
|
+
declare function findMatchingViews(transaction: DecoderResult, views: ViewDefinition[], options: ViewMatchOptions): ViewMatch[];
|
|
46
|
+
|
|
47
|
+
export { CRITERIA_WEIGHTS, calculateMatchScore, findMatchingViews };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { DecoderResult } from '@lukso/transaction-decoder';
|
|
2
|
+
import { ViewDefinition, ViewMatchOptions, ViewMatchCriteria, ViewMatch } from '../types/index.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Weights for different matching criteria (higher = more important)
|
|
6
|
+
* Context is optional - only weighted when both view and request specify context
|
|
7
|
+
*/
|
|
8
|
+
declare const CRITERIA_WEIGHTS: {
|
|
9
|
+
readonly recordType: 0.25;
|
|
10
|
+
readonly functionName: 0.2;
|
|
11
|
+
readonly context: 0.2;
|
|
12
|
+
readonly standard: 0.15;
|
|
13
|
+
readonly contractAddress: 0.1;
|
|
14
|
+
readonly contextRequirements: 0.05;
|
|
15
|
+
readonly chainId: 0.03;
|
|
16
|
+
readonly customMatcher: 0.02;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Calculate how well a view matches a transaction and context
|
|
20
|
+
*
|
|
21
|
+
* Context matching is opt-in:
|
|
22
|
+
* - If view specifies context criteria, request MUST provide matching context
|
|
23
|
+
* - If view has no context criteria, it matches any context (universal view)
|
|
24
|
+
* - If request has no context, context-specific views are deprioritized
|
|
25
|
+
*
|
|
26
|
+
* Note: For batch operations (executeBatch, setDataBatch, etc.), this matches
|
|
27
|
+
* against the parent transaction. Future enhancement could include matching
|
|
28
|
+
* against child transactions for more granular view selection.
|
|
29
|
+
*/
|
|
30
|
+
declare function calculateMatchScore(transaction: DecoderResult, view: ViewDefinition, options?: Pick<ViewMatchOptions, 'context' | 'contextRequirements'>): {
|
|
31
|
+
score: number;
|
|
32
|
+
matchedCriteria: (keyof ViewMatchCriteria)[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Find and score all matching views for a transaction
|
|
36
|
+
*
|
|
37
|
+
* Views are matched and sorted by:
|
|
38
|
+
* 1. Match score (how well criteria match the transaction)
|
|
39
|
+
* 2. Native framework bonus (Vue/RN get +0.15, Lit gets 0)
|
|
40
|
+
* 3. View priority (manually set priority)
|
|
41
|
+
*
|
|
42
|
+
* This ensures that native framework views are preferred when available,
|
|
43
|
+
* while Lit serves as a universal fallback.
|
|
44
|
+
*/
|
|
45
|
+
declare function findMatchingViews(transaction: DecoderResult, views: ViewDefinition[], options: ViewMatchOptions): ViewMatch[];
|
|
46
|
+
|
|
47
|
+
export { CRITERIA_WEIGHTS, calculateMatchScore, findMatchingViews };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
// src/utils/view-matcher.ts
|
|
2
|
+
var CRITERIA_WEIGHTS = {
|
|
3
|
+
recordType: 0.25,
|
|
4
|
+
// Most specific to transaction type
|
|
5
|
+
functionName: 0.2,
|
|
6
|
+
// Function-level specificity
|
|
7
|
+
context: 0.2,
|
|
8
|
+
// Context specificity (when opt-in)
|
|
9
|
+
standard: 0.15,
|
|
10
|
+
// LSP standard specificity
|
|
11
|
+
contractAddress: 0.1,
|
|
12
|
+
// Contract-specific logic
|
|
13
|
+
contextRequirements: 0.05,
|
|
14
|
+
// Context requirement matching
|
|
15
|
+
chainId: 0.03,
|
|
16
|
+
// Network-specific behavior
|
|
17
|
+
customMatcher: 0.02
|
|
18
|
+
// Custom logic (lowest weight due to unpredictability)
|
|
19
|
+
};
|
|
20
|
+
function calculateMatchScore(transaction, view, options) {
|
|
21
|
+
const { criteria } = view;
|
|
22
|
+
const matchedCriteria = [];
|
|
23
|
+
let totalWeight = 0;
|
|
24
|
+
let matchedWeight = 0;
|
|
25
|
+
for (const [criterion, weight] of Object.entries(CRITERIA_WEIGHTS)) {
|
|
26
|
+
const criterionKey = criterion;
|
|
27
|
+
const criterionValue = criteria[criterionKey];
|
|
28
|
+
if (criterionValue === void 0) continue;
|
|
29
|
+
totalWeight += weight;
|
|
30
|
+
if (criterionKey === "customMatcher" && typeof criterionValue === "function") {
|
|
31
|
+
try {
|
|
32
|
+
const matchCount = criterionValue(transaction);
|
|
33
|
+
if (matchCount > 0) {
|
|
34
|
+
matchedCriteria.push(criterionKey);
|
|
35
|
+
const normalizedScore = Math.min(matchCount / 10, 1);
|
|
36
|
+
matchedWeight += weight * normalizedScore;
|
|
37
|
+
}
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.warn("Custom matcher threw error:", error);
|
|
40
|
+
}
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (doesCriterionMatch(transaction, criterionKey, criterionValue, options)) {
|
|
44
|
+
matchedCriteria.push(criterionKey);
|
|
45
|
+
matchedWeight += weight;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const viewHasContext = criteria.context !== void 0;
|
|
49
|
+
const requestHasContext = options?.context !== void 0;
|
|
50
|
+
if (viewHasContext && !requestHasContext) {
|
|
51
|
+
matchedWeight *= 0.1;
|
|
52
|
+
} else if (!viewHasContext && requestHasContext) {
|
|
53
|
+
matchedWeight *= 0.9;
|
|
54
|
+
}
|
|
55
|
+
if (totalWeight === 0) return { score: 0, matchedCriteria: [] };
|
|
56
|
+
const score = matchedWeight / totalWeight;
|
|
57
|
+
return { score, matchedCriteria };
|
|
58
|
+
}
|
|
59
|
+
function doesCriterionMatch(transaction, criterion, criterionValue, options) {
|
|
60
|
+
switch (criterion) {
|
|
61
|
+
case "recordType":
|
|
62
|
+
return matchesStringOrArray(
|
|
63
|
+
transaction.recordType,
|
|
64
|
+
criterionValue
|
|
65
|
+
);
|
|
66
|
+
case "functionName":
|
|
67
|
+
return matchesStringOrArray(
|
|
68
|
+
transaction.functionName,
|
|
69
|
+
criterionValue
|
|
70
|
+
);
|
|
71
|
+
case "standard":
|
|
72
|
+
return matchesStringOrArray(
|
|
73
|
+
transaction.standard,
|
|
74
|
+
criterionValue
|
|
75
|
+
);
|
|
76
|
+
case "contractAddress":
|
|
77
|
+
return matchesStringOrArray(
|
|
78
|
+
transaction.contractAddress,
|
|
79
|
+
criterionValue
|
|
80
|
+
);
|
|
81
|
+
case "chainId":
|
|
82
|
+
return matchesNumberOrArray(transaction.chainId, criterionValue);
|
|
83
|
+
case "context":
|
|
84
|
+
if (!options?.context) return false;
|
|
85
|
+
return matchesStringOrArray(options.context, criterionValue);
|
|
86
|
+
case "contextRequirements":
|
|
87
|
+
if (!options?.contextRequirements || !criterionValue) return false;
|
|
88
|
+
return areContextRequirementsCompatible(
|
|
89
|
+
options.contextRequirements,
|
|
90
|
+
criterionValue
|
|
91
|
+
);
|
|
92
|
+
case "customMatcher":
|
|
93
|
+
if (typeof criterionValue === "function") {
|
|
94
|
+
try {
|
|
95
|
+
const matchCount = criterionValue(transaction);
|
|
96
|
+
return matchCount > 0;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.warn("Custom matcher threw error:", error);
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return false;
|
|
103
|
+
default:
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function matchesStringOrArray(value, criteria) {
|
|
108
|
+
if (!value || !criteria) return false;
|
|
109
|
+
if (Array.isArray(criteria)) {
|
|
110
|
+
return criteria.includes(value);
|
|
111
|
+
}
|
|
112
|
+
return value === criteria;
|
|
113
|
+
}
|
|
114
|
+
function matchesNumberOrArray(value, criteria) {
|
|
115
|
+
if (value === void 0 || criteria === void 0) return false;
|
|
116
|
+
if (Array.isArray(criteria)) {
|
|
117
|
+
return criteria.includes(value);
|
|
118
|
+
}
|
|
119
|
+
return value === criteria;
|
|
120
|
+
}
|
|
121
|
+
function areContextRequirementsCompatible(requested, viewRequirements) {
|
|
122
|
+
if (requested.detailLevel && viewRequirements.detailLevel) {
|
|
123
|
+
const detailOrder = ["minimal", "summary", "full", "debug"];
|
|
124
|
+
const requestedLevel = detailOrder.indexOf(requested.detailLevel);
|
|
125
|
+
const viewLevel = detailOrder.indexOf(viewRequirements.detailLevel);
|
|
126
|
+
if (viewLevel < requestedLevel) return false;
|
|
127
|
+
}
|
|
128
|
+
if (requested.maxHeight && viewRequirements.maxHeight) {
|
|
129
|
+
if (viewRequirements.maxHeight > requested.maxHeight) return false;
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
function calculateNativeFrameworkBonus(view, requestedFramework) {
|
|
134
|
+
if (requestedFramework === "lit") {
|
|
135
|
+
return 0;
|
|
136
|
+
}
|
|
137
|
+
if (requestedFramework === "vue" && view.frameworks.vue) {
|
|
138
|
+
return 0.15;
|
|
139
|
+
}
|
|
140
|
+
if (requestedFramework === "rn" && view.frameworks.rn) {
|
|
141
|
+
return 0.15;
|
|
142
|
+
}
|
|
143
|
+
return 0;
|
|
144
|
+
}
|
|
145
|
+
function findMatchingViews(transaction, views, options) {
|
|
146
|
+
const matches = [];
|
|
147
|
+
const minScore = options.minScore ?? 0;
|
|
148
|
+
for (const view of views) {
|
|
149
|
+
if (!view.frameworks[options.framework]) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
const { score, matchedCriteria } = calculateMatchScore(transaction, view, {
|
|
153
|
+
context: options.context,
|
|
154
|
+
contextRequirements: options.contextRequirements
|
|
155
|
+
});
|
|
156
|
+
if (score < minScore) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const frameworkBonus = calculateNativeFrameworkBonus(
|
|
160
|
+
view,
|
|
161
|
+
options.framework
|
|
162
|
+
);
|
|
163
|
+
const finalScore = Math.min(1, score + frameworkBonus);
|
|
164
|
+
const match = {
|
|
165
|
+
view,
|
|
166
|
+
score: finalScore,
|
|
167
|
+
matchedCriteria,
|
|
168
|
+
frameworkConfig: options.includeFrameworkConfig ? view.frameworks[options.framework] : void 0
|
|
169
|
+
};
|
|
170
|
+
matches.push(match);
|
|
171
|
+
}
|
|
172
|
+
matches.sort((a, b) => {
|
|
173
|
+
if (a.score !== b.score) {
|
|
174
|
+
return b.score - a.score;
|
|
175
|
+
}
|
|
176
|
+
return b.view.priority - a.view.priority;
|
|
177
|
+
});
|
|
178
|
+
if (options.maxMatches) {
|
|
179
|
+
return matches.slice(0, options.maxMatches);
|
|
180
|
+
}
|
|
181
|
+
return matches;
|
|
182
|
+
}
|
|
183
|
+
export {
|
|
184
|
+
CRITERIA_WEIGHTS,
|
|
185
|
+
calculateMatchScore,
|
|
186
|
+
findMatchingViews
|
|
187
|
+
};
|
|
188
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/view-matcher.ts"],"sourcesContent":["import type { DecoderResult } from '@lukso/transaction-decoder'\nimport type {\n DecoderRecordForSelection,\n ViewDefinition,\n ViewMatch,\n ViewMatchCriteria,\n ViewMatchOptions,\n} from '../types/view-matching'\n\n/**\n * Weights for different matching criteria (higher = more important)\n * Context is optional - only weighted when both view and request specify context\n */\nexport const CRITERIA_WEIGHTS = {\n recordType: 0.25, // Most specific to transaction type\n functionName: 0.2, // Function-level specificity\n context: 0.2, // Context specificity (when opt-in)\n standard: 0.15, // LSP standard specificity\n contractAddress: 0.1, // Contract-specific logic\n contextRequirements: 0.05, // Context requirement matching\n chainId: 0.03, // Network-specific behavior\n customMatcher: 0.02, // Custom logic (lowest weight due to unpredictability)\n} as const\n\n/**\n * Calculate how well a view matches a transaction and context\n *\n * Context matching is opt-in:\n * - If view specifies context criteria, request MUST provide matching context\n * - If view has no context criteria, it matches any context (universal view)\n * - If request has no context, context-specific views are deprioritized\n *\n * Note: For batch operations (executeBatch, setDataBatch, etc.), this matches\n * against the parent transaction. Future enhancement could include matching\n * against child transactions for more granular view selection.\n */\nexport function calculateMatchScore(\n transaction: DecoderResult,\n view: ViewDefinition,\n options?: Pick<ViewMatchOptions, 'context' | 'contextRequirements'>\n): { score: number; matchedCriteria: (keyof ViewMatchCriteria)[] } {\n const { criteria } = view\n const matchedCriteria: (keyof ViewMatchCriteria)[] = []\n let totalWeight = 0\n let matchedWeight = 0\n\n // Check each criterion and accumulate scores\n for (const [criterion, weight] of Object.entries(CRITERIA_WEIGHTS)) {\n const criterionKey = criterion as keyof ViewMatchCriteria\n const criterionValue = criteria[criterionKey]\n\n if (criterionValue === undefined) continue\n\n totalWeight += weight\n\n // Special handling for customMatcher - use match count\n if (\n criterionKey === 'customMatcher' &&\n typeof criterionValue === 'function'\n ) {\n try {\n const matchCount = criterionValue(transaction)\n if (matchCount > 0) {\n matchedCriteria.push(criterionKey)\n // Normalize match count to 0-1 range (cap at 10 conditions)\n const normalizedScore = Math.min(matchCount / 10, 1)\n matchedWeight += weight * normalizedScore\n }\n } catch (error) {\n console.warn('Custom matcher threw error:', error)\n }\n continue\n }\n\n if (\n doesCriterionMatch(transaction, criterionKey, criterionValue, options)\n ) {\n matchedCriteria.push(criterionKey)\n matchedWeight += weight\n }\n }\n\n // Handle context opt-in logic\n const viewHasContext = criteria.context !== undefined\n const requestHasContext = options?.context !== undefined\n\n if (viewHasContext && !requestHasContext) {\n // View requires specific context, but none provided - penalize heavily\n matchedWeight *= 0.1 // Reduce score by 90%\n } else if (!viewHasContext && requestHasContext) {\n // Universal view matching specific context - slight penalty to prefer context-specific views\n matchedWeight *= 0.9 // Reduce score by 10%\n }\n\n // If no criteria are defined, this view doesn't match\n if (totalWeight === 0) return { score: 0, matchedCriteria: [] }\n\n // Calculate final score (0-1)\n const score = matchedWeight / totalWeight\n\n return { score, matchedCriteria }\n}\n\n/**\n * Check if a specific criterion matches the transaction\n */\nfunction doesCriterionMatch(\n transaction: DecoderResult,\n criterion: keyof ViewMatchCriteria,\n criterionValue: any,\n options?: Pick<ViewMatchOptions, 'context' | 'contextRequirements'>\n): boolean {\n switch (criterion) {\n case 'recordType':\n return matchesStringOrArray(\n (transaction as DecoderRecordForSelection).recordType,\n criterionValue\n )\n\n case 'functionName':\n return matchesStringOrArray(\n (transaction as DecoderRecordForSelection).functionName,\n criterionValue\n )\n\n case 'standard':\n return matchesStringOrArray(\n (transaction as DecoderRecordForSelection).standard,\n criterionValue\n )\n\n case 'contractAddress':\n return matchesStringOrArray(\n (transaction as DecoderRecordForSelection).contractAddress,\n criterionValue\n )\n\n case 'chainId':\n return matchesNumberOrArray(transaction.chainId, criterionValue)\n\n case 'context':\n if (!options?.context) return false // No context provided, can't match\n return matchesStringOrArray(options.context, criterionValue)\n\n case 'contextRequirements':\n if (!options?.contextRequirements || !criterionValue) return false\n return areContextRequirementsCompatible(\n options.contextRequirements,\n criterionValue\n )\n\n case 'customMatcher':\n if (typeof criterionValue === 'function') {\n try {\n const matchCount = criterionValue(transaction)\n // Match if any conditions matched (> 0)\n // The actual count contributes to the score in calculateMatchScore\n return matchCount > 0\n } catch (error) {\n console.warn('Custom matcher threw error:', error)\n return false\n }\n }\n return false\n\n default:\n return false\n }\n}\n\n/**\n * Helper to match string values against string or array criteria\n */\nfunction matchesStringOrArray(\n value: string | undefined,\n criteria: string | string[]\n): boolean {\n if (!value || !criteria) return false\n\n if (Array.isArray(criteria)) {\n return criteria.includes(value)\n }\n\n return value === criteria\n}\n\n/**\n * Helper to match number values against number or array criteria\n */\nfunction matchesNumberOrArray(\n value: number | undefined,\n criteria: number | number[]\n): boolean {\n if (value === undefined || criteria === undefined) return false\n\n if (Array.isArray(criteria)) {\n return criteria.includes(value)\n }\n\n return value === criteria\n}\n\n/**\n * Check if context requirements are compatible\n */\nfunction areContextRequirementsCompatible(\n requested: any,\n viewRequirements: any\n): boolean {\n // Simple compatibility check - can be extended\n if (requested.detailLevel && viewRequirements.detailLevel) {\n const detailOrder = ['minimal', 'summary', 'full', 'debug']\n const requestedLevel = detailOrder.indexOf(requested.detailLevel)\n const viewLevel = detailOrder.indexOf(viewRequirements.detailLevel)\n if (viewLevel < requestedLevel) return false\n }\n\n if (requested.maxHeight && viewRequirements.maxHeight) {\n if (viewRequirements.maxHeight > requested.maxHeight) return false\n }\n\n return true\n}\n\n/**\n * Calculate native framework priority bonus\n *\n * Native framework implementations (Vue, React Native) get priority over Lit fallbacks:\n * - Vue: +0.15 bonus when view has Vue implementation\n * - React Native (rn): +0.15 bonus when view has RN implementation\n * - Lit: NO bonus (Lit is the universal fallback)\n *\n * This ensures that when both native and Lit views exist for the same transaction:\n * - Vue app prefers Vue view (Vue score + 0.15 > Lit score)\n * - React Native app prefers RN view (RN score + 0.15 > Lit score)\n * - Other frameworks use Lit view (universal compatibility)\n */\nfunction calculateNativeFrameworkBonus(\n view: ViewDefinition,\n requestedFramework: 'lit' | 'vue' | 'rn'\n): number {\n // Lit gets no bonus - it's the universal fallback\n if (requestedFramework === 'lit') {\n return 0\n }\n\n // Vue gets bonus if view has Vue implementation\n if (requestedFramework === 'vue' && view.frameworks.vue) {\n return 0.15\n }\n\n // React Native gets bonus if view has RN implementation\n if (requestedFramework === 'rn' && view.frameworks.rn) {\n return 0.15\n }\n\n return 0\n}\n\n/**\n * Find and score all matching views for a transaction\n *\n * Views are matched and sorted by:\n * 1. Match score (how well criteria match the transaction)\n * 2. Native framework bonus (Vue/RN get +0.15, Lit gets 0)\n * 3. View priority (manually set priority)\n *\n * This ensures that native framework views are preferred when available,\n * while Lit serves as a universal fallback.\n */\nexport function findMatchingViews(\n transaction: DecoderResult,\n views: ViewDefinition[],\n options: ViewMatchOptions\n): ViewMatch[] {\n const matches: ViewMatch[] = []\n const minScore = options.minScore ?? 0\n\n for (const view of views) {\n // Skip if framework is not supported\n if (!view.frameworks[options.framework]) {\n continue\n }\n\n const { score, matchedCriteria } = calculateMatchScore(transaction, view, {\n context: options.context,\n contextRequirements: options.contextRequirements,\n })\n\n // Skip if score is below threshold\n if (score < minScore) {\n continue\n }\n\n // Apply native framework bonus (Vue/RN only, NOT Lit)\n const frameworkBonus = calculateNativeFrameworkBonus(\n view,\n options.framework\n )\n const finalScore = Math.min(1, score + frameworkBonus)\n\n const match: ViewMatch = {\n view,\n score: finalScore,\n matchedCriteria,\n frameworkConfig: options.includeFrameworkConfig\n ? view.frameworks[options.framework]\n : undefined,\n }\n\n matches.push(match)\n }\n\n // Sort by score (descending), then by priority (descending)\n matches.sort((a, b) => {\n if (a.score !== b.score) {\n return b.score - a.score\n }\n return b.view.priority - a.view.priority\n })\n\n // Limit results if requested\n if (options.maxMatches) {\n return matches.slice(0, options.maxMatches)\n }\n\n return matches\n}\n\n/**\n * TODO: Future enhancement for batch operations\n *\n * For batch operations like executeBatch, setDataBatch, we might want to:\n * 1. Match against the batch container (current behavior)\n * 2. Also match against child transactions for more specific views\n * 3. Allow views to specify whether they handle batches vs individual items\n * 4. Support composite views that render both batch info + child items\n */\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ViewLoader, FrameworkViewConfig, ViewMatch } from './types/index.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Error thrown when view loading fails
|
|
5
|
+
*/
|
|
6
|
+
declare class ViewLoadingError extends Error {
|
|
7
|
+
readonly loader: ViewLoader;
|
|
8
|
+
readonly config: FrameworkViewConfig;
|
|
9
|
+
readonly cause?: Error;
|
|
10
|
+
constructor(message: string, loader: ViewLoader, config: FrameworkViewConfig, cause?: Error);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Framework-agnostic view loader that handles different loading strategies
|
|
14
|
+
*/
|
|
15
|
+
declare class UniversalViewLoader {
|
|
16
|
+
private cache;
|
|
17
|
+
/**
|
|
18
|
+
* Load a component based on the framework configuration
|
|
19
|
+
*/
|
|
20
|
+
loadComponent(config: FrameworkViewConfig): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Load a component from a view match
|
|
23
|
+
*/
|
|
24
|
+
loadFromMatch(match: ViewMatch): Promise<any>;
|
|
25
|
+
/**
|
|
26
|
+
* Load component using the specific strategy
|
|
27
|
+
*/
|
|
28
|
+
private loadByStrategy;
|
|
29
|
+
/**
|
|
30
|
+
* Dynamic import strategy (most common)
|
|
31
|
+
* Supports both static strings and lazy-loaded callbacks
|
|
32
|
+
*/
|
|
33
|
+
private loadDynamicImport;
|
|
34
|
+
/**
|
|
35
|
+
* Static import strategy (requires bundler support)
|
|
36
|
+
* Supports both static strings and lazy-loaded callbacks
|
|
37
|
+
*/
|
|
38
|
+
private loadStaticImport;
|
|
39
|
+
/**
|
|
40
|
+
* Custom element strategy (for Lit components)
|
|
41
|
+
*/
|
|
42
|
+
private loadCustomElement;
|
|
43
|
+
/**
|
|
44
|
+
* Registry lookup strategy (for pre-registered components)
|
|
45
|
+
*/
|
|
46
|
+
private loadFromRegistry;
|
|
47
|
+
/**
|
|
48
|
+
* Generate cache key for component config
|
|
49
|
+
*/
|
|
50
|
+
private getCacheKey;
|
|
51
|
+
/**
|
|
52
|
+
* Clear the component cache
|
|
53
|
+
*/
|
|
54
|
+
clearCache(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Get cache statistics
|
|
57
|
+
*/
|
|
58
|
+
getCacheStats(): {
|
|
59
|
+
size: number;
|
|
60
|
+
keys: string[];
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get the global view loader
|
|
65
|
+
*/
|
|
66
|
+
declare function getGlobalLoader(): UniversalViewLoader;
|
|
67
|
+
/**
|
|
68
|
+
* Set a custom global loader (useful for testing)
|
|
69
|
+
*/
|
|
70
|
+
declare function setGlobalLoader(loader: UniversalViewLoader): void;
|
|
71
|
+
/**
|
|
72
|
+
* Framework-specific helpers for strategically optimized loading patterns
|
|
73
|
+
*
|
|
74
|
+
* Following our Suffering Economics optimization, we support:
|
|
75
|
+
* - Lit Web Components (universal web compatibility) - REQUIRED
|
|
76
|
+
* - Vue (native Vue optimization) - OPTIONAL
|
|
77
|
+
* - React Native (mobile-native optimization) - OPTIONAL (WebView fallback available)
|
|
78
|
+
*
|
|
79
|
+
* All loaders support lazy loading via callbacks:
|
|
80
|
+
* ```typescript
|
|
81
|
+
* // Static (bundled)
|
|
82
|
+
* vueComponent('./Component.vue')
|
|
83
|
+
*
|
|
84
|
+
* // Lazy (loaded on demand)
|
|
85
|
+
* vueComponent(() => import('./Component.vue'))
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
declare const LoaderHelpers: {
|
|
89
|
+
/**
|
|
90
|
+
* Create a Lit custom element loader (universal web compatibility)
|
|
91
|
+
*/
|
|
92
|
+
litComponent(tagName: string): ViewLoader;
|
|
93
|
+
/**
|
|
94
|
+
* Create a Vue component loader (native Vue, optional)
|
|
95
|
+
* Supports both static paths and lazy-loaded callbacks
|
|
96
|
+
*/
|
|
97
|
+
vueComponent(path: string | (() => Promise<any>)): ViewLoader;
|
|
98
|
+
/**
|
|
99
|
+
* Create a React Native JSX dynamic import loader (mobile-native, optional)
|
|
100
|
+
* Supports both static paths and lazy-loaded callbacks
|
|
101
|
+
*/
|
|
102
|
+
rnComponent(path: string | (() => Promise<any>)): ViewLoader;
|
|
103
|
+
/**
|
|
104
|
+
* Create a custom loader function for advanced use cases
|
|
105
|
+
*/
|
|
106
|
+
custom(loader: (config: FrameworkViewConfig) => Promise<any>): ViewLoader;
|
|
107
|
+
/**
|
|
108
|
+
* @deprecated Use litComponent() instead. This exists for compilation pipeline compatibility.
|
|
109
|
+
*/
|
|
110
|
+
vueToLitCompiled(tagName: string): ViewLoader;
|
|
111
|
+
/**
|
|
112
|
+
* @deprecated Use litComponent() instead. This exists for compilation pipeline compatibility.
|
|
113
|
+
*/
|
|
114
|
+
reactToLitCompiled(tagName: string): ViewLoader;
|
|
115
|
+
/**
|
|
116
|
+
* @deprecated Use rnComponent() instead. Updated for better TypeScript support.
|
|
117
|
+
*/
|
|
118
|
+
reactNativeComponent(path: string): ViewLoader;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export { LoaderHelpers as L, UniversalViewLoader as U, ViewLoadingError as V, getGlobalLoader as g, setGlobalLoader as s };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ViewLoader, FrameworkViewConfig, ViewMatch } from './types/index.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Error thrown when view loading fails
|
|
5
|
+
*/
|
|
6
|
+
declare class ViewLoadingError extends Error {
|
|
7
|
+
readonly loader: ViewLoader;
|
|
8
|
+
readonly config: FrameworkViewConfig;
|
|
9
|
+
readonly cause?: Error;
|
|
10
|
+
constructor(message: string, loader: ViewLoader, config: FrameworkViewConfig, cause?: Error);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Framework-agnostic view loader that handles different loading strategies
|
|
14
|
+
*/
|
|
15
|
+
declare class UniversalViewLoader {
|
|
16
|
+
private cache;
|
|
17
|
+
/**
|
|
18
|
+
* Load a component based on the framework configuration
|
|
19
|
+
*/
|
|
20
|
+
loadComponent(config: FrameworkViewConfig): Promise<any>;
|
|
21
|
+
/**
|
|
22
|
+
* Load a component from a view match
|
|
23
|
+
*/
|
|
24
|
+
loadFromMatch(match: ViewMatch): Promise<any>;
|
|
25
|
+
/**
|
|
26
|
+
* Load component using the specific strategy
|
|
27
|
+
*/
|
|
28
|
+
private loadByStrategy;
|
|
29
|
+
/**
|
|
30
|
+
* Dynamic import strategy (most common)
|
|
31
|
+
* Supports both static strings and lazy-loaded callbacks
|
|
32
|
+
*/
|
|
33
|
+
private loadDynamicImport;
|
|
34
|
+
/**
|
|
35
|
+
* Static import strategy (requires bundler support)
|
|
36
|
+
* Supports both static strings and lazy-loaded callbacks
|
|
37
|
+
*/
|
|
38
|
+
private loadStaticImport;
|
|
39
|
+
/**
|
|
40
|
+
* Custom element strategy (for Lit components)
|
|
41
|
+
*/
|
|
42
|
+
private loadCustomElement;
|
|
43
|
+
/**
|
|
44
|
+
* Registry lookup strategy (for pre-registered components)
|
|
45
|
+
*/
|
|
46
|
+
private loadFromRegistry;
|
|
47
|
+
/**
|
|
48
|
+
* Generate cache key for component config
|
|
49
|
+
*/
|
|
50
|
+
private getCacheKey;
|
|
51
|
+
/**
|
|
52
|
+
* Clear the component cache
|
|
53
|
+
*/
|
|
54
|
+
clearCache(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Get cache statistics
|
|
57
|
+
*/
|
|
58
|
+
getCacheStats(): {
|
|
59
|
+
size: number;
|
|
60
|
+
keys: string[];
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get the global view loader
|
|
65
|
+
*/
|
|
66
|
+
declare function getGlobalLoader(): UniversalViewLoader;
|
|
67
|
+
/**
|
|
68
|
+
* Set a custom global loader (useful for testing)
|
|
69
|
+
*/
|
|
70
|
+
declare function setGlobalLoader(loader: UniversalViewLoader): void;
|
|
71
|
+
/**
|
|
72
|
+
* Framework-specific helpers for strategically optimized loading patterns
|
|
73
|
+
*
|
|
74
|
+
* Following our Suffering Economics optimization, we support:
|
|
75
|
+
* - Lit Web Components (universal web compatibility) - REQUIRED
|
|
76
|
+
* - Vue (native Vue optimization) - OPTIONAL
|
|
77
|
+
* - React Native (mobile-native optimization) - OPTIONAL (WebView fallback available)
|
|
78
|
+
*
|
|
79
|
+
* All loaders support lazy loading via callbacks:
|
|
80
|
+
* ```typescript
|
|
81
|
+
* // Static (bundled)
|
|
82
|
+
* vueComponent('./Component.vue')
|
|
83
|
+
*
|
|
84
|
+
* // Lazy (loaded on demand)
|
|
85
|
+
* vueComponent(() => import('./Component.vue'))
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
declare const LoaderHelpers: {
|
|
89
|
+
/**
|
|
90
|
+
* Create a Lit custom element loader (universal web compatibility)
|
|
91
|
+
*/
|
|
92
|
+
litComponent(tagName: string): ViewLoader;
|
|
93
|
+
/**
|
|
94
|
+
* Create a Vue component loader (native Vue, optional)
|
|
95
|
+
* Supports both static paths and lazy-loaded callbacks
|
|
96
|
+
*/
|
|
97
|
+
vueComponent(path: string | (() => Promise<any>)): ViewLoader;
|
|
98
|
+
/**
|
|
99
|
+
* Create a React Native JSX dynamic import loader (mobile-native, optional)
|
|
100
|
+
* Supports both static paths and lazy-loaded callbacks
|
|
101
|
+
*/
|
|
102
|
+
rnComponent(path: string | (() => Promise<any>)): ViewLoader;
|
|
103
|
+
/**
|
|
104
|
+
* Create a custom loader function for advanced use cases
|
|
105
|
+
*/
|
|
106
|
+
custom(loader: (config: FrameworkViewConfig) => Promise<any>): ViewLoader;
|
|
107
|
+
/**
|
|
108
|
+
* @deprecated Use litComponent() instead. This exists for compilation pipeline compatibility.
|
|
109
|
+
*/
|
|
110
|
+
vueToLitCompiled(tagName: string): ViewLoader;
|
|
111
|
+
/**
|
|
112
|
+
* @deprecated Use litComponent() instead. This exists for compilation pipeline compatibility.
|
|
113
|
+
*/
|
|
114
|
+
reactToLitCompiled(tagName: string): ViewLoader;
|
|
115
|
+
/**
|
|
116
|
+
* @deprecated Use rnComponent() instead. Updated for better TypeScript support.
|
|
117
|
+
*/
|
|
118
|
+
reactNativeComponent(path: string): ViewLoader;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export { LoaderHelpers as L, UniversalViewLoader as U, ViewLoadingError as V, getGlobalLoader as g, setGlobalLoader as s };
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lukso/transaction-view-headless",
|
|
3
|
+
"version": "0.2.2-dev.a8c9315",
|
|
4
|
+
"description": "Framework-agnostic transaction decoder and view selection system",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
},
|
|
14
|
+
"./types": {
|
|
15
|
+
"types": "./dist/types/index.d.ts",
|
|
16
|
+
"import": "./dist/types/index.js",
|
|
17
|
+
"require": "./dist/types/index.cjs"
|
|
18
|
+
},
|
|
19
|
+
"./composables": {
|
|
20
|
+
"types": "./dist/composables/index.d.ts",
|
|
21
|
+
"import": "./dist/composables/index.js",
|
|
22
|
+
"require": "./dist/composables/index.cjs"
|
|
23
|
+
},
|
|
24
|
+
"./registry": {
|
|
25
|
+
"types": "./dist/registry/index.d.ts",
|
|
26
|
+
"import": "./dist/registry/index.js",
|
|
27
|
+
"require": "./dist/registry/index.cjs"
|
|
28
|
+
},
|
|
29
|
+
"./utils": {
|
|
30
|
+
"types": "./dist/utils/index.d.ts",
|
|
31
|
+
"import": "./dist/utils/index.js",
|
|
32
|
+
"require": "./dist/utils/index.cjs"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@preact/signals-core": "^1.12.1",
|
|
37
|
+
"@tanstack/query-core": "^5.90.12",
|
|
38
|
+
"viem": "^2.41.2",
|
|
39
|
+
"@lukso/transaction-decoder": "1.0.1-dev.a8c9315"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^24.10.1",
|
|
43
|
+
"tsup": "^8.5.1",
|
|
44
|
+
"typescript": "^5.9.3"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@tanstack/react-query": "^5.0.0",
|
|
48
|
+
"@tanstack/vue-query": "^5.0.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"@tanstack/vue-query": {
|
|
52
|
+
"optional": true
|
|
53
|
+
},
|
|
54
|
+
"@tanstack/react-query": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "tsup",
|
|
60
|
+
"dev": "tsup --watch",
|
|
61
|
+
"dev-alt": "tsup --watch",
|
|
62
|
+
"clean": "rm -rf dist"
|
|
63
|
+
}
|
|
64
|
+
}
|
package/publish.log
ADDED
|
File without changes
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Configuration exports
|
|
2
|
+
export type { LuksoConfig } from '../config/lukso-config'
|
|
3
|
+
export {
|
|
4
|
+
cacheAddress,
|
|
5
|
+
clearAddressCache,
|
|
6
|
+
getCachedAddress,
|
|
7
|
+
getLuksoConfig,
|
|
8
|
+
isAddressResolutionEnabled,
|
|
9
|
+
setLuksoConfig,
|
|
10
|
+
useLuksoMainnet,
|
|
11
|
+
useLuksoTestnet,
|
|
12
|
+
} from '../config/lukso-config'
|
|
13
|
+
// Address resolution exports
|
|
14
|
+
export type {
|
|
15
|
+
AddressResolutionState,
|
|
16
|
+
ResolvedAddress,
|
|
17
|
+
} from '../hooks/useAddressResolution'
|
|
18
|
+
export {
|
|
19
|
+
createAddressResolutionState,
|
|
20
|
+
resolveAddress,
|
|
21
|
+
resolveAddresses,
|
|
22
|
+
resolveAddressWithState,
|
|
23
|
+
} from '../hooks/useAddressResolution'
|
|
24
|
+
export type {
|
|
25
|
+
ViewContext,
|
|
26
|
+
ViewContextRequirements,
|
|
27
|
+
ViewVariant,
|
|
28
|
+
} from '../types/view-contexts'
|
|
29
|
+
export type { ViewMatch } from '../types/view-matching'
|
|
30
|
+
export type {
|
|
31
|
+
AddressImageData,
|
|
32
|
+
ImageLoadOptions,
|
|
33
|
+
ImageResult,
|
|
34
|
+
} from './use-image-loader'
|
|
35
|
+
export {
|
|
36
|
+
useAddressResolver,
|
|
37
|
+
useImageLoader,
|
|
38
|
+
} from './use-image-loader'
|
|
39
|
+
// Transaction playback exports
|
|
40
|
+
export type {
|
|
41
|
+
PlaybackIndexResult,
|
|
42
|
+
TransactionPlaybackOptions,
|
|
43
|
+
TransactionPlaybackState,
|
|
44
|
+
} from './use-transaction-playback'
|
|
45
|
+
export {
|
|
46
|
+
createTransactionPlayback,
|
|
47
|
+
getValidPlaybackIndices,
|
|
48
|
+
isValidPlaybackIndex,
|
|
49
|
+
useTransactionPlayback,
|
|
50
|
+
} from './use-transaction-playback'
|
|
51
|
+
export type {
|
|
52
|
+
UseTransactionViewOptions,
|
|
53
|
+
UseTransactionViewResult,
|
|
54
|
+
} from './use-transaction-view'
|
|
55
|
+
export {
|
|
56
|
+
findAllTransactionViews,
|
|
57
|
+
findBestTransactionView,
|
|
58
|
+
useTransactionView,
|
|
59
|
+
} from './use-transaction-view'
|