feat: add ready to setup

This commit is contained in:
Derrick Hammer 2023-07-15 04:22:59 -04:00
parent 9fa4e3eb12
commit c329921aa4
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 11 additions and 26 deletions

View File

@ -4,38 +4,17 @@ import {
handleMessage,
} from "@lumeweb/libkernel/module";
import type {
DNSResult,
ResolverModule as ResolverModuleBase,
} from "@lumeweb/libresolver";
import type { DNSResult } from "@lumeweb/libresolver";
import { DNS_RECORD_TYPE } from "@lumeweb/libresolver";
import { dnsClient } from "./client.js";
import { DnsClient } from "@lumeweb/kernel-dns-client";
import type { ResolverOptions } from "@lumeweb/libresolver";
import { ResolverModule } from "@lumeweb/kernel-dns-client";
let resolver: ResolverModule | ResolverModuleBase;
let resolver: ResolverModule;
export interface ResolverModule {
get resolver(): DnsClient;
set resolver(value: DnsClient);
resolve(
domain: string,
options: ResolverOptions,
bypassCache: boolean,
): Promise<DNSResult>;
getSupportedTlds(): string[];
getSupportedTlds(): Promise<string[]>;
getSupportedTlds(): any;
}
export function setup(rm: ResolverModule | ResolverModuleBase) {
export function setup(rm: ResolverModule) {
addHandler("resolve", handleResolve);
addHandler("register", handleRegister);
addHandler("ready", handleReady);
addHandler("getSupportedTlds", handleGetSupportedTlds);
onmessage = handleMessage;
resolver = rm;
@ -78,6 +57,12 @@ function handleGetSupportedTlds(aq: ActiveQuery) {
aq.respond(resolver.getSupportedTlds());
}
async function handleReady(aq: ActiveQuery) {
await resolver.ready();
aq.respond();
}
export * from "@lumeweb/libresolver/lib/util.js";
export * from "@lumeweb/libresolver/lib/types.js";
export { AbstractResolverModule } from "@lumeweb/libresolver/lib/resolverModule.js";