@bamboocss/node 1.53.0 → 1.54.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.cjs CHANGED
@@ -3696,13 +3696,24 @@ var Builder = class {
3696
3696
  };
3697
3697
  /** @internal The inventory reconciled by the most recent extraction pass. */
3698
3698
  getSourceFiles = () => Object.freeze([...this.sourceInventory ?? []]);
3699
- /** @internal Whether creating this path can change source or explicit-dependency membership. */
3699
+ /** The compiled `include`/`exclude` matcher of each context, since the compiler asks per module. */
3700
+ sourceMatchers = /* @__PURE__ */ new WeakMap();
3701
+ /**
3702
+ * @internal Whether this path is one `include` covers and `exclude` does not.
3703
+ *
3704
+ * What decides source membership when a file appears, and what the Vite compiler asks of
3705
+ * every module it is handed: a module outside the extraction inventory yields no rule, so
3706
+ * compiling it is wasted — and with the TypeScript 7 backend, far from free.
3707
+ */
3700
3708
  isPotentialSourceFile = (filePath) => {
3701
3709
  const ctx = this.getContextOrThrow();
3702
3710
  const absolutePath = this.absOwner(ctx, filePath);
3703
3711
  const relativePath = this.sourcePath(ctx.runtime.path.relative(ctx.config.cwd, absolutePath));
3704
- const sourcePatterns = ctx.config.include ?? [];
3705
- const sourceMatcher = sourcePatterns.length ? (0, picomatch.default)(sourcePatterns, { ignore: globIgnore(ctx.config.exclude) }) : void 0;
3712
+ if (!this.sourceMatchers.has(ctx)) {
3713
+ const sourcePatterns = ctx.config.include ?? [];
3714
+ this.sourceMatchers.set(ctx, sourcePatterns.length ? (0, picomatch.default)(sourcePatterns, { ignore: globIgnore(ctx.config.exclude) }) : void 0);
3715
+ }
3716
+ const sourceMatcher = this.sourceMatchers.get(ctx);
3706
3717
  return sourceMatcher?.(relativePath) || sourceMatcher?.(absolutePath) || false;
3707
3718
  };
3708
3719
  /** @internal Whether creating or deleting this path can change a `dependencies` glob. */
@@ -3744,7 +3755,8 @@ var Builder = class {
3744
3755
  if (!this.context) return this.setupContext({
3745
3756
  configPath,
3746
3757
  cwd: options.cwd,
3747
- dev: options.dev
3758
+ dev: options.dev,
3759
+ atomOrigins: options.atomOrigins
3748
3760
  });
3749
3761
  const ctx = this.getContextOrThrow();
3750
3762
  const previousExplicitDeps = [...ctx.explicitDeps];
@@ -3780,6 +3792,7 @@ var Builder = class {
3780
3792
  this.context = new BambooContext(conf);
3781
3793
  });
3782
3794
  const nextContext = this.getContextOrThrow();
3795
+ nextContext.encoder.recordOrigins = Boolean(options.atomOrigins);
3783
3796
  if (options.sourceChanges?.needsConfigReload) {
3784
3797
  const { cwd: configCwd, dependencies } = nextContext.config;
3785
3798
  nextContext.explicitDeps = dependencies ? nextContext.runtime.fs.glob({
@@ -4002,6 +4015,7 @@ var Builder = class {
4002
4015
  cwd,
4003
4016
  dev
4004
4017
  });
4018
+ ctx.encoder.recordOrigins = Boolean(options.atomOrigins);
4005
4019
  this.recordConfigDependencies(ctx, cwd);
4006
4020
  this.context = ctx;
4007
4021
  this.tsconfigResolutionFiles = ctx.diff.getResolutionConfigFiles();
@@ -4184,6 +4198,12 @@ var Builder = class {
4184
4198
  });
4185
4199
  return ctx.getCss(sheet);
4186
4200
  };
4201
+ /**
4202
+ * Each atom's first call site, by class name, as recorded by the last `extract`.
4203
+ *
4204
+ * Empty unless `setup` was asked for `atomOrigins`.
4205
+ */
4206
+ getAtomOrigins = () => this.getContextOrThrow().getAtomOrigins();
4187
4207
  };
4188
4208
  //#endregion
4189
4209
  //#region src/cpu-profile.ts
package/dist/index.d.cts CHANGED
@@ -952,6 +952,8 @@ interface BuilderSetupOptions {
952
952
  configPath?: string;
953
953
  cwd?: string;
954
954
  dev?: boolean;
955
+ /** Record each atom's first call site during extraction, for `getAtomOrigins`. */
956
+ atomOrigins?: boolean;
955
957
  /** A watcher-owned change journal. Without one, Builder performs its standalone filesystem scan. */
956
958
  sourceChanges?: BuilderSourceChanges;
957
959
  }
@@ -1022,7 +1024,15 @@ declare class Builder {
1022
1024
  getResolutionReadFiles: () => readonly string[];
1023
1025
  /** @internal The inventory reconciled by the most recent extraction pass. */
1024
1026
  getSourceFiles: () => readonly string[];
1025
- /** @internal Whether creating this path can change source or explicit-dependency membership. */
1027
+ /** The compiled `include`/`exclude` matcher of each context, since the compiler asks per module. */
1028
+ private sourceMatchers;
1029
+ /**
1030
+ * @internal Whether this path is one `include` covers and `exclude` does not.
1031
+ *
1032
+ * What decides source membership when a file appears, and what the Vite compiler asks of
1033
+ * every module it is handed: a module outside the extraction inventory yields no rule, so
1034
+ * compiling it is wasted — and with the TypeScript 7 backend, far from free.
1035
+ */
1026
1036
  isPotentialSourceFile: (filePath: string) => boolean;
1027
1037
  /** @internal Whether creating or deleting this path can change a `dependencies` glob. */
1028
1038
  isPotentialConfigDependency: (filePath: string) => boolean;
@@ -1108,6 +1118,12 @@ declare class Builder {
1108
1118
  }?: {
1109
1119
  layerParams?: boolean;
1110
1120
  }) => string;
1121
+ /**
1122
+ * Each atom's first call site, by class name, as recorded by the last `extract`.
1123
+ *
1124
+ * Empty unless `setup` was asked for `atomOrigins`.
1125
+ */
1126
+ getAtomOrigins: () => Map<string, import("@bamboocss/core").AtomOrigin>;
1111
1127
  }
1112
1128
  interface FileMeta {
1113
1129
  mtime: number;
@@ -1116,6 +1132,8 @@ interface FileMeta {
1116
1132
  interface SetupContextOptions {
1117
1133
  configPath: string;
1118
1134
  cwd?: string;
1135
+ /** @see `BuilderSetupOptions.atomOrigins` */
1136
+ atomOrigins?: boolean;
1119
1137
  /** Set by the integration; only a dev server knows it is one. @see `hash: 'auto'` */
1120
1138
  dev?: boolean;
1121
1139
  }
package/dist/index.d.mts CHANGED
@@ -952,6 +952,8 @@ interface BuilderSetupOptions {
952
952
  configPath?: string;
953
953
  cwd?: string;
954
954
  dev?: boolean;
955
+ /** Record each atom's first call site during extraction, for `getAtomOrigins`. */
956
+ atomOrigins?: boolean;
955
957
  /** A watcher-owned change journal. Without one, Builder performs its standalone filesystem scan. */
956
958
  sourceChanges?: BuilderSourceChanges;
957
959
  }
@@ -1022,7 +1024,15 @@ declare class Builder {
1022
1024
  getResolutionReadFiles: () => readonly string[];
1023
1025
  /** @internal The inventory reconciled by the most recent extraction pass. */
1024
1026
  getSourceFiles: () => readonly string[];
1025
- /** @internal Whether creating this path can change source or explicit-dependency membership. */
1027
+ /** The compiled `include`/`exclude` matcher of each context, since the compiler asks per module. */
1028
+ private sourceMatchers;
1029
+ /**
1030
+ * @internal Whether this path is one `include` covers and `exclude` does not.
1031
+ *
1032
+ * What decides source membership when a file appears, and what the Vite compiler asks of
1033
+ * every module it is handed: a module outside the extraction inventory yields no rule, so
1034
+ * compiling it is wasted — and with the TypeScript 7 backend, far from free.
1035
+ */
1026
1036
  isPotentialSourceFile: (filePath: string) => boolean;
1027
1037
  /** @internal Whether creating or deleting this path can change a `dependencies` glob. */
1028
1038
  isPotentialConfigDependency: (filePath: string) => boolean;
@@ -1108,6 +1118,12 @@ declare class Builder {
1108
1118
  }?: {
1109
1119
  layerParams?: boolean;
1110
1120
  }) => string;
1121
+ /**
1122
+ * Each atom's first call site, by class name, as recorded by the last `extract`.
1123
+ *
1124
+ * Empty unless `setup` was asked for `atomOrigins`.
1125
+ */
1126
+ getAtomOrigins: () => Map<string, import("@bamboocss/core").AtomOrigin>;
1111
1127
  }
1112
1128
  interface FileMeta {
1113
1129
  mtime: number;
@@ -1116,6 +1132,8 @@ interface FileMeta {
1116
1132
  interface SetupContextOptions {
1117
1133
  configPath: string;
1118
1134
  cwd?: string;
1135
+ /** @see `BuilderSetupOptions.atomOrigins` */
1136
+ atomOrigins?: boolean;
1119
1137
  /** Set by the integration; only a dev server knows it is one. @see `hash: 'auto'` */
1120
1138
  dev?: boolean;
1121
1139
  }
package/dist/index.mjs CHANGED
@@ -3684,13 +3684,24 @@ var Builder = class {
3684
3684
  };
3685
3685
  /** @internal The inventory reconciled by the most recent extraction pass. */
3686
3686
  getSourceFiles = () => Object.freeze([...this.sourceInventory ?? []]);
3687
- /** @internal Whether creating this path can change source or explicit-dependency membership. */
3687
+ /** The compiled `include`/`exclude` matcher of each context, since the compiler asks per module. */
3688
+ sourceMatchers = /* @__PURE__ */ new WeakMap();
3689
+ /**
3690
+ * @internal Whether this path is one `include` covers and `exclude` does not.
3691
+ *
3692
+ * What decides source membership when a file appears, and what the Vite compiler asks of
3693
+ * every module it is handed: a module outside the extraction inventory yields no rule, so
3694
+ * compiling it is wasted — and with the TypeScript 7 backend, far from free.
3695
+ */
3688
3696
  isPotentialSourceFile = (filePath) => {
3689
3697
  const ctx = this.getContextOrThrow();
3690
3698
  const absolutePath = this.absOwner(ctx, filePath);
3691
3699
  const relativePath = this.sourcePath(ctx.runtime.path.relative(ctx.config.cwd, absolutePath));
3692
- const sourcePatterns = ctx.config.include ?? [];
3693
- const sourceMatcher = sourcePatterns.length ? picomatch(sourcePatterns, { ignore: globIgnore(ctx.config.exclude) }) : void 0;
3700
+ if (!this.sourceMatchers.has(ctx)) {
3701
+ const sourcePatterns = ctx.config.include ?? [];
3702
+ this.sourceMatchers.set(ctx, sourcePatterns.length ? picomatch(sourcePatterns, { ignore: globIgnore(ctx.config.exclude) }) : void 0);
3703
+ }
3704
+ const sourceMatcher = this.sourceMatchers.get(ctx);
3694
3705
  return sourceMatcher?.(relativePath) || sourceMatcher?.(absolutePath) || false;
3695
3706
  };
3696
3707
  /** @internal Whether creating or deleting this path can change a `dependencies` glob. */
@@ -3732,7 +3743,8 @@ var Builder = class {
3732
3743
  if (!this.context) return this.setupContext({
3733
3744
  configPath,
3734
3745
  cwd: options.cwd,
3735
- dev: options.dev
3746
+ dev: options.dev,
3747
+ atomOrigins: options.atomOrigins
3736
3748
  });
3737
3749
  const ctx = this.getContextOrThrow();
3738
3750
  const previousExplicitDeps = [...ctx.explicitDeps];
@@ -3768,6 +3780,7 @@ var Builder = class {
3768
3780
  this.context = new BambooContext(conf);
3769
3781
  });
3770
3782
  const nextContext = this.getContextOrThrow();
3783
+ nextContext.encoder.recordOrigins = Boolean(options.atomOrigins);
3771
3784
  if (options.sourceChanges?.needsConfigReload) {
3772
3785
  const { cwd: configCwd, dependencies } = nextContext.config;
3773
3786
  nextContext.explicitDeps = dependencies ? nextContext.runtime.fs.glob({
@@ -3990,6 +4003,7 @@ var Builder = class {
3990
4003
  cwd,
3991
4004
  dev
3992
4005
  });
4006
+ ctx.encoder.recordOrigins = Boolean(options.atomOrigins);
3993
4007
  this.recordConfigDependencies(ctx, cwd);
3994
4008
  this.context = ctx;
3995
4009
  this.tsconfigResolutionFiles = ctx.diff.getResolutionConfigFiles();
@@ -4172,6 +4186,12 @@ var Builder = class {
4172
4186
  });
4173
4187
  return ctx.getCss(sheet);
4174
4188
  };
4189
+ /**
4190
+ * Each atom's first call site, by class name, as recorded by the last `extract`.
4191
+ *
4192
+ * Empty unless `setup` was asked for `atomOrigins`.
4193
+ */
4194
+ getAtomOrigins = () => this.getContextOrThrow().getAtomOrigins();
4175
4195
  };
4176
4196
  //#endregion
4177
4197
  //#region src/cpu-profile.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/node",
3
- "version": "1.53.0",
3
+ "version": "1.54.0",
4
4
  "description": "The core css bamboo library",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -61,18 +61,18 @@
61
61
  "pkg-types": "2.3.0",
62
62
  "pluralize": "8.0.0",
63
63
  "ts-pattern": "5.9.0",
64
- "@bamboocss/config": "1.53.0",
65
- "@bamboocss/core": "1.53.0",
66
- "@bamboocss/generator": "1.53.0",
67
- "@bamboocss/logger": "1.53.0",
68
- "@bamboocss/parser": "1.53.0",
69
- "@bamboocss/plugin-svelte": "1.53.0",
70
- "@bamboocss/plugin-vue": "1.53.0",
71
- "@bamboocss/reporter": "1.53.0",
72
- "@bamboocss/shared": "1.53.0",
73
- "@bamboocss/token-dictionary": "1.53.0",
74
- "@bamboocss/ts-ast": "1.53.0",
75
- "@bamboocss/types": "1.53.0"
64
+ "@bamboocss/config": "1.54.0",
65
+ "@bamboocss/core": "1.54.0",
66
+ "@bamboocss/generator": "1.54.0",
67
+ "@bamboocss/logger": "1.54.0",
68
+ "@bamboocss/parser": "1.54.0",
69
+ "@bamboocss/plugin-svelte": "1.54.0",
70
+ "@bamboocss/plugin-vue": "1.54.0",
71
+ "@bamboocss/reporter": "1.54.0",
72
+ "@bamboocss/shared": "1.54.0",
73
+ "@bamboocss/token-dictionary": "1.54.0",
74
+ "@bamboocss/ts-ast": "1.54.0",
75
+ "@bamboocss/types": "1.54.0"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@types/fs-extra": "11.0.4",