@bamboocss/node 1.15.0 → 1.16.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.cjs +75 -4
- package/dist/index.d.cts +23 -0
- package/dist/index.d.mts +24 -1
- package/dist/index.mjs +76 -5
- package/package.json +13 -13
package/dist/index.cjs
CHANGED
|
@@ -33,6 +33,7 @@ let _bamboocss_plugin_svelte = require("@bamboocss/plugin-svelte");
|
|
|
33
33
|
let _bamboocss_plugin_vue = require("@bamboocss/plugin-vue");
|
|
34
34
|
let browserslist = require("browserslist");
|
|
35
35
|
browserslist = __toESM(browserslist);
|
|
36
|
+
let _bamboocss_core = require("@bamboocss/core");
|
|
36
37
|
let _bamboocss_generator = require("@bamboocss/generator");
|
|
37
38
|
let _bamboocss_parser = require("@bamboocss/parser");
|
|
38
39
|
let perfect_debounce = require("perfect-debounce");
|
|
@@ -63,7 +64,6 @@ node_readline = __toESM(node_readline);
|
|
|
63
64
|
let look_it_up = require("look-it-up");
|
|
64
65
|
let outdent = require("outdent");
|
|
65
66
|
outdent = __toESM(outdent);
|
|
66
|
-
let _bamboocss_core = require("@bamboocss/core");
|
|
67
67
|
let child_process = require("child_process");
|
|
68
68
|
//#region src/analyze.ts
|
|
69
69
|
function analyze(ctx, options = {}) {
|
|
@@ -134,6 +134,7 @@ async function codegen(ctx, ids) {
|
|
|
134
134
|
}
|
|
135
135
|
const promises = artifacts.map((artifact) => limit(() => ctx.output.write(artifact)));
|
|
136
136
|
await Promise.allSettled(promises);
|
|
137
|
+
await ctx.writeGroupRegistry();
|
|
137
138
|
await ctx.hooks["codegen:done"]?.({ changed: ids });
|
|
138
139
|
return {
|
|
139
140
|
box: ctx.initMessage(),
|
|
@@ -1594,6 +1595,21 @@ var OutputEngine = class {
|
|
|
1594
1595
|
};
|
|
1595
1596
|
//#endregion
|
|
1596
1597
|
//#region src/create-context.ts
|
|
1598
|
+
/**
|
|
1599
|
+
* What each loss is, and what the author can do about it.
|
|
1600
|
+
*
|
|
1601
|
+
* Kept apart from the sentence around it so every reason has to answer both questions.
|
|
1602
|
+
* "Make the value static" is the fix for a value the build could not evaluate and no help
|
|
1603
|
+
* at all for two arguments it could not tell apart, and a diagnostic that gives the wrong
|
|
1604
|
+
* instruction is worse than one that gives none.
|
|
1605
|
+
*/
|
|
1606
|
+
const unresolvedReasons = {
|
|
1607
|
+
"unresolvable-value": (prop) => [`${prop} will not reach the stylesheet because its value is not statically known`, "Make the value static to group it."],
|
|
1608
|
+
"missing-property": (prop) => [`${prop} will not reach the stylesheet because its value could not be evaluated at build time`, "Make the value static to group it."],
|
|
1609
|
+
"unenumerable-keys": () => ["an object spread or computed key leaves the build unable to tell which properties this call sets", "Write the properties out, or spread a value the build can resolve, to group it."],
|
|
1610
|
+
"ambiguous-merge": () => ["two of these arguments set the same property, and the build cannot tell a merge from a pair of alternatives", "Merge them into a single object to group it."],
|
|
1611
|
+
"too-many-combinations": () => ["this call has more conditional branches than the build will enumerate", "Split it into fewer conditional properties to group it."]
|
|
1612
|
+
};
|
|
1597
1613
|
var BambooContext = class extends _bamboocss_generator.Generator {
|
|
1598
1614
|
runtime;
|
|
1599
1615
|
project;
|
|
@@ -1619,7 +1635,28 @@ var BambooContext = class extends _bamboocss_generator.Generator {
|
|
|
1619
1635
|
this.output = new OutputEngine(this);
|
|
1620
1636
|
this.diff = new DiffEngine(this);
|
|
1621
1637
|
this.explicitDeps = this.getExplicitDependencies();
|
|
1638
|
+
const disagreement = (0, _bamboocss_core.checkNamingAgreement)(this);
|
|
1639
|
+
if (disagreement) throw new _bamboocss_shared.BambooError("NAMING_DISAGREEMENT", (0, _bamboocss_core.formatNamingDisagreement)(disagreement));
|
|
1640
|
+
if (config.cssMode === "grouped" && config.staticCss?.css?.length) _bamboocss_logger.logger.warn("config", "`staticCss.css` does not back runtime `css()` calls under `cssMode: 'grouped'`. It pre-generates one rule per property and value, while a grouped class names a whole call. The rules are still emitted, but nothing the runtime returns will match them — see https://bamboocss.com/docs/references/config#cssmode");
|
|
1622
1641
|
}
|
|
1642
|
+
/**
|
|
1643
|
+
* Report `css()` calls whose styles the build could not fully see.
|
|
1644
|
+
*
|
|
1645
|
+
* Only under `cssMode: 'grouped'`, and only as a warning: the build is not wrong, the
|
|
1646
|
+
* call site is unresolvable, and erroring would reject code that an `atomic` build
|
|
1647
|
+
* accepts. But under `grouped` that call renders the element with *no* styles rather
|
|
1648
|
+
* than merely losing a declaration, so it must not be silent.
|
|
1649
|
+
*/
|
|
1650
|
+
reportUnresolvedStyles = (result) => {
|
|
1651
|
+
const unresolved = result.unresolved;
|
|
1652
|
+
if (!unresolved?.length) return;
|
|
1653
|
+
for (const entry of unresolved) {
|
|
1654
|
+
const where = `${entry.filePath}:${entry.line}:${entry.column}`;
|
|
1655
|
+
const prop = entry.prop ? `\`${entry.prop}\`` : "a property";
|
|
1656
|
+
const [what, fix] = unresolvedReasons[entry.reason](prop);
|
|
1657
|
+
_bamboocss_logger.logger.warn("grouped", `${where} — ${what}. Under \`cssMode: 'grouped'\` one class names the whole \`css()\` call, so this call cannot use one: it falls back to naming each declaration separately and keeps only the ones the build could resolve. ${fix} See https://bamboocss.com/docs/references/config#cssmode`);
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1623
1660
|
getExplicitDependencies = () => {
|
|
1624
1661
|
const { cwd, dependencies } = this.config;
|
|
1625
1662
|
if (!dependencies) return [];
|
|
@@ -1653,6 +1690,7 @@ var BambooContext = class extends _bamboocss_generator.Generator {
|
|
|
1653
1690
|
} catch (error) {
|
|
1654
1691
|
_bamboocss_logger.logger.caughtError("file:extract", `Failed to parse ${file}`, error);
|
|
1655
1692
|
}
|
|
1693
|
+
if (result) this.reportUnresolvedStyles(result);
|
|
1656
1694
|
measure();
|
|
1657
1695
|
return result;
|
|
1658
1696
|
};
|
|
@@ -1665,16 +1703,49 @@ var BambooContext = class extends _bamboocss_generator.Generator {
|
|
|
1665
1703
|
const measure = _bamboocss_logger.logger.time.debug(`Parsed ${file}`);
|
|
1666
1704
|
const result = this.project.parseSourceFile(file, encoder);
|
|
1667
1705
|
measure();
|
|
1706
|
+
if (result) this.reportUnresolvedStyles(result);
|
|
1668
1707
|
if (!result || result.isEmpty() || encoder.isEmpty()) return;
|
|
1669
1708
|
filesWithCss.push(file);
|
|
1670
1709
|
results.push(result);
|
|
1671
1710
|
});
|
|
1711
|
+
this.writeGroupRegistry();
|
|
1672
1712
|
return {
|
|
1673
1713
|
filesWithCss,
|
|
1674
1714
|
files,
|
|
1675
1715
|
results
|
|
1676
1716
|
};
|
|
1677
1717
|
};
|
|
1718
|
+
/**
|
|
1719
|
+
* Refresh the group registry the generated `css()` consults.
|
|
1720
|
+
*
|
|
1721
|
+
* `codegen` emits it empty — it runs on config change, before anything is extracted — so
|
|
1722
|
+
* this is the pass that fills it in. Called after extraction rather than alongside the
|
|
1723
|
+
* CSS, because the PostCSS plugin never writes a stylesheet to disk at all and would
|
|
1724
|
+
* otherwise never get one.
|
|
1725
|
+
*
|
|
1726
|
+
* Safe to run late or not at all: the runtime *adds* atomic names to the group class
|
|
1727
|
+
* rather than replacing it, so a stale registry costs a class that matches nothing.
|
|
1728
|
+
*/
|
|
1729
|
+
writeGroupRegistry = () => {
|
|
1730
|
+
if (this.config.cssMode !== "grouped") return;
|
|
1731
|
+
const names = this.getGroupRegistry();
|
|
1732
|
+
if (!names.length) {
|
|
1733
|
+
const existing = this.runtime.path.join(...this.paths.css, this.file.ext(_bamboocss_generator.GROUP_REGISTRY_FILE));
|
|
1734
|
+
if (this.runtime.fs.existsSync(existing)) return;
|
|
1735
|
+
}
|
|
1736
|
+
const registry = (0, _bamboocss_generator.generateGroupRegistry)(this, names);
|
|
1737
|
+
return this.output.write({
|
|
1738
|
+
id: "css-fn",
|
|
1739
|
+
dir: this.paths.css,
|
|
1740
|
+
files: [{
|
|
1741
|
+
file: this.file.ext(_bamboocss_generator.GROUP_REGISTRY_FILE),
|
|
1742
|
+
code: registry.js
|
|
1743
|
+
}, {
|
|
1744
|
+
file: this.file.extDts(_bamboocss_generator.GROUP_REGISTRY_FILE),
|
|
1745
|
+
code: registry.dts
|
|
1746
|
+
}]
|
|
1747
|
+
});
|
|
1748
|
+
};
|
|
1678
1749
|
writeCss = (sheet) => {
|
|
1679
1750
|
_bamboocss_logger.logger.info("css", this.runtime.path.join(...this.paths.root, "styles.css"));
|
|
1680
1751
|
return this.output.write({
|
|
@@ -2281,6 +2352,7 @@ var Builder = class {
|
|
|
2281
2352
|
const files = ctx.getFiles();
|
|
2282
2353
|
const done = _bamboocss_logger.logger.time.info("Extracted in");
|
|
2283
2354
|
files.map((file) => this.extractFile(ctx, file));
|
|
2355
|
+
ctx.writeGroupRegistry();
|
|
2284
2356
|
done();
|
|
2285
2357
|
};
|
|
2286
2358
|
isValidRoot = (root) => {
|
|
@@ -2519,6 +2591,7 @@ async function generate(config, configPath) {
|
|
|
2519
2591
|
if (ctx.config.pruneUnusedKeyframes) ctx.pruneKeyframes(sheet, collectKeyframeReferences(ctx, keyframeNames(ctx)));
|
|
2520
2592
|
const css = ctx.getCss(sheet);
|
|
2521
2593
|
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2594
|
+
await ctx.writeGroupRegistry();
|
|
2522
2595
|
done();
|
|
2523
2596
|
};
|
|
2524
2597
|
ctx.watchFiles(async (event, file) => {
|
|
@@ -2589,7 +2662,7 @@ const ensure = (outPath) => {
|
|
|
2589
2662
|
//#endregion
|
|
2590
2663
|
//#region src/setup-config.ts
|
|
2591
2664
|
async function setupConfig(cwd, opts = {}) {
|
|
2592
|
-
const { force, outExtension,
|
|
2665
|
+
const { force, outExtension, outdir = "styled-system" } = opts;
|
|
2593
2666
|
let configFile;
|
|
2594
2667
|
try {
|
|
2595
2668
|
configFile = (0, _bamboocss_config.findConfig)({ cwd });
|
|
@@ -2623,8 +2696,6 @@ export default defineConfig({
|
|
|
2623
2696
|
|
|
2624
2697
|
// The output directory for your css system
|
|
2625
2698
|
outdir: ${JSON.stringify(outdir)},
|
|
2626
|
-
${jsxFramework ? `\n // The JSX framework to use\njsxFramework: '${jsxFramework}',` : ""}
|
|
2627
|
-
${syntax ? `\n // The CSS Syntax to use to use\nsyntax: '${syntax}'` : ""}
|
|
2628
2699
|
})
|
|
2629
2700
|
`;
|
|
2630
2701
|
const filePath = (0, path.join)(cwd, file);
|
package/dist/index.d.cts
CHANGED
|
@@ -52,6 +52,17 @@ declare class BambooContext extends Generator {
|
|
|
52
52
|
diff: DiffEngine;
|
|
53
53
|
explicitDeps: string[];
|
|
54
54
|
constructor(conf: LoadConfigResult);
|
|
55
|
+
/**
|
|
56
|
+
* Report `css()` calls whose styles the build could not fully see.
|
|
57
|
+
*
|
|
58
|
+
* Only under `cssMode: 'grouped'`, and only as a warning: the build is not wrong, the
|
|
59
|
+
* call site is unresolvable, and erroring would reject code that an `atomic` build
|
|
60
|
+
* accepts. But under `grouped` that call renders the element with *no* styles rather
|
|
61
|
+
* than merely losing a declaration, so it must not be silent.
|
|
62
|
+
*/
|
|
63
|
+
reportUnresolvedStyles: (result: {
|
|
64
|
+
unresolved?: ParserResult["unresolved"];
|
|
65
|
+
}) => void;
|
|
55
66
|
private getExplicitDependencies;
|
|
56
67
|
initMessage: () => string;
|
|
57
68
|
getFiles: () => string[];
|
|
@@ -61,6 +72,18 @@ declare class BambooContext extends Generator {
|
|
|
61
72
|
files: string[];
|
|
62
73
|
results: ParserResult[];
|
|
63
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* Refresh the group registry the generated `css()` consults.
|
|
77
|
+
*
|
|
78
|
+
* `codegen` emits it empty — it runs on config change, before anything is extracted — so
|
|
79
|
+
* this is the pass that fills it in. Called after extraction rather than alongside the
|
|
80
|
+
* CSS, because the PostCSS plugin never writes a stylesheet to disk at all and would
|
|
81
|
+
* otherwise never get one.
|
|
82
|
+
*
|
|
83
|
+
* Safe to run late or not at all: the runtime *adds* atomic names to the group class
|
|
84
|
+
* rather than replacing it, so a stale registry costs a class that matches nothing.
|
|
85
|
+
*/
|
|
86
|
+
writeGroupRegistry: () => Promise<PromiseSettledResult<void>[]> | undefined;
|
|
64
87
|
writeCss: (sheet?: Stylesheet) => Promise<PromiseSettledResult<void>[]> | undefined;
|
|
65
88
|
writeSplitCss: (sheet: Stylesheet) => Promise<void>;
|
|
66
89
|
watchConfig: (cb: (file: string) => void | Promise<void>, opts?: Omit<WatchOptions, "include">) => void;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReportFormat } from "@bamboocss/reporter";
|
|
2
|
+
import { StyleEncoder, Stylesheet } from "@bamboocss/core";
|
|
2
3
|
import { Generator } from "@bamboocss/generator";
|
|
3
4
|
import { ParserResult, Project } from "@bamboocss/parser";
|
|
4
|
-
import { StyleEncoder, Stylesheet } from "@bamboocss/core";
|
|
5
5
|
import { AnalysisOptions, Artifact, ArtifactId, BambooHooks, Config, CssArtifactType, LoadConfigResult, Runtime, SpecFile, WatchOptions, WatcherEventType } from "@bamboocss/types";
|
|
6
6
|
import { Message, Root } from "postcss";
|
|
7
7
|
|
|
@@ -52,6 +52,17 @@ declare class BambooContext extends Generator {
|
|
|
52
52
|
diff: DiffEngine;
|
|
53
53
|
explicitDeps: string[];
|
|
54
54
|
constructor(conf: LoadConfigResult);
|
|
55
|
+
/**
|
|
56
|
+
* Report `css()` calls whose styles the build could not fully see.
|
|
57
|
+
*
|
|
58
|
+
* Only under `cssMode: 'grouped'`, and only as a warning: the build is not wrong, the
|
|
59
|
+
* call site is unresolvable, and erroring would reject code that an `atomic` build
|
|
60
|
+
* accepts. But under `grouped` that call renders the element with *no* styles rather
|
|
61
|
+
* than merely losing a declaration, so it must not be silent.
|
|
62
|
+
*/
|
|
63
|
+
reportUnresolvedStyles: (result: {
|
|
64
|
+
unresolved?: ParserResult["unresolved"];
|
|
65
|
+
}) => void;
|
|
55
66
|
private getExplicitDependencies;
|
|
56
67
|
initMessage: () => string;
|
|
57
68
|
getFiles: () => string[];
|
|
@@ -61,6 +72,18 @@ declare class BambooContext extends Generator {
|
|
|
61
72
|
files: string[];
|
|
62
73
|
results: ParserResult[];
|
|
63
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* Refresh the group registry the generated `css()` consults.
|
|
77
|
+
*
|
|
78
|
+
* `codegen` emits it empty — it runs on config change, before anything is extracted — so
|
|
79
|
+
* this is the pass that fills it in. Called after extraction rather than alongside the
|
|
80
|
+
* CSS, because the PostCSS plugin never writes a stylesheet to disk at all and would
|
|
81
|
+
* otherwise never get one.
|
|
82
|
+
*
|
|
83
|
+
* Safe to run late or not at all: the runtime *adds* atomic names to the group class
|
|
84
|
+
* rather than replacing it, so a stale registry costs a class that matches nothing.
|
|
85
|
+
*/
|
|
86
|
+
writeGroupRegistry: () => Promise<PromiseSettledResult<void>[]> | undefined;
|
|
64
87
|
writeCss: (sheet?: Stylesheet) => Promise<PromiseSettledResult<void>[]> | undefined;
|
|
65
88
|
writeSplitCss: (sheet: Stylesheet) => Promise<void>;
|
|
66
89
|
watchConfig: (cb: (file: string) => void | Promise<void>, opts?: Omit<WatchOptions, "include">) => void;
|
package/dist/index.mjs
CHANGED
|
@@ -8,7 +8,8 @@ import { pluginLightningcss } from "@bamboocss/plugin-lightningcss";
|
|
|
8
8
|
import { pluginSvelte } from "@bamboocss/plugin-svelte";
|
|
9
9
|
import { pluginVue } from "@bamboocss/plugin-vue";
|
|
10
10
|
import browserslist from "browserslist";
|
|
11
|
-
import {
|
|
11
|
+
import { checkNamingAgreement, formatNamingDisagreement, messages } from "@bamboocss/core";
|
|
12
|
+
import { GROUP_REGISTRY_FILE, Generator, generateGroupRegistry } from "@bamboocss/generator";
|
|
12
13
|
import { Project } from "@bamboocss/parser";
|
|
13
14
|
import { debounce } from "perfect-debounce";
|
|
14
15
|
import process$1 from "node:process";
|
|
@@ -25,7 +26,6 @@ import globParent from "glob-parent";
|
|
|
25
26
|
import readline from "node:readline";
|
|
26
27
|
import { lookItUpSync } from "look-it-up";
|
|
27
28
|
import outdent$1, { outdent } from "outdent";
|
|
28
|
-
import { messages } from "@bamboocss/core";
|
|
29
29
|
import { execFileSync } from "child_process";
|
|
30
30
|
//#region \0rolldown/runtime.js
|
|
31
31
|
var __create = Object.create;
|
|
@@ -119,6 +119,7 @@ async function codegen(ctx, ids) {
|
|
|
119
119
|
}
|
|
120
120
|
const promises = artifacts.map((artifact) => limit(() => ctx.output.write(artifact)));
|
|
121
121
|
await Promise.allSettled(promises);
|
|
122
|
+
await ctx.writeGroupRegistry();
|
|
122
123
|
await ctx.hooks["codegen:done"]?.({ changed: ids });
|
|
123
124
|
return {
|
|
124
125
|
box: ctx.initMessage(),
|
|
@@ -1579,6 +1580,21 @@ var OutputEngine = class {
|
|
|
1579
1580
|
};
|
|
1580
1581
|
//#endregion
|
|
1581
1582
|
//#region src/create-context.ts
|
|
1583
|
+
/**
|
|
1584
|
+
* What each loss is, and what the author can do about it.
|
|
1585
|
+
*
|
|
1586
|
+
* Kept apart from the sentence around it so every reason has to answer both questions.
|
|
1587
|
+
* "Make the value static" is the fix for a value the build could not evaluate and no help
|
|
1588
|
+
* at all for two arguments it could not tell apart, and a diagnostic that gives the wrong
|
|
1589
|
+
* instruction is worse than one that gives none.
|
|
1590
|
+
*/
|
|
1591
|
+
const unresolvedReasons = {
|
|
1592
|
+
"unresolvable-value": (prop) => [`${prop} will not reach the stylesheet because its value is not statically known`, "Make the value static to group it."],
|
|
1593
|
+
"missing-property": (prop) => [`${prop} will not reach the stylesheet because its value could not be evaluated at build time`, "Make the value static to group it."],
|
|
1594
|
+
"unenumerable-keys": () => ["an object spread or computed key leaves the build unable to tell which properties this call sets", "Write the properties out, or spread a value the build can resolve, to group it."],
|
|
1595
|
+
"ambiguous-merge": () => ["two of these arguments set the same property, and the build cannot tell a merge from a pair of alternatives", "Merge them into a single object to group it."],
|
|
1596
|
+
"too-many-combinations": () => ["this call has more conditional branches than the build will enumerate", "Split it into fewer conditional properties to group it."]
|
|
1597
|
+
};
|
|
1582
1598
|
var BambooContext = class extends Generator {
|
|
1583
1599
|
runtime;
|
|
1584
1600
|
project;
|
|
@@ -1604,7 +1620,28 @@ var BambooContext = class extends Generator {
|
|
|
1604
1620
|
this.output = new OutputEngine(this);
|
|
1605
1621
|
this.diff = new DiffEngine(this);
|
|
1606
1622
|
this.explicitDeps = this.getExplicitDependencies();
|
|
1623
|
+
const disagreement = checkNamingAgreement(this);
|
|
1624
|
+
if (disagreement) throw new BambooError("NAMING_DISAGREEMENT", formatNamingDisagreement(disagreement));
|
|
1625
|
+
if (config.cssMode === "grouped" && config.staticCss?.css?.length) logger.warn("config", "`staticCss.css` does not back runtime `css()` calls under `cssMode: 'grouped'`. It pre-generates one rule per property and value, while a grouped class names a whole call. The rules are still emitted, but nothing the runtime returns will match them — see https://bamboocss.com/docs/references/config#cssmode");
|
|
1607
1626
|
}
|
|
1627
|
+
/**
|
|
1628
|
+
* Report `css()` calls whose styles the build could not fully see.
|
|
1629
|
+
*
|
|
1630
|
+
* Only under `cssMode: 'grouped'`, and only as a warning: the build is not wrong, the
|
|
1631
|
+
* call site is unresolvable, and erroring would reject code that an `atomic` build
|
|
1632
|
+
* accepts. But under `grouped` that call renders the element with *no* styles rather
|
|
1633
|
+
* than merely losing a declaration, so it must not be silent.
|
|
1634
|
+
*/
|
|
1635
|
+
reportUnresolvedStyles = (result) => {
|
|
1636
|
+
const unresolved = result.unresolved;
|
|
1637
|
+
if (!unresolved?.length) return;
|
|
1638
|
+
for (const entry of unresolved) {
|
|
1639
|
+
const where = `${entry.filePath}:${entry.line}:${entry.column}`;
|
|
1640
|
+
const prop = entry.prop ? `\`${entry.prop}\`` : "a property";
|
|
1641
|
+
const [what, fix] = unresolvedReasons[entry.reason](prop);
|
|
1642
|
+
logger.warn("grouped", `${where} — ${what}. Under \`cssMode: 'grouped'\` one class names the whole \`css()\` call, so this call cannot use one: it falls back to naming each declaration separately and keeps only the ones the build could resolve. ${fix} See https://bamboocss.com/docs/references/config#cssmode`);
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1608
1645
|
getExplicitDependencies = () => {
|
|
1609
1646
|
const { cwd, dependencies } = this.config;
|
|
1610
1647
|
if (!dependencies) return [];
|
|
@@ -1638,6 +1675,7 @@ var BambooContext = class extends Generator {
|
|
|
1638
1675
|
} catch (error) {
|
|
1639
1676
|
logger.caughtError("file:extract", `Failed to parse ${file}`, error);
|
|
1640
1677
|
}
|
|
1678
|
+
if (result) this.reportUnresolvedStyles(result);
|
|
1641
1679
|
measure();
|
|
1642
1680
|
return result;
|
|
1643
1681
|
};
|
|
@@ -1650,16 +1688,49 @@ var BambooContext = class extends Generator {
|
|
|
1650
1688
|
const measure = logger.time.debug(`Parsed ${file}`);
|
|
1651
1689
|
const result = this.project.parseSourceFile(file, encoder);
|
|
1652
1690
|
measure();
|
|
1691
|
+
if (result) this.reportUnresolvedStyles(result);
|
|
1653
1692
|
if (!result || result.isEmpty() || encoder.isEmpty()) return;
|
|
1654
1693
|
filesWithCss.push(file);
|
|
1655
1694
|
results.push(result);
|
|
1656
1695
|
});
|
|
1696
|
+
this.writeGroupRegistry();
|
|
1657
1697
|
return {
|
|
1658
1698
|
filesWithCss,
|
|
1659
1699
|
files,
|
|
1660
1700
|
results
|
|
1661
1701
|
};
|
|
1662
1702
|
};
|
|
1703
|
+
/**
|
|
1704
|
+
* Refresh the group registry the generated `css()` consults.
|
|
1705
|
+
*
|
|
1706
|
+
* `codegen` emits it empty — it runs on config change, before anything is extracted — so
|
|
1707
|
+
* this is the pass that fills it in. Called after extraction rather than alongside the
|
|
1708
|
+
* CSS, because the PostCSS plugin never writes a stylesheet to disk at all and would
|
|
1709
|
+
* otherwise never get one.
|
|
1710
|
+
*
|
|
1711
|
+
* Safe to run late or not at all: the runtime *adds* atomic names to the group class
|
|
1712
|
+
* rather than replacing it, so a stale registry costs a class that matches nothing.
|
|
1713
|
+
*/
|
|
1714
|
+
writeGroupRegistry = () => {
|
|
1715
|
+
if (this.config.cssMode !== "grouped") return;
|
|
1716
|
+
const names = this.getGroupRegistry();
|
|
1717
|
+
if (!names.length) {
|
|
1718
|
+
const existing = this.runtime.path.join(...this.paths.css, this.file.ext(GROUP_REGISTRY_FILE));
|
|
1719
|
+
if (this.runtime.fs.existsSync(existing)) return;
|
|
1720
|
+
}
|
|
1721
|
+
const registry = generateGroupRegistry(this, names);
|
|
1722
|
+
return this.output.write({
|
|
1723
|
+
id: "css-fn",
|
|
1724
|
+
dir: this.paths.css,
|
|
1725
|
+
files: [{
|
|
1726
|
+
file: this.file.ext(GROUP_REGISTRY_FILE),
|
|
1727
|
+
code: registry.js
|
|
1728
|
+
}, {
|
|
1729
|
+
file: this.file.extDts(GROUP_REGISTRY_FILE),
|
|
1730
|
+
code: registry.dts
|
|
1731
|
+
}]
|
|
1732
|
+
});
|
|
1733
|
+
};
|
|
1663
1734
|
writeCss = (sheet) => {
|
|
1664
1735
|
logger.info("css", this.runtime.path.join(...this.paths.root, "styles.css"));
|
|
1665
1736
|
return this.output.write({
|
|
@@ -2266,6 +2337,7 @@ var Builder = class {
|
|
|
2266
2337
|
const files = ctx.getFiles();
|
|
2267
2338
|
const done = logger.time.info("Extracted in");
|
|
2268
2339
|
files.map((file) => this.extractFile(ctx, file));
|
|
2340
|
+
ctx.writeGroupRegistry();
|
|
2269
2341
|
done();
|
|
2270
2342
|
};
|
|
2271
2343
|
isValidRoot = (root) => {
|
|
@@ -2504,6 +2576,7 @@ async function generate(config, configPath) {
|
|
|
2504
2576
|
if (ctx.config.pruneUnusedKeyframes) ctx.pruneKeyframes(sheet, collectKeyframeReferences(ctx, keyframeNames(ctx)));
|
|
2505
2577
|
const css = ctx.getCss(sheet);
|
|
2506
2578
|
await ctx.runtime.fs.writeFile(outfile, css);
|
|
2579
|
+
await ctx.writeGroupRegistry();
|
|
2507
2580
|
done();
|
|
2508
2581
|
};
|
|
2509
2582
|
ctx.watchFiles(async (event, file) => {
|
|
@@ -2574,7 +2647,7 @@ const ensure = (outPath) => {
|
|
|
2574
2647
|
//#endregion
|
|
2575
2648
|
//#region src/setup-config.ts
|
|
2576
2649
|
async function setupConfig(cwd, opts = {}) {
|
|
2577
|
-
const { force, outExtension,
|
|
2650
|
+
const { force, outExtension, outdir = "styled-system" } = opts;
|
|
2578
2651
|
let configFile;
|
|
2579
2652
|
try {
|
|
2580
2653
|
configFile = findConfig({ cwd });
|
|
@@ -2608,8 +2681,6 @@ export default defineConfig({
|
|
|
2608
2681
|
|
|
2609
2682
|
// The output directory for your css system
|
|
2610
2683
|
outdir: ${JSON.stringify(outdir)},
|
|
2611
|
-
${jsxFramework ? `\n // The JSX framework to use\njsxFramework: '${jsxFramework}',` : ""}
|
|
2612
|
-
${syntax ? `\n // The CSS Syntax to use to use\nsyntax: '${syntax}'` : ""}
|
|
2613
2684
|
})
|
|
2614
2685
|
`;
|
|
2615
2686
|
const filePath = join(cwd, file);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"description": "The core css bamboo library",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,18 +52,18 @@
|
|
|
52
52
|
"postcss": "8.5.14",
|
|
53
53
|
"ts-morph": "28.0.0",
|
|
54
54
|
"ts-pattern": "5.9.0",
|
|
55
|
-
"@bamboocss/config": "1.
|
|
56
|
-
"@bamboocss/core": "1.
|
|
57
|
-
"@bamboocss/generator": "1.
|
|
58
|
-
"@bamboocss/logger": "1.
|
|
59
|
-
"@bamboocss/parser": "1.
|
|
60
|
-
"@bamboocss/plugin-lightningcss": "1.
|
|
61
|
-
"@bamboocss/plugin-svelte": "1.
|
|
62
|
-
"@bamboocss/plugin-vue": "1.
|
|
63
|
-
"@bamboocss/reporter": "1.
|
|
64
|
-
"@bamboocss/shared": "1.
|
|
65
|
-
"@bamboocss/token-dictionary": "1.
|
|
66
|
-
"@bamboocss/types": "1.
|
|
55
|
+
"@bamboocss/config": "1.16.1",
|
|
56
|
+
"@bamboocss/core": "1.16.1",
|
|
57
|
+
"@bamboocss/generator": "1.16.1",
|
|
58
|
+
"@bamboocss/logger": "1.16.1",
|
|
59
|
+
"@bamboocss/parser": "1.16.1",
|
|
60
|
+
"@bamboocss/plugin-lightningcss": "1.16.1",
|
|
61
|
+
"@bamboocss/plugin-svelte": "1.16.1",
|
|
62
|
+
"@bamboocss/plugin-vue": "1.16.1",
|
|
63
|
+
"@bamboocss/reporter": "1.16.1",
|
|
64
|
+
"@bamboocss/shared": "1.16.1",
|
|
65
|
+
"@bamboocss/token-dictionary": "1.16.1",
|
|
66
|
+
"@bamboocss/types": "1.16.1"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/fs-extra": "11.0.4",
|