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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
// Manual additions to make the generated types below work.

import type { TurbopackResult } from './types'

export type TurboTasks = { readonly __tag: unique symbol }
export type ExternalEndpoint = { readonly __tag: unique symbol }
export type NextTurboTasks = { readonly __tag: unique symbol }
export type RefCell = { readonly __tag: unique symbol }
export type NapiRouteHas = {
  type: string
  key?: string
  value?: string
  readonly __tag: unique symbol
}
export type RcStr = string

export function lightningCssTransform(args: object): Promise<unknown>
export function lightningCssTransformStyleAttribute(
  args: object
): Promise<unknown>

// GENERATED-TYPES-BELOW
// DO NOT MANUALLY EDIT THESE TYPES
// You can regenerate this file by running `pnpm swc-build-native` in the root of the repo.

/* tslint:disable */
/* eslint-disable */

/* auto-generated by NAPI-RS */

export declare class ExternalObject<T> {
  readonly '': {
    readonly '': unique symbol
    [K: symbol]: T
  }
}
export interface TransformOutput {
  code: string
  map?: string
  output?: string
  diagnostics: Array<string>
}
export declare function mdxCompile(
  value: string,
  option: Buffer,
  signal?: AbortSignal | undefined | null
): Promise<unknown>
export declare function mdxCompileSync(value: string, option: Buffer): string
export declare function minify(
  input: Buffer,
  opts: Buffer,
  signal?: AbortSignal | undefined | null
): Promise<TransformOutput>
export declare function minifySync(input: Buffer, opts: Buffer): TransformOutput
export interface NapiEndpointConfig {}
export interface NapiServerPath {
  path: string
  contentHash: string
}
export interface NapiWrittenEndpoint {
  type: string
  entryPath?: string
  clientPaths: Array<string>
  serverPaths: Array<NapiServerPath>
  config: NapiEndpointConfig
}
export interface NapiModuleGraphSnapshots {
  moduleGraphs: Array<NapiModuleGraphSnapshot>
}
export declare function endpointWriteToDisk(endpoint: {
  __napiType: 'Endpoint'
}): Promise<TurbopackResult>
export declare function endpointModuleGraphs(endpoint: {
  __napiType: 'Endpoint'
}): Promise<TurbopackResult>
export declare function endpointServerChangedSubscribe(
  endpoint: { __napiType: 'Endpoint' },
  issues: boolean,
  func: (...args: any[]) => any
): { __napiType: 'RootTask' }
export declare function endpointClientChangedSubscribe(
  endpoint: { __napiType: 'Endpoint' },
  func: (...args: any[]) => any
): { __napiType: 'RootTask' }
export interface NapiModuleReference {
  /** The index of the referenced/referencing module in the modules list. */
  index: number
  /** The export used in the module reference. */
  export: string
  /** The type of chunking for the module reference. */
  chunkingType: string
}
export interface NapiModuleInfo {
  ident: RcStr
  path: RcStr
  depth: number
  size: number
  retainedSize: number
  references: Array<NapiModuleReference>
  incomingReferences: Array<NapiModuleReference>
}
export interface NapiModuleGraphSnapshot {
  modules: Array<NapiModuleInfo>
  entries: Array<number>
}
export interface NapiEnvVar {
  name: RcStr
  value: RcStr
}
export interface NapiOptionEnvVar {
  name: RcStr
  value?: RcStr
}
export interface NapiDraftModeOptions {
  previewModeId: RcStr
  previewModeEncryptionKey: RcStr
  previewModeSigningKey: RcStr
}
export interface NapiWatchOptions {
  /** Whether to watch the filesystem for file changes. */
  enable: boolean
  /**
   * Enable polling at a certain interval if the native file watching doesn't work (e.g.
   * docker).
   */
  pollIntervalMs?: number
}
export interface NapiProjectOptions {
  /**
   * An absolute root path (Unix or Windows path) from which all files must be nested under.
   * Trying to access a file outside this root will fail, so think of this as a chroot.
   * E.g. `/home/user/projects/my-repo`.
   */
  rootPath: RcStr
  /**
   * A path which contains the app/pages directories, relative to [`Project::root_path`], always
   * Unix path. E.g. `apps/my-app`
   */
  projectPath: RcStr
  /**
   * A path where to emit the build outputs, relative to [`Project::project_path`], always Unix
   * path. Corresponds to next.config.js's `distDir`.
   * E.g. `.next`
   */
  distDir: RcStr
  /** Filesystem watcher options. */
  watch: NapiWatchOptions
  /** The contents of next.config.js, serialized to JSON. */
  nextConfig: RcStr
  /** The contents of ts/config read by load-jsconfig, serialized to JSON. */
  jsConfig: RcStr
  /** A map of environment variables to use when compiling code. */
  env: Array<NapiEnvVar>
  /**
   * A map of environment variables which should get injected at compile
   * time.
   */
  defineEnv: NapiDefineEnv
  /** The mode in which Next.js is running. */
  dev: boolean
  /** The server actions encryption key. */
  encryptionKey: RcStr
  /** The build id. */
  buildId: RcStr
  /** Options for draft mode. */
  previewProps: NapiDraftModeOptions
  /** The browserslist query to use for targeting browsers. */
  browserslistQuery: RcStr
  /**
   * When the code is minified, this opts out of the default mangling of
   * local names for variables, functions etc., which can be useful for
   * debugging/profiling purposes.
   */
  noMangling: boolean
  /** The version of Node.js that is available/currently running. */
  currentNodeJsVersion: RcStr
}
/** [NapiProjectOptions] with all fields optional. */
export interface NapiPartialProjectOptions {
  /**
   * An absolute root path  (Unix or Windows path) from which all files must be nested under.
   * Trying to access a file outside this root will fail, so think of this as a chroot.
   * E.g. `/home/user/projects/my-repo`.
   */
  rootPath?: RcStr
  /**
   * A path which contains the app/pages directories, relative to [`Project::root_path`], always
   * a Unix path.
   * E.g. `apps/my-app`
   */
  projectPath?: RcStr
  /**
   * A path where to emit the build outputs, relative to [`Project::project_path`], always a
   * Unix path. Corresponds to next.config.js's `distDir`.
   * E.g. `.next`
   */
  distDir?: RcStr | undefined | null
  /** Filesystem watcher options. */
  watch?: NapiWatchOptions
  /** The contents of next.config.js, serialized to JSON. */
  nextConfig?: RcStr
  /** The contents of ts/config read by load-jsconfig, serialized to JSON. */
  jsConfig?: RcStr
  /** A map of environment variables to use when compiling code. */
  env?: Array<NapiEnvVar>
  /**
   * A map of environment variables which should get injected at compile
   * time.
   */
  defineEnv?: NapiDefineEnv
  /** The mode in which Next.js is running. */
  dev?: boolean
  /** The server actions encryption key. */
  encryptionKey?: RcStr
  /** The build id. */
  buildId?: RcStr
  /** Options for draft mode. */
  previewProps?: NapiDraftModeOptions
  /** The browserslist query to use for targeting browsers. */
  browserslistQuery?: RcStr
  /**
   * When the code is minified, this opts out of the default mangling of
   * local names for variables, functions etc., which can be useful for
   * debugging/profiling purposes.
   */
  noMangling?: boolean
}
export interface NapiDefineEnv {
  client: Array<NapiOptionEnvVar>
  edge: Array<NapiOptionEnvVar>
  nodejs: Array<NapiOptionEnvVar>
}
export interface NapiTurboEngineOptions {
  /** Use the new backend with persistent caching enabled. */
  persistentCaching?: boolean
  /** An upper bound of memory that turbopack will attempt to stay under. */
  memoryLimit?: number
  /** Track dependencies between tasks. If false, any change during build will error. */
  dependencyTracking?: boolean
  /** Whether the project is running in a CI environment. */
  isCi?: boolean
}
export declare function projectNew(
  options: NapiProjectOptions,
  turboEngineOptions: NapiTurboEngineOptions,
  napiCallbacks: NapiNextTurbopackCallbacksJsObject
): Promise<{ __napiType: 'Project' }>
export declare function projectUpdate(
  project: { __napiType: 'Project' },
  options: NapiPartialProjectOptions
): Promise<void>
/**
 * Invalidates the persistent cache so that it will be deleted next time that a turbopack project
 * is created with persistent caching enabled.
 */
export declare function projectInvalidatePersistentCache(project: {
  __napiType: 'Project'
}): Promise<void>
/**
 * Runs exit handlers for the project registered using the [`ExitHandler`] API.
 *
 * This is called by `project_shutdown`, so if you're calling that API, you shouldn't call this
 * one.
 */
export declare function projectOnExit(project: {
  __napiType: 'Project'
}): Promise<void>
/**
 * Runs `project_on_exit`, and then waits for turbo_tasks to gracefully shut down.
 *
 * This is used in builds where it's important that we completely persist turbo-tasks to disk, but
 * it's skipped in the development server (`project_on_exit` is used instead with a short timeout),
 * where we prioritize fast exit and user responsiveness over all else.
 */
export declare function projectShutdown(project: {
  __napiType: 'Project'
}): Promise<void>
export interface AppPageNapiRoute {
  /** The relative path from project_path to the route file */
  originalName?: RcStr
  htmlEndpoint?: ExternalObject<ExternalEndpoint>
  rscEndpoint?: ExternalObject<ExternalEndpoint>
}
export interface NapiRoute {
  /** The router path */
  pathname: string
  /** The relative path from project_path to the route file */
  originalName?: RcStr
  /** The type of route, eg a Page or App */
  type: string
  pages?: Array<AppPageNapiRoute>
  endpoint?: ExternalObject<ExternalEndpoint>
  htmlEndpoint?: ExternalObject<ExternalEndpoint>
  rscEndpoint?: ExternalObject<ExternalEndpoint>
  dataEndpoint?: ExternalObject<ExternalEndpoint>
}
export interface NapiMiddleware {
  endpoint: ExternalObject<ExternalEndpoint>
}
export interface NapiInstrumentation {
  nodeJs: ExternalObject<ExternalEndpoint>
  edge: ExternalObject<ExternalEndpoint>
}
export interface NapiEntrypoints {
  routes: Array<NapiRoute>
  middleware?: NapiMiddleware
  instrumentation?: NapiInstrumentation
  pagesDocumentEndpoint: ExternalObject<ExternalEndpoint>
  pagesAppEndpoint: ExternalObject<ExternalEndpoint>
  pagesErrorEndpoint: ExternalObject<ExternalEndpoint>
}
export declare function projectWriteAllEntrypointsToDisk(
  project: { __napiType: 'Project' },
  appDirOnly: boolean
): Promise<TurbopackResult>
export declare function projectEntrypoints(project: {
  __napiType: 'Project'
}): Promise<TurbopackResult>
export declare function projectEntrypointsSubscribe(
  project: { __napiType: 'Project' },
  func: (...args: any[]) => any
): { __napiType: 'RootTask' }
export declare function projectHmrEvents(
  project: { __napiType: 'Project' },
  identifier: RcStr,
  func: (...args: any[]) => any
): { __napiType: 'RootTask' }
export interface HmrIdentifiers {
  identifiers: Array<RcStr>
}
export declare function projectHmrIdentifiersSubscribe(
  project: { __napiType: 'Project' },
  func: (...args: any[]) => any
): { __napiType: 'RootTask' }
export interface NapiUpdateMessage {
  updateType: string
  value?: NapiUpdateInfo
}
export interface NapiUpdateInfo {
  duration: number
  tasks: number
}
/**
 * Subscribes to lifecycle events of the compilation.
 *
 * Emits an [UpdateMessage::Start] event when any computation starts.
 * Emits an [UpdateMessage::End] event when there was no computation for the
 * specified time (`aggregation_ms`). The [UpdateMessage::End] event contains
 * information about the computations that happened since the
 * [UpdateMessage::Start] event. It contains the duration of the computation
 * (excluding the idle time that was spend waiting for `aggregation_ms`), and
 * the number of tasks that were executed.
 *
 * The signature of the `func` is `(update_message: UpdateMessage) => void`.
 */
export declare function projectUpdateInfoSubscribe(
  project: { __napiType: 'Project' },
  aggregationMs: number,
  func: (...args: any[]) => any
): void
/** Subscribes to all compilation events that are not cached like timing and progress information. */
export declare function projectCompilationEventsSubscribe(
  project: { __napiType: 'Project' },
  func: (...args: any[]) => any,
  eventTypes?: Array<string> | undefined | null
): void
export interface StackFrame {
  isServer: boolean
  isInternal?: boolean
  originalFile?: RcStr
  file: RcStr
  /** 1-indexed, unlike source map tokens */
  line?: number
  /** 1-indexed, unlike source map tokens */
  column?: number
  methodName?: RcStr
}
export declare function projectTraceSource(
  project: { __napiType: 'Project' },
  frame: StackFrame,
  currentDirectoryFileUrl: string
): Promise<StackFrame | null>
export declare function projectGetSourceForAsset(
  project: { __napiType: 'Project' },
  filePath: RcStr
): Promise<string | null>
export declare function projectGetSourceMap(
  project: { __napiType: 'Project' },
  filePath: RcStr
): Promise<string | null>
export declare function projectGetSourceMapSync(
  project: { __napiType: 'Project' },
  filePath: RcStr
): string | null
export declare function projectModuleGraph(project: {
  __napiType: 'Project'
}): Promise<TurbopackResult>
/**
 * A version of [`NapiNextTurbopackCallbacks`] that can accepted as an argument to a napi function.
 *
 * This can be converted into a [`NapiNextTurbopackCallbacks`] with
 * [`NapiNextTurbopackCallbacks::from_js`].
 */
export interface NapiNextTurbopackCallbacksJsObject {
  /**
   * Called when we've encountered a bug in Turbopack and not in the user's code. Constructs and
   * throws a `TurbopackInternalError` type. Logs to anonymized telemetry.
   *
   * As a result of the use of `ErrorStrategy::CalleeHandled`, the first argument is an error if
   * there's a runtime conversion error. This should never happen, but if it does, the function
   * can throw it instead.
   */
  throwTurbopackInternalError: (
    conversionError: Error | null,
    opts: TurbopackInternalErrorOpts
  ) => never
}
/** Arguments for [`NapiNextTurbopackCallbacks::throw_turbopack_internal_error`]. */
export interface TurbopackInternalErrorOpts {
  message: string
  anonymizedLocation?: string
}
export declare function rootTaskDispose(rootTask: {
  __napiType: 'RootTask'
}): void
export interface NapiIssue {
  severity: string
  stage: string
  filePath: string
  title: any
  description?: any
  detail?: any
  source?: NapiIssueSource
  documentationLink: string
  importTraces: any
}
export interface NapiIssueSource {
  source: NapiSource
  range?: NapiIssueSourceRange
}
export interface NapiIssueSourceRange {
  start: NapiSourcePos
  end: NapiSourcePos
}
export interface NapiSource {
  ident: string
  content?: string
}
export interface NapiSourcePos {
  line: number
  column: number
}
export interface NapiDiagnostic {
  category: string
  name: string
  payload: Record<string, string>
}
export declare function parse(
  src: string,
  options: Buffer,
  filename?: string | undefined | null,
  signal?: AbortSignal | undefined | null
): Promise<string>
export declare function isReactCompilerRequired(
  filename: string,
  signal?: AbortSignal | undefined | null
): Promise<boolean>
export declare function getModuleNamedExports(
  resourcePath: string
): Promise<string[]>
export interface NapiSourceDiagnostic {
  severity: string
  message: string
  loc: NapiIssueSourceRange
}
export declare function warnForEdgeRuntime(
  source: string,
  isProduction: boolean
): Promise<NapiSourceDiagnostic[]>
export declare function transform(
  src: string | Buffer | undefined,
  isModule: boolean,
  options: Buffer,
  signal?: AbortSignal | undefined | null
): Promise<unknown>
export declare function transformSync(
  src: string | Buffer | undefined,
  isModule: boolean,
  options: Buffer
): object
export declare function startTurbopackTraceServer(path: string): void
export interface NextBuildContext {
  /** The root directory of the workspace. */
  root?: string
  /** The project's directory. */
  dir?: string
  /**
   * next.config.js's distDir. Current there's some early stage setup
   * requires this Before construct a context to read next.config.js,
   * which we passes separately here.
   */
  distDir?: string
  /** The build ID. */
  buildId?: string
  /** The rewrites, as computed by Next.js. */
  rewrites?: NapiRewrites
  defineEnv: NapiDefineEnv
}
/** Keep in sync with [`next_core::next_config::Rewrites`] */
export interface NapiRewrites {
  fallback: Array<NapiRewrite>
  afterFiles: Array<NapiRewrite>
  beforeFiles: Array<NapiRewrite>
}
/** Keep in sync with [`next_core::next_config::Rewrite`] */
export interface NapiRewrite {
  source: string
  destination: string
  basePath?: boolean
  locale?: boolean
  has?: Array<NapiRouteHas>
  missing?: Array<NapiRouteHas>
}
export declare function getTargetTriple(): string
/**
 * Initialize tracing subscriber to emit traces. This configures subscribers
 * for Trace Event Format <https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview>.
 */
export declare function initCustomTraceSubscriber(
  traceOutFilePath?: string | undefined | null
): ExternalObject<RefCell>
/**
 * Teardown currently running tracing subscriber to flush out remaining traces.
 * This should be called when parent node.js process exits, otherwise generated
 * trace may drop traces in the buffer.
 */
export declare function teardownTraceSubscriber(
  guardExternal: ExternalObject<RefCell>
): void