@tailwindcss/oxide 0.0.0-insiders.b676da8 → 0.0.0-insiders.b67cbcf

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/index.d.ts +27 -16
  2. package/index.js +501 -256
  3. package/package.json +50 -32
  4. package/scripts/install.js +143 -0
package/index.d.ts CHANGED
@@ -1,7 +1,21 @@
1
- /* tslint:disable */
1
+ /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
+ export declare class Scanner {
4
+ constructor(opts: ScannerOptions)
5
+ scan(): Array<string>
6
+ scanFiles(input: Array<ChangedContent>): Array<string>
7
+ getCandidatesWithPositions(input: ChangedContent): Array<CandidateWithPosition>
8
+ get files(): Array<string>
9
+ get globs(): Array<GlobEntry>
10
+ get normalizedSources(): Array<GlobEntry>
11
+ }
3
12
 
4
- /* auto-generated by NAPI-RS */
13
+ export interface CandidateWithPosition {
14
+ /** The candidate string */
15
+ candidate: string
16
+ /** The position of the candidate inside the content file */
17
+ position: number
18
+ }
5
19
 
6
20
  export interface ChangedContent {
7
21
  /** File path to the changed file */
@@ -11,27 +25,24 @@ export interface ChangedContent {
11
25
  /** File extension */
12
26
  extension: string
13
27
  }
28
+
14
29
  export interface GlobEntry {
15
30
  /** Base path of the glob */
16
31
  base: string
17
32
  /** Glob pattern */
18
33
  pattern: string
19
34
  }
35
+
20
36
  export interface ScannerOptions {
21
37
  /** Glob sources */
22
- sources?: Array<GlobEntry>
38
+ sources?: Array<SourceEntry>
23
39
  }
24
- export interface CandidateWithPosition {
25
- /** The candidate string */
26
- candidate: string
27
- /** The position of the candidate inside the content file */
28
- position: number
29
- }
30
- export declare class Scanner {
31
- constructor(opts: ScannerOptions)
32
- scan(): Array<string>
33
- scanFiles(input: Array<ChangedContent>): Array<string>
34
- getCandidatesWithPositions(input: ChangedContent): Array<CandidateWithPosition>
35
- get files(): Array<string>
36
- get globs(): Array<GlobEntry>
40
+
41
+ export interface SourceEntry {
42
+ /** Base path of the glob */
43
+ base: string
44
+ /** Glob pattern */
45
+ pattern: string
46
+ /** Negated flag */
47
+ negated: boolean
37
48
  }
package/index.js CHANGED
@@ -1,315 +1,560 @@
1
- /* tslint:disable */
1
+ // prettier-ignore
2
2
  /* eslint-disable */
3
- /* prettier-ignore */
4
-
3
+ // @ts-nocheck
5
4
  /* auto-generated by NAPI-RS */
6
5
 
7
- const { existsSync, readFileSync } = require('fs')
8
- const { join } = require('path')
9
-
10
- const { platform, arch } = process
6
+ const { createRequire } = require('node:module')
7
+ require = createRequire(__filename)
11
8
 
9
+ const { readFileSync } = require('node:fs')
12
10
  let nativeBinding = null
13
- let localFileExisted = false
14
- let loadError = null
11
+ const loadErrors = []
15
12
 
16
- function isMusl() {
17
- // For Node 10
18
- if (!process.report || typeof process.report.getReport !== 'function') {
19
- try {
20
- const lddPath = require('child_process').execSync('which ldd').toString().trim()
21
- return readFileSync(lddPath, 'utf8').includes('musl')
22
- } catch (e) {
13
+ const isMusl = () => {
14
+ let musl = false
15
+ if (process.platform === 'linux') {
16
+ musl = isMuslFromFilesystem()
17
+ if (musl === null) {
18
+ musl = isMuslFromReport()
19
+ }
20
+ if (musl === null) {
21
+ musl = isMuslFromChildProcess()
22
+ }
23
+ }
24
+ return musl
25
+ }
26
+
27
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
28
+
29
+ const isMuslFromFilesystem = () => {
30
+ try {
31
+ return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
32
+ } catch {
33
+ return null
34
+ }
35
+ }
36
+
37
+ const isMuslFromReport = () => {
38
+ let report = null
39
+ if (typeof process.report?.getReport === 'function') {
40
+ process.report.excludeNetwork = true
41
+ report = process.report.getReport()
42
+ }
43
+ if (!report) {
44
+ return null
45
+ }
46
+ if (report.header && report.header.glibcVersionRuntime) {
47
+ return false
48
+ }
49
+ if (Array.isArray(report.sharedObjects)) {
50
+ if (report.sharedObjects.some(isFileMusl)) {
23
51
  return true
24
52
  }
25
- } else {
26
- const { glibcVersionRuntime } = process.report.getReport().header
27
- return !glibcVersionRuntime
28
53
  }
54
+ return false
29
55
  }
30
56
 
31
- switch (platform) {
32
- case 'android':
33
- switch (arch) {
34
- case 'arm64':
35
- localFileExisted = existsSync(join(__dirname, 'tailwindcss-oxide.android-arm64.node'))
57
+ const isMuslFromChildProcess = () => {
58
+ try {
59
+ return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
60
+ } catch (e) {
61
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
62
+ return false
63
+ }
64
+ }
65
+
66
+ function requireNative() {
67
+ if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
68
+ try {
69
+ return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
70
+ } catch (err) {
71
+ loadErrors.push(err)
72
+ }
73
+ } else if (process.platform === 'android') {
74
+ if (process.arch === 'arm64') {
75
+ try {
76
+ return require('./tailwindcss-oxide.android-arm64.node')
77
+ } catch (e) {
78
+ loadErrors.push(e)
79
+ }
80
+ try {
81
+ const binding = require('@tailwindcss/oxide-android-arm64')
82
+ const bindingPackageVersion = require('@tailwindcss/oxide-android-arm64/package.json').version
83
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
84
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
85
+ }
86
+ return binding
87
+ } catch (e) {
88
+ loadErrors.push(e)
89
+ }
90
+ } else if (process.arch === 'arm') {
91
+ try {
92
+ return require('./tailwindcss-oxide.android-arm-eabi.node')
93
+ } catch (e) {
94
+ loadErrors.push(e)
95
+ }
96
+ try {
97
+ const binding = require('@tailwindcss/oxide-android-arm-eabi')
98
+ const bindingPackageVersion = require('@tailwindcss/oxide-android-arm-eabi/package.json').version
99
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
100
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
101
+ }
102
+ return binding
103
+ } catch (e) {
104
+ loadErrors.push(e)
105
+ }
106
+ } else {
107
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
108
+ }
109
+ } else if (process.platform === 'win32') {
110
+ if (process.arch === 'x64') {
111
+ try {
112
+ return require('./tailwindcss-oxide.win32-x64-msvc.node')
113
+ } catch (e) {
114
+ loadErrors.push(e)
115
+ }
116
+ try {
117
+ const binding = require('@tailwindcss/oxide-win32-x64-msvc')
118
+ const bindingPackageVersion = require('@tailwindcss/oxide-win32-x64-msvc/package.json').version
119
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
120
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
121
+ }
122
+ return binding
123
+ } catch (e) {
124
+ loadErrors.push(e)
125
+ }
126
+ } else if (process.arch === 'ia32') {
127
+ try {
128
+ return require('./tailwindcss-oxide.win32-ia32-msvc.node')
129
+ } catch (e) {
130
+ loadErrors.push(e)
131
+ }
132
+ try {
133
+ const binding = require('@tailwindcss/oxide-win32-ia32-msvc')
134
+ const bindingPackageVersion = require('@tailwindcss/oxide-win32-ia32-msvc/package.json').version
135
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
136
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
137
+ }
138
+ return binding
139
+ } catch (e) {
140
+ loadErrors.push(e)
141
+ }
142
+ } else if (process.arch === 'arm64') {
143
+ try {
144
+ return require('./tailwindcss-oxide.win32-arm64-msvc.node')
145
+ } catch (e) {
146
+ loadErrors.push(e)
147
+ }
148
+ try {
149
+ const binding = require('@tailwindcss/oxide-win32-arm64-msvc')
150
+ const bindingPackageVersion = require('@tailwindcss/oxide-win32-arm64-msvc/package.json').version
151
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
152
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
153
+ }
154
+ return binding
155
+ } catch (e) {
156
+ loadErrors.push(e)
157
+ }
158
+ } else {
159
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
160
+ }
161
+ } else if (process.platform === 'darwin') {
162
+ try {
163
+ return require('./tailwindcss-oxide.darwin-universal.node')
164
+ } catch (e) {
165
+ loadErrors.push(e)
166
+ }
167
+ try {
168
+ const binding = require('@tailwindcss/oxide-darwin-universal')
169
+ const bindingPackageVersion = require('@tailwindcss/oxide-darwin-universal/package.json').version
170
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
171
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
172
+ }
173
+ return binding
174
+ } catch (e) {
175
+ loadErrors.push(e)
176
+ }
177
+ if (process.arch === 'x64') {
178
+ try {
179
+ return require('./tailwindcss-oxide.darwin-x64.node')
180
+ } catch (e) {
181
+ loadErrors.push(e)
182
+ }
183
+ try {
184
+ const binding = require('@tailwindcss/oxide-darwin-x64')
185
+ const bindingPackageVersion = require('@tailwindcss/oxide-darwin-x64/package.json').version
186
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
187
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
188
+ }
189
+ return binding
190
+ } catch (e) {
191
+ loadErrors.push(e)
192
+ }
193
+ } else if (process.arch === 'arm64') {
194
+ try {
195
+ return require('./tailwindcss-oxide.darwin-arm64.node')
196
+ } catch (e) {
197
+ loadErrors.push(e)
198
+ }
199
+ try {
200
+ const binding = require('@tailwindcss/oxide-darwin-arm64')
201
+ const bindingPackageVersion = require('@tailwindcss/oxide-darwin-arm64/package.json').version
202
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
203
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
204
+ }
205
+ return binding
206
+ } catch (e) {
207
+ loadErrors.push(e)
208
+ }
209
+ } else {
210
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
211
+ }
212
+ } else if (process.platform === 'freebsd') {
213
+ if (process.arch === 'x64') {
214
+ try {
215
+ return require('./tailwindcss-oxide.freebsd-x64.node')
216
+ } catch (e) {
217
+ loadErrors.push(e)
218
+ }
219
+ try {
220
+ const binding = require('@tailwindcss/oxide-freebsd-x64')
221
+ const bindingPackageVersion = require('@tailwindcss/oxide-freebsd-x64/package.json').version
222
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
223
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
224
+ }
225
+ return binding
226
+ } catch (e) {
227
+ loadErrors.push(e)
228
+ }
229
+ } else if (process.arch === 'arm64') {
230
+ try {
231
+ return require('./tailwindcss-oxide.freebsd-arm64.node')
232
+ } catch (e) {
233
+ loadErrors.push(e)
234
+ }
235
+ try {
236
+ const binding = require('@tailwindcss/oxide-freebsd-arm64')
237
+ const bindingPackageVersion = require('@tailwindcss/oxide-freebsd-arm64/package.json').version
238
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
239
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
240
+ }
241
+ return binding
242
+ } catch (e) {
243
+ loadErrors.push(e)
244
+ }
245
+ } else {
246
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
247
+ }
248
+ } else if (process.platform === 'linux') {
249
+ if (process.arch === 'x64') {
250
+ if (isMusl()) {
36
251
  try {
37
- if (localFileExisted) {
38
- nativeBinding = require('./tailwindcss-oxide.android-arm64.node')
39
- } else {
40
- nativeBinding = require('@tailwindcss/oxide-android-arm64')
41
- }
252
+ return require('./tailwindcss-oxide.linux-x64-musl.node')
42
253
  } catch (e) {
43
- loadError = e
254
+ loadErrors.push(e)
44
255
  }
45
- break
46
- case 'arm':
47
- localFileExisted = existsSync(join(__dirname, 'tailwindcss-oxide.android-arm-eabi.node'))
48
256
  try {
49
- if (localFileExisted) {
50
- nativeBinding = require('./tailwindcss-oxide.android-arm-eabi.node')
51
- } else {
52
- nativeBinding = require('@tailwindcss/oxide-android-arm-eabi')
257
+ const binding = require('@tailwindcss/oxide-linux-x64-musl')
258
+ const bindingPackageVersion = require('@tailwindcss/oxide-linux-x64-musl/package.json').version
259
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
260
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
53
261
  }
262
+ return binding
54
263
  } catch (e) {
55
- loadError = e
264
+ loadErrors.push(e)
56
265
  }
57
- break
58
- default:
59
- throw new Error(`Unsupported architecture on Android ${arch}`)
60
- }
61
- break
62
- case 'win32':
63
- switch (arch) {
64
- case 'x64':
65
- localFileExisted = existsSync(
66
- join(__dirname, 'tailwindcss-oxide.win32-x64-msvc.node')
67
- )
266
+ } else {
68
267
  try {
69
- if (localFileExisted) {
70
- nativeBinding = require('./tailwindcss-oxide.win32-x64-msvc.node')
71
- } else {
72
- nativeBinding = require('@tailwindcss/oxide-win32-x64-msvc')
73
- }
268
+ return require('./tailwindcss-oxide.linux-x64-gnu.node')
74
269
  } catch (e) {
75
- loadError = e
270
+ loadErrors.push(e)
76
271
  }
77
- break
78
- case 'ia32':
79
- localFileExisted = existsSync(
80
- join(__dirname, 'tailwindcss-oxide.win32-ia32-msvc.node')
81
- )
82
272
  try {
83
- if (localFileExisted) {
84
- nativeBinding = require('./tailwindcss-oxide.win32-ia32-msvc.node')
85
- } else {
86
- nativeBinding = require('@tailwindcss/oxide-win32-ia32-msvc')
273
+ const binding = require('@tailwindcss/oxide-linux-x64-gnu')
274
+ const bindingPackageVersion = require('@tailwindcss/oxide-linux-x64-gnu/package.json').version
275
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
276
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
87
277
  }
278
+ return binding
88
279
  } catch (e) {
89
- loadError = e
280
+ loadErrors.push(e)
90
281
  }
91
- break
92
- case 'arm64':
93
- localFileExisted = existsSync(
94
- join(__dirname, 'tailwindcss-oxide.win32-arm64-msvc.node')
95
- )
282
+ }
283
+ } else if (process.arch === 'arm64') {
284
+ if (isMusl()) {
96
285
  try {
97
- if (localFileExisted) {
98
- nativeBinding = require('./tailwindcss-oxide.win32-arm64-msvc.node')
99
- } else {
100
- nativeBinding = require('@tailwindcss/oxide-win32-arm64-msvc')
286
+ return require('./tailwindcss-oxide.linux-arm64-musl.node')
287
+ } catch (e) {
288
+ loadErrors.push(e)
289
+ }
290
+ try {
291
+ const binding = require('@tailwindcss/oxide-linux-arm64-musl')
292
+ const bindingPackageVersion = require('@tailwindcss/oxide-linux-arm64-musl/package.json').version
293
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
294
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
101
295
  }
296
+ return binding
102
297
  } catch (e) {
103
- loadError = e
298
+ loadErrors.push(e)
104
299
  }
105
- break
106
- default:
107
- throw new Error(`Unsupported architecture on Windows: ${arch}`)
108
- }
109
- break
110
- case 'darwin':
111
- localFileExisted = existsSync(join(__dirname, 'tailwindcss-oxide.darwin-universal.node'))
112
- try {
113
- if (localFileExisted) {
114
- nativeBinding = require('./tailwindcss-oxide.darwin-universal.node')
115
300
  } else {
116
- nativeBinding = require('@tailwindcss/oxide-darwin-universal')
117
- }
118
- break
119
- } catch {}
120
- switch (arch) {
121
- case 'x64':
122
- localFileExisted = existsSync(join(__dirname, 'tailwindcss-oxide.darwin-x64.node'))
123
301
  try {
124
- if (localFileExisted) {
125
- nativeBinding = require('./tailwindcss-oxide.darwin-x64.node')
126
- } else {
127
- nativeBinding = require('@tailwindcss/oxide-darwin-x64')
128
- }
302
+ return require('./tailwindcss-oxide.linux-arm64-gnu.node')
129
303
  } catch (e) {
130
- loadError = e
304
+ loadErrors.push(e)
131
305
  }
132
- break
133
- case 'arm64':
134
- localFileExisted = existsSync(
135
- join(__dirname, 'tailwindcss-oxide.darwin-arm64.node')
136
- )
137
306
  try {
138
- if (localFileExisted) {
139
- nativeBinding = require('./tailwindcss-oxide.darwin-arm64.node')
140
- } else {
141
- nativeBinding = require('@tailwindcss/oxide-darwin-arm64')
307
+ const binding = require('@tailwindcss/oxide-linux-arm64-gnu')
308
+ const bindingPackageVersion = require('@tailwindcss/oxide-linux-arm64-gnu/package.json').version
309
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
310
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
142
311
  }
312
+ return binding
143
313
  } catch (e) {
144
- loadError = e
314
+ loadErrors.push(e)
145
315
  }
146
- break
147
- default:
148
- throw new Error(`Unsupported architecture on macOS: ${arch}`)
149
- }
150
- break
151
- case 'freebsd':
152
- if (arch !== 'x64') {
153
- throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
154
- }
155
- localFileExisted = existsSync(join(__dirname, 'tailwindcss-oxide.freebsd-x64.node'))
156
- try {
157
- if (localFileExisted) {
158
- nativeBinding = require('./tailwindcss-oxide.freebsd-x64.node')
159
- } else {
160
- nativeBinding = require('@tailwindcss/oxide-freebsd-x64')
161
316
  }
162
- } catch (e) {
163
- loadError = e
164
- }
165
- break
166
- case 'linux':
167
- switch (arch) {
168
- case 'x64':
169
- if (isMusl()) {
170
- localFileExisted = existsSync(
171
- join(__dirname, 'tailwindcss-oxide.linux-x64-musl.node')
172
- )
173
- try {
174
- if (localFileExisted) {
175
- nativeBinding = require('./tailwindcss-oxide.linux-x64-musl.node')
176
- } else {
177
- nativeBinding = require('@tailwindcss/oxide-linux-x64-musl')
178
- }
179
- } catch (e) {
180
- loadError = e
181
- }
182
- } else {
183
- localFileExisted = existsSync(
184
- join(__dirname, 'tailwindcss-oxide.linux-x64-gnu.node')
185
- )
186
- try {
187
- if (localFileExisted) {
188
- nativeBinding = require('./tailwindcss-oxide.linux-x64-gnu.node')
189
- } else {
190
- nativeBinding = require('@tailwindcss/oxide-linux-x64-gnu')
191
- }
192
- } catch (e) {
193
- loadError = e
194
- }
317
+ } else if (process.arch === 'arm') {
318
+ if (isMusl()) {
319
+ try {
320
+ return require('./tailwindcss-oxide.linux-arm-musleabihf.node')
321
+ } catch (e) {
322
+ loadErrors.push(e)
195
323
  }
196
- break
197
- case 'arm64':
198
- if (isMusl()) {
199
- localFileExisted = existsSync(
200
- join(__dirname, 'tailwindcss-oxide.linux-arm64-musl.node')
201
- )
202
- try {
203
- if (localFileExisted) {
204
- nativeBinding = require('./tailwindcss-oxide.linux-arm64-musl.node')
205
- } else {
206
- nativeBinding = require('@tailwindcss/oxide-linux-arm64-musl')
207
- }
208
- } catch (e) {
209
- loadError = e
210
- }
211
- } else {
212
- localFileExisted = existsSync(
213
- join(__dirname, 'tailwindcss-oxide.linux-arm64-gnu.node')
214
- )
215
- try {
216
- if (localFileExisted) {
217
- nativeBinding = require('./tailwindcss-oxide.linux-arm64-gnu.node')
218
- } else {
219
- nativeBinding = require('@tailwindcss/oxide-linux-arm64-gnu')
220
- }
221
- } catch (e) {
222
- loadError = e
324
+ try {
325
+ const binding = require('@tailwindcss/oxide-linux-arm-musleabihf')
326
+ const bindingPackageVersion = require('@tailwindcss/oxide-linux-arm-musleabihf/package.json').version
327
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
328
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
223
329
  }
330
+ return binding
331
+ } catch (e) {
332
+ loadErrors.push(e)
224
333
  }
225
- break
226
- case 'arm':
227
- if (isMusl()) {
228
- localFileExisted = existsSync(
229
- join(__dirname, 'tailwindcss-oxide.linux-arm-musleabihf.node')
230
- )
231
- try {
232
- if (localFileExisted) {
233
- nativeBinding = require('./tailwindcss-oxide.linux-arm-musleabihf.node')
234
- } else {
235
- nativeBinding = require('@tailwindcss/oxide-linux-arm-musleabihf')
236
- }
237
- } catch (e) {
238
- loadError = e
334
+ } else {
335
+ try {
336
+ return require('./tailwindcss-oxide.linux-arm-gnueabihf.node')
337
+ } catch (e) {
338
+ loadErrors.push(e)
339
+ }
340
+ try {
341
+ const binding = require('@tailwindcss/oxide-linux-arm-gnueabihf')
342
+ const bindingPackageVersion = require('@tailwindcss/oxide-linux-arm-gnueabihf/package.json').version
343
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
344
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
345
  }
240
- } else {
241
- localFileExisted = existsSync(
242
- join(__dirname, 'tailwindcss-oxide.linux-arm-gnueabihf.node')
243
- )
244
- try {
245
- if (localFileExisted) {
246
- nativeBinding = require('./tailwindcss-oxide.linux-arm-gnueabihf.node')
247
- } else {
248
- nativeBinding = require('@tailwindcss/oxide-linux-arm-gnueabihf')
249
- }
250
- } catch (e) {
251
- loadError = e
346
+ return binding
347
+ } catch (e) {
348
+ loadErrors.push(e)
349
+ }
350
+ }
351
+ } else if (process.arch === 'loong64') {
352
+ if (isMusl()) {
353
+ try {
354
+ return require('./tailwindcss-oxide.linux-loong64-musl.node')
355
+ } catch (e) {
356
+ loadErrors.push(e)
357
+ }
358
+ try {
359
+ const binding = require('@tailwindcss/oxide-linux-loong64-musl')
360
+ const bindingPackageVersion = require('@tailwindcss/oxide-linux-loong64-musl/package.json').version
361
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
362
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
252
363
  }
364
+ return binding
365
+ } catch (e) {
366
+ loadErrors.push(e)
367
+ }
368
+ } else {
369
+ try {
370
+ return require('./tailwindcss-oxide.linux-loong64-gnu.node')
371
+ } catch (e) {
372
+ loadErrors.push(e)
253
373
  }
254
- break
255
- case 'riscv64':
256
- if (isMusl()) {
257
- localFileExisted = existsSync(
258
- join(__dirname, 'tailwindcss-oxide.linux-riscv64-musl.node')
259
- )
260
- try {
261
- if (localFileExisted) {
262
- nativeBinding = require('./tailwindcss-oxide.linux-riscv64-musl.node')
263
- } else {
264
- nativeBinding = require('@tailwindcss/oxide-linux-riscv64-musl')
265
- }
266
- } catch (e) {
267
- loadError = e
374
+ try {
375
+ const binding = require('@tailwindcss/oxide-linux-loong64-gnu')
376
+ const bindingPackageVersion = require('@tailwindcss/oxide-linux-loong64-gnu/package.json').version
377
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
378
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
268
379
  }
269
- } else {
270
- localFileExisted = existsSync(
271
- join(__dirname, 'tailwindcss-oxide.linux-riscv64-gnu.node')
272
- )
273
- try {
274
- if (localFileExisted) {
275
- nativeBinding = require('./tailwindcss-oxide.linux-riscv64-gnu.node')
276
- } else {
277
- nativeBinding = require('@tailwindcss/oxide-linux-riscv64-gnu')
278
- }
279
- } catch (e) {
280
- loadError = e
380
+ return binding
381
+ } catch (e) {
382
+ loadErrors.push(e)
383
+ }
384
+ }
385
+ } else if (process.arch === 'riscv64') {
386
+ if (isMusl()) {
387
+ try {
388
+ return require('./tailwindcss-oxide.linux-riscv64-musl.node')
389
+ } catch (e) {
390
+ loadErrors.push(e)
391
+ }
392
+ try {
393
+ const binding = require('@tailwindcss/oxide-linux-riscv64-musl')
394
+ const bindingPackageVersion = require('@tailwindcss/oxide-linux-riscv64-musl/package.json').version
395
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
396
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
281
397
  }
398
+ return binding
399
+ } catch (e) {
400
+ loadErrors.push(e)
282
401
  }
283
- break
284
- case 's390x':
285
- localFileExisted = existsSync(
286
- join(__dirname, 'tailwindcss-oxide.linux-s390x-gnu.node')
287
- )
402
+ } else {
288
403
  try {
289
- if (localFileExisted) {
290
- nativeBinding = require('./tailwindcss-oxide.linux-s390x-gnu.node')
291
- } else {
292
- nativeBinding = require('@tailwindcss/oxide-linux-s390x-gnu')
404
+ return require('./tailwindcss-oxide.linux-riscv64-gnu.node')
405
+ } catch (e) {
406
+ loadErrors.push(e)
407
+ }
408
+ try {
409
+ const binding = require('@tailwindcss/oxide-linux-riscv64-gnu')
410
+ const bindingPackageVersion = require('@tailwindcss/oxide-linux-riscv64-gnu/package.json').version
411
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
412
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
293
413
  }
414
+ return binding
294
415
  } catch (e) {
295
- loadError = e
416
+ loadErrors.push(e)
417
+ }
418
+ }
419
+ } else if (process.arch === 'ppc64') {
420
+ try {
421
+ return require('./tailwindcss-oxide.linux-ppc64-gnu.node')
422
+ } catch (e) {
423
+ loadErrors.push(e)
424
+ }
425
+ try {
426
+ const binding = require('@tailwindcss/oxide-linux-ppc64-gnu')
427
+ const bindingPackageVersion = require('@tailwindcss/oxide-linux-ppc64-gnu/package.json').version
428
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
429
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
430
+ }
431
+ return binding
432
+ } catch (e) {
433
+ loadErrors.push(e)
434
+ }
435
+ } else if (process.arch === 's390x') {
436
+ try {
437
+ return require('./tailwindcss-oxide.linux-s390x-gnu.node')
438
+ } catch (e) {
439
+ loadErrors.push(e)
440
+ }
441
+ try {
442
+ const binding = require('@tailwindcss/oxide-linux-s390x-gnu')
443
+ const bindingPackageVersion = require('@tailwindcss/oxide-linux-s390x-gnu/package.json').version
444
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
445
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
446
+ }
447
+ return binding
448
+ } catch (e) {
449
+ loadErrors.push(e)
450
+ }
451
+ } else {
452
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
453
+ }
454
+ } else if (process.platform === 'openharmony') {
455
+ if (process.arch === 'arm64') {
456
+ try {
457
+ return require('./tailwindcss-oxide.openharmony-arm64.node')
458
+ } catch (e) {
459
+ loadErrors.push(e)
460
+ }
461
+ try {
462
+ const binding = require('@tailwindcss/oxide-openharmony-arm64')
463
+ const bindingPackageVersion = require('@tailwindcss/oxide-openharmony-arm64/package.json').version
464
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
465
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
466
+ }
467
+ return binding
468
+ } catch (e) {
469
+ loadErrors.push(e)
470
+ }
471
+ } else if (process.arch === 'x64') {
472
+ try {
473
+ return require('./tailwindcss-oxide.openharmony-x64.node')
474
+ } catch (e) {
475
+ loadErrors.push(e)
476
+ }
477
+ try {
478
+ const binding = require('@tailwindcss/oxide-openharmony-x64')
479
+ const bindingPackageVersion = require('@tailwindcss/oxide-openharmony-x64/package.json').version
480
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
481
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
296
482
  }
297
- break
298
- default:
299
- throw new Error(`Unsupported architecture on Linux: ${arch}`)
483
+ return binding
484
+ } catch (e) {
485
+ loadErrors.push(e)
486
+ }
487
+ } else if (process.arch === 'arm') {
488
+ try {
489
+ return require('./tailwindcss-oxide.openharmony-arm.node')
490
+ } catch (e) {
491
+ loadErrors.push(e)
492
+ }
493
+ try {
494
+ const binding = require('@tailwindcss/oxide-openharmony-arm')
495
+ const bindingPackageVersion = require('@tailwindcss/oxide-openharmony-arm/package.json').version
496
+ if (bindingPackageVersion !== '0.0.0-insiders.b67cbcf' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
497
+ throw new Error(`Native binding package version mismatch, expected 0.0.0-insiders.b67cbcf but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
498
+ }
499
+ return binding
500
+ } catch (e) {
501
+ loadErrors.push(e)
502
+ }
503
+ } else {
504
+ loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
505
+ }
506
+ } else {
507
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
508
+ }
509
+ }
510
+
511
+ nativeBinding = requireNative()
512
+
513
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
514
+ let wasiBinding = null
515
+ let wasiBindingError = null
516
+ try {
517
+ wasiBinding = require('./tailwindcss-oxide.wasi.cjs')
518
+ nativeBinding = wasiBinding
519
+ } catch (err) {
520
+ if (process.env.NAPI_RS_FORCE_WASI) {
521
+ wasiBindingError = err
300
522
  }
301
- break
302
- default:
303
- throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
523
+ }
524
+ if (!nativeBinding) {
525
+ try {
526
+ wasiBinding = require('@tailwindcss/oxide-wasm32-wasi')
527
+ nativeBinding = wasiBinding
528
+ } catch (err) {
529
+ if (process.env.NAPI_RS_FORCE_WASI) {
530
+ wasiBindingError.cause = err
531
+ loadErrors.push(err)
532
+ }
533
+ }
534
+ }
535
+ if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
536
+ const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
537
+ error.cause = wasiBindingError
538
+ throw error
539
+ }
304
540
  }
305
541
 
306
542
  if (!nativeBinding) {
307
- if (loadError) {
308
- throw loadError
543
+ if (loadErrors.length > 0) {
544
+ throw new Error(
545
+ `Cannot find native binding. ` +
546
+ `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
547
+ 'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
548
+ {
549
+ cause: loadErrors.reduce((err, cur) => {
550
+ cur.cause = err
551
+ return cur
552
+ }),
553
+ },
554
+ )
309
555
  }
310
556
  throw new Error(`Failed to load native binding`)
311
557
  }
312
558
 
313
- const { Scanner } = nativeBinding
314
-
315
- module.exports.Scanner = Scanner
559
+ module.exports = nativeBinding
560
+ module.exports.Scanner = nativeBinding.Scanner
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailwindcss/oxide",
3
- "version": "0.0.0-insiders.b676da8",
3
+ "version": "0.0.0-insiders.b67cbcf",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/tailwindlabs/tailwindcss.git",
@@ -9,55 +9,73 @@
9
9
  "main": "index.js",
10
10
  "types": "index.d.ts",
11
11
  "napi": {
12
- "name": "tailwindcss-oxide",
13
- "triples": {
14
- "additional": [
15
- "armv7-linux-androideabi",
16
- "aarch64-linux-android",
17
- "aarch64-apple-darwin",
18
- "aarch64-unknown-linux-gnu",
19
- "aarch64-unknown-linux-musl",
20
- "armv7-unknown-linux-gnueabihf",
21
- "x86_64-unknown-linux-musl",
22
- "x86_64-unknown-freebsd",
23
- "i686-pc-windows-msvc",
24
- "aarch64-pc-windows-msvc"
25
- ]
12
+ "binaryName": "tailwindcss-oxide",
13
+ "packageName": "@tailwindcss/oxide",
14
+ "targets": [
15
+ "armv7-linux-androideabi",
16
+ "aarch64-linux-android",
17
+ "aarch64-apple-darwin",
18
+ "aarch64-unknown-linux-gnu",
19
+ "aarch64-unknown-linux-musl",
20
+ "armv7-unknown-linux-gnueabihf",
21
+ "x86_64-unknown-linux-musl",
22
+ "x86_64-unknown-freebsd",
23
+ "i686-pc-windows-msvc",
24
+ "aarch64-pc-windows-msvc",
25
+ "wasm32-wasip1-threads"
26
+ ],
27
+ "wasm": {
28
+ "initialMemory": 16384,
29
+ "browser": {
30
+ "fs": true
31
+ }
26
32
  }
27
33
  },
28
34
  "license": "MIT",
35
+ "dependencies": {
36
+ "tar": "^7.5.1",
37
+ "detect-libc": "^2.0.4"
38
+ },
29
39
  "devDependencies": {
30
- "@napi-rs/cli": "^2.18.4"
40
+ "@napi-rs/cli": "^3.2.0",
41
+ "@napi-rs/wasm-runtime": "^1.0.5",
42
+ "emnapi": "1.5.0"
31
43
  },
32
44
  "engines": {
33
45
  "node": ">= 10"
34
46
  },
35
47
  "files": [
36
48
  "index.js",
37
- "index.d.ts"
49
+ "index.d.ts",
50
+ "scripts/install.js"
38
51
  ],
39
52
  "publishConfig": {
40
53
  "provenance": true,
41
54
  "access": "public"
42
55
  },
43
56
  "optionalDependencies": {
44
- "@tailwindcss/oxide-android-arm64": "0.0.0-insiders.b676da8",
45
- "@tailwindcss/oxide-freebsd-x64": "0.0.0-insiders.b676da8",
46
- "@tailwindcss/oxide-darwin-arm64": "0.0.0-insiders.b676da8",
47
- "@tailwindcss/oxide-linux-arm64-gnu": "0.0.0-insiders.b676da8",
48
- "@tailwindcss/oxide-darwin-x64": "0.0.0-insiders.b676da8",
49
- "@tailwindcss/oxide-linux-arm64-musl": "0.0.0-insiders.b676da8",
50
- "@tailwindcss/oxide-win32-x64-msvc": "0.0.0-insiders.b676da8",
51
- "@tailwindcss/oxide-linux-arm-gnueabihf": "0.0.0-insiders.b676da8",
52
- "@tailwindcss/oxide-linux-x64-gnu": "0.0.0-insiders.b676da8",
53
- "@tailwindcss/oxide-win32-arm64-msvc": "0.0.0-insiders.b676da8",
54
- "@tailwindcss/oxide-linux-x64-musl": "0.0.0-insiders.b676da8"
57
+ "@tailwindcss/oxide-darwin-arm64": "0.0.0-insiders.b67cbcf",
58
+ "@tailwindcss/oxide-android-arm64": "0.0.0-insiders.b67cbcf",
59
+ "@tailwindcss/oxide-freebsd-x64": "0.0.0-insiders.b67cbcf",
60
+ "@tailwindcss/oxide-darwin-x64": "0.0.0-insiders.b67cbcf",
61
+ "@tailwindcss/oxide-linux-arm64-gnu": "0.0.0-insiders.b67cbcf",
62
+ "@tailwindcss/oxide-linux-arm64-musl": "0.0.0-insiders.b67cbcf",
63
+ "@tailwindcss/oxide-linux-x64-gnu": "0.0.0-insiders.b67cbcf",
64
+ "@tailwindcss/oxide-linux-arm-gnueabihf": "0.0.0-insiders.b67cbcf",
65
+ "@tailwindcss/oxide-wasm32-wasi": "0.0.0-insiders.b67cbcf",
66
+ "@tailwindcss/oxide-linux-x64-musl": "0.0.0-insiders.b67cbcf",
67
+ "@tailwindcss/oxide-win32-arm64-msvc": "0.0.0-insiders.b67cbcf",
68
+ "@tailwindcss/oxide-win32-x64-msvc": "0.0.0-insiders.b67cbcf"
55
69
  },
56
70
  "scripts": {
57
- "artifacts": "napi artifacts",
58
- "build": "napi build --platform --release --no-const-enum",
71
+ "build": "pnpm run build:platform && pnpm run build:wasm",
72
+ "build:platform": "napi build --platform --release",
73
+ "postbuild:platform": "node ./scripts/move-artifacts.mjs",
74
+ "build:wasm": "napi build --release --target wasm32-wasip1-threads",
75
+ "postbuild:wasm": "node ./scripts/move-artifacts.mjs",
59
76
  "dev": "cargo watch --quiet --shell 'npm run build'",
60
- "build:debug": "napi build --platform --no-const-enum",
61
- "version": "napi version"
77
+ "build:debug": "napi build --platform",
78
+ "version": "napi version",
79
+ "postinstall": "node ./scripts/install.js"
62
80
  }
63
81
  }
@@ -0,0 +1,143 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @tailwindcss/oxide postinstall script
5
+ *
6
+ * This script ensures that the correct binary for the current platform and
7
+ * architecture is downloaded and available.
8
+ */
9
+
10
+ const fs = require('fs')
11
+ const path = require('path')
12
+ const https = require('https')
13
+ const { extract } = require('tar')
14
+ const packageJson = require('../package.json')
15
+ const detectLibc = require('detect-libc')
16
+
17
+ const version = packageJson.version
18
+
19
+ function getPlatformPackageName() {
20
+ let platform = process.platform
21
+ let arch = process.arch
22
+
23
+ let libc = ''
24
+ if (platform === 'linux') {
25
+ libc = detectLibc.isNonGlibcLinuxSync() ? 'musl' : 'gnu'
26
+ }
27
+
28
+ // Map to our package naming conventions
29
+ switch (platform) {
30
+ case 'darwin':
31
+ return arch === 'arm64' ? '@tailwindcss/oxide-darwin-arm64' : '@tailwindcss/oxide-darwin-x64'
32
+ case 'win32':
33
+ if (arch === 'arm64') return '@tailwindcss/oxide-win32-arm64-msvc'
34
+ if (arch === 'ia32') return '@tailwindcss/oxide-win32-ia32-msvc'
35
+ return '@tailwindcss/oxide-win32-x64-msvc'
36
+ case 'linux':
37
+ if (arch === 'x64') {
38
+ return libc === 'musl'
39
+ ? '@tailwindcss/oxide-linux-x64-musl'
40
+ : '@tailwindcss/oxide-linux-x64-gnu'
41
+ } else if (arch === 'arm64') {
42
+ return libc === 'musl'
43
+ ? '@tailwindcss/oxide-linux-arm64-musl'
44
+ : '@tailwindcss/oxide-linux-arm64-gnu'
45
+ } else if (arch === 'arm') {
46
+ return '@tailwindcss/oxide-linux-arm-gnueabihf'
47
+ }
48
+ break
49
+ case 'freebsd':
50
+ return '@tailwindcss/oxide-freebsd-x64'
51
+ case 'android':
52
+ return '@tailwindcss/oxide-android-arm64'
53
+ default:
54
+ return '@tailwindcss/oxide-wasm32-wasi'
55
+ }
56
+ }
57
+
58
+ function isPackageAvailable(packageName) {
59
+ try {
60
+ require.resolve(packageName)
61
+ return true
62
+ } catch (e) {
63
+ return false
64
+ }
65
+ }
66
+
67
+ // Extract all files from a tarball to a destination directory
68
+ async function extractTarball(tarballStream, destDir) {
69
+ if (!fs.existsSync(destDir)) {
70
+ fs.mkdirSync(destDir, { recursive: true })
71
+ }
72
+
73
+ return new Promise((resolve, reject) => {
74
+ tarballStream
75
+ .pipe(extract({ cwd: destDir, strip: 1 }))
76
+ .on('error', (err) => reject(err))
77
+ .on('end', () => resolve())
78
+ })
79
+ }
80
+
81
+ async function downloadAndExtractBinary(packageName) {
82
+ let tarballUrl = `https://registry.npmjs.org/${packageName}/-/${packageName.replace('@tailwindcss/', '')}-${version}.tgz`
83
+ console.log(`Downloading ${tarballUrl}...`)
84
+
85
+ return new Promise((resolve) => {
86
+ https
87
+ .get(tarballUrl, (response) => {
88
+ if (response.statusCode === 302 || response.statusCode === 301) {
89
+ // Handle redirects
90
+ https.get(response.headers.location, handleResponse).on('error', (err) => {
91
+ console.error('Download error:', err)
92
+ resolve()
93
+ })
94
+ return
95
+ }
96
+
97
+ handleResponse(response)
98
+
99
+ async function handleResponse(response) {
100
+ try {
101
+ if (response.statusCode !== 200) {
102
+ throw new Error(`Download failed with status code: ${response.statusCode}`)
103
+ }
104
+
105
+ await extractTarball(
106
+ response,
107
+ path.join(__dirname, '..', 'node_modules', ...packageName.split('/')),
108
+ )
109
+ console.log(`Successfully downloaded and installed ${packageName}`)
110
+ } catch (error) {
111
+ console.error('Error during extraction:', error)
112
+ resolve()
113
+ } finally {
114
+ resolve()
115
+ }
116
+ }
117
+ })
118
+ .on('error', (err) => {
119
+ console.error('Download error:', err)
120
+ resolve()
121
+ })
122
+ })
123
+ }
124
+
125
+ async function main() {
126
+ // Don't run this script in the package source
127
+ try {
128
+ if (fs.existsSync(path.join(__dirname, '..', 'build.rs'))) {
129
+ return
130
+ }
131
+
132
+ let packageName = getPlatformPackageName()
133
+ if (!packageName) return
134
+ if (isPackageAvailable(packageName)) return
135
+
136
+ await downloadAndExtractBinary(packageName)
137
+ } catch (error) {
138
+ console.error(error)
139
+ return
140
+ }
141
+ }
142
+
143
+ main()