@bamboocss/node 1.49.0 → 1.50.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
@@ -24,6 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  //#endregion
25
25
  const require_static_compiler = require("./static-compiler.cjs");
26
26
  let _bamboocss_logger = require("@bamboocss/logger");
27
+ let _bamboocss_ts_ast = require("@bamboocss/ts-ast");
27
28
  let _bamboocss_config = require("@bamboocss/config");
28
29
  let _bamboocss_shared = require("@bamboocss/shared");
29
30
  let node_crypto = require("node:crypto");
@@ -47,7 +48,6 @@ let node_fs = require("node:fs");
47
48
  node_fs = __toESM(node_fs);
48
49
  let node_path = require("node:path");
49
50
  node_path = __toESM(node_path);
50
- let ts_morph = require("ts-morph");
51
51
  let chokidar = require("chokidar");
52
52
  chokidar = __toESM(chokidar);
53
53
  let fast_glob = require("fast-glob");
@@ -1671,7 +1671,7 @@ const collectReferenceGraph = async (rootPath, rootParsed, parseTsconfig, cache)
1671
1671
  visited.add(referencedPath);
1672
1672
  try {
1673
1673
  const source = await node_fs.promises.readFile(referencedPath, "utf8");
1674
- if (ts_morph.ts.parseConfigFileTextToJson(referencedPath, source).error) throw new Error("Invalid tsconfig");
1674
+ JSON.parse(source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"));
1675
1675
  queue.push({
1676
1676
  parsed: parseTsconfig(referencedPath, cache),
1677
1677
  path: referencedPath
@@ -1826,6 +1826,21 @@ function globDirname(globs) {
1826
1826
  * mutated.
1827
1827
  */
1828
1828
  const globIgnore = (exclude) => ["**/*.d.ts", ...exclude ?? []];
1829
+ /**
1830
+ * The order the source glob returns files in, made a decision rather than an accident.
1831
+ *
1832
+ * `fast-glob` hands back whatever `readdir` gave it, which is the filesystem's order and is not
1833
+ * the same on every machine. That order is not cosmetic: it is the order atoms enter the sheet,
1834
+ * and sheet order is what decides a conflict between two classes on one element — `cx` joins
1835
+ * them and the browser picks by position, not by the order they were passed. So an unsorted
1836
+ * glob lets two checkouts of the same commit build stylesheets that resolve the same conflict
1837
+ * differently, and makes the emitted bytes irreproducible, which is also what content-hashed
1838
+ * asset caching is keyed on.
1839
+ *
1840
+ * Sorted by code unit rather than `localeCompare`, whose answer depends on the host's locale —
1841
+ * the exact class of machine-dependence this exists to remove.
1842
+ */
1843
+ const sortSources = (files) => files.sort();
1829
1844
  const nodeRuntime = {
1830
1845
  cwd() {
1831
1846
  return process.cwd();
@@ -1852,11 +1867,11 @@ const nodeRuntime = {
1852
1867
  },
1853
1868
  glob(opts) {
1854
1869
  if (!opts.include) return [];
1855
- return fast_glob.default.sync(opts.include, {
1870
+ return sortSources(fast_glob.default.sync(opts.include, {
1856
1871
  cwd: opts.cwd,
1857
1872
  ignore: globIgnore(opts.exclude),
1858
1873
  absolute: true
1859
- });
1874
+ }));
1860
1875
  },
1861
1876
  writeFile: fs_extra.default.writeFile,
1862
1877
  writeFileSync: fs_extra.default.writeFileSync,
@@ -2001,10 +2016,36 @@ var OutputEngine = class {
2001
2016
  const absPath = this.path.join(...dir, file);
2002
2017
  _bamboocss_logger.logger.debug("write:file", dir.slice(-1).concat(file).join("/"));
2003
2018
  if (file === "package.json") return this.writePackageJson(absPath, code);
2019
+ if (this.isUnchanged(absPath, code)) {
2020
+ _bamboocss_logger.logger.debug("write:unchanged", dir.slice(-1).concat(file).join("/"));
2021
+ return;
2022
+ }
2004
2023
  return this.fs.writeFile(absPath, code);
2005
2024
  }));
2006
2025
  };
2007
2026
  /**
2027
+ * Whether the file on disk already holds exactly what codegen would write.
2028
+ *
2029
+ * Not for the write itself, which is cheap — 54 artifacts and 1.4 MB measure ~6ms, against
2030
+ * ~1.3ms to read them back and compare. It is for the mtime. Codegen rewrote every artifact
2031
+ * on every build whether or not a byte moved, and most builds move nothing: `csstype.d.ts` is
2032
+ * copied verbatim from a constant and accounts for 895 kB on its own. Everything downstream
2033
+ * watches those files — the dev server's module graph, `tsc --incremental`, any bundler with
2034
+ * the output directory in scope — and each of them re-does work for a file that is identical
2035
+ * to the one it already read.
2036
+ *
2037
+ * A read that throws is an answer, not a failure: the file is unreadable or absent, so it has
2038
+ * to be written.
2039
+ */
2040
+ isUnchanged = (absPath, code) => {
2041
+ if (!this.fs.existsSync(absPath)) return false;
2042
+ try {
2043
+ return this.fs.readFileSync(absPath) === code;
2044
+ } catch {
2045
+ return false;
2046
+ }
2047
+ };
2048
+ /**
2008
2049
  * Unlike the rest of the output, `package.json` is not exclusively ours: `emit-pkg`
2009
2050
  * writes entrypoints to the same path, and consumers hand-edit it. Overwriting would
2010
2051
  * drop that, so only keys that are absent get filled in — anything already declared,
@@ -2088,6 +2129,9 @@ var BambooContext = class extends _bamboocss_generator.Generator {
2088
2129
  config.cwd ||= this.runtime.cwd();
2089
2130
  if (config.logLevel) _bamboocss_logger.logger.level = config.logLevel;
2090
2131
  this.project = new _bamboocss_parser.Project({
2132
+ cwd: config.cwd ?? this.runtime.cwd(),
2133
+ tsConfigFilePath: conf.tsconfigFile ?? `${config.cwd ?? this.runtime.cwd()}/tsconfig.json`,
2134
+ fs: { readFile: (filePath) => this.runtime.fs.readFileSync(filePath) },
2091
2135
  ...conf.tsconfig,
2092
2136
  deferInitialSourceFiles: true,
2093
2137
  resolutionConfigFiles: getTsConfigResolutionFiles(conf),
@@ -2529,7 +2573,7 @@ function accountSnapshot(ctx, snapshot, accounting) {
2529
2573
  });
2530
2574
  return;
2531
2575
  }
2532
- if (parseErrorCount(sourceFile)) {
2576
+ if (ctx.project.getSyntacticDiagnosticCount(filePath)) {
2533
2577
  if (!mentionsToken(ctx, parsed)) return;
2534
2578
  declined.push({
2535
2579
  filePath,
@@ -2571,15 +2615,6 @@ const mentionsToken = (ctx, text) => {
2571
2615
  if (ctx.imports.value.tokens.some((mod) => text.includes(mod))) return true;
2572
2616
  return IMPORTING_CALL.test(text);
2573
2617
  };
2574
- /**
2575
- * How many syntax errors the parse produced.
2576
- *
2577
- * `parseDiagnostics` is TypeScript-internal and absent from the public `SourceFile` type, so
2578
- * it is reached through a cast. The alternative, `getPreEmitDiagnostics`, runs the type checker
2579
- * over the whole program — orders of magnitude more work for a question about syntax, and it
2580
- * would report type errors this pass has no business declining over.
2581
- */
2582
- const parseErrorCount = (sourceFile) => sourceFile.compilerNode.parseDiagnostics?.length ?? 0;
2583
2618
  /** Whether a module specifier resolves to the generated tokens artifact. */
2584
2619
  const isTokensEntrypoint = (ctx, specifier) => {
2585
2620
  const mods = ctx.imports.value.tokens;
@@ -2590,7 +2625,7 @@ const isTokensEntrypoint = (ctx, specifier) => {
2590
2625
  if (!resolved) return false;
2591
2626
  return mods.some((mod) => resolved.includes(mod) || resolved === mod);
2592
2627
  };
2593
- const lineOf = (node) => node.getSourceFile().getLineAndColumnAtPos(node.getStart()).line;
2628
+ const lineOf = (node) => (0, _bamboocss_ts_ast.getLineAndColumnAtPos)(node.getSourceFile(), node.getStart()).line;
2594
2629
  function accountFile(ctx, sourceFile, filePath, paths, prefixes, declined) {
2595
2630
  const decline = (node, reason) => declined.push({
2596
2631
  filePath,
@@ -2601,60 +2636,60 @@ function accountFile(ctx, sourceFile, filePath, paths, prefixes, declined) {
2601
2636
  });
2602
2637
  /** Local names bound to the artifact: the `token` export, and any namespace of it. */
2603
2638
  const bindings = /* @__PURE__ */ new Set();
2604
- for (const statement of sourceFile.getStatements()) {
2605
- if (ts_morph.Node.isExportDeclaration(statement)) {
2606
- const specifier = statement.getModuleSpecifierValue();
2639
+ for (const statement of sourceFile.statements) {
2640
+ if (_bamboocss_ts_ast.Node.isExportDeclaration(statement)) {
2641
+ const specifier = (0, _bamboocss_ts_ast.getModuleSpecifierValue)(statement);
2607
2642
  if (specifier && isTokensEntrypoint(ctx, specifier)) decline(statement, "re-exported");
2608
2643
  continue;
2609
2644
  }
2610
- if (!ts_morph.Node.isImportDeclaration(statement)) continue;
2611
- const specifier = statement.getModuleSpecifierValue();
2645
+ if (!_bamboocss_ts_ast.Node.isImportDeclaration(statement)) continue;
2646
+ const specifier = (0, _bamboocss_ts_ast.getModuleSpecifierValue)(statement);
2612
2647
  if (!specifier) continue;
2613
- const clause = statement.getImportClause();
2614
- if (!clause || statement.isTypeOnly()) continue;
2648
+ const clause = statement.importClause;
2649
+ if (!clause || (0, _bamboocss_ts_ast.isTypeOnly)(statement)) continue;
2615
2650
  if (!isTokensEntrypoint(ctx, specifier)) {
2616
- for (const named of clause.getNamedImports()) if (!named.isTypeOnly() && nameOf(named.getNameNode()) === "token") decline(named, "unclassified-import");
2617
- const foreignDefault = clause.getDefaultImport();
2651
+ for (const named of (0, _bamboocss_ts_ast.getNamedImports)(clause)) if (!(0, _bamboocss_ts_ast.isTypeOnly)(named) && nameOf((0, _bamboocss_ts_ast.nameNodeOf)(named)) === "token") decline(named, "unclassified-import");
2652
+ const foreignDefault = (0, _bamboocss_ts_ast.getDefaultImport)(clause);
2618
2653
  if (foreignDefault && nameOf(foreignDefault) === "token") decline(foreignDefault, "unclassified-import");
2619
- const foreignNamespace = clause.getNamespaceImport();
2654
+ const foreignNamespace = (0, _bamboocss_ts_ast.getNamespaceImport)(clause);
2620
2655
  if (foreignNamespace && usesTokenMember(sourceFile, foreignNamespace.getText())) decline(foreignNamespace, "unclassified-import");
2621
2656
  continue;
2622
2657
  }
2623
- const defaultImport = clause.getDefaultImport();
2658
+ const defaultImport = (0, _bamboocss_ts_ast.getDefaultImport)(clause);
2624
2659
  if (defaultImport) decline(defaultImport, "unsupported-import");
2625
- const namespace = clause.getNamespaceImport();
2660
+ const namespace = (0, _bamboocss_ts_ast.getNamespaceImport)(clause);
2626
2661
  if (namespace) bindings.add(namespace.getText());
2627
- for (const named of clause.getNamedImports()) {
2628
- if (named.isTypeOnly()) continue;
2629
- if (nameOf(named.getNameNode()) !== "token") {
2630
- if (usedAsValue(sourceFile, (named.getAliasNode() ?? named.getNameNode()).getText(), named)) decline(named, "unsupported-import");
2662
+ for (const named of (0, _bamboocss_ts_ast.getNamedImports)(clause)) {
2663
+ if ((0, _bamboocss_ts_ast.isTypeOnly)(named)) continue;
2664
+ if (nameOf((0, _bamboocss_ts_ast.nameNodeOf)(named)) !== "token") {
2665
+ if (usedAsValue(sourceFile, ((0, _bamboocss_ts_ast.getAliasNode)(named) ?? (0, _bamboocss_ts_ast.nameNodeOf)(named))?.getText() ?? "", named)) decline(named, "unsupported-import");
2631
2666
  continue;
2632
2667
  }
2633
- bindings.add((named.getAliasNode() ?? named.getNameNode()).getText());
2668
+ bindings.add(((0, _bamboocss_ts_ast.getAliasNode)(named) ?? (0, _bamboocss_ts_ast.nameNodeOf)(named))?.getText() ?? "");
2634
2669
  }
2635
2670
  }
2636
- for (const importEquals of sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.ImportEqualsDeclaration)) if (importEquals.getText().includes("token")) decline(importEquals, "import-equals");
2637
- for (const call of sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.CallExpression)) {
2638
- const callee = call.getExpression();
2639
- const isRequire = ts_morph.Node.isIdentifier(callee) && callee.getText() === "require";
2640
- const isDynamicImport = callee.getKind() === ts_morph.SyntaxKind.ImportKeyword;
2671
+ for (const importEquals of (0, _bamboocss_ts_ast.getDescendantsOfKind)(sourceFile, _bamboocss_ts_ast.SyntaxKind.ImportEqualsDeclaration)) if (importEquals.getText().includes("token")) decline(importEquals, "import-equals");
2672
+ for (const call of (0, _bamboocss_ts_ast.getDescendantsOfKind)(sourceFile, _bamboocss_ts_ast.SyntaxKind.CallExpression)) {
2673
+ const callee = (0, _bamboocss_ts_ast.childOf)(call, "expression");
2674
+ const isRequire = callee !== void 0 && _bamboocss_ts_ast.Node.isIdentifier(callee) && callee.getText() === "require";
2675
+ const isDynamicImport = callee?.kind === _bamboocss_ts_ast.SyntaxKind.ImportKeyword;
2641
2676
  if (!isRequire && !isDynamicImport) continue;
2642
- const argument = call.getArguments()[0];
2677
+ const argument = (0, _bamboocss_ts_ast.childOf)(call, "arguments")?.[0];
2643
2678
  if (!argument) continue;
2644
- if (ts_morph.Node.isStringLiteral(argument) ? isTokensEntrypoint(ctx, argument.getLiteralValue()) : true) decline(call, isRequire ? "require" : "dynamic-import");
2679
+ if (_bamboocss_ts_ast.Node.isStringLiteral(argument) ? isTokensEntrypoint(ctx, (0, _bamboocss_ts_ast.stringLiteralValue)(argument)) : true) decline(call, isRequire ? "require" : "dynamic-import");
2645
2680
  }
2646
2681
  const shadows = shadowedScopes(sourceFile);
2647
2682
  for (const identifier of identifiersNamed(sourceFile, (name) => bindings.has(name) || name === "token")) {
2648
2683
  const text = nameOf(identifier);
2649
- const parent = identifier.getParent();
2650
- if (ts_morph.Node.isExportSpecifier(parent)) {
2651
- const declaration = parent.getFirstAncestorByKind(ts_morph.SyntaxKind.ExportDeclaration);
2652
- if (declaration && !declaration.getModuleSpecifier()) decline(identifier, "re-exported");
2684
+ const parent = identifier.parent;
2685
+ if (_bamboocss_ts_ast.Node.isExportSpecifier(parent)) {
2686
+ const declaration = (0, _bamboocss_ts_ast.getFirstAncestorByKind)(parent, _bamboocss_ts_ast.SyntaxKind.ExportDeclaration);
2687
+ if (declaration && !(0, _bamboocss_ts_ast.childOf)(declaration, "moduleSpecifier")) decline(identifier, "re-exported");
2653
2688
  continue;
2654
2689
  }
2655
- if (ts_morph.Node.isPropertyAccessExpression(parent) && parent.getNameNode() === identifier) {
2656
- const object = parent.getExpression();
2657
- const objectName = ts_morph.Node.isIdentifier(object) ? object.getText() : void 0;
2690
+ if (_bamboocss_ts_ast.Node.isPropertyAccessExpression(parent) && parent.name === identifier) {
2691
+ const object = parent.expression;
2692
+ const objectName = _bamboocss_ts_ast.Node.isIdentifier(object) ? object.getText() : void 0;
2658
2693
  if (objectName && bindings.has(objectName)) continue;
2659
2694
  decline(identifier, "unresolved-reference");
2660
2695
  continue;
@@ -2681,11 +2716,11 @@ function accountFile(ctx, sourceFile, filePath, paths, prefixes, declined) {
2681
2716
  * property-access-only scan.
2682
2717
  */
2683
2718
  function usesTokenMember(sourceFile, namespace) {
2684
- if (sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.PropertyAccessExpression).some((access) => access.getExpression().getText() === namespace && nameOf(access.getNameNode()) === "token")) return true;
2685
- return sourceFile.getDescendantsOfKind(ts_morph.SyntaxKind.ElementAccessExpression).some((access) => {
2686
- if (access.getExpression().getText() !== namespace) return false;
2687
- const argument = access.getArgumentExpression();
2688
- return argument != null && (!ts_morph.Node.isStringLiteral(argument) || argument.getLiteralValue() === "token");
2719
+ if ((0, _bamboocss_ts_ast.getDescendantsOfKind)(sourceFile, _bamboocss_ts_ast.SyntaxKind.PropertyAccessExpression).some((access) => (0, _bamboocss_ts_ast.childOf)(access, "expression")?.getText() === namespace && nameOf((0, _bamboocss_ts_ast.nameNodeOf)(access)) === "token")) return true;
2720
+ return (0, _bamboocss_ts_ast.getDescendantsOfKind)(sourceFile, _bamboocss_ts_ast.SyntaxKind.ElementAccessExpression).some((access) => {
2721
+ if ((0, _bamboocss_ts_ast.childOf)(access, "expression")?.getText() !== namespace) return false;
2722
+ const argument = (0, _bamboocss_ts_ast.childOf)(access, "argumentExpression");
2723
+ return argument != null && (!_bamboocss_ts_ast.Node.isStringLiteral(argument) || (0, _bamboocss_ts_ast.stringLiteralValue)(argument) === "token");
2689
2724
  });
2690
2725
  }
2691
2726
  /**
@@ -2711,14 +2746,13 @@ function usesTokenMember(sourceFile, namespace) {
2711
2746
  function* identifiersNamed(sourceFile, wanted) {
2712
2747
  const found = [];
2713
2748
  const collect = (node) => {
2714
- if (node.kind === ts_morph.SyntaxKind.Identifier && wanted(String(node.escapedText))) found.push(node);
2749
+ if (node.kind === _bamboocss_ts_ast.SyntaxKind.Identifier && wanted(String(node.text))) found.push(node);
2715
2750
  const jsDoc = node.jsDoc;
2716
2751
  if (jsDoc) for (const doc of jsDoc) collect(doc);
2717
- ts_morph.ts.forEachChild(node, collect);
2752
+ _bamboocss_ts_ast.ts.forEachChild(node, collect);
2718
2753
  };
2719
- collect(sourceFile.compilerNode);
2720
- const wrap = sourceFile;
2721
- for (const node of found) yield wrap._getNodeFromCompilerNode(node);
2754
+ collect(sourceFile);
2755
+ for (const node of found) yield node;
2722
2756
  }
2723
2757
  /**
2724
2758
  * An identifier's name as the compiler resolves it, not as it is spelled.
@@ -2726,16 +2760,16 @@ function* identifiersNamed(sourceFile, wanted) {
2726
2760
  * `token` is the identifier `token`; reading `getText()` returns the escape and compares
2727
2761
  * unequal, which let an import of the artifact's export past the checks that key on the name.
2728
2762
  */
2729
- const nameOf = (node) => ts_morph.Node.isIdentifier(node) ? String(node.compilerNode.escapedText) : node.getText();
2763
+ const nameOf = (node) => _bamboocss_ts_ast.Node.isIdentifier(node) ? String(node.text) : node.getText();
2730
2764
  /** Every name a binding name binds, following object and array destructuring. */
2731
2765
  function boundNames(name, bound) {
2732
2766
  if (!name) return;
2733
- if (ts_morph.Node.isIdentifier(name)) {
2767
+ if (_bamboocss_ts_ast.Node.isIdentifier(name)) {
2734
2768
  bound(nameOf(name));
2735
2769
  return;
2736
2770
  }
2737
- if (!ts_morph.Node.isObjectBindingPattern(name) && !ts_morph.Node.isArrayBindingPattern(name)) return;
2738
- for (const element of name.getElements()) if (ts_morph.Node.isBindingElement(element)) boundNames(element.getNameNode(), bound);
2771
+ if (!_bamboocss_ts_ast.Node.isObjectBindingPattern(name) && !_bamboocss_ts_ast.Node.isArrayBindingPattern(name)) return;
2772
+ for (const element of name.elements) if (_bamboocss_ts_ast.Node.isBindingElement(element)) boundNames(element.name, bound);
2739
2773
  }
2740
2774
  /**
2741
2775
  * Scopes that bind a name to something which cannot be the artifact, keyed by that name.
@@ -2771,34 +2805,34 @@ function shadowedScopes(sourceFile) {
2771
2805
  else scopes.set(name, [scope]);
2772
2806
  };
2773
2807
  const variables = [];
2774
- sourceFile.forEachDescendant((node) => {
2775
- if (ts_morph.Node.isParameterDeclaration(node)) {
2776
- const scope = node.getParent();
2777
- boundNames(node.getNameNode(), (name) => add(name, scope));
2808
+ (0, _bamboocss_ts_ast.forEachDescendant)(sourceFile, (node) => {
2809
+ if (_bamboocss_ts_ast.Node.isParameterDeclaration(node)) {
2810
+ const scope = node.parent;
2811
+ boundNames(node.name, (name) => add(name, scope));
2778
2812
  return;
2779
2813
  }
2780
- if (ts_morph.Node.isCatchClause(node)) {
2781
- boundNames(node.getVariableDeclaration()?.getNameNode(), (name) => add(name, node));
2814
+ if (_bamboocss_ts_ast.Node.isCatchClause(node)) {
2815
+ boundNames(node.variableDeclaration?.name, (name) => add(name, node));
2782
2816
  return;
2783
2817
  }
2784
- if (ts_morph.Node.isFunctionDeclaration(node) || ts_morph.Node.isClassDeclaration(node)) {
2785
- const name = node.getNameNode();
2786
- if (name) add(nameOf(name), node.getParent());
2818
+ if (_bamboocss_ts_ast.Node.isFunctionDeclaration(node) || _bamboocss_ts_ast.Node.isClassDeclaration(node)) {
2819
+ const name = node.name;
2820
+ if (name) add(nameOf(name), node.parent);
2787
2821
  return;
2788
2822
  }
2789
- if (ts_morph.Node.isFunctionExpression(node) || ts_morph.Node.isClassExpression(node)) {
2790
- const name = node.getNameNode();
2823
+ if (_bamboocss_ts_ast.Node.isFunctionExpression(node) || _bamboocss_ts_ast.Node.isClassExpression(node)) {
2824
+ const name = node.name;
2791
2825
  if (name) add(nameOf(name), node);
2792
2826
  return;
2793
2827
  }
2794
- if (ts_morph.Node.isVariableDeclaration(node)) variables.push(node);
2828
+ if (_bamboocss_ts_ast.Node.isVariableDeclaration(node)) variables.push(node);
2795
2829
  });
2796
2830
  for (const declaration of variables) {
2797
- if (!ts_morph.Node.isVariableDeclaration(declaration)) continue;
2798
- const root = rootIdentifier(declaration.getInitializer());
2831
+ if (!_bamboocss_ts_ast.Node.isVariableDeclaration(declaration)) continue;
2832
+ const root = rootIdentifier(declaration.initializer);
2799
2833
  if (!root || !isShadowed(root, scopes.get(nameOf(root)))) continue;
2800
- const scope = declaration.getFirstAncestor((ancestor) => ts_morph.Node.isBlock(ancestor) || ts_morph.Node.isSourceFile(ancestor) || ts_morph.Node.isModuleBlock(ancestor) || ts_morph.Node.isCaseClause(ancestor) || ts_morph.Node.isDefaultClause(ancestor) || ts_morph.Node.isForStatement(ancestor) || ts_morph.Node.isForOfStatement(ancestor) || ts_morph.Node.isForInStatement(ancestor));
2801
- boundNames(declaration.getNameNode(), (name) => add(name, scope));
2834
+ const scope = (0, _bamboocss_ts_ast.getFirstAncestor)(declaration, (ancestor) => _bamboocss_ts_ast.Node.isBlock(ancestor) || _bamboocss_ts_ast.Node.isSourceFile(ancestor) || _bamboocss_ts_ast.Node.isModuleBlock(ancestor) || _bamboocss_ts_ast.Node.isCaseClause(ancestor) || _bamboocss_ts_ast.Node.isDefaultClause(ancestor) || _bamboocss_ts_ast.Node.isForStatement(ancestor) || _bamboocss_ts_ast.Node.isForOfStatement(ancestor) || _bamboocss_ts_ast.Node.isForInStatement(ancestor));
2835
+ boundNames(declaration.name, (name) => add(name, scope));
2802
2836
  }
2803
2837
  return scopes;
2804
2838
  }
@@ -2810,8 +2844,8 @@ function shadowedScopes(sourceFile) {
2810
2844
  */
2811
2845
  function rootIdentifier(expression) {
2812
2846
  let current = expression;
2813
- while (current && (ts_morph.Node.isPropertyAccessExpression(current) || ts_morph.Node.isElementAccessExpression(current))) current = current.getExpression();
2814
- return current && ts_morph.Node.isIdentifier(current) ? current : void 0;
2847
+ while (current && (_bamboocss_ts_ast.Node.isPropertyAccessExpression(current) || _bamboocss_ts_ast.Node.isElementAccessExpression(current))) current = current.expression;
2848
+ return current && _bamboocss_ts_ast.Node.isIdentifier(current) ? current : void 0;
2815
2849
  }
2816
2850
  /**
2817
2851
  * Whether an identifier is the *name* of a declaration rather than a read of one.
@@ -2825,7 +2859,7 @@ function rootIdentifier(expression) {
2825
2859
  * the binding, so it is a reference like any other.
2826
2860
  */
2827
2861
  function isDeclarationName(identifier, parent) {
2828
- if (ts_morph.Node.isPropertyAssignment(parent) || ts_morph.Node.isPropertySignature(parent) || ts_morph.Node.isMethodSignature(parent) || ts_morph.Node.isPropertyDeclaration(parent) || ts_morph.Node.isMethodDeclaration(parent) || ts_morph.Node.isEnumMember(parent)) return parent.getNameNode() === identifier;
2862
+ if (_bamboocss_ts_ast.Node.isPropertyAssignment(parent) || _bamboocss_ts_ast.Node.isPropertySignatureDeclaration(parent) || _bamboocss_ts_ast.Node.isMethodSignatureDeclaration(parent) || _bamboocss_ts_ast.Node.isPropertyDeclaration(parent) || _bamboocss_ts_ast.Node.isMethodDeclaration(parent) || _bamboocss_ts_ast.Node.isEnumMember(parent)) return (0, _bamboocss_ts_ast.nameNodeOf)(parent) === identifier;
2829
2863
  return false;
2830
2864
  }
2831
2865
  /**
@@ -2849,20 +2883,20 @@ function isShadowed(identifier, scopes) {
2849
2883
  * (`useMemo(() => token)`), spread, or enumerated.
2850
2884
  */
2851
2885
  function accountedPath(identifier) {
2852
- const parent = identifier.getParent();
2886
+ const parent = identifier.parent;
2853
2887
  if (!parent) return void 0;
2854
- if (ts_morph.Node.isImportSpecifier(parent) || ts_morph.Node.isNamespaceImport(parent) || ts_morph.Node.isImportClause(parent) || ts_morph.Node.isExportSpecifier(parent)) return { kind: "binding" };
2855
- if (ts_morph.Node.isCallExpression(parent) && parent.getExpression() === identifier) return literalPath(parent);
2856
- if (!ts_morph.Node.isPropertyAccessExpression(parent) || parent.getExpression() !== identifier) return void 0;
2857
- const property = parent.getNameNode().getText();
2858
- const grandParent = parent.getParent();
2859
- if (property === "value") return ts_morph.Node.isCallExpression(grandParent) && grandParent.getExpression() === parent ? literalPath(grandParent) : void 0;
2888
+ if (_bamboocss_ts_ast.Node.isImportSpecifier(parent) || _bamboocss_ts_ast.Node.isNamespaceImport(parent) || _bamboocss_ts_ast.Node.isImportClause(parent) || _bamboocss_ts_ast.Node.isExportSpecifier(parent)) return { kind: "binding" };
2889
+ if (_bamboocss_ts_ast.Node.isCallExpression(parent) && parent.expression === identifier) return literalPath(parent);
2890
+ if (!_bamboocss_ts_ast.Node.isPropertyAccessExpression(parent) || parent.expression !== identifier) return void 0;
2891
+ const property = parent.name.getText();
2892
+ const grandParent = parent.parent;
2893
+ if (property === "value") return _bamboocss_ts_ast.Node.isCallExpression(grandParent) && grandParent.expression === parent ? literalPath(grandParent) : void 0;
2860
2894
  if (property !== "token") return void 0;
2861
- if (ts_morph.Node.isCallExpression(grandParent) && grandParent.getExpression() === parent) return literalPath(grandParent);
2862
- if (ts_morph.Node.isPropertyAccessExpression(grandParent) && grandParent.getExpression() === parent) {
2863
- if (grandParent.getNameNode().getText() !== "value") return void 0;
2864
- const call = grandParent.getParent();
2865
- return ts_morph.Node.isCallExpression(call) && call.getExpression() === grandParent ? literalPath(call) : void 0;
2895
+ if (_bamboocss_ts_ast.Node.isCallExpression(grandParent) && grandParent.expression === parent) return literalPath(grandParent);
2896
+ if (_bamboocss_ts_ast.Node.isPropertyAccessExpression(grandParent) && grandParent.expression === parent) {
2897
+ if (grandParent.name.getText() !== "value") return void 0;
2898
+ const call = grandParent.parent;
2899
+ return _bamboocss_ts_ast.Node.isCallExpression(call) && call.expression === grandParent ? literalPath(call) : void 0;
2866
2900
  }
2867
2901
  }
2868
2902
  /**
@@ -2880,19 +2914,19 @@ function accountedPath(identifier) {
2880
2914
  * head bounds nothing at all, so that still declines.
2881
2915
  */
2882
2916
  function literalPath(call) {
2883
- if (!ts_morph.Node.isCallExpression(call)) return void 0;
2884
- const argument = unwrapAssertions(call.getArguments()[0]);
2917
+ if (!_bamboocss_ts_ast.Node.isCallExpression(call)) return void 0;
2918
+ const argument = unwrapAssertions(call.arguments[0]);
2885
2919
  if (!argument) return void 0;
2886
- if (ts_morph.Node.isStringLiteral(argument)) return {
2920
+ if (_bamboocss_ts_ast.Node.isStringLiteral(argument)) return {
2887
2921
  kind: "path",
2888
- value: argument.getLiteralValue()
2922
+ value: (0, _bamboocss_ts_ast.stringLiteralValue)(argument)
2889
2923
  };
2890
- if (ts_morph.Node.isNoSubstitutionTemplateLiteral(argument)) return {
2924
+ if (_bamboocss_ts_ast.Node.isNoSubstitutionTemplateLiteral(argument)) return {
2891
2925
  kind: "path",
2892
- value: argument.getLiteralValue()
2926
+ value: (0, _bamboocss_ts_ast.stringLiteralValue)(argument)
2893
2927
  };
2894
- if (ts_morph.Node.isTemplateExpression(argument)) {
2895
- const head = argument.getHead().getLiteralText();
2928
+ if (_bamboocss_ts_ast.Node.isTemplateExpression(argument)) {
2929
+ const head = (0, _bamboocss_ts_ast.getLiteralText)(argument.head);
2896
2930
  return head ? {
2897
2931
  kind: "prefix",
2898
2932
  value: head
@@ -2908,8 +2942,8 @@ function literalPath(call) {
2908
2942
  */
2909
2943
  function usedAsValue(sourceFile, name, declaration) {
2910
2944
  for (const identifier of identifiersNamed(sourceFile, (candidate) => candidate === name)) {
2911
- if (identifier.getFirstAncestor((ancestor) => ancestor === declaration)) continue;
2912
- if (!identifier.getFirstAncestor((ancestor) => ts_morph.Node.isTypeNode(ancestor))) return true;
2945
+ if ((0, _bamboocss_ts_ast.getFirstAncestor)(identifier, (ancestor) => ancestor === declaration)) continue;
2946
+ if (!(0, _bamboocss_ts_ast.getFirstAncestor)(identifier, (ancestor) => _bamboocss_ts_ast.Node.isTypeNode(ancestor))) return true;
2913
2947
  }
2914
2948
  return false;
2915
2949
  }
@@ -2927,7 +2961,7 @@ function usedAsValue(sourceFile, name, declaration) {
2927
2961
  */
2928
2962
  function unwrapAssertions(node) {
2929
2963
  let current = node;
2930
- while (current && (ts_morph.Node.isAsExpression(current) || ts_morph.Node.isSatisfiesExpression(current) || ts_morph.Node.isNonNullExpression(current) || ts_morph.Node.isParenthesizedExpression(current) || ts_morph.Node.isTypeAssertion(current))) current = current.getExpression();
2964
+ while (current && (_bamboocss_ts_ast.Node.isAsExpression(current) || _bamboocss_ts_ast.Node.isSatisfiesExpression(current) || _bamboocss_ts_ast.Node.isNonNullExpression(current) || _bamboocss_ts_ast.Node.isParenthesizedExpression(current) || _bamboocss_ts_ast.Node.isTypeAssertion(current))) current = current.expression;
2931
2965
  return current;
2932
2966
  }
2933
2967
  //#endregion
@@ -3775,7 +3809,7 @@ var Builder = class {
3775
3809
  const recipes = [];
3776
3810
  for (const set of [parserResult?.cva, parserResult?.sva]) for (const item of set ?? []) recipes.push([item.name ?? "", item.data]);
3777
3811
  const sourceFile = ctx.project?.getSourceFile?.(file);
3778
- const exports = sourceFile ? sourceFile.getExportDeclarations().map((declaration) => declaration.getText()) : [];
3812
+ const exports = sourceFile ? (0, _bamboocss_ts_ast.getExportDeclarations)(sourceFile).map((declaration) => declaration.getText()) : [];
3779
3813
  const json = JSON.stringify([recipes, exports], (_key, value) => value === void 0 ? "bamboo:undefined" : value);
3780
3814
  if (json === void 0) return void 0;
3781
3815
  return (0, node_crypto.createHash)("sha256").update(json).digest("base64");