Skip to content

Commit 5cad143

Browse files
committed
Prep for new Oxide API
1 parent be14790 commit 5cad143

File tree

1 file changed

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

1 file changed

+39
-2
lines changed

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

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,32 @@ 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+
negated: boolean
67+
}
68+
69+
interface ScannerOptions {
70+
sources: Array<GlobEntry>
71+
}
72+
73+
interface ScannerConstructor {
74+
new (options: ScannerOptions): Scanner
75+
}
76+
77+
interface Scanner {
78+
files: Array<string>
79+
globs: Array<GlobEntry>
80+
}
81+
}
82+
6183
interface Oxide {
6284
scanDir?(options: OxideV1.ScanOptions): OxideV1.ScanResult
6385
scanDir?(options: OxideV2.ScanOptions): OxideV2.ScanResult
64-
Scanner?: OxideV3And4.ScannerConstructor
86+
Scanner?: OxideV3And4.ScannerConstructor | OxideV5.ScannerConstructor
6587
}
6688

6789
async function loadOxideAtPath(id: string): Promise<Oxide | null> {
@@ -145,7 +167,7 @@ export async function scan(options: ScanOptions): Promise<ScanResult | null> {
145167
}
146168

147169
// V4
148-
else {
170+
else if (lte(options.oxideVersion, '4.0.9999')) {
149171
let scanner = new (oxide.Scanner as OxideV3And4.ScannerConstructor)({
150172
sources: [
151173
{ base: options.basePath, pattern: '**/*' },
@@ -158,4 +180,19 @@ export async function scan(options: ScanOptions): Promise<ScanResult | null> {
158180
globs: scanner.globs.map((g) => ({ base: g.base, pattern: g.pattern, negated: false })),
159181
}
160182
}
183+
184+
// V5
185+
else {
186+
let scanner = new (oxide.Scanner as OxideV5.ScannerConstructor)({
187+
sources: [
188+
{ base: options.basePath, pattern: '**/*', negated: false },
189+
...options.sources.map((s) => ({ base: s.base, pattern: s.pattern, negated: s.negated })),
190+
],
191+
})
192+
193+
return {
194+
files: scanner.files,
195+
globs: scanner.globs,
196+
}
197+
}
161198
}

0 commit comments

Comments
 (0)