mirror of
https://github.com/certd/certd.git
synced 2026-06-21 09:17:31 +08:00
chore: 完善第三方依赖动态加载
This commit is contained in:
@@ -15,7 +15,9 @@
|
||||
"preview": "vite preview",
|
||||
"test:unit": "cross-env NODE_ENV=unittest mocha --no-config --node-option no-warnings --node-option loader=ts-node/esm \"src/**/*.test.ts\"",
|
||||
"pub": "npm publish",
|
||||
"compile": "tsc --skipLibCheck --watch"
|
||||
"compile": "tsc --skipLibCheck --watch",
|
||||
"format": "prettier --write src",
|
||||
"lint": "eslint --fix"
|
||||
},
|
||||
"dependencies": {
|
||||
"@alicloud/openapi-client": "^0.4.15",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { HttpClient, ILogger } from "@certd/basic";
|
||||
import { IAccessService, PageRes, PageSearch } from "@certd/pipeline";
|
||||
import { IAccessService, IRuntimeDepsService, PageRes, PageSearch } from "@certd/pipeline";
|
||||
import punycode from "punycode.js";
|
||||
import { CreateRecordOptions, DnsProviderContext, DnsProviderDefine, DnsResolveRecord, DomainRecord, IDnsProvider, RemoveRecordOptions } from "./api.js";
|
||||
import { dnsProviderRegistry } from "./registry.js";
|
||||
@@ -7,16 +7,13 @@ export abstract class AbstractDnsProvider<T = any> implements IDnsProvider<T> {
|
||||
ctx!: DnsProviderContext;
|
||||
http!: HttpClient;
|
||||
logger!: ILogger;
|
||||
runtimeDepsService?: {
|
||||
ensureRuntimeDependencies(pluginKeys: string | string[]): Promise<any>;
|
||||
importRuntime(specifier: string): Promise<any>;
|
||||
};
|
||||
runtimeDepsService?: IRuntimeDepsService;
|
||||
|
||||
async importRuntime(specifier: string) {
|
||||
if (!this.runtimeDepsService) {
|
||||
return await import(specifier);
|
||||
}
|
||||
return await this.runtimeDepsService.importRuntime(specifier);
|
||||
return await this.runtimeDepsService.importRuntime(specifier, this.logger);
|
||||
}
|
||||
|
||||
usePunyCode(): boolean {
|
||||
@@ -49,7 +46,7 @@ export abstract class AbstractDnsProvider<T = any> implements IDnsProvider<T> {
|
||||
this.runtimeDepsService = await this.ctx.serviceGetter.get("runtimeDepsService");
|
||||
}
|
||||
if (this.runtimeDepsService && this.ctx.define?.name) {
|
||||
await this.runtimeDepsService.ensureRuntimeDependencies(`dnsProvider:${this.ctx.define.name}`);
|
||||
await this.runtimeDepsService.ensureRuntimeDependencies({ pluginKeys: `dnsProvider:${this.ctx.define.name}`, logger: this.logger });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user