@teacss/postcss 0.5.1 → 0.6.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/README.md +2 -3
- package/dist/esm.mjs +12 -7
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
PostCSS 8 integration for TeaCSS.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
-
npm install teacss
|
|
7
|
-
npm install --save-dev @teacss/postcss postcss
|
|
6
|
+
npm install --save-dev teacss @teacss/postcss postcss
|
|
8
7
|
```
|
|
9
8
|
|
|
10
9
|
```js
|
|
@@ -25,7 +24,7 @@ export default {
|
|
|
25
24
|
```
|
|
26
25
|
|
|
27
26
|
```css
|
|
28
|
-
@
|
|
27
|
+
@presets "standard";
|
|
29
28
|
@source "./src/**/*.{ts,tsx,html}";
|
|
30
29
|
@teacss;
|
|
31
30
|
```
|
package/dist/esm.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { readFile, stat } from "node:fs/promises";
|
|
2
2
|
import { dirname, extname, join, normalize, relative, resolve } from "node:path";
|
|
3
3
|
import process from "node:process";
|
|
4
|
-
import { createRecoveryConfigLoader, entryDiscoveryFiles, getConfigSourcesFromError } from "@teacss/config";
|
|
4
|
+
import { ROLE_DIRECTIVES, createRecoveryConfigLoader, entryDiscoveryFiles, getConfigSourcesFromError } from "@teacss/config";
|
|
5
5
|
import { createGenerator, expandClassGroups, expandVariantGroup, splitClassTokens } from "@teacss/core";
|
|
6
6
|
import { hasIconFn, hasThemeFn } from "@teacss/rule-helpers";
|
|
7
7
|
import { defaultFilesystemGlobs } from "@teacss/runtime";
|
|
8
8
|
import postcss from "postcss";
|
|
9
9
|
import { glob, isDynamicPattern } from "tinyglobby";
|
|
10
|
-
import { formatMissingApplyTokens, missingApplyTokens, prepareApplyUtilities, renderStandaloneApplyUtility, resolveApplyTokens, resolveCssFunction, resolveScreenQuery } from "@teacss/directives/core";
|
|
10
|
+
import { formatMissingApplyTokens, generateApplyPreflights, missingApplyTokens, prepareApplyUtilities, renderStandaloneApplyUtility, resolveApplyTokens, resolveCssFunction, resolveScreenQuery } from "@teacss/directives/core";
|
|
11
11
|
import { generate, parse, walk } from "css-tree";
|
|
12
12
|
//#region src/apply.ts
|
|
13
13
|
/**
|
|
@@ -36,10 +36,11 @@ function readGroupApply(rule, directiveName) {
|
|
|
36
36
|
consumed
|
|
37
37
|
} : void 0;
|
|
38
38
|
}
|
|
39
|
-
async function parseApply(root, generator, directiveName) {
|
|
39
|
+
async function parseApply(root, generator, directiveName, filename) {
|
|
40
40
|
const rules = [];
|
|
41
41
|
const lastParentAfterNode = /* @__PURE__ */ new Map();
|
|
42
42
|
const applyHosts = /* @__PURE__ */ new Map();
|
|
43
|
+
const generated = [];
|
|
43
44
|
root.walkAtRules(directiveName, (rule) => {
|
|
44
45
|
rules.push(rule);
|
|
45
46
|
});
|
|
@@ -58,6 +59,7 @@ async function parseApply(root, generator, directiveName) {
|
|
|
58
59
|
for (const { parsed, rule, consumed } of resolvedRules) {
|
|
59
60
|
const hostRule = rule.parent;
|
|
60
61
|
if (!hostRule) continue;
|
|
62
|
+
for (const [, utilities] of parsed) if (utilities) generated.push(...utilities);
|
|
61
63
|
for (const node of consumed) node.remove();
|
|
62
64
|
const source = rule.source;
|
|
63
65
|
const utils = prepareApplyUtilities(parsed, generator.parentOrders);
|
|
@@ -83,7 +85,7 @@ async function parseApply(root, generator, directiveName) {
|
|
|
83
85
|
applyHosts.set(hostRule, applyHost);
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
|
-
const css = renderStandaloneApplyUtility(applyHost, utility);
|
|
88
|
+
const css = renderStandaloneApplyUtility(applyHost, utility, filename);
|
|
87
89
|
const parsedCss = postcss.parse(css);
|
|
88
90
|
parsedCss.walkDecls((declaration) => {
|
|
89
91
|
declaration.source = source;
|
|
@@ -105,6 +107,8 @@ async function parseApply(root, generator, directiveName) {
|
|
|
105
107
|
rule.remove();
|
|
106
108
|
if (hostRule.type === "rule" && !hostRule.nodes?.length) hostRule.remove();
|
|
107
109
|
}
|
|
110
|
+
const dependencies = await generateApplyPreflights(generator, generated, filename);
|
|
111
|
+
if (dependencies) root.append(postcss.parse(dependencies));
|
|
108
112
|
}
|
|
109
113
|
//#endregion
|
|
110
114
|
//#region src/screen.ts
|
|
@@ -218,10 +222,11 @@ function replaceRuleWithCss(rule, generatedCss) {
|
|
|
218
222
|
rule.replaceWith(css);
|
|
219
223
|
}
|
|
220
224
|
const ENTRY_STATEMENT_DIRECTIVES = /* @__PURE__ */ new Set([
|
|
221
|
-
"
|
|
225
|
+
"presets",
|
|
222
226
|
"source",
|
|
223
227
|
"shortcut",
|
|
224
|
-
"safelist"
|
|
228
|
+
"safelist",
|
|
229
|
+
...ROLE_DIRECTIVES
|
|
225
230
|
]);
|
|
226
231
|
function removeEntryDirectives(root) {
|
|
227
232
|
root.walkAtRules((rule) => {
|
|
@@ -412,7 +417,7 @@ function createPlugin(options) {
|
|
|
412
417
|
}
|
|
413
418
|
const { generator } = state;
|
|
414
419
|
for (const file of getConfigSourceFiles(state.sources)) addDependency(file);
|
|
415
|
-
await parseApply(root, generator, directiveMap.apply);
|
|
420
|
+
await parseApply(root, generator, directiveMap.apply, from);
|
|
416
421
|
await parseTheme(root, generator);
|
|
417
422
|
await parseScreen(root, generator, directiveMap.screen);
|
|
418
423
|
removeEntryDirectives(root);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teacss/postcss",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "PostCSS plugin for TeaCSS — generate utilities within a PostCSS pipeline.",
|
|
5
5
|
"homepage": "https://css.teasim.com",
|
|
6
6
|
"funding": "https://github.com/sponsors/billgo",
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
"dev": "tsdown --watch"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@teacss/config": "0.
|
|
27
|
-
"@teacss/core": "0.
|
|
28
|
-
"@teacss/directives": "0.
|
|
29
|
-
"@teacss/rule-helpers": "0.
|
|
30
|
-
"@teacss/runtime": "0.
|
|
26
|
+
"@teacss/config": "0.6.0",
|
|
27
|
+
"@teacss/core": "0.6.0",
|
|
28
|
+
"@teacss/directives": "0.6.0",
|
|
29
|
+
"@teacss/rule-helpers": "0.6.0",
|
|
30
|
+
"@teacss/runtime": "0.6.0",
|
|
31
31
|
"css-tree": "^3.2.1",
|
|
32
32
|
"tinyglobby": "^0.2.17"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@teacss/preset-standard": "0.
|
|
35
|
+
"@teacss/preset-standard": "0.6.0",
|
|
36
36
|
"@types/css-tree": "^3.2.0",
|
|
37
37
|
"consola": "^3.4.2",
|
|
38
38
|
"magic-string": "^1.2.3",
|