@sanity/pkg-utils 7.2.9 → 7.2.10-canary.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
- import type {PluginItem} from '@babel/core'
2
- import type {IExtractorMessagesConfig} from '@microsoft/api-extractor'
3
- import type {OptimizeLodashOptions} from '@optimize-lodash/rollup-plugin'
4
- import type {NormalizedOutputOptions, TreeshakingOptions} from 'rollup'
5
- import {Plugin as RollupPlugin} from 'rollup'
6
- import {z} from 'zod'
1
+ import { PluginItem } from "@babel/core";
2
+ import { OptimizeLodashOptions } from "@optimize-lodash/rollup-plugin";
3
+ import { NormalizedOutputOptions, Plugin, Plugin as RollupPlugin, TreeshakingOptions } from "rollup";
4
+ import { z } from "zod";
5
+ import { IExtractorMessagesConfig } from "@microsoft/api-extractor";
6
+
7
+ //#region src/node/build.d.ts
7
8
 
8
9
  /**
9
10
  * Build the distribution files of a npm package.
@@ -24,216 +25,277 @@ import {z} from 'zod'
24
25
  *
25
26
  * @public
26
27
  */
27
- export declare function build(options: {
28
- cwd: string
29
- emitDeclarationOnly?: boolean
30
- strict?: boolean
31
- tsconfig?: string
32
- clean?: boolean
33
- }): Promise<void>
34
-
28
+ declare function build(options: {
29
+ cwd: string;
30
+ emitDeclarationOnly?: boolean;
31
+ strict?: boolean;
32
+ tsconfig?: string;
33
+ clean?: boolean;
34
+ }): Promise<void>;
35
+ //#endregion
36
+ //#region src/node/check.d.ts
35
37
  /** @public */
36
- export declare function check(options: {
37
- cwd: string
38
- strict?: boolean
39
- tsconfig?: string
40
- }): Promise<void>
41
-
38
+ declare function check(options: {
39
+ cwd: string;
40
+ strict?: boolean;
41
+ tsconfig?: string;
42
+ }): Promise<void>;
43
+ //#endregion
44
+ //#region src/node/strict.d.ts
45
+ /**
46
+ * @public
47
+ */
48
+ declare const toggle: z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>;
49
+ /**
50
+ * @public
51
+ */
52
+ type ToggleType = z.infer<typeof toggle>;
53
+ /**
54
+ * @public
55
+ */
56
+ declare const strictOptions: z.ZodObject<{
57
+ noPackageJsonTypings: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>>;
58
+ noImplicitSideEffects: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>>;
59
+ noImplicitBrowsersList: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>>;
60
+ alwaysPackageJsonTypes: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>>;
61
+ alwaysPackageJsonMain: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>>;
62
+ alwaysPackageJsonFiles: z.ZodDefault<z.ZodUnion<[z.ZodLiteral<"error">, z.ZodLiteral<"warn">, z.ZodLiteral<"off">]>>;
63
+ }, "strict", z.ZodTypeAny, {
64
+ noPackageJsonTypings: "error" | "warn" | "off";
65
+ noImplicitSideEffects: "error" | "warn" | "off";
66
+ noImplicitBrowsersList: "error" | "warn" | "off";
67
+ alwaysPackageJsonTypes: "error" | "warn" | "off";
68
+ alwaysPackageJsonMain: "error" | "warn" | "off";
69
+ alwaysPackageJsonFiles: "error" | "warn" | "off";
70
+ }, {
71
+ noPackageJsonTypings?: "error" | "warn" | "off" | undefined;
72
+ noImplicitSideEffects?: "error" | "warn" | "off" | undefined;
73
+ noImplicitBrowsersList?: "error" | "warn" | "off" | undefined;
74
+ alwaysPackageJsonTypes?: "error" | "warn" | "off" | undefined;
75
+ alwaysPackageJsonMain?: "error" | "warn" | "off" | undefined;
76
+ alwaysPackageJsonFiles?: "error" | "warn" | "off" | undefined;
77
+ }>;
78
+ /**
79
+ * @public
80
+ */
81
+ type InferredStrictOptions = z.infer<typeof strictOptions>;
82
+ /**
83
+ * @public
84
+ */
85
+ interface StrictOptions {
86
+ /**
87
+ * Disallows a top level `typings` field in `package.json` if it is equal to `exports['.'].source`.
88
+ * @defaultValue 'error'
89
+ */
90
+ noPackageJsonTypings?: ToggleType;
91
+ /**
92
+ * Requires specifying `sideEffects` in `package.json`.
93
+ * @defaultValue 'warn'
94
+ */
95
+ noImplicitSideEffects?: ToggleType;
96
+ /**
97
+ * Requires specifying `browserslist` in `package.json`, instead of relying on it implicitly being:
98
+ * @example
99
+ * ```
100
+ * "browserslist": "extends @sanity/browserslist-config"
101
+ * ```
102
+ * @defaultValue 'warn'
103
+ */
104
+ noImplicitBrowsersList?: ToggleType;
105
+ /**
106
+ * If typescript is used then `types` in `package.json` should be specified for npm listings to show the TS icon.
107
+ * @defaultValue 'error'
108
+ */
109
+ alwaysPackageJsonTypes?: ToggleType;
110
+ /**
111
+ * A lot of analysis tooling requiers the `main` field to work (like bundlephobia) and so it's best practice to always include it
112
+ * @defaultValue 'error'
113
+ */
114
+ alwaysPackageJsonMain?: ToggleType;
115
+ /**
116
+ * Using `.npmignore` is error prone, it's best practice to always declare `files` instead
117
+ * @defaultValue 'error'
118
+ */
119
+ alwaysPackageJsonFiles?: ToggleType;
120
+ }
42
121
  /** @alpha */
43
- export declare function createLogger(): Logger
44
-
122
+ declare function parseStrictOptions(input: unknown): InferredStrictOptions;
123
+ //#endregion
124
+ //#region src/node/core/config/types.d.ts
45
125
  /** @public */
46
- export declare const DEFAULT_BROWSERSLIST_QUERY: string[]
47
-
126
+ type PkgFormat = 'commonjs' | 'esm';
48
127
  /** @public */
49
- export declare function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T
50
-
128
+ type PkgRuntime = '*' | 'browser' | 'node';
51
129
  /** @public */
52
- export declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>
53
-
54
- /** @alpha */
55
- export declare function getExtractMessagesConfig(options: {
56
- rules: NonNullable<PkgConfigOptions['extract']>['rules']
57
- }): IExtractorMessagesConfig
58
-
59
- /**
60
- * @public
61
- */
62
- export declare type InferredStrictOptions = z.infer<typeof strictOptions>
63
-
130
+ interface PkgExport {
131
+ /** @internal */
132
+ _exported?: boolean;
133
+ browser?: {
134
+ source: string;
135
+ import?: string;
136
+ require?: string;
137
+ };
138
+ node?: {
139
+ source?: string;
140
+ import?: string;
141
+ require?: string;
142
+ };
143
+ types?: string;
144
+ source: string;
145
+ import?: string;
146
+ require?: string;
147
+ default: string;
148
+ }
64
149
  /** @public */
65
- export declare function init(options: {cwd: string; path: string}): Promise<void>
66
-
67
- /** @alpha */
68
- export declare function loadConfig(options: {cwd: string}): Promise<PkgConfigOptions | undefined>
69
-
70
- /** @internal */
71
- export declare function loadPkg(options: {cwd: string}): Promise<PackageJSON>
72
-
73
- /** @alpha */
74
- export declare function loadPkgWithReporting(options: {
75
- cwd: string
76
- logger: Logger
77
- strict: boolean
78
- }): Promise<PackageJSON>
79
-
80
- /** @alpha */
81
- declare interface Logger {
82
- log: (...args: unknown[]) => void
83
- info: (...args: unknown[]) => void
84
- warn: (...args: unknown[]) => void
85
- error: (...args: unknown[]) => void
86
- success: (...args: unknown[]) => void
150
+ type PkgConfigPropertyResolver<T> = (prev: T) => T;
151
+ /** @public */
152
+ type PkgConfigProperty<T> = PkgConfigPropertyResolver<T> | T;
153
+ /** @public */
154
+ interface PkgBundle {
155
+ source: string;
156
+ import?: string;
157
+ require?: string;
158
+ runtime?: PkgRuntime;
87
159
  }
88
-
89
- /** @alpha */
90
- export declare interface PackageJSON {
91
- type?: 'commonjs' | 'module'
92
- version: string
93
- private?: boolean
94
- author?:
95
- | string
96
- | {
97
- name: string
98
- email?: string
99
- url?: string
100
- }
101
- name: string
102
- description?: string
103
- keywords?: string[]
104
- bin?: Record<string, string>
105
- dependencies?: Record<string, string | undefined>
106
- devDependencies?: Record<string, string | undefined>
107
- peerDependencies?: Record<string, string | undefined>
108
- exports?: Record<
109
- string,
110
- | `./${string}.json`
111
- | `./${string}.css`
112
- | {
113
- source?: string
114
- types?: string
115
- browser?: {
116
- source: string
117
- import?: string
118
- require?: string
119
- }
120
- node?: {
121
- source?: string
122
- module?: string
123
- import?: string
124
- require?: string
125
- }
126
- module?: string
127
- import?: string
128
- require?: string
129
- default: string
130
- }
131
- | {
132
- types?: string
133
- svelte: string
134
- default?: string
135
- }
136
- >
137
- main?: string
138
- browser?: Record<string, string>
139
- source?: string
140
- module?: string
141
- types?: string
142
- files?: string[]
143
- scripts?: Record<string, string | undefined>
144
- browserslist?: string | string[]
145
- sideEffects?: boolean | string[]
146
- engines?: {
147
- node?: string
148
- npm?: string
149
- }
150
- repository?:
151
- | string
152
- | {
153
- type: 'git'
154
- url: string
155
- }
156
- bugs?:
157
- | string
158
- | {
159
- url: string
160
- email?: string
161
- }
162
- homepage?: string
163
- license?: string
160
+ /** @public */
161
+ interface PkgExports {
162
+ [path: string]: PkgExport;
164
163
  }
165
-
166
- /** @alpha */
167
- export declare function parseExports(options: {
168
- cwd: string
169
- pkg: PackageJSON
170
- strict: boolean
171
- strictOptions: InferredStrictOptions
172
- logger: Logger
173
- }): (PkgExport & {
174
- _path: string
175
- })[]
176
-
177
- /** @alpha */
178
- export declare function parseStrictOptions(input: unknown): InferredStrictOptions
179
-
180
164
  /** @public */
181
- export declare interface PkgBundle {
182
- source: string
183
- import?: string
184
- require?: string
185
- runtime?: PkgRuntime
165
+ type PkgRuleLevel = 'error' | 'warn' | 'info' | 'off';
166
+ /** @public */
167
+ interface TSDocCustomTag {
168
+ name: string;
169
+ syntaxKind: 'block' | 'modifier';
170
+ allowMultiple?: boolean;
186
171
  }
187
-
172
+ /**
173
+ * Until these types are on npm: https://github.com/facebook/react/blob/0bc30748730063e561d87a24a4617526fdd38349/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts#L39-L122
174
+ * @alpha
175
+ */
176
+ interface ReactCompilerOptions {
177
+ logger?: ReactCompilerLogger | null;
178
+ panicThreshold?: 'ALL_ERRORS' | 'CRITICAL_ERRORS' | 'NONE';
179
+ compilationMode?: 'infer' | 'syntax' | 'annotation' | 'all';
180
+ runtimeModule?: string | null | undefined;
181
+ /**
182
+ * By default React Compiler will skip compilation of code that suppresses the default
183
+ * React ESLint rules, since this is a strong indication that the code may be breaking React rules
184
+ * in some way.
185
+ *
186
+ * Use eslintSuppressionRules to pass a custom set of rule names: any code which suppresses the
187
+ * provided rules will skip compilation. To disable this feature (never bailout of compilation
188
+ * even if the default ESLint is suppressed), pass an empty array.
189
+ */
190
+ eslintSuppressionRules?: Array<string> | null | undefined;
191
+ sources?: Array<string> | ((filename: string) => boolean) | null;
192
+ /**
193
+ * The minimum major version of React that the compiler should emit code for. If the target is 19
194
+ * or higher, the compiler emits direct imports of React runtime APIs needed by the compiler. On
195
+ * versions prior to 19, an extra runtime package react-compiler-runtime is necessary to provide
196
+ * a userspace approximation of runtime APIs.
197
+ */
198
+ target: '17' | '18' | '19';
199
+ }
200
+ /**
201
+ * @alpha
202
+ * Represents 'events' that may occur during compilation. Events are only
203
+ * recorded when a logger is set (through the config).
204
+ * These are the different types of events:
205
+ * CompileError:
206
+ * Forget skipped compilation of a function / file due to a known todo,
207
+ * invalid input, or compiler invariant being broken.
208
+ * CompileSuccess:
209
+ * Forget successfully compiled a function.
210
+ * PipelineError:
211
+ * Unexpected errors that occurred during compilation (e.g. failures in
212
+ * babel or other unhandled exceptions).
213
+ */
214
+ type ReactCompilerLoggerEvent = {
215
+ kind: 'CompileError';
216
+ fnLoc: unknown;
217
+ detail: unknown;
218
+ } | {
219
+ kind: 'CompileDiagnostic';
220
+ fnLoc: unknown;
221
+ detail: unknown;
222
+ } | {
223
+ kind: 'CompileSuccess';
224
+ fnLoc: unknown;
225
+ fnName: string | null;
226
+ memoSlots: number;
227
+ memoBlocks: number;
228
+ memoValues: number;
229
+ prunedMemoBlocks: number;
230
+ prunedMemoValues: number;
231
+ } | {
232
+ kind: 'PipelineError';
233
+ fnLoc: unknown;
234
+ data: string;
235
+ };
236
+ /**
237
+ * @alpha
238
+ */
239
+ type ReactCompilerLogger = {
240
+ logEvent: (filename: string | null, event: ReactCompilerLoggerEvent) => void;
241
+ };
242
+ type DtsType = 'api-extractor' | 'rolldown';
188
243
  /** @public */
189
- export declare interface PkgConfigOptions {
244
+ interface PkgConfigOptions {
190
245
  /** @alpha */
191
246
  babel?: {
192
- plugins?: PluginItem[] | null | undefined
247
+ plugins?: PluginItem[] | null | undefined;
193
248
  /** @alpha */
194
- reactCompiler?: boolean
249
+ reactCompiler?: boolean;
195
250
  /** @alpha */
196
- styledComponents?:
197
- | boolean
198
- | {
199
- /** @defaultValue true */
200
- displayName?: boolean
201
- /**
202
- * @defaultValue []
203
- * @example ["@xstyled/styled-components", "@xstyled/styled-components/*"]
204
- */
205
- topLevelImportPaths?: string[]
206
- /** @defaultValue true */
207
- ssr?: boolean
208
- /** @defaultValue fale */
209
- fileName?: boolean
210
- /** @defaultValue ["index"] */
211
- meaninglessFileNames?: string[]
212
- /** @defaultValue true */
213
- minify?: boolean
214
- /** @defaultValue false */
215
- transpileTemplateLiterals?: boolean
216
- namespace?: string
217
- /** @defaultValue true */
218
- pure?: boolean
219
- }
220
- }
251
+ styledComponents?: boolean | {
252
+ /** @defaultValue true */
253
+ displayName?: boolean;
254
+ /**
255
+ * @defaultValue []
256
+ * @example ["\@xstyled/styled-components", "\@xstyled/styled-components/*"]
257
+ */
258
+ topLevelImportPaths?: string[];
259
+ /** @defaultValue true */
260
+ ssr?: boolean;
261
+ /** @defaultValue fale */
262
+ fileName?: boolean;
263
+ /** @defaultValue ["index"] */
264
+ meaninglessFileNames?: string[];
265
+ /** @defaultValue true */
266
+ minify?: boolean;
267
+ /** @defaultValue false */
268
+ transpileTemplateLiterals?: boolean;
269
+ namespace?: string;
270
+ /** @defaultValue true */
271
+ pure?: boolean;
272
+ };
273
+ };
221
274
  /**
222
275
  * Configure the React Compiler.
223
276
  * To enable it, either:
224
277
  * - set `babel.reactCompiler` to `true`
225
278
  * - add a `react-compiler` export condition, before any `browser`, `require` or `import` conditions. After any `react-server` and `node` conditions
226
279
  * @alpha */
227
- reactCompilerOptions?: ReactCompilerOptions
228
- bundles?: PkgBundle[]
280
+ reactCompilerOptions?: ReactCompilerOptions;
281
+ bundles?: PkgBundle[];
229
282
  /** @alpha */
230
- define?: Record<string, string | number | boolean | undefined | null>
283
+ define?: Record<string, string | number | boolean | undefined | null>;
231
284
  /**
232
285
  * Directory of distributed & bundled files.
233
286
  */
234
- dist?: string
235
- exports?: PkgConfigProperty<PkgExports>
287
+ dist?: string;
288
+ exports?: PkgConfigProperty<PkgExports>;
289
+ /**
290
+ * Runs `@microsoft/api-extractor` to check that TSDoc tags are valid, and release tags are correct.
291
+ * This is useful for packages that need to be consumed by TSDoc-based tooling.
292
+ * It's enabled by default, it can be disabled by setting `extract: {enabled: false}`
293
+ */
236
294
  extract?: {
295
+ /**
296
+ * @defaultValue true
297
+ */
298
+ enabled?: boolean;
237
299
  /**
238
300
  * Packages in `devDependencies` that are not in `external` are automatically added to the `bundledPackages` config.
239
301
  * You can exclude a package from being bundled by using a callback:
@@ -241,21 +303,21 @@ export declare interface PkgConfigOptions {
241
303
  * bundledPackages: (prev) => prev.filter(package => package !== 'sanity')
242
304
  * ```
243
305
  */
244
- bundledPackages?: PkgConfigProperty<string[]>
245
- customTags?: TSDocCustomTag[]
306
+ bundledPackages?: PkgConfigProperty<string[]>;
307
+ customTags?: TSDocCustomTag[];
246
308
  rules?: {
247
309
  /**
248
310
  * @deprecated as it's no longer needed since TypeScript 5.5 https://github.com/microsoft/TypeScript/issues/42873
249
311
  */
250
- 'ae-forgotten-export'?: never
251
- 'ae-incompatible-release-tags'?: PkgRuleLevel
252
- 'ae-internal-missing-underscore'?: PkgRuleLevel
253
- 'ae-missing-release-tag'?: PkgRuleLevel
254
- 'tsdoc-link-tag-unescaped-text'?: PkgRuleLevel
255
- 'tsdoc-undefined-tag'?: PkgRuleLevel
256
- 'tsdoc-unsupported-tag'?: PkgRuleLevel
257
- }
258
- }
312
+ 'ae-forgotten-export'?: never;
313
+ 'ae-incompatible-release-tags'?: PkgRuleLevel;
314
+ 'ae-internal-missing-underscore'?: PkgRuleLevel;
315
+ 'ae-missing-release-tag'?: PkgRuleLevel;
316
+ 'tsdoc-link-tag-unescaped-text'?: PkgRuleLevel;
317
+ 'tsdoc-undefined-tag'?: PkgRuleLevel;
318
+ 'tsdoc-unsupported-tag'?: PkgRuleLevel;
319
+ };
320
+ };
259
321
  /**
260
322
  * Packages to exclude from bundles.
261
323
  * Provide an array to merge with default exclusions, use a function to replace them:
@@ -263,45 +325,45 @@ export declare interface PkgConfigOptions {
263
325
  * exclude: (prev) => prev.filter(package => package !== 'foo')
264
326
  * ```
265
327
  */
266
- external?: PkgConfigProperty<string[]>
328
+ external?: PkgConfigProperty<string[]>;
267
329
  /**
268
330
  * Defaults to `"automatic"`
269
331
  */
270
- jsx?: 'transform' | 'preserve' | 'automatic'
332
+ jsx?: 'transform' | 'preserve' | 'automatic';
271
333
  /**
272
334
  * Defaults to `"createElement"`
273
335
  */
274
- jsxFactory?: string
336
+ jsxFactory?: string;
275
337
  /**
276
338
  * Defaults to `"Fragment"`
277
339
  */
278
- jsxFragment?: string
340
+ jsxFragment?: string;
279
341
  /**
280
342
  * Defaults to `"react"`
281
343
  */
282
- jsxImportSource?: string
344
+ jsxImportSource?: string;
283
345
  /**
284
346
  * @deprecated no longer supported
285
347
  */
286
- legacyExports?: never
287
- minify?: boolean
348
+ legacyExports?: never;
349
+ minify?: boolean;
288
350
  /** @alpha */
289
351
  rollup?: {
290
- plugins?: PkgConfigProperty<RollupPlugin[]>
291
- output?: Partial<NormalizedOutputOptions>
352
+ plugins?: PkgConfigProperty<Plugin[]>;
353
+ output?: Partial<NormalizedOutputOptions>;
292
354
  /**
293
355
  * Default options are `preset: 'recommended'` and `propertyReadSideEffects: false`
294
356
  * @alpha
295
357
  */
296
- treeshake?: TreeshakingOptions
358
+ treeshake?: TreeshakingOptions;
297
359
  /** @alpha */
298
- experimentalLogSideEffects?: boolean
360
+ experimentalLogSideEffects?: boolean;
299
361
  /**
300
362
  * Adds [hash] to chunk filenames, generally only useful if `@sanity/pkg-utils` is used to deploy a package directly to a CDN.
301
363
  * It's not needed when publishing to npm for consumption by other libraries, bundlers and frameworks.
302
364
  * @defaultValue false
303
365
  */
304
- hashChunkFileNames?: boolean
366
+ hashChunkFileNames?: boolean;
305
367
  /**
306
368
  * Optimizes lodash imports using `@optimize-lodash/rollup-plugin` when set to `true`.
307
369
  * It's enabled if `lodash` is found in `dependencies` or `peerDependencies`.
@@ -309,296 +371,209 @@ export declare interface PkgConfigOptions {
309
371
  * @defaultValue true
310
372
  * @alpha
311
373
  */
312
- optimizeLodash?: boolean | OptimizeLodashOptions
313
- }
374
+ optimizeLodash?: boolean | OptimizeLodashOptions;
375
+ };
314
376
  /**
315
377
  * Default runtime of package exports
316
378
  */
317
- runtime?: PkgRuntime
318
- sourcemap?: boolean
379
+ runtime?: PkgRuntime;
380
+ sourcemap?: boolean;
319
381
  /**
320
382
  * Directory of source files.
321
383
  */
322
- src?: string
323
- tsconfig?: string
384
+ src?: string;
385
+ tsconfig?: string;
324
386
  /**
325
387
  * Configure what checks are made when running `--strict` builds and checks
326
388
  */
327
- strictOptions?: StrictOptions
389
+ strictOptions?: StrictOptions;
390
+ /**
391
+ * .d.ts files can be generated either by using `@microsoft/api-extractor` or `rolldown`.
392
+ * `rolldown` is the faster option, but is not yet stable.
393
+ * @defaultValue 'api-extractor'
394
+ */
395
+ dts?: DtsType;
328
396
  }
329
-
330
- /** @public */
331
- export declare type PkgConfigProperty<T> = PkgConfigPropertyResolver<T> | T
332
-
397
+ //#endregion
398
+ //#region src/node/core/config/defineConfig.d.ts
333
399
  /** @public */
334
- export declare type PkgConfigPropertyResolver<T> = (prev: T) => T
335
-
400
+ declare function defineConfig<const T extends PkgConfigOptions>(configOptions: T): T;
401
+ //#endregion
402
+ //#region src/node/core/config/loadConfig.d.ts
403
+ /** @alpha */
404
+ declare function loadConfig(options: {
405
+ cwd: string;
406
+ }): Promise<PkgConfigOptions | undefined>;
407
+ //#endregion
408
+ //#region src/node/core/defaults.d.ts
336
409
  /** @public */
337
- export declare interface PkgExport {
338
- /** @internal */
339
- _exported?: boolean
340
- browser?: {
341
- source: string
342
- import?: string
343
- require?: string
344
- }
345
- node?: {
346
- source?: string
347
- import?: string
348
- require?: string
349
- }
350
- types?: string
351
- source: string
352
- import?: string
353
- require?: string
354
- default: string
410
+ declare const DEFAULT_BROWSERSLIST_QUERY: string[];
411
+ //#endregion
412
+ //#region src/node/core/pkg/types.d.ts
413
+ /** @alpha */
414
+ interface PackageJSON {
415
+ type?: 'commonjs' | 'module';
416
+ version: string;
417
+ private?: boolean;
418
+ author?: string | {
419
+ name: string;
420
+ email?: string;
421
+ url?: string;
422
+ };
423
+ name: string;
424
+ description?: string;
425
+ keywords?: string[];
426
+ bin?: Record<string, string>;
427
+ dependencies?: Record<string, string | undefined>;
428
+ devDependencies?: Record<string, string | undefined>;
429
+ peerDependencies?: Record<string, string | undefined>;
430
+ exports?: Record<string, `./${string}.json` | `./${string}.css` | {
431
+ source?: string;
432
+ types?: string;
433
+ browser?: {
434
+ source: string;
435
+ import?: string;
436
+ require?: string;
437
+ };
438
+ node?: {
439
+ source?: string;
440
+ module?: string;
441
+ import?: string;
442
+ require?: string;
443
+ };
444
+ module?: string;
445
+ import?: string;
446
+ require?: string;
447
+ default: string;
448
+ } | {
449
+ types?: string;
450
+ svelte: string;
451
+ default?: string;
452
+ }>;
453
+ main?: string;
454
+ browser?: Record<string, string>;
455
+ source?: string;
456
+ module?: string;
457
+ types?: string;
458
+ files?: string[];
459
+ scripts?: Record<string, string | undefined>;
460
+ browserslist?: string | string[];
461
+ sideEffects?: boolean | string[];
462
+ engines?: {
463
+ node?: string;
464
+ npm?: string;
465
+ };
466
+ repository?: string | {
467
+ type: 'git';
468
+ url: string;
469
+ };
470
+ bugs?: string | {
471
+ url: string;
472
+ email?: string;
473
+ };
474
+ homepage?: string;
475
+ license?: string;
355
476
  }
356
-
357
- /** @public */
358
- export declare interface PkgExports {
359
- [path: string]: PkgExport
477
+ //#endregion
478
+ //#region src/node/core/pkg/loadPkg.d.ts
479
+ /** @internal */
480
+ declare function loadPkg(options: {
481
+ cwd: string;
482
+ }): Promise<PackageJSON>;
483
+ //#endregion
484
+ //#region src/node/logger.d.ts
485
+ /** @alpha */
486
+ interface Logger {
487
+ log: (...args: unknown[]) => void;
488
+ info: (...args: unknown[]) => void;
489
+ warn: (...args: unknown[]) => void;
490
+ error: (...args: unknown[]) => void;
491
+ success: (...args: unknown[]) => void;
360
492
  }
361
-
362
- /** @public */
363
- export declare type PkgFormat = 'commonjs' | 'esm'
364
-
493
+ /** @alpha */
494
+ declare function createLogger(): Logger;
495
+ //#endregion
496
+ //#region src/node/core/pkg/loadPkgWithReporting.d.ts
497
+ /** @alpha */
498
+ declare function loadPkgWithReporting(options: {
499
+ cwd: string;
500
+ logger: Logger;
501
+ strict: boolean;
502
+ }): Promise<PackageJSON>;
503
+ //#endregion
504
+ //#region src/node/core/pkg/parseExports.d.ts
505
+ /** @alpha */
506
+ declare function parseExports(options: {
507
+ cwd: string;
508
+ pkg: PackageJSON;
509
+ strict: boolean;
510
+ strictOptions: InferredStrictOptions;
511
+ logger: Logger;
512
+ }): (PkgExport & {
513
+ _path: string;
514
+ })[];
515
+ //#endregion
516
+ //#region src/node/core/template/types.d.ts
365
517
  /** @public */
366
- export declare type PkgRuleLevel = 'error' | 'warn' | 'info' | 'off'
367
-
518
+ interface PkgTemplateFile {
519
+ name: string;
520
+ contents: string;
521
+ }
368
522
  /** @public */
369
- export declare type PkgRuntime = '*' | 'browser' | 'node'
370
-
523
+ interface PkgTemplateStringOption<T = string> {
524
+ name: string;
525
+ type: 'string';
526
+ description: string;
527
+ initial?: T | ((options: Record<string, any>) => T);
528
+ parse?: (v: string) => T | null;
529
+ validate?: (v: string) => string | true;
530
+ }
371
531
  /** @public */
372
- export declare type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver
373
-
532
+ type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>;
374
533
  /** @public */
375
- export declare interface PkgTemplateDefinition {
376
- options: PkgTemplateStringOption<any>[]
534
+ interface PkgTemplateDefinition {
535
+ options: PkgTemplateStringOption<any>[];
377
536
  features: {
378
- name: string
379
- optional: boolean
380
- initial: boolean
381
- }[]
382
- getFiles: (
383
- options: Record<string, any>,
384
- features: Record<string, boolean>,
385
- ) => Promise<PkgTemplateFile[]>
386
- }
387
-
388
- /** @public */
389
- export declare interface PkgTemplateFile {
390
- name: string
391
- contents: string
537
+ name: string;
538
+ optional: boolean;
539
+ initial: boolean;
540
+ }[];
541
+ getFiles: (options: Record<string, any>, features: Record<string, boolean>) => Promise<PkgTemplateFile[]>;
392
542
  }
393
-
394
- /** @public */
395
- export declare type PkgTemplateOption<T = string> = PkgTemplateStringOption<T>
396
-
397
543
  /** @public */
398
- export declare type PkgTemplateResolver = (options: {
399
- cwd: string
544
+ type PkgTemplateResolver = (options: {
545
+ cwd: string;
400
546
  /** @internal */
401
- logger: Logger
402
- packagePath: string
403
- }) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>
404
-
547
+ logger: Logger;
548
+ packagePath: string;
549
+ }) => PkgTemplateDefinition | Promise<PkgTemplateDefinition>;
405
550
  /** @public */
406
- export declare interface PkgTemplateStringOption<T = string> {
407
- name: string
408
- type: 'string'
409
- description: string
410
- initial?: T | ((options: Record<string, any>) => T)
411
- parse?: (v: string) => T | null
412
- validate?: (v: string) => string | true
413
- }
414
-
415
- /**
416
- * @alpha
417
- */
418
- export declare type ReactCompilerLogger = {
419
- logEvent: (filename: string | null, event: ReactCompilerLoggerEvent) => void
420
- }
421
-
422
- /**
423
- * @alpha
424
- * Represents 'events' that may occur during compilation. Events are only
425
- * recorded when a logger is set (through the config).
426
- * These are the different types of events:
427
- * CompileError:
428
- * Forget skipped compilation of a function / file due to a known todo,
429
- * invalid input, or compiler invariant being broken.
430
- * CompileSuccess:
431
- * Forget successfully compiled a function.
432
- * PipelineError:
433
- * Unexpected errors that occurred during compilation (e.g. failures in
434
- * babel or other unhandled exceptions).
435
- */
436
- export declare type ReactCompilerLoggerEvent =
437
- | {
438
- kind: 'CompileError'
439
- fnLoc: unknown
440
- detail: unknown
441
- }
442
- | {
443
- kind: 'CompileDiagnostic'
444
- fnLoc: unknown
445
- detail: unknown
446
- }
447
- | {
448
- kind: 'CompileSuccess'
449
- fnLoc: unknown
450
- fnName: string | null
451
- memoSlots: number
452
- memoBlocks: number
453
- memoValues: number
454
- prunedMemoBlocks: number
455
- prunedMemoValues: number
456
- }
457
- | {
458
- kind: 'PipelineError'
459
- fnLoc: unknown
460
- data: string
461
- }
462
-
463
- /**
464
- * Until these types are on npm: https://github.com/facebook/react/blob/0bc30748730063e561d87a24a4617526fdd38349/compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Options.ts#L39-L122
465
- * @alpha
466
- */
467
- export declare interface ReactCompilerOptions {
468
- logger?: ReactCompilerLogger | null
469
- panicThreshold?: 'ALL_ERRORS' | 'CRITICAL_ERRORS' | 'NONE'
470
- compilationMode?: 'infer' | 'syntax' | 'annotation' | 'all'
471
- runtimeModule?: string | null | undefined
472
- /**
473
- * By default React Compiler will skip compilation of code that suppresses the default
474
- * React ESLint rules, since this is a strong indication that the code may be breaking React rules
475
- * in some way.
476
- *
477
- * Use eslintSuppressionRules to pass a custom set of rule names: any code which suppresses the
478
- * provided rules will skip compilation. To disable this feature (never bailout of compilation
479
- * even if the default ESLint is suppressed), pass an empty array.
480
- */
481
- eslintSuppressionRules?: Array<string> | null | undefined
482
- sources?: Array<string> | ((filename: string) => boolean) | null
483
- /**
484
- * The minimum major version of React that the compiler should emit code for. If the target is 19
485
- * or higher, the compiler emits direct imports of React runtime APIs needed by the compiler. On
486
- * versions prior to 19, an extra runtime package react-compiler-runtime is necessary to provide
487
- * a userspace approximation of runtime APIs.
488
- */
489
- target: '17' | '18' | '19'
490
- }
491
-
492
- export {RollupPlugin}
493
-
494
- /**
495
- * @public
496
- */
497
- export declare interface StrictOptions {
498
- /**
499
- * Disallows a top level `typings` field in `package.json` if it is equal to `exports['.'].source`.
500
- * @defaultValue 'error'
501
- */
502
- noPackageJsonTypings?: ToggleType
503
- /**
504
- * Requires specifying `sideEffects` in `package.json`.
505
- * @defaultValue 'warn'
506
- */
507
- noImplicitSideEffects?: ToggleType
508
- /**
509
- * Requires specifying `browserslist` in `package.json`, instead of relying on it implicitly being:
510
- * @example
511
- * ```
512
- * "browserslist": "extends @sanity/browserslist-config"
513
- * ```
514
- * @defaultValue 'warn'
515
- */
516
- noImplicitBrowsersList?: ToggleType
517
- /**
518
- * If typescript is used then `types` in `package.json` should be specified for npm listings to show the TS icon.
519
- * @defaultValue 'error'
520
- */
521
- alwaysPackageJsonTypes?: ToggleType
522
- /**
523
- * A lot of analysis tooling requiers the `main` field to work (like bundlephobia) and so it's best practice to always include it
524
- * @defaultValue 'error'
525
- */
526
- alwaysPackageJsonMain?: ToggleType
527
- /**
528
- * Using `.npmignore` is error prone, it's best practice to always declare `files` instead
529
- * @defaultValue 'error'
530
- */
531
- alwaysPackageJsonFiles?: ToggleType
532
- }
533
-
534
- /**
535
- * @public
536
- */
537
- export declare const strictOptions: z.ZodObject<
538
- {
539
- noPackageJsonTypings: z.ZodDefault<
540
- z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
541
- >
542
- noImplicitSideEffects: z.ZodDefault<
543
- z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
544
- >
545
- noImplicitBrowsersList: z.ZodDefault<
546
- z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
547
- >
548
- alwaysPackageJsonTypes: z.ZodDefault<
549
- z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
550
- >
551
- alwaysPackageJsonMain: z.ZodDefault<
552
- z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
553
- >
554
- alwaysPackageJsonFiles: z.ZodDefault<
555
- z.ZodUnion<[z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]>
556
- >
557
- },
558
- 'strict',
559
- z.ZodTypeAny,
560
- {
561
- noPackageJsonTypings: 'error' | 'warn' | 'off'
562
- noImplicitSideEffects: 'error' | 'warn' | 'off'
563
- noImplicitBrowsersList: 'error' | 'warn' | 'off'
564
- alwaysPackageJsonTypes: 'error' | 'warn' | 'off'
565
- alwaysPackageJsonMain: 'error' | 'warn' | 'off'
566
- alwaysPackageJsonFiles: 'error' | 'warn' | 'off'
567
- },
568
- {
569
- noPackageJsonTypings?: 'error' | 'warn' | 'off' | undefined
570
- noImplicitSideEffects?: 'error' | 'warn' | 'off' | undefined
571
- noImplicitBrowsersList?: 'error' | 'warn' | 'off' | undefined
572
- alwaysPackageJsonTypes?: 'error' | 'warn' | 'off' | undefined
573
- alwaysPackageJsonMain?: 'error' | 'warn' | 'off' | undefined
574
- alwaysPackageJsonFiles?: 'error' | 'warn' | 'off' | undefined
575
- }
576
- >
577
-
578
- /**
579
- * @public
580
- */
581
- export declare const toggle: z.ZodUnion<
582
- [z.ZodLiteral<'error'>, z.ZodLiteral<'warn'>, z.ZodLiteral<'off'>]
583
- >
584
-
585
- /**
586
- * @public
587
- */
588
- export declare type ToggleType = z.infer<typeof toggle>
589
-
551
+ type PkgTemplate = PkgTemplateDefinition | PkgTemplateResolver;
552
+ //#endregion
553
+ //#region src/node/core/template/define.d.ts
590
554
  /** @public */
591
- export declare interface TSDocCustomTag {
592
- name: string
593
- syntaxKind: 'block' | 'modifier'
594
- allowMultiple?: boolean
595
- }
596
-
555
+ declare function defineTemplateOption<T>(option: PkgTemplateOption<T>): PkgTemplateOption<T>;
556
+ //#endregion
557
+ //#region src/node/init.d.ts
597
558
  /** @public */
598
- export declare function watch(options: {
599
- cwd: string
600
- strict?: boolean
601
- tsconfig?: string
602
- }): Promise<void>
603
-
604
- export {}
559
+ declare function init(options: {
560
+ cwd: string;
561
+ path: string;
562
+ }): Promise<void>;
563
+ //#endregion
564
+ //#region src/node/tasks/dts/getExtractMessagesConfig.d.ts
565
+ /** @alpha */
566
+ declare function getExtractMessagesConfig(options: {
567
+ rules: NonNullable<PkgConfigOptions['extract']>['rules'];
568
+ disabled?: boolean;
569
+ }): IExtractorMessagesConfig;
570
+ //#endregion
571
+ //#region src/node/watch.d.ts
572
+ /** @public */
573
+ declare function watch(options: {
574
+ cwd: string;
575
+ strict?: boolean;
576
+ tsconfig?: string;
577
+ }): Promise<void>;
578
+ //#endregion
579
+ export { DEFAULT_BROWSERSLIST_QUERY, InferredStrictOptions, PackageJSON, PkgBundle, PkgConfigOptions, PkgConfigProperty, PkgConfigPropertyResolver, PkgExport, PkgExports, PkgFormat, PkgRuleLevel, PkgRuntime, PkgTemplate, PkgTemplateDefinition, PkgTemplateFile, PkgTemplateOption, PkgTemplateResolver, PkgTemplateStringOption, ReactCompilerLogger, ReactCompilerLoggerEvent, ReactCompilerOptions, RollupPlugin, StrictOptions, TSDocCustomTag, ToggleType, build, check, createLogger, defineConfig, defineTemplateOption, getExtractMessagesConfig, init, loadConfig, loadPkg, loadPkgWithReporting, parseExports, parseStrictOptions, strictOptions, toggle, watch };