@bsv/overlay-express 0.6.0 → 0.7.2
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/dist/cjs/package.json +6 -5
- package/dist/cjs/src/generalGuide.md.js +77 -0
- package/dist/cjs/src/generalGuide.md.js.map +1 -0
- package/dist/cjs/src/makeUserInterface.js +289 -93
- package/dist/cjs/src/makeUserInterface.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/generalGuide.md.js +75 -0
- package/dist/esm/src/generalGuide.md.js.map +1 -0
- package/dist/esm/src/makeUserInterface.js +286 -93
- package/dist/esm/src/makeUserInterface.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/generalGuide.md.d.ts +3 -0
- package/dist/types/src/generalGuide.md.d.ts.map +1 -0
- package/dist/types/src/makeUserInterface.d.ts +5 -0
- package/dist/types/src/makeUserInterface.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/src/generalGuide.md.ts +74 -0
- package/src/makeUserInterface.ts +301 -97
- package/src/__tests/OverlayExpress.test.ts +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export default `\`
|
|
2
|
+
# General Guide
|
|
3
|
+
|
|
4
|
+
## Topic Managers
|
|
5
|
+
|
|
6
|
+
A Topic Manager controls addition and removal of transaction outputs to an Overlay Topic. It processes transaction by exposing a /submit endpoint, request should looks something like:
|
|
7
|
+
|
|
8
|
+
### [POST] /submit
|
|
9
|
+
|
|
10
|
+
#### Request Headers
|
|
11
|
+
\\\`\\\`\\\`json
|
|
12
|
+
{
|
|
13
|
+
"x-topics": "[\"tm_messagebox\"]", // array of topic identifiers as stringified JSON
|
|
14
|
+
"x-includes-off-chain-values": "false" // string "true" or "false"
|
|
15
|
+
}
|
|
16
|
+
\\\`\\\`\\\`
|
|
17
|
+
|
|
18
|
+
#### Request Body
|
|
19
|
+
\\\`\\\`\\\`json
|
|
20
|
+
[1,1,1,1... ], // transaction in atomic BEEF format as Uint8Array
|
|
21
|
+
\\\`\\\`\\\`
|
|
22
|
+
|
|
23
|
+
The engine processes this TaggedBEEF and generates a STEAK (Submitted Transaction Execution AcKnowledgment), which is returned to the client.
|
|
24
|
+
|
|
25
|
+
#### Response Body
|
|
26
|
+
\\\`\\\`\\\`json
|
|
27
|
+
{
|
|
28
|
+
"tm_messagebox": {
|
|
29
|
+
"outputsToAdmit": [0], // which of the outputs in the BEEF to admit
|
|
30
|
+
"coinsToRetain": [], // which of the inputs in the BEEF to mark spent but keep within the Topic
|
|
31
|
+
"coinsRemoved": [], // which of the inputs in the BEEF to remove from the Topic
|
|
32
|
+
},
|
|
33
|
+
... // per topic
|
|
34
|
+
}
|
|
35
|
+
\\\`\\\`\\\`
|
|
36
|
+
|
|
37
|
+
<br />
|
|
38
|
+
|
|
39
|
+
## Lookup Services
|
|
40
|
+
|
|
41
|
+
A Lookup Service is a component that enables data retrieval from the Overlay Services ecosystem. It allows clients to search and retrieve transactions that were previously submitted to Topic Managers, using specific criteria or identifiers.
|
|
42
|
+
|
|
43
|
+
### [POST] /lookup
|
|
44
|
+
|
|
45
|
+
#### Request Body
|
|
46
|
+
\\\`\\\`\\\`json
|
|
47
|
+
{
|
|
48
|
+
"service": "ls_messagebox", // Lookup Service identifier as string,
|
|
49
|
+
"query": "findAll" // query must be a string, JSON queries should be stringified
|
|
50
|
+
}
|
|
51
|
+
\\\`\\\`\\\`
|
|
52
|
+
|
|
53
|
+
#### Response Body
|
|
54
|
+
\\\`\\\`\\\`json
|
|
55
|
+
{
|
|
56
|
+
"type": "output-list",
|
|
57
|
+
"outputs": [{
|
|
58
|
+
"beef": [1, 1, 1...], // number[]
|
|
59
|
+
"outputIndex": 0, // number
|
|
60
|
+
"context"?: [1, 1, 1...], // number[]
|
|
61
|
+
}>]
|
|
62
|
+
}
|
|
63
|
+
\\\`\\\`\\\`
|
|
64
|
+
|
|
65
|
+
<br />
|
|
66
|
+
|
|
67
|
+
## Summary
|
|
68
|
+
|
|
69
|
+
Usually Topic Managers and Lookup Services are paired, but they can be separated for greater flexibility. Together, they form a complete system for data submission, organization, and retrieval within the Overlay Services framework.
|
|
70
|
+
|
|
71
|
+
<br />
|
|
72
|
+
<br />
|
|
73
|
+
\`
|
|
74
|
+
`;
|
package/src/makeUserInterface.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import generalGuide from './generalGuide.md.js'
|
|
2
|
+
|
|
1
3
|
export type UIConfig = {
|
|
4
|
+
host?: string;
|
|
2
5
|
faviconUrl?: string;
|
|
3
6
|
backgroundColor?: string;
|
|
4
7
|
primaryColor?: string;
|
|
@@ -7,24 +10,33 @@ export type UIConfig = {
|
|
|
7
10
|
headingFontFamily?: string;
|
|
8
11
|
additionalStyles?: string;
|
|
9
12
|
sectionBackgroundColor?: string;
|
|
13
|
+
primaryTextColor?: string;
|
|
10
14
|
linkColor?: string;
|
|
11
15
|
hoverColor?: string;
|
|
12
16
|
borderColor?: string;
|
|
17
|
+
secondaryBackgroundColor?: string;
|
|
18
|
+
secondaryTextColor?: string;
|
|
19
|
+
defaultContent?: string;
|
|
13
20
|
};
|
|
14
21
|
|
|
15
22
|
export default (config: UIConfig = {}): string => {
|
|
16
23
|
const {
|
|
24
|
+
host = '',
|
|
17
25
|
faviconUrl = 'https://bsvblockchain.org/favicon.ico',
|
|
18
|
-
backgroundColor = '#
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
26
|
+
backgroundColor = '#191919',
|
|
27
|
+
primaryTextColor = '#f0f0f0',
|
|
28
|
+
primaryColor = '#3b6efb',
|
|
29
|
+
secondaryColor = '#001242',
|
|
30
|
+
fontFamily = 'Helvetica, Arial, sans-serif',
|
|
31
|
+
headingFontFamily = 'Helvetica, Arial, sans-serif',
|
|
23
32
|
additionalStyles = '',
|
|
24
33
|
sectionBackgroundColor = '#323940',
|
|
25
34
|
linkColor = '#579DFF',
|
|
26
35
|
hoverColor = '#3A4147',
|
|
27
36
|
borderColor = '#B6C2CF',
|
|
37
|
+
secondaryBackgroundColor = '#f8f8f8',
|
|
38
|
+
secondaryTextColor = '#0e0e0e',
|
|
39
|
+
defaultContent = generalGuide
|
|
28
40
|
} = config;
|
|
29
41
|
|
|
30
42
|
return `<!DOCTYPE html>
|
|
@@ -45,6 +57,9 @@ export default (config: UIConfig = {}): string => {
|
|
|
45
57
|
--link-color: ${linkColor};
|
|
46
58
|
--hover-color: ${hoverColor};
|
|
47
59
|
--border-color: ${borderColor};
|
|
60
|
+
--secondary-background-color: ${secondaryBackgroundColor};
|
|
61
|
+
--secondary-text-color: ${secondaryTextColor};
|
|
62
|
+
--primary-text-color: ${primaryTextColor};
|
|
48
63
|
}
|
|
49
64
|
|
|
50
65
|
body {
|
|
@@ -52,13 +67,24 @@ export default (config: UIConfig = {}): string => {
|
|
|
52
67
|
background-color: var(--background-color);
|
|
53
68
|
margin: 0;
|
|
54
69
|
padding: 0;
|
|
55
|
-
color: var(--primary-color);
|
|
70
|
+
color: var(--primary-text-color);
|
|
56
71
|
}
|
|
57
72
|
|
|
58
73
|
h1, h2, h3 {
|
|
59
74
|
font-family: var(--heading-font-family);
|
|
60
75
|
}
|
|
61
76
|
|
|
77
|
+
p {
|
|
78
|
+
line-height: 1.5;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.welcome {
|
|
82
|
+
background-clip: text;
|
|
83
|
+
color: transparent;
|
|
84
|
+
background-image: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
|
|
85
|
+
cursor: pointer;
|
|
86
|
+
}
|
|
87
|
+
|
|
62
88
|
a {
|
|
63
89
|
color: var(--link-color);
|
|
64
90
|
text-decoration: none;
|
|
@@ -75,69 +101,57 @@ export default (config: UIConfig = {}): string => {
|
|
|
75
101
|
overflow: hidden;
|
|
76
102
|
}
|
|
77
103
|
|
|
78
|
-
.
|
|
104
|
+
.column_right {
|
|
79
105
|
padding: 1.5em;
|
|
80
106
|
overflow-y: auto;
|
|
81
107
|
}
|
|
82
108
|
|
|
83
109
|
.column_left {
|
|
84
|
-
|
|
85
|
-
|
|
110
|
+
padding: 15px 15px 15px 35px;
|
|
111
|
+
overflow-y: auto;
|
|
112
|
+
width: 360px;
|
|
113
|
+
background-color: var(--secondary-background-color);
|
|
114
|
+
color: var(--secondary-text-color);
|
|
86
115
|
}
|
|
87
116
|
|
|
88
117
|
.column_right {
|
|
89
|
-
width:
|
|
90
|
-
border-left: 1px solid var(--border-color);
|
|
118
|
+
width: calc(100% - 360px);
|
|
91
119
|
}
|
|
92
120
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
border-bottom: 1px solid var(--border-color);
|
|
121
|
+
#documentation_container {
|
|
122
|
+
padding: 0 8em;
|
|
123
|
+
margin: 0;
|
|
97
124
|
}
|
|
98
125
|
|
|
99
126
|
/* List styles */
|
|
100
127
|
.list-item {
|
|
101
|
-
|
|
102
|
-
align-items: center;
|
|
103
|
-
margin: 0.5em 0;
|
|
128
|
+
margin: 0;
|
|
104
129
|
}
|
|
105
130
|
|
|
106
131
|
.list-item a {
|
|
107
|
-
display:
|
|
108
|
-
align-items: center;
|
|
132
|
+
display: block;
|
|
109
133
|
width: 100%;
|
|
110
|
-
padding: 0.5em;
|
|
134
|
+
padding: 0.5em 0.75em;
|
|
111
135
|
background-color: transparent;
|
|
112
136
|
border-radius: 5px;
|
|
113
137
|
transition: background-color 0.3s;
|
|
114
138
|
text-decoration: none;
|
|
115
139
|
color: inherit;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
.list-item a:hover {
|
|
119
|
-
background-color: var(--hover-color);
|
|
140
|
+
font-weight: 500;
|
|
120
141
|
cursor: pointer;
|
|
121
142
|
}
|
|
122
143
|
|
|
123
|
-
.list-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
.list-text {
|
|
130
|
-
display: flex;
|
|
131
|
-
flex-direction: column;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
.list-title {
|
|
135
|
-
font-weight: bold;
|
|
144
|
+
.list-item a:hover, .list-item a.active {
|
|
145
|
+
background: var(--primary-color) linear-gradient(90deg, var(--primary-color), var(--secondary-color));
|
|
146
|
+
color: white;
|
|
147
|
+
cursor: pointer;
|
|
148
|
+
border-radius: 8px 0 0 8px;
|
|
136
149
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
|
|
151
|
+
ul#manager_list, ul#provider_list, ul#external_list {
|
|
152
|
+
list-style-type: none;
|
|
153
|
+
padding-left: 0;
|
|
154
|
+
margin-top: 0.5em;
|
|
141
155
|
}
|
|
142
156
|
|
|
143
157
|
/* Detail styles */
|
|
@@ -170,41 +184,186 @@ export default (config: UIConfig = {}): string => {
|
|
|
170
184
|
color: var(--link-color);
|
|
171
185
|
}
|
|
172
186
|
|
|
187
|
+
/* Code highlighting styles */
|
|
188
|
+
pre {
|
|
189
|
+
position: relative;
|
|
190
|
+
padding: 1em;
|
|
191
|
+
border-radius: 5px;
|
|
192
|
+
overflow: auto;
|
|
193
|
+
background-color: #282c34;
|
|
194
|
+
margin: 1em 0;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
pre[data-language]:before {
|
|
198
|
+
content: attr(data-language);
|
|
199
|
+
position: absolute;
|
|
200
|
+
top: 0;
|
|
201
|
+
right: 0;
|
|
202
|
+
padding: 0.25em 0.5em;
|
|
203
|
+
font-size: 0.75em;
|
|
204
|
+
color: #abb2bf;
|
|
205
|
+
background-color: #3e4451;
|
|
206
|
+
border-radius: 0 0 0 4px;
|
|
207
|
+
text-transform: uppercase;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
code {
|
|
211
|
+
font-family: Menlo, Monaco, 'Courier New', monospace;
|
|
212
|
+
font-size: 0.9em;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/* Inline code */
|
|
216
|
+
p code, li code {
|
|
217
|
+
background-color: #3e4451;
|
|
218
|
+
padding: 0.2em 0.4em;
|
|
219
|
+
border-radius: 3px;
|
|
220
|
+
white-space: nowrap;
|
|
221
|
+
}
|
|
222
|
+
|
|
173
223
|
/* Responsive design */
|
|
174
224
|
@media screen and (max-width: 850px) {
|
|
175
225
|
.main {
|
|
176
226
|
flex-direction: column;
|
|
177
227
|
}
|
|
178
228
|
|
|
229
|
+
.column_left {
|
|
230
|
+
max-height: 30vh;
|
|
231
|
+
}
|
|
232
|
+
|
|
179
233
|
.column_left, .column_right {
|
|
180
|
-
width:
|
|
234
|
+
width: 90%;
|
|
235
|
+
margin: 0;
|
|
236
|
+
padding: 0 5%;
|
|
181
237
|
}
|
|
182
238
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
239
|
+
#documentation_container {
|
|
240
|
+
margin: 0;
|
|
241
|
+
padding: 0;
|
|
186
242
|
}
|
|
187
243
|
}
|
|
188
244
|
|
|
189
245
|
${additionalStyles}
|
|
190
246
|
</style>
|
|
191
247
|
<script src="https://cdn.jsdelivr.net/npm/showdown@2.0.3/dist/showdown.min.js"></script>
|
|
248
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.7.0/build/styles/atom-one-dark.min.css">
|
|
249
|
+
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.7.0/build/highlight.min.js"></script>
|
|
192
250
|
<script>
|
|
193
251
|
const faviconUrl = '${faviconUrl}';
|
|
194
252
|
|
|
195
253
|
const showdown = window.showdown;
|
|
254
|
+
window.hljs.configure({ languages: ['typescript', 'javascript', 'json', 'html', 'css', 'bash', 'markdown'] });
|
|
255
|
+
|
|
196
256
|
|
|
197
257
|
const Convert = (md) => {
|
|
198
|
-
let converter = new showdown.Converter(
|
|
199
|
-
|
|
258
|
+
let converter = new showdown.Converter({
|
|
259
|
+
ghCompatibleHeaderId: true,
|
|
260
|
+
simpleLineBreaks: true,
|
|
261
|
+
ghMentions: true,
|
|
262
|
+
tables: true,
|
|
263
|
+
tasklists: true,
|
|
264
|
+
strikethrough: true,
|
|
265
|
+
parseImgDimensions: true,
|
|
266
|
+
simplifiedAutoLink: true
|
|
267
|
+
});
|
|
268
|
+
// Set to use GitHub flavor markdown
|
|
269
|
+
converter.setFlavor('github');
|
|
270
|
+
|
|
271
|
+
// Set language detection for code blocks
|
|
272
|
+
converter.setOption('ghCodeBlocks', true);
|
|
273
|
+
converter.setOption('omitExtraWLInCodeBlocks', true);
|
|
274
|
+
converter.setOption('literalMidWordUnderscores', true);
|
|
275
|
+
converter.setOption('parseImgDimensions', true);
|
|
276
|
+
|
|
277
|
+
// Add custom extension for adding language-specific class to code blocks
|
|
278
|
+
const codeExtension = () => [
|
|
279
|
+
{
|
|
280
|
+
type: 'output',
|
|
281
|
+
filter: function(text) {
|
|
282
|
+
return text.replace(/<pre><code\s*class="([^"]*)">(.*?)<\\/code><\\/pre>/gs, function(match, language, content) {
|
|
283
|
+
if (language) {
|
|
284
|
+
// Clean up the language identifier
|
|
285
|
+
const lang = language.replace('language-', '').trim();
|
|
286
|
+
return \`<pre data-language="\${lang}"><code class="language-\${lang} hljs">\${content}</code></pre>\`;
|
|
287
|
+
} else {
|
|
288
|
+
return \`<pre><code class="hljs">\${content}</code></pre>\`;
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
];
|
|
294
|
+
|
|
295
|
+
// Add the extension
|
|
296
|
+
converter.addExtension(codeExtension());
|
|
297
|
+
const html = converter.makeHtml(md);
|
|
298
|
+
|
|
299
|
+
return html;
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
window.returnHome = () => {
|
|
303
|
+
if (!window.defaultHtml) {
|
|
304
|
+
let newStuff = Convert(${defaultContent});
|
|
305
|
+
window.defaultHtml = newStuff;
|
|
306
|
+
}
|
|
307
|
+
document.getElementById('documentation_container').innerHTML = window.defaultHtml;
|
|
308
|
+
window.location.hash = '';
|
|
309
|
+
document.querySelectorAll('.list-item a').forEach(item => {
|
|
310
|
+
item.classList.remove('active');
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// Function to apply syntax highlighting after content is inserted
|
|
315
|
+
const applyHighlighting = () => {
|
|
316
|
+
document.querySelectorAll('pre code').forEach(block => {
|
|
317
|
+
const blockElement = block;
|
|
318
|
+
|
|
319
|
+
// Check for language class
|
|
320
|
+
const classList = Array.from(blockElement.classList);
|
|
321
|
+
const langClass = classList.find(cls => cls.startsWith('language-'));
|
|
322
|
+
|
|
323
|
+
if (langClass) {
|
|
324
|
+
const language = langClass.replace('language-', '');
|
|
325
|
+
// Set language label on the parent pre element
|
|
326
|
+
const preElement = blockElement.parentElement;
|
|
327
|
+
if (preElement) {
|
|
328
|
+
preElement.setAttribute('data-language', language);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Apply highlighting to all code blocks
|
|
333
|
+
try {
|
|
334
|
+
// @ts-ignore - hljs is loaded from CDN
|
|
335
|
+
window.hljs.highlightElement(blockElement);
|
|
336
|
+
} catch (e) {
|
|
337
|
+
console.error('Error highlighting code:', e);
|
|
338
|
+
}
|
|
339
|
+
});
|
|
200
340
|
};
|
|
201
341
|
|
|
202
342
|
let managersData = {};
|
|
203
343
|
let providersData = {};
|
|
204
344
|
|
|
345
|
+
// Function to update URL hash and highlight selected item
|
|
346
|
+
const updateSelectedItem = (type, id) => {
|
|
347
|
+
// Update URL hash
|
|
348
|
+
window.location.hash = \`\${type}/\${id}\`;
|
|
349
|
+
|
|
350
|
+
// Remove active class from all list items
|
|
351
|
+
document.querySelectorAll('.list-item a').forEach(item => {
|
|
352
|
+
item.classList.remove('active');
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
// Add active class to selected item
|
|
356
|
+
const selector = \`[data-\${type}="\${id}"]\`;
|
|
357
|
+
const selectedItem = document.querySelector(selector);
|
|
358
|
+
if (selectedItem) {
|
|
359
|
+
selectedItem.classList.add('active');
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
// @ts-ignore - Adding custom property to window
|
|
205
364
|
window.managerDocumentation = async (manager) => {
|
|
206
365
|
try {
|
|
207
|
-
let res = await fetch(
|
|
366
|
+
let res = await fetch(\`${host}/getDocumentationForTopicManager?manager=\${manager}\`);
|
|
208
367
|
let docs = await res.text();
|
|
209
368
|
let managerReadme = Convert(docs);
|
|
210
369
|
|
|
@@ -212,25 +371,19 @@ export default (config: UIConfig = {}): string => {
|
|
|
212
371
|
let iconURL = managerData.iconURL || faviconUrl;
|
|
213
372
|
|
|
214
373
|
document.getElementById('documentation_container').innerHTML = managerReadme;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
<h1 class="detail-title">\${managerData.name}</h1>
|
|
220
|
-
<p class="detail-description">\${managerData.shortDescription || ''}</p>
|
|
221
|
-
\${managerData.version ? '<p class="detail-version">Version: ' + managerData.version + '</p>' : ''}
|
|
222
|
-
\${managerData.informationURL ? '<p class="detail-info"><a href="' + managerData.informationURL + '" target="_blank">More Information</a></p>' : ''}
|
|
223
|
-
</div>
|
|
224
|
-
</div>
|
|
225
|
-
\`;
|
|
374
|
+
applyHighlighting();
|
|
375
|
+
|
|
376
|
+
// Update active item and URL
|
|
377
|
+
updateSelectedItem('manager', manager);
|
|
226
378
|
} catch (error) {
|
|
227
379
|
console.error('Error fetching manager documentation:', error);
|
|
228
380
|
}
|
|
229
381
|
};
|
|
230
382
|
|
|
383
|
+
// @ts-ignore - Adding custom property to window
|
|
231
384
|
window.topicDocumentation = async (provider) => {
|
|
232
385
|
try {
|
|
233
|
-
let res = await fetch(
|
|
386
|
+
let res = await fetch(\`${host}/getDocumentationForLookupServiceProvider?lookupService=\${provider}\`);
|
|
234
387
|
let docs = await res.text();
|
|
235
388
|
let providerReadme = Convert(docs);
|
|
236
389
|
|
|
@@ -238,81 +391,127 @@ export default (config: UIConfig = {}): string => {
|
|
|
238
391
|
let iconURL = providerData.iconURL || faviconUrl;
|
|
239
392
|
|
|
240
393
|
document.getElementById('documentation_container').innerHTML = providerReadme;
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
<h1 class="detail-title">\${providerData.name}</h1>
|
|
246
|
-
<p class="detail-description">\${providerData.shortDescription || ''}</p>
|
|
247
|
-
\${providerData.version ? '<p class="detail-version">Version: ' + providerData.version + '</p>' : ''}
|
|
248
|
-
\${providerData.informationURL ? '<p class="detail-info"><a href="' + providerData.informationURL + '" target="_blank">More Information</a></p>' : ''}
|
|
249
|
-
</div>
|
|
250
|
-
</div>
|
|
251
|
-
\`;
|
|
394
|
+
applyHighlighting();
|
|
395
|
+
|
|
396
|
+
// Update active item and URL
|
|
397
|
+
updateSelectedItem('provider', provider);
|
|
252
398
|
} catch (error) {
|
|
253
399
|
console.error('Error fetching provider documentation:', error);
|
|
254
400
|
}
|
|
255
401
|
};
|
|
256
402
|
|
|
403
|
+
// Function to parse hash and load appropriate content
|
|
404
|
+
const handleUrlHash = () => {
|
|
405
|
+
const hash = window.location.hash.substring(1); // Remove the # character
|
|
406
|
+
if (hash) {
|
|
407
|
+
const [type, id] = hash.split('/');
|
|
408
|
+
if (type && id) {
|
|
409
|
+
if (type === 'manager') {
|
|
410
|
+
// Check if managers data is loaded
|
|
411
|
+
if (Object.keys(managersData).length > 0 && managersData[id]) {
|
|
412
|
+
window.managerDocumentation(id);
|
|
413
|
+
}
|
|
414
|
+
} else if (type === 'provider') {
|
|
415
|
+
// Check if providers data is loaded
|
|
416
|
+
if (Object.keys(providersData).length > 0 && providersData[id]) {
|
|
417
|
+
window.topicDocumentation(id);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
|
|
257
424
|
document.addEventListener('DOMContentLoaded', () => {
|
|
258
|
-
|
|
425
|
+
let managersLoaded = false;
|
|
426
|
+
let providersLoaded = false;
|
|
427
|
+
|
|
428
|
+
// Check if both managers and providers are loaded before handling hash
|
|
429
|
+
const checkAllLoaded = () => {
|
|
430
|
+
if (managersLoaded && providersLoaded) {
|
|
431
|
+
handleUrlHash();
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
fetch('${host}/listTopicManagers')
|
|
259
436
|
.then(res => res.json())
|
|
260
437
|
.then(managers => {
|
|
261
438
|
managersData = managers;
|
|
262
439
|
const managerList = document.getElementById('manager_list');
|
|
263
440
|
Object.keys(managers).forEach(manager => {
|
|
264
441
|
let managerData = managers[manager];
|
|
265
|
-
let iconURL = managerData.iconURL || faviconUrl;
|
|
266
442
|
let li = document.createElement('li');
|
|
267
443
|
li.className = 'list-item';
|
|
268
444
|
li.innerHTML = \`
|
|
269
|
-
<a onclick="window.managerDocumentation('\${manager}')">
|
|
270
|
-
|
|
271
|
-
<div class="list-text">
|
|
272
|
-
<span class="list-title">\${managerData.name}</span>
|
|
273
|
-
<span class="list-description">\${managerData.shortDescription || ''}</span>
|
|
274
|
-
</div>
|
|
445
|
+
<a data-manager="\${manager}" onclick="window.managerDocumentation('\${manager}')">
|
|
446
|
+
\${managerData.name}
|
|
275
447
|
</a>
|
|
276
448
|
\`;
|
|
277
449
|
managerList.appendChild(li);
|
|
278
450
|
});
|
|
451
|
+
managersLoaded = true;
|
|
452
|
+
checkAllLoaded();
|
|
279
453
|
})
|
|
280
454
|
.catch(() => {
|
|
281
455
|
let message = document.createElement('h4');
|
|
282
456
|
message.innerText = 'Something went wrong!';
|
|
283
457
|
manager_list.insertBefore(message, manager_list.children[0]);
|
|
458
|
+
managersLoaded = true;
|
|
459
|
+
checkAllLoaded();
|
|
284
460
|
});
|
|
285
461
|
|
|
286
|
-
fetch('/listLookupServiceProviders')
|
|
462
|
+
fetch('${host}/listLookupServiceProviders')
|
|
287
463
|
.then(res => res.json())
|
|
288
464
|
.then(providers => {
|
|
289
465
|
providersData = providers;
|
|
290
466
|
const providerList = document.getElementById('provider_list');
|
|
291
467
|
Object.keys(providers).forEach(provider => {
|
|
292
468
|
let providerData = providers[provider];
|
|
293
|
-
let iconURL = providerData.iconURL || faviconUrl;
|
|
294
469
|
let li = document.createElement('li');
|
|
295
470
|
li.className = 'list-item';
|
|
296
471
|
li.innerHTML = \`
|
|
297
|
-
<a onclick="window.topicDocumentation('\${provider}')">
|
|
298
|
-
|
|
299
|
-
<div class="list-text">
|
|
300
|
-
<span class="list-title">\${providerData.name}</span>
|
|
301
|
-
<span class="list-description">\${providerData.shortDescription || ''}</span>
|
|
302
|
-
</div>
|
|
472
|
+
<a data-provider="\${provider}" onclick="window.topicDocumentation('\${provider}')">
|
|
473
|
+
\${providerData.name}
|
|
303
474
|
</a>
|
|
304
475
|
\`;
|
|
305
476
|
providerList.appendChild(li);
|
|
306
477
|
});
|
|
478
|
+
providersLoaded = true;
|
|
479
|
+
checkAllLoaded();
|
|
307
480
|
})
|
|
308
481
|
.catch(() => {
|
|
309
482
|
let message = document.createElement('h4');
|
|
310
483
|
message.innerText = 'Something went wrong!';
|
|
311
484
|
provider_list.insertBefore(message, provider_list.children[0]);
|
|
485
|
+
providersLoaded = true;
|
|
486
|
+
checkAllLoaded();
|
|
312
487
|
});
|
|
313
488
|
|
|
314
|
-
//
|
|
315
|
-
|
|
489
|
+
// Check URL hash to see if we should load specific documentation
|
|
490
|
+
const checkUrlHash = () => {
|
|
491
|
+
const hash = window.location.hash.substring(1); // Remove the # symbol
|
|
492
|
+
if (hash) {
|
|
493
|
+
const parts = hash.split('/');
|
|
494
|
+
if (parts.length === 2) {
|
|
495
|
+
const type = parts[0];
|
|
496
|
+
const id = parts[1];
|
|
497
|
+
|
|
498
|
+
if (type === 'manager' && id && managersData[id]) {
|
|
499
|
+
window.managerDocumentation(id);
|
|
500
|
+
} else if (type === 'provider' && id && providersData[id]) {
|
|
501
|
+
window.topicDocumentation(id);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
} else {
|
|
505
|
+
// Display default message when no manager or provider is selected
|
|
506
|
+
returnHome();
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// Listen for hash changes
|
|
511
|
+
window.addEventListener('hashchange', checkUrlHash);
|
|
512
|
+
|
|
513
|
+
// Check hash on initial page load
|
|
514
|
+
checkUrlHash();
|
|
316
515
|
});
|
|
317
516
|
</script>
|
|
318
517
|
</head>
|
|
@@ -321,22 +520,27 @@ export default (config: UIConfig = {}): string => {
|
|
|
321
520
|
<div class="main">
|
|
322
521
|
<div class="column_left">
|
|
323
522
|
<div class="page_head">
|
|
324
|
-
<h1
|
|
325
|
-
<p>Learn more on <a href="https://github.com/bitcoin-sv/overlay-services" target="_blank">GitHub</a></p>
|
|
523
|
+
<h1 class="welcome" onclick="window.returnHome()">Overlay Services</h1>
|
|
326
524
|
</div>
|
|
327
525
|
<div class="topic_container">
|
|
328
|
-
<
|
|
329
|
-
<h3>Supported Topic Managers:</h3>
|
|
526
|
+
<h3>Topic Managers</h3>
|
|
330
527
|
<ul id="manager_list"></ul>
|
|
331
528
|
</div>
|
|
332
529
|
<div class="provider_container">
|
|
333
|
-
<h3>
|
|
530
|
+
<h3>Lookup Services</h3>
|
|
334
531
|
<ul id="provider_list"></ul>
|
|
335
532
|
</div>
|
|
533
|
+
<div>
|
|
534
|
+
<h3>External Links</h3>
|
|
535
|
+
<ul id="external_list">
|
|
536
|
+
<li class="list-item"><a href="https://github.com/bsv-blockchain/overlay-services" target="_blank">Overlay Services GitHub</a></li>
|
|
537
|
+
<li class="list-item"><a href="https://bsv.brc.dev/overlays/0088" target="_blank">BRC-88 GASP</a></li>
|
|
538
|
+
<li class="list-item"><a href="https://fast.brc.dev" target="_blank">Quick Start for App Developers</a></li>
|
|
539
|
+
</ul>
|
|
540
|
+
</div>
|
|
336
541
|
</div>
|
|
337
542
|
<div class="column_right">
|
|
338
|
-
<div id="
|
|
339
|
-
<div id="documentation_container" style="margin-left: 1.5em"></div>
|
|
543
|
+
<div id="documentation_container"></div>
|
|
340
544
|
</div>
|
|
341
545
|
</div>
|
|
342
546
|
</body>
|
|
File without changes
|