From a9cb2c7045d18f96647635465a631358cff13206 Mon Sep 17 00:00:00 2001 From: Outer Cloud Studio Date: Tue, 21 May 2024 01:45:00 -0500 Subject: [PATCH] Load scripting types if none match --- src/components/Data/TypeLoader.ts | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/components/Data/TypeLoader.ts b/src/components/Data/TypeLoader.ts index 7795097ad..16a6eaf09 100644 --- a/src/components/Data/TypeLoader.ts +++ b/src/components/Data/TypeLoader.ts @@ -165,20 +165,34 @@ export class TypeLoader { const matcher = new RequiresMatcher() await matcher.setup() - const libs = await this.load( - types + let libDefinitions = types + .map((type) => { + if (typeof type === 'string') return [type] + + const { definition, requires, moduleName } = type + + if (!requires || matcher.isValid(requires as IRequirements)) + return [definition, moduleName] + + return [] + }) + .filter((type) => type[0]) as [string, string?][] + + if (libDefinitions.length === 0) { + libDefinitions = types .map((type) => { if (typeof type === 'string') return [type] const { definition, requires, moduleName } = type - if (!requires || matcher.isValid(requires as IRequirements)) - return [definition, moduleName] - - return [] + return [definition, moduleName] }) .filter((type) => type[0]) as [string, string?][] - ) + } + + console.log(libDefinitions) + + const libs = await this.load(libDefinitions) for (const [typePath, lib] of libs) { const uri = Uri.file(typePath)