@bamboocss/node 1.64.4 → 1.64.6

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
@@ -1434,33 +1434,6 @@ const EXTENSIONS = [
1434
1434
  ".mjs",
1435
1435
  ".cjs"
1436
1436
  ];
1437
- /** What a `.js`-family specifier may actually name, source first. */
1438
- const EMITTED = [
1439
- [".js", [
1440
- ".ts",
1441
- ".tsx",
1442
- ".d.ts",
1443
- ".js",
1444
- ".jsx"
1445
- ]],
1446
- [".jsx", [
1447
- ".tsx",
1448
- ".ts",
1449
- ".d.ts",
1450
- ".jsx",
1451
- ".js"
1452
- ]],
1453
- [".mjs", [
1454
- ".mts",
1455
- ".d.mts",
1456
- ".mjs"
1457
- ]],
1458
- [".cjs", [
1459
- ".cts",
1460
- ".d.cts",
1461
- ".cjs"
1462
- ]]
1463
- ];
1464
1437
  /** Every specifier in a source, or `undefined` when the text could not be scanned at all. */
1465
1438
  const scanSpecifiers = (text) => {
1466
1439
  const found = [];
@@ -1487,8 +1460,7 @@ const trimmed = (path) => {
1487
1460
  const resolveSlashed = (base, path) => trimmed(absolute(path) ? slash(path) : node_path.posix.join(base, slash(path)));
1488
1461
  /** A candidate path with every extension a specifier may have omitted. */
1489
1462
  const candidatesFor = (base) => {
1490
- const emitted = EMITTED.find(([suffix]) => base.endsWith(suffix));
1491
- return [...emitted ? emitted[1].map((extension) => base.slice(0, -emitted[0].length) + extension) : [base, ...EXTENSIONS.map((extension) => base + extension)], ...EXTENSIONS.map((extension) => `${base}/index${extension}`)];
1463
+ return [...(0, _bamboocss_shared.emittedModuleCandidates)(base) ?? [base, ...EXTENSIONS.map((extension) => base + extension)], ...EXTENSIONS.map((extension) => `${base}/index${extension}`)];
1492
1464
  };
1493
1465
  /**
1494
1466
  * Where a specifier points, when that is somewhere inside the project.
@@ -4212,7 +4184,6 @@ var BambooContext = class extends _bamboocss_generator.Generator {
4212
4184
  pattern,
4213
4185
  paths: values
4214
4186
  })),
4215
- tokens: this.nativeTokens,
4216
4187
  cssModules: this.imports.value.css,
4217
4188
  tokenModules: this.imports.value.tokens,
4218
4189
  recipeModules: this.imports.value.recipe,
@@ -4221,21 +4192,24 @@ var BambooContext = class extends _bamboocss_generator.Generator {
4221
4192
  patternNames: this.patterns.keys,
4222
4193
  references: options.references,
4223
4194
  classPrefix: this.utility.prefix || void 0
4224
- });
4195
+ }, this.nativeTokens);
4225
4196
  };
4226
4197
  /**
4227
- * The token table as the native evaluator reads it.
4198
+ * The token table as the native evaluator reads it, converted into the native engine once per
4199
+ * context and handed to each call from then on.
4228
4200
  *
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()`.
4201
+ * `compileModules` runs once per transformed module, and the table is every token in the
4202
+ * project. Rebuilding it priced the whole dictionary into every file, most of which never call
4203
+ * `token()`, and so did handing it over built: each call converted it into Rust again, about
4204
+ * 0.44 µs a token — 0.9 ms a module under `preset-atlaskit`'s 1,655 tokens, several times what
4205
+ * analyzing most modules takes.
4232
4206
  */
4233
4207
  get nativeTokens() {
4234
- this.nativeTokenTable ??= this.tokens.allTokens.map((token) => ({
4208
+ this.nativeTokenTable ??= this.loadNativeExtractor().tokenTable(this.tokens.allTokens.map((token) => ({
4235
4209
  path: token.name,
4236
4210
  value: this.tokens.view.get(token.name),
4237
4211
  variable: this.tokens.view.getVar(token.name)
4238
- }));
4212
+ })));
4239
4213
  return this.nativeTokenTable;
4240
4214
  }
4241
4215
  nativeTokenTable;
@@ -4401,13 +4375,12 @@ var BambooContext = class extends _bamboocss_generator.Generator {
4401
4375
  pattern,
4402
4376
  paths: values
4403
4377
  })),
4404
- tokens: this.nativeTokens,
4405
4378
  jsx: this.jsx.isEnabled,
4406
4379
  classPrefix: this.utility.prefix || void 0
4407
4380
  };
4408
4381
  let analyses;
4409
4382
  try {
4410
- analyses = this.loadNativeExtractor().analyzeMany(sources, entrypoints, options);
4383
+ analyses = this.loadNativeExtractor().analyzeMany(sources, entrypoints, options, this.nativeTokens);
4411
4384
  } finally {
4412
4385
  this.nativePreparedSources.clear();
4413
4386
  }
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;
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;
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { isStaticCompilerActive, markStaticCompilerActive } from "./static-compi
2
2
  import { createRequire } from "node:module";
3
3
  import { colors, logger, quote } from "@bamboocss/logger";
4
4
  import { checkNamingAgreement, formatNamingDisagreement, messages, prunesPreflight } from "@bamboocss/core";
5
- import { BambooError, cssVarRefs, getOrCreateSet, groupBy, truncateList, uniq } from "@bamboocss/shared";
5
+ import { BambooError, cssVarRefs, emittedModuleCandidates, getOrCreateSet, groupBy, truncateList, uniq } from "@bamboocss/shared";
6
6
  import { isMatch } from "matcher";
7
7
  import fs, { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";
8
8
  import { changesEveryArtifact, convertTsPathsToRegexes, diffConfigs, filesReadBy, findConfig, getConfigDependencies, loadConfig, mergeHooks } from "@bamboocss/config";
@@ -1423,33 +1423,6 @@ const EXTENSIONS = [
1423
1423
  ".mjs",
1424
1424
  ".cjs"
1425
1425
  ];
1426
- /** What a `.js`-family specifier may actually name, source first. */
1427
- const EMITTED = [
1428
- [".js", [
1429
- ".ts",
1430
- ".tsx",
1431
- ".d.ts",
1432
- ".js",
1433
- ".jsx"
1434
- ]],
1435
- [".jsx", [
1436
- ".tsx",
1437
- ".ts",
1438
- ".d.ts",
1439
- ".jsx",
1440
- ".js"
1441
- ]],
1442
- [".mjs", [
1443
- ".mts",
1444
- ".d.mts",
1445
- ".mjs"
1446
- ]],
1447
- [".cjs", [
1448
- ".cts",
1449
- ".d.cts",
1450
- ".cjs"
1451
- ]]
1452
- ];
1453
1426
  /** Every specifier in a source, or `undefined` when the text could not be scanned at all. */
1454
1427
  const scanSpecifiers = (text) => {
1455
1428
  const found = [];
@@ -1476,8 +1449,7 @@ const trimmed = (path) => {
1476
1449
  const resolveSlashed = (base, path) => trimmed(absolute(path) ? slash(path) : posix.join(base, slash(path)));
1477
1450
  /** A candidate path with every extension a specifier may have omitted. */
1478
1451
  const candidatesFor = (base) => {
1479
- const emitted = EMITTED.find(([suffix]) => base.endsWith(suffix));
1480
- return [...emitted ? emitted[1].map((extension) => base.slice(0, -emitted[0].length) + extension) : [base, ...EXTENSIONS.map((extension) => base + extension)], ...EXTENSIONS.map((extension) => `${base}/index${extension}`)];
1452
+ return [...emittedModuleCandidates(base) ?? [base, ...EXTENSIONS.map((extension) => base + extension)], ...EXTENSIONS.map((extension) => `${base}/index${extension}`)];
1481
1453
  };
1482
1454
  /**
1483
1455
  * Where a specifier points, when that is somewhere inside the project.
@@ -4201,7 +4173,6 @@ var BambooContext = class extends Generator {
4201
4173
  pattern,
4202
4174
  paths: values
4203
4175
  })),
4204
- tokens: this.nativeTokens,
4205
4176
  cssModules: this.imports.value.css,
4206
4177
  tokenModules: this.imports.value.tokens,
4207
4178
  recipeModules: this.imports.value.recipe,
@@ -4210,21 +4181,24 @@ var BambooContext = class extends Generator {
4210
4181
  patternNames: this.patterns.keys,
4211
4182
  references: options.references,
4212
4183
  classPrefix: this.utility.prefix || void 0
4213
- });
4184
+ }, this.nativeTokens);
4214
4185
  };
4215
4186
  /**
4216
- * The token table as the native evaluator reads it.
4187
+ * The token table as the native evaluator reads it, converted into the native engine once per
4188
+ * context and handed to each call from then on.
4217
4189
  *
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()`.
4190
+ * `compileModules` runs once per transformed module, and the table is every token in the
4191
+ * project. Rebuilding it priced the whole dictionary into every file, most of which never call
4192
+ * `token()`, and so did handing it over built: each call converted it into Rust again, about
4193
+ * 0.44 µs a token — 0.9 ms a module under `preset-atlaskit`'s 1,655 tokens, several times what
4194
+ * analyzing most modules takes.
4221
4195
  */
4222
4196
  get nativeTokens() {
4223
- this.nativeTokenTable ??= this.tokens.allTokens.map((token) => ({
4197
+ this.nativeTokenTable ??= this.loadNativeExtractor().tokenTable(this.tokens.allTokens.map((token) => ({
4224
4198
  path: token.name,
4225
4199
  value: this.tokens.view.get(token.name),
4226
4200
  variable: this.tokens.view.getVar(token.name)
4227
- }));
4201
+ })));
4228
4202
  return this.nativeTokenTable;
4229
4203
  }
4230
4204
  nativeTokenTable;
@@ -4390,13 +4364,12 @@ var BambooContext = class extends Generator {
4390
4364
  pattern,
4391
4365
  paths: values
4392
4366
  })),
4393
- tokens: this.nativeTokens,
4394
4367
  jsx: this.jsx.isEnabled,
4395
4368
  classPrefix: this.utility.prefix || void 0
4396
4369
  };
4397
4370
  let analyses;
4398
4371
  try {
4399
- analyses = this.loadNativeExtractor().analyzeMany(sources, entrypoints, options);
4372
+ analyses = this.loadNativeExtractor().analyzeMany(sources, entrypoints, options, this.nativeTokens);
4400
4373
  } finally {
4401
4374
  this.nativePreparedSources.clear();
4402
4375
  }
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.4",
3
+ "version": "1.64.6",
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.4",
63
- "@bamboocss/core": "1.64.4",
64
- "@bamboocss/generator": "1.64.4",
65
- "@bamboocss/logger": "1.64.4",
66
- "@bamboocss/plugin-svelte": "1.64.4",
67
- "@bamboocss/plugin-vue": "1.64.4",
68
- "@bamboocss/reporter": "1.64.4",
69
- "@bamboocss/shared": "1.64.4",
70
- "@bamboocss/token-dictionary": "1.64.4",
71
- "@bamboocss/types": "1.64.4"
62
+ "@bamboocss/config": "1.64.6",
63
+ "@bamboocss/core": "1.64.6",
64
+ "@bamboocss/generator": "1.64.6",
65
+ "@bamboocss/logger": "1.64.6",
66
+ "@bamboocss/plugin-svelte": "1.64.6",
67
+ "@bamboocss/plugin-vue": "1.64.6",
68
+ "@bamboocss/reporter": "1.64.6",
69
+ "@bamboocss/shared": "1.64.6",
70
+ "@bamboocss/token-dictionary": "1.64.6",
71
+ "@bamboocss/types": "1.64.6"
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.4"
78
+ "@bamboocss/native-extractor": "1.64.6"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "@astrojs/compiler": ">=2",