figma-lupa 0.2.1 → 0.3.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 +1 -1
- package/dist/cli.js +2143 -334
- package/dist/server.js +2079 -304
- package/package.json +1 -1
- package/plugin/dist/code.js +1 -1
- package/skills/figma-implement/SKILL.md +4 -4
package/dist/cli.js
CHANGED
|
@@ -380,26 +380,26 @@ var require_permessage_deflate = __commonJS({
|
|
|
380
380
|
value = value[0];
|
|
381
381
|
if (key === "client_max_window_bits") {
|
|
382
382
|
if (value !== true) {
|
|
383
|
-
const
|
|
384
|
-
if (!Number.isInteger(
|
|
383
|
+
const num3 = +value;
|
|
384
|
+
if (!Number.isInteger(num3) || num3 < 8 || num3 > 15) {
|
|
385
385
|
throw new TypeError(
|
|
386
386
|
`Invalid value for parameter "${key}": ${value}`
|
|
387
387
|
);
|
|
388
388
|
}
|
|
389
|
-
value =
|
|
389
|
+
value = num3;
|
|
390
390
|
} else if (!this._isServer) {
|
|
391
391
|
throw new TypeError(
|
|
392
392
|
`Invalid value for parameter "${key}": ${value}`
|
|
393
393
|
);
|
|
394
394
|
}
|
|
395
395
|
} else if (key === "server_max_window_bits") {
|
|
396
|
-
const
|
|
397
|
-
if (!Number.isInteger(
|
|
396
|
+
const num3 = +value;
|
|
397
|
+
if (!Number.isInteger(num3) || num3 < 8 || num3 > 15) {
|
|
398
398
|
throw new TypeError(
|
|
399
399
|
`Invalid value for parameter "${key}": ${value}`
|
|
400
400
|
);
|
|
401
401
|
}
|
|
402
|
-
value =
|
|
402
|
+
value = num3;
|
|
403
403
|
} else if (key === "client_no_context_takeover" || key === "server_no_context_takeover") {
|
|
404
404
|
if (value !== true) {
|
|
405
405
|
throw new TypeError(
|
|
@@ -1113,8 +1113,8 @@ var require_receiver = __commonJS({
|
|
|
1113
1113
|
return;
|
|
1114
1114
|
}
|
|
1115
1115
|
const buf = this.consume(8);
|
|
1116
|
-
const
|
|
1117
|
-
if (
|
|
1116
|
+
const num3 = buf.readUInt32BE(0);
|
|
1117
|
+
if (num3 > Math.pow(2, 53 - 32) - 1) {
|
|
1118
1118
|
const error62 = this.createError(
|
|
1119
1119
|
RangeError,
|
|
1120
1120
|
"Unsupported WebSocket frame: payload length > 2^53 - 1",
|
|
@@ -1125,7 +1125,7 @@ var require_receiver = __commonJS({
|
|
|
1125
1125
|
cb(error62);
|
|
1126
1126
|
return;
|
|
1127
1127
|
}
|
|
1128
|
-
this._payloadLength =
|
|
1128
|
+
this._payloadLength = num3 * Math.pow(2, 32) + buf.readUInt32BE(4);
|
|
1129
1129
|
this.haveLength(cb);
|
|
1130
1130
|
}
|
|
1131
1131
|
/**
|
|
@@ -2257,9 +2257,9 @@ var require_extension = __commonJS({
|
|
|
2257
2257
|
return configurations.map((params) => {
|
|
2258
2258
|
return [extension2].concat(
|
|
2259
2259
|
Object.keys(params).map((k) => {
|
|
2260
|
-
let
|
|
2261
|
-
if (!Array.isArray(
|
|
2262
|
-
return
|
|
2260
|
+
let values2 = params[k];
|
|
2261
|
+
if (!Array.isArray(values2)) values2 = [values2];
|
|
2262
|
+
return values2.map((v) => v === true ? k : `${k}=${v}`).join("; ");
|
|
2263
2263
|
})
|
|
2264
2264
|
).join("; ");
|
|
2265
2265
|
}).join(", ");
|
|
@@ -3743,7 +3743,7 @@ var init_package = __esm({
|
|
|
3743
3743
|
"package.json"() {
|
|
3744
3744
|
package_default = {
|
|
3745
3745
|
name: "figma-lupa",
|
|
3746
|
-
version: "0.
|
|
3746
|
+
version: "0.3.0",
|
|
3747
3747
|
description: "Read-only Figma CLI, MCP server and plugin for pixel-faithful design-to-code with a small context footprint.",
|
|
3748
3748
|
type: "module",
|
|
3749
3749
|
license: "GPL-3.0-or-later",
|
|
@@ -4258,7 +4258,7 @@ var init_legend = __esm({
|
|
|
4258
4258
|
"+N more like \u2191" / "+N more alternating like the 2 above" = siblings with the same structure as the layer(s) just printed; the lines under it give each one's id and its own texts/images.
|
|
4259
4259
|
"\u2026 +N layers not shown \u2192 get_design #id" = cut by the token budget; fetch that subtree when you need it.
|
|
4260
4260
|
// lines = designer notes, prototype interactions, component props, exports.
|
|
4261
|
-
Codebase: "\u2192 var(--x)" after a colour or font = the project's own variable for that value; "\u2192 .class" after a typography token = its text style class. "// project has: \u2026" = where the project defines that component. A src: outside the assets folder = the project's own icon with the same drawing.
|
|
4261
|
+
Codebase: "\u2192 var(--x)" after a colour or font = the project's own variable for that value; "\u2192 .class" after a typography token = its text style class. Tailwind theme (v4 @theme or v3 tailwind.config): "\u2192 *-grey-200" = that colour's utilities (bg-grey-200, text-grey-200, border-grey-200\u2026), "\u2192 font-sans" = the font utility, "\u2192 text-sm font-medium leading-[20px]" = utility classes for a typography token. "// project has: \u2026" = where the project defines that component, with its props when Lupa can read them (<Button variant="default*|outline"> for React cva/tv variants or string-union props, <.button variant="primary"> <:actions> for Phoenix attrs and slots; * = default). A src: outside the assets folder = the project's own icon with the same drawing; src:<PlusIcon /> (components/icons/plus.tsx) = the project's own icon component; src:<ChevronDown /> from lucide-react or src:<.icon name="hero-x-mark" /> = that icon from the project's icon library (no file written).
|
|
4262
4262
|
Reproduce exact values (sizes, spacing, colours, type). Before writing any colour, $token or raw (#hex, rgba), look for the codebase's own token with that name or value (Tailwind theme, CSS variables, theme object) and use it; hardcode only when none matches.`;
|
|
4263
4263
|
}
|
|
4264
4264
|
});
|
|
@@ -4924,9 +4924,9 @@ var init_build = __esm({
|
|
|
4924
4924
|
LINE: "line"
|
|
4925
4925
|
};
|
|
4926
4926
|
Builder = class {
|
|
4927
|
-
constructor(snap,
|
|
4927
|
+
constructor(snap, files2) {
|
|
4928
4928
|
this.snap = snap;
|
|
4929
|
-
this.files =
|
|
4929
|
+
this.files = files2;
|
|
4930
4930
|
this.reg = new Registry(snap);
|
|
4931
4931
|
}
|
|
4932
4932
|
reg;
|
|
@@ -5053,18 +5053,18 @@ var init_build = __esm({
|
|
|
5053
5053
|
if (!raw.layoutMode || raw.graphic) return;
|
|
5054
5054
|
const L = ir.layout;
|
|
5055
5055
|
const bv = raw.boundVariables ?? {};
|
|
5056
|
-
const
|
|
5056
|
+
const num3 = (key) => this.reg.number(raw[key] ?? 0, bv[key]?.id);
|
|
5057
5057
|
if (raw.layoutMode === "GRID") {
|
|
5058
5058
|
const tracks = (t, count) => (t?.length ? t : Array.from({ length: count ?? 0 }, () => ({ type: "FLEX", value: 1 }))).map((s) => s.type === "FIXED" ? n(s.value ?? 0) : s.type === "HUG" ? "auto" : `${n(s.value ?? 1)}fr`).join(",");
|
|
5059
5059
|
L.grid = "";
|
|
5060
5060
|
L.cols = emptyTracks(raw, "col", tracks(raw.gridColumnSizes, raw.gridColumnCount));
|
|
5061
5061
|
L.rows = emptyTracks(raw, "row", tracks(raw.gridRowSizes, raw.gridRowCount));
|
|
5062
|
-
if (raw.gridColumnGap) L.gap =
|
|
5063
|
-
if (raw.gridRowGap) L.rowgap =
|
|
5062
|
+
if (raw.gridColumnGap) L.gap = num3("gridColumnGap");
|
|
5063
|
+
if (raw.gridRowGap) L.rowgap = num3("gridRowGap");
|
|
5064
5064
|
} else {
|
|
5065
5065
|
L[raw.layoutMode === "VERTICAL" ? "col" : "row"] = "";
|
|
5066
5066
|
if (raw.primaryAxisAlignItems === "SPACE_BETWEEN") L.justify = "between";
|
|
5067
|
-
else if (raw.itemSpacing) L.gap =
|
|
5067
|
+
else if (raw.itemSpacing) L.gap = num3("itemSpacing");
|
|
5068
5068
|
if (raw.layoutWrap) {
|
|
5069
5069
|
L.wrap = "";
|
|
5070
5070
|
if (raw.counterAxisSpacing) L.rowgap = this.reg.number(raw.counterAxisSpacing, bv.counterAxisSpacing?.id);
|
|
@@ -5080,8 +5080,8 @@ var init_build = __esm({
|
|
|
5080
5080
|
const pad = (key, side) => {
|
|
5081
5081
|
const v = raw[key] ?? 0;
|
|
5082
5082
|
const w = inset?.[side] ?? 0;
|
|
5083
|
-
if (!w || v < w) return
|
|
5084
|
-
const ref =
|
|
5083
|
+
if (!w || v < w) return num3(key);
|
|
5084
|
+
const ref = num3(key);
|
|
5085
5085
|
return ref.startsWith("$") ? `calc(${ref} - ${n(w)})` : n(v - w);
|
|
5086
5086
|
};
|
|
5087
5087
|
const p = sides(pad("paddingTop", 0), pad("paddingRight", 1), pad("paddingBottom", 2), pad("paddingLeft", 3));
|
|
@@ -5165,8 +5165,8 @@ var init_build = __esm({
|
|
|
5165
5165
|
const full = raw.cornerRadius >= Math.min(raw.w, raw.h) / 2 - 0.01 && Math.min(raw.w, raw.h) > 0;
|
|
5166
5166
|
S.radius = bv.cornerRadius ? this.reg.number(raw.cornerRadius, bv.cornerRadius.id) : full ? "full" : n(raw.cornerRadius);
|
|
5167
5167
|
} else if (raw.radii) {
|
|
5168
|
-
const
|
|
5169
|
-
S.radius = raw.radii.map((r, i) => this.reg.number(r, bv[
|
|
5168
|
+
const keys2 = ["topLeftRadius", "topRightRadius", "bottomRightRadius", "bottomLeftRadius"];
|
|
5169
|
+
S.radius = raw.radii.map((r, i) => this.reg.number(r, bv[keys2[i]]?.id)).join(",");
|
|
5170
5170
|
}
|
|
5171
5171
|
if (raw.cornerSmoothing && S.radius) S.smooth = `${n(raw.cornerSmoothing * 100, 0)}%`;
|
|
5172
5172
|
}
|
|
@@ -5449,7 +5449,7 @@ var init_components = __esm({
|
|
|
5449
5449
|
this.diffChildren(inst, def, "", out, keyOf, resized);
|
|
5450
5450
|
return out;
|
|
5451
5451
|
}
|
|
5452
|
-
diffChildren(a, d,
|
|
5452
|
+
diffChildren(a, d, path7, out, keyOf, resized) {
|
|
5453
5453
|
const defByKey = new Map(d.children.map((c) => [keyOf(c, true), c]));
|
|
5454
5454
|
const matched = /* @__PURE__ */ new Set();
|
|
5455
5455
|
const names = pathNames(d.children);
|
|
@@ -5460,7 +5460,7 @@ var init_components = __esm({
|
|
|
5460
5460
|
const cand = d.children[a.children.indexOf(child)];
|
|
5461
5461
|
dc = ok(cand) ? cand : d.children.find(ok);
|
|
5462
5462
|
}
|
|
5463
|
-
const p = joinPath(
|
|
5463
|
+
const p = joinPath(path7, dc ? names.get(dc) ?? dc.name : child.name);
|
|
5464
5464
|
if (!dc) {
|
|
5465
5465
|
out.push({ path: p, changes: ["added"], sub: child });
|
|
5466
5466
|
continue;
|
|
@@ -5471,20 +5471,20 @@ var init_components = __esm({
|
|
|
5471
5471
|
for (const dc of d.children) {
|
|
5472
5472
|
if (matched.has(dc) || dc.hidden) continue;
|
|
5473
5473
|
if (dc.propRefs?.visible) continue;
|
|
5474
|
-
out.push({ path: joinPath(
|
|
5474
|
+
out.push({ path: joinPath(path7, names.get(dc) ?? dc.name), changes: ["hidden"] });
|
|
5475
5475
|
}
|
|
5476
5476
|
}
|
|
5477
|
-
diffNode(a, d,
|
|
5477
|
+
diffNode(a, d, path7, out, keyOf, resized) {
|
|
5478
5478
|
if (a.hidden && !d.hidden) {
|
|
5479
|
-
if (!d.propRefs?.visible) out.push({ path:
|
|
5479
|
+
if (!d.propRefs?.visible) out.push({ path: path7, changes: ["hidden"] });
|
|
5480
5480
|
return;
|
|
5481
5481
|
}
|
|
5482
5482
|
if (!a.hidden && d.hidden) {
|
|
5483
5483
|
if (d.propRefs?.visible) {
|
|
5484
5484
|
const changes2 = this.nodeChanges(a, d, resized);
|
|
5485
|
-
if (changes2.length) out.push({ path:
|
|
5486
|
-
this.diffChildren(a, d,
|
|
5487
|
-
} else out.push({ path:
|
|
5485
|
+
if (changes2.length) out.push({ path: path7, changes: changes2 });
|
|
5486
|
+
this.diffChildren(a, d, path7, out, keyOf, resized);
|
|
5487
|
+
} else out.push({ path: path7, changes: ["shown"], sub: a });
|
|
5488
5488
|
return;
|
|
5489
5489
|
}
|
|
5490
5490
|
if (a.hidden) return;
|
|
@@ -5498,22 +5498,22 @@ var init_components = __esm({
|
|
|
5498
5498
|
if (a.kind === "svg" || !a.children.length) {
|
|
5499
5499
|
if (a.kind === "svg" && a.style.src !== d.style.src && a.style.src) changes2.push(`src:${a.style.src}`);
|
|
5500
5500
|
if (a.kind === "svg" && a.style.color !== d.style.color && a.style.color) changes2.push(`color:${a.style.color}`);
|
|
5501
|
-
if (changes2.length) out.push({ path:
|
|
5501
|
+
if (changes2.length) out.push({ path: path7, changes: changes2 });
|
|
5502
5502
|
} else if (def) {
|
|
5503
5503
|
changes2.push(...this.rootChanges(a, def.ir));
|
|
5504
|
-
if (changes2.length) out.push({ path:
|
|
5504
|
+
if (changes2.length) out.push({ path: path7, changes: changes2 });
|
|
5505
5505
|
const nested = this.overrides(a, def.ir);
|
|
5506
|
-
for (const o2 of nested) out.push({ ...o2, path: joinPath(
|
|
5506
|
+
for (const o2 of nested) out.push({ ...o2, path: joinPath(path7, o2.path) });
|
|
5507
5507
|
} else {
|
|
5508
|
-
out.push({ path:
|
|
5508
|
+
out.push({ path: path7, changes: changes2.length ? changes2 : [`swap\u2192${label}`], sub: a });
|
|
5509
5509
|
}
|
|
5510
5510
|
return;
|
|
5511
5511
|
}
|
|
5512
5512
|
const changes = this.nodeChanges(a, d, resized);
|
|
5513
|
-
const o = { path:
|
|
5513
|
+
const o = { path: path7, changes };
|
|
5514
5514
|
if (a.runs && JSON.stringify(a.runs) !== JSON.stringify(d.runs)) o.runs = a.runs;
|
|
5515
5515
|
if (changes.length || o.runs) out.push(o);
|
|
5516
|
-
if (a.kind !== "svg") this.diffChildren(a, d,
|
|
5516
|
+
if (a.kind !== "svg") this.diffChildren(a, d, path7, out, keyOf, resized);
|
|
5517
5517
|
}
|
|
5518
5518
|
nodeChanges(a, d, resized) {
|
|
5519
5519
|
const changes = [];
|
|
@@ -5697,12 +5697,12 @@ var init_render = __esm({
|
|
|
5697
5697
|
const fonts = this.fonts([...roots, ...[...this.comps.defs.values()].filter((d) => charged.has(d.mainId)).map((d) => d.ir)]);
|
|
5698
5698
|
if (fonts) head.push(`fonts: ${fonts}`);
|
|
5699
5699
|
const assets = this.assets(roots);
|
|
5700
|
-
const
|
|
5701
|
-
if (
|
|
5702
|
-
const own2 =
|
|
5703
|
-
const count = (/* @__PURE__ */ new Set([...
|
|
5700
|
+
const files2 = this.opts.files;
|
|
5701
|
+
if (files2) {
|
|
5702
|
+
const own2 = files2.reused?.size ?? 0;
|
|
5703
|
+
const count = (/* @__PURE__ */ new Set([...files2.byNode.values(), ...files2.byImage.values()])).size - own2;
|
|
5704
5704
|
const ownNote = own2 ? ` + ${own2} icon${own2 === 1 ? "" : "s"} the project already has` : "";
|
|
5705
|
-
head.push(`assets: ${count} file${count === 1 ? "" : "s"} in ${
|
|
5705
|
+
head.push(`assets: ${count} file${count === 1 ? "" : "s"} in ${files2.dir}/${ownNote}, named by src: on each layer${files2.failures.length ? ` (${files2.failures.length} failed \u2192 export_assets)` : ""}`);
|
|
5706
5706
|
} else if (assets) head.push(`assets: ${assets} \u2192 export_assets`);
|
|
5707
5707
|
if (cut) head.push(`budget: tree cut breadth-first at ~${Math.round(this.budgetChars / CHARS_PER_TOKEN)} tokens \u2014 "not shown" markers say how to expand`);
|
|
5708
5708
|
if (this.snap.stats.truncated) head.push(`warning: snapshot hit the node limit; some layers were not loaded`);
|
|
@@ -6041,9 +6041,9 @@ function formatOutline(o) {
|
|
|
6041
6041
|
function formatMatches(r) {
|
|
6042
6042
|
if (!r.matches.length) return "No matches.";
|
|
6043
6043
|
const out = r.matches.map((m) => {
|
|
6044
|
-
const
|
|
6044
|
+
const path7 = [m.page, ...m.path].filter(Boolean).join(" \u203A ");
|
|
6045
6045
|
const text2 = m.text !== void 0 ? ` ${JSON.stringify(m.text)}` : "";
|
|
6046
|
-
return `${m.type.toLowerCase()} "${m.name}" #${m.id} ${m.w}\xD7${m.h}${text2} \u2014 ${
|
|
6046
|
+
return `${m.type.toLowerCase()} "${m.name}" #${m.id} ${m.w}\xD7${m.h}${text2} \u2014 ${path7}`;
|
|
6047
6047
|
});
|
|
6048
6048
|
if (r.truncated) out.push("\u2026 more matches; narrow the query, page or type.");
|
|
6049
6049
|
return out.join("\n");
|
|
@@ -6102,9 +6102,9 @@ function formatTokens(t, format, filter) {
|
|
|
6102
6102
|
if (!vars.length) continue;
|
|
6103
6103
|
lines.push(`${c.name}${c.remote ? " (library)" : ""} \u2014 modes: ${c.modes.map((m) => m.name).join(" | ")}`);
|
|
6104
6104
|
for (const v of vars) {
|
|
6105
|
-
const
|
|
6106
|
-
const uniq = new Set(
|
|
6107
|
-
lines.push(` ${v.name} = ${uniq.size === 1 ?
|
|
6105
|
+
const values2 = c.modes.map((m) => tokenValue(v.values[m.id], v.type));
|
|
6106
|
+
const uniq = new Set(values2);
|
|
6107
|
+
lines.push(` ${v.name} = ${uniq.size === 1 ? values2[0] : values2.join(" | ")}${v.web ? ` ${v.web}` : ""}${v.description ? ` \u2014 ${v.description.slice(0, 80)}` : ""}`);
|
|
6108
6108
|
}
|
|
6109
6109
|
}
|
|
6110
6110
|
}
|
|
@@ -6141,44 +6141,1685 @@ var init_format = __esm({
|
|
|
6141
6141
|
}
|
|
6142
6142
|
});
|
|
6143
6143
|
|
|
6144
|
-
// src/tools/
|
|
6145
|
-
import { readdir, readFile as readFile2 } from "node:fs/promises";
|
|
6146
|
-
import os3 from "node:os";
|
|
6144
|
+
// src/tools/icons.ts
|
|
6145
|
+
import { readdir, readFile as readFile2, stat as stat2 } from "node:fs/promises";
|
|
6147
6146
|
import path3 from "node:path";
|
|
6148
|
-
async function
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6147
|
+
async function exists(p) {
|
|
6148
|
+
try {
|
|
6149
|
+
await stat2(p);
|
|
6150
|
+
return true;
|
|
6151
|
+
} catch {
|
|
6152
|
+
return false;
|
|
6153
|
+
}
|
|
6154
|
+
}
|
|
6155
|
+
async function installed(from, root, pkg) {
|
|
6156
|
+
for (let dir = from; ; dir = path3.dirname(dir)) {
|
|
6157
|
+
const p = path3.join(dir, "node_modules", pkg);
|
|
6158
|
+
if (await exists(p)) return p;
|
|
6159
|
+
if (dir === root || path3.dirname(dir) === dir || !dir.startsWith(root)) return void 0;
|
|
6160
|
+
}
|
|
6161
|
+
}
|
|
6162
|
+
async function files(dir, re) {
|
|
6163
|
+
try {
|
|
6164
|
+
return (await readdir(dir)).filter((f) => re.test(f)).sort().map((f) => path3.join(dir, f));
|
|
6165
|
+
} catch {
|
|
6166
|
+
return [];
|
|
6167
|
+
}
|
|
6168
|
+
}
|
|
6169
|
+
function once(f) {
|
|
6170
|
+
let p;
|
|
6171
|
+
return () => p ??= f();
|
|
6172
|
+
}
|
|
6173
|
+
async function svgFolder(dir, usage) {
|
|
6174
|
+
const out = [];
|
|
6175
|
+
for (const f of await files(dir, /\.svg$/i)) {
|
|
6176
|
+
const svg = await readFile2(f, "utf8").catch(() => "");
|
|
6177
|
+
const points = pointsOf(svg);
|
|
6178
|
+
const name = path3.basename(f, ".svg");
|
|
6179
|
+
if (points) out.push({ usage: usage(name), name, points });
|
|
6180
|
+
}
|
|
6181
|
+
return out;
|
|
6182
|
+
}
|
|
6183
|
+
async function lucideModules(pkgDir, pkg) {
|
|
6184
|
+
const out = [];
|
|
6185
|
+
for (const f of await files(path3.join(pkgDir, "dist/esm/icons"), /\.m?js$/)) {
|
|
6186
|
+
const js = await readFile2(f, "utf8").catch(() => "");
|
|
6187
|
+
const els = [...js.matchAll(/\[\s*"(path|circle|rect|ellipse|line|polyline|polygon)"\s*,\s*\{([^}]*)\}\s*\]/g)];
|
|
6188
|
+
if (!els.length) continue;
|
|
6189
|
+
const body = els.map((m) => `<${m[1]} ${[...m[2].matchAll(/(\w+)\s*:\s*"([^"]*)"/g)].filter((a) => a[1] !== "key").map((a) => `${a[1]}="${a[2]}"`).join(" ")}/>`).join("");
|
|
6190
|
+
const points = pointsOf(`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">${body}</svg>`);
|
|
6191
|
+
const name = path3.basename(f).replace(/\.m?js$/, "");
|
|
6192
|
+
if (points) out.push({ usage: `<${pascal(name)} /> from ${pkg}`, name, points });
|
|
6193
|
+
}
|
|
6194
|
+
return out;
|
|
6195
|
+
}
|
|
6196
|
+
async function heroReact(pkgDir) {
|
|
6197
|
+
const out = [];
|
|
6198
|
+
for (const set2 of HERO_SETS) {
|
|
6199
|
+
for (const f of await files(path3.join(pkgDir, set2.dir), /Icon\.js$/)) {
|
|
6200
|
+
const js = await readFile2(f, "utf8").catch(() => "");
|
|
6201
|
+
const ds = [...js.matchAll(/\bd:\s*"([^"]+)"/g)].map((m) => `<path d="${m[1]}"/>`).join("");
|
|
6202
|
+
const size = set2.dir.split("/")[0];
|
|
6203
|
+
const points = pointsOf(`<svg viewBox="0 0 ${size} ${size}" ${set2.stroke ? 'fill="none" stroke="currentColor"' : ""}>${ds}</svg>`);
|
|
6204
|
+
const comp = path3.basename(f, ".js");
|
|
6205
|
+
const name = comp.replace(/Icon$/, "").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
6206
|
+
if (points) out.push({ usage: `<${comp} /> from @heroicons/react/${set2.dir}`, name, points });
|
|
6207
|
+
}
|
|
6208
|
+
}
|
|
6209
|
+
return out;
|
|
6210
|
+
}
|
|
6211
|
+
async function heroPhoenix(base) {
|
|
6212
|
+
const out = [];
|
|
6213
|
+
for (const set2 of HERO_SETS) out.push(...await svgFolder(path3.join(base, set2.dir), (n2) => `<.icon name="hero-${n2}${set2.suffix}" />`));
|
|
6214
|
+
return out;
|
|
6215
|
+
}
|
|
6216
|
+
function codeIcons(src, file2, phoenix = false) {
|
|
6217
|
+
const out = [];
|
|
6218
|
+
if (!src.includes("<svg")) return out;
|
|
6219
|
+
if (phoenix) {
|
|
6220
|
+
for (const m of src.matchAll(/\bdef\s+(\w+)\(assigns\)[^~]*?~H"""\s*(<svg\b[\s\S]*?<\/svg>)\s*"""/g)) {
|
|
6221
|
+
out.push({ usage: `<.${m[1]} /> (${file2})`, name: kebab(m[1]).replace(/-?icon-?/, ""), svg: plainSvg(m[2]) });
|
|
6222
|
+
}
|
|
6223
|
+
return out;
|
|
6224
|
+
}
|
|
6225
|
+
const defs = [...src.matchAll(/(?:function\s+([A-Z]\w*)|(?:const|let)\s+([A-Z]\w*)\s*(?::[^=]+)?=)/g)];
|
|
6226
|
+
for (const m of src.matchAll(/(?:return|=>)\s*\(?\s*(<svg\b[\s\S]*?<\/svg>)/g)) {
|
|
6227
|
+
const def = defs.filter((d) => d.index < m.index).pop();
|
|
6228
|
+
const name = def?.[1] ?? def?.[2];
|
|
6229
|
+
if (!name || !new RegExp(`export\\b[^\\n]*\\b${name}\\b`).test(src) || out.some((o) => o.usage.startsWith(`<${name} `))) continue;
|
|
6230
|
+
out.push({ usage: `<${name} /> (${file2})`, name: kebab(name.replace(/Icon$/, "")), svg: plainSvg(m[1]) });
|
|
6231
|
+
}
|
|
6232
|
+
return out;
|
|
6233
|
+
}
|
|
6234
|
+
function bracketed(t, open2) {
|
|
6235
|
+
let depth = 0;
|
|
6236
|
+
for (let i = open2; i < t.length; i++) {
|
|
6237
|
+
const c = t[i];
|
|
6238
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
6239
|
+
for (i++; i < t.length && t[i] !== c; i++) if (t[i] === "\\") i++;
|
|
6240
|
+
} else if (c === "[" || c === "{") depth++;
|
|
6241
|
+
else if ((c === "]" || c === "}") && --depth === 0) return t.slice(open2, i + 1);
|
|
6242
|
+
}
|
|
6243
|
+
return t.slice(open2);
|
|
6244
|
+
}
|
|
6245
|
+
async function bannedImports(root, pkgs) {
|
|
6246
|
+
const out = /* @__PURE__ */ new Set();
|
|
6247
|
+
const quoted = (t, p) => t.includes(`'${p}'`) || t.includes(`"${p}"`);
|
|
6248
|
+
const names = [".oxlintrc.json", ".eslintrc", ".eslintrc.json", ".eslintrc.js", ".eslintrc.cjs", "eslint.config.js", "eslint.config.mjs", "eslint.config.cjs", "eslint.config.ts", "biome.json", "biome.jsonc"];
|
|
6249
|
+
for (const n2 of names) {
|
|
6250
|
+
const t = await readFile2(path3.join(root, n2), "utf8").catch(() => "");
|
|
6251
|
+
for (const m of t.matchAll(/(?:no-restricted-imports|noRestrictedImports)["']?\s*[:=]\s*/g)) {
|
|
6252
|
+
const at = m.index + m[0].length;
|
|
6253
|
+
if (t[at] !== "[" && t[at] !== "{") continue;
|
|
6254
|
+
const opts = bracketed(t, at);
|
|
6255
|
+
if (/^\[\s*["']off["']|^\[\s*0\b/.test(opts)) continue;
|
|
6256
|
+
for (const p of pkgs) if (quoted(opts, p)) out.add(p);
|
|
6257
|
+
}
|
|
6258
|
+
}
|
|
6259
|
+
const sg = await readFile2(path3.join(root, "sgconfig.yml"), "utf8").catch(() => "");
|
|
6260
|
+
const dirs = [...(/ruleDirs:\s*((?:\n\s*-\s*.+)+)/.exec(sg)?.[1] ?? "").matchAll(/-\s*["']?([^"'\n]+)/g)].map((m) => m[1].trim());
|
|
6261
|
+
for (const d of dirs) {
|
|
6262
|
+
for (const f of await files(path3.join(root, d), /\.ya?ml$/)) {
|
|
6263
|
+
const t = await readFile2(f, "utf8").catch(() => "");
|
|
6264
|
+
if (/^\s*severity:\s*off\b/m.test(t)) continue;
|
|
6265
|
+
for (const line of t.split("\n").filter((l) => /^\s*(?:-\s*)?pattern:/.test(l))) {
|
|
6266
|
+
for (const p of pkgs) if (/\b(?:from|import|require\s*\()/.test(line) && quoted(line, p)) out.add(p);
|
|
6267
|
+
}
|
|
6268
|
+
}
|
|
6269
|
+
}
|
|
6270
|
+
return out;
|
|
6271
|
+
}
|
|
6272
|
+
async function iconLibraries(root, manifests, own2 = []) {
|
|
6273
|
+
const libs = /* @__PURE__ */ new Map();
|
|
6274
|
+
if (own2.length) {
|
|
6275
|
+
libs.set("project", {
|
|
6276
|
+
name: "project",
|
|
6277
|
+
load: once(async () => own2.flatMap((i) => {
|
|
6278
|
+
const points = pointsOf(i.svg);
|
|
6279
|
+
return points ? [{ usage: i.usage, name: i.name, points }] : [];
|
|
6280
|
+
}))
|
|
6281
|
+
});
|
|
6282
|
+
}
|
|
6283
|
+
const banned = await bannedImports(root, ICON_PACKAGES);
|
|
6284
|
+
const add = (name, load) => {
|
|
6285
|
+
if (!libs.has(name)) libs.set(name, { name, load: once(load) });
|
|
6286
|
+
};
|
|
6287
|
+
const phoenix = manifests.some((m) => path3.basename(m) === "mix.exs");
|
|
6288
|
+
for (const m of manifests) {
|
|
6289
|
+
const dir = path3.dirname(m);
|
|
6290
|
+
const text2 = await readFile2(m, "utf8").catch(() => "");
|
|
6291
|
+
if (path3.basename(m) === "mix.exs") {
|
|
6292
|
+
if (/\{:heroicons\b/.test(text2)) {
|
|
6293
|
+
const base = path3.join(root, "deps/heroicons/optimized");
|
|
6294
|
+
if (await exists(base)) add("heroicons (Phoenix)", () => heroPhoenix(base));
|
|
6295
|
+
}
|
|
6296
|
+
if (/\{:lucide_icons\b/.test(text2)) {
|
|
6297
|
+
const base = path3.join(root, "deps/lucide_icons/priv/node_modules/lucide-static/icons");
|
|
6298
|
+
if (await exists(base)) add("lucide_icons", () => svgFolder(base, (n2) => `<Lucideicons.${n2.replace(/-/g, "_")} />`));
|
|
6299
|
+
}
|
|
6300
|
+
continue;
|
|
6301
|
+
}
|
|
6302
|
+
let deps = {};
|
|
6160
6303
|
try {
|
|
6161
|
-
|
|
6304
|
+
const pkg = JSON.parse(text2);
|
|
6305
|
+
deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
6162
6306
|
} catch {
|
|
6163
|
-
|
|
6307
|
+
continue;
|
|
6308
|
+
}
|
|
6309
|
+
for (const pkg of ICON_PACKAGES) {
|
|
6310
|
+
if (!(pkg in deps) || banned.has(pkg)) continue;
|
|
6311
|
+
const at = await installed(dir, root, pkg);
|
|
6312
|
+
if (!at) continue;
|
|
6313
|
+
if (pkg === "lucide-react" || pkg === "lucide-vue-next") add(pkg, () => lucideModules(at, pkg));
|
|
6314
|
+
else if (pkg === "@heroicons/react") add(pkg, () => heroReact(at));
|
|
6315
|
+
else if (pkg === "heroicons" && phoenix) add("heroicons (Phoenix)", () => heroPhoenix(at));
|
|
6316
|
+
else if (pkg === "lucide-static") {
|
|
6317
|
+
add(pkg, () => svgFolder(path3.join(at, "icons"), (n2) => `lucide-static/icons/${n2}.svg`));
|
|
6318
|
+
}
|
|
6319
|
+
}
|
|
6320
|
+
}
|
|
6321
|
+
return [...libs.values()];
|
|
6322
|
+
}
|
|
6323
|
+
async function matchLibraryIcon(libs, svg, layerName = "") {
|
|
6324
|
+
if (!libs.length) return void 0;
|
|
6325
|
+
const p = pointsOf(svg);
|
|
6326
|
+
if (!p) return void 0;
|
|
6327
|
+
const wanted = layerName.split("/").pop().trim().toLowerCase().replace(/icon$/i, "").replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
6328
|
+
const icons = (await Promise.all(libs.map(async (lib) => (await lib.load()).map((icon) => ({ icon, own: lib.name === "project" }))))).flat();
|
|
6329
|
+
for (const fit of [false, true]) {
|
|
6330
|
+
const a = fit ? fitted(p) : p;
|
|
6331
|
+
let best;
|
|
6332
|
+
for (const { icon, own: own2 } of icons) {
|
|
6333
|
+
if (fit && icon.points.kind !== p.kind) continue;
|
|
6334
|
+
const q = fit ? fitted(icon.points) : icon.points;
|
|
6335
|
+
if (q.box.some((v, i) => Math.abs(v - a.box[i]) > 0.12)) continue;
|
|
6336
|
+
const score = compare(a, q, best?.score);
|
|
6337
|
+
if (score === void 0) continue;
|
|
6338
|
+
const s = score - (icon.name === wanted ? 0.01 : 0) - (own2 ? 0.01 : 0);
|
|
6339
|
+
if (!best || s < best.score) best = { icon, score: s };
|
|
6340
|
+
}
|
|
6341
|
+
if (best) return best.icon;
|
|
6342
|
+
}
|
|
6343
|
+
return void 0;
|
|
6344
|
+
}
|
|
6345
|
+
function fitted(p) {
|
|
6346
|
+
let f = fits.get(p);
|
|
6347
|
+
if (f) return f;
|
|
6348
|
+
const [x0, y0, x1, y1] = p.box;
|
|
6349
|
+
const size = Math.max(x1 - x0, y1 - y0) || 1;
|
|
6350
|
+
const cx = (x0 + x1) / 2;
|
|
6351
|
+
const cy = (y0 + y1) / 2;
|
|
6352
|
+
const xy = p.xy.map((v, i) => (v - (i % 2 ? cy : cx)) / size + 0.5);
|
|
6353
|
+
f = { xy, box: [(x0 - cx) / size + 0.5, (y0 - cy) / size + 0.5, (x1 - cx) / size + 0.5, (y1 - cy) / size + 0.5], kind: p.kind };
|
|
6354
|
+
fits.set(p, f);
|
|
6355
|
+
return f;
|
|
6356
|
+
}
|
|
6357
|
+
function compare(a, b, beat = Infinity) {
|
|
6358
|
+
const d1 = nearest(a.xy, b.xy, MAX_OFFSET + SPREAD);
|
|
6359
|
+
if (!d1) return void 0;
|
|
6360
|
+
const d2 = nearest(b.xy, a.xy, MAX_OFFSET + SPREAD);
|
|
6361
|
+
if (!d2) return void 0;
|
|
6362
|
+
const all = Float64Array.from([...d1, ...d2]).sort();
|
|
6363
|
+
const offset = all[all.length >> 1];
|
|
6364
|
+
const spread = all[all.length - 1] - offset;
|
|
6365
|
+
const maxOffset = a.kind === b.kind && a.kind !== "mixed" ? SAME_KIND_OFFSET : MAX_OFFSET;
|
|
6366
|
+
if (offset > maxOffset || spread > SPREAD) return void 0;
|
|
6367
|
+
const score = spread + offset / 4;
|
|
6368
|
+
return score < beat + 0.01 ? score : void 0;
|
|
6369
|
+
}
|
|
6370
|
+
function nearest(a, b, limit) {
|
|
6371
|
+
const out = [];
|
|
6372
|
+
const lim2 = limit * limit;
|
|
6373
|
+
const stride = 14;
|
|
6374
|
+
for (let s = 0; s < stride; s += 2) {
|
|
6375
|
+
for (let i = s; i < a.length; i += stride) {
|
|
6376
|
+
const x = a[i];
|
|
6377
|
+
const y = a[i + 1];
|
|
6378
|
+
let m = Infinity;
|
|
6379
|
+
for (let j = 0; j < b.length; j += 2) {
|
|
6380
|
+
const dx = b[j] - x;
|
|
6381
|
+
const dy = b[j + 1] - y;
|
|
6382
|
+
const d = dx * dx + dy * dy;
|
|
6383
|
+
if (d < m) m = d;
|
|
6384
|
+
}
|
|
6385
|
+
if (m > lim2) return void 0;
|
|
6386
|
+
out.push(Math.sqrt(m));
|
|
6387
|
+
}
|
|
6388
|
+
}
|
|
6389
|
+
return out;
|
|
6390
|
+
}
|
|
6391
|
+
function pointsOf(svg) {
|
|
6392
|
+
const rootTag = /<svg\b[^>]*>/i.exec(svg)?.[0];
|
|
6393
|
+
if (!rootTag) return void 0;
|
|
6394
|
+
const root = attrs(rootTag);
|
|
6395
|
+
const vb = (root.viewBox ?? `0 0 ${parseFloat(root.width ?? "")} ${parseFloat(root.height ?? "")}`).split(/[\s,]+/).map(Number);
|
|
6396
|
+
const [vx, vy, vw, vh] = vb;
|
|
6397
|
+
if (vb.length !== 4 || !(vw > 0) || !(vh > 0)) return void 0;
|
|
6398
|
+
const size = Math.max(vw, vh);
|
|
6399
|
+
const body = svg.replace(/<(mask|clipPath|defs|title|desc)\b[\s\S]*?<\/\1>/gi, "");
|
|
6400
|
+
const polys = [];
|
|
6401
|
+
let stroked = false;
|
|
6402
|
+
let filled = false;
|
|
6403
|
+
for (const m of body.matchAll(/<(path|rect|circle|ellipse|line|polyline|polygon)\b([^>]*)>/gi)) {
|
|
6404
|
+
const a = attrs(m[2]);
|
|
6405
|
+
const fill = a.fill ?? root.fill ?? "black";
|
|
6406
|
+
const stroke = a.stroke ?? root.stroke ?? "none";
|
|
6407
|
+
if ((fill === "none" || fill === "transparent") && (stroke === "none" || stroke === "transparent")) continue;
|
|
6408
|
+
if (a.opacity === "0" || a.visibility === "hidden" || a.display === "none") continue;
|
|
6409
|
+
const lines = shapeLines(m[1].toLowerCase(), a);
|
|
6410
|
+
if (!lines) return void 0;
|
|
6411
|
+
const t = a.transform ? matrix(a.transform) : void 0;
|
|
6412
|
+
for (const l of lines) polys.push(t ? apply2(t, l) : l);
|
|
6413
|
+
if (stroke !== "none" && stroke !== "transparent") stroked = true;
|
|
6414
|
+
if (fill !== "none" && fill !== "transparent" && !/^(line|polyline)$/i.test(m[1])) filled = true;
|
|
6415
|
+
}
|
|
6416
|
+
const pts = [];
|
|
6417
|
+
let len = 0;
|
|
6418
|
+
for (const l of polys) for (let i = 2; i < l.length; i += 2) len += Math.hypot(l[i] - l[i - 2], l[i + 1] - l[i - 1]);
|
|
6419
|
+
if (!len) return void 0;
|
|
6420
|
+
const step = Math.max(STEP * size, len / MAX_POINTS);
|
|
6421
|
+
for (const l of polys) {
|
|
6422
|
+
pts.push(l[0], l[1]);
|
|
6423
|
+
let carry = 0;
|
|
6424
|
+
for (let i = 2; i < l.length; i += 2) {
|
|
6425
|
+
const x0 = l[i - 2], y0 = l[i - 1], x1 = l[i], y1 = l[i + 1];
|
|
6426
|
+
const seg = Math.hypot(x1 - x0, y1 - y0);
|
|
6427
|
+
let s = step - carry;
|
|
6428
|
+
for (; s <= seg; s += step) pts.push(x0 + (x1 - x0) * s / seg, y0 + (y1 - y0) * s / seg);
|
|
6429
|
+
carry = seg - (s - step);
|
|
6430
|
+
}
|
|
6431
|
+
if (carry > 0) pts.push(l[l.length - 2], l[l.length - 1]);
|
|
6432
|
+
}
|
|
6433
|
+
const xy = new Float64Array(pts.length);
|
|
6434
|
+
const box = [Infinity, Infinity, -Infinity, -Infinity];
|
|
6435
|
+
for (let i = 0; i < pts.length; i += 2) {
|
|
6436
|
+
const x = (pts[i] - vx) / size;
|
|
6437
|
+
const y = (pts[i + 1] - vy) / size;
|
|
6438
|
+
xy[i] = x;
|
|
6439
|
+
xy[i + 1] = y;
|
|
6440
|
+
box[0] = Math.min(box[0], x);
|
|
6441
|
+
box[1] = Math.min(box[1], y);
|
|
6442
|
+
box[2] = Math.max(box[2], x);
|
|
6443
|
+
box[3] = Math.max(box[3], y);
|
|
6444
|
+
}
|
|
6445
|
+
return { xy, box, kind: stroked && filled ? "mixed" : stroked ? "stroke" : "fill" };
|
|
6446
|
+
}
|
|
6447
|
+
function attrs(tag) {
|
|
6448
|
+
const out = {};
|
|
6449
|
+
for (const m of tag.matchAll(/([\w:-]+)\s*=\s*("([^"]*)"|'([^']*)')/g)) out[m[1]] = m[3] ?? m[4] ?? "";
|
|
6450
|
+
for (const d of (out.style ?? "").split(";")) {
|
|
6451
|
+
const [k, v] = d.split(":").map((s) => s?.trim());
|
|
6452
|
+
if (k && v) out[k] = v;
|
|
6453
|
+
}
|
|
6454
|
+
return out;
|
|
6455
|
+
}
|
|
6456
|
+
function shapeLines(tag, a) {
|
|
6457
|
+
const f = (k) => parseFloat(a[k] ?? "0") || 0;
|
|
6458
|
+
switch (tag) {
|
|
6459
|
+
case "path":
|
|
6460
|
+
return a.d ? pathLines(a.d) : void 0;
|
|
6461
|
+
case "rect": {
|
|
6462
|
+
const x = f("x"), y = f("y"), w = f("width"), h = f("height");
|
|
6463
|
+
const r = Math.min(f("rx") || f("ry"), w / 2, h / 2);
|
|
6464
|
+
if (!r) return [[x, y, x + w, y, x + w, y + h, x, y + h, x, y]];
|
|
6465
|
+
return pathLines(`M${x + r} ${y}H${x + w - r}A${r} ${r} 0 0 1 ${x + w} ${y + r}V${y + h - r}A${r} ${r} 0 0 1 ${x + w - r} ${y + h}H${x + r}A${r} ${r} 0 0 1 ${x} ${y + h - r}V${y + r}A${r} ${r} 0 0 1 ${x + r} ${y}Z`);
|
|
6466
|
+
}
|
|
6467
|
+
case "circle":
|
|
6468
|
+
case "ellipse": {
|
|
6469
|
+
const cx = f("cx"), cy = f("cy");
|
|
6470
|
+
const rx = tag === "circle" ? f("r") : f("rx");
|
|
6471
|
+
const ry = tag === "circle" ? f("r") : f("ry");
|
|
6472
|
+
const l = [];
|
|
6473
|
+
for (let k = 0; k <= 48; k++) l.push(cx + rx * Math.cos(k / 48 * 2 * Math.PI), cy + ry * Math.sin(k / 48 * 2 * Math.PI));
|
|
6474
|
+
return [l];
|
|
6164
6475
|
}
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
const
|
|
6169
|
-
if (
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6476
|
+
case "line":
|
|
6477
|
+
return [[f("x1"), f("y1"), f("x2"), f("y2")]];
|
|
6478
|
+
default: {
|
|
6479
|
+
const pts = (a.points ?? "").trim().split(/[\s,]+/).map(Number);
|
|
6480
|
+
if (pts.length < 4 || pts.some(Number.isNaN)) return void 0;
|
|
6481
|
+
return [tag === "polygon" ? [...pts, pts[0], pts[1]] : pts];
|
|
6482
|
+
}
|
|
6483
|
+
}
|
|
6484
|
+
}
|
|
6485
|
+
function pathLines(d) {
|
|
6486
|
+
const NUM = /[\s,]*([-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/y;
|
|
6487
|
+
const FLAG = /[\s,]*([01])/y;
|
|
6488
|
+
const CMD = /[\s,]*([MmLlHhVvCcSsQqTtAaZz])/y;
|
|
6489
|
+
let i = 0;
|
|
6490
|
+
const read = (re) => {
|
|
6491
|
+
re.lastIndex = i;
|
|
6492
|
+
const m = re.exec(d);
|
|
6493
|
+
if (!m) return void 0;
|
|
6494
|
+
i = re.lastIndex;
|
|
6495
|
+
return m[1];
|
|
6496
|
+
};
|
|
6497
|
+
const out = [];
|
|
6498
|
+
let cur = [];
|
|
6499
|
+
let x = 0, y = 0, sx = 0, sy = 0;
|
|
6500
|
+
let cx = 0, cy = 0;
|
|
6501
|
+
let prev = "";
|
|
6502
|
+
let cmd = "";
|
|
6503
|
+
const num3 = () => {
|
|
6504
|
+
const t = read(NUM);
|
|
6505
|
+
if (t === void 0) throw new Error("bad path");
|
|
6506
|
+
return parseFloat(t);
|
|
6507
|
+
};
|
|
6508
|
+
const flag = () => {
|
|
6509
|
+
const t = read(FLAG);
|
|
6510
|
+
if (t === void 0) throw new Error("bad path");
|
|
6511
|
+
return Number(t);
|
|
6512
|
+
};
|
|
6513
|
+
const lineTo = (nx, ny) => {
|
|
6514
|
+
cur.push(nx, ny);
|
|
6515
|
+
x = nx;
|
|
6516
|
+
y = ny;
|
|
6517
|
+
};
|
|
6518
|
+
const curve = (pts) => {
|
|
6519
|
+
const n2 = pts.length / 2;
|
|
6520
|
+
for (let k = 1; k <= 12; k++) {
|
|
6521
|
+
const t = k / 12;
|
|
6522
|
+
const p = pts.slice();
|
|
6523
|
+
for (let r = n2 - 1; r > 0; r--) for (let j = 0; j < r; j++) {
|
|
6524
|
+
p[2 * j] = p[2 * j] + (p[2 * j + 2] - p[2 * j]) * t;
|
|
6525
|
+
p[2 * j + 1] = p[2 * j + 1] + (p[2 * j + 3] - p[2 * j + 1]) * t;
|
|
6526
|
+
}
|
|
6527
|
+
cur.push(p[0], p[1]);
|
|
6528
|
+
}
|
|
6529
|
+
x = pts[pts.length - 2];
|
|
6530
|
+
y = pts[pts.length - 1];
|
|
6531
|
+
};
|
|
6532
|
+
try {
|
|
6533
|
+
while (!/^[\s,]*$/.test(d.slice(i))) {
|
|
6534
|
+
const c = read(CMD);
|
|
6535
|
+
if (c) cmd = c;
|
|
6536
|
+
else if (!cmd || /z/i.test(cmd)) return void 0;
|
|
6537
|
+
const up = cmd.toUpperCase();
|
|
6538
|
+
const rel = cmd !== up;
|
|
6539
|
+
const ox = rel ? x : 0;
|
|
6540
|
+
const oy = rel ? y : 0;
|
|
6541
|
+
if (up === "Z") {
|
|
6542
|
+
if (cur.length) cur.push(sx, sy);
|
|
6543
|
+
x = sx;
|
|
6544
|
+
y = sy;
|
|
6545
|
+
prev = "Z";
|
|
6546
|
+
continue;
|
|
6175
6547
|
}
|
|
6548
|
+
if (ARGS[up] === void 0) return void 0;
|
|
6549
|
+
if (up === "M") {
|
|
6550
|
+
if (cur.length > 2) out.push(cur);
|
|
6551
|
+
x = num3() + ox;
|
|
6552
|
+
y = num3() + oy;
|
|
6553
|
+
sx = x;
|
|
6554
|
+
sy = y;
|
|
6555
|
+
cur = [x, y];
|
|
6556
|
+
cmd = rel ? "l" : "L";
|
|
6557
|
+
} else if (up === "L") lineTo(num3() + ox, num3() + oy);
|
|
6558
|
+
else if (up === "H") lineTo(num3() + ox, y);
|
|
6559
|
+
else if (up === "V") lineTo(x, num3() + oy);
|
|
6560
|
+
else if (up === "C") {
|
|
6561
|
+
const p = [num3() + ox, num3() + oy, num3() + ox, num3() + oy, num3() + ox, num3() + oy];
|
|
6562
|
+
curve([x, y, ...p]);
|
|
6563
|
+
cx = p[2];
|
|
6564
|
+
cy = p[3];
|
|
6565
|
+
} else if (up === "S") {
|
|
6566
|
+
const [rx, ry] = /[CS]/.test(prev) ? [2 * x - cx, 2 * y - cy] : [x, y];
|
|
6567
|
+
const p = [num3() + ox, num3() + oy, num3() + ox, num3() + oy];
|
|
6568
|
+
curve([x, y, rx, ry, ...p]);
|
|
6569
|
+
cx = p[0];
|
|
6570
|
+
cy = p[1];
|
|
6571
|
+
} else if (up === "Q") {
|
|
6572
|
+
const p = [num3() + ox, num3() + oy, num3() + ox, num3() + oy];
|
|
6573
|
+
curve([x, y, ...p]);
|
|
6574
|
+
cx = p[0];
|
|
6575
|
+
cy = p[1];
|
|
6576
|
+
} else if (up === "T") {
|
|
6577
|
+
const [rx, ry] = /[QT]/.test(prev) ? [2 * x - cx, 2 * y - cy] : [x, y];
|
|
6578
|
+
curve([x, y, rx, ry, num3() + ox, num3() + oy]);
|
|
6579
|
+
cx = rx;
|
|
6580
|
+
cy = ry;
|
|
6581
|
+
} else if (up === "A") {
|
|
6582
|
+
const rx = num3(), ry = num3(), rot = num3(), large = flag(), sweep = flag();
|
|
6583
|
+
arc(x, y, rx, ry, rot, large, sweep, num3() + ox, num3() + oy, lineTo);
|
|
6584
|
+
}
|
|
6585
|
+
prev = up;
|
|
6176
6586
|
}
|
|
6587
|
+
} catch {
|
|
6588
|
+
return void 0;
|
|
6589
|
+
}
|
|
6590
|
+
if (cur.length > 2) out.push(cur);
|
|
6591
|
+
return out;
|
|
6592
|
+
}
|
|
6593
|
+
function arc(x1, y1, rx, ry, rotDeg, large, sweep, x2, y2, lineTo) {
|
|
6594
|
+
rx = Math.abs(rx);
|
|
6595
|
+
ry = Math.abs(ry);
|
|
6596
|
+
if (!rx || !ry || x1 === x2 && y1 === y2) return lineTo(x2, y2);
|
|
6597
|
+
const phi = rotDeg * Math.PI / 180;
|
|
6598
|
+
const cos = Math.cos(phi), sin = Math.sin(phi);
|
|
6599
|
+
const dx = (x1 - x2) / 2, dy = (y1 - y2) / 2;
|
|
6600
|
+
const x1p = cos * dx + sin * dy, y1p = -sin * dx + cos * dy;
|
|
6601
|
+
const lambda = x1p * x1p / (rx * rx) + y1p * y1p / (ry * ry);
|
|
6602
|
+
if (lambda > 1) {
|
|
6603
|
+
rx *= Math.sqrt(lambda);
|
|
6604
|
+
ry *= Math.sqrt(lambda);
|
|
6605
|
+
}
|
|
6606
|
+
const num3 = rx * rx * ry * ry - rx * rx * y1p * y1p - ry * ry * x1p * x1p;
|
|
6607
|
+
const den = rx * rx * y1p * y1p + ry * ry * x1p * x1p;
|
|
6608
|
+
let k = Math.sqrt(Math.max(0, num3 / den));
|
|
6609
|
+
if (large === sweep) k = -k;
|
|
6610
|
+
const cxp = k * rx * y1p / ry, cyp = -k * ry * x1p / rx;
|
|
6611
|
+
const cx = cos * cxp - sin * cyp + (x1 + x2) / 2;
|
|
6612
|
+
const cy = sin * cxp + cos * cyp + (y1 + y2) / 2;
|
|
6613
|
+
const ang = (ux, uy, vx, vy) => Math.atan2(ux * vy - uy * vx, ux * vx + uy * vy);
|
|
6614
|
+
const t1 = ang(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
|
|
6615
|
+
let dt = ang((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry);
|
|
6616
|
+
if (!sweep && dt > 0) dt -= 2 * Math.PI;
|
|
6617
|
+
else if (sweep && dt < 0) dt += 2 * Math.PI;
|
|
6618
|
+
const n2 = Math.max(4, Math.ceil(Math.abs(dt) / (Math.PI / 12)));
|
|
6619
|
+
for (let s = 1; s <= n2; s++) {
|
|
6620
|
+
const t = t1 + dt * s / n2;
|
|
6621
|
+
const ex = rx * Math.cos(t), ey = ry * Math.sin(t);
|
|
6622
|
+
lineTo(cos * ex - sin * ey + cx, sin * ex + cos * ey + cy);
|
|
6623
|
+
}
|
|
6624
|
+
}
|
|
6625
|
+
function matrix(t) {
|
|
6626
|
+
let m = [1, 0, 0, 1, 0, 0];
|
|
6627
|
+
const mul = (a, b) => [
|
|
6628
|
+
a[0] * b[0] + a[2] * b[1],
|
|
6629
|
+
a[1] * b[0] + a[3] * b[1],
|
|
6630
|
+
a[0] * b[2] + a[2] * b[3],
|
|
6631
|
+
a[1] * b[2] + a[3] * b[3],
|
|
6632
|
+
a[0] * b[4] + a[2] * b[5] + a[4],
|
|
6633
|
+
a[1] * b[4] + a[3] * b[5] + a[5]
|
|
6634
|
+
];
|
|
6635
|
+
for (const f of t.matchAll(/(matrix|translate|scale|rotate)\s*\(([^)]*)\)/g)) {
|
|
6636
|
+
const v = f[2].split(/[\s,]+/).filter(Boolean).map(Number);
|
|
6637
|
+
let n2;
|
|
6638
|
+
if (f[1] === "matrix") n2 = v;
|
|
6639
|
+
else if (f[1] === "translate") n2 = [1, 0, 0, 1, v[0] ?? 0, v[1] ?? 0];
|
|
6640
|
+
else if (f[1] === "scale") n2 = [v[0] ?? 1, 0, 0, v[1] ?? v[0] ?? 1, 0, 0];
|
|
6641
|
+
else {
|
|
6642
|
+
const r = (v[0] ?? 0) * Math.PI / 180;
|
|
6643
|
+
const [c, s, px2, py] = [Math.cos(r), Math.sin(r), v[1] ?? 0, v[2] ?? 0];
|
|
6644
|
+
n2 = [c, s, -s, c, px2 - c * px2 + s * py, py - s * px2 - c * py];
|
|
6645
|
+
}
|
|
6646
|
+
m = mul(m, n2);
|
|
6647
|
+
}
|
|
6648
|
+
return m;
|
|
6649
|
+
}
|
|
6650
|
+
function apply2(m, l) {
|
|
6651
|
+
const out = [];
|
|
6652
|
+
for (let i = 0; i < l.length; i += 2) out.push(m[0] * l[i] + m[2] * l[i + 1] + m[4], m[1] * l[i] + m[3] * l[i + 1] + m[5]);
|
|
6653
|
+
return out;
|
|
6654
|
+
}
|
|
6655
|
+
var pascal, HERO_SETS, kebab, plainSvg, ICON_PACKAGES, fits, MAX_OFFSET, SAME_KIND_OFFSET, SPREAD, STEP, MAX_POINTS, ARGS;
|
|
6656
|
+
var init_icons = __esm({
|
|
6657
|
+
"src/tools/icons.ts"() {
|
|
6658
|
+
"use strict";
|
|
6659
|
+
pascal = (s) => s.replace(/(^|[-_])([a-z0-9])/g, (_, __, c) => c.toUpperCase());
|
|
6660
|
+
HERO_SETS = [
|
|
6661
|
+
{ dir: "24/outline", suffix: "", stroke: true },
|
|
6662
|
+
{ dir: "24/solid", suffix: "-solid", stroke: false },
|
|
6663
|
+
{ dir: "20/solid", suffix: "-mini", stroke: false },
|
|
6664
|
+
{ dir: "16/solid", suffix: "-micro", stroke: false }
|
|
6665
|
+
];
|
|
6666
|
+
kebab = (s) => s.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
|
|
6667
|
+
plainSvg = (svg) => svg.replace(/\{\.\.\.[^{}]*\}/g, "").replace(/([\w:-]+)=\{[^{}]*\}/g, '$1="currentColor"');
|
|
6668
|
+
ICON_PACKAGES = ["lucide-react", "lucide-vue-next", "@heroicons/react", "heroicons", "lucide-static"];
|
|
6669
|
+
fits = /* @__PURE__ */ new WeakMap();
|
|
6670
|
+
MAX_OFFSET = 0.09;
|
|
6671
|
+
SAME_KIND_OFFSET = 0.02;
|
|
6672
|
+
SPREAD = 0.025;
|
|
6673
|
+
STEP = 0.02;
|
|
6674
|
+
MAX_POINTS = 240;
|
|
6675
|
+
ARGS = { M: 2, L: 2, H: 1, V: 1, C: 6, S: 4, Q: 4, T: 2, A: 7, Z: 0 };
|
|
6676
|
+
}
|
|
6677
|
+
});
|
|
6678
|
+
|
|
6679
|
+
// src/tools/code-components.ts
|
|
6680
|
+
function values(list, def) {
|
|
6681
|
+
const shown = list.slice(0, MAX_VALUES).map((v) => v === def ? `${v}*` : v);
|
|
6682
|
+
return shown.join("|") + (list.length > MAX_VALUES ? "|\u2026" : "");
|
|
6683
|
+
}
|
|
6684
|
+
function closing(src, open2) {
|
|
6685
|
+
let depth = 0;
|
|
6686
|
+
for (let i = open2; i < src.length; i++) {
|
|
6687
|
+
const c = src[i];
|
|
6688
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
6689
|
+
for (i++; i < src.length && src[i] !== c; i++) if (src[i] === "\\") i++;
|
|
6690
|
+
} else if (c === "/" && src[i + 1] === "/") i = src.indexOf("\n", i) < 0 ? src.length : src.indexOf("\n", i);
|
|
6691
|
+
else if (c === "/" && src[i + 1] === "*") i = src.indexOf("*/", i) < 0 ? src.length : src.indexOf("*/", i) + 1;
|
|
6692
|
+
else if (c === "{") depth++;
|
|
6693
|
+
else if (c === "}" && --depth === 0) return i + 1;
|
|
6694
|
+
}
|
|
6695
|
+
return src.length;
|
|
6696
|
+
}
|
|
6697
|
+
function keys(src, open2) {
|
|
6698
|
+
const end = closing(src, open2);
|
|
6699
|
+
const out = [];
|
|
6700
|
+
let i = open2 + 1;
|
|
6701
|
+
while (i < end - 1) {
|
|
6702
|
+
const m = /^\s*(?:(["'])([^"']*)\1|([\w$-]+))\s*:\s*/.exec(src.slice(i, end));
|
|
6703
|
+
if (!m) break;
|
|
6704
|
+
out.push({ key: m[2] ?? m[3], at: i + m[0].length });
|
|
6705
|
+
let j = i + m[0].length;
|
|
6706
|
+
for (; j < end - 1; j++) {
|
|
6707
|
+
const c = src[j];
|
|
6708
|
+
if (c === "{" || c === "[" || c === "(") {
|
|
6709
|
+
const close = c === "{" ? "}" : c === "[" ? "]" : ")";
|
|
6710
|
+
let d = 0;
|
|
6711
|
+
for (; j < end; j++) {
|
|
6712
|
+
const x = src[j];
|
|
6713
|
+
if (x === '"' || x === "'" || x === "`") {
|
|
6714
|
+
for (j++; j < end && src[j] !== x; j++) if (src[j] === "\\") j++;
|
|
6715
|
+
} else if (x === c) d++;
|
|
6716
|
+
else if (x === close && --d === 0) break;
|
|
6717
|
+
}
|
|
6718
|
+
} else if (c === '"' || c === "'" || c === "`") {
|
|
6719
|
+
for (j++; j < end && src[j] !== c; j++) if (src[j] === "\\") j++;
|
|
6720
|
+
} else if (c === ",") break;
|
|
6721
|
+
}
|
|
6722
|
+
i = j + 1;
|
|
6723
|
+
}
|
|
6724
|
+
return out;
|
|
6725
|
+
}
|
|
6726
|
+
function variantCalls(src) {
|
|
6727
|
+
const out = /* @__PURE__ */ new Map();
|
|
6728
|
+
for (const m of src.matchAll(/(?:const|let)\s+(\w+)\s*=\s*(?:cva|tv)\s*\(/g)) {
|
|
6729
|
+
const v = /\bvariants\s*:\s*\{/.exec(src.slice(m.index));
|
|
6730
|
+
if (!v) continue;
|
|
6731
|
+
const open2 = m.index + v.index + v[0].length - 1;
|
|
6732
|
+
const defaults = /* @__PURE__ */ new Map();
|
|
6733
|
+
const dv = /\bdefaultVariants\s*:\s*\{/.exec(src.slice(m.index));
|
|
6734
|
+
if (dv) {
|
|
6735
|
+
const at = m.index + dv.index + dv[0].length - 1;
|
|
6736
|
+
for (const k of keys(src, at)) {
|
|
6737
|
+
const val = /^\s*(["'])([^"']*)\1/.exec(src.slice(k.at))?.[2] ?? /^\s*(true|false)\b/.exec(src.slice(k.at))?.[1];
|
|
6738
|
+
if (val) defaults.set(k.key, val);
|
|
6739
|
+
}
|
|
6740
|
+
}
|
|
6741
|
+
const props = [];
|
|
6742
|
+
for (const k of keys(src, open2)) {
|
|
6743
|
+
if (src[k.at] !== "{") continue;
|
|
6744
|
+
const opts = keys(src, k.at).map((o) => o.key);
|
|
6745
|
+
if (!opts.length) continue;
|
|
6746
|
+
props.push(opts.every((o) => o === "true" || o === "false") ? k.key : `${k.key}="${values(opts, defaults.get(k.key))}"`);
|
|
6747
|
+
}
|
|
6748
|
+
if (props.length) out.set(m[1], props);
|
|
6749
|
+
}
|
|
6750
|
+
return out;
|
|
6751
|
+
}
|
|
6752
|
+
function reactComponents(src) {
|
|
6753
|
+
const exported = /* @__PURE__ */ new Set();
|
|
6754
|
+
for (const m of src.matchAll(/export\s+(?:default\s+)?(?:async\s+)?(?:function|const|let|class)\s+([A-Z]\w*)/g)) exported.add(m[1]);
|
|
6755
|
+
for (const m of src.matchAll(/export\s*\{([^}]*)\}/g)) {
|
|
6756
|
+
for (const part of m[1].split(",")) {
|
|
6757
|
+
const name = part.trim().split(/\s+as\s+/)[0].trim();
|
|
6758
|
+
if (/^[A-Z]\w*$/.test(name)) exported.add(name);
|
|
6759
|
+
}
|
|
6760
|
+
}
|
|
6761
|
+
const defined = [];
|
|
6762
|
+
for (const m of src.matchAll(/(?:^|\n)\s*(?:export\s+)?(?:default\s+)?(?:function\s+([A-Z]\w*)\s*[(<]|(?:const|let)\s+([A-Z]\w*)\s*(?::[^=]+)?=\s*(?:React\.)?(?:forwardRef|memo|\(|function|<))/g)) {
|
|
6763
|
+
const name = m[1] ?? m[2];
|
|
6764
|
+
if (exported.has(name)) defined.push({ name, at: m.index });
|
|
6765
|
+
}
|
|
6766
|
+
if (!defined.length) return [];
|
|
6767
|
+
const calls = variantCalls(src);
|
|
6768
|
+
const unions = [];
|
|
6769
|
+
for (const m of src.matchAll(/\b(\w+)\??\s*:\s*((?:["'][\w-]+["']\s*\|\s*)+["'][\w-]+["'])/g)) {
|
|
6770
|
+
const opts = [...m[2].matchAll(/["']([\w-]+)["']/g)].map((x) => x[1]);
|
|
6771
|
+
unions.push(`${m[1]}="${values(opts)}"`);
|
|
6772
|
+
}
|
|
6773
|
+
return defined.map(({ name, at }, i) => {
|
|
6774
|
+
const body = src.slice(at, defined[i + 1]?.at ?? src.length);
|
|
6775
|
+
const props = [...calls].filter(([fn]) => new RegExp(`\\b${fn}\\s*\\(`).test(body)).flatMap(([, p]) => p);
|
|
6776
|
+
if (!props.length && defined.length === 1) props.push(...unions);
|
|
6777
|
+
return { name, api: `<${name}${props.length ? ` ${[...new Set(props)].join(" ")}` : ""}>` };
|
|
6778
|
+
});
|
|
6779
|
+
}
|
|
6780
|
+
function elixirList(v) {
|
|
6781
|
+
const w = /^~w[([{<]([^)\]}>]*)[)\]}>]/.exec(v);
|
|
6782
|
+
if (w) return w[1].trim().split(/\s+/).filter(Boolean);
|
|
6783
|
+
const l = /^\[([^\]]*)\]/.exec(v);
|
|
6784
|
+
if (!l) return void 0;
|
|
6785
|
+
const out = [...l[1].matchAll(/(?:"([^"]*)"|:(\w+))/g)].map((m) => m[1] ?? m[2]);
|
|
6786
|
+
return out.length ? out : void 0;
|
|
6787
|
+
}
|
|
6788
|
+
function phoenixComponents(src) {
|
|
6789
|
+
const attrs3 = /* @__PURE__ */ new Map();
|
|
6790
|
+
for (const m of src.matchAll(/^\s*@(\w+)\s+(.+)$/gm)) {
|
|
6791
|
+
const list = elixirList(m[2].trim());
|
|
6792
|
+
if (list) attrs3.set(m[1], list);
|
|
6793
|
+
else if (m[2].trim().startsWith("%{")) {
|
|
6794
|
+
const ks = [...m[2].matchAll(/(?:^%\{|,)\s*(?:(\w+):|"([^"]+)"\s*=>|:(\w+)\s*=>)/g)].map((k) => k[1] ?? k[2] ?? k[3]);
|
|
6795
|
+
if (ks.length) attrs3.set(m[1], ks);
|
|
6796
|
+
}
|
|
6797
|
+
}
|
|
6798
|
+
const resolve = (v) => {
|
|
6799
|
+
v = v.trim();
|
|
6800
|
+
const direct = elixirList(v);
|
|
6801
|
+
if (direct) return direct.filter((x) => x !== "nil");
|
|
6802
|
+
const a = /^(?:Map\.keys\()?@(\w+)\)?/.exec(v);
|
|
6803
|
+
if (a) return attrs3.get(a[1]);
|
|
6804
|
+
const withNil = /^\[nil\s*\|\s*(.+)\]$/.exec(v);
|
|
6805
|
+
return withNil ? resolve(withNil[1]) : void 0;
|
|
6177
6806
|
};
|
|
6178
|
-
|
|
6807
|
+
const out = [];
|
|
6808
|
+
let props = [];
|
|
6809
|
+
let slots = [];
|
|
6810
|
+
let any2 = false;
|
|
6811
|
+
const joined = src.replace(/([,[(])[ \t]*\r?\n\s*/g, (_, c) => c === "," ? ", " : c).replace(/\r?\n\s*(?=[\])])/g, "");
|
|
6812
|
+
for (const line of joined.split("\n")) {
|
|
6813
|
+
const a = /^\s*attr\s+:(\w+)\s*,\s*:(\w+)(.*)$/.exec(line);
|
|
6814
|
+
if (a) {
|
|
6815
|
+
any2 = true;
|
|
6816
|
+
const [, name, type, rest] = a;
|
|
6817
|
+
const vals = /\bvalues:\s*(.+?)(?:,\s*\w+:|\s*$)/.exec(rest)?.[1];
|
|
6818
|
+
const def = /\bdefault:\s*(?:"([^"]*)"|:(\w+))/.exec(rest);
|
|
6819
|
+
const list = vals ? resolve(vals) : void 0;
|
|
6820
|
+
if (list?.length) props.push(`${name}="${values(list, def?.[1] ?? def?.[2])}"`);
|
|
6821
|
+
else if (type === "boolean") props.push(name);
|
|
6822
|
+
continue;
|
|
6823
|
+
}
|
|
6824
|
+
const s = /^\s*slot\s+:(\w+)/.exec(line);
|
|
6825
|
+
if (s) {
|
|
6826
|
+
any2 = true;
|
|
6827
|
+
if (s[1] !== "inner_block") slots.push(`<:${s[1]}>`);
|
|
6828
|
+
continue;
|
|
6829
|
+
}
|
|
6830
|
+
const d = /^\s*(defp?)\s+(\w+)\s*\(/.exec(line);
|
|
6831
|
+
if (d) {
|
|
6832
|
+
if (d[1] === "def" && any2 && !out.some((c) => c.name === d[2])) {
|
|
6833
|
+
out.push({ name: d[2], api: [`<.${d[2]}${props.length ? ` ${props.join(" ")}` : ""}>`, ...slots].join(" ") });
|
|
6834
|
+
}
|
|
6835
|
+
if (d[1] === "defp" || any2) {
|
|
6836
|
+
props = [];
|
|
6837
|
+
slots = [];
|
|
6838
|
+
any2 = false;
|
|
6839
|
+
}
|
|
6840
|
+
}
|
|
6841
|
+
}
|
|
6842
|
+
return out;
|
|
6843
|
+
}
|
|
6844
|
+
var MAX_VALUES;
|
|
6845
|
+
var init_code_components = __esm({
|
|
6846
|
+
"src/tools/code-components.ts"() {
|
|
6847
|
+
"use strict";
|
|
6848
|
+
MAX_VALUES = 8;
|
|
6849
|
+
}
|
|
6850
|
+
});
|
|
6851
|
+
|
|
6852
|
+
// src/tools/tailwind-v3-theme.ts
|
|
6853
|
+
var TAILWIND_V3_THEME;
|
|
6854
|
+
var init_tailwind_v3_theme = __esm({
|
|
6855
|
+
"src/tools/tailwind-v3-theme.ts"() {
|
|
6856
|
+
"use strict";
|
|
6857
|
+
TAILWIND_V3_THEME = {
|
|
6858
|
+
"--color-black": "#000",
|
|
6859
|
+
"--color-white": "#fff",
|
|
6860
|
+
"--color-slate-50": "#f8fafc",
|
|
6861
|
+
"--color-slate-100": "#f1f5f9",
|
|
6862
|
+
"--color-slate-200": "#e2e8f0",
|
|
6863
|
+
"--color-slate-300": "#cbd5e1",
|
|
6864
|
+
"--color-slate-400": "#94a3b8",
|
|
6865
|
+
"--color-slate-500": "#64748b",
|
|
6866
|
+
"--color-slate-600": "#475569",
|
|
6867
|
+
"--color-slate-700": "#334155",
|
|
6868
|
+
"--color-slate-800": "#1e293b",
|
|
6869
|
+
"--color-slate-900": "#0f172a",
|
|
6870
|
+
"--color-slate-950": "#020617",
|
|
6871
|
+
"--color-gray-50": "#f9fafb",
|
|
6872
|
+
"--color-gray-100": "#f3f4f6",
|
|
6873
|
+
"--color-gray-200": "#e5e7eb",
|
|
6874
|
+
"--color-gray-300": "#d1d5db",
|
|
6875
|
+
"--color-gray-400": "#9ca3af",
|
|
6876
|
+
"--color-gray-500": "#6b7280",
|
|
6877
|
+
"--color-gray-600": "#4b5563",
|
|
6878
|
+
"--color-gray-700": "#374151",
|
|
6879
|
+
"--color-gray-800": "#1f2937",
|
|
6880
|
+
"--color-gray-900": "#111827",
|
|
6881
|
+
"--color-gray-950": "#030712",
|
|
6882
|
+
"--color-zinc-50": "#fafafa",
|
|
6883
|
+
"--color-zinc-100": "#f4f4f5",
|
|
6884
|
+
"--color-zinc-200": "#e4e4e7",
|
|
6885
|
+
"--color-zinc-300": "#d4d4d8",
|
|
6886
|
+
"--color-zinc-400": "#a1a1aa",
|
|
6887
|
+
"--color-zinc-500": "#71717a",
|
|
6888
|
+
"--color-zinc-600": "#52525b",
|
|
6889
|
+
"--color-zinc-700": "#3f3f46",
|
|
6890
|
+
"--color-zinc-800": "#27272a",
|
|
6891
|
+
"--color-zinc-900": "#18181b",
|
|
6892
|
+
"--color-zinc-950": "#09090b",
|
|
6893
|
+
"--color-neutral-50": "#fafafa",
|
|
6894
|
+
"--color-neutral-100": "#f5f5f5",
|
|
6895
|
+
"--color-neutral-200": "#e5e5e5",
|
|
6896
|
+
"--color-neutral-300": "#d4d4d4",
|
|
6897
|
+
"--color-neutral-400": "#a3a3a3",
|
|
6898
|
+
"--color-neutral-500": "#737373",
|
|
6899
|
+
"--color-neutral-600": "#525252",
|
|
6900
|
+
"--color-neutral-700": "#404040",
|
|
6901
|
+
"--color-neutral-800": "#262626",
|
|
6902
|
+
"--color-neutral-900": "#171717",
|
|
6903
|
+
"--color-neutral-950": "#0a0a0a",
|
|
6904
|
+
"--color-stone-50": "#fafaf9",
|
|
6905
|
+
"--color-stone-100": "#f5f5f4",
|
|
6906
|
+
"--color-stone-200": "#e7e5e4",
|
|
6907
|
+
"--color-stone-300": "#d6d3d1",
|
|
6908
|
+
"--color-stone-400": "#a8a29e",
|
|
6909
|
+
"--color-stone-500": "#78716c",
|
|
6910
|
+
"--color-stone-600": "#57534e",
|
|
6911
|
+
"--color-stone-700": "#44403c",
|
|
6912
|
+
"--color-stone-800": "#292524",
|
|
6913
|
+
"--color-stone-900": "#1c1917",
|
|
6914
|
+
"--color-stone-950": "#0c0a09",
|
|
6915
|
+
"--color-red-50": "#fef2f2",
|
|
6916
|
+
"--color-red-100": "#fee2e2",
|
|
6917
|
+
"--color-red-200": "#fecaca",
|
|
6918
|
+
"--color-red-300": "#fca5a5",
|
|
6919
|
+
"--color-red-400": "#f87171",
|
|
6920
|
+
"--color-red-500": "#ef4444",
|
|
6921
|
+
"--color-red-600": "#dc2626",
|
|
6922
|
+
"--color-red-700": "#b91c1c",
|
|
6923
|
+
"--color-red-800": "#991b1b",
|
|
6924
|
+
"--color-red-900": "#7f1d1d",
|
|
6925
|
+
"--color-red-950": "#450a0a",
|
|
6926
|
+
"--color-orange-50": "#fff7ed",
|
|
6927
|
+
"--color-orange-100": "#ffedd5",
|
|
6928
|
+
"--color-orange-200": "#fed7aa",
|
|
6929
|
+
"--color-orange-300": "#fdba74",
|
|
6930
|
+
"--color-orange-400": "#fb923c",
|
|
6931
|
+
"--color-orange-500": "#f97316",
|
|
6932
|
+
"--color-orange-600": "#ea580c",
|
|
6933
|
+
"--color-orange-700": "#c2410c",
|
|
6934
|
+
"--color-orange-800": "#9a3412",
|
|
6935
|
+
"--color-orange-900": "#7c2d12",
|
|
6936
|
+
"--color-orange-950": "#431407",
|
|
6937
|
+
"--color-amber-50": "#fffbeb",
|
|
6938
|
+
"--color-amber-100": "#fef3c7",
|
|
6939
|
+
"--color-amber-200": "#fde68a",
|
|
6940
|
+
"--color-amber-300": "#fcd34d",
|
|
6941
|
+
"--color-amber-400": "#fbbf24",
|
|
6942
|
+
"--color-amber-500": "#f59e0b",
|
|
6943
|
+
"--color-amber-600": "#d97706",
|
|
6944
|
+
"--color-amber-700": "#b45309",
|
|
6945
|
+
"--color-amber-800": "#92400e",
|
|
6946
|
+
"--color-amber-900": "#78350f",
|
|
6947
|
+
"--color-amber-950": "#451a03",
|
|
6948
|
+
"--color-yellow-50": "#fefce8",
|
|
6949
|
+
"--color-yellow-100": "#fef9c3",
|
|
6950
|
+
"--color-yellow-200": "#fef08a",
|
|
6951
|
+
"--color-yellow-300": "#fde047",
|
|
6952
|
+
"--color-yellow-400": "#facc15",
|
|
6953
|
+
"--color-yellow-500": "#eab308",
|
|
6954
|
+
"--color-yellow-600": "#ca8a04",
|
|
6955
|
+
"--color-yellow-700": "#a16207",
|
|
6956
|
+
"--color-yellow-800": "#854d0e",
|
|
6957
|
+
"--color-yellow-900": "#713f12",
|
|
6958
|
+
"--color-yellow-950": "#422006",
|
|
6959
|
+
"--color-lime-50": "#f7fee7",
|
|
6960
|
+
"--color-lime-100": "#ecfccb",
|
|
6961
|
+
"--color-lime-200": "#d9f99d",
|
|
6962
|
+
"--color-lime-300": "#bef264",
|
|
6963
|
+
"--color-lime-400": "#a3e635",
|
|
6964
|
+
"--color-lime-500": "#84cc16",
|
|
6965
|
+
"--color-lime-600": "#65a30d",
|
|
6966
|
+
"--color-lime-700": "#4d7c0f",
|
|
6967
|
+
"--color-lime-800": "#3f6212",
|
|
6968
|
+
"--color-lime-900": "#365314",
|
|
6969
|
+
"--color-lime-950": "#1a2e05",
|
|
6970
|
+
"--color-green-50": "#f0fdf4",
|
|
6971
|
+
"--color-green-100": "#dcfce7",
|
|
6972
|
+
"--color-green-200": "#bbf7d0",
|
|
6973
|
+
"--color-green-300": "#86efac",
|
|
6974
|
+
"--color-green-400": "#4ade80",
|
|
6975
|
+
"--color-green-500": "#22c55e",
|
|
6976
|
+
"--color-green-600": "#16a34a",
|
|
6977
|
+
"--color-green-700": "#15803d",
|
|
6978
|
+
"--color-green-800": "#166534",
|
|
6979
|
+
"--color-green-900": "#14532d",
|
|
6980
|
+
"--color-green-950": "#052e16",
|
|
6981
|
+
"--color-emerald-50": "#ecfdf5",
|
|
6982
|
+
"--color-emerald-100": "#d1fae5",
|
|
6983
|
+
"--color-emerald-200": "#a7f3d0",
|
|
6984
|
+
"--color-emerald-300": "#6ee7b7",
|
|
6985
|
+
"--color-emerald-400": "#34d399",
|
|
6986
|
+
"--color-emerald-500": "#10b981",
|
|
6987
|
+
"--color-emerald-600": "#059669",
|
|
6988
|
+
"--color-emerald-700": "#047857",
|
|
6989
|
+
"--color-emerald-800": "#065f46",
|
|
6990
|
+
"--color-emerald-900": "#064e3b",
|
|
6991
|
+
"--color-emerald-950": "#022c22",
|
|
6992
|
+
"--color-teal-50": "#f0fdfa",
|
|
6993
|
+
"--color-teal-100": "#ccfbf1",
|
|
6994
|
+
"--color-teal-200": "#99f6e4",
|
|
6995
|
+
"--color-teal-300": "#5eead4",
|
|
6996
|
+
"--color-teal-400": "#2dd4bf",
|
|
6997
|
+
"--color-teal-500": "#14b8a6",
|
|
6998
|
+
"--color-teal-600": "#0d9488",
|
|
6999
|
+
"--color-teal-700": "#0f766e",
|
|
7000
|
+
"--color-teal-800": "#115e59",
|
|
7001
|
+
"--color-teal-900": "#134e4a",
|
|
7002
|
+
"--color-teal-950": "#042f2e",
|
|
7003
|
+
"--color-cyan-50": "#ecfeff",
|
|
7004
|
+
"--color-cyan-100": "#cffafe",
|
|
7005
|
+
"--color-cyan-200": "#a5f3fc",
|
|
7006
|
+
"--color-cyan-300": "#67e8f9",
|
|
7007
|
+
"--color-cyan-400": "#22d3ee",
|
|
7008
|
+
"--color-cyan-500": "#06b6d4",
|
|
7009
|
+
"--color-cyan-600": "#0891b2",
|
|
7010
|
+
"--color-cyan-700": "#0e7490",
|
|
7011
|
+
"--color-cyan-800": "#155e75",
|
|
7012
|
+
"--color-cyan-900": "#164e63",
|
|
7013
|
+
"--color-cyan-950": "#083344",
|
|
7014
|
+
"--color-sky-50": "#f0f9ff",
|
|
7015
|
+
"--color-sky-100": "#e0f2fe",
|
|
7016
|
+
"--color-sky-200": "#bae6fd",
|
|
7017
|
+
"--color-sky-300": "#7dd3fc",
|
|
7018
|
+
"--color-sky-400": "#38bdf8",
|
|
7019
|
+
"--color-sky-500": "#0ea5e9",
|
|
7020
|
+
"--color-sky-600": "#0284c7",
|
|
7021
|
+
"--color-sky-700": "#0369a1",
|
|
7022
|
+
"--color-sky-800": "#075985",
|
|
7023
|
+
"--color-sky-900": "#0c4a6e",
|
|
7024
|
+
"--color-sky-950": "#082f49",
|
|
7025
|
+
"--color-blue-50": "#eff6ff",
|
|
7026
|
+
"--color-blue-100": "#dbeafe",
|
|
7027
|
+
"--color-blue-200": "#bfdbfe",
|
|
7028
|
+
"--color-blue-300": "#93c5fd",
|
|
7029
|
+
"--color-blue-400": "#60a5fa",
|
|
7030
|
+
"--color-blue-500": "#3b82f6",
|
|
7031
|
+
"--color-blue-600": "#2563eb",
|
|
7032
|
+
"--color-blue-700": "#1d4ed8",
|
|
7033
|
+
"--color-blue-800": "#1e40af",
|
|
7034
|
+
"--color-blue-900": "#1e3a8a",
|
|
7035
|
+
"--color-blue-950": "#172554",
|
|
7036
|
+
"--color-indigo-50": "#eef2ff",
|
|
7037
|
+
"--color-indigo-100": "#e0e7ff",
|
|
7038
|
+
"--color-indigo-200": "#c7d2fe",
|
|
7039
|
+
"--color-indigo-300": "#a5b4fc",
|
|
7040
|
+
"--color-indigo-400": "#818cf8",
|
|
7041
|
+
"--color-indigo-500": "#6366f1",
|
|
7042
|
+
"--color-indigo-600": "#4f46e5",
|
|
7043
|
+
"--color-indigo-700": "#4338ca",
|
|
7044
|
+
"--color-indigo-800": "#3730a3",
|
|
7045
|
+
"--color-indigo-900": "#312e81",
|
|
7046
|
+
"--color-indigo-950": "#1e1b4b",
|
|
7047
|
+
"--color-violet-50": "#f5f3ff",
|
|
7048
|
+
"--color-violet-100": "#ede9fe",
|
|
7049
|
+
"--color-violet-200": "#ddd6fe",
|
|
7050
|
+
"--color-violet-300": "#c4b5fd",
|
|
7051
|
+
"--color-violet-400": "#a78bfa",
|
|
7052
|
+
"--color-violet-500": "#8b5cf6",
|
|
7053
|
+
"--color-violet-600": "#7c3aed",
|
|
7054
|
+
"--color-violet-700": "#6d28d9",
|
|
7055
|
+
"--color-violet-800": "#5b21b6",
|
|
7056
|
+
"--color-violet-900": "#4c1d95",
|
|
7057
|
+
"--color-violet-950": "#2e1065",
|
|
7058
|
+
"--color-purple-50": "#faf5ff",
|
|
7059
|
+
"--color-purple-100": "#f3e8ff",
|
|
7060
|
+
"--color-purple-200": "#e9d5ff",
|
|
7061
|
+
"--color-purple-300": "#d8b4fe",
|
|
7062
|
+
"--color-purple-400": "#c084fc",
|
|
7063
|
+
"--color-purple-500": "#a855f7",
|
|
7064
|
+
"--color-purple-600": "#9333ea",
|
|
7065
|
+
"--color-purple-700": "#7e22ce",
|
|
7066
|
+
"--color-purple-800": "#6b21a8",
|
|
7067
|
+
"--color-purple-900": "#581c87",
|
|
7068
|
+
"--color-purple-950": "#3b0764",
|
|
7069
|
+
"--color-fuchsia-50": "#fdf4ff",
|
|
7070
|
+
"--color-fuchsia-100": "#fae8ff",
|
|
7071
|
+
"--color-fuchsia-200": "#f5d0fe",
|
|
7072
|
+
"--color-fuchsia-300": "#f0abfc",
|
|
7073
|
+
"--color-fuchsia-400": "#e879f9",
|
|
7074
|
+
"--color-fuchsia-500": "#d946ef",
|
|
7075
|
+
"--color-fuchsia-600": "#c026d3",
|
|
7076
|
+
"--color-fuchsia-700": "#a21caf",
|
|
7077
|
+
"--color-fuchsia-800": "#86198f",
|
|
7078
|
+
"--color-fuchsia-900": "#701a75",
|
|
7079
|
+
"--color-fuchsia-950": "#4a044e",
|
|
7080
|
+
"--color-pink-50": "#fdf2f8",
|
|
7081
|
+
"--color-pink-100": "#fce7f3",
|
|
7082
|
+
"--color-pink-200": "#fbcfe8",
|
|
7083
|
+
"--color-pink-300": "#f9a8d4",
|
|
7084
|
+
"--color-pink-400": "#f472b6",
|
|
7085
|
+
"--color-pink-500": "#ec4899",
|
|
7086
|
+
"--color-pink-600": "#db2777",
|
|
7087
|
+
"--color-pink-700": "#be185d",
|
|
7088
|
+
"--color-pink-800": "#9d174d",
|
|
7089
|
+
"--color-pink-900": "#831843",
|
|
7090
|
+
"--color-pink-950": "#500724",
|
|
7091
|
+
"--color-rose-50": "#fff1f2",
|
|
7092
|
+
"--color-rose-100": "#ffe4e6",
|
|
7093
|
+
"--color-rose-200": "#fecdd3",
|
|
7094
|
+
"--color-rose-300": "#fda4af",
|
|
7095
|
+
"--color-rose-400": "#fb7185",
|
|
7096
|
+
"--color-rose-500": "#f43f5e",
|
|
7097
|
+
"--color-rose-600": "#e11d48",
|
|
7098
|
+
"--color-rose-700": "#be123c",
|
|
7099
|
+
"--color-rose-800": "#9f1239",
|
|
7100
|
+
"--color-rose-900": "#881337",
|
|
7101
|
+
"--color-rose-950": "#4c0519",
|
|
7102
|
+
"--text-xs": "0.75rem",
|
|
7103
|
+
"--text-xs--line-height": "1rem",
|
|
7104
|
+
"--text-sm": "0.875rem",
|
|
7105
|
+
"--text-sm--line-height": "1.25rem",
|
|
7106
|
+
"--text-base": "1rem",
|
|
7107
|
+
"--text-base--line-height": "1.5rem",
|
|
7108
|
+
"--text-lg": "1.125rem",
|
|
7109
|
+
"--text-lg--line-height": "1.75rem",
|
|
7110
|
+
"--text-xl": "1.25rem",
|
|
7111
|
+
"--text-xl--line-height": "1.75rem",
|
|
7112
|
+
"--text-2xl": "1.5rem",
|
|
7113
|
+
"--text-2xl--line-height": "2rem",
|
|
7114
|
+
"--text-3xl": "1.875rem",
|
|
7115
|
+
"--text-3xl--line-height": "2.25rem",
|
|
7116
|
+
"--text-4xl": "2.25rem",
|
|
7117
|
+
"--text-4xl--line-height": "2.5rem",
|
|
7118
|
+
"--text-5xl": "3rem",
|
|
7119
|
+
"--text-5xl--line-height": "1",
|
|
7120
|
+
"--text-6xl": "3.75rem",
|
|
7121
|
+
"--text-6xl--line-height": "1",
|
|
7122
|
+
"--text-7xl": "4.5rem",
|
|
7123
|
+
"--text-7xl--line-height": "1",
|
|
7124
|
+
"--text-8xl": "6rem",
|
|
7125
|
+
"--text-8xl--line-height": "1",
|
|
7126
|
+
"--text-9xl": "8rem",
|
|
7127
|
+
"--text-9xl--line-height": "1",
|
|
7128
|
+
"--font-weight-thin": "100",
|
|
7129
|
+
"--font-weight-extralight": "200",
|
|
7130
|
+
"--font-weight-light": "300",
|
|
7131
|
+
"--font-weight-normal": "400",
|
|
7132
|
+
"--font-weight-medium": "500",
|
|
7133
|
+
"--font-weight-semibold": "600",
|
|
7134
|
+
"--font-weight-bold": "700",
|
|
7135
|
+
"--font-weight-extrabold": "800",
|
|
7136
|
+
"--font-weight-black": "900",
|
|
7137
|
+
"--tracking-tighter": "-0.05em",
|
|
7138
|
+
"--tracking-tight": "-0.025em",
|
|
7139
|
+
"--tracking-normal": "0em",
|
|
7140
|
+
"--tracking-wide": "0.025em",
|
|
7141
|
+
"--tracking-wider": "0.05em",
|
|
7142
|
+
"--tracking-widest": "0.1em",
|
|
7143
|
+
"--font-sans": 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
|
7144
|
+
"--font-serif": 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',
|
|
7145
|
+
"--font-mono": 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
|
|
7146
|
+
};
|
|
7147
|
+
}
|
|
7148
|
+
});
|
|
7149
|
+
|
|
7150
|
+
// src/tools/tailwind-config.ts
|
|
7151
|
+
function configObject(src) {
|
|
7152
|
+
const anchor2 = /(?:module\.exports\s*=|export\s+default)\s*/.exec(src);
|
|
7153
|
+
if (!anchor2) return void 0;
|
|
7154
|
+
let i = anchor2.index + anchor2[0].length;
|
|
7155
|
+
const wrapper = /^[\w$.]+\s*\(\s*/.exec(src.slice(i));
|
|
7156
|
+
if (wrapper) i += wrapper[0].length;
|
|
7157
|
+
if (src[i] === "{") return parseAt(src, i);
|
|
7158
|
+
const name = /^[\w$]+/.exec(src.slice(i))?.[0];
|
|
7159
|
+
const decl = name && new RegExp(`(?:const|let|var)\\s+${name}\\s*(?::[^=\\n]+)?=\\s*(?:[\\w$.]+\\s*\\(\\s*)?\\{`).exec(src);
|
|
7160
|
+
return decl ? parseAt(src, decl.index + decl[0].length - 1) : void 0;
|
|
7161
|
+
}
|
|
7162
|
+
function localObject(src, name) {
|
|
7163
|
+
const m = new RegExp(`(?:const|let|var)\\s+${name}\\s*(?::[^=\\n]+)?=\\s*\\{`).exec(src);
|
|
7164
|
+
return m ? parseAt(src, m.index + m[0].length - 1) : void 0;
|
|
7165
|
+
}
|
|
7166
|
+
function paletteNames(src) {
|
|
7167
|
+
const names = /* @__PURE__ */ new Set();
|
|
7168
|
+
for (const m of src.matchAll(/(?:(?:const|let|var)\s+([\w$]+)\s*=\s*require\(|import\s+([\w$]+)\s+from\s+)\s*["']tailwindcss\/colors(?:\.js)?["']/g)) names.add(m[1] ?? m[2]);
|
|
7169
|
+
return names;
|
|
7170
|
+
}
|
|
7171
|
+
function replacedBy(name, replaced) {
|
|
7172
|
+
return [...replaced].some((p) => name.startsWith(p) && !(p === "--font-" && name.startsWith("--font-weight-")));
|
|
7173
|
+
}
|
|
7174
|
+
function tailwindV3Defaults(replaced) {
|
|
7175
|
+
return Object.entries(TAILWIND_V3_THEME).filter(([k]) => !replacedBy(k, replaced));
|
|
7176
|
+
}
|
|
7177
|
+
function tailwindConfigTheme(src, channel) {
|
|
7178
|
+
const out = { vars: [], replaced: /* @__PURE__ */ new Set() };
|
|
7179
|
+
const root = configObject(src);
|
|
7180
|
+
const theme = get(root, "theme");
|
|
7181
|
+
if (theme?.t !== "obj") return out;
|
|
7182
|
+
const palettes = paletteNames(src);
|
|
7183
|
+
const colorValue = (v) => {
|
|
7184
|
+
const fn = /^(hsl|rgb)a?\(\s*var\(\s*(--[\w-]+)\s*\)\s*(?:\/\s*([^)]*))?\)$/i.exec(v.trim());
|
|
7185
|
+
if (fn) {
|
|
7186
|
+
const ch = channel(fn[2]);
|
|
7187
|
+
if (!ch) return void 0;
|
|
7188
|
+
if (/^(hsl|rgb)a?\(/i.test(ch)) return ch;
|
|
7189
|
+
const alpha = fn[3]?.trim();
|
|
7190
|
+
return `${fn[1].toLowerCase()}(${ch}${alpha && !alpha.includes("<alpha-value>") ? ` / ${alpha}` : ""})`;
|
|
7191
|
+
}
|
|
7192
|
+
const plain = /^var\(\s*(--[\w-]+)\s*\)$/.exec(v.trim());
|
|
7193
|
+
return plain ? channel(plain[1]) : v;
|
|
7194
|
+
};
|
|
7195
|
+
const colors = (prefix, n2, depth = 0) => {
|
|
7196
|
+
if (depth > 6) return;
|
|
7197
|
+
if (n2.t === "str") {
|
|
7198
|
+
const v = colorValue(n2.v);
|
|
7199
|
+
if (v) out.vars.push([prefix, v]);
|
|
7200
|
+
} else if (n2.t === "obj") {
|
|
7201
|
+
for (const [k, x] of n2.props) colors(k === "DEFAULT" ? prefix : `${prefix}-${k}`, x, depth + 1);
|
|
7202
|
+
} else if (n2.t === "ref") {
|
|
7203
|
+
if (palettes.has(n2.path[0]) && n2.path.length > 1) {
|
|
7204
|
+
const base = `--color-${n2.path.slice(1).join("-")}`;
|
|
7205
|
+
for (const [k, v] of Object.entries(TAILWIND_V3_THEME)) {
|
|
7206
|
+
if (k === base || k.startsWith(`${base}-`)) out.vars.push([prefix + k.slice(base.length), v]);
|
|
7207
|
+
}
|
|
7208
|
+
} else if (n2.path.length === 1) {
|
|
7209
|
+
const local = localObject(src, n2.path[0]);
|
|
7210
|
+
if (local) colors(prefix, local, depth + 1);
|
|
7211
|
+
}
|
|
7212
|
+
}
|
|
7213
|
+
};
|
|
7214
|
+
const family = (n2) => {
|
|
7215
|
+
if (n2.t === "str") return n2.v;
|
|
7216
|
+
if (n2.t !== "arr") return void 0;
|
|
7217
|
+
const first = n2.items[0];
|
|
7218
|
+
const list = first?.t === "arr" ? first.items : n2.items;
|
|
7219
|
+
const names = list.flatMap((x) => x.t === "str" ? [/\s/.test(x.v) && !/[",]/.test(x.v) ? `"${x.v}"` : x.v] : []);
|
|
7220
|
+
return names.length ? names.join(", ") : void 0;
|
|
7221
|
+
};
|
|
7222
|
+
const sizes = (key, n2) => {
|
|
7223
|
+
const size = n2.t === "str" ? n2 : n2.t === "arr" ? n2.items[0] : void 0;
|
|
7224
|
+
if (size?.t !== "str") return;
|
|
7225
|
+
out.vars.push([`--text-${key}`, size.v]);
|
|
7226
|
+
const spec = n2.t === "arr" ? n2.items[1] : void 0;
|
|
7227
|
+
if (spec?.t === "str") out.vars.push([`--text-${key}--line-height`, spec.v]);
|
|
7228
|
+
else if (spec?.t === "obj") {
|
|
7229
|
+
for (const [prop2, name] of [["lineHeight", "line-height"], ["letterSpacing", "letter-spacing"], ["fontWeight", "font-weight"]]) {
|
|
7230
|
+
const x = spec.props.get(prop2);
|
|
7231
|
+
if (x?.t === "str") out.vars.push([`--text-${key}--${name}`, x.v]);
|
|
7232
|
+
}
|
|
7233
|
+
}
|
|
7234
|
+
};
|
|
7235
|
+
for (const layer of [theme, get(theme, "extend")]) {
|
|
7236
|
+
if (layer?.t !== "obj") continue;
|
|
7237
|
+
for (const [group, prefix] of GROUPS) {
|
|
7238
|
+
const n2 = layer.props.get(group);
|
|
7239
|
+
if (!n2) continue;
|
|
7240
|
+
if (layer === theme) out.replaced.add(prefix);
|
|
7241
|
+
if (n2.t !== "obj") continue;
|
|
7242
|
+
for (const [k, x] of n2.props) {
|
|
7243
|
+
if (group === "colors") colors(`--color-${k}`, x);
|
|
7244
|
+
else if (k === "DEFAULT") continue;
|
|
7245
|
+
else if (group === "fontSize") sizes(k, x);
|
|
7246
|
+
else if (group === "fontFamily") {
|
|
7247
|
+
const f = family(x);
|
|
7248
|
+
if (f) out.vars.push([`--font-${k}`, f]);
|
|
7249
|
+
} else if (x.t === "str") out.vars.push([`${prefix}${k}`, x.v]);
|
|
7250
|
+
}
|
|
7251
|
+
}
|
|
7252
|
+
}
|
|
7253
|
+
return out;
|
|
7254
|
+
}
|
|
7255
|
+
var OTHER, IDENT, Reader, parseAt, get, GROUPS;
|
|
7256
|
+
var init_tailwind_config = __esm({
|
|
7257
|
+
"src/tools/tailwind-config.ts"() {
|
|
7258
|
+
"use strict";
|
|
7259
|
+
init_tailwind_v3_theme();
|
|
7260
|
+
OTHER = { t: "other" };
|
|
7261
|
+
IDENT = /[\w$]/;
|
|
7262
|
+
Reader = class {
|
|
7263
|
+
constructor(s, i = 0) {
|
|
7264
|
+
this.s = s;
|
|
7265
|
+
this.i = i;
|
|
7266
|
+
}
|
|
7267
|
+
ws() {
|
|
7268
|
+
const s = this.s;
|
|
7269
|
+
for (; ; ) {
|
|
7270
|
+
while (this.i < s.length && /\s/.test(s[this.i])) this.i++;
|
|
7271
|
+
if (s[this.i] === "/" && s[this.i + 1] === "/") {
|
|
7272
|
+
const nl = s.indexOf("\n", this.i);
|
|
7273
|
+
this.i = nl < 0 ? s.length : nl;
|
|
7274
|
+
} else if (s[this.i] === "/" && s[this.i + 1] === "*") {
|
|
7275
|
+
const end = s.indexOf("*/", this.i + 2);
|
|
7276
|
+
this.i = end < 0 ? s.length : end + 2;
|
|
7277
|
+
} else return;
|
|
7278
|
+
}
|
|
7279
|
+
}
|
|
7280
|
+
quoted() {
|
|
7281
|
+
const s = this.s;
|
|
7282
|
+
const q = s[this.i++];
|
|
7283
|
+
let out = "";
|
|
7284
|
+
for (; this.i < s.length && s[this.i] !== q; this.i++) {
|
|
7285
|
+
if (s[this.i] === "\\") this.i++;
|
|
7286
|
+
out += s[this.i] ?? "";
|
|
7287
|
+
}
|
|
7288
|
+
this.i++;
|
|
7289
|
+
return out;
|
|
7290
|
+
}
|
|
7291
|
+
/** Moves to the next `,` or closing bracket at this depth, without consuming it. */
|
|
7292
|
+
skipExpr() {
|
|
7293
|
+
const s = this.s;
|
|
7294
|
+
let depth = 0;
|
|
7295
|
+
for (; this.i < s.length; this.i++) {
|
|
7296
|
+
const c = s[this.i];
|
|
7297
|
+
if (c === '"' || c === "'" || c === "`") this.quoted(), this.i--;
|
|
7298
|
+
else if (c === "/" && (s[this.i + 1] === "/" || s[this.i + 1] === "*")) this.ws(), this.i--;
|
|
7299
|
+
else if (c === "{" || c === "[" || c === "(") depth++;
|
|
7300
|
+
else if (c === "}" || c === "]" || c === ")") {
|
|
7301
|
+
if (depth === 0) return;
|
|
7302
|
+
depth--;
|
|
7303
|
+
} else if (c === "," && depth === 0) return;
|
|
7304
|
+
}
|
|
7305
|
+
}
|
|
7306
|
+
/** A value; anything that isn't a literal, an object, an array or a plain reference is `other`. */
|
|
7307
|
+
value() {
|
|
7308
|
+
this.ws();
|
|
7309
|
+
const s = this.s;
|
|
7310
|
+
const c = s[this.i];
|
|
7311
|
+
let node2 = OTHER;
|
|
7312
|
+
if (c === "{") node2 = this.object();
|
|
7313
|
+
else if (c === "[") {
|
|
7314
|
+
this.i++;
|
|
7315
|
+
const items = [];
|
|
7316
|
+
for (; ; ) {
|
|
7317
|
+
this.ws();
|
|
7318
|
+
if (this.i >= s.length || s[this.i] === "]") break;
|
|
7319
|
+
if (s[this.i] === ",") {
|
|
7320
|
+
this.i++;
|
|
7321
|
+
continue;
|
|
7322
|
+
}
|
|
7323
|
+
const before = this.i;
|
|
7324
|
+
items.push(s.startsWith("...", this.i) ? (this.skipExpr(), OTHER) : this.value());
|
|
7325
|
+
if (this.i === before) this.i++;
|
|
7326
|
+
}
|
|
7327
|
+
this.i++;
|
|
7328
|
+
node2 = { t: "arr", items };
|
|
7329
|
+
} else if (c === '"' || c === "'") node2 = { t: "str", v: this.quoted() };
|
|
7330
|
+
else if (c === "`") {
|
|
7331
|
+
const v = this.quoted();
|
|
7332
|
+
node2 = v.includes("${") ? OTHER : { t: "str", v };
|
|
7333
|
+
} else if (c !== void 0 && /[\d.-]/.test(c)) {
|
|
7334
|
+
const m = /^-?[\d.]+/.exec(s.slice(this.i, this.i + 24));
|
|
7335
|
+
if (m) {
|
|
7336
|
+
this.i += m[0].length;
|
|
7337
|
+
node2 = { t: "str", v: m[0] };
|
|
7338
|
+
}
|
|
7339
|
+
} else if (c !== void 0 && IDENT.test(c)) {
|
|
7340
|
+
const path7 = [];
|
|
7341
|
+
for (; ; ) {
|
|
7342
|
+
const m = /^[\w$]+/.exec(s.slice(this.i, this.i + 80));
|
|
7343
|
+
if (!m) break;
|
|
7344
|
+
path7.push(m[0]);
|
|
7345
|
+
this.i += m[0].length;
|
|
7346
|
+
if (s[this.i] === ".") {
|
|
7347
|
+
this.i++;
|
|
7348
|
+
continue;
|
|
7349
|
+
}
|
|
7350
|
+
const lit = /^\[\s*(["']?)([\w-]+)\1\s*\]/.exec(s.slice(this.i, this.i + 40));
|
|
7351
|
+
if (!lit) break;
|
|
7352
|
+
path7.push(lit[2]);
|
|
7353
|
+
this.i += lit[0].length;
|
|
7354
|
+
if (s[this.i] === ".") this.i++;
|
|
7355
|
+
else break;
|
|
7356
|
+
}
|
|
7357
|
+
node2 = path7.length ? { t: "ref", path: path7 } : OTHER;
|
|
7358
|
+
}
|
|
7359
|
+
this.ws();
|
|
7360
|
+
if (node2 !== OTHER && /^(?:as|satisfies)\s/.test(s.slice(this.i, this.i + 11))) {
|
|
7361
|
+
this.skipExpr();
|
|
7362
|
+
return node2;
|
|
7363
|
+
}
|
|
7364
|
+
if (this.i < s.length && ![",", "}", "]", ")"].includes(s[this.i])) {
|
|
7365
|
+
this.skipExpr();
|
|
7366
|
+
return OTHER;
|
|
7367
|
+
}
|
|
7368
|
+
return node2;
|
|
7369
|
+
}
|
|
7370
|
+
object() {
|
|
7371
|
+
const s = this.s;
|
|
7372
|
+
this.i++;
|
|
7373
|
+
const props = /* @__PURE__ */ new Map();
|
|
7374
|
+
for (; ; ) {
|
|
7375
|
+
this.ws();
|
|
7376
|
+
if (this.i >= s.length || s[this.i] === "}") break;
|
|
7377
|
+
if (s[this.i] === ",") {
|
|
7378
|
+
this.i++;
|
|
7379
|
+
continue;
|
|
7380
|
+
}
|
|
7381
|
+
const before = this.i;
|
|
7382
|
+
let key;
|
|
7383
|
+
if (s[this.i] === '"' || s[this.i] === "'") key = this.quoted();
|
|
7384
|
+
else {
|
|
7385
|
+
const m = /^[\w$-]+/.exec(s.slice(this.i, this.i + 80));
|
|
7386
|
+
if (m) {
|
|
7387
|
+
key = m[0];
|
|
7388
|
+
this.i += m[0].length;
|
|
7389
|
+
}
|
|
7390
|
+
}
|
|
7391
|
+
this.ws();
|
|
7392
|
+
if (key !== void 0 && s[this.i] === ":") {
|
|
7393
|
+
this.i++;
|
|
7394
|
+
props.set(key, this.value());
|
|
7395
|
+
} else if (key !== void 0 && (s[this.i] === "," || s[this.i] === "}")) {
|
|
7396
|
+
props.set(key, { t: "ref", path: [key] });
|
|
7397
|
+
} else this.skipExpr();
|
|
7398
|
+
if (this.i === before) this.i++;
|
|
7399
|
+
}
|
|
7400
|
+
this.i++;
|
|
7401
|
+
return { t: "obj", props };
|
|
7402
|
+
}
|
|
7403
|
+
};
|
|
7404
|
+
parseAt = (src, open2) => new Reader(src, open2).value();
|
|
7405
|
+
get = (n2, key) => n2?.t === "obj" ? n2.props.get(key) : void 0;
|
|
7406
|
+
GROUPS = [
|
|
7407
|
+
["colors", "--color-"],
|
|
7408
|
+
["fontFamily", "--font-"],
|
|
7409
|
+
["fontSize", "--text-"],
|
|
7410
|
+
["fontWeight", "--font-weight-"],
|
|
7411
|
+
["letterSpacing", "--tracking-"]
|
|
7412
|
+
];
|
|
7413
|
+
}
|
|
7414
|
+
});
|
|
7415
|
+
|
|
7416
|
+
// src/tools/tailwind-theme.ts
|
|
7417
|
+
var TAILWIND_THEME;
|
|
7418
|
+
var init_tailwind_theme = __esm({
|
|
7419
|
+
"src/tools/tailwind-theme.ts"() {
|
|
7420
|
+
"use strict";
|
|
7421
|
+
TAILWIND_THEME = {
|
|
7422
|
+
"--color-red-50": "oklch(97.1% 0.013 17.38)",
|
|
7423
|
+
"--color-red-100": "oklch(93.6% 0.032 17.717)",
|
|
7424
|
+
"--color-red-200": "oklch(88.5% 0.062 18.334)",
|
|
7425
|
+
"--color-red-300": "oklch(80.8% 0.114 19.571)",
|
|
7426
|
+
"--color-red-400": "oklch(70.4% 0.191 22.216)",
|
|
7427
|
+
"--color-red-500": "oklch(63.7% 0.237 25.331)",
|
|
7428
|
+
"--color-red-600": "oklch(57.7% 0.245 27.325)",
|
|
7429
|
+
"--color-red-700": "oklch(50.5% 0.213 27.518)",
|
|
7430
|
+
"--color-red-800": "oklch(44.4% 0.177 26.899)",
|
|
7431
|
+
"--color-red-900": "oklch(39.6% 0.141 25.723)",
|
|
7432
|
+
"--color-red-950": "oklch(25.8% 0.092 26.042)",
|
|
7433
|
+
"--color-orange-50": "oklch(98% 0.016 73.684)",
|
|
7434
|
+
"--color-orange-100": "oklch(95.4% 0.038 75.164)",
|
|
7435
|
+
"--color-orange-200": "oklch(90.1% 0.076 70.697)",
|
|
7436
|
+
"--color-orange-300": "oklch(83.7% 0.128 66.29)",
|
|
7437
|
+
"--color-orange-400": "oklch(75% 0.183 55.934)",
|
|
7438
|
+
"--color-orange-500": "oklch(70.5% 0.213 47.604)",
|
|
7439
|
+
"--color-orange-600": "oklch(64.6% 0.222 41.116)",
|
|
7440
|
+
"--color-orange-700": "oklch(55.3% 0.195 38.402)",
|
|
7441
|
+
"--color-orange-800": "oklch(47% 0.157 37.304)",
|
|
7442
|
+
"--color-orange-900": "oklch(40.8% 0.123 38.172)",
|
|
7443
|
+
"--color-orange-950": "oklch(26.6% 0.079 36.259)",
|
|
7444
|
+
"--color-amber-50": "oklch(98.7% 0.022 95.277)",
|
|
7445
|
+
"--color-amber-100": "oklch(96.2% 0.059 95.617)",
|
|
7446
|
+
"--color-amber-200": "oklch(92.4% 0.12 95.746)",
|
|
7447
|
+
"--color-amber-300": "oklch(87.9% 0.169 91.605)",
|
|
7448
|
+
"--color-amber-400": "oklch(82.8% 0.189 84.429)",
|
|
7449
|
+
"--color-amber-500": "oklch(76.9% 0.188 70.08)",
|
|
7450
|
+
"--color-amber-600": "oklch(66.6% 0.179 58.318)",
|
|
7451
|
+
"--color-amber-700": "oklch(55.5% 0.163 48.998)",
|
|
7452
|
+
"--color-amber-800": "oklch(47.3% 0.137 46.201)",
|
|
7453
|
+
"--color-amber-900": "oklch(41.4% 0.112 45.904)",
|
|
7454
|
+
"--color-amber-950": "oklch(27.9% 0.077 45.635)",
|
|
7455
|
+
"--color-yellow-50": "oklch(98.7% 0.026 102.212)",
|
|
7456
|
+
"--color-yellow-100": "oklch(97.3% 0.071 103.193)",
|
|
7457
|
+
"--color-yellow-200": "oklch(94.5% 0.129 101.54)",
|
|
7458
|
+
"--color-yellow-300": "oklch(90.5% 0.182 98.111)",
|
|
7459
|
+
"--color-yellow-400": "oklch(85.2% 0.199 91.936)",
|
|
7460
|
+
"--color-yellow-500": "oklch(79.5% 0.184 86.047)",
|
|
7461
|
+
"--color-yellow-600": "oklch(68.1% 0.162 75.834)",
|
|
7462
|
+
"--color-yellow-700": "oklch(55.4% 0.135 66.442)",
|
|
7463
|
+
"--color-yellow-800": "oklch(47.6% 0.114 61.907)",
|
|
7464
|
+
"--color-yellow-900": "oklch(42.1% 0.095 57.708)",
|
|
7465
|
+
"--color-yellow-950": "oklch(28.6% 0.066 53.813)",
|
|
7466
|
+
"--color-lime-50": "oklch(98.6% 0.031 120.757)",
|
|
7467
|
+
"--color-lime-100": "oklch(96.7% 0.067 122.328)",
|
|
7468
|
+
"--color-lime-200": "oklch(93.8% 0.127 124.321)",
|
|
7469
|
+
"--color-lime-300": "oklch(89.7% 0.196 126.665)",
|
|
7470
|
+
"--color-lime-400": "oklch(84.1% 0.238 128.85)",
|
|
7471
|
+
"--color-lime-500": "oklch(76.8% 0.233 130.85)",
|
|
7472
|
+
"--color-lime-600": "oklch(64.8% 0.2 131.684)",
|
|
7473
|
+
"--color-lime-700": "oklch(53.2% 0.157 131.589)",
|
|
7474
|
+
"--color-lime-800": "oklch(45.3% 0.124 130.933)",
|
|
7475
|
+
"--color-lime-900": "oklch(40.5% 0.101 131.063)",
|
|
7476
|
+
"--color-lime-950": "oklch(27.4% 0.072 132.109)",
|
|
7477
|
+
"--color-green-50": "oklch(98.2% 0.018 155.826)",
|
|
7478
|
+
"--color-green-100": "oklch(96.2% 0.044 156.743)",
|
|
7479
|
+
"--color-green-200": "oklch(92.5% 0.084 155.995)",
|
|
7480
|
+
"--color-green-300": "oklch(87.1% 0.15 154.449)",
|
|
7481
|
+
"--color-green-400": "oklch(79.2% 0.209 151.711)",
|
|
7482
|
+
"--color-green-500": "oklch(72.3% 0.219 149.579)",
|
|
7483
|
+
"--color-green-600": "oklch(62.7% 0.194 149.214)",
|
|
7484
|
+
"--color-green-700": "oklch(52.7% 0.154 150.069)",
|
|
7485
|
+
"--color-green-800": "oklch(44.8% 0.119 151.328)",
|
|
7486
|
+
"--color-green-900": "oklch(39.3% 0.095 152.535)",
|
|
7487
|
+
"--color-green-950": "oklch(26.6% 0.065 152.934)",
|
|
7488
|
+
"--color-emerald-50": "oklch(97.9% 0.021 166.113)",
|
|
7489
|
+
"--color-emerald-100": "oklch(95% 0.052 163.051)",
|
|
7490
|
+
"--color-emerald-200": "oklch(90.5% 0.093 164.15)",
|
|
7491
|
+
"--color-emerald-300": "oklch(84.5% 0.143 164.978)",
|
|
7492
|
+
"--color-emerald-400": "oklch(76.5% 0.177 163.223)",
|
|
7493
|
+
"--color-emerald-500": "oklch(69.6% 0.17 162.48)",
|
|
7494
|
+
"--color-emerald-600": "oklch(59.6% 0.145 163.225)",
|
|
7495
|
+
"--color-emerald-700": "oklch(50.8% 0.118 165.612)",
|
|
7496
|
+
"--color-emerald-800": "oklch(43.2% 0.095 166.913)",
|
|
7497
|
+
"--color-emerald-900": "oklch(37.8% 0.077 168.94)",
|
|
7498
|
+
"--color-emerald-950": "oklch(26.2% 0.051 172.552)",
|
|
7499
|
+
"--color-teal-50": "oklch(98.4% 0.014 180.72)",
|
|
7500
|
+
"--color-teal-100": "oklch(95.3% 0.051 180.801)",
|
|
7501
|
+
"--color-teal-200": "oklch(91% 0.096 180.426)",
|
|
7502
|
+
"--color-teal-300": "oklch(85.5% 0.138 181.071)",
|
|
7503
|
+
"--color-teal-400": "oklch(77.7% 0.152 181.912)",
|
|
7504
|
+
"--color-teal-500": "oklch(70.4% 0.14 182.503)",
|
|
7505
|
+
"--color-teal-600": "oklch(60% 0.118 184.704)",
|
|
7506
|
+
"--color-teal-700": "oklch(51.1% 0.096 186.391)",
|
|
7507
|
+
"--color-teal-800": "oklch(43.7% 0.078 188.216)",
|
|
7508
|
+
"--color-teal-900": "oklch(38.6% 0.063 188.416)",
|
|
7509
|
+
"--color-teal-950": "oklch(27.7% 0.046 192.524)",
|
|
7510
|
+
"--color-cyan-50": "oklch(98.4% 0.019 200.873)",
|
|
7511
|
+
"--color-cyan-100": "oklch(95.6% 0.045 203.388)",
|
|
7512
|
+
"--color-cyan-200": "oklch(91.7% 0.08 205.041)",
|
|
7513
|
+
"--color-cyan-300": "oklch(86.5% 0.127 207.078)",
|
|
7514
|
+
"--color-cyan-400": "oklch(78.9% 0.154 211.53)",
|
|
7515
|
+
"--color-cyan-500": "oklch(71.5% 0.143 215.221)",
|
|
7516
|
+
"--color-cyan-600": "oklch(60.9% 0.126 221.723)",
|
|
7517
|
+
"--color-cyan-700": "oklch(52% 0.105 223.128)",
|
|
7518
|
+
"--color-cyan-800": "oklch(45% 0.085 224.283)",
|
|
7519
|
+
"--color-cyan-900": "oklch(39.8% 0.07 227.392)",
|
|
7520
|
+
"--color-cyan-950": "oklch(30.2% 0.056 229.695)",
|
|
7521
|
+
"--color-sky-50": "oklch(97.7% 0.013 236.62)",
|
|
7522
|
+
"--color-sky-100": "oklch(95.1% 0.026 236.824)",
|
|
7523
|
+
"--color-sky-200": "oklch(90.1% 0.058 230.902)",
|
|
7524
|
+
"--color-sky-300": "oklch(82.8% 0.111 230.318)",
|
|
7525
|
+
"--color-sky-400": "oklch(74.6% 0.16 232.661)",
|
|
7526
|
+
"--color-sky-500": "oklch(68.5% 0.169 237.323)",
|
|
7527
|
+
"--color-sky-600": "oklch(58.8% 0.158 241.966)",
|
|
7528
|
+
"--color-sky-700": "oklch(50% 0.134 242.749)",
|
|
7529
|
+
"--color-sky-800": "oklch(44.3% 0.11 240.79)",
|
|
7530
|
+
"--color-sky-900": "oklch(39.1% 0.09 240.876)",
|
|
7531
|
+
"--color-sky-950": "oklch(29.3% 0.066 243.157)",
|
|
7532
|
+
"--color-blue-50": "oklch(97% 0.014 254.604)",
|
|
7533
|
+
"--color-blue-100": "oklch(93.2% 0.032 255.585)",
|
|
7534
|
+
"--color-blue-200": "oklch(88.2% 0.059 254.128)",
|
|
7535
|
+
"--color-blue-300": "oklch(80.9% 0.105 251.813)",
|
|
7536
|
+
"--color-blue-400": "oklch(70.7% 0.165 254.624)",
|
|
7537
|
+
"--color-blue-500": "oklch(62.3% 0.214 259.815)",
|
|
7538
|
+
"--color-blue-600": "oklch(54.6% 0.245 262.881)",
|
|
7539
|
+
"--color-blue-700": "oklch(48.8% 0.243 264.376)",
|
|
7540
|
+
"--color-blue-800": "oklch(42.4% 0.199 265.638)",
|
|
7541
|
+
"--color-blue-900": "oklch(37.9% 0.146 265.522)",
|
|
7542
|
+
"--color-blue-950": "oklch(28.2% 0.091 267.935)",
|
|
7543
|
+
"--color-indigo-50": "oklch(96.2% 0.018 272.314)",
|
|
7544
|
+
"--color-indigo-100": "oklch(93% 0.034 272.788)",
|
|
7545
|
+
"--color-indigo-200": "oklch(87% 0.065 274.039)",
|
|
7546
|
+
"--color-indigo-300": "oklch(78.5% 0.115 274.713)",
|
|
7547
|
+
"--color-indigo-400": "oklch(67.3% 0.182 276.935)",
|
|
7548
|
+
"--color-indigo-500": "oklch(58.5% 0.233 277.117)",
|
|
7549
|
+
"--color-indigo-600": "oklch(51.1% 0.262 276.966)",
|
|
7550
|
+
"--color-indigo-700": "oklch(45.7% 0.24 277.023)",
|
|
7551
|
+
"--color-indigo-800": "oklch(39.8% 0.195 277.366)",
|
|
7552
|
+
"--color-indigo-900": "oklch(35.9% 0.144 278.697)",
|
|
7553
|
+
"--color-indigo-950": "oklch(25.7% 0.09 281.288)",
|
|
7554
|
+
"--color-violet-50": "oklch(96.9% 0.016 293.756)",
|
|
7555
|
+
"--color-violet-100": "oklch(94.3% 0.029 294.588)",
|
|
7556
|
+
"--color-violet-200": "oklch(89.4% 0.057 293.283)",
|
|
7557
|
+
"--color-violet-300": "oklch(81.1% 0.111 293.571)",
|
|
7558
|
+
"--color-violet-400": "oklch(70.2% 0.183 293.541)",
|
|
7559
|
+
"--color-violet-500": "oklch(60.6% 0.25 292.717)",
|
|
7560
|
+
"--color-violet-600": "oklch(54.1% 0.281 293.009)",
|
|
7561
|
+
"--color-violet-700": "oklch(49.1% 0.27 292.581)",
|
|
7562
|
+
"--color-violet-800": "oklch(43.2% 0.232 292.759)",
|
|
7563
|
+
"--color-violet-900": "oklch(38% 0.189 293.745)",
|
|
7564
|
+
"--color-violet-950": "oklch(28.3% 0.141 291.089)",
|
|
7565
|
+
"--color-purple-50": "oklch(97.7% 0.014 308.299)",
|
|
7566
|
+
"--color-purple-100": "oklch(94.6% 0.033 307.174)",
|
|
7567
|
+
"--color-purple-200": "oklch(90.2% 0.063 306.703)",
|
|
7568
|
+
"--color-purple-300": "oklch(82.7% 0.119 306.383)",
|
|
7569
|
+
"--color-purple-400": "oklch(71.4% 0.203 305.504)",
|
|
7570
|
+
"--color-purple-500": "oklch(62.7% 0.265 303.9)",
|
|
7571
|
+
"--color-purple-600": "oklch(55.8% 0.288 302.321)",
|
|
7572
|
+
"--color-purple-700": "oklch(49.6% 0.265 301.924)",
|
|
7573
|
+
"--color-purple-800": "oklch(43.8% 0.218 303.724)",
|
|
7574
|
+
"--color-purple-900": "oklch(38.1% 0.176 304.987)",
|
|
7575
|
+
"--color-purple-950": "oklch(29.1% 0.149 302.717)",
|
|
7576
|
+
"--color-fuchsia-50": "oklch(97.7% 0.017 320.058)",
|
|
7577
|
+
"--color-fuchsia-100": "oklch(95.2% 0.037 318.852)",
|
|
7578
|
+
"--color-fuchsia-200": "oklch(90.3% 0.076 319.62)",
|
|
7579
|
+
"--color-fuchsia-300": "oklch(83.3% 0.145 321.434)",
|
|
7580
|
+
"--color-fuchsia-400": "oklch(74% 0.238 322.16)",
|
|
7581
|
+
"--color-fuchsia-500": "oklch(66.7% 0.295 322.15)",
|
|
7582
|
+
"--color-fuchsia-600": "oklch(59.1% 0.293 322.896)",
|
|
7583
|
+
"--color-fuchsia-700": "oklch(51.8% 0.253 323.949)",
|
|
7584
|
+
"--color-fuchsia-800": "oklch(45.2% 0.211 324.591)",
|
|
7585
|
+
"--color-fuchsia-900": "oklch(40.1% 0.17 325.612)",
|
|
7586
|
+
"--color-fuchsia-950": "oklch(29.3% 0.136 325.661)",
|
|
7587
|
+
"--color-pink-50": "oklch(97.1% 0.014 343.198)",
|
|
7588
|
+
"--color-pink-100": "oklch(94.8% 0.028 342.258)",
|
|
7589
|
+
"--color-pink-200": "oklch(89.9% 0.061 343.231)",
|
|
7590
|
+
"--color-pink-300": "oklch(82.3% 0.12 346.018)",
|
|
7591
|
+
"--color-pink-400": "oklch(71.8% 0.202 349.761)",
|
|
7592
|
+
"--color-pink-500": "oklch(65.6% 0.241 354.308)",
|
|
7593
|
+
"--color-pink-600": "oklch(59.2% 0.249 0.584)",
|
|
7594
|
+
"--color-pink-700": "oklch(52.5% 0.223 3.958)",
|
|
7595
|
+
"--color-pink-800": "oklch(45.9% 0.187 3.815)",
|
|
7596
|
+
"--color-pink-900": "oklch(40.8% 0.153 2.432)",
|
|
7597
|
+
"--color-pink-950": "oklch(28.4% 0.109 3.907)",
|
|
7598
|
+
"--color-rose-50": "oklch(96.9% 0.015 12.422)",
|
|
7599
|
+
"--color-rose-100": "oklch(94.1% 0.03 12.58)",
|
|
7600
|
+
"--color-rose-200": "oklch(89.2% 0.058 10.001)",
|
|
7601
|
+
"--color-rose-300": "oklch(81% 0.117 11.638)",
|
|
7602
|
+
"--color-rose-400": "oklch(71.2% 0.194 13.428)",
|
|
7603
|
+
"--color-rose-500": "oklch(64.5% 0.246 16.439)",
|
|
7604
|
+
"--color-rose-600": "oklch(58.6% 0.253 17.585)",
|
|
7605
|
+
"--color-rose-700": "oklch(51.4% 0.222 16.935)",
|
|
7606
|
+
"--color-rose-800": "oklch(45.5% 0.188 13.697)",
|
|
7607
|
+
"--color-rose-900": "oklch(41% 0.159 10.272)",
|
|
7608
|
+
"--color-rose-950": "oklch(27.1% 0.105 12.094)",
|
|
7609
|
+
"--color-slate-50": "oklch(98.4% 0.003 247.858)",
|
|
7610
|
+
"--color-slate-100": "oklch(96.8% 0.007 247.896)",
|
|
7611
|
+
"--color-slate-200": "oklch(92.9% 0.013 255.508)",
|
|
7612
|
+
"--color-slate-300": "oklch(86.9% 0.022 252.894)",
|
|
7613
|
+
"--color-slate-400": "oklch(70.4% 0.04 256.788)",
|
|
7614
|
+
"--color-slate-500": "oklch(55.4% 0.046 257.417)",
|
|
7615
|
+
"--color-slate-600": "oklch(44.6% 0.043 257.281)",
|
|
7616
|
+
"--color-slate-700": "oklch(37.2% 0.044 257.287)",
|
|
7617
|
+
"--color-slate-800": "oklch(27.9% 0.041 260.031)",
|
|
7618
|
+
"--color-slate-900": "oklch(20.8% 0.042 265.755)",
|
|
7619
|
+
"--color-slate-950": "oklch(12.9% 0.042 264.695)",
|
|
7620
|
+
"--color-gray-50": "oklch(98.5% 0.002 247.839)",
|
|
7621
|
+
"--color-gray-100": "oklch(96.7% 0.003 264.542)",
|
|
7622
|
+
"--color-gray-200": "oklch(92.8% 0.006 264.531)",
|
|
7623
|
+
"--color-gray-300": "oklch(87.2% 0.01 258.338)",
|
|
7624
|
+
"--color-gray-400": "oklch(70.7% 0.022 261.325)",
|
|
7625
|
+
"--color-gray-500": "oklch(55.1% 0.027 264.364)",
|
|
7626
|
+
"--color-gray-600": "oklch(44.6% 0.03 256.802)",
|
|
7627
|
+
"--color-gray-700": "oklch(37.3% 0.034 259.733)",
|
|
7628
|
+
"--color-gray-800": "oklch(27.8% 0.033 256.848)",
|
|
7629
|
+
"--color-gray-900": "oklch(21% 0.034 264.665)",
|
|
7630
|
+
"--color-gray-950": "oklch(13% 0.028 261.692)",
|
|
7631
|
+
"--color-zinc-50": "oklch(98.5% 0 none)",
|
|
7632
|
+
"--color-zinc-100": "oklch(96.7% 0.001 286.375)",
|
|
7633
|
+
"--color-zinc-200": "oklch(92% 0.004 286.32)",
|
|
7634
|
+
"--color-zinc-300": "oklch(87.1% 0.006 286.286)",
|
|
7635
|
+
"--color-zinc-400": "oklch(70.5% 0.015 286.067)",
|
|
7636
|
+
"--color-zinc-500": "oklch(55.2% 0.016 285.938)",
|
|
7637
|
+
"--color-zinc-600": "oklch(44.2% 0.017 285.786)",
|
|
7638
|
+
"--color-zinc-700": "oklch(37% 0.013 285.805)",
|
|
7639
|
+
"--color-zinc-800": "oklch(27.4% 0.006 286.033)",
|
|
7640
|
+
"--color-zinc-900": "oklch(21% 0.006 285.885)",
|
|
7641
|
+
"--color-zinc-950": "oklch(14.1% 0.005 285.823)",
|
|
7642
|
+
"--color-neutral-50": "oklch(98.5% 0 none)",
|
|
7643
|
+
"--color-neutral-100": "oklch(97% 0 none)",
|
|
7644
|
+
"--color-neutral-200": "oklch(92.2% 0 none)",
|
|
7645
|
+
"--color-neutral-300": "oklch(87% 0 none)",
|
|
7646
|
+
"--color-neutral-400": "oklch(70.8% 0 none)",
|
|
7647
|
+
"--color-neutral-500": "oklch(55.6% 0 none)",
|
|
7648
|
+
"--color-neutral-600": "oklch(43.9% 0 none)",
|
|
7649
|
+
"--color-neutral-700": "oklch(37.1% 0 none)",
|
|
7650
|
+
"--color-neutral-800": "oklch(26.9% 0 none)",
|
|
7651
|
+
"--color-neutral-900": "oklch(20.5% 0 none)",
|
|
7652
|
+
"--color-neutral-950": "oklch(14.5% 0 none)",
|
|
7653
|
+
"--color-stone-50": "oklch(98.5% 0.001 106.423)",
|
|
7654
|
+
"--color-stone-100": "oklch(97% 0.001 106.424)",
|
|
7655
|
+
"--color-stone-200": "oklch(92.3% 0.003 48.717)",
|
|
7656
|
+
"--color-stone-300": "oklch(86.9% 0.005 56.366)",
|
|
7657
|
+
"--color-stone-400": "oklch(70.9% 0.01 56.259)",
|
|
7658
|
+
"--color-stone-500": "oklch(55.3% 0.013 58.071)",
|
|
7659
|
+
"--color-stone-600": "oklch(44.4% 0.011 73.639)",
|
|
7660
|
+
"--color-stone-700": "oklch(37.4% 0.01 67.558)",
|
|
7661
|
+
"--color-stone-800": "oklch(26.8% 0.007 34.298)",
|
|
7662
|
+
"--color-stone-900": "oklch(21.6% 0.006 56.043)",
|
|
7663
|
+
"--color-stone-950": "oklch(14.7% 0.004 49.25)",
|
|
7664
|
+
"--color-mauve-50": "oklch(98.5% 0 none)",
|
|
7665
|
+
"--color-mauve-100": "oklch(96% 0.003 325.6)",
|
|
7666
|
+
"--color-mauve-200": "oklch(92.2% 0.005 325.62)",
|
|
7667
|
+
"--color-mauve-300": "oklch(86.5% 0.012 325.68)",
|
|
7668
|
+
"--color-mauve-400": "oklch(71.1% 0.019 323.02)",
|
|
7669
|
+
"--color-mauve-500": "oklch(54.2% 0.034 322.5)",
|
|
7670
|
+
"--color-mauve-600": "oklch(43.5% 0.029 321.78)",
|
|
7671
|
+
"--color-mauve-700": "oklch(36.4% 0.029 323.89)",
|
|
7672
|
+
"--color-mauve-800": "oklch(26.3% 0.024 320.12)",
|
|
7673
|
+
"--color-mauve-900": "oklch(21.2% 0.019 322.12)",
|
|
7674
|
+
"--color-mauve-950": "oklch(14.5% 0.008 326)",
|
|
7675
|
+
"--color-olive-50": "oklch(98.8% 0.003 106.5)",
|
|
7676
|
+
"--color-olive-100": "oklch(96.6% 0.005 106.5)",
|
|
7677
|
+
"--color-olive-200": "oklch(93% 0.007 106.5)",
|
|
7678
|
+
"--color-olive-300": "oklch(88% 0.011 106.6)",
|
|
7679
|
+
"--color-olive-400": "oklch(73.7% 0.021 106.9)",
|
|
7680
|
+
"--color-olive-500": "oklch(58% 0.031 107.3)",
|
|
7681
|
+
"--color-olive-600": "oklch(46.6% 0.025 107.3)",
|
|
7682
|
+
"--color-olive-700": "oklch(39.4% 0.023 107.4)",
|
|
7683
|
+
"--color-olive-800": "oklch(28.6% 0.016 107.4)",
|
|
7684
|
+
"--color-olive-900": "oklch(22.8% 0.013 107.4)",
|
|
7685
|
+
"--color-olive-950": "oklch(15.3% 0.006 107.1)",
|
|
7686
|
+
"--color-mist-50": "oklch(98.7% 0.002 197.1)",
|
|
7687
|
+
"--color-mist-100": "oklch(96.3% 0.002 197.1)",
|
|
7688
|
+
"--color-mist-200": "oklch(92.5% 0.005 214.3)",
|
|
7689
|
+
"--color-mist-300": "oklch(87.2% 0.007 219.6)",
|
|
7690
|
+
"--color-mist-400": "oklch(72.3% 0.014 214.4)",
|
|
7691
|
+
"--color-mist-500": "oklch(56% 0.021 213.5)",
|
|
7692
|
+
"--color-mist-600": "oklch(45% 0.017 213.2)",
|
|
7693
|
+
"--color-mist-700": "oklch(37.8% 0.015 216)",
|
|
7694
|
+
"--color-mist-800": "oklch(27.5% 0.011 216.9)",
|
|
7695
|
+
"--color-mist-900": "oklch(21.8% 0.008 223.9)",
|
|
7696
|
+
"--color-mist-950": "oklch(14.8% 0.004 228.8)",
|
|
7697
|
+
"--color-taupe-50": "oklch(98.6% 0.002 67.8)",
|
|
7698
|
+
"--color-taupe-100": "oklch(96% 0.002 17.2)",
|
|
7699
|
+
"--color-taupe-200": "oklch(92.2% 0.005 34.3)",
|
|
7700
|
+
"--color-taupe-300": "oklch(86.8% 0.007 39.5)",
|
|
7701
|
+
"--color-taupe-400": "oklch(71.4% 0.014 41.2)",
|
|
7702
|
+
"--color-taupe-500": "oklch(54.7% 0.021 43.1)",
|
|
7703
|
+
"--color-taupe-600": "oklch(43.8% 0.017 39.3)",
|
|
7704
|
+
"--color-taupe-700": "oklch(36.7% 0.016 35.7)",
|
|
7705
|
+
"--color-taupe-800": "oklch(26.8% 0.011 36.5)",
|
|
7706
|
+
"--color-taupe-900": "oklch(21.4% 0.009 43.1)",
|
|
7707
|
+
"--color-taupe-950": "oklch(14.7% 0.004 49.3)",
|
|
7708
|
+
"--color-black": "#000",
|
|
7709
|
+
"--color-white": "#fff",
|
|
7710
|
+
"--text-xs": "0.75rem",
|
|
7711
|
+
"--text-xs--line-height": "calc(1 / 0.75)",
|
|
7712
|
+
"--text-sm": "0.875rem",
|
|
7713
|
+
"--text-sm--line-height": "calc(1.25 / 0.875)",
|
|
7714
|
+
"--text-base": "1rem",
|
|
7715
|
+
"--text-base--line-height": "calc(1.5 / 1)",
|
|
7716
|
+
"--text-lg": "1.125rem",
|
|
7717
|
+
"--text-lg--line-height": "calc(1.75 / 1.125)",
|
|
7718
|
+
"--text-xl": "1.25rem",
|
|
7719
|
+
"--text-xl--line-height": "calc(1.75 / 1.25)",
|
|
7720
|
+
"--text-2xl": "1.5rem",
|
|
7721
|
+
"--text-2xl--line-height": "calc(2 / 1.5)",
|
|
7722
|
+
"--text-3xl": "1.875rem",
|
|
7723
|
+
"--text-3xl--line-height": "calc(2.25 / 1.875)",
|
|
7724
|
+
"--text-4xl": "2.25rem",
|
|
7725
|
+
"--text-4xl--line-height": "calc(2.5 / 2.25)",
|
|
7726
|
+
"--text-5xl": "3rem",
|
|
7727
|
+
"--text-5xl--line-height": "1",
|
|
7728
|
+
"--text-6xl": "3.75rem",
|
|
7729
|
+
"--text-6xl--line-height": "1",
|
|
7730
|
+
"--text-7xl": "4.5rem",
|
|
7731
|
+
"--text-7xl--line-height": "1",
|
|
7732
|
+
"--text-8xl": "6rem",
|
|
7733
|
+
"--text-8xl--line-height": "1",
|
|
7734
|
+
"--text-9xl": "8rem",
|
|
7735
|
+
"--text-9xl--line-height": "1",
|
|
7736
|
+
"--font-weight-thin": "100",
|
|
7737
|
+
"--font-weight-extralight": "200",
|
|
7738
|
+
"--font-weight-light": "300",
|
|
7739
|
+
"--font-weight-normal": "400",
|
|
7740
|
+
"--font-weight-medium": "500",
|
|
7741
|
+
"--font-weight-semibold": "600",
|
|
7742
|
+
"--font-weight-bold": "700",
|
|
7743
|
+
"--font-weight-extrabold": "800",
|
|
7744
|
+
"--font-weight-black": "900",
|
|
7745
|
+
"--tracking-tighter": "-0.05em",
|
|
7746
|
+
"--tracking-tight": "-0.025em",
|
|
7747
|
+
"--tracking-normal": "0em",
|
|
7748
|
+
"--tracking-wide": "0.025em",
|
|
7749
|
+
"--tracking-wider": "0.05em",
|
|
7750
|
+
"--tracking-widest": "0.1em",
|
|
7751
|
+
"--text-shadow-2xs": "0px 1px 0px rgb(0 0 0 / 0.15)",
|
|
7752
|
+
"--text-shadow-xs": "0px 1px 1px rgb(0 0 0 / 0.2)",
|
|
7753
|
+
"--text-shadow-sm": "0px 1px 0px rgb(0 0 0 / 0.075), 0px 1px 1px rgb(0 0 0 / 0.075), 0px 2px 2px rgb(0 0 0 / 0.075)",
|
|
7754
|
+
"--text-shadow-md": "0px 1px 1px rgb(0 0 0 / 0.1), 0px 1px 2px rgb(0 0 0 / 0.1), 0px 2px 4px rgb(0 0 0 / 0.1)",
|
|
7755
|
+
"--text-shadow-lg": "0px 1px 2px rgb(0 0 0 / 0.1), 0px 3px 2px rgb(0 0 0 / 0.1), 0px 4px 8px rgb(0 0 0 / 0.1)"
|
|
7756
|
+
};
|
|
7757
|
+
}
|
|
7758
|
+
});
|
|
7759
|
+
|
|
7760
|
+
// src/tools/project.ts
|
|
7761
|
+
import { execFile } from "node:child_process";
|
|
7762
|
+
import { readdir as readdir2, readFile as readFile3 } from "node:fs/promises";
|
|
7763
|
+
import os3 from "node:os";
|
|
7764
|
+
import path4 from "node:path";
|
|
7765
|
+
import { promisify } from "node:util";
|
|
7766
|
+
async function scanProject(root, exclude = [], maxEntries = MAX_ENTRIES) {
|
|
7767
|
+
root = path4.resolve(root);
|
|
7768
|
+
if (root === path4.parse(root).root || root === os3.homedir()) return void 0;
|
|
7769
|
+
const skip = [...new Set(exclude.map((e) => path4.resolve(e)))];
|
|
7770
|
+
const styles = [];
|
|
7771
|
+
const svgs = [];
|
|
7772
|
+
const comps = [];
|
|
7773
|
+
const manifests = [];
|
|
7774
|
+
const elixir = [];
|
|
7775
|
+
const twConfigs = [];
|
|
7776
|
+
const shown = (p) => path4.relative(process.cwd(), p).split(path4.sep).join("/");
|
|
7777
|
+
let incomplete;
|
|
7778
|
+
const sort = (p) => {
|
|
7779
|
+
const name = path4.basename(p);
|
|
7780
|
+
if (STYLE.test(name)) styles.push(p);
|
|
7781
|
+
else if (/\.svg$/i.test(name)) svgs.push(p);
|
|
7782
|
+
else if (COMPONENT_FILE.test(name)) comps.push(p);
|
|
7783
|
+
else if (name === "package.json" || name === "mix.exs") manifests.push(p);
|
|
7784
|
+
else if (name.endsWith(".ex")) elixir.push(p);
|
|
7785
|
+
else if (/^tailwind\.config\.(js|cjs|mjs|ts)$/.test(name)) twConfigs.push(p);
|
|
7786
|
+
};
|
|
7787
|
+
const skipped = (p) => skip.some((s) => p === s || p.startsWith(s + path4.sep));
|
|
7788
|
+
const tracked = await gitFiles(root);
|
|
7789
|
+
if (tracked?.length) {
|
|
7790
|
+
for (const p of tracked) {
|
|
7791
|
+
const dirs = path4.relative(root, p).split(path4.sep).slice(0, -1);
|
|
7792
|
+
if (!dirs.some((d) => d.startsWith(".") || SKIP_DIRS.has(d)) && !skipped(p)) sort(p);
|
|
7793
|
+
}
|
|
7794
|
+
} else {
|
|
7795
|
+
const started = Date.now();
|
|
7796
|
+
let entries = 0;
|
|
7797
|
+
const walk = async (dir, depth) => {
|
|
7798
|
+
if (depth > 10) return;
|
|
7799
|
+
if (entries > maxEntries || Date.now() - started > MAX_MS) {
|
|
7800
|
+
incomplete ??= `stopped after ${entries > maxEntries ? `${maxEntries} entries` : `${MAX_MS / 1e3}s`}, before ${shown(dir) || "."}`;
|
|
7801
|
+
return;
|
|
7802
|
+
}
|
|
7803
|
+
let list;
|
|
7804
|
+
try {
|
|
7805
|
+
list = await readdir2(dir, { withFileTypes: true });
|
|
7806
|
+
} catch {
|
|
7807
|
+
return;
|
|
7808
|
+
}
|
|
7809
|
+
entries += list.length;
|
|
7810
|
+
list.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
7811
|
+
for (const e of list) {
|
|
7812
|
+
const p = path4.join(dir, e.name);
|
|
7813
|
+
if (e.isDirectory()) {
|
|
7814
|
+
if (!e.name.startsWith(".") && !SKIP_DIRS.has(e.name) && !skipped(p)) await walk(p, depth + 1);
|
|
7815
|
+
} else if (e.isFile()) sort(p);
|
|
7816
|
+
}
|
|
7817
|
+
};
|
|
7818
|
+
await walk(root, 0);
|
|
7819
|
+
}
|
|
7820
|
+
if (styles.length > MAX_STYLES) incomplete ??= `read only the first ${MAX_STYLES} of ${styles.length} stylesheets`;
|
|
6179
7821
|
const idx = { colors: /* @__PURE__ */ new Map(), fonts: /* @__PURE__ */ new Map(), icons: /* @__PURE__ */ new Map(), components: /* @__PURE__ */ new Map(), textStyles: [] };
|
|
6180
7822
|
const rules = [];
|
|
6181
|
-
const shown = (p) => path3.relative(process.cwd(), p).split(path3.sep).join("/");
|
|
6182
7823
|
const add = (m, key, ref2) => {
|
|
6183
7824
|
const list = m.get(key) ?? [];
|
|
6184
7825
|
if (!list.includes(ref2)) list.push(ref2);
|
|
@@ -6186,17 +7827,25 @@ async function scanProject(root, exclude = []) {
|
|
|
6186
7827
|
};
|
|
6187
7828
|
const vars = /* @__PURE__ */ new Map();
|
|
6188
7829
|
const classes = /* @__PURE__ */ new Map();
|
|
6189
|
-
|
|
7830
|
+
let tailwind = false;
|
|
7831
|
+
const theme = /* @__PURE__ */ new Set();
|
|
7832
|
+
const resets = [];
|
|
7833
|
+
for (const f of styles.slice(0, MAX_STYLES)) {
|
|
6190
7834
|
const css = await readText(f, 1e6);
|
|
6191
7835
|
if (!css) continue;
|
|
6192
7836
|
const text2 = css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
|
|
7837
|
+
if (/@import\s+(?:url\(\s*)?["']tailwindcss(?:\/[\w-]+\.css)?["']|@theme\b/.test(text2)) tailwind = true;
|
|
7838
|
+
for (const block of themeBlocks(text2)) {
|
|
7839
|
+
for (const m of block.matchAll(/(?<=(?:^|[{;])\s*)(--[\w-]+)\s*:/g)) theme.add(m[1]);
|
|
7840
|
+
for (const m of block.matchAll(/(--[\w-]*)\*\s*:\s*initial/g)) resets.push(m[1]);
|
|
7841
|
+
}
|
|
6193
7842
|
const define = (re) => {
|
|
6194
7843
|
for (const m of text2.matchAll(re)) if (!vars.has(m[1])) vars.set(m[1], m[2].trim());
|
|
6195
7844
|
};
|
|
6196
7845
|
define(/(?<=(?:^|[{;])\s*)(--[\w-]+)\s*:\s*([^;{}]+)/g);
|
|
6197
7846
|
if (/\.(scss|sass)$/i.test(f)) define(/^\s*(\$[\w-]+)\s*:\s*([^;\n]+)/gm);
|
|
6198
7847
|
if (/\.less$/i.test(f)) define(/^\s*(@[\w-]+)\s*:\s*([^;\n]+)/gm);
|
|
6199
|
-
const stem = slug2(
|
|
7848
|
+
const stem = slug2(path4.basename(f).replace(/\.[^.]+$/, ""));
|
|
6200
7849
|
for (const m of text2.matchAll(/(?<=^|[{};])\s*\.(-?[_a-zA-Z][\w-]*)\s*\{([^{}]*)\}/g)) {
|
|
6201
7850
|
if (!/__|--/.test(m[1])) rules.push({ cls: m[1], decls: m[2], file: shown(f) });
|
|
6202
7851
|
}
|
|
@@ -6207,12 +7856,28 @@ async function scanProject(root, exclude = []) {
|
|
|
6207
7856
|
}
|
|
6208
7857
|
}
|
|
6209
7858
|
}
|
|
7859
|
+
const defaults = /* @__PURE__ */ new Set();
|
|
7860
|
+
if (tailwind) {
|
|
7861
|
+
for (const [k, v] of Object.entries(TAILWIND_THEME)) {
|
|
7862
|
+
if (vars.has(k) || resets.some((r) => k.startsWith(r) && !(r === "--font-" && k.startsWith("--font-weight-")))) continue;
|
|
7863
|
+
vars.set(k, v);
|
|
7864
|
+
theme.add(k);
|
|
7865
|
+
defaults.add(k);
|
|
7866
|
+
}
|
|
7867
|
+
}
|
|
7868
|
+
const utility = (name) => {
|
|
7869
|
+
if (!theme.has(name)) return void 0;
|
|
7870
|
+
const m = /^--(color|font)-([\w-]+)$/.exec(name);
|
|
7871
|
+
if (!m || m[1] === "font" && m[2].startsWith("weight-")) return void 0;
|
|
7872
|
+
return m[1] === "color" ? `*-${m[2]}` : `font-${m[2]}`;
|
|
7873
|
+
};
|
|
6210
7874
|
const ref = (name, wrap) => {
|
|
7875
|
+
const u = utility(name);
|
|
7876
|
+
if (u) return u;
|
|
6211
7877
|
const r = name.startsWith("--") ? `var(${name})` : name;
|
|
6212
7878
|
return wrap ? `${wrap}(${r})` : r;
|
|
6213
7879
|
};
|
|
6214
|
-
const
|
|
6215
|
-
for (const [name, value] of vars) {
|
|
7880
|
+
const resolve = (value) => {
|
|
6216
7881
|
let v = value;
|
|
6217
7882
|
let alias = false;
|
|
6218
7883
|
for (let hops = 0; hops < 5; hops++) {
|
|
@@ -6222,19 +7887,48 @@ async function scanProject(root, exclude = []) {
|
|
|
6222
7887
|
v = next;
|
|
6223
7888
|
alias = true;
|
|
6224
7889
|
}
|
|
6225
|
-
|
|
6226
|
-
}
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
7890
|
+
return { v, alias };
|
|
7891
|
+
};
|
|
7892
|
+
if (twConfigs.length) {
|
|
7893
|
+
const channel = (name) => resolve(vars.get(name) ?? "").v || void 0;
|
|
7894
|
+
const replaced = /* @__PURE__ */ new Set();
|
|
7895
|
+
const own2 = [];
|
|
7896
|
+
for (const f of twConfigs.slice(0, 8)) {
|
|
7897
|
+
const src = await readText(f, 2e5);
|
|
7898
|
+
if (!src) continue;
|
|
7899
|
+
const c = tailwindConfigTheme(src, channel);
|
|
7900
|
+
c.replaced.forEach((p) => replaced.add(p));
|
|
7901
|
+
own2.push(...c.vars);
|
|
7902
|
+
}
|
|
7903
|
+
const add2 = (k, v, isDefault) => {
|
|
7904
|
+
if (vars.has(k)) return;
|
|
7905
|
+
vars.set(k, v);
|
|
7906
|
+
theme.add(k);
|
|
7907
|
+
if (isDefault) defaults.add(k);
|
|
7908
|
+
};
|
|
7909
|
+
for (const [k, v] of own2) add2(k, v, false);
|
|
7910
|
+
if (!tailwind) for (const [k, v] of tailwindV3Defaults(replaced)) add2(k, v, true);
|
|
7911
|
+
tailwind = true;
|
|
7912
|
+
}
|
|
7913
|
+
const ranked = [];
|
|
7914
|
+
for (const [name, value] of vars) {
|
|
7915
|
+
const { v, alias } = resolve(value);
|
|
7916
|
+
const rank2 = defaults.has(name) ? 3 : utility(name) ? 0 : alias ? 1 : 2;
|
|
7917
|
+
ranked.push({ name, v, rank: rank2 });
|
|
7918
|
+
}
|
|
7919
|
+
ranked.sort((a, b) => a.rank - b.rank);
|
|
7920
|
+
for (const { name, v } of ranked) {
|
|
7921
|
+
const c = parseColor(v);
|
|
7922
|
+
if (c) add(idx.colors, c.hex, ref(name, c.wrap));
|
|
7923
|
+
else if (/font|family|typeface/i.test(name) && !/^--(font-weight|text)-/.test(name)) {
|
|
7924
|
+
const fam = firstFamily(v);
|
|
7925
|
+
if (fam && !/^\d|^var\(/.test(fam)) add(idx.fonts, fam, ref(name));
|
|
7926
|
+
}
|
|
7927
|
+
}
|
|
7928
|
+
if (tailwind) idx.tailwind = tailwindTheme(theme, defaults, (name) => {
|
|
7929
|
+
const raw = vars.get(name);
|
|
7930
|
+
return raw === void 0 ? void 0 : resolve(raw).v;
|
|
7931
|
+
});
|
|
6238
7932
|
const family = (v) => {
|
|
6239
7933
|
let x = v?.trim();
|
|
6240
7934
|
for (let hops = 0; x && hops < 5; hops++) {
|
|
@@ -6248,7 +7942,7 @@ async function scanProject(root, exclude = []) {
|
|
|
6248
7942
|
const t = textStyle(r.decls, family);
|
|
6249
7943
|
if (t) idx.textStyles.push({ ...t, ref: `.${r.cls} (${r.file})` });
|
|
6250
7944
|
}
|
|
6251
|
-
for (const f of svgs.slice(0,
|
|
7945
|
+
for (const f of svgs.slice(0, MAX_SVGS)) {
|
|
6252
7946
|
const svg = await readText(f, 64e3);
|
|
6253
7947
|
const s = svg && shapeOf(svg);
|
|
6254
7948
|
if (!s) continue;
|
|
@@ -6256,22 +7950,122 @@ async function scanProject(root, exclude = []) {
|
|
|
6256
7950
|
list.push({ file: shown(f), nums: s.nums });
|
|
6257
7951
|
idx.icons.set(s.key, list);
|
|
6258
7952
|
}
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
|
|
6262
|
-
if (
|
|
6263
|
-
|
|
7953
|
+
const ownIcons = [];
|
|
7954
|
+
for (const [k, f] of comps.entries()) {
|
|
7955
|
+
let stem = path4.basename(f).replace(/\.[^.]+$/, "");
|
|
7956
|
+
if (/^index$/i.test(stem)) stem = path4.basename(path4.dirname(f));
|
|
7957
|
+
if (/\.(test|spec|stories|story)$/i.test(stem)) continue;
|
|
7958
|
+
const text2 = /\.(tsx|jsx)$/i.test(f) && k < MAX_CODE ? await readText(f, 2e5) : void 0;
|
|
7959
|
+
const found = text2 ? reactComponents(text2) : [];
|
|
7960
|
+
if (text2) ownIcons.push(...codeIcons(text2, shown(f)));
|
|
7961
|
+
for (const c of found) add(idx.components, slug2(c.name), `${c.api} (${shown(f)})`);
|
|
7962
|
+
if (!found.some((c) => slug2(c.name) === slug2(stem)) && !NOT_COMPONENT.test(stem)) add(idx.components, slug2(stem), shown(f));
|
|
7963
|
+
}
|
|
7964
|
+
for (const f of elixir.filter((f2) => !/(^|[/\\])test[/\\]/.test(path4.relative(root, f2))).slice(0, MAX_CODE)) {
|
|
7965
|
+
const text2 = await readText(f, 4e5);
|
|
7966
|
+
if (text2) ownIcons.push(...codeIcons(text2, shown(f), true));
|
|
7967
|
+
if (!text2 || !/^\s*(attr|slot)\s+:/m.test(text2)) continue;
|
|
7968
|
+
for (const c of phoenixComponents(text2)) add(idx.components, slug2(c.name), `${c.api} (${shown(f)})`);
|
|
6264
7969
|
}
|
|
6265
7970
|
for (const [c, f] of classes) add(idx.components, c.toLowerCase(), `.${c} (${f})`);
|
|
6266
|
-
const
|
|
6267
|
-
|
|
7971
|
+
const rank = (ref2) => /components?[/\\]ui[/\\]|core_components|_ui[/\\]|[/\\]components[/\\]/.test(ref2) ? 0 : /mail|email|stories|example/i.test(ref2) ? 2 : 1;
|
|
7972
|
+
for (const list of idx.components.values()) list.sort((a, b) => rank(a) - rank(b));
|
|
7973
|
+
const libs = await iconLibraries(root, manifests, ownIcons).catch(() => []);
|
|
7974
|
+
if (libs.length) idx.iconLibs = libs;
|
|
7975
|
+
if (svgs.length > MAX_SVGS) incomplete ??= `read only the first ${MAX_SVGS} of ${svgs.length} SVG files`;
|
|
7976
|
+
if (incomplete) idx.incomplete = `project scan of ${shown(root) || "."} ${incomplete}`;
|
|
7977
|
+
const empty = !idx.colors.size && !idx.fonts.size && !idx.icons.size && !idx.components.size && !idx.textStyles.length && !idx.tailwind?.text.length && !idx.iconLibs;
|
|
7978
|
+
return empty && !incomplete ? void 0 : idx;
|
|
7979
|
+
}
|
|
7980
|
+
async function gitFiles(root) {
|
|
7981
|
+
try {
|
|
7982
|
+
const { stdout } = await promisify(execFile)("git", ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], {
|
|
7983
|
+
cwd: root,
|
|
7984
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
7985
|
+
timeout: 1e4
|
|
7986
|
+
});
|
|
7987
|
+
return stdout.split("\0").filter(Boolean).map((f) => path4.join(root, f));
|
|
7988
|
+
} catch {
|
|
7989
|
+
return void 0;
|
|
7990
|
+
}
|
|
7991
|
+
}
|
|
7992
|
+
function withScanNote(text2, idx) {
|
|
7993
|
+
if (!idx?.incomplete) return text2;
|
|
7994
|
+
return `${text2}
|
|
7995
|
+
|
|
7996
|
+
## project scan incomplete
|
|
7997
|
+
${idx.incomplete}: a colour, font, icon or component without a project match may still exist, so search the code before adding a copy`;
|
|
7998
|
+
}
|
|
7999
|
+
function themeBlocks(css) {
|
|
8000
|
+
const out = [];
|
|
8001
|
+
for (const m of css.matchAll(/@(?:theme|plugin)\b[^{;]*\{/g)) {
|
|
8002
|
+
let depth = 1;
|
|
8003
|
+
let i = m.index + m[0].length;
|
|
8004
|
+
const start = i;
|
|
8005
|
+
for (; i < css.length && depth; i++) {
|
|
8006
|
+
if (css[i] === "{") depth++;
|
|
8007
|
+
else if (css[i] === "}") depth--;
|
|
8008
|
+
}
|
|
8009
|
+
out.push(css.slice(start, i - 1));
|
|
8010
|
+
}
|
|
8011
|
+
return out;
|
|
8012
|
+
}
|
|
8013
|
+
function lineHeightPx(v, size) {
|
|
8014
|
+
const c = /^calc\(\s*([\d.]+)\s*\/\s*([\d.]+)\s*\)$/.exec(v.trim());
|
|
8015
|
+
return c ? parseFloat(c[1]) / parseFloat(c[2]) * size : px(v, size);
|
|
8016
|
+
}
|
|
8017
|
+
function tailwindTheme(theme, defaults, value) {
|
|
8018
|
+
const out = { text: [], weights: /* @__PURE__ */ new Map(), tracking: /* @__PURE__ */ new Map() };
|
|
8019
|
+
for (const name of theme) {
|
|
8020
|
+
const v = value(name);
|
|
8021
|
+
if (v === void 0) continue;
|
|
8022
|
+
let m;
|
|
8023
|
+
if (m = /^--font-weight-([\w-]+)$/.exec(name)) {
|
|
8024
|
+
const w = parseInt(v, 10);
|
|
8025
|
+
if (w && !out.weights.has(w)) out.weights.set(w, m[1]);
|
|
8026
|
+
} else if (m = /^--tracking-([\w-]+)$/.exec(name)) {
|
|
8027
|
+
const em = /^(-?[\d.]+)em$/.exec(v.trim());
|
|
8028
|
+
if (em && !out.tracking.has(parseFloat(em[1]))) out.tracking.set(parseFloat(em[1]), m[1]);
|
|
8029
|
+
} else if ((m = /^--text-([\w-]+)$/.exec(name)) && !m[1].includes("--")) {
|
|
8030
|
+
const size = /[a-z%]$/i.test(v.trim()) ? px(v, 16) : void 0;
|
|
8031
|
+
if (!size) continue;
|
|
8032
|
+
const lh = value(`${name}--line-height`);
|
|
8033
|
+
const fw = value(`${name}--font-weight`);
|
|
8034
|
+
const ls = value(`${name}--letter-spacing`);
|
|
8035
|
+
out.text.push({
|
|
8036
|
+
cls: `text-${m[1]}`,
|
|
8037
|
+
size,
|
|
8038
|
+
lineHeight: lh === void 0 ? void 0 : lineHeightPx(lh, size),
|
|
8039
|
+
weight: fw === void 0 ? void 0 : parseInt(fw, 10) || void 0,
|
|
8040
|
+
letterSpacing: ls === void 0 ? void 0 : px(ls, size),
|
|
8041
|
+
own: !defaults.has(name)
|
|
8042
|
+
});
|
|
8043
|
+
}
|
|
8044
|
+
}
|
|
8045
|
+
return out;
|
|
8046
|
+
}
|
|
8047
|
+
function tailwindText(tw, t) {
|
|
8048
|
+
const sized = tw.text.filter((x) => Math.abs(x.size - t.size) <= 0.01);
|
|
8049
|
+
const own2 = sized.filter((x) => x.own);
|
|
8050
|
+
return (own2.length ? own2 : sized).map((x) => {
|
|
8051
|
+
const parts = [x.cls];
|
|
8052
|
+
if ((x.weight ?? 400) !== t.weight) parts.push(`font-${tw.weights.get(t.weight) ?? `[${t.weight}]`}`);
|
|
8053
|
+
if (t.italic) parts.push("italic");
|
|
8054
|
+
if (t.lh !== void 0 && (x.lineHeight === void 0 || Math.abs(x.lineHeight - t.lh) > 0.5)) parts.push(`leading-[${num(t.lh)}px]`);
|
|
8055
|
+
if (Math.abs((x.letterSpacing ?? 0) - t.ls) > 0.05) {
|
|
8056
|
+
const named = [...tw.tracking].find(([em]) => Math.abs(em * t.size - t.ls) <= 0.05);
|
|
8057
|
+
parts.push(named ? `tracking-${named[1]}` : `tracking-[${t.lsText ?? `${num(t.ls)}px`}]`);
|
|
8058
|
+
}
|
|
8059
|
+
if (t.transform !== "none") parts.push(t.transform);
|
|
8060
|
+
return parts.join(" ");
|
|
8061
|
+
});
|
|
6268
8062
|
}
|
|
6269
8063
|
function firstFamily(stack) {
|
|
6270
8064
|
return stack.split(",")[0].trim().replace(/^["']|["']$/g, "").toLowerCase();
|
|
6271
8065
|
}
|
|
6272
8066
|
async function readText(file2, max) {
|
|
6273
8067
|
try {
|
|
6274
|
-
const buf = await
|
|
8068
|
+
const buf = await readFile3(file2);
|
|
6275
8069
|
return buf.length > max ? void 0 : buf.toString("utf8");
|
|
6276
8070
|
} catch {
|
|
6277
8071
|
return void 0;
|
|
@@ -6372,7 +8166,8 @@ function textRefs(idx, spec) {
|
|
|
6372
8166
|
const ls = lsm ? lsm[2] === "em" ? parseFloat(lsm[1]) * size : parseFloat(lsm[1]) : 0;
|
|
6373
8167
|
const transform2 = /\b(uppercase|lowercase|capitalize)\b/.exec(g.rest)?.[1] ?? "none";
|
|
6374
8168
|
const fam = g.family.toLowerCase();
|
|
6375
|
-
|
|
8169
|
+
const tw = idx.tailwind ? tailwindText(idx.tailwind, { size, weight: Number(g.weight), italic: !!g.italic, lh, ls, lsText: lsm ? `${lsm[1]}${lsm[2]}` : void 0, transform: transform2 }) : [];
|
|
8170
|
+
const classes = idx.textStyles.filter((t) => {
|
|
6376
8171
|
if (t.size !== size && Math.abs(t.size - size) > 0.01) return false;
|
|
6377
8172
|
if (t.weight !== Number(g.weight) || t.italic !== !!g.italic || t.transform !== transform2) return false;
|
|
6378
8173
|
if (Math.abs(t.letterSpacing - ls) > 0.05) return false;
|
|
@@ -6380,7 +8175,8 @@ function textRefs(idx, spec) {
|
|
|
6380
8175
|
if (t.lineHeight === "normal") return g.lh === "normal";
|
|
6381
8176
|
if (lh === void 0) return true;
|
|
6382
8177
|
return typeof t.lineHeight === "number" && Math.abs(t.lineHeight - lh) <= 0.5;
|
|
6383
|
-
}).map((t) => t.ref)
|
|
8178
|
+
}).map((t) => t.ref);
|
|
8179
|
+
return [...classes, ...tw].slice(0, 3);
|
|
6384
8180
|
}
|
|
6385
8181
|
function normHex(h) {
|
|
6386
8182
|
const m = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(h.trim());
|
|
@@ -6440,28 +8236,28 @@ function parseColor(value) {
|
|
|
6440
8236
|
function shapeOf(svg) {
|
|
6441
8237
|
const rootTag = /<svg\b[^>]*>/i.exec(svg)?.[0];
|
|
6442
8238
|
if (!rootTag) return void 0;
|
|
6443
|
-
const root =
|
|
8239
|
+
const root = attrs2(rootTag);
|
|
6444
8240
|
const vb = (root.viewBox ?? `0 0 ${parseFloat(root.width ?? "")} ${parseFloat(root.height ?? "")}`).split(/[\s,]+/).map(Number);
|
|
6445
8241
|
const [vx, vy, vw, vh] = vb;
|
|
6446
8242
|
if (vb.length !== 4 || !(vw > 0) || !(vh > 0)) return void 0;
|
|
6447
8243
|
const body = svg.replace(/<(mask|clipPath|defs|title|desc)\b[\s\S]*?<\/\1>/gi, "");
|
|
6448
8244
|
const scaled = { x: (v) => (v - vx) / vw, y: (v) => (v - vy) / vh, s: (v) => v / vw, r: (v) => v };
|
|
6449
|
-
const
|
|
8245
|
+
const keys2 = [];
|
|
6450
8246
|
const nums = [];
|
|
6451
8247
|
for (const m of body.matchAll(/<(path|rect|circle|ellipse|line|polyline|polygon)\b([^>]*)>/gi)) {
|
|
6452
|
-
const a =
|
|
8248
|
+
const a = attrs2(m[2]);
|
|
6453
8249
|
const fill = a.fill ?? root.fill ?? "black";
|
|
6454
8250
|
const stroke = a.stroke ?? root.stroke ?? "none";
|
|
6455
8251
|
if ((fill === "none" || fill === "transparent") && (stroke === "none" || stroke === "transparent")) continue;
|
|
6456
8252
|
if (a.opacity === "0" || a.visibility === "hidden" || a.display === "none") continue;
|
|
6457
8253
|
const g = geometry(m[1].toLowerCase(), a);
|
|
6458
8254
|
if (!g) return void 0;
|
|
6459
|
-
|
|
8255
|
+
keys2.push(g.key);
|
|
6460
8256
|
for (const [v, axis] of g.vals) nums.push(scaled[axis](v));
|
|
6461
8257
|
}
|
|
6462
|
-
return
|
|
8258
|
+
return keys2.length ? { key: keys2.join("|"), nums } : void 0;
|
|
6463
8259
|
}
|
|
6464
|
-
function
|
|
8260
|
+
function attrs2(tag) {
|
|
6465
8261
|
const out = {};
|
|
6466
8262
|
for (const m of tag.matchAll(/([\w:-]+)\s*=\s*("([^"]*)"|'([^']*)')/g)) out[m[1]] = m[3] ?? m[4] ?? "";
|
|
6467
8263
|
for (const d of (out.style ?? "").split(";")) {
|
|
@@ -6525,7 +8321,7 @@ function absolutePath(d) {
|
|
|
6525
8321
|
continue;
|
|
6526
8322
|
}
|
|
6527
8323
|
const n2 = [];
|
|
6528
|
-
for (let k = 0; k <
|
|
8324
|
+
for (let k = 0; k < ARGS2[up]; k++) {
|
|
6529
8325
|
const s = up === "A" && (k === 3 || k === 4) ? read(FLAG) : read(NUM);
|
|
6530
8326
|
if (s === void 0) return k === 0 && !c && atEnd() ? { key, vals } : void 0;
|
|
6531
8327
|
n2.push(Number(s));
|
|
@@ -6558,10 +8354,14 @@ function absolutePath(d) {
|
|
|
6558
8354
|
}
|
|
6559
8355
|
return { key, vals };
|
|
6560
8356
|
}
|
|
6561
|
-
var TEXT_PROPS, SKIP_DIRS, STYLE, COMPONENT_FILE, NOT_COMPONENT, MAX_ENTRIES, MAX_MS, WEIGHTS, hex22, pct,
|
|
8357
|
+
var TEXT_PROPS, SKIP_DIRS, STYLE, COMPONENT_FILE, NOT_COMPONENT, MAX_ENTRIES, MAX_MS, MAX_STYLES, MAX_SVGS, MAX_CODE, num, WEIGHTS, hex22, pct, ARGS2;
|
|
6562
8358
|
var init_project = __esm({
|
|
6563
8359
|
"src/tools/project.ts"() {
|
|
6564
8360
|
"use strict";
|
|
8361
|
+
init_code_components();
|
|
8362
|
+
init_icons();
|
|
8363
|
+
init_tailwind_config();
|
|
8364
|
+
init_tailwind_theme();
|
|
6565
8365
|
TEXT_PROPS = /^(font(-[\w-]+)?|line-height|letter-spacing|text-transform|text-decoration[\w-]*|color|-webkit-font-smoothing|-moz-osx-font-smoothing|text-rendering)$/;
|
|
6566
8366
|
SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
6567
8367
|
"node_modules",
|
|
@@ -6578,17 +8378,23 @@ var init_project = __esm({
|
|
|
6578
8378
|
"Pods",
|
|
6579
8379
|
"DerivedData",
|
|
6580
8380
|
"tmp",
|
|
6581
|
-
"temp"
|
|
8381
|
+
"temp",
|
|
8382
|
+
"_build",
|
|
8383
|
+
"deps"
|
|
6582
8384
|
]);
|
|
6583
8385
|
STYLE = /\.(css|scss|sass|less|styl|pcss)$/i;
|
|
6584
8386
|
COMPONENT_FILE = /\.(tsx|jsx|vue|svelte|astro)$/i;
|
|
6585
8387
|
NOT_COMPONENT = /^(index|page|layout|main|app|route|\+page|\+layout)$|\.(test|spec|stories|story)$/i;
|
|
6586
8388
|
MAX_ENTRIES = 3e4;
|
|
6587
8389
|
MAX_MS = 2e3;
|
|
8390
|
+
MAX_STYLES = 600;
|
|
8391
|
+
MAX_SVGS = 3e3;
|
|
8392
|
+
MAX_CODE = 4e3;
|
|
8393
|
+
num = (x) => String(+x.toFixed(2));
|
|
6588
8394
|
WEIGHTS = { normal: 400, bold: 700, lighter: 300, bolder: 700 };
|
|
6589
8395
|
hex22 = (v) => Math.round(Math.max(0, Math.min(255, v))).toString(16).padStart(2, "0");
|
|
6590
8396
|
pct = (s, full) => s.endsWith("%") ? parseFloat(s) / 100 * full : parseFloat(s);
|
|
6591
|
-
|
|
8397
|
+
ARGS2 = { M: 2, L: 2, H: 1, V: 1, C: 6, S: 4, Q: 4, T: 2, A: 7, Z: 0 };
|
|
6592
8398
|
}
|
|
6593
8399
|
});
|
|
6594
8400
|
|
|
@@ -9023,8 +10829,8 @@ var init_png = __esm({
|
|
|
9023
10829
|
});
|
|
9024
10830
|
|
|
9025
10831
|
// src/tools/media.ts
|
|
9026
|
-
import { mkdir as mkdir2, readFile as
|
|
9027
|
-
import
|
|
10832
|
+
import { mkdir as mkdir2, readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
|
|
10833
|
+
import path5 from "node:path";
|
|
9028
10834
|
function rasterWaitMs(frozen) {
|
|
9029
10835
|
return Number(process.env.LUPA_RASTER_WAIT_MS) || (frozen ? 2500 : 1e4);
|
|
9030
10836
|
}
|
|
@@ -9069,9 +10875,9 @@ async function screenshot(bridge, ids, file2, opts) {
|
|
|
9069
10875
|
const raster = decodePng(buf);
|
|
9070
10876
|
if (opts.saveTo) {
|
|
9071
10877
|
const target = ids.length > 1 || head.roots.length > 1 ? withSuffix(opts.saveTo, slug(root.name) || root.id) : opts.saveTo;
|
|
9072
|
-
await mkdir2(
|
|
10878
|
+
await mkdir2(path5.dirname(path5.resolve(target)), { recursive: true });
|
|
9073
10879
|
await writeFile2(target, buf);
|
|
9074
|
-
lines.push(`saved ${
|
|
10880
|
+
lines.push(`saved ${path5.resolve(target)} (${raster.width}\xD7${raster.height}px)`);
|
|
9075
10881
|
}
|
|
9076
10882
|
const parts = tiles(raster);
|
|
9077
10883
|
const visionScale = scale * parts[0].scale;
|
|
@@ -9085,8 +10891,8 @@ async function screenshot(bridge, ids, file2, opts) {
|
|
|
9085
10891
|
return { text: lines.join("\n"), images };
|
|
9086
10892
|
}
|
|
9087
10893
|
function withSuffix(file2, suffix) {
|
|
9088
|
-
const ext =
|
|
9089
|
-
return `${file2.slice(0, file2.length -
|
|
10894
|
+
const ext = path5.extname(file2) || ".png";
|
|
10895
|
+
return `${file2.slice(0, file2.length - path5.extname(file2).length)}-${suffix}${ext}`;
|
|
9090
10896
|
}
|
|
9091
10897
|
function collect(snap, defs = []) {
|
|
9092
10898
|
const graphics = [];
|
|
@@ -9156,7 +10962,7 @@ function fileNamer() {
|
|
|
9156
10962
|
}
|
|
9157
10963
|
async function exportAssets(bridge, ids, file2, opts) {
|
|
9158
10964
|
if (opts.as !== "auto") {
|
|
9159
|
-
const dir =
|
|
10965
|
+
const dir = path5.resolve(opts.dir);
|
|
9160
10966
|
await mkdir2(dir, { recursive: true });
|
|
9161
10967
|
const fileName = fileNamer();
|
|
9162
10968
|
const lines = [];
|
|
@@ -9165,7 +10971,7 @@ async function exportAssets(bridge, ids, file2, opts) {
|
|
|
9165
10971
|
for (const b of res2.blobs) {
|
|
9166
10972
|
const name = fileName(b.name, opts.as);
|
|
9167
10973
|
const data = b.encoding === "utf8" ? opts.currentColor ? toCurrentColor(b.data) : b.data : Buffer.from(b.data, "base64");
|
|
9168
|
-
await writeFile2(
|
|
10974
|
+
await writeFile2(path5.join(dir, name), data);
|
|
9169
10975
|
lines.push(`${name} \u2190 "${b.name}" #${b.id} ${n(b.w)}\xD7${n(b.h)}${opts.as === "png" ? ` @${opts.scale ?? 2}x` : ""}`);
|
|
9170
10976
|
}
|
|
9171
10977
|
for (const e of res2.errors) lines.push(`failed #${e.id}: ${e.error}`);
|
|
@@ -9179,10 +10985,10 @@ async function exportAssets(bridge, ids, file2, opts) {
|
|
|
9179
10985
|
return res.report;
|
|
9180
10986
|
}
|
|
9181
10987
|
async function writeAssets(bridge, snap, file2, opts) {
|
|
9182
|
-
const dir =
|
|
10988
|
+
const dir = path5.resolve(opts.dir);
|
|
9183
10989
|
await mkdir2(dir, { recursive: true });
|
|
9184
10990
|
const fileName = fileNamer();
|
|
9185
|
-
const rel = (name) =>
|
|
10991
|
+
const rel = (name) => path5.join(opts.dir, name).split(path5.sep).join("/");
|
|
9186
10992
|
const lines = [];
|
|
9187
10993
|
const failures = [];
|
|
9188
10994
|
const fail2 = (line) => {
|
|
@@ -9218,13 +11024,14 @@ async function writeAssets(bridge, snap, file2, opts) {
|
|
|
9218
11024
|
continue;
|
|
9219
11025
|
}
|
|
9220
11026
|
const own3 = opts.project && iconFile(opts.project, svg);
|
|
9221
|
-
const
|
|
9222
|
-
|
|
9223
|
-
|
|
11027
|
+
const lib = !own3 && opts.project?.iconLibs ? (await matchLibraryIcon(opts.project.iconLibs, svg, g.name))?.usage : void 0;
|
|
11028
|
+
const name = own3 || lib || fileName(g.base, "svg");
|
|
11029
|
+
if (own3 || lib) reused.add(name);
|
|
11030
|
+
else await writeFile2(path5.join(dir, name), svg);
|
|
9224
11031
|
written.set(key, { name, line: lines.length, uses: 1, component: g.component, also: [] });
|
|
9225
|
-
byNode.set(g.nodeId, own3 || rel(name));
|
|
11032
|
+
byNode.set(g.nodeId, own3 || lib || rel(name));
|
|
9226
11033
|
if (g.sig) bySig.set(g.sig, name);
|
|
9227
|
-
lines.push(`${name} \u2190 svg "${g.name}" #${g.nodeId} ${n(b.w)}\xD7${n(b.h)}${own3 ? " (the project's own icon: not written)" : ""}`);
|
|
11034
|
+
lines.push(`${name} \u2190 svg "${g.name}" #${g.nodeId} ${n(b.w)}\xD7${n(b.h)}${own3 ? " (the project's own icon: not written)" : lib ? " (from the project's icon library: not written)" : ""}`);
|
|
9228
11035
|
}
|
|
9229
11036
|
}
|
|
9230
11037
|
for (const { g, error: error62 } of failed) {
|
|
@@ -9255,7 +11062,7 @@ async function writeAssets(bridge, snap, file2, opts) {
|
|
|
9255
11062
|
}
|
|
9256
11063
|
const buf = Buffer.from(got.data, "base64");
|
|
9257
11064
|
const name = fileName(img.base, imageExt(buf));
|
|
9258
|
-
await writeFile2(
|
|
11065
|
+
await writeFile2(path5.join(dir, name), buf);
|
|
9259
11066
|
byImage.set(img.hash, rel(name));
|
|
9260
11067
|
lines.push(`${name} \u2190 src:${img.hash.slice(0, 10)} "${img.name}" #${img.nodeId}${got.w ? ` ${got.w}\xD7${got.h}px original` : ""}${img.uses > 1 ? ` (used ${img.uses}\xD7)` : ""}`);
|
|
9261
11068
|
}
|
|
@@ -9323,8 +11130,8 @@ function ignoreEdges(a, b, band) {
|
|
|
9323
11130
|
}
|
|
9324
11131
|
}
|
|
9325
11132
|
}
|
|
9326
|
-
async function
|
|
9327
|
-
const actualBuf = typeof opts.image === "string" ? await
|
|
11133
|
+
async function compare2(bridge, root, file2, opts) {
|
|
11134
|
+
const actualBuf = typeof opts.image === "string" ? await readFile4(opts.image) : opts.image;
|
|
9328
11135
|
const actual = flatten(decodePng(actualBuf));
|
|
9329
11136
|
const scale = actual.width / root.w;
|
|
9330
11137
|
const res = await renderNode(bridge, root, file2, { scale, width: actual.width }, {});
|
|
@@ -9366,9 +11173,9 @@ async function compare(bridge, root, file2, opts) {
|
|
|
9366
11173
|
if (d.regions.length > 10) lines.push(` \u2026 +${d.regions.length - 10} smaller regions`);
|
|
9367
11174
|
let strip = sideBySide([a, b, d.diff]);
|
|
9368
11175
|
if (opts.saveDiff) {
|
|
9369
|
-
await mkdir2(
|
|
11176
|
+
await mkdir2(path5.dirname(path5.resolve(opts.saveDiff)), { recursive: true });
|
|
9370
11177
|
await writeFile2(opts.saveDiff, encodePng(strip));
|
|
9371
|
-
lines.push(`saved ${
|
|
11178
|
+
lines.push(`saved ${path5.resolve(opts.saveDiff)}`);
|
|
9372
11179
|
}
|
|
9373
11180
|
if (strip.width > VISION_MAX_EDGE || strip.height > VISION_MAX_EDGE) {
|
|
9374
11181
|
const s = Math.min(VISION_MAX_EDGE / strip.width, VISION_MAX_EDGE / strip.height);
|
|
@@ -9385,6 +11192,7 @@ var init_media = __esm({
|
|
|
9385
11192
|
init_build();
|
|
9386
11193
|
init_css();
|
|
9387
11194
|
init_browser();
|
|
11195
|
+
init_icons();
|
|
9388
11196
|
init_project();
|
|
9389
11197
|
init_png();
|
|
9390
11198
|
SVG_FALLBACK_NOTE = "Figma didn't render a PNG (its window is hidden or covered), so this image is Figma's SVG export rendered in Chromium. SVG export can leave out background blur, newer effects and occasionally a stroke: check a region against `lupa design` before changing it. Bring Figma to the front for an exact render.";
|
|
@@ -9510,14 +11318,14 @@ var init_ops = __esm({
|
|
|
9510
11318
|
if (!snap.roots.length) throw new Error(`Nothing found for ${r.ids.join(", ")}${snap.missing.length ? " (not in this file, or deleted)" : ""}`);
|
|
9511
11319
|
const index = await scan;
|
|
9512
11320
|
const opts = { budget: o.budget ?? 8e3, components: o.components ?? "auto", project: index && projectHints(index) };
|
|
9513
|
-
if (!o.assetsDir) return renderSnapshot(snap, opts).text;
|
|
11321
|
+
if (!o.assetsDir) return withScanNote(renderSnapshot(snap, opts).text, index);
|
|
9514
11322
|
const defs = printedDefs(snap, opts.components);
|
|
9515
11323
|
const written = await writeAssets(this.bridge, snap, r.file, { dir: o.assetsDir, currentColor: o.currentColor, defs, project: index });
|
|
9516
11324
|
const text2 = renderSnapshot(snap, { ...opts, files: { ...written, dir: o.assetsDir } }).text;
|
|
9517
|
-
return written.failures.length ? `${text2}
|
|
11325
|
+
return withScanNote(written.failures.length ? `${text2}
|
|
9518
11326
|
|
|
9519
11327
|
## asset export failures
|
|
9520
|
-
${written.failures.join("\n")}` : text2;
|
|
11328
|
+
${written.failures.join("\n")}` : text2, index);
|
|
9521
11329
|
}
|
|
9522
11330
|
async screenshot(o) {
|
|
9523
11331
|
const r = await this.resolve(o.target, o.file);
|
|
@@ -9527,7 +11335,8 @@ ${written.failures.join("\n")}` : text2;
|
|
|
9527
11335
|
const r = await this.resolve(o.target, o.file);
|
|
9528
11336
|
const dir = o.dir ?? "figma-assets";
|
|
9529
11337
|
const project = o.as === "auto" || !o.as ? await scanProject(process.cwd(), [dir]).catch(() => void 0) : void 0;
|
|
9530
|
-
|
|
11338
|
+
const text2 = await exportAssets(this.bridge, r.ids, r.file, { dir, as: o.as ?? "auto", scale: o.scale, currentColor: o.currentColor, project });
|
|
11339
|
+
return withScanNote(text2, project);
|
|
9531
11340
|
}
|
|
9532
11341
|
async tokens(o) {
|
|
9533
11342
|
await this.connect();
|
|
@@ -9556,7 +11365,7 @@ ${Object.entries(x.css).map(([k, v]) => `${k}: ${v};`).join("\n")}`).join("\n\n"
|
|
|
9556
11365
|
note = `fonts not available to the page: ${page.missingFonts.map((f) => `"${f}"`).join(", ")}. The browser uses fallbacks, so text and the hug boxes around it differ in width. Load the fonts (@font-face or local install) for an exact comparison.`;
|
|
9557
11366
|
}
|
|
9558
11367
|
}
|
|
9559
|
-
return
|
|
11368
|
+
return compare2(this.bridge, root, r.file, { image, threshold: o.threshold, saveDiff: o.saveDiff, note });
|
|
9560
11369
|
}
|
|
9561
11370
|
};
|
|
9562
11371
|
}
|
|
@@ -9597,13 +11406,13 @@ var init_util = __esm({
|
|
|
9597
11406
|
});
|
|
9598
11407
|
};
|
|
9599
11408
|
util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object3) => {
|
|
9600
|
-
const
|
|
11409
|
+
const keys2 = [];
|
|
9601
11410
|
for (const key in object3) {
|
|
9602
11411
|
if (Object.prototype.hasOwnProperty.call(object3, key)) {
|
|
9603
|
-
|
|
11412
|
+
keys2.push(key);
|
|
9604
11413
|
}
|
|
9605
11414
|
}
|
|
9606
|
-
return
|
|
11415
|
+
return keys2;
|
|
9607
11416
|
};
|
|
9608
11417
|
util2.find = (arr, checker) => {
|
|
9609
11418
|
for (const item of arr) {
|
|
@@ -9982,8 +11791,8 @@ var init_parseUtil = __esm({
|
|
|
9982
11791
|
init_errors();
|
|
9983
11792
|
init_en();
|
|
9984
11793
|
makeIssue = (params) => {
|
|
9985
|
-
const { data, path:
|
|
9986
|
-
const fullPath = [...
|
|
11794
|
+
const { data, path: path7, errorMaps, issueData } = params;
|
|
11795
|
+
const fullPath = [...path7, ...issueData.path || []];
|
|
9987
11796
|
const fullIssue = {
|
|
9988
11797
|
...issueData,
|
|
9989
11798
|
path: fullPath
|
|
@@ -10251,9 +12060,9 @@ function mergeValues(a, b) {
|
|
|
10251
12060
|
return { valid: false };
|
|
10252
12061
|
}
|
|
10253
12062
|
}
|
|
10254
|
-
function createZodEnum(
|
|
12063
|
+
function createZodEnum(values2, params) {
|
|
10255
12064
|
return new ZodEnum({
|
|
10256
|
-
values,
|
|
12065
|
+
values: values2,
|
|
10257
12066
|
typeName: ZodFirstPartyTypeKind.ZodEnum,
|
|
10258
12067
|
...processCreateParams(params)
|
|
10259
12068
|
});
|
|
@@ -10267,11 +12076,11 @@ var init_types = __esm({
|
|
|
10267
12076
|
init_parseUtil();
|
|
10268
12077
|
init_util();
|
|
10269
12078
|
ParseInputLazyPath = class {
|
|
10270
|
-
constructor(parent, value,
|
|
12079
|
+
constructor(parent, value, path7, key) {
|
|
10271
12080
|
this._cachedPath = [];
|
|
10272
12081
|
this.parent = parent;
|
|
10273
12082
|
this.data = value;
|
|
10274
|
-
this._path =
|
|
12083
|
+
this._path = path7;
|
|
10275
12084
|
this._key = key;
|
|
10276
12085
|
}
|
|
10277
12086
|
get path() {
|
|
@@ -11931,8 +13740,8 @@ var init_types = __esm({
|
|
|
11931
13740
|
if (this._cached !== null)
|
|
11932
13741
|
return this._cached;
|
|
11933
13742
|
const shape = this._def.shape();
|
|
11934
|
-
const
|
|
11935
|
-
this._cached = { shape, keys };
|
|
13743
|
+
const keys2 = util.objectKeys(shape);
|
|
13744
|
+
this._cached = { shape, keys: keys2 };
|
|
11936
13745
|
return this._cached;
|
|
11937
13746
|
}
|
|
11938
13747
|
_parse(input2) {
|
|
@@ -12977,14 +14786,14 @@ var init_types = __esm({
|
|
|
12977
14786
|
}
|
|
12978
14787
|
return enumValues;
|
|
12979
14788
|
}
|
|
12980
|
-
extract(
|
|
12981
|
-
return _ZodEnum.create(
|
|
14789
|
+
extract(values2, newDef = this._def) {
|
|
14790
|
+
return _ZodEnum.create(values2, {
|
|
12982
14791
|
...this._def,
|
|
12983
14792
|
...newDef
|
|
12984
14793
|
});
|
|
12985
14794
|
}
|
|
12986
|
-
exclude(
|
|
12987
|
-
return _ZodEnum.create(this.options.filter((opt) => !
|
|
14795
|
+
exclude(values2, newDef = this._def) {
|
|
14796
|
+
return _ZodEnum.create(this.options.filter((opt) => !values2.includes(opt)), {
|
|
12988
14797
|
...this._def,
|
|
12989
14798
|
...newDef
|
|
12990
14799
|
});
|
|
@@ -13022,9 +14831,9 @@ var init_types = __esm({
|
|
|
13022
14831
|
return this._def.values;
|
|
13023
14832
|
}
|
|
13024
14833
|
};
|
|
13025
|
-
ZodNativeEnum.create = (
|
|
14834
|
+
ZodNativeEnum.create = (values2, params) => {
|
|
13026
14835
|
return new ZodNativeEnum({
|
|
13027
|
-
values,
|
|
14836
|
+
values: values2,
|
|
13028
14837
|
typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
|
|
13029
14838
|
...processCreateParams(params)
|
|
13030
14839
|
});
|
|
@@ -13622,8 +15431,8 @@ function assert(_) {
|
|
|
13622
15431
|
}
|
|
13623
15432
|
function getEnumValues(entries) {
|
|
13624
15433
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
13625
|
-
const
|
|
13626
|
-
return
|
|
15434
|
+
const values2 = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
15435
|
+
return values2;
|
|
13627
15436
|
}
|
|
13628
15437
|
function joinValues(array2, separator = "|") {
|
|
13629
15438
|
return array2.map((val) => stringifyPrimitive(val)).join(separator);
|
|
@@ -13709,9 +15518,9 @@ function putProp(target, key, value) {
|
|
|
13709
15518
|
else
|
|
13710
15519
|
target[key] = value;
|
|
13711
15520
|
}
|
|
13712
|
-
function mirrorShape(target, source,
|
|
15521
|
+
function mirrorShape(target, source, keys2, wrap) {
|
|
13713
15522
|
const raw = sourceShape(source);
|
|
13714
|
-
for (const key of
|
|
15523
|
+
for (const key of keys2) {
|
|
13715
15524
|
const desc = Object.getOwnPropertyDescriptor(raw, key);
|
|
13716
15525
|
if (!desc.enumerable)
|
|
13717
15526
|
continue;
|
|
@@ -13746,18 +15555,18 @@ function mergeDefs(...defs) {
|
|
|
13746
15555
|
function cloneDef(schema) {
|
|
13747
15556
|
return mergeDefs(schema._zod.def);
|
|
13748
15557
|
}
|
|
13749
|
-
function getElementAtPath(obj,
|
|
13750
|
-
if (!
|
|
15558
|
+
function getElementAtPath(obj, path7) {
|
|
15559
|
+
if (!path7)
|
|
13751
15560
|
return obj;
|
|
13752
|
-
return
|
|
15561
|
+
return path7.reduce((acc, key) => acc?.[key], obj);
|
|
13753
15562
|
}
|
|
13754
15563
|
function promiseAllObject(promisesObj) {
|
|
13755
|
-
const
|
|
13756
|
-
const promises =
|
|
15564
|
+
const keys2 = Object.keys(promisesObj);
|
|
15565
|
+
const promises = keys2.map((key) => promisesObj[key]);
|
|
13757
15566
|
return Promise.all(promises).then((results) => {
|
|
13758
15567
|
const resolvedObj = {};
|
|
13759
|
-
for (let i = 0; i <
|
|
13760
|
-
resolvedObj[
|
|
15568
|
+
for (let i = 0; i < keys2.length; i++) {
|
|
15569
|
+
resolvedObj[keys2[i]] = results[i];
|
|
13761
15570
|
}
|
|
13762
15571
|
return resolvedObj;
|
|
13763
15572
|
});
|
|
@@ -13898,15 +15707,15 @@ function pick(schema, mask) {
|
|
|
13898
15707
|
}
|
|
13899
15708
|
function maskedKeys(schema, mask) {
|
|
13900
15709
|
const raw = sourceShape(schema);
|
|
13901
|
-
const
|
|
15710
|
+
const keys2 = [];
|
|
13902
15711
|
for (const key of Reflect.ownKeys(mask)) {
|
|
13903
15712
|
if (!Object.getOwnPropertyDescriptor(raw, key)?.enumerable) {
|
|
13904
15713
|
throw new Error(`Unrecognized key: "${String(key)}"`);
|
|
13905
15714
|
}
|
|
13906
15715
|
if (mask[key])
|
|
13907
|
-
|
|
15716
|
+
keys2.push(key);
|
|
13908
15717
|
}
|
|
13909
|
-
return
|
|
15718
|
+
return keys2;
|
|
13910
15719
|
}
|
|
13911
15720
|
function omit(schema, mask) {
|
|
13912
15721
|
const currDef = schema._zod.def;
|
|
@@ -14008,11 +15817,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
14008
15817
|
}
|
|
14009
15818
|
return false;
|
|
14010
15819
|
}
|
|
14011
|
-
function prefixIssues(
|
|
15820
|
+
function prefixIssues(path7, issues) {
|
|
14012
15821
|
return issues.map((iss) => {
|
|
14013
15822
|
var _a3;
|
|
14014
15823
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
14015
|
-
iss.path.unshift(
|
|
15824
|
+
iss.path.unshift(path7);
|
|
14016
15825
|
return iss;
|
|
14017
15826
|
});
|
|
14018
15827
|
}
|
|
@@ -14545,16 +16354,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
|
|
|
14545
16354
|
}
|
|
14546
16355
|
function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
14547
16356
|
const fieldErrors = { _errors: [] };
|
|
14548
|
-
const processError = (error63,
|
|
16357
|
+
const processError = (error63, path7 = []) => {
|
|
14549
16358
|
for (const issue2 of error63.issues) {
|
|
14550
16359
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
14551
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
16360
|
+
issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
|
|
14552
16361
|
} else if (issue2.code === "invalid_key") {
|
|
14553
|
-
processError({ issues: issue2.issues }, [...
|
|
16362
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
14554
16363
|
} else if (issue2.code === "invalid_element") {
|
|
14555
|
-
processError({ issues: issue2.issues }, [...
|
|
16364
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
14556
16365
|
} else {
|
|
14557
|
-
const fullpath = [...
|
|
16366
|
+
const fullpath = [...path7, ...issue2.path];
|
|
14558
16367
|
if (fullpath.length === 0) {
|
|
14559
16368
|
fieldErrors._errors.push(mapper(issue2));
|
|
14560
16369
|
} else {
|
|
@@ -14593,17 +16402,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
|
14593
16402
|
}
|
|
14594
16403
|
function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
14595
16404
|
const result = { errors: [] };
|
|
14596
|
-
const processError = (error63,
|
|
16405
|
+
const processError = (error63, path7 = []) => {
|
|
14597
16406
|
var _a3;
|
|
14598
16407
|
for (const issue2 of error63.issues) {
|
|
14599
16408
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
14600
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
16409
|
+
issue2.errors.map((issues) => processError({ issues }, [...path7, ...issue2.path]));
|
|
14601
16410
|
} else if (issue2.code === "invalid_key") {
|
|
14602
|
-
processError({ issues: issue2.issues }, [...
|
|
16411
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
14603
16412
|
} else if (issue2.code === "invalid_element") {
|
|
14604
|
-
processError({ issues: issue2.issues }, [...
|
|
16413
|
+
processError({ issues: issue2.issues }, [...path7, ...issue2.path]);
|
|
14605
16414
|
} else {
|
|
14606
|
-
const fullpath = [...
|
|
16415
|
+
const fullpath = [...path7, ...issue2.path];
|
|
14607
16416
|
if (fullpath.length === 0) {
|
|
14608
16417
|
result.errors.push(mapper(issue2));
|
|
14609
16418
|
continue;
|
|
@@ -14642,8 +16451,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
|
14642
16451
|
}
|
|
14643
16452
|
function toDotPath(_path) {
|
|
14644
16453
|
const segs = [];
|
|
14645
|
-
const
|
|
14646
|
-
for (const seg of
|
|
16454
|
+
const path7 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
16455
|
+
for (const seg of path7) {
|
|
14647
16456
|
if (typeof seg === "number")
|
|
14648
16457
|
segs.push(`[${seg}]`);
|
|
14649
16458
|
else if (typeof seg === "symbol")
|
|
@@ -15816,10 +17625,10 @@ function handlePropertyResult(result, final, key, input2, optin, optout) {
|
|
|
15816
17625
|
}
|
|
15817
17626
|
}
|
|
15818
17627
|
function normalizeDef(def) {
|
|
15819
|
-
const
|
|
17628
|
+
const keys2 = Object.keys(def.shape);
|
|
15820
17629
|
const ownSymbols = Object.getOwnPropertySymbols(def.shape);
|
|
15821
17630
|
const symbolKeys = ownSymbols.length ? ownSymbols : NO_SYMBOL_KEYS;
|
|
15822
|
-
const allKeys = symbolKeys.length ? [...
|
|
17631
|
+
const allKeys = symbolKeys.length ? [...keys2, ...symbolKeys] : keys2;
|
|
15823
17632
|
for (const k of allKeys) {
|
|
15824
17633
|
if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
|
|
15825
17634
|
throw new Error(`Invalid element at key "${String(k)}": expected a Zod schema`);
|
|
@@ -15831,8 +17640,8 @@ function normalizeDef(def) {
|
|
|
15831
17640
|
allKeys,
|
|
15832
17641
|
symbolKeys,
|
|
15833
17642
|
// string-only: handleCatchall matches it against `for...in`, which never yields a symbol
|
|
15834
|
-
keySet: new Set(
|
|
15835
|
-
numKeys:
|
|
17643
|
+
keySet: new Set(keys2),
|
|
17644
|
+
numKeys: keys2.length,
|
|
15836
17645
|
optionalKeys: new Set(okeys)
|
|
15837
17646
|
};
|
|
15838
17647
|
}
|
|
@@ -15948,10 +17757,10 @@ function getDiscriminatedOption(union2, value) {
|
|
|
15948
17757
|
function discriminatorMap(def) {
|
|
15949
17758
|
const map2 = /* @__PURE__ */ new Map();
|
|
15950
17759
|
for (const option of def.options) {
|
|
15951
|
-
const
|
|
15952
|
-
if (!
|
|
17760
|
+
const values2 = option._zod.propValues?.[def.discriminator];
|
|
17761
|
+
if (!values2 || values2.size === 0)
|
|
15953
17762
|
throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
15954
|
-
for (const value of
|
|
17763
|
+
for (const value of values2) {
|
|
15955
17764
|
if (map2.has(value)) {
|
|
15956
17765
|
if (value !== void 0)
|
|
15957
17766
|
throw new Error(`Duplicate discriminator value "${String(value)}"`);
|
|
@@ -16016,19 +17825,19 @@ function handleIntersectionResults(result, left, right) {
|
|
|
16016
17825
|
let unrecIssue;
|
|
16017
17826
|
const keyIssues = /* @__PURE__ */ new Map();
|
|
16018
17827
|
const collect2 = (iss, side) => {
|
|
16019
|
-
let
|
|
17828
|
+
let keys2;
|
|
16020
17829
|
if (iss.code === "unrecognized_keys" && !iss.path?.length) {
|
|
16021
17830
|
unrecIssue ?? (unrecIssue = iss);
|
|
16022
|
-
|
|
17831
|
+
keys2 = iss.keys;
|
|
16023
17832
|
} else if (iss.code === "invalid_key" && iss.origin === "record" && iss.path?.length === 1) {
|
|
16024
17833
|
const k = String(iss.path[0]);
|
|
16025
17834
|
if (!keyIssues.has(k))
|
|
16026
17835
|
keyIssues.set(k, iss);
|
|
16027
|
-
|
|
17836
|
+
keys2 = [k];
|
|
16028
17837
|
} else {
|
|
16029
17838
|
return false;
|
|
16030
17839
|
}
|
|
16031
|
-
for (const k of
|
|
17840
|
+
for (const k of keys2) {
|
|
16032
17841
|
if (!unrecKeys.has(k))
|
|
16033
17842
|
unrecKeys.set(k, {});
|
|
16034
17843
|
unrecKeys.get(k)[side] = true;
|
|
@@ -16933,14 +18742,14 @@ var init_schemas = __esm({
|
|
|
16933
18742
|
const desc = Object.getOwnPropertyDescriptor(def, "shape");
|
|
16934
18743
|
const sh = desc?.get ? desc.get.raw : def.shape ?? {};
|
|
16935
18744
|
if (sh) {
|
|
16936
|
-
const
|
|
18745
|
+
const get2 = () => {
|
|
16937
18746
|
const newSh = { ...sh };
|
|
16938
18747
|
Object.defineProperty(def, "shape", { value: newSh });
|
|
16939
|
-
|
|
18748
|
+
get2.raw = newSh;
|
|
16940
18749
|
return newSh;
|
|
16941
18750
|
};
|
|
16942
|
-
|
|
16943
|
-
Object.defineProperty(def, "shape", { get });
|
|
18751
|
+
get2.raw = sh;
|
|
18752
|
+
Object.defineProperty(def, "shape", { get: get2 });
|
|
16944
18753
|
}
|
|
16945
18754
|
const _normalized = cached(() => normalizeDef(def));
|
|
16946
18755
|
defineLazyInternal(inst, "propValues", (zod) => {
|
|
@@ -17386,11 +19195,11 @@ var init_schemas = __esm({
|
|
|
17386
19195
|
return payload;
|
|
17387
19196
|
}
|
|
17388
19197
|
const proms = [];
|
|
17389
|
-
const
|
|
17390
|
-
if (
|
|
19198
|
+
const values2 = def.keyType._zod.values;
|
|
19199
|
+
if (values2 && !def.partial) {
|
|
17391
19200
|
payload.value = memo2 ? memo2.alloc(inst, payload, {}, ctx) : {};
|
|
17392
19201
|
const recordKeys = /* @__PURE__ */ new Set();
|
|
17393
|
-
for (const key of
|
|
19202
|
+
for (const key of values2) {
|
|
17394
19203
|
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
17395
19204
|
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
17396
19205
|
if (key === "__proto__")
|
|
@@ -17476,7 +19285,7 @@ var init_schemas = __esm({
|
|
|
17476
19285
|
if (keyResult.issues.length) {
|
|
17477
19286
|
if (def.mode === "loose") {
|
|
17478
19287
|
payload.value[key] = input2[key];
|
|
17479
|
-
} else if (
|
|
19288
|
+
} else if (values2) {
|
|
17480
19289
|
unrecognized = unrecognized ?? [];
|
|
17481
19290
|
unrecognized.push(key);
|
|
17482
19291
|
} else {
|
|
@@ -17605,8 +19414,8 @@ var init_schemas = __esm({
|
|
|
17605
19414
|
});
|
|
17606
19415
|
$ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
17607
19416
|
$ZodType.init(inst, def);
|
|
17608
|
-
const
|
|
17609
|
-
const valuesSet = new Set(
|
|
19417
|
+
const values2 = getEnumValues(def.entries);
|
|
19418
|
+
const valuesSet = new Set(values2);
|
|
17610
19419
|
inst._zod.values = valuesSet;
|
|
17611
19420
|
defineLazyInternal(inst, "pattern", (zod) => {
|
|
17612
19421
|
const patternValues = getEnumValues(zod.def.entries).filter((k) => propertyKeyTypes.has(typeof k));
|
|
@@ -17619,7 +19428,7 @@ var init_schemas = __esm({
|
|
|
17619
19428
|
}
|
|
17620
19429
|
payload.issues.push({
|
|
17621
19430
|
code: "invalid_value",
|
|
17622
|
-
values,
|
|
19431
|
+
values: values2,
|
|
17623
19432
|
input: input2,
|
|
17624
19433
|
inst
|
|
17625
19434
|
});
|
|
@@ -17628,15 +19437,15 @@ var init_schemas = __esm({
|
|
|
17628
19437
|
});
|
|
17629
19438
|
$ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
17630
19439
|
$ZodType.init(inst, def);
|
|
17631
|
-
const
|
|
17632
|
-
inst._zod.values =
|
|
19440
|
+
const values2 = new Set(def.values);
|
|
19441
|
+
inst._zod.values = values2;
|
|
17633
19442
|
defineLazyInternal(inst, "pattern", (zod) => {
|
|
17634
19443
|
const vals = zod.def.values;
|
|
17635
19444
|
return new RegExp(vals.length ? `^(${vals.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$` : "^[^\\s\\S]$");
|
|
17636
19445
|
});
|
|
17637
19446
|
inst._zod.parse = (payload, _ctx) => {
|
|
17638
19447
|
const input2 = payload.value;
|
|
17639
|
-
if (
|
|
19448
|
+
if (values2.has(input2)) {
|
|
17640
19449
|
return payload;
|
|
17641
19450
|
}
|
|
17642
19451
|
payload.issues.push({
|
|
@@ -17691,8 +19500,8 @@ var init_schemas = __esm({
|
|
|
17691
19500
|
defineLazyInternal(inst, "optin", (zod) => zod.def.innerType._zod.optin === "defaulted" ? "defaulted" : "optional");
|
|
17692
19501
|
inst._zod.optout = "optional";
|
|
17693
19502
|
defineLazyInternal(inst, "values", (zod) => {
|
|
17694
|
-
const
|
|
17695
|
-
return
|
|
19503
|
+
const values2 = zod.def.innerType._zod.values;
|
|
19504
|
+
return values2 ? /* @__PURE__ */ new Set([...values2, void 0]) : void 0;
|
|
17696
19505
|
});
|
|
17697
19506
|
defineLazyInternal(inst, "pattern", (zod) => {
|
|
17698
19507
|
const pattern = zod.def.innerType._zod.pattern;
|
|
@@ -27111,13 +28920,13 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
27111
28920
|
const def = schema._zod.def;
|
|
27112
28921
|
doc.write(`if (typeof ${accessor} !== "object" || ${accessor} === null || Array.isArray(${accessor})) return INVALID;`);
|
|
27113
28922
|
const shape = def.shape;
|
|
27114
|
-
const
|
|
28923
|
+
const keys2 = Object.keys(shape);
|
|
27115
28924
|
const symbolKeys = Object.getOwnPropertySymbols(shape);
|
|
27116
|
-
const allKeys = symbolKeys.length ? [...
|
|
28925
|
+
const allKeys = symbolKeys.length ? [...keys2, ...symbolKeys] : keys2;
|
|
27117
28926
|
const keyExpr = (k) => typeof k === "symbol" ? addConstant(ctx, k) : esc(k);
|
|
27118
28927
|
const propKey = (k) => typeof k === "symbol" ? `[${keyExpr(k)}]` : esc(k);
|
|
27119
28928
|
const propShape = shape;
|
|
27120
|
-
if (
|
|
28929
|
+
if (keys2.includes("__proto__")) {
|
|
27121
28930
|
throw new ZodCompileUnsupportedError('object shape key "__proto__"');
|
|
27122
28931
|
}
|
|
27123
28932
|
const propOutputs = /* @__PURE__ */ new Map();
|
|
@@ -27159,7 +28968,7 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
27159
28968
|
if (catchall) {
|
|
27160
28969
|
const catchallType = catchall._zod.def.type;
|
|
27161
28970
|
if (catchallType === "never") {
|
|
27162
|
-
const condition =
|
|
28971
|
+
const condition = keys2.map((k) => `k !== ${esc(k)}`).join(" && ") || "true";
|
|
27163
28972
|
doc.write(`for (const k in ${accessor}) {`);
|
|
27164
28973
|
doc.indented((d) => {
|
|
27165
28974
|
d.write(`if (${condition}) return INVALID;`);
|
|
@@ -27175,7 +28984,7 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
27175
28984
|
const hasConditionalKeys = allKeys.some((k) => mayOmitUndefined(propShape[k]) || dropsWhenAbsent(propShape[k]));
|
|
27176
28985
|
if (!buildsValue) {
|
|
27177
28986
|
if (unknownKeysMode === "schema") {
|
|
27178
|
-
const knownSet =
|
|
28987
|
+
const knownSet = keys2.length > 0 ? addConstant(ctx, new Set(keys2)) : null;
|
|
27179
28988
|
doc.write(`for (const k in ${accessor}) {`);
|
|
27180
28989
|
doc.indented((d) => {
|
|
27181
28990
|
d.write(`if (k === "__proto__") continue;`);
|
|
@@ -27207,7 +29016,7 @@ function generateObjectCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
27207
29016
|
}
|
|
27208
29017
|
}
|
|
27209
29018
|
if (unknownKeysMode !== "none") {
|
|
27210
|
-
const knownSet =
|
|
29019
|
+
const knownSet = keys2.length > 0 ? addConstant(ctx, new Set(keys2)) : null;
|
|
27211
29020
|
doc.write(`for (const k in ${accessor}) {`);
|
|
27212
29021
|
doc.indented((d) => {
|
|
27213
29022
|
d.write(`if (k === "__proto__") continue;`);
|
|
@@ -27417,15 +29226,15 @@ function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
27417
29226
|
}
|
|
27418
29227
|
function generateLiteralCheck(doc, ctx, schema, accessor) {
|
|
27419
29228
|
const def = schema._zod.def;
|
|
27420
|
-
const
|
|
27421
|
-
if (
|
|
27422
|
-
const literalSet = addConstant(ctx, new Set(
|
|
29229
|
+
const values2 = def.values;
|
|
29230
|
+
if (values2.length !== 1) {
|
|
29231
|
+
const literalSet = addConstant(ctx, new Set(values2));
|
|
27423
29232
|
doc.write(`if (!${literalSet}.has(${accessor})) return INVALID;`);
|
|
27424
29233
|
return accessor;
|
|
27425
29234
|
}
|
|
27426
|
-
const value =
|
|
29235
|
+
const value = values2[0];
|
|
27427
29236
|
if (typeof value === "number" && Number.isNaN(value)) {
|
|
27428
|
-
const literalSet = addConstant(ctx, new Set(
|
|
29237
|
+
const literalSet = addConstant(ctx, new Set(values2));
|
|
27429
29238
|
doc.write(`if (!${literalSet}.has(${accessor})) return INVALID;`);
|
|
27430
29239
|
return accessor;
|
|
27431
29240
|
}
|
|
@@ -27445,11 +29254,11 @@ function generateLiteralCheck(doc, ctx, schema, accessor) {
|
|
|
27445
29254
|
return accessor;
|
|
27446
29255
|
}
|
|
27447
29256
|
function generateEnumCheck(doc, ctx, schema, accessor) {
|
|
27448
|
-
const
|
|
27449
|
-
if (!
|
|
29257
|
+
const values2 = schema._zod.values;
|
|
29258
|
+
if (!values2) {
|
|
27450
29259
|
throw new ZodCompileUnsupportedError("enum schema without enumerated values");
|
|
27451
29260
|
}
|
|
27452
|
-
const enumSet = addConstant(ctx,
|
|
29261
|
+
const enumSet = addConstant(ctx, values2);
|
|
27453
29262
|
doc.write(`if (!${enumSet}.has(${accessor})) return INVALID;`);
|
|
27454
29263
|
return accessor;
|
|
27455
29264
|
}
|
|
@@ -27598,8 +29407,8 @@ function generateUnionCheck(doc, ctx, schema, accessor) {
|
|
|
27598
29407
|
}
|
|
27599
29408
|
const allLiterals = options.every((opt) => opt._zod.def.type === "literal" && !opt._zod.def.checks?.length);
|
|
27600
29409
|
if (allLiterals) {
|
|
27601
|
-
const
|
|
27602
|
-
const valuesConst = addConstant(ctx,
|
|
29410
|
+
const values2 = new Set(options.flatMap((opt) => opt._zod.def.values));
|
|
29411
|
+
const valuesConst = addConstant(ctx, values2);
|
|
27603
29412
|
doc.write(`if (!${valuesConst}.has(${accessor})) return INVALID;`);
|
|
27604
29413
|
return accessor;
|
|
27605
29414
|
}
|
|
@@ -27636,17 +29445,17 @@ function generateDiscriminatedUnionCheck(doc, ctx, def, accessor) {
|
|
|
27636
29445
|
let firstBranch = true;
|
|
27637
29446
|
const claimed = /* @__PURE__ */ new Set();
|
|
27638
29447
|
for (const option of def.options) {
|
|
27639
|
-
const
|
|
27640
|
-
if (!
|
|
29448
|
+
const values2 = option._zod.propValues?.[def.discriminator];
|
|
29449
|
+
if (!values2 || values2.size === 0) {
|
|
27641
29450
|
throw new ZodCompileUnsupportedError("discriminated union option without static discriminator values");
|
|
27642
29451
|
}
|
|
27643
|
-
for (const value of
|
|
29452
|
+
for (const value of values2) {
|
|
27644
29453
|
if (claimed.has(value)) {
|
|
27645
29454
|
throw new ZodCompileUnsupportedError(`duplicate discriminator value ${String(value)}`);
|
|
27646
29455
|
}
|
|
27647
29456
|
claimed.add(value);
|
|
27648
29457
|
}
|
|
27649
|
-
const conditions = Array.from(
|
|
29458
|
+
const conditions = Array.from(values2, (value) => literalEquality(ctx, discVar, value));
|
|
27650
29459
|
const prefix = firstBranch ? "if" : "else if";
|
|
27651
29460
|
doc.write(`${prefix} (${conditions.join(" || ")}) {`);
|
|
27652
29461
|
doc.indented((d) => {
|
|
@@ -28801,8 +30610,8 @@ function _set(Class2, valueType, params) {
|
|
|
28801
30610
|
});
|
|
28802
30611
|
}
|
|
28803
30612
|
// @__NO_SIDE_EFFECTS__
|
|
28804
|
-
function _enum(Class2,
|
|
28805
|
-
const entries = Array.isArray(
|
|
30613
|
+
function _enum(Class2, values2, params) {
|
|
30614
|
+
const entries = Array.isArray(values2) ? Object.fromEntries(values2.map((v) => [v, v])) : values2;
|
|
28806
30615
|
return new Class2({
|
|
28807
30616
|
type: "enum",
|
|
28808
30617
|
entries,
|
|
@@ -29295,8 +31104,8 @@ function compactTypeUnion(schema) {
|
|
|
29295
31104
|
if (!option || typeof option !== "object")
|
|
29296
31105
|
return;
|
|
29297
31106
|
compactTypeUnion(option);
|
|
29298
|
-
const
|
|
29299
|
-
if (
|
|
31107
|
+
const keys2 = Object.keys(option);
|
|
31108
|
+
if (keys2.length !== 1 || keys2[0] !== "type")
|
|
29300
31109
|
return;
|
|
29301
31110
|
const type = option.type;
|
|
29302
31111
|
for (const member of Array.isArray(type) ? type : [type]) {
|
|
@@ -29686,8 +31495,8 @@ function stringifyKeyNames(bySchema, json2, visited) {
|
|
|
29686
31495
|
}
|
|
29687
31496
|
const types = Array.isArray(json2.type) ? json2.type : [json2.type];
|
|
29688
31497
|
const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
|
|
29689
|
-
const
|
|
29690
|
-
if (!numericType && !
|
|
31498
|
+
const values2 = json2.enum ?? (json2.const !== void 0 ? [json2.const] : void 0);
|
|
31499
|
+
if (!numericType && !values2?.some((v) => typeof v === "number"))
|
|
29691
31500
|
return json2;
|
|
29692
31501
|
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json2;
|
|
29693
31502
|
if (rest.enum)
|
|
@@ -29697,7 +31506,7 @@ function stringifyKeyNames(bySchema, json2, visited) {
|
|
|
29697
31506
|
if (!numericType)
|
|
29698
31507
|
return rest;
|
|
29699
31508
|
rest.type = "string";
|
|
29700
|
-
if (!
|
|
31509
|
+
if (!values2)
|
|
29701
31510
|
rest.pattern = (types.includes("number") ? number : integer).source;
|
|
29702
31511
|
return rest;
|
|
29703
31512
|
}
|
|
@@ -29964,16 +31773,16 @@ var init_json_schema_processors = __esm({
|
|
|
29964
31773
|
};
|
|
29965
31774
|
enumProcessor = (schema, _ctx, json2, _params) => {
|
|
29966
31775
|
const def = schema._zod.def;
|
|
29967
|
-
const
|
|
29968
|
-
if (
|
|
31776
|
+
const values2 = getEnumValues(def.entries);
|
|
31777
|
+
if (values2.length === 0) {
|
|
29969
31778
|
json2.not = {};
|
|
29970
31779
|
return;
|
|
29971
31780
|
}
|
|
29972
|
-
if (
|
|
31781
|
+
if (values2.every((v) => typeof v === "number"))
|
|
29973
31782
|
json2.type = "number";
|
|
29974
|
-
if (
|
|
31783
|
+
if (values2.every((v) => typeof v === "string"))
|
|
29975
31784
|
json2.type = "string";
|
|
29976
|
-
json2.enum =
|
|
31785
|
+
json2.enum = values2;
|
|
29977
31786
|
};
|
|
29978
31787
|
literalProcessor = (schema, ctx, json2, params) => {
|
|
29979
31788
|
const def = schema._zod.def;
|
|
@@ -30931,10 +32740,10 @@ function visit(schema, fnOrHandlers) {
|
|
|
30931
32740
|
switch (kind) {
|
|
30932
32741
|
case "object": {
|
|
30933
32742
|
const oldShape = def.shape;
|
|
30934
|
-
const
|
|
32743
|
+
const keys2 = Object.keys(oldShape);
|
|
30935
32744
|
let changed = false;
|
|
30936
32745
|
const newShape = {};
|
|
30937
|
-
for (const k of
|
|
32746
|
+
for (const k of keys2) {
|
|
30938
32747
|
const mapped = run2(oldShape[k]);
|
|
30939
32748
|
if (mapped !== oldShape[k])
|
|
30940
32749
|
changed = true;
|
|
@@ -31103,11 +32912,11 @@ function isZ4Schema(s) {
|
|
|
31103
32912
|
return !!schema._zod;
|
|
31104
32913
|
}
|
|
31105
32914
|
function objectFromShape(shape) {
|
|
31106
|
-
const
|
|
31107
|
-
if (
|
|
32915
|
+
const values2 = Object.values(shape);
|
|
32916
|
+
if (values2.length === 0)
|
|
31108
32917
|
return object({});
|
|
31109
|
-
const allV4 =
|
|
31110
|
-
const allV3 =
|
|
32918
|
+
const allV4 = values2.every(isZ4Schema);
|
|
32919
|
+
const allV3 = values2.every((s) => !isZ4Schema(s));
|
|
31111
32920
|
if (allV4)
|
|
31112
32921
|
return object(shape);
|
|
31113
32922
|
if (allV3)
|
|
@@ -31161,8 +32970,8 @@ function normalizeObjectSchema(schema) {
|
|
|
31161
32970
|
const asV3 = schema;
|
|
31162
32971
|
const asV4 = schema;
|
|
31163
32972
|
if (!asV3._def && !asV4._zod) {
|
|
31164
|
-
const
|
|
31165
|
-
if (
|
|
32973
|
+
const values2 = Object.values(schema);
|
|
32974
|
+
if (values2.length > 0 && values2.every((v) => typeof v === "object" && v !== null && (v._def !== void 0 || v._zod !== void 0 || typeof v.parse === "function"))) {
|
|
31166
32975
|
return objectFromShape(schema);
|
|
31167
32976
|
}
|
|
31168
32977
|
}
|
|
@@ -31181,11 +32990,11 @@ function normalizeObjectSchema(schema) {
|
|
|
31181
32990
|
}
|
|
31182
32991
|
return void 0;
|
|
31183
32992
|
}
|
|
31184
|
-
function getDotPath(
|
|
31185
|
-
if (
|
|
32993
|
+
function getDotPath(path7) {
|
|
32994
|
+
if (path7.length === 0) {
|
|
31186
32995
|
return "object root";
|
|
31187
32996
|
}
|
|
31188
|
-
return
|
|
32997
|
+
return path7.reduce((acc, seg, index) => {
|
|
31189
32998
|
if (index === 0) {
|
|
31190
32999
|
return String(seg);
|
|
31191
33000
|
}
|
|
@@ -31847,8 +33656,8 @@ function set(valueType, params) {
|
|
|
31847
33656
|
...util_exports.normalizeParams(params)
|
|
31848
33657
|
});
|
|
31849
33658
|
}
|
|
31850
|
-
function _enum2(
|
|
31851
|
-
const entries = Array.isArray(
|
|
33659
|
+
function _enum2(values2, params) {
|
|
33660
|
+
const entries = Array.isArray(values2) ? Object.fromEntries(values2.map((v) => [v, v])) : values2;
|
|
31852
33661
|
return new ZodEnum2({
|
|
31853
33662
|
type: "enum",
|
|
31854
33663
|
entries,
|
|
@@ -32828,11 +34637,11 @@ var init_schemas3 = __esm({
|
|
|
32828
34637
|
inst._zod.processJSONSchema = (ctx, json2, params) => enumProcessor(inst, ctx, json2, params);
|
|
32829
34638
|
inst.enum = def.entries;
|
|
32830
34639
|
inst.options = [...inst._zod.values];
|
|
32831
|
-
const
|
|
32832
|
-
inst.extract = (
|
|
34640
|
+
const keys2 = new Set(Object.keys(def.entries));
|
|
34641
|
+
inst.extract = (values2, params) => {
|
|
32833
34642
|
const newEntries = {};
|
|
32834
|
-
for (const value of
|
|
32835
|
-
if (
|
|
34643
|
+
for (const value of values2) {
|
|
34644
|
+
if (keys2.has(value)) {
|
|
32836
34645
|
newEntries[value] = def.entries[value];
|
|
32837
34646
|
} else
|
|
32838
34647
|
throw new Error(`Key ${value} not found in enum`);
|
|
@@ -32844,10 +34653,10 @@ var init_schemas3 = __esm({
|
|
|
32844
34653
|
entries: newEntries
|
|
32845
34654
|
});
|
|
32846
34655
|
};
|
|
32847
|
-
inst.exclude = (
|
|
34656
|
+
inst.exclude = (values2, params) => {
|
|
32848
34657
|
const newEntries = { ...def.entries };
|
|
32849
|
-
for (const value of
|
|
32850
|
-
if (
|
|
34658
|
+
for (const value of values2) {
|
|
34659
|
+
if (keys2.has(value)) {
|
|
32851
34660
|
delete newEntries[value];
|
|
32852
34661
|
} else
|
|
32853
34662
|
throw new Error(`Key ${value} not found in enum`);
|
|
@@ -33123,13 +34932,13 @@ function resolveRef(ref, ctx) {
|
|
|
33123
34932
|
if (!ref.startsWith("#")) {
|
|
33124
34933
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
33125
34934
|
}
|
|
33126
|
-
const
|
|
33127
|
-
if (
|
|
34935
|
+
const path7 = ref.slice(1).split("/").filter(Boolean);
|
|
34936
|
+
if (path7.length === 0) {
|
|
33128
34937
|
return ctx.rootSchema;
|
|
33129
34938
|
}
|
|
33130
34939
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
33131
|
-
if (
|
|
33132
|
-
const key =
|
|
34940
|
+
if (path7[0] === defsKey) {
|
|
34941
|
+
const key = path7[1] === void 0 ? void 0 : decodeJSONPointerSegment(path7[1]);
|
|
33133
34942
|
if (!key || !ctx.defs[key]) {
|
|
33134
34943
|
throw new Error(`Reference not found: ${ref}`);
|
|
33135
34944
|
}
|
|
@@ -33142,8 +34951,8 @@ function checkObjectGuards(objectSchema, guards) {
|
|
|
33142
34951
|
const value = payload.value;
|
|
33143
34952
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
33144
34953
|
return;
|
|
33145
|
-
const
|
|
33146
|
-
if (guards.minProperties !== void 0 &&
|
|
34954
|
+
const keys2 = Object.getOwnPropertyNames(value);
|
|
34955
|
+
if (guards.minProperties !== void 0 && keys2.length < guards.minProperties) {
|
|
33147
34956
|
payload.issues.push({
|
|
33148
34957
|
origin: "object",
|
|
33149
34958
|
code: "too_small",
|
|
@@ -33155,7 +34964,7 @@ function checkObjectGuards(objectSchema, guards) {
|
|
|
33155
34964
|
continue: true
|
|
33156
34965
|
});
|
|
33157
34966
|
}
|
|
33158
|
-
if (guards.maxProperties !== void 0 &&
|
|
34967
|
+
if (guards.maxProperties !== void 0 && keys2.length > guards.maxProperties) {
|
|
33159
34968
|
payload.issues.push({
|
|
33160
34969
|
origin: "object",
|
|
33161
34970
|
code: "too_big",
|
|
@@ -33168,7 +34977,7 @@ function checkObjectGuards(objectSchema, guards) {
|
|
|
33168
34977
|
});
|
|
33169
34978
|
}
|
|
33170
34979
|
if (guards.keySchema) {
|
|
33171
|
-
for (const key of
|
|
34980
|
+
for (const key of keys2) {
|
|
33172
34981
|
const result = guards.keySchema.safeParse(key);
|
|
33173
34982
|
if (result.success)
|
|
33174
34983
|
continue;
|
|
@@ -33209,9 +35018,9 @@ function canonicalKey(value, seen) {
|
|
|
33209
35018
|
}
|
|
33210
35019
|
return `a${parts2.length}:[${parts2.join(",")}]`;
|
|
33211
35020
|
}
|
|
33212
|
-
const
|
|
35021
|
+
const keys2 = Object.keys(value).sort();
|
|
33213
35022
|
const parts = [];
|
|
33214
|
-
for (const k of
|
|
35023
|
+
for (const k of keys2) {
|
|
33215
35024
|
const key = canonicalKey(value[k], seen);
|
|
33216
35025
|
if (key === null)
|
|
33217
35026
|
return null;
|
|
@@ -36575,11 +38384,11 @@ function parseMapDef(def, refs) {
|
|
|
36575
38384
|
if (refs.mapStrategy === "record") {
|
|
36576
38385
|
return parseRecordDef(def, refs);
|
|
36577
38386
|
}
|
|
36578
|
-
const
|
|
38387
|
+
const keys2 = parseDef(def.keyType._def, {
|
|
36579
38388
|
...refs,
|
|
36580
38389
|
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
36581
38390
|
}) || parseAnyDef(refs);
|
|
36582
|
-
const
|
|
38391
|
+
const values2 = parseDef(def.valueType._def, {
|
|
36583
38392
|
...refs,
|
|
36584
38393
|
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
36585
38394
|
}) || parseAnyDef(refs);
|
|
@@ -36588,7 +38397,7 @@ function parseMapDef(def, refs) {
|
|
|
36588
38397
|
maxItems: 125,
|
|
36589
38398
|
items: {
|
|
36590
38399
|
type: "array",
|
|
36591
|
-
items: [
|
|
38400
|
+
items: [keys2, values2],
|
|
36592
38401
|
minItems: 2,
|
|
36593
38402
|
maxItems: 2
|
|
36594
38403
|
}
|
|
@@ -36609,7 +38418,7 @@ function parseNativeEnumDef(def) {
|
|
|
36609
38418
|
return typeof object3[object3[key]] !== "number";
|
|
36610
38419
|
});
|
|
36611
38420
|
const actualValues = actualKeys.map((key) => object3[key]);
|
|
36612
|
-
const parsedTypes = Array.from(new Set(actualValues.map((
|
|
38421
|
+
const parsedTypes = Array.from(new Set(actualValues.map((values2) => typeof values2)));
|
|
36613
38422
|
return {
|
|
36614
38423
|
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
36615
38424
|
enum: actualValues
|
|
@@ -38632,24 +40441,24 @@ var require_scope = __commonJS({
|
|
|
38632
40441
|
return;
|
|
38633
40442
|
return vs.get(keyOrRef);
|
|
38634
40443
|
}
|
|
38635
|
-
scopeRefs(scopeName,
|
|
38636
|
-
return this._reduceValues(
|
|
40444
|
+
scopeRefs(scopeName, values2 = this._values) {
|
|
40445
|
+
return this._reduceValues(values2, (name) => {
|
|
38637
40446
|
if (name.scopePath === void 0)
|
|
38638
40447
|
throw new Error(`CodeGen: name "${name}" has no value`);
|
|
38639
40448
|
return (0, code_1._)`${scopeName}${name.scopePath}`;
|
|
38640
40449
|
});
|
|
38641
40450
|
}
|
|
38642
|
-
scopeCode(
|
|
38643
|
-
return this._reduceValues(
|
|
40451
|
+
scopeCode(values2 = this._values, usedValues, getCode) {
|
|
40452
|
+
return this._reduceValues(values2, (name) => {
|
|
38644
40453
|
if (name.value === void 0)
|
|
38645
40454
|
throw new Error(`CodeGen: name "${name}" has no value`);
|
|
38646
40455
|
return name.value.code;
|
|
38647
40456
|
}, usedValues, getCode);
|
|
38648
40457
|
}
|
|
38649
|
-
_reduceValues(
|
|
40458
|
+
_reduceValues(values2, valueCode, usedValues = {}, getCode) {
|
|
38650
40459
|
let code = code_1.nil;
|
|
38651
|
-
for (const prefix in
|
|
38652
|
-
const vs =
|
|
40460
|
+
for (const prefix in values2) {
|
|
40461
|
+
const vs = values2[prefix];
|
|
38653
40462
|
if (!vs)
|
|
38654
40463
|
continue;
|
|
38655
40464
|
const nameSet = usedValues[prefix] = usedValues[prefix] || /* @__PURE__ */ new Map();
|
|
@@ -40392,7 +42201,7 @@ var require_fast_deep_equal = __commonJS({
|
|
|
40392
42201
|
if (a === b) return true;
|
|
40393
42202
|
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
40394
42203
|
if (a.constructor !== b.constructor) return false;
|
|
40395
|
-
var length, i,
|
|
42204
|
+
var length, i, keys2;
|
|
40396
42205
|
if (Array.isArray(a)) {
|
|
40397
42206
|
length = a.length;
|
|
40398
42207
|
if (length != b.length) return false;
|
|
@@ -40403,13 +42212,13 @@ var require_fast_deep_equal = __commonJS({
|
|
|
40403
42212
|
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
|
|
40404
42213
|
if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
|
|
40405
42214
|
if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
|
|
40406
|
-
|
|
40407
|
-
length =
|
|
42215
|
+
keys2 = Object.keys(a);
|
|
42216
|
+
length = keys2.length;
|
|
40408
42217
|
if (length !== Object.keys(b).length) return false;
|
|
40409
42218
|
for (i = length; i-- !== 0; )
|
|
40410
|
-
if (!Object.prototype.hasOwnProperty.call(b,
|
|
42219
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys2[i])) return false;
|
|
40411
42220
|
for (i = length; i-- !== 0; ) {
|
|
40412
|
-
var key =
|
|
42221
|
+
var key = keys2[i];
|
|
40413
42222
|
if (!equal(a[key], b[key])) return false;
|
|
40414
42223
|
}
|
|
40415
42224
|
return true;
|
|
@@ -41572,16 +43381,16 @@ var require_utils = __commonJS({
|
|
|
41572
43381
|
return compressIPv6ZeroRun(expanded);
|
|
41573
43382
|
}
|
|
41574
43383
|
function normalizeIPv6(host) {
|
|
41575
|
-
const
|
|
43384
|
+
const bracketed2 = host[0] === "[" && host[host.length - 1] === "]";
|
|
41576
43385
|
const hasBracket = host[0] === "[" || host[host.length - 1] === "]";
|
|
41577
|
-
if (hasBracket && !
|
|
41578
|
-
let input2 =
|
|
41579
|
-
if (
|
|
43386
|
+
if (hasBracket && !bracketed2) return { host, isIPV6: false, error: true };
|
|
43387
|
+
let input2 = bracketed2 ? host.slice(1, -1) : host;
|
|
43388
|
+
if (bracketed2 && isIPvFuture(input2)) {
|
|
41580
43389
|
input2 = input2.toLowerCase();
|
|
41581
43390
|
return { host: `[${input2}]`, escapedHost: input2, isIPV6: false, isIPVFuture: true };
|
|
41582
43391
|
}
|
|
41583
43392
|
if (findToken(input2, ":") < 2) {
|
|
41584
|
-
return { host, isIPV6: false, error:
|
|
43393
|
+
return { host, isIPV6: false, error: bracketed2 };
|
|
41585
43394
|
}
|
|
41586
43395
|
let zoneIdentifier = "";
|
|
41587
43396
|
const zoneSeparator = input2.indexOf("%");
|
|
@@ -41606,8 +43415,8 @@ var require_utils = __commonJS({
|
|
|
41606
43415
|
}
|
|
41607
43416
|
return ind;
|
|
41608
43417
|
}
|
|
41609
|
-
function removeDotSegments(
|
|
41610
|
-
let input2 =
|
|
43418
|
+
function removeDotSegments(path7) {
|
|
43419
|
+
let input2 = path7;
|
|
41611
43420
|
const output2 = [];
|
|
41612
43421
|
let nextSlash = -1;
|
|
41613
43422
|
let len = 0;
|
|
@@ -41681,11 +43490,11 @@ var require_utils = __commonJS({
|
|
|
41681
43490
|
}
|
|
41682
43491
|
return output2.join("");
|
|
41683
43492
|
}
|
|
41684
|
-
function removeDotSegmentsRelative(
|
|
41685
|
-
if (
|
|
41686
|
-
return removeDotSegments(
|
|
43493
|
+
function removeDotSegmentsRelative(path7) {
|
|
43494
|
+
if (path7 === "" || path7[0] === "/") {
|
|
43495
|
+
return removeDotSegments(path7);
|
|
41687
43496
|
}
|
|
41688
|
-
const segments =
|
|
43497
|
+
const segments = path7.split("/");
|
|
41689
43498
|
const last = segments.length - 1;
|
|
41690
43499
|
const output2 = [];
|
|
41691
43500
|
let trailingDirectory = false;
|
|
@@ -42048,8 +43857,8 @@ var require_schemes = __commonJS({
|
|
|
42048
43857
|
}
|
|
42049
43858
|
if (wsComponent.resourceName) {
|
|
42050
43859
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
42051
|
-
const
|
|
42052
|
-
wsComponent.path =
|
|
43860
|
+
const path7 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
43861
|
+
wsComponent.path = path7 && path7 !== "/" ? path7 : void 0;
|
|
42053
43862
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
42054
43863
|
wsComponent.resourceName = void 0;
|
|
42055
43864
|
}
|
|
@@ -45288,8 +47097,8 @@ var require_formats = __commonJS({
|
|
|
45288
47097
|
"use strict";
|
|
45289
47098
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45290
47099
|
exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
|
|
45291
|
-
function fmtDef(validate2,
|
|
45292
|
-
return { validate: validate2, compare:
|
|
47100
|
+
function fmtDef(validate2, compare3) {
|
|
47101
|
+
return { validate: validate2, compare: compare3 };
|
|
45293
47102
|
}
|
|
45294
47103
|
exports.fullFormats = {
|
|
45295
47104
|
// date: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
@@ -47666,7 +49475,7 @@ import { spawn } from "node:child_process";
|
|
|
47666
49475
|
import { mkdirSync as mkdirSync2, openSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
47667
49476
|
import net from "node:net";
|
|
47668
49477
|
import os4 from "node:os";
|
|
47669
|
-
import
|
|
49478
|
+
import path6 from "node:path";
|
|
47670
49479
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
47671
49480
|
import { parseArgs } from "node:util";
|
|
47672
49481
|
|
|
@@ -47753,18 +49562,18 @@ function skillsDirs() {
|
|
|
47753
49562
|
}
|
|
47754
49563
|
function linkSkill(skillsDir, source = path.join(packageRoot(), "skills", SKILL)) {
|
|
47755
49564
|
const link = path.join(skillsDir, SKILL);
|
|
47756
|
-
let
|
|
49565
|
+
let stat3;
|
|
47757
49566
|
try {
|
|
47758
|
-
|
|
49567
|
+
stat3 = lstatSync(link);
|
|
47759
49568
|
} catch {
|
|
47760
49569
|
}
|
|
47761
49570
|
let note = "";
|
|
47762
|
-
if (
|
|
49571
|
+
if (stat3?.isSymbolicLink()) {
|
|
47763
49572
|
const target = path.resolve(skillsDir, readlinkSync(link));
|
|
47764
49573
|
if (target === source) return `\u2713 Claude skill: ${link} \u2192 ${source}`;
|
|
47765
49574
|
rmSync(link);
|
|
47766
49575
|
note = ` (it pointed at ${target})`;
|
|
47767
|
-
} else if (
|
|
49576
|
+
} else if (stat3) {
|
|
47768
49577
|
const backup = `${link}.old-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}`;
|
|
47769
49578
|
rmSync(backup, { recursive: true, force: true });
|
|
47770
49579
|
renameSync(link, backup);
|
|
@@ -47928,7 +49737,7 @@ var SPECS = {
|
|
|
47928
49737
|
};
|
|
47929
49738
|
var UsageError = class extends Error {
|
|
47930
49739
|
};
|
|
47931
|
-
function
|
|
49740
|
+
function num2(v, key, min, max) {
|
|
47932
49741
|
const raw = v[key];
|
|
47933
49742
|
if (raw === void 0) return void 0;
|
|
47934
49743
|
const x = Number(raw);
|
|
@@ -47943,20 +49752,20 @@ function oneOf(v, key, allowed) {
|
|
|
47943
49752
|
}
|
|
47944
49753
|
var str = (v, key) => v[key];
|
|
47945
49754
|
function imageDir() {
|
|
47946
|
-
return
|
|
49755
|
+
return path6.join(os4.tmpdir(), "lupa");
|
|
47947
49756
|
}
|
|
47948
49757
|
function deliver(v, out, kind) {
|
|
47949
49758
|
if (!v.images.length) return v.text;
|
|
47950
|
-
const base = out ??
|
|
47951
|
-
mkdirSync2(
|
|
47952
|
-
const ext =
|
|
47953
|
-
const stem = base.slice(0, base.length -
|
|
47954
|
-
const
|
|
47955
|
-
const f =
|
|
49759
|
+
const base = out ?? path6.join(imageDir(), `${kind}-${Date.now().toString(36)}.png`);
|
|
49760
|
+
mkdirSync2(path6.dirname(path6.resolve(base)), { recursive: true });
|
|
49761
|
+
const ext = path6.extname(base) || ".png";
|
|
49762
|
+
const stem = base.slice(0, base.length - path6.extname(base).length);
|
|
49763
|
+
const files2 = v.images.map((png, i) => {
|
|
49764
|
+
const f = path6.resolve(i === 0 ? `${stem}${ext}` : `${stem}-${i + 1}${ext}`);
|
|
47956
49765
|
writeFileSync2(f, png);
|
|
47957
49766
|
return f;
|
|
47958
49767
|
});
|
|
47959
|
-
return [v.text, ...
|
|
49768
|
+
return [v.text, ...files2.map((f) => `image: ${f}`)].join("\n");
|
|
47960
49769
|
}
|
|
47961
49770
|
async function run(cmd, v, pos, lupa) {
|
|
47962
49771
|
const target = pos.length ? pos.join(" ") : void 0;
|
|
@@ -47968,9 +49777,9 @@ async function run(cmd, v, pos, lupa) {
|
|
|
47968
49777
|
const text2 = await lupa.design({
|
|
47969
49778
|
target,
|
|
47970
49779
|
file: file2,
|
|
47971
|
-
budget:
|
|
49780
|
+
budget: num2(v, "budget", 500, 1e5),
|
|
47972
49781
|
components: oneOf(v, "components", ["auto", "inline", "names"]),
|
|
47973
|
-
depth:
|
|
49782
|
+
depth: num2(v, "depth", 0, 1e3),
|
|
47974
49783
|
includeHidden: v.hidden === true,
|
|
47975
49784
|
expandVectors: v.vectors === true,
|
|
47976
49785
|
assetsDir: str(v, "dir"),
|
|
@@ -47984,14 +49793,14 @@ async function run(cmd, v, pos, lupa) {
|
|
|
47984
49793
|
${deliver(await lupa.screenshot({ target, file: file2 }), void 0, "screenshot")}`;
|
|
47985
49794
|
}
|
|
47986
49795
|
case "screenshot":
|
|
47987
|
-
return deliver(await lupa.screenshot({ target, file: file2, scale:
|
|
49796
|
+
return deliver(await lupa.screenshot({ target, file: file2, scale: num2(v, "scale", 0.1, 4), saveTo: str(v, "full") }), str(v, "out"), "screenshot");
|
|
47988
49797
|
case "assets":
|
|
47989
49798
|
return lupa.assets({
|
|
47990
49799
|
target,
|
|
47991
49800
|
file: file2,
|
|
47992
49801
|
dir: str(v, "dir"),
|
|
47993
49802
|
as: oneOf(v, "as", ["auto", "svg", "png"]),
|
|
47994
|
-
scale:
|
|
49803
|
+
scale: num2(v, "scale", 0.5, 4),
|
|
47995
49804
|
currentColor: v["current-color"] === true
|
|
47996
49805
|
});
|
|
47997
49806
|
case "tokens":
|
|
@@ -48000,7 +49809,7 @@ ${deliver(await lupa.screenshot({ target, file: file2 }), void 0, "screenshot")}
|
|
|
48000
49809
|
if (!target) throw new UsageError("css needs a target (node id or URL)");
|
|
48001
49810
|
return lupa.css({ target, file: file2 });
|
|
48002
49811
|
case "outline":
|
|
48003
|
-
return lupa.outline({ file: file2, page: str(v, "page"), depth:
|
|
49812
|
+
return lupa.outline({ file: file2, page: str(v, "page"), depth: num2(v, "depth", 1, 4) });
|
|
48004
49813
|
case "find":
|
|
48005
49814
|
if (!target) throw new UsageError("find needs a query");
|
|
48006
49815
|
return lupa.find({
|
|
@@ -48010,7 +49819,7 @@ ${deliver(await lupa.screenshot({ target, file: file2 }), void 0, "screenshot")}
|
|
|
48010
49819
|
types: v.type?.map((t) => t.toUpperCase()),
|
|
48011
49820
|
page: str(v, "page"),
|
|
48012
49821
|
within: str(v, "within"),
|
|
48013
|
-
limit:
|
|
49822
|
+
limit: num2(v, "limit", 1, 200)
|
|
48014
49823
|
});
|
|
48015
49824
|
case "compare": {
|
|
48016
49825
|
if (!v.url === !v.image) throw new UsageError("compare needs --url (your running page) or --image (a PNG screenshot)");
|
|
@@ -48021,7 +49830,7 @@ ${deliver(await lupa.screenshot({ target, file: file2 }), void 0, "screenshot")}
|
|
|
48021
49830
|
selector: str(v, "selector"),
|
|
48022
49831
|
waitFor: str(v, "wait-for"),
|
|
48023
49832
|
image: str(v, "image"),
|
|
48024
|
-
threshold:
|
|
49833
|
+
threshold: num2(v, "threshold", 0, 1)
|
|
48025
49834
|
});
|
|
48026
49835
|
return deliver(res, str(v, "out"), "compare");
|
|
48027
49836
|
}
|
|
@@ -48033,7 +49842,7 @@ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
|
48033
49842
|
function spawnHub(port) {
|
|
48034
49843
|
const dir = imageDir();
|
|
48035
49844
|
mkdirSync2(dir, { recursive: true });
|
|
48036
|
-
const logFile =
|
|
49845
|
+
const logFile = path6.join(dir, "hub.log");
|
|
48037
49846
|
const log = openSync(logFile, "a");
|
|
48038
49847
|
const entry = fileURLToPath3(import.meta.url);
|
|
48039
49848
|
spawn(process.execPath, [...process.execArgv, entry, "serve", "--port", String(port)], {
|
|
@@ -48134,16 +49943,16 @@ async function runCli(argv, io = { out: (t) => process.stdout.write(`${t}
|
|
|
48134
49943
|
${USAGE}`);
|
|
48135
49944
|
return 2;
|
|
48136
49945
|
}
|
|
48137
|
-
let
|
|
49946
|
+
let values2;
|
|
48138
49947
|
let positionals;
|
|
48139
49948
|
try {
|
|
48140
|
-
({ values, positionals } = parseArgs({ args: rest, options: { ...GLOBAL, ...spec }, allowPositionals: true, strict: true }));
|
|
49949
|
+
({ values: values2, positionals } = parseArgs({ args: rest, options: { ...GLOBAL, ...spec }, allowPositionals: true, strict: true }));
|
|
48141
49950
|
} catch (e) {
|
|
48142
49951
|
io.err(`${e.message}
|
|
48143
49952
|
Run lupa help.`);
|
|
48144
49953
|
return 2;
|
|
48145
49954
|
}
|
|
48146
|
-
if (
|
|
49955
|
+
if (values2.help) {
|
|
48147
49956
|
io.out(USAGE);
|
|
48148
49957
|
return 0;
|
|
48149
49958
|
}
|
|
@@ -48152,7 +49961,7 @@ Run lupa help.`);
|
|
|
48152
49961
|
return 0;
|
|
48153
49962
|
}
|
|
48154
49963
|
if (cmd === "setup") {
|
|
48155
|
-
io.out(await setup({ skillsDir: str(
|
|
49964
|
+
io.out(await setup({ skillsDir: str(values2, "skills-dir"), checkBrowser }));
|
|
48156
49965
|
return 0;
|
|
48157
49966
|
}
|
|
48158
49967
|
if (cmd === "update") {
|
|
@@ -48164,8 +49973,8 @@ Run lupa help.`);
|
|
|
48164
49973
|
let port;
|
|
48165
49974
|
let idle;
|
|
48166
49975
|
try {
|
|
48167
|
-
port =
|
|
48168
|
-
idle =
|
|
49976
|
+
port = num2(values2, "port", 1, 65535) ?? Number(process.env.LUPA_PORT ?? DEFAULT_PORT);
|
|
49977
|
+
idle = num2(values2, "idle", 0, 7 * 24 * 60) ?? 60;
|
|
48169
49978
|
} catch (e) {
|
|
48170
49979
|
io.err(e.message);
|
|
48171
49980
|
return 2;
|
|
@@ -48187,7 +49996,7 @@ Run lupa help.`);
|
|
|
48187
49996
|
if (!bridge) ({ bridge, fresh } = await joinHub(port, (m) => debug && io.err(`[lupa] ${m}`)));
|
|
48188
49997
|
const lupa = new Lupa(bridge);
|
|
48189
49998
|
if (fresh) lupa.pluginWaitMs = 8e3;
|
|
48190
|
-
io.out(await run(cmd,
|
|
49999
|
+
io.out(await run(cmd, values2, positionals, lupa));
|
|
48191
50000
|
for (const line of [...pluginWarnings(bridge.list()), updateNotice()]) if (line) io.err(`lupa: ${line}`);
|
|
48192
50001
|
return 0;
|
|
48193
50002
|
} catch (e) {
|