From b20ef423328ce795822c3f4bb45fa52a0488d5dc Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Tue, 25 Jul 2023 12:04:30 -0400 Subject: [PATCH] refactor: need to explicitly import types due to verbatimModuleSyntax --- src/contentProviders/baseProvider.ts | 2 +- src/contentProviders/internalProvider.ts | 2 +- src/contentProviders/ipfsProvider.ts | 7 ++++--- src/contentProviders/serverProvider.ts | 10 ++++++--- src/dns.ts | 7 ++----- src/main/bootloader/kernel.ts | 2 +- src/requestStream.ts | 2 +- src/types.ts | 26 ++++++++++-------------- src/webEngine.ts | 4 ++-- 9 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/contentProviders/baseProvider.ts b/src/contentProviders/baseProvider.ts index 1417a30..ab7e6ef 100644 --- a/src/contentProviders/baseProvider.ts +++ b/src/contentProviders/baseProvider.ts @@ -1,4 +1,4 @@ -import { +import type { BlockingResponse, OnBeforeRequestDetailsType, OnBeforeSendHeadersDetailsType, diff --git a/src/contentProviders/internalProvider.ts b/src/contentProviders/internalProvider.ts index 9f9d0af..8cac853 100644 --- a/src/contentProviders/internalProvider.ts +++ b/src/contentProviders/internalProvider.ts @@ -1,5 +1,5 @@ import BaseProvider from "./baseProvider.js"; -import { +import type { BlockingResponse, OnBeforeRequestDetailsType, OnHeadersReceivedDetailsType, diff --git a/src/contentProviders/ipfsProvider.ts b/src/contentProviders/ipfsProvider.ts index e669f97..2693140 100644 --- a/src/contentProviders/ipfsProvider.ts +++ b/src/contentProviders/ipfsProvider.ts @@ -1,5 +1,5 @@ import BaseProvider from "./baseProvider.js"; -import { +import type { BlockingResponse, OnBeforeRequestDetailsType, OnBeforeSendHeadersDetailsType, @@ -10,9 +10,10 @@ import { import { getRelayProxies } from "../util.js"; import { ipfsPath, ipnsPath, path as checkPath } from "is-ipfs"; import { createClient } from "@lumeweb/kernel-ipfs-client"; -import { DNS_RECORD_TYPE, DNSResult } from "@lumeweb/libresolver"; +import { DNS_RECORD_TYPE } from "@lumeweb/libresolver"; +import type { DNSResult } from "@lumeweb/libresolver"; import RequestStream from "../requestStream.js"; -import { UnixFSStats } from "@helia/unixfs"; +import type { UnixFSStats } from "@helia/unixfs"; import * as path from "path"; import { CID } from "multiformats/cid"; import { fileTypeFromBuffer } from "file-type"; diff --git a/src/contentProviders/serverProvider.ts b/src/contentProviders/serverProvider.ts index 024d901..86d4422 100644 --- a/src/contentProviders/serverProvider.ts +++ b/src/contentProviders/serverProvider.ts @@ -1,11 +1,15 @@ import BaseProvider from "./baseProvider.js"; -import { OnBeforeRequestDetailsType, OnRequestDetailsType } from "../types.js"; +import type { + OnBeforeRequestDetailsType, + OnRequestDetailsType, +} from "../types.js"; import { isDomain, isIp } from "../util.js"; -import { DNS_RECORD_TYPE, DNSRecord, DNSResult } from "@lumeweb/libresolver"; +import { DNS_RECORD_TYPE } from "@lumeweb/libresolver"; +import type { DNSRecord, DNSResult } from "@lumeweb/libresolver"; export default class ServerProvider extends BaseProvider { async shouldHandleRequest( - details: OnBeforeRequestDetailsType + details: OnBeforeRequestDetailsType, ): Promise { let dnsResult: DNSResult | boolean = await this.resolveDns(details, [ DNS_RECORD_TYPE.A, diff --git a/src/dns.ts b/src/dns.ts index c05ee53..a5dfde6 100644 --- a/src/dns.ts +++ b/src/dns.ts @@ -1,9 +1,6 @@ import NodeCache from "node-cache"; -import { - DNS_RECORD_TYPE, - DNSResult, - ResolverOptions, -} from "@lumeweb/libresolver"; +import { DNS_RECORD_TYPE } from "@lumeweb/libresolver"; +import type { DNSResult, ResolverOptions } from "@lumeweb/libresolver"; import { bufToHex } from "@lumeweb/libweb"; import { getDnsSetupDefer } from "./vars.js"; import { dnsClient } from "./clients.js"; diff --git a/src/main/bootloader/kernel.ts b/src/main/bootloader/kernel.ts index 753837b..8263890 100644 --- a/src/main/bootloader/kernel.ts +++ b/src/main/bootloader/kernel.ts @@ -1,10 +1,10 @@ import { addContextToErr, downloadObject, - Err, maybeInitDefaultPortals, setActivePortalMasterKey, } from "@lumeweb/libweb"; +import type { Err } from "@lumeweb/libweb"; import { log, logErr, sendAuthUpdate } from "./util.js"; import { defaultKernelLink, diff --git a/src/requestStream.ts b/src/requestStream.ts index 69a2552..a186fb5 100644 --- a/src/requestStream.ts +++ b/src/requestStream.ts @@ -1,4 +1,4 @@ -import { OnBeforeRequestDetailsType, StreamFilter } from "./types.js"; +import type { OnBeforeRequestDetailsType, StreamFilter } from "./types.js"; import browser from "webextension-polyfill"; import { iterateStream, streamToArray } from "./util.js"; diff --git a/src/types.ts b/src/types.ts index 91b463c..28dcd27 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,23 +1,21 @@ -import { +import type { WebRequest, Proxy, Tabs, WebNavigation, Menus, } from "webextension-polyfill"; -import OnHeadersReceivedDetailsType = WebRequest.OnHeadersReceivedDetailsType; -import OnBeforeRequestDetailsType = WebRequest.OnBeforeRequestDetailsType; -import OnBeforeSendHeadersDetailsType = WebRequest.OnBeforeSendHeadersDetailsType; -import OnCompletedDetailsType = WebRequest.OnCompletedDetailsType; -import OnErrorOccurredDetailsType = WebRequest.OnErrorOccurredDetailsType; -import BlockingResponse = WebRequest.BlockingResponse; -import OnRequestDetailsType = Proxy.OnRequestDetailsType; -import HttpHeaders = WebRequest.HttpHeaders; -import StreamFilter = WebRequest.StreamFilter; -import HttpHeadersItemType = WebRequest.HttpHeadersItemType; -import OnBeforeNavigateDetailsType = WebNavigation.OnBeforeNavigateDetailsType; +type OnHeadersReceivedDetailsType = WebRequest.OnHeadersReceivedDetailsType; +type OnBeforeRequestDetailsType = WebRequest.OnBeforeRequestDetailsType; +type OnBeforeSendHeadersDetailsType = WebRequest.OnBeforeSendHeadersDetailsType; +type OnCompletedDetailsType = WebRequest.OnCompletedDetailsType; +type OnErrorOccurredDetailsType = WebRequest.OnErrorOccurredDetailsType; +type BlockingResponse = WebRequest.BlockingResponse; +type OnRequestDetailsType = Proxy.OnRequestDetailsType; +type StreamFilter = WebRequest.StreamFilter; +type OnBeforeNavigateDetailsType = WebNavigation.OnBeforeNavigateDetailsType; -export { +export type { OnHeadersReceivedDetailsType, OnBeforeRequestDetailsType, OnBeforeSendHeadersDetailsType, @@ -25,9 +23,7 @@ export { OnErrorOccurredDetailsType, BlockingResponse, OnRequestDetailsType, - HttpHeaders, StreamFilter, - HttpHeadersItemType, Tabs, OnBeforeNavigateDetailsType, Menus, diff --git a/src/webEngine.ts b/src/webEngine.ts index 688e7c3..6e9e6ad 100644 --- a/src/webEngine.ts +++ b/src/webEngine.ts @@ -1,6 +1,6 @@ import browser from "webextension-polyfill"; import BaseProvider from "./contentProviders/baseProvider.js"; -import { +import type { BlockingResponse, OnBeforeNavigateDetailsType, OnBeforeRequestDetailsType, @@ -15,7 +15,7 @@ import tldEnum from "@lumeweb/tld-enum"; import { scanRecords } from "./dns.js"; import { bufToHex } from "@lumeweb/libweb"; import { getAuthStatus } from "./vars.js"; -import { DNSResult } from "@lumeweb/libresolver"; +import type { DNSResult } from "@lumeweb/libresolver"; import { blake3 } from "@noble/hashes/blake3"; import "./contentFilters/index.js";