@bamboocss/node 1.26.0 → 1.28.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/README.md +33 -197
- package/dist/index.cjs +7 -5
- package/dist/index.mjs +7 -5
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -1,208 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
# @bamboocss/node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
- `styled-system` (index.js, index.d.ts)
|
|
6
|
-
- `package.json`
|
|
3
|
+
The Node runtime behind Bamboo CSS: config loading, context creation, extraction and the write side of codegen and
|
|
4
|
+
`styles.css`.
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
6
|
+
This is an internal package. It is what `@bamboocss/dev` (the CLI), `@bamboocss/postcss` and `@bamboocss/vite` are built
|
|
7
|
+
on, and it is versioned with them — most projects should install one of those instead. User-facing documentation lives
|
|
8
|
+
at [bamboocss.com/docs](https://bamboocss.com/docs).
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
colors: [{ group: 'red', key: 'red.400', value: '...' }],
|
|
15
|
-
fonts: [],
|
|
16
|
-
}
|
|
10
|
+
## Exports
|
|
17
11
|
|
|
18
|
-
|
|
19
|
-
const { value } = tokens[path] || {}
|
|
20
|
-
return value
|
|
21
|
-
}
|
|
12
|
+
Everything below is exported from `@bamboocss/node`.
|
|
22
13
|
|
|
23
|
-
|
|
24
|
-
const { variable } = tokens[path] || {}
|
|
25
|
-
return variable
|
|
26
|
-
}
|
|
27
|
-
```
|
|
14
|
+
### Context
|
|
28
15
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
- `loadConfigAndCreateContext({ cwd?, config?, configPath? })` – resolve the config file, merge presets and inline
|
|
17
|
+
overrides, auto-inject the built-in plugins (`vue`, `svelte`, `lightningcss`), and return a `BambooContext`.
|
|
18
|
+
- `BambooContext` – the resolved config plus everything derived from it: tokens, utilities, conditions, recipes,
|
|
19
|
+
patterns, the `ts-morph` project, the output engine and the diff engine.
|
|
20
|
+
- `Builder` – the incremental driver the bundler plugins use. It owns context setup, tracks which files and config
|
|
21
|
+
dependencies changed, re-extracts only those, and hands back the stylesheet (`toCss`) or writes it into a PostCSS root
|
|
22
|
+
(`write`).
|
|
32
23
|
|
|
33
|
-
|
|
24
|
+
### Commands
|
|
34
25
|
|
|
35
|
-
|
|
26
|
+
Each takes a `BambooContext`, and each backs the CLI command of the same name.
|
|
36
27
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
- `generate(config, configPath?)` – the full build, including `--watch`. Unlike the rest, it creates its own context.
|
|
29
|
+
- `codegen(ctx, ids?)` – write the generated `styled-system` artifacts.
|
|
30
|
+
- `cssgen(ctx, options)` – write the stylesheet.
|
|
31
|
+
- `analyze(ctx, options?)` – report token and recipe usage.
|
|
32
|
+
- `debug(ctx, options)` – write the resolved config, per-file AST and per-file CSS.
|
|
33
|
+
- `buildInfo(ctx, outfile)` – write the static extraction result as JSON, for consumers that ship it instead of source.
|
|
34
|
+
- `spec(ctx, options)` – write the spec files.
|
|
41
35
|
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
"name": "dot-bamboo",
|
|
45
|
-
"description": "...",
|
|
46
|
-
"exports": {
|
|
47
|
-
"./tokens": {
|
|
48
|
-
"import": "./generated/tokens/index.mjs"
|
|
49
|
-
},
|
|
50
|
-
"./css": {
|
|
51
|
-
"import": "./generated/css/index.mjs"
|
|
52
|
-
}
|
|
53
|
-
},
|
|
54
|
-
"typeVersions": {
|
|
55
|
-
"*": {
|
|
56
|
-
"tokens": ["./generated/tokens"],
|
|
57
|
-
"css": ["./generated/css"]
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
```
|
|
36
|
+
### Setup and utilities
|
|
62
37
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
exports: ['tokens', 'css'],
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
writePackage(pkg)
|
|
74
|
-
|
|
75
|
-
updateTsConfig({
|
|
76
|
-
compilerOptions: {
|
|
77
|
-
paths: {
|
|
78
|
-
'design-system': ['./.bamboo'],
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
updateGitIgnore({ comment: '# Bamboo', path: '.@bamboocss/dev' })
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
```ts
|
|
87
|
-
type ConditionType =
|
|
88
|
-
| 'color-scheme'
|
|
89
|
-
| 'resolution'
|
|
90
|
-
| 'writing-mode'
|
|
91
|
-
| 'pseudo'
|
|
92
|
-
| 'selector'
|
|
93
|
-
| 'viewport'
|
|
94
|
-
| 'interaction-media'
|
|
95
|
-
| 'reduced-motion'
|
|
96
|
-
| 'reduced-data'
|
|
97
|
-
| 'reduced-transparent'
|
|
98
|
-
| 'contrast'
|
|
99
|
-
|
|
100
|
-
const conditions = {
|
|
101
|
-
dark: {
|
|
102
|
-
type: 'color-scheme',
|
|
103
|
-
value: '[data-theme=dark]',
|
|
104
|
-
colorScheme: 'dark',
|
|
105
|
-
},
|
|
106
|
-
darkDimmed: {
|
|
107
|
-
type: 'color-scheme',
|
|
108
|
-
value: '[data-theme=dark_dimmed]',
|
|
109
|
-
colorScheme: 'dark',
|
|
110
|
-
},
|
|
111
|
-
ltr: {
|
|
112
|
-
type: 'dir',
|
|
113
|
-
value: '[dir=rtl]',
|
|
114
|
-
},
|
|
115
|
-
rtl: {
|
|
116
|
-
type: 'dir',
|
|
117
|
-
value: '[dir=rtl]',
|
|
118
|
-
},
|
|
119
|
-
hover: {
|
|
120
|
-
type: 'pseudo',
|
|
121
|
-
value: '&:hover',
|
|
122
|
-
},
|
|
123
|
-
focus: {
|
|
124
|
-
type: 'pseudo',
|
|
125
|
-
value: '&:focus',
|
|
126
|
-
},
|
|
127
|
-
sm: {
|
|
128
|
-
type: 'viewport',
|
|
129
|
-
value: '@media (min-width: 480px)',
|
|
130
|
-
},
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
```ts
|
|
135
|
-
const defaults = {
|
|
136
|
-
className: ({ prop, value }) => `${prop}-${esc(value)}`,
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const tt = defineConfig({
|
|
140
|
-
utilities: [
|
|
141
|
-
{
|
|
142
|
-
properties: {
|
|
143
|
-
display: {
|
|
144
|
-
className: ({ value }) => `d-${value}`,
|
|
145
|
-
transform(value) {
|
|
146
|
-
return { display: value }
|
|
147
|
-
},
|
|
148
|
-
values: {
|
|
149
|
-
fl: 'flex',
|
|
150
|
-
ib: 'inline-block',
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
background: {
|
|
154
|
-
className: ({ prop, value }) => `bg-${value}`,
|
|
155
|
-
values: ({ tokens }) => ({
|
|
156
|
-
...tokens.colors,
|
|
157
|
-
inherit: 'inherit',
|
|
158
|
-
}),
|
|
159
|
-
},
|
|
160
|
-
color: {
|
|
161
|
-
className: ({ prop, value }) => `text-${value}`,
|
|
162
|
-
values: (tokens) => ({ ...tokens.colors }),
|
|
163
|
-
},
|
|
164
|
-
fill: { values: 'colors' },
|
|
165
|
-
lineClamp: {
|
|
166
|
-
className: ({ prop, value }) => `clamp-${value}`,
|
|
167
|
-
values: {
|
|
168
|
-
'1': {
|
|
169
|
-
'--line-clamp': '1',
|
|
170
|
-
},
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
shorthands: {
|
|
175
|
-
bg: 'background',
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
{
|
|
180
|
-
properties: {
|
|
181
|
-
strokeWidth: {
|
|
182
|
-
values: { '1': '1px', 2: '2px' },
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
{
|
|
188
|
-
properties: {
|
|
189
|
-
paddingLeft: { values: 'space', className: 'pl' },
|
|
190
|
-
paddingRight: { values: 'space', className: 'pr' },
|
|
191
|
-
paddingX: {
|
|
192
|
-
className: 'px',
|
|
193
|
-
values({ theme, map }) {
|
|
194
|
-
return map(theme.space, (value) => ({
|
|
195
|
-
paddingLeft: value,
|
|
196
|
-
paddingRight: value,
|
|
197
|
-
}))
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
shorthands: {
|
|
202
|
-
pl: 'paddingLeft',
|
|
203
|
-
px: 'paddingX',
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
],
|
|
207
|
-
})
|
|
208
|
-
```
|
|
38
|
+
- `setupConfig(cwd, options?)` / `setupPostcss(cwd)` – scaffold `bamboo.config.ts` and the PostCSS config.
|
|
39
|
+
- `setupGitIgnore(ctx)` – add the outdir to `.gitignore`, unless `config.gitignore` is off.
|
|
40
|
+
- `parseDependency(fileOrGlob)` – turn a `config.dependencies` entry into a PostCSS `dependency` or `dir-dependency`
|
|
41
|
+
message.
|
|
42
|
+
- `setLogStream({ cwd, logfile })` – tee logs to a file.
|
|
43
|
+
- `startProfiling(cwd, prefix, isWatching?)` – start a V8 CPU profile; the returned function stops it and writes
|
|
44
|
+
`bamboo-{prefix}-{timestamp}.cpuprofile` into `cwd`.
|
package/dist/index.cjs
CHANGED
|
@@ -2117,10 +2117,11 @@ function parseDependency(fileOrGlob) {
|
|
|
2117
2117
|
//#region src/token-references.ts
|
|
2118
2118
|
/**
|
|
2119
2119
|
* `token.var('colors.red.300')` and `token('spacing.4')`, including the whitespace a
|
|
2120
|
-
* formatter may leave behind. The parser
|
|
2121
|
-
*
|
|
2122
|
-
*
|
|
2123
|
-
* built somewhere the extractor cannot
|
|
2120
|
+
* formatter may leave behind. The parser reports both, resolving constants and template
|
|
2121
|
+
* literals through them — `token.var()` included, since it is recorded as its own kind
|
|
2122
|
+
* rather than dropped for having a property access as its callee. Scanning the text still
|
|
2123
|
+
* earns its place twice over: it covers a path built somewhere the extractor cannot
|
|
2124
|
+
* follow, and it covers the callers below that supply no `results` at all.
|
|
2124
2125
|
*/
|
|
2125
2126
|
const TOKEN_CALL = /\btoken(?:\s*\.\s*var)?\s*\(\s*['"`]([^'"`]+)['"`]/g;
|
|
2126
2127
|
/**
|
|
@@ -2164,7 +2165,8 @@ function* sourceTexts(ctx) {
|
|
|
2164
2165
|
* costs bytes; dropping one that is breaks the page, so the bias belongs on this side.
|
|
2165
2166
|
*
|
|
2166
2167
|
* `results` is a second, redundant source for the same paths: the extractor resolves one
|
|
2167
|
-
* built from a constant
|
|
2168
|
+
* built from a constant — for `token.var()` as well as `token()` — which the text scan reads
|
|
2169
|
+
* literally and fails to look up. Callers
|
|
2168
2170
|
* that cannot supply it — the watch rebuild and the PostCSS plugin, where re-parsing would
|
|
2169
2171
|
* encode every style a second time — pass none, and stay correct only because a path the
|
|
2170
2172
|
* scan misses can lose nothing: `token()` hands javascript a literal for exactly the
|
package/dist/index.mjs
CHANGED
|
@@ -2102,10 +2102,11 @@ function parseDependency(fileOrGlob) {
|
|
|
2102
2102
|
//#region src/token-references.ts
|
|
2103
2103
|
/**
|
|
2104
2104
|
* `token.var('colors.red.300')` and `token('spacing.4')`, including the whitespace a
|
|
2105
|
-
* formatter may leave behind. The parser
|
|
2106
|
-
*
|
|
2107
|
-
*
|
|
2108
|
-
* built somewhere the extractor cannot
|
|
2105
|
+
* formatter may leave behind. The parser reports both, resolving constants and template
|
|
2106
|
+
* literals through them — `token.var()` included, since it is recorded as its own kind
|
|
2107
|
+
* rather than dropped for having a property access as its callee. Scanning the text still
|
|
2108
|
+
* earns its place twice over: it covers a path built somewhere the extractor cannot
|
|
2109
|
+
* follow, and it covers the callers below that supply no `results` at all.
|
|
2109
2110
|
*/
|
|
2110
2111
|
const TOKEN_CALL = /\btoken(?:\s*\.\s*var)?\s*\(\s*['"`]([^'"`]+)['"`]/g;
|
|
2111
2112
|
/**
|
|
@@ -2149,7 +2150,8 @@ function* sourceTexts(ctx) {
|
|
|
2149
2150
|
* costs bytes; dropping one that is breaks the page, so the bias belongs on this side.
|
|
2150
2151
|
*
|
|
2151
2152
|
* `results` is a second, redundant source for the same paths: the extractor resolves one
|
|
2152
|
-
* built from a constant
|
|
2153
|
+
* built from a constant — for `token.var()` as well as `token()` — which the text scan reads
|
|
2154
|
+
* literally and fails to look up. Callers
|
|
2153
2155
|
* that cannot supply it — the watch rebuild and the PostCSS plugin, where re-parsing would
|
|
2154
2156
|
* encode every style a second time — pass none, and stay correct only because a path the
|
|
2155
2157
|
* scan misses can lose nothing: `token()` hands javascript a literal for exactly the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/node",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.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.26",
|
|
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.28.1",
|
|
56
|
+
"@bamboocss/core": "1.28.1",
|
|
57
|
+
"@bamboocss/generator": "1.28.1",
|
|
58
|
+
"@bamboocss/logger": "1.28.1",
|
|
59
|
+
"@bamboocss/parser": "1.28.1",
|
|
60
|
+
"@bamboocss/plugin-lightningcss": "1.28.1",
|
|
61
|
+
"@bamboocss/plugin-svelte": "1.28.1",
|
|
62
|
+
"@bamboocss/plugin-vue": "1.28.1",
|
|
63
|
+
"@bamboocss/reporter": "1.28.1",
|
|
64
|
+
"@bamboocss/shared": "1.28.1",
|
|
65
|
+
"@bamboocss/token-dictionary": "1.28.1",
|
|
66
|
+
"@bamboocss/types": "1.28.1"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/fs-extra": "11.0.4",
|