boss-css 0.0.15 → 0.0.16
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/cli/tasks/init.cjs +11 -9
- package/dist/cli/tasks/init.mjs +11 -9
- package/dist/devtools-app/index.mjs +2 -2
- package/dist/parser/jsx/extractCode.cjs +3 -2
- package/dist/parser/jsx/extractCode.mjs +3 -2
- package/dist/parser/jsx/extractProps.cjs +7 -1
- package/dist/parser/jsx/extractProps.mjs +7 -1
- package/dist/tasks/postcss.cjs +16 -5
- package/dist/tasks/postcss.mjs +16 -5
- package/package.json +1 -7
|
@@ -48,12 +48,13 @@ function extractCode(code) {
|
|
|
48
48
|
}
|
|
49
49
|
if (!isInside) continue;
|
|
50
50
|
if (type === "jsx") {
|
|
51
|
-
|
|
51
|
+
const openedCurrentContext = !isIgnored && openingRegexp.test(current);
|
|
52
|
+
if (openedCurrentContext) {
|
|
52
53
|
stack.push(current);
|
|
53
54
|
currentOpener = current;
|
|
54
55
|
isIgnored = Boolean(ignoredContexts[current]);
|
|
55
56
|
}
|
|
56
|
-
if (current === map[currentOpener]) {
|
|
57
|
+
if (!openedCurrentContext && current === map[currentOpener]) {
|
|
57
58
|
stack.pop();
|
|
58
59
|
currentOpener = stack.at(-1) || "";
|
|
59
60
|
isIgnored = false;
|
|
@@ -47,12 +47,13 @@ function extractCode(code) {
|
|
|
47
47
|
}
|
|
48
48
|
if (!isInside) continue;
|
|
49
49
|
if (type === "jsx") {
|
|
50
|
-
|
|
50
|
+
const openedCurrentContext = !isIgnored && openingRegexp.test(current);
|
|
51
|
+
if (openedCurrentContext) {
|
|
51
52
|
stack.push(current);
|
|
52
53
|
currentOpener = current;
|
|
53
54
|
isIgnored = Boolean(ignoredContexts[current]);
|
|
54
55
|
}
|
|
55
|
-
if (current === map[currentOpener]) {
|
|
56
|
+
if (!openedCurrentContext && current === map[currentOpener]) {
|
|
56
57
|
stack.pop();
|
|
57
58
|
currentOpener = stack.at(-1) || "";
|
|
58
59
|
isIgnored = false;
|
|
@@ -17,7 +17,13 @@ async function extractPropTrees(codes) {
|
|
|
17
17
|
return expressions.map(extractPropTreeFromExpression);
|
|
18
18
|
}
|
|
19
19
|
const normalizeCode = (code) => {
|
|
20
|
-
|
|
20
|
+
let end = code.length - 1;
|
|
21
|
+
while (end >= 0 && /\s/.test(code[end])) end -= 1;
|
|
22
|
+
if (end < 0 || code[end] !== ">") return code;
|
|
23
|
+
let prev = end - 1;
|
|
24
|
+
while (prev >= 0 && /\s/.test(code[prev])) prev -= 1;
|
|
25
|
+
if (prev >= 0 && code[prev] === "/") return code;
|
|
26
|
+
return `${code.slice(0, end)}/${code.slice(end)}`;
|
|
21
27
|
};
|
|
22
28
|
const extractPropTreeFromCode = async (code) => {
|
|
23
29
|
const { body } = await _swc_core.default.parse(normalizeCode(code), {
|
|
@@ -15,7 +15,13 @@ async function extractPropTrees(codes) {
|
|
|
15
15
|
return expressions.map(extractPropTreeFromExpression);
|
|
16
16
|
}
|
|
17
17
|
const normalizeCode = (code) => {
|
|
18
|
-
|
|
18
|
+
let end = code.length - 1;
|
|
19
|
+
while (end >= 0 && /\s/.test(code[end])) end -= 1;
|
|
20
|
+
if (end < 0 || code[end] !== ">") return code;
|
|
21
|
+
let prev = end - 1;
|
|
22
|
+
while (prev >= 0 && /\s/.test(code[prev])) prev -= 1;
|
|
23
|
+
if (prev >= 0 && code[prev] === "/") return code;
|
|
24
|
+
return `${code.slice(0, end)}/${code.slice(end)}`;
|
|
19
25
|
};
|
|
20
26
|
const extractPropTreeFromCode = async (code) => {
|
|
21
27
|
const { body } = await swc.parse(normalizeCode(code), {
|
package/dist/tasks/postcss.cjs
CHANGED
|
@@ -91,7 +91,7 @@ const runPostcss = async (root, result, options = {}) => {
|
|
|
91
91
|
promises.push(require_processFile.default(file));
|
|
92
92
|
});
|
|
93
93
|
const processedFiles = await Promise.allSettled(promises);
|
|
94
|
-
const
|
|
94
|
+
const onParseTasks = [];
|
|
95
95
|
for (const settled of processedFiles) {
|
|
96
96
|
if (settled.status !== "fulfilled") continue;
|
|
97
97
|
const processed = settled.value;
|
|
@@ -99,9 +99,20 @@ const runPostcss = async (root, result, options = {}) => {
|
|
|
99
99
|
if (!value || !processed?.changed) continue;
|
|
100
100
|
const changedPath = value.path ? node_path.default.resolve(value.path) : null;
|
|
101
101
|
if (changedPath) api.css?.removeSource?.(changedPath);
|
|
102
|
-
|
|
102
|
+
const sourcePath = changedPath ?? value.path ?? "(unknown file)";
|
|
103
|
+
onParseTasks.push({
|
|
104
|
+
filePath: sourcePath,
|
|
105
|
+
promise: api.trigger("onParse", value)
|
|
106
|
+
});
|
|
103
107
|
}
|
|
104
|
-
await Promise.allSettled(
|
|
108
|
+
(await Promise.allSettled(onParseTasks.map((task) => task.promise))).forEach((parseResult, index) => {
|
|
109
|
+
if (parseResult.status !== "rejected") return;
|
|
110
|
+
const task = onParseTasks[index];
|
|
111
|
+
const relativePath = node_path.default.relative(baseDir ?? process.cwd(), task.filePath);
|
|
112
|
+
const sourceLabel = relativePath && !relativePath.startsWith("..") ? relativePath : task.filePath;
|
|
113
|
+
const reason = parseResult.reason instanceof Error ? parseResult.reason.message : String(parseResult.reason ?? "Unknown parsing error");
|
|
114
|
+
result.warn(`[boss-css] Failed parsing ${sourceLabel}: ${reason}`, { plugin: "boss-postcss-plugin" });
|
|
115
|
+
});
|
|
105
116
|
const boundaryResult = await require_boundaries.resolveBoundaryOutputs(api, {
|
|
106
117
|
rootDir: baseDir ?? process.cwd(),
|
|
107
118
|
stylesheetPath,
|
|
@@ -119,8 +130,8 @@ const runPostcss = async (root, result, options = {}) => {
|
|
|
119
130
|
const outputText = new Map(boundaryResult.outputs.map((output) => [node_path.default.resolve(output.path), output.text])).get(resolvedFile ?? resolvedStylesheet);
|
|
120
131
|
if (outputText !== void 0) result.root = postcss.default.parse(outputText, result.opts);
|
|
121
132
|
if (api.strategy !== "classname-only") {
|
|
122
|
-
api.file.js.write();
|
|
123
|
-
if (api.file.native?.hasContent) api.file.native.write();
|
|
133
|
+
await api.file.js.write();
|
|
134
|
+
if (api.file.native?.hasContent) await api.file.native.write();
|
|
124
135
|
}
|
|
125
136
|
});
|
|
126
137
|
runQueues.set(queueKey, run);
|
package/dist/tasks/postcss.mjs
CHANGED
|
@@ -88,7 +88,7 @@ const runPostcss = async (root, result, options = {}) => {
|
|
|
88
88
|
promises.push(processFile(file));
|
|
89
89
|
});
|
|
90
90
|
const processedFiles = await Promise.allSettled(promises);
|
|
91
|
-
const
|
|
91
|
+
const onParseTasks = [];
|
|
92
92
|
for (const settled of processedFiles) {
|
|
93
93
|
if (settled.status !== "fulfilled") continue;
|
|
94
94
|
const processed = settled.value;
|
|
@@ -96,9 +96,20 @@ const runPostcss = async (root, result, options = {}) => {
|
|
|
96
96
|
if (!value || !processed?.changed) continue;
|
|
97
97
|
const changedPath = value.path ? path.resolve(value.path) : null;
|
|
98
98
|
if (changedPath) api.css?.removeSource?.(changedPath);
|
|
99
|
-
|
|
99
|
+
const sourcePath = changedPath ?? value.path ?? "(unknown file)";
|
|
100
|
+
onParseTasks.push({
|
|
101
|
+
filePath: sourcePath,
|
|
102
|
+
promise: api.trigger("onParse", value)
|
|
103
|
+
});
|
|
100
104
|
}
|
|
101
|
-
await Promise.allSettled(
|
|
105
|
+
(await Promise.allSettled(onParseTasks.map((task) => task.promise))).forEach((parseResult, index) => {
|
|
106
|
+
if (parseResult.status !== "rejected") return;
|
|
107
|
+
const task = onParseTasks[index];
|
|
108
|
+
const relativePath = path.relative(baseDir ?? process.cwd(), task.filePath);
|
|
109
|
+
const sourceLabel = relativePath && !relativePath.startsWith("..") ? relativePath : task.filePath;
|
|
110
|
+
const reason = parseResult.reason instanceof Error ? parseResult.reason.message : String(parseResult.reason ?? "Unknown parsing error");
|
|
111
|
+
result.warn(`[boss-css] Failed parsing ${sourceLabel}: ${reason}`, { plugin: "boss-postcss-plugin" });
|
|
112
|
+
});
|
|
102
113
|
const boundaryResult = await resolveBoundaryOutputs(api, {
|
|
103
114
|
rootDir: baseDir ?? process.cwd(),
|
|
104
115
|
stylesheetPath,
|
|
@@ -116,8 +127,8 @@ const runPostcss = async (root, result, options = {}) => {
|
|
|
116
127
|
const outputText = new Map(boundaryResult.outputs.map((output) => [path.resolve(output.path), output.text])).get(resolvedFile ?? resolvedStylesheet);
|
|
117
128
|
if (outputText !== void 0) result.root = postcss.parse(outputText, result.opts);
|
|
118
129
|
if (api.strategy !== "classname-only") {
|
|
119
|
-
api.file.js.write();
|
|
120
|
-
if (api.file.native?.hasContent) api.file.native.write();
|
|
130
|
+
await api.file.js.write();
|
|
131
|
+
if (api.file.native?.hasContent) await api.file.native.write();
|
|
121
132
|
}
|
|
122
133
|
});
|
|
123
134
|
runQueues.set(queueKey, run);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "boss-css",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "Polymorphic, usage-driven CSS-in-JS.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"boss": "./dist/cli/index.cjs",
|
|
@@ -313,11 +313,5 @@
|
|
|
313
313
|
"react": "^19.2.3",
|
|
314
314
|
"react-dom": "^19.2.3",
|
|
315
315
|
"react-native": ">=0.83.1"
|
|
316
|
-
},
|
|
317
|
-
"bo$$": {
|
|
318
|
-
"configDir": "src/.bo51761",
|
|
319
|
-
"compile": {
|
|
320
|
-
"tempOutDir": "src/.bo$$/compiled"
|
|
321
|
-
}
|
|
322
316
|
}
|
|
323
317
|
}
|