Skip to content

Commit fd83226

Browse files
committed
Prep for new Oxide API
1 parent ed289bf commit fd83226

File tree

1 file changed

+44
-2
lines changed
  • packages/tailwindcss-language-server/src

1 file changed

+44
-2
lines changed

packages/tailwindcss-language-server/src/oxide.ts

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,37 @@ declare namespace OxideV3And4 {
5858
}
5959
}
6060

61+
// This covers the Oxide API from v4.1.0+
62+
declare namespace OxideV5 {
63+
interface GlobEntry {
64+
base: string
65+
pattern: string
66+
}
67+
68+
interface SourceEntry {
69+
base: string
70+
pattern: string
71+
negated: boolean
72+
}
73+
74+
interface ScannerOptions {
75+
sources: Array<SourceEntry>
76+
}
77+
78+
interface ScannerConstructor {
79+
new (options: ScannerOptions): Scanner
80+
}
81+
82+
interface Scanner {
83+
get files(): Array<string>
84+
get globs(): Array<GlobEntry>
85+
}
86+
}
87+
6188
interface Oxide {
6289
scanDir?(options: OxideV1.ScanOptions): OxideV1.ScanResult
6390
scanDir?(options: OxideV2.ScanOptions): OxideV2.ScanResult
64-
Scanner?: OxideV3And4.ScannerConstructor
91+
Scanner?: OxideV3And4.ScannerConstructor | OxideV5.ScannerConstructor
6592
}
6693

6794
async function loadOxideAtPath(id: string): Promise<Oxide | null> {
@@ -150,7 +177,7 @@ export async function scan(options: ScanOptions): Promise<ScanResult | null> {
150177
}
151178

152179
// V4
153-
else {
180+
else if (lte(options.oxideVersion, '4.0.9999')) {
154181
let scanner = new (oxide.Scanner as OxideV3And4.ScannerConstructor)({
155182
sources: [
156183
{ base: options.basePath, pattern: '**/*' },
@@ -163,4 +190,19 @@ export async function scan(options: ScanOptions): Promise<ScanResult | null> {
163190
globs: scanner.globs.map((g) => ({ base: g.base, pattern: g.pattern })),
164191
}
165192
}
193+
194+
// V5
195+
else {
196+
let scanner = new (oxide.Scanner as OxideV5.ScannerConstructor)({
197+
sources: [
198+
{ base: options.basePath, pattern: '**/*', negated: false },
199+
...options.sources.map((g) => ({ base: g.base, pattern: g.pattern, negated: g.negated })),
200+
],
201+
})
202+
203+
return {
204+
files: scanner.files,
205+
globs: scanner.globs.map((g) => ({ base: g.base, pattern: g.pattern })),
206+
}
207+
}
166208
}

0 commit comments

Comments
 (0)