@xingwangzhe/stalux 1.35.9 → 1.35.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xingwangzhe/stalux",
3
- "version": "1.35.9",
3
+ "version": "1.35.11",
4
4
  "description": "A powerful, modern Astro blog theme — use as template or install as plugin",
5
5
  "keywords": [
6
6
  "astro",
@@ -102,14 +102,13 @@
102
102
  "@astrojs/partytown": "^2.1.8",
103
103
  "@astrojs/rss": "^4.0.19",
104
104
  "@astrojs/sitemap": "^3.7.4",
105
- "@babel/parser": "^8.0.6",
106
105
  "@expressive-code/plugin-line-numbers": "^0.44.2",
107
- "@lucide/astro": "^1.52.0",
106
+ "@lucide/astro": "^1.56.0",
108
107
  "@mcp-b/webmcp-polyfill": "^5.1.0",
109
108
  "@pagefind/component-ui": "^1.5.2",
110
- "@waline/client": "^3.16.0",
109
+ "@waline/client": "^3.16.1",
111
110
  "@xingwangzhe/cjk-font-split-native": "^0.4.10",
112
- "@xingwangzhe/satteri-mermaid": "^0.8.1",
111
+ "@xingwangzhe/satteri-mermaid": "^0.8.2",
113
112
  "@xingwangzhe/satteri-photoswipe": "^0.2.6",
114
113
  "@xingwangzhe/tags-cloud": "^1.2.9",
115
114
  "astro-expressive-code": "^0.44.2",
@@ -121,23 +120,23 @@
121
120
  "parse5": "^8.0.1",
122
121
  "photoswipe": "^5.4.4",
123
122
  "satteri": "^0.10.5",
124
- "simple-icons": "^16.34.0",
125
- "temml": "^0.13.5",
123
+ "simple-icons": "^16.35.0",
124
+ "temml": "^0.14.0",
126
125
  "yaml": "^2.9.1"
127
126
  },
128
127
  "devDependencies": {
129
128
  "@astrojs/check": "^0.9.10",
130
129
  "@biomejs/biome": "^2.5.15",
131
130
  "@types/css-tree": "^3.2.0",
132
- "@types/node": "^26.6.4",
133
- "@unocss/astro": "^66.10.5",
134
- "@vitest/coverage-v8": "^5.0.3",
131
+ "@types/node": "^26.6.5",
132
+ "@unocss/astro": "^66.11.0",
133
+ "@vitest/coverage-v8": "^5.0.4",
135
134
  "astro": "^7.3.8",
136
- "knip": "^6.40.0",
135
+ "knip": "^6.41.0",
137
136
  "typescript": "npm:@typescript/typescript6@6.0.2",
138
- "unocss": "^66.10.5",
139
- "vite": "^8.3.3",
140
- "vitest": "^5.0.3"
137
+ "unocss": "^66.11.0",
138
+ "vite": "^8.3.4",
139
+ "vitest": "^5.0.4"
141
140
  },
142
141
  "peerDependencies": {
143
142
  "astro": "^7.3.5"
@@ -1,10 +1,9 @@
1
1
  import path from "node:path";
2
2
  import { parse as parseAstro } from "@astrojs/compiler";
3
- import { parseExpression, parse as parseScript } from "@babel/parser";
4
3
  import { generate, ident, parse, walk } from "css-tree";
5
4
  import MagicString from "magic-string";
6
5
  import { parseFragment } from "parse5";
7
- import type { Plugin } from "vite";
6
+ import { type Plugin, parseSync } from "vite";
8
7
  import { styleNameIn } from "./style-name-lookup.ts";
9
8
  import { styleNames } from "./style-names.generated.ts";
10
9
 
@@ -162,11 +161,16 @@ function visitSyntax(
162
161
 
163
162
  /** Parse source literals; never rewrite generated bundles or consumer modules. */
164
163
  export function compactScript(code: string, names: Names = styleNames, expression = false): string {
165
- const ast = expression
166
- ? parseExpression(code, { plugins: ["typescript"] })
167
- : parseScript(code, { sourceType: "module", plugins: ["typescript"] });
168
- const output = new MagicString(code);
169
- visitSyntax(ast, (node) => {
164
+ // Reuse Vite's public Oxc parser. Parentheses make Astro attribute values
165
+ // expressions (including object literals) while preserving source offsets.
166
+ const source = expression ? `(${code})` : code;
167
+ const { program, errors } = parseSync("stalux-theme.ts", source, {
168
+ lang: "ts",
169
+ sourceType: "module",
170
+ });
171
+ if (errors.length) throw new SyntaxError(errors.map((error) => error.message).join("\n"));
172
+ const output = new MagicString(source);
173
+ visitSyntax(program, (node) => {
170
174
  if (
171
175
  node.type === "ImportDeclaration" ||
172
176
  node.type === "ImportExpression" ||
@@ -174,7 +178,7 @@ export function compactScript(code: string, names: Names = styleNames, expressio
174
178
  )
175
179
  return false;
176
180
  if (
177
- node.type === "StringLiteral" &&
181
+ node.type === "Literal" &&
178
182
  typeof node.value === "string" &&
179
183
  typeof node.start === "number" &&
180
184
  typeof node.end === "number"
@@ -192,11 +196,12 @@ export function compactScript(code: string, names: Names = styleNames, expressio
192
196
  const segments = node.quasis as Array<{
193
197
  start: number;
194
198
  end: number;
199
+ tail: boolean;
195
200
  value: { raw: string };
196
201
  }>;
197
202
  const bodyStart = node.start + 1;
198
203
  const expressions = node.expressions as Array<{ start: number; end: number }>;
199
- const masked = new MagicString(code.slice(bodyStart, node.end - 1));
204
+ const masked = new MagicString(source.slice(bodyStart, node.end - 1));
200
205
  for (const expr of expressions)
201
206
  masked.overwrite(
202
207
  expr.start - 2 - bodyStart,
@@ -215,11 +220,17 @@ export function compactScript(code: string, names: Names = styleNames, expressio
215
220
  for (const segment of segments) {
216
221
  const next = compactTokens(segment.value.raw, names);
217
222
  if (next !== segment.value.raw)
218
- output.overwrite(segment.start, segment.end, next);
223
+ // ESTree/Oxc ranges include ` or } at the start and
224
+ // ${ or ` at the end; rewrite only the quasi's text.
225
+ output.overwrite(
226
+ segment.start + 1,
227
+ segment.end - (segment.tail ? 1 : 2),
228
+ next,
229
+ );
219
230
  }
220
231
  }
221
232
  });
222
- return output.toString();
233
+ return expression ? output.toString().slice(1, -1) : output.toString();
223
234
  }
224
235
 
225
236
  export async function compactAstro(code: string, names: Names = styleNames): Promise<string> {