index.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  1. // prettier-ignore
  2. /* eslint-disable */
  3. // @ts-nocheck
  4. /* auto-generated by NAPI-RS */
  5. const { readFileSync } = require('node:fs')
  6. let nativeBinding = null
  7. const loadErrors = []
  8. const isMusl = () => {
  9. let musl = false
  10. if (process.platform === 'linux') {
  11. musl = isMuslFromFilesystem()
  12. if (musl === null) {
  13. musl = isMuslFromReport()
  14. }
  15. if (musl === null) {
  16. musl = isMuslFromChildProcess()
  17. }
  18. }
  19. return musl
  20. }
  21. const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
  22. const isMuslFromFilesystem = () => {
  23. try {
  24. return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
  25. } catch {
  26. return null
  27. }
  28. }
  29. const isMuslFromReport = () => {
  30. let report = null
  31. if (typeof process.report?.getReport === 'function') {
  32. process.report.excludeNetwork = true
  33. report = process.report.getReport()
  34. }
  35. if (!report) {
  36. return null
  37. }
  38. if (report.header && report.header.glibcVersionRuntime) {
  39. return false
  40. }
  41. if (Array.isArray(report.sharedObjects)) {
  42. if (report.sharedObjects.some(isFileMusl)) {
  43. return true
  44. }
  45. }
  46. return false
  47. }
  48. const isMuslFromChildProcess = () => {
  49. try {
  50. return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
  51. } catch (e) {
  52. // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
  53. return false
  54. }
  55. }
  56. function requireNative() {
  57. if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
  58. try {
  59. return require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
  60. } catch (err) {
  61. loadErrors.push(err)
  62. }
  63. } else if (process.platform === 'android') {
  64. if (process.arch === 'arm64') {
  65. try {
  66. return require('./tailwindcss-oxide.android-arm64.node')
  67. } catch (e) {
  68. loadErrors.push(e)
  69. }
  70. try {
  71. const binding = require('@tailwindcss/oxide-android-arm64')
  72. const bindingPackageVersion = require('@tailwindcss/oxide-android-arm64/package.json').version
  73. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  74. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  75. }
  76. return binding
  77. } catch (e) {
  78. loadErrors.push(e)
  79. }
  80. } else if (process.arch === 'arm') {
  81. try {
  82. return require('./tailwindcss-oxide.android-arm-eabi.node')
  83. } catch (e) {
  84. loadErrors.push(e)
  85. }
  86. try {
  87. const binding = require('@tailwindcss/oxide-android-arm-eabi')
  88. const bindingPackageVersion = require('@tailwindcss/oxide-android-arm-eabi/package.json').version
  89. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  90. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  91. }
  92. return binding
  93. } catch (e) {
  94. loadErrors.push(e)
  95. }
  96. } else {
  97. loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
  98. }
  99. } else if (process.platform === 'win32') {
  100. if (process.arch === 'x64') {
  101. if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
  102. try {
  103. return require('./tailwindcss-oxide.win32-x64-gnu.node')
  104. } catch (e) {
  105. loadErrors.push(e)
  106. }
  107. try {
  108. const binding = require('@tailwindcss/oxide-win32-x64-gnu')
  109. const bindingPackageVersion = require('@tailwindcss/oxide-win32-x64-gnu/package.json').version
  110. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  111. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  112. }
  113. return binding
  114. } catch (e) {
  115. loadErrors.push(e)
  116. }
  117. } else {
  118. try {
  119. return require('./tailwindcss-oxide.win32-x64-msvc.node')
  120. } catch (e) {
  121. loadErrors.push(e)
  122. }
  123. try {
  124. const binding = require('@tailwindcss/oxide-win32-x64-msvc')
  125. const bindingPackageVersion = require('@tailwindcss/oxide-win32-x64-msvc/package.json').version
  126. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  127. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  128. }
  129. return binding
  130. } catch (e) {
  131. loadErrors.push(e)
  132. }
  133. }
  134. } else if (process.arch === 'ia32') {
  135. try {
  136. return require('./tailwindcss-oxide.win32-ia32-msvc.node')
  137. } catch (e) {
  138. loadErrors.push(e)
  139. }
  140. try {
  141. const binding = require('@tailwindcss/oxide-win32-ia32-msvc')
  142. const bindingPackageVersion = require('@tailwindcss/oxide-win32-ia32-msvc/package.json').version
  143. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  144. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  145. }
  146. return binding
  147. } catch (e) {
  148. loadErrors.push(e)
  149. }
  150. } else if (process.arch === 'arm64') {
  151. try {
  152. return require('./tailwindcss-oxide.win32-arm64-msvc.node')
  153. } catch (e) {
  154. loadErrors.push(e)
  155. }
  156. try {
  157. const binding = require('@tailwindcss/oxide-win32-arm64-msvc')
  158. const bindingPackageVersion = require('@tailwindcss/oxide-win32-arm64-msvc/package.json').version
  159. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  160. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  161. }
  162. return binding
  163. } catch (e) {
  164. loadErrors.push(e)
  165. }
  166. } else {
  167. loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
  168. }
  169. } else if (process.platform === 'darwin') {
  170. try {
  171. return require('./tailwindcss-oxide.darwin-universal.node')
  172. } catch (e) {
  173. loadErrors.push(e)
  174. }
  175. try {
  176. const binding = require('@tailwindcss/oxide-darwin-universal')
  177. const bindingPackageVersion = require('@tailwindcss/oxide-darwin-universal/package.json').version
  178. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  179. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  180. }
  181. return binding
  182. } catch (e) {
  183. loadErrors.push(e)
  184. }
  185. if (process.arch === 'x64') {
  186. try {
  187. return require('./tailwindcss-oxide.darwin-x64.node')
  188. } catch (e) {
  189. loadErrors.push(e)
  190. }
  191. try {
  192. const binding = require('@tailwindcss/oxide-darwin-x64')
  193. const bindingPackageVersion = require('@tailwindcss/oxide-darwin-x64/package.json').version
  194. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  195. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  196. }
  197. return binding
  198. } catch (e) {
  199. loadErrors.push(e)
  200. }
  201. } else if (process.arch === 'arm64') {
  202. try {
  203. return require('./tailwindcss-oxide.darwin-arm64.node')
  204. } catch (e) {
  205. loadErrors.push(e)
  206. }
  207. try {
  208. const binding = require('@tailwindcss/oxide-darwin-arm64')
  209. const bindingPackageVersion = require('@tailwindcss/oxide-darwin-arm64/package.json').version
  210. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  211. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  212. }
  213. return binding
  214. } catch (e) {
  215. loadErrors.push(e)
  216. }
  217. } else {
  218. loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
  219. }
  220. } else if (process.platform === 'freebsd') {
  221. if (process.arch === 'x64') {
  222. try {
  223. return require('./tailwindcss-oxide.freebsd-x64.node')
  224. } catch (e) {
  225. loadErrors.push(e)
  226. }
  227. try {
  228. const binding = require('@tailwindcss/oxide-freebsd-x64')
  229. const bindingPackageVersion = require('@tailwindcss/oxide-freebsd-x64/package.json').version
  230. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  231. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  232. }
  233. return binding
  234. } catch (e) {
  235. loadErrors.push(e)
  236. }
  237. } else if (process.arch === 'arm64') {
  238. try {
  239. return require('./tailwindcss-oxide.freebsd-arm64.node')
  240. } catch (e) {
  241. loadErrors.push(e)
  242. }
  243. try {
  244. const binding = require('@tailwindcss/oxide-freebsd-arm64')
  245. const bindingPackageVersion = require('@tailwindcss/oxide-freebsd-arm64/package.json').version
  246. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  247. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  248. }
  249. return binding
  250. } catch (e) {
  251. loadErrors.push(e)
  252. }
  253. } else {
  254. loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
  255. }
  256. } else if (process.platform === 'linux') {
  257. if (process.arch === 'x64') {
  258. if (isMusl()) {
  259. try {
  260. return require('./tailwindcss-oxide.linux-x64-musl.node')
  261. } catch (e) {
  262. loadErrors.push(e)
  263. }
  264. try {
  265. const binding = require('@tailwindcss/oxide-linux-x64-musl')
  266. const bindingPackageVersion = require('@tailwindcss/oxide-linux-x64-musl/package.json').version
  267. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  268. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  269. }
  270. return binding
  271. } catch (e) {
  272. loadErrors.push(e)
  273. }
  274. } else {
  275. try {
  276. return require('./tailwindcss-oxide.linux-x64-gnu.node')
  277. } catch (e) {
  278. loadErrors.push(e)
  279. }
  280. try {
  281. const binding = require('@tailwindcss/oxide-linux-x64-gnu')
  282. const bindingPackageVersion = require('@tailwindcss/oxide-linux-x64-gnu/package.json').version
  283. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  284. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  285. }
  286. return binding
  287. } catch (e) {
  288. loadErrors.push(e)
  289. }
  290. }
  291. } else if (process.arch === 'arm64') {
  292. if (isMusl()) {
  293. try {
  294. return require('./tailwindcss-oxide.linux-arm64-musl.node')
  295. } catch (e) {
  296. loadErrors.push(e)
  297. }
  298. try {
  299. const binding = require('@tailwindcss/oxide-linux-arm64-musl')
  300. const bindingPackageVersion = require('@tailwindcss/oxide-linux-arm64-musl/package.json').version
  301. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  302. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  303. }
  304. return binding
  305. } catch (e) {
  306. loadErrors.push(e)
  307. }
  308. } else {
  309. try {
  310. return require('./tailwindcss-oxide.linux-arm64-gnu.node')
  311. } catch (e) {
  312. loadErrors.push(e)
  313. }
  314. try {
  315. const binding = require('@tailwindcss/oxide-linux-arm64-gnu')
  316. const bindingPackageVersion = require('@tailwindcss/oxide-linux-arm64-gnu/package.json').version
  317. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  318. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  319. }
  320. return binding
  321. } catch (e) {
  322. loadErrors.push(e)
  323. }
  324. }
  325. } else if (process.arch === 'arm') {
  326. if (isMusl()) {
  327. try {
  328. return require('./tailwindcss-oxide.linux-arm-musleabihf.node')
  329. } catch (e) {
  330. loadErrors.push(e)
  331. }
  332. try {
  333. const binding = require('@tailwindcss/oxide-linux-arm-musleabihf')
  334. const bindingPackageVersion = require('@tailwindcss/oxide-linux-arm-musleabihf/package.json').version
  335. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  336. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  337. }
  338. return binding
  339. } catch (e) {
  340. loadErrors.push(e)
  341. }
  342. } else {
  343. try {
  344. return require('./tailwindcss-oxide.linux-arm-gnueabihf.node')
  345. } catch (e) {
  346. loadErrors.push(e)
  347. }
  348. try {
  349. const binding = require('@tailwindcss/oxide-linux-arm-gnueabihf')
  350. const bindingPackageVersion = require('@tailwindcss/oxide-linux-arm-gnueabihf/package.json').version
  351. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  352. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  353. }
  354. return binding
  355. } catch (e) {
  356. loadErrors.push(e)
  357. }
  358. }
  359. } else if (process.arch === 'loong64') {
  360. if (isMusl()) {
  361. try {
  362. return require('./tailwindcss-oxide.linux-loong64-musl.node')
  363. } catch (e) {
  364. loadErrors.push(e)
  365. }
  366. try {
  367. const binding = require('@tailwindcss/oxide-linux-loong64-musl')
  368. const bindingPackageVersion = require('@tailwindcss/oxide-linux-loong64-musl/package.json').version
  369. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  370. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  371. }
  372. return binding
  373. } catch (e) {
  374. loadErrors.push(e)
  375. }
  376. } else {
  377. try {
  378. return require('./tailwindcss-oxide.linux-loong64-gnu.node')
  379. } catch (e) {
  380. loadErrors.push(e)
  381. }
  382. try {
  383. const binding = require('@tailwindcss/oxide-linux-loong64-gnu')
  384. const bindingPackageVersion = require('@tailwindcss/oxide-linux-loong64-gnu/package.json').version
  385. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  386. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  387. }
  388. return binding
  389. } catch (e) {
  390. loadErrors.push(e)
  391. }
  392. }
  393. } else if (process.arch === 'riscv64') {
  394. if (isMusl()) {
  395. try {
  396. return require('./tailwindcss-oxide.linux-riscv64-musl.node')
  397. } catch (e) {
  398. loadErrors.push(e)
  399. }
  400. try {
  401. const binding = require('@tailwindcss/oxide-linux-riscv64-musl')
  402. const bindingPackageVersion = require('@tailwindcss/oxide-linux-riscv64-musl/package.json').version
  403. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  404. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  405. }
  406. return binding
  407. } catch (e) {
  408. loadErrors.push(e)
  409. }
  410. } else {
  411. try {
  412. return require('./tailwindcss-oxide.linux-riscv64-gnu.node')
  413. } catch (e) {
  414. loadErrors.push(e)
  415. }
  416. try {
  417. const binding = require('@tailwindcss/oxide-linux-riscv64-gnu')
  418. const bindingPackageVersion = require('@tailwindcss/oxide-linux-riscv64-gnu/package.json').version
  419. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  420. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  421. }
  422. return binding
  423. } catch (e) {
  424. loadErrors.push(e)
  425. }
  426. }
  427. } else if (process.arch === 'ppc64') {
  428. try {
  429. return require('./tailwindcss-oxide.linux-ppc64-gnu.node')
  430. } catch (e) {
  431. loadErrors.push(e)
  432. }
  433. try {
  434. const binding = require('@tailwindcss/oxide-linux-ppc64-gnu')
  435. const bindingPackageVersion = require('@tailwindcss/oxide-linux-ppc64-gnu/package.json').version
  436. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  437. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  438. }
  439. return binding
  440. } catch (e) {
  441. loadErrors.push(e)
  442. }
  443. } else if (process.arch === 's390x') {
  444. try {
  445. return require('./tailwindcss-oxide.linux-s390x-gnu.node')
  446. } catch (e) {
  447. loadErrors.push(e)
  448. }
  449. try {
  450. const binding = require('@tailwindcss/oxide-linux-s390x-gnu')
  451. const bindingPackageVersion = require('@tailwindcss/oxide-linux-s390x-gnu/package.json').version
  452. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  453. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  454. }
  455. return binding
  456. } catch (e) {
  457. loadErrors.push(e)
  458. }
  459. } else {
  460. loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
  461. }
  462. } else if (process.platform === 'openharmony') {
  463. if (process.arch === 'arm64') {
  464. try {
  465. return require('./tailwindcss-oxide.openharmony-arm64.node')
  466. } catch (e) {
  467. loadErrors.push(e)
  468. }
  469. try {
  470. const binding = require('@tailwindcss/oxide-openharmony-arm64')
  471. const bindingPackageVersion = require('@tailwindcss/oxide-openharmony-arm64/package.json').version
  472. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  473. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  474. }
  475. return binding
  476. } catch (e) {
  477. loadErrors.push(e)
  478. }
  479. } else if (process.arch === 'x64') {
  480. try {
  481. return require('./tailwindcss-oxide.openharmony-x64.node')
  482. } catch (e) {
  483. loadErrors.push(e)
  484. }
  485. try {
  486. const binding = require('@tailwindcss/oxide-openharmony-x64')
  487. const bindingPackageVersion = require('@tailwindcss/oxide-openharmony-x64/package.json').version
  488. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  489. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  490. }
  491. return binding
  492. } catch (e) {
  493. loadErrors.push(e)
  494. }
  495. } else if (process.arch === 'arm') {
  496. try {
  497. return require('./tailwindcss-oxide.openharmony-arm.node')
  498. } catch (e) {
  499. loadErrors.push(e)
  500. }
  501. try {
  502. const binding = require('@tailwindcss/oxide-openharmony-arm')
  503. const bindingPackageVersion = require('@tailwindcss/oxide-openharmony-arm/package.json').version
  504. if (bindingPackageVersion !== '4.2.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
  505. throw new Error(`Native binding package version mismatch, expected 4.2.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
  506. }
  507. return binding
  508. } catch (e) {
  509. loadErrors.push(e)
  510. }
  511. } else {
  512. loadErrors.push(new Error(`Unsupported architecture on OpenHarmony: ${process.arch}`))
  513. }
  514. } else {
  515. loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
  516. }
  517. }
  518. nativeBinding = requireNative()
  519. if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
  520. let wasiBinding = null
  521. let wasiBindingError = null
  522. try {
  523. wasiBinding = require('./tailwindcss-oxide.wasi.cjs')
  524. nativeBinding = wasiBinding
  525. } catch (err) {
  526. if (process.env.NAPI_RS_FORCE_WASI) {
  527. wasiBindingError = err
  528. }
  529. }
  530. if (!nativeBinding) {
  531. try {
  532. wasiBinding = require('@tailwindcss/oxide-wasm32-wasi')
  533. nativeBinding = wasiBinding
  534. } catch (err) {
  535. if (process.env.NAPI_RS_FORCE_WASI) {
  536. wasiBindingError.cause = err
  537. loadErrors.push(err)
  538. }
  539. }
  540. }
  541. if (process.env.NAPI_RS_FORCE_WASI === 'error' && !wasiBinding) {
  542. const error = new Error('WASI binding not found and NAPI_RS_FORCE_WASI is set to error')
  543. error.cause = wasiBindingError
  544. throw error
  545. }
  546. }
  547. if (!nativeBinding) {
  548. if (loadErrors.length > 0) {
  549. throw new Error(
  550. `Cannot find native binding. ` +
  551. `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
  552. 'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
  553. {
  554. cause: loadErrors.reduce((err, cur) => {
  555. cur.cause = err
  556. return cur
  557. }),
  558. },
  559. )
  560. }
  561. throw new Error(`Failed to load native binding`)
  562. }
  563. module.exports = nativeBinding
  564. module.exports.Scanner = nativeBinding.Scanner