@bamboocss/node 1.64.3 → 1.64.5

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
@@ -4212,7 +4212,6 @@ var BambooContext = class extends _bamboocss_generator.Generator {
4212
4212
  pattern,
4213
4213
  paths: values
4214
4214
  })),
4215
- tokens: this.nativeTokens,
4216
4215
  cssModules: this.imports.value.css,
4217
4216
  tokenModules: this.imports.value.tokens,
4218
4217
  recipeModules: this.imports.value.recipe,
@@ -4221,21 +4220,24 @@ var BambooContext = class extends _bamboocss_generator.Generator {
4221
4220
  patternNames: this.patterns.keys,
4222
4221
  references: options.references,
4223
4222
  classPrefix: this.utility.prefix || void 0
4224
- });
4223
+ }, this.nativeTokens);
4225
4224
  };
4226
4225
  /**
4227
- * The token table as the native evaluator reads it.
4226
+ * The token table as the native evaluator reads it, converted into the native engine once per
4227
+ * context and handed to each call from then on.
4228
4228
  *
4229
- * Built once per context rather than per call: `compileModules` runs once per transformed
4230
- * module, and the table is every token in the project — rebuilding it priced the whole
4231
- * dictionary into every file, most of which never call `token()`.
4229
+ * `compileModules` runs once per transformed module, and the table is every token in the
4230
+ * project. Rebuilding it priced the whole dictionary into every file, most of which never call
4231
+ * `token()`, and so did handing it over built: each call converted it into Rust again, about
4232
+ * 0.44 µs a token — 0.9 ms a module under `preset-atlaskit`'s 1,655 tokens, several times what
4233
+ * analyzing most modules takes.
4232
4234
  */
4233
4235
  get nativeTokens() {
4234
- this.nativeTokenTable ??= this.tokens.allTokens.map((token) => ({
4236
+ this.nativeTokenTable ??= this.loadNativeExtractor().tokenTable(this.tokens.allTokens.map((token) => ({
4235
4237
  path: token.name,
4236
4238
  value: this.tokens.view.get(token.name),
4237
4239
  variable: this.tokens.view.getVar(token.name)
4238
- }));
4240
+ })));
4239
4241
  return this.nativeTokenTable;
4240
4242
  }
4241
4243
  nativeTokenTable;
@@ -4401,13 +4403,12 @@ var BambooContext = class extends _bamboocss_generator.Generator {
4401
4403
  pattern,
4402
4404
  paths: values
4403
4405
  })),
4404
- tokens: this.nativeTokens,
4405
4406
  jsx: this.jsx.isEnabled,
4406
4407
  classPrefix: this.utility.prefix || void 0
4407
4408
  };
4408
4409
  let analyses;
4409
4410
  try {
4410
- analyses = this.loadNativeExtractor().analyzeMany(sources, entrypoints, options);
4411
+ analyses = this.loadNativeExtractor().analyzeMany(sources, entrypoints, options, this.nativeTokens);
4411
4412
  } finally {
4412
4413
  this.nativePreparedSources.clear();
4413
4414
  }
@@ -5685,6 +5686,48 @@ var Builder = class {
5685
5686
  const bases = this.includeBases(ctx);
5686
5687
  return this.sourcePathsOf(absolutePath).some((source) => bases.some((base) => source === base.path || source.startsWith(base.prefix)) && isSource(this.sourcePath(ctx.runtime.path.relative(ctx.config.cwd, source))));
5687
5688
  };
5689
+ /** The packages the inventory holds files of, by name, for one inventory. @see isSourcePackage */
5690
+ sourcePackages;
5691
+ /**
5692
+ * @internal Whether a package is one the inventory holds files of — a workspace package `include`
5693
+ * reaches, such as a design system imported as `@acme/ds`. `true` before an inventory exists.
5694
+ *
5695
+ * What the Vite compiler asks of a module importing a package by name. A published package ships
5696
+ * its own output, but a call into this one folds against its source, and the compiled source no
5697
+ * longer defines what a module left uncompiled would call. Named as a workspace links a package:
5698
+ * by the nearest `package.json` above each file that has a name.
5699
+ */
5700
+ isSourcePackage = (name) => {
5701
+ const ctx = this.getContextOrThrow();
5702
+ const inventory = this.sourceInventory;
5703
+ if (!inventory) return true;
5704
+ if (this.sourcePackages?.inventory !== inventory) {
5705
+ const nameByDirectory = /* @__PURE__ */ new Map();
5706
+ const packageNameOf = (directory) => {
5707
+ if (nameByDirectory.has(directory)) return nameByDirectory.get(directory);
5708
+ let packageName;
5709
+ const manifest = (0, node_path.resolve)(directory, "package.json");
5710
+ if ((0, node_fs.existsSync)(manifest)) try {
5711
+ const parsed = JSON.parse((0, node_fs.readFileSync)(manifest, "utf8"));
5712
+ if (typeof parsed.name === "string") packageName = parsed.name;
5713
+ } catch {}
5714
+ const parent = (0, node_path.dirname)(directory);
5715
+ if (packageName === void 0 && parent !== directory) packageName = packageNameOf(parent);
5716
+ nameByDirectory.set(directory, packageName);
5717
+ return packageName;
5718
+ };
5719
+ const names = /* @__PURE__ */ new Set();
5720
+ for (const file of inventory) {
5721
+ const packageName = packageNameOf((0, node_path.dirname)(this.absOwner(ctx, file)));
5722
+ if (packageName) names.add(packageName);
5723
+ }
5724
+ this.sourcePackages = {
5725
+ inventory,
5726
+ names
5727
+ };
5728
+ }
5729
+ return this.sourcePackages.names.has(name);
5730
+ };
5688
5731
  /** The folders each context's `include` is globbed from. @see isPotentialSourceFile */
5689
5732
  includeBaseCache = /* @__PURE__ */ new WeakMap();
5690
5733
  includeBases = (ctx) => {
package/dist/index.d.cts CHANGED
@@ -70,6 +70,11 @@ interface FoldCxArgument {
70
70
  /** For an argument of the call itself: it reads a Bamboo binding or a recipe, so it cannot be copied. */
71
71
  readsBamboo: boolean;
72
72
  }
73
+ interface FoldStyleBranch {
74
+ test: FoldSpan;
75
+ consequent: Record<string, unknown>;
76
+ alternate: Record<string, unknown>;
77
+ }
73
78
  interface FoldCall {
74
79
  name: string;
75
80
  kind: 'css' | 'pattern' | 'recipe' | 'token' | 'tokenValue' | 'viewTransition' | 'keyframes' | 'cva-call' | 'cva' | 'sva' | 'cx';
@@ -82,6 +87,8 @@ interface FoldCall {
82
87
  calleeProperty?: string;
83
88
  data: unknown[];
84
89
  exact: boolean;
90
+ /** Two exact `css()` style objects chosen by the test at the call site. */
91
+ styleBranch?: FoldStyleBranch;
85
92
  /** Why the call is not exact, when the evaluator refused code it does not run. */
86
93
  refusal?: FoldRefusal;
87
94
  argumentCount: number;
@@ -102,7 +109,7 @@ interface FoldCall {
102
109
  */
103
110
  guarded: boolean;
104
111
  /**
105
- * A `token.value()` or `cx()` call written first in an expression statement. What replaces it there
112
+ * A `token.value()`, `cx()`, or conditional `css()` call written first in an expression statement. What replaces it there
106
113
  * cannot open with `(` or `-`, which would continue the line before it where that line has no
107
114
  * semicolon.
108
115
  */
@@ -117,10 +124,12 @@ interface FoldCall {
117
124
  * than it follows, `module` when the helper is called again through another module while it runs;
118
125
  * `helper` and the location are the recursive helper: for `loop` the first to run of those its
119
126
  * cycle goes through, for `calls` the same of the cycle the innermost recurring call closes, for
120
- * `depth` the one most of the calls running are of. `line` is 1-based; `column` too, in UTF-16.
127
+ * `depth` the one most of the calls running are of. `compiled`: a call the compiler replaces,
128
+ * `css()` or a recipe, whose value only it knows — `subject` is the name it imports, `excerpt` and
129
+ * the location the call. `line` is 1-based; `column` too, in UTF-16.
121
130
  */
122
131
  interface FoldRefusal {
123
- kind: 'statement' | 'write' | 'recursion';
132
+ kind: 'statement' | 'write' | 'recursion' | 'compiled';
124
133
  subject: string;
125
134
  helper?: string;
126
135
  excerpt: string;
@@ -688,11 +697,14 @@ declare class BambooContext extends Generator {
688
697
  references: boolean;
689
698
  }) => FoldAnalysis[];
690
699
  /**
691
- * The token table as the native evaluator reads it.
700
+ * The token table as the native evaluator reads it, converted into the native engine once per
701
+ * context and handed to each call from then on.
692
702
  *
693
- * Built once per context rather than per call: `compileModules` runs once per transformed
694
- * module, and the table is every token in the project — rebuilding it priced the whole
695
- * dictionary into every file, most of which never call `token()`.
703
+ * `compileModules` runs once per transformed module, and the table is every token in the
704
+ * project. Rebuilding it priced the whole dictionary into every file, most of which never call
705
+ * `token()`, and so did handing it over built: each call converted it into Rust again, about
706
+ * 0.44 µs a token — 0.9 ms a module under `preset-atlaskit`'s 1,655 tokens, several times what
707
+ * analyzing most modules takes.
696
708
  */
697
709
  private get nativeTokens();
698
710
  private nativeTokenTable;
@@ -950,6 +962,18 @@ declare class Builder {
950
962
  * compiling it is wasted — and with the TypeScript 7 backend, far from free.
951
963
  */
952
964
  isPotentialSourceFile: (filePath: string) => boolean;
965
+ /** The packages the inventory holds files of, by name, for one inventory. @see isSourcePackage */
966
+ private sourcePackages;
967
+ /**
968
+ * @internal Whether a package is one the inventory holds files of — a workspace package `include`
969
+ * reaches, such as a design system imported as `@acme/ds`. `true` before an inventory exists.
970
+ *
971
+ * What the Vite compiler asks of a module importing a package by name. A published package ships
972
+ * its own output, but a call into this one folds against its source, and the compiled source no
973
+ * longer defines what a module left uncompiled would call. Named as a workspace links a package:
974
+ * by the nearest `package.json` above each file that has a name.
975
+ */
976
+ isSourcePackage: (name: string) => boolean;
953
977
  /** The folders each context's `include` is globbed from. @see isPotentialSourceFile */
954
978
  private includeBaseCache;
955
979
  private includeBases;
package/dist/index.d.mts CHANGED
@@ -70,6 +70,11 @@ interface FoldCxArgument {
70
70
  /** For an argument of the call itself: it reads a Bamboo binding or a recipe, so it cannot be copied. */
71
71
  readsBamboo: boolean;
72
72
  }
73
+ interface FoldStyleBranch {
74
+ test: FoldSpan;
75
+ consequent: Record<string, unknown>;
76
+ alternate: Record<string, unknown>;
77
+ }
73
78
  interface FoldCall {
74
79
  name: string;
75
80
  kind: 'css' | 'pattern' | 'recipe' | 'token' | 'tokenValue' | 'viewTransition' | 'keyframes' | 'cva-call' | 'cva' | 'sva' | 'cx';
@@ -82,6 +87,8 @@ interface FoldCall {
82
87
  calleeProperty?: string;
83
88
  data: unknown[];
84
89
  exact: boolean;
90
+ /** Two exact `css()` style objects chosen by the test at the call site. */
91
+ styleBranch?: FoldStyleBranch;
85
92
  /** Why the call is not exact, when the evaluator refused code it does not run. */
86
93
  refusal?: FoldRefusal;
87
94
  argumentCount: number;
@@ -102,7 +109,7 @@ interface FoldCall {
102
109
  */
103
110
  guarded: boolean;
104
111
  /**
105
- * A `token.value()` or `cx()` call written first in an expression statement. What replaces it there
112
+ * A `token.value()`, `cx()`, or conditional `css()` call written first in an expression statement. What replaces it there
106
113
  * cannot open with `(` or `-`, which would continue the line before it where that line has no
107
114
  * semicolon.
108
115
  */
@@ -117,10 +124,12 @@ interface FoldCall {
117
124
  * than it follows, `module` when the helper is called again through another module while it runs;
118
125
  * `helper` and the location are the recursive helper: for `loop` the first to run of those its
119
126
  * cycle goes through, for `calls` the same of the cycle the innermost recurring call closes, for
120
- * `depth` the one most of the calls running are of. `line` is 1-based; `column` too, in UTF-16.
127
+ * `depth` the one most of the calls running are of. `compiled`: a call the compiler replaces,
128
+ * `css()` or a recipe, whose value only it knows — `subject` is the name it imports, `excerpt` and
129
+ * the location the call. `line` is 1-based; `column` too, in UTF-16.
121
130
  */
122
131
  interface FoldRefusal {
123
- kind: 'statement' | 'write' | 'recursion';
132
+ kind: 'statement' | 'write' | 'recursion' | 'compiled';
124
133
  subject: string;
125
134
  helper?: string;
126
135
  excerpt: string;
@@ -688,11 +697,14 @@ declare class BambooContext extends Generator {
688
697
  references: boolean;
689
698
  }) => FoldAnalysis[];
690
699
  /**
691
- * The token table as the native evaluator reads it.
700
+ * The token table as the native evaluator reads it, converted into the native engine once per
701
+ * context and handed to each call from then on.
692
702
  *
693
- * Built once per context rather than per call: `compileModules` runs once per transformed
694
- * module, and the table is every token in the project — rebuilding it priced the whole
695
- * dictionary into every file, most of which never call `token()`.
703
+ * `compileModules` runs once per transformed module, and the table is every token in the
704
+ * project. Rebuilding it priced the whole dictionary into every file, most of which never call
705
+ * `token()`, and so did handing it over built: each call converted it into Rust again, about
706
+ * 0.44 µs a token — 0.9 ms a module under `preset-atlaskit`'s 1,655 tokens, several times what
707
+ * analyzing most modules takes.
696
708
  */
697
709
  private get nativeTokens();
698
710
  private nativeTokenTable;
@@ -950,6 +962,18 @@ declare class Builder {
950
962
  * compiling it is wasted — and with the TypeScript 7 backend, far from free.
951
963
  */
952
964
  isPotentialSourceFile: (filePath: string) => boolean;
965
+ /** The packages the inventory holds files of, by name, for one inventory. @see isSourcePackage */
966
+ private sourcePackages;
967
+ /**
968
+ * @internal Whether a package is one the inventory holds files of — a workspace package `include`
969
+ * reaches, such as a design system imported as `@acme/ds`. `true` before an inventory exists.
970
+ *
971
+ * What the Vite compiler asks of a module importing a package by name. A published package ships
972
+ * its own output, but a call into this one folds against its source, and the compiled source no
973
+ * longer defines what a module left uncompiled would call. Named as a workspace links a package:
974
+ * by the nearest `package.json` above each file that has a name.
975
+ */
976
+ isSourcePackage: (name: string) => boolean;
953
977
  /** The folders each context's `include` is globbed from. @see isPotentialSourceFile */
954
978
  private includeBaseCache;
955
979
  private includeBases;
package/dist/index.mjs CHANGED
@@ -4201,7 +4201,6 @@ var BambooContext = class extends Generator {
4201
4201
  pattern,
4202
4202
  paths: values
4203
4203
  })),
4204
- tokens: this.nativeTokens,
4205
4204
  cssModules: this.imports.value.css,
4206
4205
  tokenModules: this.imports.value.tokens,
4207
4206
  recipeModules: this.imports.value.recipe,
@@ -4210,21 +4209,24 @@ var BambooContext = class extends Generator {
4210
4209
  patternNames: this.patterns.keys,
4211
4210
  references: options.references,
4212
4211
  classPrefix: this.utility.prefix || void 0
4213
- });
4212
+ }, this.nativeTokens);
4214
4213
  };
4215
4214
  /**
4216
- * The token table as the native evaluator reads it.
4215
+ * The token table as the native evaluator reads it, converted into the native engine once per
4216
+ * context and handed to each call from then on.
4217
4217
  *
4218
- * Built once per context rather than per call: `compileModules` runs once per transformed
4219
- * module, and the table is every token in the project — rebuilding it priced the whole
4220
- * dictionary into every file, most of which never call `token()`.
4218
+ * `compileModules` runs once per transformed module, and the table is every token in the
4219
+ * project. Rebuilding it priced the whole dictionary into every file, most of which never call
4220
+ * `token()`, and so did handing it over built: each call converted it into Rust again, about
4221
+ * 0.44 µs a token — 0.9 ms a module under `preset-atlaskit`'s 1,655 tokens, several times what
4222
+ * analyzing most modules takes.
4221
4223
  */
4222
4224
  get nativeTokens() {
4223
- this.nativeTokenTable ??= this.tokens.allTokens.map((token) => ({
4225
+ this.nativeTokenTable ??= this.loadNativeExtractor().tokenTable(this.tokens.allTokens.map((token) => ({
4224
4226
  path: token.name,
4225
4227
  value: this.tokens.view.get(token.name),
4226
4228
  variable: this.tokens.view.getVar(token.name)
4227
- }));
4229
+ })));
4228
4230
  return this.nativeTokenTable;
4229
4231
  }
4230
4232
  nativeTokenTable;
@@ -4390,13 +4392,12 @@ var BambooContext = class extends Generator {
4390
4392
  pattern,
4391
4393
  paths: values
4392
4394
  })),
4393
- tokens: this.nativeTokens,
4394
4395
  jsx: this.jsx.isEnabled,
4395
4396
  classPrefix: this.utility.prefix || void 0
4396
4397
  };
4397
4398
  let analyses;
4398
4399
  try {
4399
- analyses = this.loadNativeExtractor().analyzeMany(sources, entrypoints, options);
4400
+ analyses = this.loadNativeExtractor().analyzeMany(sources, entrypoints, options, this.nativeTokens);
4400
4401
  } finally {
4401
4402
  this.nativePreparedSources.clear();
4402
4403
  }
@@ -5674,6 +5675,48 @@ var Builder = class {
5674
5675
  const bases = this.includeBases(ctx);
5675
5676
  return this.sourcePathsOf(absolutePath).some((source) => bases.some((base) => source === base.path || source.startsWith(base.prefix)) && isSource(this.sourcePath(ctx.runtime.path.relative(ctx.config.cwd, source))));
5676
5677
  };
5678
+ /** The packages the inventory holds files of, by name, for one inventory. @see isSourcePackage */
5679
+ sourcePackages;
5680
+ /**
5681
+ * @internal Whether a package is one the inventory holds files of — a workspace package `include`
5682
+ * reaches, such as a design system imported as `@acme/ds`. `true` before an inventory exists.
5683
+ *
5684
+ * What the Vite compiler asks of a module importing a package by name. A published package ships
5685
+ * its own output, but a call into this one folds against its source, and the compiled source no
5686
+ * longer defines what a module left uncompiled would call. Named as a workspace links a package:
5687
+ * by the nearest `package.json` above each file that has a name.
5688
+ */
5689
+ isSourcePackage = (name) => {
5690
+ const ctx = this.getContextOrThrow();
5691
+ const inventory = this.sourceInventory;
5692
+ if (!inventory) return true;
5693
+ if (this.sourcePackages?.inventory !== inventory) {
5694
+ const nameByDirectory = /* @__PURE__ */ new Map();
5695
+ const packageNameOf = (directory) => {
5696
+ if (nameByDirectory.has(directory)) return nameByDirectory.get(directory);
5697
+ let packageName;
5698
+ const manifest = resolve(directory, "package.json");
5699
+ if (existsSync(manifest)) try {
5700
+ const parsed = JSON.parse(readFileSync(manifest, "utf8"));
5701
+ if (typeof parsed.name === "string") packageName = parsed.name;
5702
+ } catch {}
5703
+ const parent = dirname(directory);
5704
+ if (packageName === void 0 && parent !== directory) packageName = packageNameOf(parent);
5705
+ nameByDirectory.set(directory, packageName);
5706
+ return packageName;
5707
+ };
5708
+ const names = /* @__PURE__ */ new Set();
5709
+ for (const file of inventory) {
5710
+ const packageName = packageNameOf(dirname(this.absOwner(ctx, file)));
5711
+ if (packageName) names.add(packageName);
5712
+ }
5713
+ this.sourcePackages = {
5714
+ inventory,
5715
+ names
5716
+ };
5717
+ }
5718
+ return this.sourcePackages.names.has(name);
5719
+ };
5677
5720
  /** The folders each context's `include` is globbed from. @see isPotentialSourceFile */
5678
5721
  includeBaseCache = /* @__PURE__ */ new WeakMap();
5679
5722
  includeBases = (ctx) => {
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/node",
3
- "version": "1.64.3",
3
+ "version": "1.64.5",
4
4
  "description": "The core css bamboo library",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -59,23 +59,23 @@
59
59
  "pkg-types": "2.3.0",
60
60
  "pluralize": "8.0.0",
61
61
  "ts-pattern": "5.9.0",
62
- "@bamboocss/config": "1.64.3",
63
- "@bamboocss/core": "1.64.3",
64
- "@bamboocss/generator": "1.64.3",
65
- "@bamboocss/logger": "1.64.3",
66
- "@bamboocss/plugin-svelte": "1.64.3",
67
- "@bamboocss/plugin-vue": "1.64.3",
68
- "@bamboocss/reporter": "1.64.3",
69
- "@bamboocss/shared": "1.64.3",
70
- "@bamboocss/token-dictionary": "1.64.3",
71
- "@bamboocss/types": "1.64.3"
62
+ "@bamboocss/config": "1.64.5",
63
+ "@bamboocss/core": "1.64.5",
64
+ "@bamboocss/generator": "1.64.5",
65
+ "@bamboocss/logger": "1.64.5",
66
+ "@bamboocss/plugin-svelte": "1.64.5",
67
+ "@bamboocss/plugin-vue": "1.64.5",
68
+ "@bamboocss/reporter": "1.64.5",
69
+ "@bamboocss/shared": "1.64.5",
70
+ "@bamboocss/token-dictionary": "1.64.5",
71
+ "@bamboocss/types": "1.64.5"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@astrojs/compiler": "3.0.1",
75
75
  "@astrojs/compiler-rs": "0.5.1",
76
76
  "@types/picomatch": "4.0.2",
77
77
  "boxen": "8.0.1",
78
- "@bamboocss/native-extractor": "1.64.3"
78
+ "@bamboocss/native-extractor": "1.64.5"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "@astrojs/compiler": ">=2",