MCPcopy Create free account
hub / github.com/chakra-ui/panda / PandaContext

Class PandaContext

packages/node/src/create-context.ts:13–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11import { OutputEngine } from './output-engine'
12
13export class PandaContext extends Generator {
14 runtime: Runtime
15 project: Project
16 output: OutputEngine
17 diff: DiffEngine
18 explicitDeps: string[] = []
19
20 constructor(conf: LoadConfigResult) {
21 super(conf)
22
23 const config = conf.config
24 this.runtime = nodeRuntime
25
26 config.cwd ||= this.runtime.cwd()
27
28 if (config.logLevel) {
29 logger.level = config.logLevel
30 }
31
32 this.project = new Project({
33 ...conf.tsconfig,
34 getFiles: this.getFiles.bind(this),
35 readFile: this.runtime.fs.readFileSync.bind(this),
36 hooks: conf.hooks,
37 parserOptions: {
38 ...this.parserOptions,
39 join: this.runtime.path.join || this.parserOptions.join,
40 },
41 })
42
43 this.output = new OutputEngine(this)
44 this.diff = new DiffEngine(this)
45 this.explicitDeps = this.getExplicitDependencies()
46 }
47
48 private getExplicitDependencies = () => {
49 const { cwd, dependencies } = this.config
50 if (!dependencies) return []
51 return this.runtime.fs.glob({ include: dependencies, cwd })
52 }
53
54 initMessage = () => {
55 return createBox({
56 content: this.messages.codegenComplete(),
57 title: this.messages.exclamation(),
58 })
59 }
60
61 getFiles = () => {
62 const { include, exclude, cwd } = this.config
63 return this.runtime.fs.glob({ include, exclude, cwd })
64 }
65
66 parseFile = (filePath: string, styleEncoder?: StyleEncoder) => {
67 const file = this.runtime.path.abs(this.config.cwd, filePath)
68 logger.debug('file:extract', file)
69
70 const measure = logger.time.debug(`Parsed ${file}`)

Callers

nothing calls this directly

Calls 12

createBoxFunction · 0.90
uniqFunction · 0.90
forEachMethod · 0.80
filterMethod · 0.80
globMethod · 0.65
absMethod · 0.65
getFilesMethod · 0.65
joinMethod · 0.65
ensureDirSyncMethod · 0.65
watchMethod · 0.65
onMethod · 0.65
isEmptyMethod · 0.45

Tested by

no test coverage detected