Home

tailwind-ctp-intellisense @b3c17cf5c9d1d74091a4a5ee0504696bb2ce1c46 - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / packages / tailwindcss-intellisense / src / class-names / environment.js
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import * as path from 'path'
import findUp from 'find-up'
import resolveFrom from 'resolve-from'
import importFrom from 'import-from'

let isPnp
let pnpApi

export function withUserEnvironment(base, root, cb) {
  if (isPnp === true) {
    return withPnpEnvironment(base, cb)
  }

  if (isPnp === false) {
    return withNonPnpEnvironment(base, cb)
  }

  const pnpPath = findUp.sync(
    (dir) => {
      let pnpFile = path.join(dir, '.pnp.js')
      if (findUp.sync.exists(pnpFile)) {
        return pnpFile
      }
      pnpFile = path.join(dir, '.pnp.cjs')
      if (findUp.sync.exists(pnpFile)) {
        return pnpFile
      }
      if (dir === root) {
        return findUp.stop
      }
    },
    { cwd: base }
  )

  if (pnpPath) {
    isPnp = true
    pnpApi = __non_webpack_require__(pnpPath)
    pnpApi.setup()
  } else {
    isPnp = false
  }

  return withUserEnvironment(base, root, cb)
}

function withPnpEnvironment(base, cb) {
  const pnpResolve = (request, from = base) => {
    return pnpApi.resolveRequest(request, from.replace(/\/$/, '') + '/')
  }

  const pnpRequire = (request, from) => {
    return __non_webpack_require__(pnpResolve(request, from))
  }

  const res = cb({ isPnp: true, resolve: pnpResolve, require: pnpRequire })

  // check if it return a thenable
  if (res != null && res.then) {
    return res.then(
      (x) => {
        return x
      },
      (err) => {
        throw err
      }
    )
  }

  return res
}

function withNonPnpEnvironment(base, cb) {
  return cb({
    isPnp: false,
    require(request, from = base) {
      return importFrom(from, request)
    },
    resolve(request, from = base) {
      return resolveFrom(from, request)
    },
  })
}