Files
NapCatQQ/.pnpm-store/v3/files/91/fc45cfe84c902a67f9b795d14b834d3cb56ea480bce0995cf3970781c8271dbf810efb89ad56808b94ec97ba96465b5e98ba759aafca0a6b3a506e0530fd73
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

33 lines
1.3 KiB
Plaintext

import { CreateType } from '../create/index.mjs';
import { Kind } from '../symbols/index.mjs';
// ------------------------------------------------------------------
// Module Infrastructure Types
// ------------------------------------------------------------------
import { ComputeModuleProperties } from './compute.mjs';
// ------------------------------------------------------------------
// Module
// ------------------------------------------------------------------
// prettier-ignore
export class TModule {
constructor($defs) {
const computed = ComputeModuleProperties($defs);
const identified = this.WithIdentifiers(computed);
this.$defs = identified;
}
/** `[Json]` Imports a Type by Key. */
Import(key, options) {
const $defs = { ...this.$defs, [key]: CreateType(this.$defs[key], options) };
return CreateType({ [Kind]: 'Import', $defs, $ref: key });
}
// prettier-ignore
WithIdentifiers($defs) {
return globalThis.Object.getOwnPropertyNames($defs).reduce((result, key) => {
return { ...result, [key]: { ...$defs[key], $id: key } };
}, {});
}
}
/** `[Json]` Creates a Type Definition Module. */
export function Module(properties) {
return new TModule(properties);
}