inital upload
This commit is contained in:
21
node_modules/@tailwindcss/oxide/LICENSE
generated
vendored
Normal file
21
node_modules/@tailwindcss/oxide/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Tailwind Labs, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
48
node_modules/@tailwindcss/oxide/index.d.ts
generated
vendored
Normal file
48
node_modules/@tailwindcss/oxide/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
/* auto-generated by NAPI-RS */
|
||||
/* eslint-disable */
|
||||
export declare class Scanner {
|
||||
constructor(opts: ScannerOptions)
|
||||
scan(): Array<string>
|
||||
scanFiles(input: Array<ChangedContent>): Array<string>
|
||||
getCandidatesWithPositions(input: ChangedContent): Array<CandidateWithPosition>
|
||||
get files(): Array<string>
|
||||
get globs(): Array<GlobEntry>
|
||||
get normalizedSources(): Array<GlobEntry>
|
||||
}
|
||||
|
||||
export interface CandidateWithPosition {
|
||||
/** The candidate string */
|
||||
candidate: string
|
||||
/** The position of the candidate inside the content file */
|
||||
position: number
|
||||
}
|
||||
|
||||
export interface ChangedContent {
|
||||
/** File path to the changed file */
|
||||
file?: string
|
||||
/** Contents of the changed file */
|
||||
content?: string
|
||||
/** File extension */
|
||||
extension: string
|
||||
}
|
||||
|
||||
export interface GlobEntry {
|
||||
/** Base path of the glob */
|
||||
base: string
|
||||
/** Glob pattern */
|
||||
pattern: string
|
||||
}
|
||||
|
||||
export interface ScannerOptions {
|
||||
/** Glob sources */
|
||||
sources?: Array<SourceEntry>
|
||||
}
|
||||
|
||||
export interface SourceEntry {
|
||||
/** Base path of the glob */
|
||||
base: string
|
||||
/** Glob pattern */
|
||||
pattern: string
|
||||
/** Negated flag */
|
||||
negated: boolean
|
||||
}
|
||||
377
node_modules/@tailwindcss/oxide/index.js
generated
vendored
Normal file
377
node_modules/@tailwindcss/oxide/index.js
generated
vendored
Normal file
@@ -0,0 +1,377 @@
|
||||
// prettier-ignore
|
||||
/* eslint-disable */
|
||||
// @ts-nocheck
|
||||
/* auto-generated by NAPI-RS */
|
||||
|
||||
const { createRequire } = require('node:module')
|
||||
require = createRequire(__filename)
|
||||
|
||||
const { readFileSync } = require('node:fs')
|
||||
let nativeBinding = null
|
||||
const loadErrors = []
|
||||
|
||||
const isMusl = () => {
|
||||
let musl = false
|
||||
if (process.platform === 'linux') {
|
||||
musl = isMuslFromFilesystem()
|
||||
if (musl === null) {
|
||||
musl = isMuslFromReport()
|
||||
}
|
||||
if (musl === null) {
|
||||
musl = isMuslFromChildProcess()
|
||||
}
|
||||
}
|
||||
return musl
|
||||
}
|
||||
|
||||
const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
|
||||
|
||||
const isMuslFromFilesystem = () => {
|
||||
try {
|
||||
return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
const isMuslFromReport = () => {
|
||||
let report = null
|
||||
if (typeof process.report?.getReport === 'function') {
|
||||
process.report.excludeNetwork = true
|
||||
report = process.report.getReport()
|
||||
}
|
||||
if (!report) {
|
||||
return null
|
||||
}
|
||||
if (report.header && report.header.glibcVersionRuntime) {
|
||||
return false
|
||||
}
|
||||
if (Array.isArray(report.sharedObjects)) {
|
||||
if (report.sharedObjects.some(isFileMusl)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const isMuslFromChildProcess = () => {
|
||||
try {
|
||||
return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
|
||||
} catch (e) {
|
||||
// If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function requireNative() {
|
||||
if (process.env.NAPI_RS_NATIVE_LIBRARY_PATH) {
|
||||
try {
|
||||
nativeBinding = require(process.env.NAPI_RS_NATIVE_LIBRARY_PATH);
|
||||
} catch (err) {
|
||||
loadErrors.push(err);
|
||||
}
|
||||
} else if (process.platform === 'android') {
|
||||
if (process.arch === 'arm64') {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.android-arm64.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-android-arm64')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else if (process.arch === 'arm') {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.android-arm-eabi.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-android-arm-eabi')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else {
|
||||
loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
|
||||
}
|
||||
} else if (process.platform === 'win32') {
|
||||
if (process.arch === 'x64') {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.win32-x64-msvc.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-win32-x64-msvc')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else if (process.arch === 'ia32') {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.win32-ia32-msvc.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-win32-ia32-msvc')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else if (process.arch === 'arm64') {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.win32-arm64-msvc.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-win32-arm64-msvc')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else {
|
||||
loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
|
||||
}
|
||||
} else if (process.platform === 'darwin') {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.darwin-universal.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-darwin-universal')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
if (process.arch === 'x64') {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.darwin-x64.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-darwin-x64')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else if (process.arch === 'arm64') {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.darwin-arm64.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-darwin-arm64')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else {
|
||||
loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
|
||||
}
|
||||
} else if (process.platform === 'freebsd') {
|
||||
if (process.arch === 'x64') {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.freebsd-x64.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-freebsd-x64')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else if (process.arch === 'arm64') {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.freebsd-arm64.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-freebsd-arm64')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else {
|
||||
loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
|
||||
}
|
||||
} else if (process.platform === 'linux') {
|
||||
if (process.arch === 'x64') {
|
||||
if (isMusl()) {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.linux-x64-musl.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-linux-x64-musl')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.linux-x64-gnu.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-linux-x64-gnu')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
}
|
||||
} else if (process.arch === 'arm64') {
|
||||
if (isMusl()) {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.linux-arm64-musl.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-linux-arm64-musl')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.linux-arm64-gnu.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-linux-arm64-gnu')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
}
|
||||
} else if (process.arch === 'arm') {
|
||||
if (isMusl()) {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.linux-arm-musleabihf.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-linux-arm-musleabihf')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.linux-arm-gnueabihf.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-linux-arm-gnueabihf')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
}
|
||||
} else if (process.arch === 'riscv64') {
|
||||
if (isMusl()) {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.linux-riscv64-musl.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-linux-riscv64-musl')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.linux-riscv64-gnu.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-linux-riscv64-gnu')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
}
|
||||
} else if (process.arch === 'ppc64') {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.linux-ppc64-gnu.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-linux-ppc64-gnu')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else if (process.arch === 's390x') {
|
||||
try {
|
||||
return require('./tailwindcss-oxide.linux-s390x-gnu.node')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
try {
|
||||
return require('@tailwindcss/oxide-linux-s390x-gnu')
|
||||
} catch (e) {
|
||||
loadErrors.push(e)
|
||||
}
|
||||
|
||||
} else {
|
||||
loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
|
||||
}
|
||||
} else {
|
||||
loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
|
||||
}
|
||||
}
|
||||
|
||||
nativeBinding = requireNative()
|
||||
|
||||
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
||||
try {
|
||||
nativeBinding = require('./tailwindcss-oxide.wasi.cjs')
|
||||
} catch (err) {
|
||||
if (process.env.NAPI_RS_FORCE_WASI) {
|
||||
loadErrors.push(err)
|
||||
}
|
||||
}
|
||||
if (!nativeBinding) {
|
||||
try {
|
||||
nativeBinding = require('@tailwindcss/oxide-wasm32-wasi')
|
||||
} catch (err) {
|
||||
if (process.env.NAPI_RS_FORCE_WASI) {
|
||||
loadErrors.push(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!nativeBinding) {
|
||||
if (loadErrors.length > 0) {
|
||||
// TODO Link to documentation with potential fixes
|
||||
// - The package owner could build/publish bindings for this arch
|
||||
// - The user may need to bundle the correct files
|
||||
// - The user may need to re-install node_modules to get new packages
|
||||
throw new Error('Failed to load native binding', { cause: loadErrors })
|
||||
}
|
||||
throw new Error(`Failed to load native binding`)
|
||||
}
|
||||
|
||||
module.exports.Scanner = nativeBinding.Scanner
|
||||
82
node_modules/@tailwindcss/oxide/package.json
generated
vendored
Normal file
82
node_modules/@tailwindcss/oxide/package.json
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"name": "@tailwindcss/oxide",
|
||||
"version": "4.1.6",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/tailwindlabs/tailwindcss.git",
|
||||
"directory": "crates/node"
|
||||
},
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"napi": {
|
||||
"binaryName": "tailwindcss-oxide",
|
||||
"packageName": "@tailwindcss/oxide",
|
||||
"targets": [
|
||||
"armv7-linux-androideabi",
|
||||
"aarch64-linux-android",
|
||||
"aarch64-apple-darwin",
|
||||
"aarch64-unknown-linux-gnu",
|
||||
"aarch64-unknown-linux-musl",
|
||||
"armv7-unknown-linux-gnueabihf",
|
||||
"x86_64-unknown-linux-musl",
|
||||
"x86_64-unknown-freebsd",
|
||||
"i686-pc-windows-msvc",
|
||||
"aarch64-pc-windows-msvc",
|
||||
"wasm32-wasip1-threads"
|
||||
],
|
||||
"wasm": {
|
||||
"initialMemory": 16384,
|
||||
"browser": {
|
||||
"fs": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tar": "^7.4.3",
|
||||
"detect-libc": "^2.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@napi-rs/cli": "^3.0.0-alpha.78",
|
||||
"@napi-rs/wasm-runtime": "^0.2.9",
|
||||
"emnapi": "1.4.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"scripts/install.js"
|
||||
],
|
||||
"publishConfig": {
|
||||
"provenance": true,
|
||||
"access": "public"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@tailwindcss/oxide-android-arm64": "4.1.6",
|
||||
"@tailwindcss/oxide-linux-arm-gnueabihf": "4.1.6",
|
||||
"@tailwindcss/oxide-darwin-x64": "4.1.6",
|
||||
"@tailwindcss/oxide-linux-arm64-gnu": "4.1.6",
|
||||
"@tailwindcss/oxide-linux-arm64-musl": "4.1.6",
|
||||
"@tailwindcss/oxide-darwin-arm64": "4.1.6",
|
||||
"@tailwindcss/oxide-linux-x64-gnu": "4.1.6",
|
||||
"@tailwindcss/oxide-linux-x64-musl": "4.1.6",
|
||||
"@tailwindcss/oxide-win32-arm64-msvc": "4.1.6",
|
||||
"@tailwindcss/oxide-wasm32-wasi": "4.1.6",
|
||||
"@tailwindcss/oxide-win32-x64-msvc": "4.1.6",
|
||||
"@tailwindcss/oxide-freebsd-x64": "4.1.6"
|
||||
},
|
||||
"scripts": {
|
||||
"artifacts": "napi artifacts",
|
||||
"build": "pnpm run build:platform && pnpm run build:wasm",
|
||||
"build:platform": "napi build --platform --release --no-const-enum",
|
||||
"postbuild:platform": "node ./scripts/move-artifacts.mjs",
|
||||
"build:wasm": "napi build --release --target wasm32-wasip1-threads --no-const-enum",
|
||||
"postbuild:wasm": "node ./scripts/move-artifacts.mjs",
|
||||
"dev": "cargo watch --quiet --shell 'npm run build'",
|
||||
"build:debug": "napi build --platform --no-const-enum",
|
||||
"version": "napi version",
|
||||
"postinstall": "node ./scripts/install.js"
|
||||
}
|
||||
}
|
||||
143
node_modules/@tailwindcss/oxide/scripts/install.js
generated
vendored
Normal file
143
node_modules/@tailwindcss/oxide/scripts/install.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* @tailwindcss/oxide postinstall script
|
||||
*
|
||||
* This script ensures that the correct binary for the current platform and
|
||||
* architecture is downloaded and available.
|
||||
*/
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const https = require('https')
|
||||
const { extract } = require('tar')
|
||||
const packageJson = require('../package.json')
|
||||
const detectLibc = require('detect-libc')
|
||||
|
||||
const version = packageJson.version
|
||||
|
||||
function getPlatformPackageName() {
|
||||
let platform = process.platform
|
||||
let arch = process.arch
|
||||
|
||||
let libc = ''
|
||||
if (platform === 'linux') {
|
||||
libc = detectLibc.isNonGlibcLinuxSync() ? 'musl' : 'gnu'
|
||||
}
|
||||
|
||||
// Map to our package naming conventions
|
||||
switch (platform) {
|
||||
case 'darwin':
|
||||
return arch === 'arm64' ? '@tailwindcss/oxide-darwin-arm64' : '@tailwindcss/oxide-darwin-x64'
|
||||
case 'win32':
|
||||
if (arch === 'arm64') return '@tailwindcss/oxide-win32-arm64-msvc'
|
||||
if (arch === 'ia32') return '@tailwindcss/oxide-win32-ia32-msvc'
|
||||
return '@tailwindcss/oxide-win32-x64-msvc'
|
||||
case 'linux':
|
||||
if (arch === 'x64') {
|
||||
return libc === 'musl'
|
||||
? '@tailwindcss/oxide-linux-x64-musl'
|
||||
: '@tailwindcss/oxide-linux-x64-gnu'
|
||||
} else if (arch === 'arm64') {
|
||||
return libc === 'musl'
|
||||
? '@tailwindcss/oxide-linux-arm64-musl'
|
||||
: '@tailwindcss/oxide-linux-arm64-gnu'
|
||||
} else if (arch === 'arm') {
|
||||
return '@tailwindcss/oxide-linux-arm-gnueabihf'
|
||||
}
|
||||
break
|
||||
case 'freebsd':
|
||||
return '@tailwindcss/oxide-freebsd-x64'
|
||||
case 'android':
|
||||
return '@tailwindcss/oxide-android-arm64'
|
||||
default:
|
||||
return '@tailwindcss/oxide-wasm32-wasi'
|
||||
}
|
||||
}
|
||||
|
||||
function isPackageAvailable(packageName) {
|
||||
try {
|
||||
require.resolve(packageName)
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// Extract all files from a tarball to a destination directory
|
||||
async function extractTarball(tarballStream, destDir) {
|
||||
if (!fs.existsSync(destDir)) {
|
||||
fs.mkdirSync(destDir, { recursive: true })
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
tarballStream
|
||||
.pipe(extract({ cwd: destDir, strip: 1 }))
|
||||
.on('error', (err) => reject(err))
|
||||
.on('end', () => resolve())
|
||||
})
|
||||
}
|
||||
|
||||
async function downloadAndExtractBinary(packageName) {
|
||||
let tarballUrl = `https://registry.npmjs.org/${packageName}/-/${packageName.replace('@tailwindcss/', '')}-${version}.tgz`
|
||||
console.log(`Downloading ${tarballUrl}...`)
|
||||
|
||||
return new Promise((resolve) => {
|
||||
https
|
||||
.get(tarballUrl, (response) => {
|
||||
if (response.statusCode === 302 || response.statusCode === 301) {
|
||||
// Handle redirects
|
||||
https.get(response.headers.location, handleResponse).on('error', (err) => {
|
||||
console.error('Download error:', err)
|
||||
resolve()
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
handleResponse(response)
|
||||
|
||||
async function handleResponse(response) {
|
||||
try {
|
||||
if (response.statusCode !== 200) {
|
||||
throw new Error(`Download failed with status code: ${response.statusCode}`)
|
||||
}
|
||||
|
||||
await extractTarball(
|
||||
response,
|
||||
path.join(__dirname, '..', 'node_modules', ...packageName.split('/')),
|
||||
)
|
||||
console.log(`Successfully downloaded and installed ${packageName}`)
|
||||
} catch (error) {
|
||||
console.error('Error during extraction:', error)
|
||||
resolve()
|
||||
} finally {
|
||||
resolve()
|
||||
}
|
||||
}
|
||||
})
|
||||
.on('error', (err) => {
|
||||
console.error('Download error:', err)
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function main() {
|
||||
// Don't run this script in the package source
|
||||
try {
|
||||
if (fs.existsSync(path.join(__dirname, '..', 'build.rs'))) {
|
||||
return
|
||||
}
|
||||
|
||||
let packageName = getPlatformPackageName()
|
||||
if (!packageName) return
|
||||
if (isPackageAvailable(packageName)) return
|
||||
|
||||
await downloadAndExtractBinary(packageName)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user