@unocss/svelte-scoped 66.6.6 → 66.6.7

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.
@@ -6,7 +6,6 @@ import MagicString from "magic-string";
6
6
  import * as acorn from "acorn";
7
7
  import { walk } from "zimmerframe";
8
8
  import { clone, generate, parse, walk as walk$1 } from "css-tree";
9
-
10
9
  //#region src/_preprocess/transformClasses/addGeneratedStyles.ts
11
10
  const actualStylesTagWithCapturedDirectivesRE = new RegExp(/(?<!<!--\s*)/.source + /<style([^>]*)>[\s\S]*?<\/style\s*>/.source, "g");
12
11
  const captureOpeningStyleTagWithAttributesRE = /(<style[^>]*>)/;
@@ -14,7 +13,6 @@ function addGeneratedStylesIntoStyleBlock(code, styles) {
14
13
  if (code.match(actualStylesTagWithCapturedDirectivesRE)) return code.replace(captureOpeningStyleTagWithAttributesRE, `$1${styles}`);
15
14
  return `${code}\n<style>${styles}</style>`;
16
15
  }
17
-
18
16
  //#endregion
19
17
  //#region src/_preprocess/transformClasses/findClasses.ts
20
18
  const classesRE$1 = /class=(["'`])([\s\S]*?)\1/g;
@@ -105,7 +103,6 @@ function parseMatchesWithAcorn(matches, code) {
105
103
  return classes;
106
104
  }).filter(hasBody);
107
105
  }
108
-
109
106
  //#endregion
110
107
  //#region src/_preprocess/transformClasses/hash.ts
111
108
  function hash(str) {
@@ -118,7 +115,6 @@ function hash(str) {
118
115
  }
119
116
  return `00000${(hval >>> 0).toString(36)}`.slice(-6);
120
117
  }
121
-
122
118
  //#endregion
123
119
  //#region src/_preprocess/transformClasses/generateClassName.ts
124
120
  function generateClassName(body, options, filename) {
@@ -126,20 +122,17 @@ function generateClassName(body, options, filename) {
126
122
  if (combine) return `${classPrefix}${hashFn(body + filename)}`;
127
123
  else return `_${body}_${hashFn(filename)}`;
128
124
  }
129
-
130
125
  //#endregion
131
126
  //#region src/_preprocess/transformClasses/isShortcut.ts
132
127
  function isShortcut(token, shortcuts) {
133
128
  return shortcuts.some((s) => s[0] === token);
134
129
  }
135
-
136
130
  //#endregion
137
131
  //#region src/_preprocess/transformClasses/needsGenerated.ts
138
132
  async function needsGenerated(token, uno) {
139
133
  if (uno.config.safelist.includes(token)) return false;
140
134
  return !!await uno.parseToken(token);
141
135
  }
142
-
143
136
  //#endregion
144
137
  //#region src/_preprocess/transformClasses/sortClassesIntoCategories.ts
145
138
  async function sortClassesIntoCategories(body, options, uno, filename) {
@@ -168,7 +161,6 @@ async function sortClassesIntoCategories(body, options, uno, filename) {
168
161
  ignore
169
162
  };
170
163
  }
171
-
172
164
  //#endregion
173
165
  //#region src/_preprocess/transformClasses/processExpressions.ts
174
166
  const expressionsRE = /\S*\{[^{}]+\}\S*/g;
@@ -195,7 +187,6 @@ async function processExpressions(body, options, uno, filename) {
195
187
  restOfBody
196
188
  };
197
189
  }
198
-
199
190
  //#endregion
200
191
  //#region src/_preprocess/transformClasses/processClassBody.ts
201
192
  async function processClassBody({ body, start, end }, options, uno, filename) {
@@ -215,7 +206,6 @@ async function processClassBody({ body, start, end }, options, uno, filename) {
215
206
  }
216
207
  };
217
208
  }
218
-
219
209
  //#endregion
220
210
  //#region src/_preprocess/transformClasses/processDirective.ts
221
211
  async function processDirective({ body: token, start, end, type }, options, uno, filename) {
@@ -231,7 +221,6 @@ async function processDirective({ body: token, start, end, type }, options, uno,
231
221
  }
232
222
  };
233
223
  }
234
-
235
224
  //#endregion
236
225
  //#region src/_preprocess/transformClasses/processClsx.ts
237
226
  async function processClsx(cls, options, uno, filename) {
@@ -261,7 +250,6 @@ async function processClsx(cls, options, uno, filename) {
261
250
  }
262
251
  }
263
252
  }
264
-
265
253
  //#endregion
266
254
  //#region src/_preprocess/transformClasses/processClasses.ts
267
255
  async function processClasses(classes, options, uno, filename) {
@@ -281,14 +269,12 @@ async function processClass(foundClass, options, uno, filename) {
281
269
  if (foundClass.type === "clsxObject" || foundClass.type === "clsxObjectShorthand") return await processClsx(foundClass, options, uno, filename) ?? {};
282
270
  return await processDirective(foundClass, options, uno, filename) ?? {};
283
271
  }
284
-
285
272
  //#endregion
286
273
  //#region src/_preprocess/transformClasses/wrapGlobal.ts
287
274
  const EXTRACT_SELECTOR_RE = new RegExp(/(?<![\d(])/.source + /([[.][\s\S]+?)/.source + /(\{[\s\S]+?\})/.source, "g");
288
275
  function wrapSelectorsWithGlobal(css) {
289
276
  return css.replace(EXTRACT_SELECTOR_RE, ":global($1)$2");
290
277
  }
291
-
292
278
  //#endregion
293
279
  //#region src/_preprocess/transformClasses/index.ts
294
280
  async function transformClasses({ content, filename, uno, options }) {
@@ -329,14 +315,13 @@ async function generateStyles(rulesToGenerate, uno) {
329
315
  });
330
316
  return wrapSelectorsWithGlobal(css);
331
317
  }
332
-
333
318
  //#endregion
334
319
  //#region src/_preprocess/transformApply/getUtils.ts
335
320
  async function getUtils(body, uno) {
336
321
  return (await parseUtils(expandVariantGroup(body).split(/\s+/g).map((className) => className.trim().replace(/\\/, "")), uno)).sort(([aIndex], [bIndex]) => aIndex - bIndex).sort(([, , , aParent], [, , , bParent]) => (aParent ? uno.parentOrders.get(aParent) ?? 0 : 0) - (bParent ? uno.parentOrders.get(bParent) ?? 0 : 0)).reduce((acc, item) => {
337
- const [, selector, body$1, parent] = item;
322
+ const [, selector, body, parent] = item;
338
323
  const sibling = acc.find(([, targetSelector, , targetParent]) => targetSelector === selector && targetParent === parent);
339
- if (sibling) sibling[2] += body$1;
324
+ if (sibling) sibling[2] += body;
340
325
  else acc.push([...item]);
341
326
  return acc;
342
327
  }, []);
@@ -350,14 +335,12 @@ async function parseUtils(classNames, uno) {
350
335
  }
351
336
  return foundUtils.flat();
352
337
  }
353
-
354
338
  //#endregion
355
339
  //#region src/_preprocess/transformApply/removeOuterQuotes.ts
356
340
  function removeOuterQuotes(input) {
357
341
  if (!input) return "";
358
342
  return /^(['"]).*\1$/.test(input) ? input.slice(1, -1) : input;
359
343
  }
360
-
361
344
  //#endregion
362
345
  //#region src/_preprocess/transformApply/writeUtilStyles.ts
363
346
  function writeUtilStyles([, selector, body, parent], s, node, childNode) {
@@ -366,8 +349,8 @@ function writeUtilStyles([, selector, body, parent], s, node, childNode) {
366
349
  if (!parent && !selectorChanged) return s.appendRight(childNode.loc.end.offset, body);
367
350
  const originalSelector = generate(node.prelude);
368
351
  if (parent && !selectorChanged) {
369
- const css$1 = `${parent}{${originalSelector}{${body}}}`;
370
- return s.appendLeft(node.loc.end.offset, css$1);
352
+ const css = `${parent}{${originalSelector}{${body}}}`;
353
+ return s.appendLeft(node.loc.end.offset, css);
371
354
  }
372
355
  const rule = `${surroundAllButOriginalSelectorWithGlobal(originalSelector, generateUpdatedSelector(selector.replace(regexScopePlaceholder, " "), node.prelude))}{${body}}`;
373
356
  const css = parent ? `${parent}{${rule}}` : rule;
@@ -410,7 +393,6 @@ function findFirstCombinatorIndex(input) {
410
393
  }
411
394
  return -1;
412
395
  }
413
-
414
396
  //#endregion
415
397
  //#region src/_preprocess/transformApply/index.ts
416
398
  async function transformApply(ctx) {
@@ -447,7 +429,6 @@ function getChildNodeValue(childNode, applyVariables) {
447
429
  if (childNode.type === "Atrule" && childNode.name === "apply" && childNode.prelude && childNode.prelude.type === "Raw") return childNode.prelude.value.trim();
448
430
  if (childNode.type === "Declaration" && applyVariables.includes(childNode.property) && childNode.value.type === "Raw") return removeOuterQuotes(childNode.value.value.trim());
449
431
  }
450
-
451
432
  //#endregion
452
433
  //#region src/_preprocess/transformTheme.ts
453
434
  const themeRE = /theme\((.+?)\)/g;
@@ -463,7 +444,6 @@ function getThemeValue(rawArguments, theme) {
463
444
  else current = current[key];
464
445
  return current;
465
446
  }
466
-
467
447
  //#endregion
468
448
  //#region src/_preprocess/transformStyle.ts
469
449
  const DEFAULT_APPLY_VARIABLES = ["--at-apply"];
@@ -496,7 +476,6 @@ async function transformStyle({ content, uno, prepend, filename, applyVariables,
496
476
  })
497
477
  };
498
478
  }
499
-
500
479
  //#endregion
501
480
  //#region src/_preprocess/index.ts
502
481
  function UnocssSveltePreprocess(options = {}, unoContextFromVite, isViteBuild) {
@@ -558,6 +537,5 @@ function UnocssSveltePreprocess(options = {}, unoContextFromVite, isViteBuild) {
558
537
  }
559
538
  };
560
539
  }
561
-
562
540
  //#endregion
563
- export { UnocssSveltePreprocess as t };
541
+ export { UnocssSveltePreprocess as t };
@@ -1,2 +1,2 @@
1
- import { a as TransformDirectivesOptions, i as TransformClassesOptions, n as SvelteScopedContext, o as UnocssSveltePreprocessOptions, r as TransformApplyOptions, t as UnocssSveltePreprocess } from "./preprocess-twOgJvD9.mjs";
1
+ import { a as TransformDirectivesOptions, i as TransformClassesOptions, n as SvelteScopedContext, o as UnocssSveltePreprocessOptions, r as TransformApplyOptions, t as UnocssSveltePreprocess } from "./preprocess-eGXggMC-.mjs";
2
2
  export { SvelteScopedContext, TransformApplyOptions, TransformClassesOptions, TransformDirectivesOptions, UnocssSveltePreprocessOptions, UnocssSveltePreprocess as default };
@@ -1,3 +1,2 @@
1
- import { t as UnocssSveltePreprocess } from "./preprocess-smYe4zo2.mjs";
2
-
3
- export { UnocssSveltePreprocess as default };
1
+ import { t as UnocssSveltePreprocess } from "./preprocess-C0sgyK1A.mjs";
2
+ export { UnocssSveltePreprocess as default };
package/dist/vite.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { o as UnocssSveltePreprocessOptions } from "./preprocess-twOgJvD9.mjs";
1
+ import { o as UnocssSveltePreprocessOptions } from "./preprocess-eGXggMC-.mjs";
2
2
  import { PluginOptions } from "@unocss/core";
3
3
  import { Plugin } from "vite";
4
4
 
package/dist/vite.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as UnocssSveltePreprocess } from "./preprocess-smYe4zo2.mjs";
1
+ import { t as UnocssSveltePreprocess } from "./preprocess-C0sgyK1A.mjs";
2
2
  import process from "node:process";
3
3
  import { createRecoveryConfigLoader } from "@unocss/config";
4
4
  import { createGenerator, cssIdRE } from "@unocss/core";
@@ -8,7 +8,6 @@ import remapping from "@jridgewell/remapping";
8
8
  import { existsSync, readFileSync, statSync } from "node:fs";
9
9
  import { dirname, resolve } from "node:path";
10
10
  import { fileURLToPath } from "node:url";
11
-
12
11
  //#region src/_vite/config-hmr.ts
13
12
  function ConfigHMRPlugin({ ready }) {
14
13
  return {
@@ -26,14 +25,9 @@ function ConfigHMRPlugin({ ready }) {
26
25
  }
27
26
  };
28
27
  }
29
-
30
- //#endregion
31
- //#region ../../virtual-shared/integration/src/constants.ts
32
- const IGNORE_COMMENT = "@unocss-ignore";
33
28
  const SKIP_START_COMMENT = "@unocss-skip-start";
34
29
  const SKIP_END_COMMENT = "@unocss-skip-end";
35
30
  const SKIP_COMMENT_RE = new RegExp(`(\/\/\\s*?${SKIP_START_COMMENT}\\s*?|\\/\\*\\s*?${SKIP_START_COMMENT}\\s*?\\*\\/|<!--\\s*?${SKIP_START_COMMENT}\\s*?-->)[\\s\\S]*?(\/\/\\s*?${SKIP_END_COMMENT}\\s*?|\\/\\*\\s*?${SKIP_END_COMMENT}\\s*?\\*\\/|<!--\\s*?${SKIP_END_COMMENT}\\s*?-->)`, "g");
36
-
37
31
  //#endregion
38
32
  //#region ../../virtual-shared/integration/src/utils.ts
39
33
  function hash(str) {
@@ -59,11 +53,10 @@ function restoreSkipCode(code, map) {
59
53
  for (const [withHashKey, matched] of map.entries()) code = code.replaceAll(withHashKey, matched);
60
54
  return code;
61
55
  }
62
-
63
56
  //#endregion
64
57
  //#region ../../virtual-shared/integration/src/transformers.ts
65
58
  async function applyTransformers(ctx, original, id, enforce = "default") {
66
- if (original.includes(IGNORE_COMMENT)) return;
59
+ if (original.includes("@unocss-ignore")) return;
67
60
  const transformers = (ctx.uno.config.transformers || []).filter((i) => (i.enforce || "default") === enforce);
68
61
  if (!transformers.length) return;
69
62
  const skipMap = /* @__PURE__ */ new Map();
@@ -86,13 +79,12 @@ async function applyTransformers(ctx, original, id, enforce = "default") {
86
79
  }
87
80
  if (code !== original) return {
88
81
  code,
89
- map: remapping(maps, (_, ctx$1) => {
90
- ctx$1.content = code;
82
+ map: remapping(maps, (_, ctx) => {
83
+ ctx.content = code;
91
84
  return null;
92
85
  })
93
86
  };
94
87
  }
95
-
96
88
  //#endregion
97
89
  //#region src/_vite/createCssTransformerPlugins.ts
98
90
  const svelteIdRE = /[&?]svelte/;
@@ -114,13 +106,11 @@ function createCssTransformerPlugins(context, cssTransformers) {
114
106
  }
115
107
  }));
116
108
  }
117
-
118
109
  //#endregion
119
110
  //#region src/_vite/constants.ts
120
111
  const PLACEHOLDER_USER_SETS_IN_INDEX_HTML = "%unocss-svelte-scoped.global%";
121
112
  const DEV_GLOBAL_STYLES_DATA_TITLE = "unocss-svelte-scoped global styles";
122
113
  const GLOBAL_STYLES_CSS_FILE_NAME = "unocss-svelte-scoped-global.css";
123
-
124
114
  //#endregion
125
115
  //#region src/_vite/getReset.ts
126
116
  const _dirname = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
@@ -147,7 +137,6 @@ function getReset(injectReset) {
147
137
  function isFile(path) {
148
138
  return existsSync(path) && statSync(path).isFile();
149
139
  }
150
-
151
140
  //#endregion
152
141
  //#region src/_vite/global.ts
153
142
  async function generateGlobalCss(uno, injectReset) {
@@ -163,13 +152,12 @@ function checkTransformPageChunkHook(server, isSvelteKit) {
163
152
  const originalWrite = res.write;
164
153
  res.write = function(chunk, ...rest) {
165
154
  const str = typeof chunk === "string" ? chunk : chunk instanceof Buffer ? chunk.toString() : Array.isArray(chunk) || "at" in chunk ? Buffer.from(chunk).toString() : `${chunk}`;
166
- if (str.includes("<head>") && !str.includes(DEV_GLOBAL_STYLES_DATA_TITLE)) server.config.logger.error(`[unocss] You have not setup the svelte-scoped global styles correctly. You must place '${PLACEHOLDER_USER_SETS_IN_INDEX_HTML}' in your \`${isSvelteKit ? "app.html" : "index.html"}\` file.`, { timestamp: true });
155
+ if (str.includes("<head>") && !str.includes("unocss-svelte-scoped global styles")) server.config.logger.error(`[unocss] You have not setup the svelte-scoped global styles correctly. You must place '${PLACEHOLDER_USER_SETS_IN_INDEX_HTML}' in your \`${isSvelteKit ? "app.html" : "index.html"}\` file.`, { timestamp: true });
167
156
  return originalWrite.call(this, chunk, ...rest);
168
157
  };
169
158
  next();
170
159
  });
171
160
  }
172
-
173
161
  //#endregion
174
162
  //#region src/_vite/globalStylesPlugin.ts
175
163
  function GlobalStylesPlugin(ctx, injectReset) {
@@ -195,7 +183,7 @@ function GlobalStylesPlugin(ctx, injectReset) {
195
183
  await ctx.ready;
196
184
  if (isSvelteKit) {
197
185
  if (id.includes("hooks") && id.includes("server") && code.includes("unocss_svelte_scoped_global_styles")) this.warn(`[unocss] You are probably using an outdated setup for your sveltekit app. The server hook to handle an unocss styles placeholder is no longer needed.`);
198
- if (viteConfig.command === "serve" && code.includes(PLACEHOLDER_USER_SETS_IN_INDEX_HTML)) {
186
+ if (viteConfig.command === "serve" && code.includes("%unocss-svelte-scoped.global%")) {
199
187
  const tag = `<link href=\\"${viteConfig.base ?? "/"}${GLOBAL_STYLES_CSS_FILE_NAME}\\" rel=\\"stylesheet\\" data-title=\\"${DEV_GLOBAL_STYLES_DATA_TITLE}\\" />`;
200
188
  return { code: code.replace(PLACEHOLDER_USER_SETS_IN_INDEX_HTML, tag) };
201
189
  }
@@ -217,7 +205,7 @@ function GlobalStylesPlugin(ctx, injectReset) {
217
205
  unoCssGlobalFileName = this.getFileName(unoCssFileReferenceId);
218
206
  },
219
207
  renderChunk(code) {
220
- if (isSvelteKit && code.includes(PLACEHOLDER_USER_SETS_IN_INDEX_HTML)) {
208
+ if (isSvelteKit && code.includes("%unocss-svelte-scoped.global%")) {
221
209
  const tag = `<link href=\\"${viteConfig.base ?? "/"}${unoCssGlobalFileName}\\" rel=\\"stylesheet\\" />`;
222
210
  return code.replace(PLACEHOLDER_USER_SETS_IN_INDEX_HTML, tag);
223
211
  }
@@ -230,7 +218,6 @@ function GlobalStylesPlugin(ctx, injectReset) {
230
218
  }
231
219
  };
232
220
  }
233
-
234
221
  //#endregion
235
222
  //#region src/_vite/passPreprocessToSveltePlugin.ts
236
223
  function PassPreprocessToSveltePlugin(context, options = {}) {
@@ -245,7 +232,6 @@ function PassPreprocessToSveltePlugin(context, options = {}) {
245
232
  api: { sveltePreprocess: UnocssSveltePreprocess(options, context, isBuild) }
246
233
  };
247
234
  }
248
-
249
235
  //#endregion
250
236
  //#region src/_vite/index.ts
251
237
  function UnocssSvelteScopedVite(options = {}) {
@@ -283,6 +269,5 @@ function createSvelteScopedContext(configOrPath) {
283
269
  ready
284
270
  };
285
271
  }
286
-
287
272
  //#endregion
288
- export { UnocssSvelteScopedVite as default };
273
+ export { UnocssSvelteScopedVite as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/svelte-scoped",
3
3
  "type": "module",
4
- "version": "66.6.6",
4
+ "version": "66.6.7",
5
5
  "description": "Use UnoCSS in a modular fashion with styles being stored only in the Svelte component they are used in: Vite plugin for apps, Svelte preprocessor for component libraries",
6
6
  "author": "Jacob Bowdoin",
7
7
  "license": "MIT",
@@ -47,11 +47,11 @@
47
47
  "css-tree": "^3.1.0",
48
48
  "magic-string": "^0.30.21",
49
49
  "zimmerframe": "^1.1.4",
50
- "@unocss/config": "66.6.6",
51
- "@unocss/core": "66.6.6",
52
- "@unocss/preset-uno": "66.6.6",
53
- "@unocss/reset": "66.6.6",
54
- "@unocss/preset-wind3": "66.6.6"
50
+ "@unocss/config": "66.6.7",
51
+ "@unocss/reset": "66.6.7",
52
+ "@unocss/preset-uno": "66.6.7",
53
+ "@unocss/preset-wind3": "66.6.7",
54
+ "@unocss/core": "66.6.7"
55
55
  },
56
56
  "devDependencies": {
57
57
  "prettier-plugin-svelte": "^2.10.1",