@bamboocss/node 1.47.0 → 1.48.1

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.cts CHANGED
@@ -4,7 +4,6 @@ import { AnalysisOptions, Artifact, ArtifactId, BambooHooks, Config, CssArtifact
4
4
  import { DeadImport, StyleEncoder, Stylesheet } from "@bamboocss/core";
5
5
  import { Generator, generatePackageExports } from "@bamboocss/generator";
6
6
  import { ParserResult, Project } from "@bamboocss/parser";
7
- import { Message, Root } from "postcss";
8
7
 
9
8
  //#region src/diff-engine.d.ts
10
9
  declare class DiffEngine {
@@ -195,11 +194,7 @@ declare class BambooContext extends Generator {
195
194
  results: ParserResult[];
196
195
  };
197
196
  writeCss: (sheet?: Stylesheet) => Promise<PromiseSettledResult<void>[]> | undefined;
198
- writeSplitCss: (sheet: Stylesheet, {
199
- includeRecipes
200
- }?: {
201
- includeRecipes?: boolean;
202
- }) => Promise<void>;
197
+ writeSplitCss: (sheet: Stylesheet) => Promise<void>;
203
198
  watchConfig: (cb: (file: string) => void | Promise<void>, opts?: Omit<WatchOptions, "include">) => void;
204
199
  watchFiles: (cb: (event: WatcherEventType, file: string) => void | Promise<void>, opts?: Omit<WatchOptions, "include" | "exclude" | "poll" | "cwd" | "logger">) => void;
205
200
  }
@@ -221,6 +216,22 @@ declare function analyze(ctx: BambooContext, options?: AnalysisOptions): {
221
216
  declare function buildInfo(ctx: BambooContext, outfile: string): Promise<void>;
222
217
  //#endregion
223
218
  //#region src/builder.d.ts
219
+ /** Files a watcher knows moved since the previous setup. Omit this to retain filesystem discovery. */
220
+ interface BuilderSourceChanges {
221
+ /** Absolute or cwd-relative paths. An empty list authoritatively means no source moved. */
222
+ files: readonly string[];
223
+ /** Additions and deletions can change glob membership, so they still reconcile the inventory. */
224
+ needsInventoryScan?: boolean;
225
+ /** A `dependencies` glob gained or lost a member and must be expanded before config diffing. */
226
+ needsConfigReload?: boolean;
227
+ }
228
+ interface BuilderSetupOptions {
229
+ configPath?: string;
230
+ cwd?: string;
231
+ dev?: boolean;
232
+ /** A watcher-owned change journal. Without one, Builder performs its standalone filesystem scan. */
233
+ sourceChanges?: BuilderSourceChanges;
234
+ }
224
235
  declare class Builder {
225
236
  /**
226
237
  * The current bamboo context
@@ -231,7 +242,6 @@ declare class Builder {
231
242
  private explicitDepsMeta;
232
243
  private affecteds;
233
244
  private configDependencies;
234
- private pendingConfigCrawl;
235
245
  /** Last complete included inventory, including members which have since been deleted. */
236
246
  private sourceInventory;
237
247
  /** Existing included owners selected by the last resolution-ledger invalidation pass. */
@@ -266,29 +276,40 @@ declare class Builder {
266
276
  private resolutionAffectedThisPass;
267
277
  /** Per-pass digests of re-read values, so N dependents of one edit digest each value once. */
268
278
  private readDigestMemo;
279
+ /** Resolution ledger as it stood before this pass's first physical source mutation. */
280
+ private capturedLedger;
281
+ /**
282
+ * Reload one edited source, keeping the closure the next extraction pass has to select.
283
+ *
284
+ * An integration which shares this context has to refresh an edited module before anything
285
+ * folds against it — a consumer is transformed before the module it imports, so the fold
286
+ * would otherwise bake in the previous contents. Doing that through the Project directly
287
+ * loses the graph the rebuild needs: reloading retracts the file's own forward edges, and
288
+ * `invalidateChangedSources` reads them afterwards to find its dependents. So the mutation
289
+ * belongs here, behind a snapshot taken before the first of them.
290
+ *
291
+ * Once per pass, not once per file: the first mutation is the boundary, and every later one
292
+ * in the same event is already described by that snapshot. `refreshSourceState` consumes it.
293
+ */
294
+ reloadSource: (filePath: string) => import("ts-morph").FileSystemRefreshResult | undefined;
295
+ /** The deletion half of `reloadSource`, with the same snapshot obligation. */
296
+ removeSource: (filePath: string) => boolean;
297
+ private captureResolutionLedger;
269
298
  /** @internal Current and missing resolver paths which can change the stylesheet. */
270
299
  getResolutionReadFiles: () => readonly string[];
300
+ /** @internal The inventory reconciled by the most recent extraction pass. */
301
+ getSourceFiles: () => readonly string[];
302
+ /** @internal Whether creating this path can change source or explicit-dependency membership. */
303
+ isPotentialSourceFile: (filePath: string) => boolean;
304
+ /** @internal Whether creating or deleting this path can change a `dependencies` glob. */
305
+ isPotentialConfigDependency: (filePath: string) => boolean;
271
306
  /** @internal Exact local package/tsconfig files which can change semantic resolution. */
272
307
  getResolutionConfigurationFiles: () => readonly string[];
273
308
  private readResolutionConfiguration;
274
309
  private changedResolutionConfigurations;
275
310
  private snapshotResolutionConfigurations;
276
- /**
277
- * Remember what to crawl; do not crawl yet.
278
- *
279
- * The crawl walks the config's own import graph, and resolving a bare specifier there loads a
280
- * whole TypeScript compiler. Only `registerDependency` reads the result, and only the PostCSS
281
- * plugin calls that — the CLI and the Vite plugin (which crawls separately, when it watches)
282
- * paid ~155ms of compiler load per build for a set neither of them ever read.
283
- */
284
- setConfigDependencies(options: SetupContextOptions): void;
285
- /** Crawl on first read, once per `setConfigDependencies`. */
286
- private crawlConfigDependencies;
287
- setup: (options?: {
288
- configPath?: string;
289
- cwd?: string;
290
- dev?: boolean;
291
- }) => Promise<BambooContext | undefined>;
311
+ private recordConfigDependencies;
312
+ setup: (options?: BuilderSetupOptions) => Promise<BambooContext | undefined>;
292
313
  /** Every file whose content participates in the resolved config, for the dev fast path. */
293
314
  private configGraphFiles;
294
315
  private configGraphUnchanged;
@@ -345,37 +366,25 @@ declare class Builder {
345
366
  mtime: number;
346
367
  isUnchanged: boolean;
347
368
  };
348
- checkFilesChanged(files: string[]): {
369
+ checkFilesChanged(files: readonly string[], knownChanges?: ReadonlySet<string>): {
349
370
  changes: Map<string, FileMeta>;
350
371
  hasFilesChanged: boolean;
351
372
  };
352
373
  extractFile: (ctx: BambooContext, file: string) => import("@bamboocss/parser").ParserResult | undefined;
353
374
  extract: () => void;
354
- isValidRoot: (root: Root) => boolean;
355
- write: (root: Root) => void;
356
375
  /**
357
376
  * The finished stylesheet, as a string.
358
377
  *
359
- * The same sheet `write` injects into a postcss root, for callers that want the css
360
- * rather than a mutated root -- the vite plugin serves it as a virtual module. Both go
361
- * through here so a build cannot depend on which integration asked for it.
362
- *
363
- * `layerParams` is the one thing that differs between them, and it is not cosmetic: the
364
- * `@layer a, b, c;` statement is what fixes layer *order*, and css layers are ordered by
365
- * first appearance otherwise. `write` leaves it out because the root it appends to is a
366
- * file that already declares it -- that declaration is what `isValidRoot` matches on. A
367
- * virtual module is the whole stylesheet and has nothing to inherit it from.
378
+ * `layerParams` controls the `@layer a, b, c;` statement that fixes layer order. CSS layers
379
+ * are ordered by first appearance otherwise.
368
380
  *
369
381
  * `extract` has to have run first: this reads the encoder rather than filling it.
370
382
  */
371
383
  toCss: ({
372
- layerParams,
373
- includeRecipes
384
+ layerParams
374
385
  }?: {
375
386
  layerParams?: boolean;
376
- includeRecipes?: boolean;
377
387
  }) => string;
378
- registerDependency: (fn: (dep: Message) => void) => void;
379
388
  }
380
389
  interface FileMeta {
381
390
  mtime: number;
@@ -443,9 +452,6 @@ declare const setLogStream: (options: LogstreamOptions) => {
443
452
  [Symbol.dispose]: () => void;
444
453
  };
445
454
  //#endregion
446
- //#region src/parse-dependency.d.ts
447
- declare function parseDependency(fileOrGlob: string): Message | null;
448
- //#endregion
449
455
  //#region src/setup-config.d.ts
450
456
  type SetupOptions = Partial<Config> & {
451
457
  force?: boolean;
@@ -475,4 +481,4 @@ declare const hasUncompilableSources: (options: {
475
481
  include?: readonly string[];
476
482
  }) => boolean;
477
483
  //#endregion
478
- export { BambooContext, Builder, type CssGenOptions, analyze, buildInfo, codegen, cssgen, debug, findViteConfig, generate, generatePackageExports, hasUncompilableSources, isStaticCompilerActive, loadConfigAndCreateContext, markStaticCompilerActive, parseDependency, setLogStream, setupConfig, setupGitIgnore, spec, startProfiling };
484
+ export { BambooContext, Builder, type BuilderSetupOptions, type BuilderSourceChanges, type CssGenOptions, analyze, buildInfo, codegen, cssgen, debug, findViteConfig, generate, generatePackageExports, hasUncompilableSources, isStaticCompilerActive, loadConfigAndCreateContext, markStaticCompilerActive, setLogStream, setupConfig, setupGitIgnore, spec, startProfiling };
package/dist/index.d.mts CHANGED
@@ -4,7 +4,6 @@ import { DeadImport, StyleEncoder, Stylesheet } from "@bamboocss/core";
4
4
  import { Generator, generatePackageExports } from "@bamboocss/generator";
5
5
  import { ParserResult, Project } from "@bamboocss/parser";
6
6
  import { AnalysisOptions, Artifact, ArtifactId, BambooHooks, Config, CssArtifactType, LoadConfigResult, Runtime, SpecFile, WatchOptions, WatcherEventType } from "@bamboocss/types";
7
- import { Message, Root } from "postcss";
8
7
 
9
8
  //#region src/diff-engine.d.ts
10
9
  declare class DiffEngine {
@@ -195,11 +194,7 @@ declare class BambooContext extends Generator {
195
194
  results: ParserResult[];
196
195
  };
197
196
  writeCss: (sheet?: Stylesheet) => Promise<PromiseSettledResult<void>[]> | undefined;
198
- writeSplitCss: (sheet: Stylesheet, {
199
- includeRecipes
200
- }?: {
201
- includeRecipes?: boolean;
202
- }) => Promise<void>;
197
+ writeSplitCss: (sheet: Stylesheet) => Promise<void>;
203
198
  watchConfig: (cb: (file: string) => void | Promise<void>, opts?: Omit<WatchOptions, "include">) => void;
204
199
  watchFiles: (cb: (event: WatcherEventType, file: string) => void | Promise<void>, opts?: Omit<WatchOptions, "include" | "exclude" | "poll" | "cwd" | "logger">) => void;
205
200
  }
@@ -221,6 +216,22 @@ declare function analyze(ctx: BambooContext, options?: AnalysisOptions): {
221
216
  declare function buildInfo(ctx: BambooContext, outfile: string): Promise<void>;
222
217
  //#endregion
223
218
  //#region src/builder.d.ts
219
+ /** Files a watcher knows moved since the previous setup. Omit this to retain filesystem discovery. */
220
+ interface BuilderSourceChanges {
221
+ /** Absolute or cwd-relative paths. An empty list authoritatively means no source moved. */
222
+ files: readonly string[];
223
+ /** Additions and deletions can change glob membership, so they still reconcile the inventory. */
224
+ needsInventoryScan?: boolean;
225
+ /** A `dependencies` glob gained or lost a member and must be expanded before config diffing. */
226
+ needsConfigReload?: boolean;
227
+ }
228
+ interface BuilderSetupOptions {
229
+ configPath?: string;
230
+ cwd?: string;
231
+ dev?: boolean;
232
+ /** A watcher-owned change journal. Without one, Builder performs its standalone filesystem scan. */
233
+ sourceChanges?: BuilderSourceChanges;
234
+ }
224
235
  declare class Builder {
225
236
  /**
226
237
  * The current bamboo context
@@ -231,7 +242,6 @@ declare class Builder {
231
242
  private explicitDepsMeta;
232
243
  private affecteds;
233
244
  private configDependencies;
234
- private pendingConfigCrawl;
235
245
  /** Last complete included inventory, including members which have since been deleted. */
236
246
  private sourceInventory;
237
247
  /** Existing included owners selected by the last resolution-ledger invalidation pass. */
@@ -266,29 +276,40 @@ declare class Builder {
266
276
  private resolutionAffectedThisPass;
267
277
  /** Per-pass digests of re-read values, so N dependents of one edit digest each value once. */
268
278
  private readDigestMemo;
279
+ /** Resolution ledger as it stood before this pass's first physical source mutation. */
280
+ private capturedLedger;
281
+ /**
282
+ * Reload one edited source, keeping the closure the next extraction pass has to select.
283
+ *
284
+ * An integration which shares this context has to refresh an edited module before anything
285
+ * folds against it — a consumer is transformed before the module it imports, so the fold
286
+ * would otherwise bake in the previous contents. Doing that through the Project directly
287
+ * loses the graph the rebuild needs: reloading retracts the file's own forward edges, and
288
+ * `invalidateChangedSources` reads them afterwards to find its dependents. So the mutation
289
+ * belongs here, behind a snapshot taken before the first of them.
290
+ *
291
+ * Once per pass, not once per file: the first mutation is the boundary, and every later one
292
+ * in the same event is already described by that snapshot. `refreshSourceState` consumes it.
293
+ */
294
+ reloadSource: (filePath: string) => import("ts-morph").FileSystemRefreshResult | undefined;
295
+ /** The deletion half of `reloadSource`, with the same snapshot obligation. */
296
+ removeSource: (filePath: string) => boolean;
297
+ private captureResolutionLedger;
269
298
  /** @internal Current and missing resolver paths which can change the stylesheet. */
270
299
  getResolutionReadFiles: () => readonly string[];
300
+ /** @internal The inventory reconciled by the most recent extraction pass. */
301
+ getSourceFiles: () => readonly string[];
302
+ /** @internal Whether creating this path can change source or explicit-dependency membership. */
303
+ isPotentialSourceFile: (filePath: string) => boolean;
304
+ /** @internal Whether creating or deleting this path can change a `dependencies` glob. */
305
+ isPotentialConfigDependency: (filePath: string) => boolean;
271
306
  /** @internal Exact local package/tsconfig files which can change semantic resolution. */
272
307
  getResolutionConfigurationFiles: () => readonly string[];
273
308
  private readResolutionConfiguration;
274
309
  private changedResolutionConfigurations;
275
310
  private snapshotResolutionConfigurations;
276
- /**
277
- * Remember what to crawl; do not crawl yet.
278
- *
279
- * The crawl walks the config's own import graph, and resolving a bare specifier there loads a
280
- * whole TypeScript compiler. Only `registerDependency` reads the result, and only the PostCSS
281
- * plugin calls that — the CLI and the Vite plugin (which crawls separately, when it watches)
282
- * paid ~155ms of compiler load per build for a set neither of them ever read.
283
- */
284
- setConfigDependencies(options: SetupContextOptions): void;
285
- /** Crawl on first read, once per `setConfigDependencies`. */
286
- private crawlConfigDependencies;
287
- setup: (options?: {
288
- configPath?: string;
289
- cwd?: string;
290
- dev?: boolean;
291
- }) => Promise<BambooContext | undefined>;
311
+ private recordConfigDependencies;
312
+ setup: (options?: BuilderSetupOptions) => Promise<BambooContext | undefined>;
292
313
  /** Every file whose content participates in the resolved config, for the dev fast path. */
293
314
  private configGraphFiles;
294
315
  private configGraphUnchanged;
@@ -345,37 +366,25 @@ declare class Builder {
345
366
  mtime: number;
346
367
  isUnchanged: boolean;
347
368
  };
348
- checkFilesChanged(files: string[]): {
369
+ checkFilesChanged(files: readonly string[], knownChanges?: ReadonlySet<string>): {
349
370
  changes: Map<string, FileMeta>;
350
371
  hasFilesChanged: boolean;
351
372
  };
352
373
  extractFile: (ctx: BambooContext, file: string) => import("@bamboocss/parser").ParserResult | undefined;
353
374
  extract: () => void;
354
- isValidRoot: (root: Root) => boolean;
355
- write: (root: Root) => void;
356
375
  /**
357
376
  * The finished stylesheet, as a string.
358
377
  *
359
- * The same sheet `write` injects into a postcss root, for callers that want the css
360
- * rather than a mutated root -- the vite plugin serves it as a virtual module. Both go
361
- * through here so a build cannot depend on which integration asked for it.
362
- *
363
- * `layerParams` is the one thing that differs between them, and it is not cosmetic: the
364
- * `@layer a, b, c;` statement is what fixes layer *order*, and css layers are ordered by
365
- * first appearance otherwise. `write` leaves it out because the root it appends to is a
366
- * file that already declares it -- that declaration is what `isValidRoot` matches on. A
367
- * virtual module is the whole stylesheet and has nothing to inherit it from.
378
+ * `layerParams` controls the `@layer a, b, c;` statement that fixes layer order. CSS layers
379
+ * are ordered by first appearance otherwise.
368
380
  *
369
381
  * `extract` has to have run first: this reads the encoder rather than filling it.
370
382
  */
371
383
  toCss: ({
372
- layerParams,
373
- includeRecipes
384
+ layerParams
374
385
  }?: {
375
386
  layerParams?: boolean;
376
- includeRecipes?: boolean;
377
387
  }) => string;
378
- registerDependency: (fn: (dep: Message) => void) => void;
379
388
  }
380
389
  interface FileMeta {
381
390
  mtime: number;
@@ -443,9 +452,6 @@ declare const setLogStream: (options: LogstreamOptions) => {
443
452
  [Symbol.dispose]: () => void;
444
453
  };
445
454
  //#endregion
446
- //#region src/parse-dependency.d.ts
447
- declare function parseDependency(fileOrGlob: string): Message | null;
448
- //#endregion
449
455
  //#region src/setup-config.d.ts
450
456
  type SetupOptions = Partial<Config> & {
451
457
  force?: boolean;
@@ -475,4 +481,4 @@ declare const hasUncompilableSources: (options: {
475
481
  include?: readonly string[];
476
482
  }) => boolean;
477
483
  //#endregion
478
- export { BambooContext, Builder, type CssGenOptions, analyze, buildInfo, codegen, cssgen, debug, findViteConfig, generate, generatePackageExports, hasUncompilableSources, isStaticCompilerActive, loadConfigAndCreateContext, markStaticCompilerActive, parseDependency, setLogStream, setupConfig, setupGitIgnore, spec, startProfiling };
484
+ export { BambooContext, Builder, type BuilderSetupOptions, type BuilderSourceChanges, type CssGenOptions, analyze, buildInfo, codegen, cssgen, debug, findViteConfig, generate, generatePackageExports, hasUncompilableSources, isStaticCompilerActive, loadConfigAndCreateContext, markStaticCompilerActive, setLogStream, setupConfig, setupGitIgnore, spec, startProfiling };