Skip to content

Commit

Permalink
Load scripting types if none match
Browse files Browse the repository at this point in the history
  • Loading branch information
outercloudstudio committed May 21, 2024
1 parent a596b78 commit a9cb2c7
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/components/Data/TypeLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a9cb2c7

Please sign in to comment.