@unocss/postcss 0.52.7 → 0.53.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
@@ -15,7 +15,9 @@ const fg__default = /*#__PURE__*/_interopDefaultLegacy(fg);
15
15
  const postcss__default = /*#__PURE__*/_interopDefaultLegacy(postcss);
16
16
  const MagicString__default = /*#__PURE__*/_interopDefaultLegacy(MagicString);
17
17
 
18
- const defaultIncludeGlobs = ["**/*.{html,js,ts,jsx,tsx,vue,svelte,astro,elm,php,phtml,mdx,md}"];
18
+ const defaultFilesystemGlobs = [
19
+ "**/*.{html,js,ts,jsx,tsx,vue,svelte,astro,elm,php,phtml,mdx,md}"
20
+ ];
19
21
 
20
22
  async function parseApply(root, uno, directiveName) {
21
23
  root.walkAtRules(directiveName, async (rule) => {
@@ -157,7 +159,7 @@ async function parseScreen(root, uno, directiveName) {
157
159
  function calcMaxWidthBySize(size) {
158
160
  const value = size.match(/^-?[0-9]+\.?[0-9]*/)?.[0] || "";
159
161
  const unit = size.slice(value.length);
160
- const maxWidth = parseFloat(value) - 0.1;
162
+ const maxWidth = Number.parseFloat(value) - 0.1;
161
163
  return Number.isNaN(maxWidth) ? size : `${maxWidth}${unit}`;
162
164
  }
163
165
 
@@ -167,7 +169,6 @@ function unocss(options = {}) {
167
169
  );
168
170
  const {
169
171
  cwd = process.cwd(),
170
- content,
171
172
  configOrPath
172
173
  } = options;
173
174
  const directiveMap = Object.assign({
@@ -233,8 +234,8 @@ function unocss(options = {}) {
233
234
  } catch (error) {
234
235
  throw new Error(`UnoCSS config not found: ${error.message}`);
235
236
  }
236
- const globs = content?.filter((v) => typeof v === "string") ?? defaultIncludeGlobs;
237
- const rawContent = content?.filter((v) => typeof v === "object") ?? [];
237
+ const globs = uno.config.content?.filesystem ?? defaultFilesystemGlobs;
238
+ const plainContent = uno.config.content?.inline ?? [];
238
239
  const entries = await fg__default(isScanTarget ? globs : from, {
239
240
  cwd,
240
241
  absolute: true,
@@ -245,10 +246,12 @@ function unocss(options = {}) {
245
246
  await parseTheme(root, uno, directiveMap.theme);
246
247
  await parseScreen(root, uno, directiveMap.screen);
247
248
  promises$1.push(
248
- ...rawContent.map(async (v) => {
249
- const { matched } = await uno.generate(v.raw, {
250
- id: `unocss.${v.extension}`
251
- });
249
+ ...plainContent.map(async (c2, idx) => {
250
+ if (typeof c2 === "function")
251
+ c2 = await c2();
252
+ if (typeof c2 === "string")
253
+ c2 = { code: c2 };
254
+ const { matched } = await uno.generate(c2.code, { id: c2.id ?? `__plain_content_${idx}__` });
252
255
  for (const candidate of matched)
253
256
  classes.add(candidate);
254
257
  }),
@@ -263,8 +266,8 @@ function unocss(options = {}) {
263
266
  return;
264
267
  else
265
268
  fileMap.set(file, mtimeMs);
266
- const content2 = await promises.readFile(file, "utf8");
267
- const { matched } = await uno.generate(content2, {
269
+ const content = await promises.readFile(file, "utf8");
270
+ const { matched } = await uno.generate(content, {
268
271
  id: file
269
272
  });
270
273
  fileClassMap.set(file, matched);
package/dist/index.mjs CHANGED
@@ -7,7 +7,9 @@ import { loadConfig } from '@unocss/config';
7
7
  import { parse, generate, clone } from 'css-tree';
8
8
  import MagicString from 'magic-string';
9
9
 
10
- const defaultIncludeGlobs = ["**/*.{html,js,ts,jsx,tsx,vue,svelte,astro,elm,php,phtml,mdx,md}"];
10
+ const defaultFilesystemGlobs = [
11
+ "**/*.{html,js,ts,jsx,tsx,vue,svelte,astro,elm,php,phtml,mdx,md}"
12
+ ];
11
13
 
12
14
  async function parseApply(root, uno, directiveName) {
13
15
  root.walkAtRules(directiveName, async (rule) => {
@@ -149,7 +151,7 @@ async function parseScreen(root, uno, directiveName) {
149
151
  function calcMaxWidthBySize(size) {
150
152
  const value = size.match(/^-?[0-9]+\.?[0-9]*/)?.[0] || "";
151
153
  const unit = size.slice(value.length);
152
- const maxWidth = parseFloat(value) - 0.1;
154
+ const maxWidth = Number.parseFloat(value) - 0.1;
153
155
  return Number.isNaN(maxWidth) ? size : `${maxWidth}${unit}`;
154
156
  }
155
157
 
@@ -159,7 +161,6 @@ function unocss(options = {}) {
159
161
  );
160
162
  const {
161
163
  cwd = process.cwd(),
162
- content,
163
164
  configOrPath
164
165
  } = options;
165
166
  const directiveMap = Object.assign({
@@ -225,8 +226,8 @@ function unocss(options = {}) {
225
226
  } catch (error) {
226
227
  throw new Error(`UnoCSS config not found: ${error.message}`);
227
228
  }
228
- const globs = content?.filter((v) => typeof v === "string") ?? defaultIncludeGlobs;
229
- const rawContent = content?.filter((v) => typeof v === "object") ?? [];
229
+ const globs = uno.config.content?.filesystem ?? defaultFilesystemGlobs;
230
+ const plainContent = uno.config.content?.inline ?? [];
230
231
  const entries = await fg(isScanTarget ? globs : from, {
231
232
  cwd,
232
233
  absolute: true,
@@ -237,10 +238,12 @@ function unocss(options = {}) {
237
238
  await parseTheme(root, uno, directiveMap.theme);
238
239
  await parseScreen(root, uno, directiveMap.screen);
239
240
  promises.push(
240
- ...rawContent.map(async (v) => {
241
- const { matched } = await uno.generate(v.raw, {
242
- id: `unocss.${v.extension}`
243
- });
241
+ ...plainContent.map(async (c2, idx) => {
242
+ if (typeof c2 === "function")
243
+ c2 = await c2();
244
+ if (typeof c2 === "string")
245
+ c2 = { code: c2 };
246
+ const { matched } = await uno.generate(c2.code, { id: c2.id ?? `__plain_content_${idx}__` });
244
247
  for (const candidate of matched)
245
248
  classes.add(candidate);
246
249
  }),
@@ -255,8 +258,8 @@ function unocss(options = {}) {
255
258
  return;
256
259
  else
257
260
  fileMap.set(file, mtimeMs);
258
- const content2 = await readFile(file, "utf8");
259
- const { matched } = await uno.generate(content2, {
261
+ const content = await readFile(file, "utf8");
262
+ const { matched } = await uno.generate(content, {
260
263
  id: file
261
264
  });
262
265
  fileClassMap.set(file, matched);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/postcss",
3
- "version": "0.52.7",
3
+ "version": "0.53.0",
4
4
  "description": "PostCSS plugin for UnoCSS",
5
5
  "author": "sibbng <sibbngheid@gmail.com>",
6
6
  "license": "MIT",
@@ -40,8 +40,8 @@
40
40
  "fast-glob": "^3.2.12",
41
41
  "magic-string": "^0.30.0",
42
42
  "postcss": "^8.4.24",
43
- "@unocss/config": "0.52.7",
44
- "@unocss/core": "0.52.7"
43
+ "@unocss/config": "0.53.0",
44
+ "@unocss/core": "0.53.0"
45
45
  },
46
46
  "scripts": {
47
47
  "build": "unbuild",