@enbox/browser 0.3.57 → 0.3.59
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/browser.mjs +14 -14
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/dweb-connect-client.js +14 -15
- package/dist/esm/dweb-connect-client.js.map +1 -1
- package/dist/esm/dweb-connect-wallet.js +11 -13
- package/dist/esm/dweb-connect-wallet.js.map +1 -1
- package/dist/esm/handled-deferred.js +24 -0
- package/dist/esm/handled-deferred.js.map +1 -0
- package/dist/esm/index.js +7 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/relay-connect-runner.js +55 -26
- package/dist/esm/relay-connect-runner.js.map +1 -1
- package/dist/esm/ui/connect-modal.js +111 -77
- package/dist/esm/ui/connect-modal.js.map +1 -1
- package/dist/esm/ui/qr.js +121 -64
- package/dist/esm/ui/qr.js.map +1 -1
- package/dist/esm/web-features.js +54 -41
- package/dist/esm/web-features.js.map +1 -1
- package/dist/types/dweb-connect-client.d.ts +4 -4
- package/dist/types/dweb-connect-client.d.ts.map +1 -1
- package/dist/types/dweb-connect-wallet.d.ts +3 -3
- package/dist/types/dweb-connect-wallet.d.ts.map +1 -1
- package/dist/types/handled-deferred.d.ts +22 -0
- package/dist/types/handled-deferred.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/relay-connect-runner.d.ts +1 -1
- package/dist/types/relay-connect-runner.d.ts.map +1 -1
- package/dist/types/ui/connect-modal.d.ts.map +1 -1
- package/dist/types/ui/qr.d.ts.map +1 -1
- package/dist/types/web-features.d.ts.map +1 -1
- package/package.json +11 -10
- package/src/dweb-connect-client.ts +15 -15
- package/src/dweb-connect-wallet.ts +14 -14
- package/src/handled-deferred.ts +38 -0
- package/src/index.ts +50 -0
- package/src/relay-connect-runner.ts +71 -30
- package/src/ui/connect-modal.ts +113 -72
- package/src/ui/qr.ts +145 -69
- package/src/web-features.ts +55 -43
package/src/web-features.ts
CHANGED
|
@@ -426,6 +426,41 @@ function cancelNavigation(): void {
|
|
|
426
426
|
activeNavigation = null;
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
+
/**
|
|
430
|
+
* Opens the tab/loading-overlay target for a DRL anchor click, then resolves
|
|
431
|
+
* and navigates to the DRL's first working DWN endpoint. Extracted from the
|
|
432
|
+
* click handler so the handler itself stays a shallow guard-clause dispatch
|
|
433
|
+
* (Sonar S3776).
|
|
434
|
+
*/
|
|
435
|
+
async function navigateToDrl(did: string, path: string, openAsTab: boolean): Promise<void> {
|
|
436
|
+
let tab: Window | null = null;
|
|
437
|
+
if (openAsTab) {
|
|
438
|
+
tab = window.open('', '_blank');
|
|
439
|
+
if (tab) {tab.document.write(tabContent);}
|
|
440
|
+
} else {
|
|
441
|
+
activeNavigation = path;
|
|
442
|
+
// this is to allow for cached DIDs to instantly load without any flash of loading UI
|
|
443
|
+
setTimeout(
|
|
444
|
+
() =>
|
|
445
|
+
document.documentElement.setAttribute('drl-link-loading', ''),
|
|
446
|
+
50
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
const endpoints = await getDwnEndpoints(did);
|
|
450
|
+
if (!endpoints.length) {
|
|
451
|
+
throw new Error('no valid DWN endpoints found');
|
|
452
|
+
}
|
|
453
|
+
const url = `${endpoints[0].replace(
|
|
454
|
+
trailingSlashRegex,
|
|
455
|
+
''
|
|
456
|
+
)}/${did}/${path}`;
|
|
457
|
+
if (openAsTab) {
|
|
458
|
+
if (tab && !tab.closed) {tab.location.href = url;}
|
|
459
|
+
} else if (activeNavigation === path) {
|
|
460
|
+
window.location.href = url;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
429
464
|
let activeNavigation: string | null = null;
|
|
430
465
|
let linkFeaturesActive = false;
|
|
431
466
|
|
|
@@ -437,50 +472,27 @@ function addLinkFeatures(): void {
|
|
|
437
472
|
if (!linkFeaturesActive) {
|
|
438
473
|
clickHandler = async (event: MouseEvent): Promise<void> => {
|
|
439
474
|
const anchor = (event.target as Element)?.closest('a');
|
|
440
|
-
if (anchor) {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
() =>
|
|
458
|
-
document.documentElement.setAttribute('drl-link-loading', ''),
|
|
459
|
-
50
|
|
460
|
-
);
|
|
461
|
-
}
|
|
462
|
-
const endpoints = await getDwnEndpoints(did);
|
|
463
|
-
if (!endpoints.length) {
|
|
464
|
-
throw new Error('no valid DWN endpoints found');
|
|
465
|
-
}
|
|
466
|
-
const url = `${endpoints[0].replace(
|
|
467
|
-
trailingSlashRegex,
|
|
468
|
-
''
|
|
469
|
-
)}/${did}/${path}`;
|
|
470
|
-
if (openAsTab) {
|
|
471
|
-
if (tab && !tab.closed) {tab.location.href = url;}
|
|
472
|
-
} else if (activeNavigation === path) {
|
|
473
|
-
window.location.href = url;
|
|
474
|
-
}
|
|
475
|
-
} catch {
|
|
476
|
-
if (activeNavigation === path) {
|
|
477
|
-
cancelNavigation();
|
|
478
|
-
}
|
|
479
|
-
throw new Error(
|
|
480
|
-
`DID endpoint resolution failed for the DRL: ${href}`
|
|
481
|
-
);
|
|
482
|
-
}
|
|
475
|
+
if (!anchor) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
const href = anchor.href;
|
|
479
|
+
const parsed = parseDrlUrl(href);
|
|
480
|
+
if (!parsed) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
const did = parsed[0];
|
|
484
|
+
const path = parsed[1];
|
|
485
|
+
const openAsTab = anchor.target === '_blank';
|
|
486
|
+
event.preventDefault();
|
|
487
|
+
try {
|
|
488
|
+
await navigateToDrl(did, path, openAsTab);
|
|
489
|
+
} catch {
|
|
490
|
+
if (activeNavigation === path) {
|
|
491
|
+
cancelNavigation();
|
|
483
492
|
}
|
|
493
|
+
throw new Error(
|
|
494
|
+
`DID endpoint resolution failed for the DRL: ${href}`
|
|
495
|
+
);
|
|
484
496
|
}
|
|
485
497
|
};
|
|
486
498
|
|