32 lines
1.4 KiB
JavaScript
32 lines
1.4 KiB
JavaScript
|
|
"use strict";
|
||
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||
|
|
exports.installNetworkingFeatures = void 0;
|
||
|
|
/**
|
||
|
|
* Installs the DWeb networking features in the current environment.
|
||
|
|
*/
|
||
|
|
function installNetworkingFeatures(path) {
|
||
|
|
var _a;
|
||
|
|
var workerSelf = self;
|
||
|
|
try {
|
||
|
|
if (typeof ServiceWorkerGlobalScope !== 'undefined' && workerSelf instanceof ServiceWorkerGlobalScope) {
|
||
|
|
// Dynamically import service worker code only if we're in a Service Worker context
|
||
|
|
import('./service-worker.js').catch(function (error) {
|
||
|
|
console.error('Error loading service worker module:', error);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
else if ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _a === void 0 ? void 0 : _a.serviceWorker) {
|
||
|
|
if (path)
|
||
|
|
navigator.serviceWorker.register(path).catch(function (error) {
|
||
|
|
console.error('DWeb networking feature installation failed: ', error);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
throw new Error('DWeb networking features are not available for install in this environment');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch (error) {
|
||
|
|
console.error('Error in installing networking features:', error);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
exports.installNetworkingFeatures = installNetworkingFeatures;
|
||
|
|
//# sourceMappingURL=web-features.js.map
|