figma-lupa 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +80 -35
- package/dist/server.js +79 -34
- package/package.json +1 -1
- package/plugin/dist/code.js +1 -1
package/dist/cli.js
CHANGED
|
@@ -3743,7 +3743,7 @@ var init_package = __esm({
|
|
|
3743
3743
|
"package.json"() {
|
|
3744
3744
|
package_default = {
|
|
3745
3745
|
name: "figma-lupa",
|
|
3746
|
-
version: "0.2.
|
|
3746
|
+
version: "0.2.2",
|
|
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",
|
|
@@ -6142,43 +6142,62 @@ var init_format = __esm({
|
|
|
6142
6142
|
});
|
|
6143
6143
|
|
|
6144
6144
|
// src/tools/project.ts
|
|
6145
|
+
import { execFile } from "node:child_process";
|
|
6145
6146
|
import { readdir, readFile as readFile2 } from "node:fs/promises";
|
|
6146
6147
|
import os3 from "node:os";
|
|
6147
6148
|
import path3 from "node:path";
|
|
6148
|
-
|
|
6149
|
+
import { promisify } from "node:util";
|
|
6150
|
+
async function scanProject(root, exclude = [], maxEntries = MAX_ENTRIES) {
|
|
6149
6151
|
root = path3.resolve(root);
|
|
6150
6152
|
if (root === path3.parse(root).root || root === os3.homedir()) return void 0;
|
|
6151
|
-
const skip = new Set(exclude.map((e) => path3.resolve(e)));
|
|
6153
|
+
const skip = [...new Set(exclude.map((e) => path3.resolve(e)))];
|
|
6152
6154
|
const styles = [];
|
|
6153
6155
|
const svgs = [];
|
|
6154
6156
|
const comps = [];
|
|
6155
|
-
const
|
|
6156
|
-
let
|
|
6157
|
-
const
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
|
|
6157
|
+
const shown = (p) => path3.relative(process.cwd(), p).split(path3.sep).join("/");
|
|
6158
|
+
let incomplete;
|
|
6159
|
+
const sort = (p) => {
|
|
6160
|
+
const name = path3.basename(p);
|
|
6161
|
+
if (STYLE.test(name)) styles.push(p);
|
|
6162
|
+
else if (/\.svg$/i.test(name)) svgs.push(p);
|
|
6163
|
+
else if (COMPONENT_FILE.test(name)) comps.push(p);
|
|
6164
|
+
};
|
|
6165
|
+
const skipped = (p) => skip.some((s) => p === s || p.startsWith(s + path3.sep));
|
|
6166
|
+
const tracked = await gitFiles(root);
|
|
6167
|
+
if (tracked?.length) {
|
|
6168
|
+
for (const p of tracked) {
|
|
6169
|
+
const dirs = path3.relative(root, p).split(path3.sep).slice(0, -1);
|
|
6170
|
+
if (!dirs.some((d) => d.startsWith(".") || SKIP_DIRS.has(d)) && !skipped(p)) sort(p);
|
|
6164
6171
|
}
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
if (
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
else if (/\.svg$/i.test(e.name)) svgs.push(p);
|
|
6174
|
-
else if (COMPONENT_FILE.test(e.name)) comps.push(p);
|
|
6172
|
+
} else {
|
|
6173
|
+
const started = Date.now();
|
|
6174
|
+
let entries = 0;
|
|
6175
|
+
const walk = async (dir, depth) => {
|
|
6176
|
+
if (depth > 10) return;
|
|
6177
|
+
if (entries > maxEntries || Date.now() - started > MAX_MS) {
|
|
6178
|
+
incomplete ??= `stopped after ${entries > maxEntries ? `${maxEntries} entries` : `${MAX_MS / 1e3}s`}, before ${shown(dir) || "."}`;
|
|
6179
|
+
return;
|
|
6175
6180
|
}
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6181
|
+
let list;
|
|
6182
|
+
try {
|
|
6183
|
+
list = await readdir(dir, { withFileTypes: true });
|
|
6184
|
+
} catch {
|
|
6185
|
+
return;
|
|
6186
|
+
}
|
|
6187
|
+
entries += list.length;
|
|
6188
|
+
list.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
6189
|
+
for (const e of list) {
|
|
6190
|
+
const p = path3.join(dir, e.name);
|
|
6191
|
+
if (e.isDirectory()) {
|
|
6192
|
+
if (!e.name.startsWith(".") && !SKIP_DIRS.has(e.name) && !skipped(p)) await walk(p, depth + 1);
|
|
6193
|
+
} else if (e.isFile()) sort(p);
|
|
6194
|
+
}
|
|
6195
|
+
};
|
|
6196
|
+
await walk(root, 0);
|
|
6197
|
+
}
|
|
6198
|
+
if (styles.length > MAX_STYLES) incomplete ??= `read only the first ${MAX_STYLES} of ${styles.length} stylesheets`;
|
|
6179
6199
|
const idx = { colors: /* @__PURE__ */ new Map(), fonts: /* @__PURE__ */ new Map(), icons: /* @__PURE__ */ new Map(), components: /* @__PURE__ */ new Map(), textStyles: [] };
|
|
6180
6200
|
const rules = [];
|
|
6181
|
-
const shown = (p) => path3.relative(process.cwd(), p).split(path3.sep).join("/");
|
|
6182
6201
|
const add = (m, key, ref2) => {
|
|
6183
6202
|
const list = m.get(key) ?? [];
|
|
6184
6203
|
if (!list.includes(ref2)) list.push(ref2);
|
|
@@ -6186,7 +6205,7 @@ async function scanProject(root, exclude = []) {
|
|
|
6186
6205
|
};
|
|
6187
6206
|
const vars = /* @__PURE__ */ new Map();
|
|
6188
6207
|
const classes = /* @__PURE__ */ new Map();
|
|
6189
|
-
for (const f of styles.slice(0,
|
|
6208
|
+
for (const f of styles.slice(0, MAX_STYLES)) {
|
|
6190
6209
|
const css = await readText(f, 1e6);
|
|
6191
6210
|
if (!css) continue;
|
|
6192
6211
|
const text2 = css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
|
|
@@ -6248,7 +6267,7 @@ async function scanProject(root, exclude = []) {
|
|
|
6248
6267
|
const t = textStyle(r.decls, family);
|
|
6249
6268
|
if (t) idx.textStyles.push({ ...t, ref: `.${r.cls} (${r.file})` });
|
|
6250
6269
|
}
|
|
6251
|
-
for (const f of svgs.slice(0,
|
|
6270
|
+
for (const f of svgs.slice(0, MAX_SVGS)) {
|
|
6252
6271
|
const svg = await readText(f, 64e3);
|
|
6253
6272
|
const s = svg && shapeOf(svg);
|
|
6254
6273
|
if (!s) continue;
|
|
@@ -6263,8 +6282,29 @@ async function scanProject(root, exclude = []) {
|
|
|
6263
6282
|
add(idx.components, slug2(stem), shown(f));
|
|
6264
6283
|
}
|
|
6265
6284
|
for (const [c, f] of classes) add(idx.components, c.toLowerCase(), `.${c} (${f})`);
|
|
6285
|
+
if (svgs.length > MAX_SVGS) incomplete ??= `read only the first ${MAX_SVGS} of ${svgs.length} SVG files`;
|
|
6286
|
+
if (incomplete) idx.incomplete = `project scan of ${shown(root) || "."} ${incomplete}`;
|
|
6266
6287
|
const empty = !idx.colors.size && !idx.fonts.size && !idx.icons.size && !idx.components.size && !idx.textStyles.length;
|
|
6267
|
-
return empty ? void 0 : idx;
|
|
6288
|
+
return empty && !incomplete ? void 0 : idx;
|
|
6289
|
+
}
|
|
6290
|
+
async function gitFiles(root) {
|
|
6291
|
+
try {
|
|
6292
|
+
const { stdout } = await promisify(execFile)("git", ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], {
|
|
6293
|
+
cwd: root,
|
|
6294
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
6295
|
+
timeout: 1e4
|
|
6296
|
+
});
|
|
6297
|
+
return stdout.split("\0").filter(Boolean).map((f) => path3.join(root, f));
|
|
6298
|
+
} catch {
|
|
6299
|
+
return void 0;
|
|
6300
|
+
}
|
|
6301
|
+
}
|
|
6302
|
+
function withScanNote(text2, idx) {
|
|
6303
|
+
if (!idx?.incomplete) return text2;
|
|
6304
|
+
return `${text2}
|
|
6305
|
+
|
|
6306
|
+
## project scan incomplete
|
|
6307
|
+
${idx.incomplete}: a colour, font, icon or component without a project match may still exist, so search the code before adding a copy`;
|
|
6268
6308
|
}
|
|
6269
6309
|
function firstFamily(stack) {
|
|
6270
6310
|
return stack.split(",")[0].trim().replace(/^["']|["']$/g, "").toLowerCase();
|
|
@@ -6558,7 +6598,7 @@ function absolutePath(d) {
|
|
|
6558
6598
|
}
|
|
6559
6599
|
return { key, vals };
|
|
6560
6600
|
}
|
|
6561
|
-
var TEXT_PROPS, SKIP_DIRS, STYLE, COMPONENT_FILE, NOT_COMPONENT, MAX_ENTRIES, MAX_MS, WEIGHTS, hex22, pct, ARGS;
|
|
6601
|
+
var TEXT_PROPS, SKIP_DIRS, STYLE, COMPONENT_FILE, NOT_COMPONENT, MAX_ENTRIES, MAX_MS, MAX_STYLES, MAX_SVGS, WEIGHTS, hex22, pct, ARGS;
|
|
6562
6602
|
var init_project = __esm({
|
|
6563
6603
|
"src/tools/project.ts"() {
|
|
6564
6604
|
"use strict";
|
|
@@ -6578,13 +6618,17 @@ var init_project = __esm({
|
|
|
6578
6618
|
"Pods",
|
|
6579
6619
|
"DerivedData",
|
|
6580
6620
|
"tmp",
|
|
6581
|
-
"temp"
|
|
6621
|
+
"temp",
|
|
6622
|
+
"_build",
|
|
6623
|
+
"deps"
|
|
6582
6624
|
]);
|
|
6583
6625
|
STYLE = /\.(css|scss|sass|less|styl|pcss)$/i;
|
|
6584
6626
|
COMPONENT_FILE = /\.(tsx|jsx|vue|svelte|astro)$/i;
|
|
6585
6627
|
NOT_COMPONENT = /^(index|page|layout|main|app|route|\+page|\+layout)$|\.(test|spec|stories|story)$/i;
|
|
6586
6628
|
MAX_ENTRIES = 3e4;
|
|
6587
6629
|
MAX_MS = 2e3;
|
|
6630
|
+
MAX_STYLES = 600;
|
|
6631
|
+
MAX_SVGS = 3e3;
|
|
6588
6632
|
WEIGHTS = { normal: 400, bold: 700, lighter: 300, bolder: 700 };
|
|
6589
6633
|
hex22 = (v) => Math.round(Math.max(0, Math.min(255, v))).toString(16).padStart(2, "0");
|
|
6590
6634
|
pct = (s, full) => s.endsWith("%") ? parseFloat(s) / 100 * full : parseFloat(s);
|
|
@@ -9510,14 +9554,14 @@ var init_ops = __esm({
|
|
|
9510
9554
|
if (!snap.roots.length) throw new Error(`Nothing found for ${r.ids.join(", ")}${snap.missing.length ? " (not in this file, or deleted)" : ""}`);
|
|
9511
9555
|
const index = await scan;
|
|
9512
9556
|
const opts = { budget: o.budget ?? 8e3, components: o.components ?? "auto", project: index && projectHints(index) };
|
|
9513
|
-
if (!o.assetsDir) return renderSnapshot(snap, opts).text;
|
|
9557
|
+
if (!o.assetsDir) return withScanNote(renderSnapshot(snap, opts).text, index);
|
|
9514
9558
|
const defs = printedDefs(snap, opts.components);
|
|
9515
9559
|
const written = await writeAssets(this.bridge, snap, r.file, { dir: o.assetsDir, currentColor: o.currentColor, defs, project: index });
|
|
9516
9560
|
const text2 = renderSnapshot(snap, { ...opts, files: { ...written, dir: o.assetsDir } }).text;
|
|
9517
|
-
return written.failures.length ? `${text2}
|
|
9561
|
+
return withScanNote(written.failures.length ? `${text2}
|
|
9518
9562
|
|
|
9519
9563
|
## asset export failures
|
|
9520
|
-
${written.failures.join("\n")}` : text2;
|
|
9564
|
+
${written.failures.join("\n")}` : text2, index);
|
|
9521
9565
|
}
|
|
9522
9566
|
async screenshot(o) {
|
|
9523
9567
|
const r = await this.resolve(o.target, o.file);
|
|
@@ -9527,7 +9571,8 @@ ${written.failures.join("\n")}` : text2;
|
|
|
9527
9571
|
const r = await this.resolve(o.target, o.file);
|
|
9528
9572
|
const dir = o.dir ?? "figma-assets";
|
|
9529
9573
|
const project = o.as === "auto" || !o.as ? await scanProject(process.cwd(), [dir]).catch(() => void 0) : void 0;
|
|
9530
|
-
|
|
9574
|
+
const text2 = await exportAssets(this.bridge, r.ids, r.file, { dir, as: o.as ?? "auto", scale: o.scale, currentColor: o.currentColor, project });
|
|
9575
|
+
return withScanNote(text2, project);
|
|
9531
9576
|
}
|
|
9532
9577
|
async tokens(o) {
|
|
9533
9578
|
await this.connect();
|
package/dist/server.js
CHANGED
|
@@ -42436,7 +42436,7 @@ var import_websocket_server = __toESM(require_websocket_server(), 1);
|
|
|
42436
42436
|
// package.json
|
|
42437
42437
|
var package_default = {
|
|
42438
42438
|
name: "figma-lupa",
|
|
42439
|
-
version: "0.2.
|
|
42439
|
+
version: "0.2.2",
|
|
42440
42440
|
description: "Read-only Figma CLI, MCP server and plugin for pixel-faithful design-to-code with a small context footprint.",
|
|
42441
42441
|
type: "module",
|
|
42442
42442
|
license: "GPL-3.0-or-later",
|
|
@@ -44760,9 +44760,11 @@ import { mkdir as mkdir2, readFile as readFile3, writeFile as writeFile2 } from
|
|
|
44760
44760
|
import path3 from "node:path";
|
|
44761
44761
|
|
|
44762
44762
|
// src/tools/project.ts
|
|
44763
|
+
import { execFile } from "node:child_process";
|
|
44763
44764
|
import { readdir, readFile as readFile2 } from "node:fs/promises";
|
|
44764
44765
|
import os2 from "node:os";
|
|
44765
44766
|
import path2 from "node:path";
|
|
44767
|
+
import { promisify } from "node:util";
|
|
44766
44768
|
var TEXT_PROPS = /^(font(-[\w-]+)?|line-height|letter-spacing|text-transform|text-decoration[\w-]*|color|-webkit-font-smoothing|-moz-osx-font-smoothing|text-rendering)$/;
|
|
44767
44769
|
var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
44768
44770
|
"node_modules",
|
|
@@ -44779,47 +44781,68 @@ var SKIP_DIRS = /* @__PURE__ */ new Set([
|
|
|
44779
44781
|
"Pods",
|
|
44780
44782
|
"DerivedData",
|
|
44781
44783
|
"tmp",
|
|
44782
|
-
"temp"
|
|
44784
|
+
"temp",
|
|
44785
|
+
"_build",
|
|
44786
|
+
"deps"
|
|
44783
44787
|
]);
|
|
44784
44788
|
var STYLE = /\.(css|scss|sass|less|styl|pcss)$/i;
|
|
44785
44789
|
var COMPONENT_FILE = /\.(tsx|jsx|vue|svelte|astro)$/i;
|
|
44786
44790
|
var NOT_COMPONENT = /^(index|page|layout|main|app|route|\+page|\+layout)$|\.(test|spec|stories|story)$/i;
|
|
44787
44791
|
var MAX_ENTRIES = 3e4;
|
|
44788
44792
|
var MAX_MS = 2e3;
|
|
44789
|
-
|
|
44793
|
+
var MAX_STYLES = 600;
|
|
44794
|
+
var MAX_SVGS = 3e3;
|
|
44795
|
+
async function scanProject(root, exclude = [], maxEntries = MAX_ENTRIES) {
|
|
44790
44796
|
root = path2.resolve(root);
|
|
44791
44797
|
if (root === path2.parse(root).root || root === os2.homedir()) return void 0;
|
|
44792
|
-
const skip = new Set(exclude.map((e) => path2.resolve(e)));
|
|
44798
|
+
const skip = [...new Set(exclude.map((e) => path2.resolve(e)))];
|
|
44793
44799
|
const styles = [];
|
|
44794
44800
|
const svgs = [];
|
|
44795
44801
|
const comps = [];
|
|
44796
|
-
const
|
|
44797
|
-
let
|
|
44798
|
-
const
|
|
44799
|
-
|
|
44800
|
-
|
|
44801
|
-
|
|
44802
|
-
|
|
44803
|
-
|
|
44804
|
-
|
|
44802
|
+
const shown = (p) => path2.relative(process.cwd(), p).split(path2.sep).join("/");
|
|
44803
|
+
let incomplete;
|
|
44804
|
+
const sort = (p) => {
|
|
44805
|
+
const name = path2.basename(p);
|
|
44806
|
+
if (STYLE.test(name)) styles.push(p);
|
|
44807
|
+
else if (/\.svg$/i.test(name)) svgs.push(p);
|
|
44808
|
+
else if (COMPONENT_FILE.test(name)) comps.push(p);
|
|
44809
|
+
};
|
|
44810
|
+
const skipped = (p) => skip.some((s) => p === s || p.startsWith(s + path2.sep));
|
|
44811
|
+
const tracked = await gitFiles(root);
|
|
44812
|
+
if (tracked?.length) {
|
|
44813
|
+
for (const p of tracked) {
|
|
44814
|
+
const dirs = path2.relative(root, p).split(path2.sep).slice(0, -1);
|
|
44815
|
+
if (!dirs.some((d) => d.startsWith(".") || SKIP_DIRS.has(d)) && !skipped(p)) sort(p);
|
|
44805
44816
|
}
|
|
44806
|
-
|
|
44807
|
-
|
|
44808
|
-
|
|
44809
|
-
|
|
44810
|
-
if (
|
|
44811
|
-
|
|
44812
|
-
|
|
44813
|
-
|
|
44814
|
-
else if (/\.svg$/i.test(e.name)) svgs.push(p);
|
|
44815
|
-
else if (COMPONENT_FILE.test(e.name)) comps.push(p);
|
|
44817
|
+
} else {
|
|
44818
|
+
const started = Date.now();
|
|
44819
|
+
let entries = 0;
|
|
44820
|
+
const walk = async (dir, depth) => {
|
|
44821
|
+
if (depth > 10) return;
|
|
44822
|
+
if (entries > maxEntries || Date.now() - started > MAX_MS) {
|
|
44823
|
+
incomplete ??= `stopped after ${entries > maxEntries ? `${maxEntries} entries` : `${MAX_MS / 1e3}s`}, before ${shown(dir) || "."}`;
|
|
44824
|
+
return;
|
|
44816
44825
|
}
|
|
44817
|
-
|
|
44818
|
-
|
|
44819
|
-
|
|
44826
|
+
let list;
|
|
44827
|
+
try {
|
|
44828
|
+
list = await readdir(dir, { withFileTypes: true });
|
|
44829
|
+
} catch {
|
|
44830
|
+
return;
|
|
44831
|
+
}
|
|
44832
|
+
entries += list.length;
|
|
44833
|
+
list.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
44834
|
+
for (const e of list) {
|
|
44835
|
+
const p = path2.join(dir, e.name);
|
|
44836
|
+
if (e.isDirectory()) {
|
|
44837
|
+
if (!e.name.startsWith(".") && !SKIP_DIRS.has(e.name) && !skipped(p)) await walk(p, depth + 1);
|
|
44838
|
+
} else if (e.isFile()) sort(p);
|
|
44839
|
+
}
|
|
44840
|
+
};
|
|
44841
|
+
await walk(root, 0);
|
|
44842
|
+
}
|
|
44843
|
+
if (styles.length > MAX_STYLES) incomplete ??= `read only the first ${MAX_STYLES} of ${styles.length} stylesheets`;
|
|
44820
44844
|
const idx = { colors: /* @__PURE__ */ new Map(), fonts: /* @__PURE__ */ new Map(), icons: /* @__PURE__ */ new Map(), components: /* @__PURE__ */ new Map(), textStyles: [] };
|
|
44821
44845
|
const rules = [];
|
|
44822
|
-
const shown = (p) => path2.relative(process.cwd(), p).split(path2.sep).join("/");
|
|
44823
44846
|
const add = (m, key, ref2) => {
|
|
44824
44847
|
const list = m.get(key) ?? [];
|
|
44825
44848
|
if (!list.includes(ref2)) list.push(ref2);
|
|
@@ -44827,7 +44850,7 @@ async function scanProject(root, exclude = []) {
|
|
|
44827
44850
|
};
|
|
44828
44851
|
const vars = /* @__PURE__ */ new Map();
|
|
44829
44852
|
const classes = /* @__PURE__ */ new Map();
|
|
44830
|
-
for (const f of styles.slice(0,
|
|
44853
|
+
for (const f of styles.slice(0, MAX_STYLES)) {
|
|
44831
44854
|
const css = await readText(f, 1e6);
|
|
44832
44855
|
if (!css) continue;
|
|
44833
44856
|
const text2 = css.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
|
|
@@ -44889,7 +44912,7 @@ async function scanProject(root, exclude = []) {
|
|
|
44889
44912
|
const t = textStyle(r.decls, family);
|
|
44890
44913
|
if (t) idx.textStyles.push({ ...t, ref: `.${r.cls} (${r.file})` });
|
|
44891
44914
|
}
|
|
44892
|
-
for (const f of svgs.slice(0,
|
|
44915
|
+
for (const f of svgs.slice(0, MAX_SVGS)) {
|
|
44893
44916
|
const svg = await readText(f, 64e3);
|
|
44894
44917
|
const s = svg && shapeOf(svg);
|
|
44895
44918
|
if (!s) continue;
|
|
@@ -44904,8 +44927,29 @@ async function scanProject(root, exclude = []) {
|
|
|
44904
44927
|
add(idx.components, slug2(stem), shown(f));
|
|
44905
44928
|
}
|
|
44906
44929
|
for (const [c, f] of classes) add(idx.components, c.toLowerCase(), `.${c} (${f})`);
|
|
44930
|
+
if (svgs.length > MAX_SVGS) incomplete ??= `read only the first ${MAX_SVGS} of ${svgs.length} SVG files`;
|
|
44931
|
+
if (incomplete) idx.incomplete = `project scan of ${shown(root) || "."} ${incomplete}`;
|
|
44907
44932
|
const empty = !idx.colors.size && !idx.fonts.size && !idx.icons.size && !idx.components.size && !idx.textStyles.length;
|
|
44908
|
-
return empty ? void 0 : idx;
|
|
44933
|
+
return empty && !incomplete ? void 0 : idx;
|
|
44934
|
+
}
|
|
44935
|
+
async function gitFiles(root) {
|
|
44936
|
+
try {
|
|
44937
|
+
const { stdout } = await promisify(execFile)("git", ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], {
|
|
44938
|
+
cwd: root,
|
|
44939
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
44940
|
+
timeout: 1e4
|
|
44941
|
+
});
|
|
44942
|
+
return stdout.split("\0").filter(Boolean).map((f) => path2.join(root, f));
|
|
44943
|
+
} catch {
|
|
44944
|
+
return void 0;
|
|
44945
|
+
}
|
|
44946
|
+
}
|
|
44947
|
+
function withScanNote(text2, idx) {
|
|
44948
|
+
if (!idx?.incomplete) return text2;
|
|
44949
|
+
return `${text2}
|
|
44950
|
+
|
|
44951
|
+
## project scan incomplete
|
|
44952
|
+
${idx.incomplete}: a colour, font, icon or component without a project match may still exist, so search the code before adding a copy`;
|
|
44909
44953
|
}
|
|
44910
44954
|
function firstFamily(stack) {
|
|
44911
44955
|
return stack.split(",")[0].trim().replace(/^["']|["']$/g, "").toLowerCase();
|
|
@@ -45993,14 +46037,14 @@ var Lupa = class {
|
|
|
45993
46037
|
if (!snap.roots.length) throw new Error(`Nothing found for ${r.ids.join(", ")}${snap.missing.length ? " (not in this file, or deleted)" : ""}`);
|
|
45994
46038
|
const index = await scan;
|
|
45995
46039
|
const opts = { budget: o.budget ?? 8e3, components: o.components ?? "auto", project: index && projectHints(index) };
|
|
45996
|
-
if (!o.assetsDir) return renderSnapshot(snap, opts).text;
|
|
46040
|
+
if (!o.assetsDir) return withScanNote(renderSnapshot(snap, opts).text, index);
|
|
45997
46041
|
const defs = printedDefs(snap, opts.components);
|
|
45998
46042
|
const written = await writeAssets(this.bridge, snap, r.file, { dir: o.assetsDir, currentColor: o.currentColor, defs, project: index });
|
|
45999
46043
|
const text2 = renderSnapshot(snap, { ...opts, files: { ...written, dir: o.assetsDir } }).text;
|
|
46000
|
-
return written.failures.length ? `${text2}
|
|
46044
|
+
return withScanNote(written.failures.length ? `${text2}
|
|
46001
46045
|
|
|
46002
46046
|
## asset export failures
|
|
46003
|
-
${written.failures.join("\n")}` : text2;
|
|
46047
|
+
${written.failures.join("\n")}` : text2, index);
|
|
46004
46048
|
}
|
|
46005
46049
|
async screenshot(o) {
|
|
46006
46050
|
const r = await this.resolve(o.target, o.file);
|
|
@@ -46010,7 +46054,8 @@ ${written.failures.join("\n")}` : text2;
|
|
|
46010
46054
|
const r = await this.resolve(o.target, o.file);
|
|
46011
46055
|
const dir = o.dir ?? "figma-assets";
|
|
46012
46056
|
const project = o.as === "auto" || !o.as ? await scanProject(process.cwd(), [dir]).catch(() => void 0) : void 0;
|
|
46013
|
-
|
|
46057
|
+
const text2 = await exportAssets(this.bridge, r.ids, r.file, { dir, as: o.as ?? "auto", scale: o.scale, currentColor: o.currentColor, project });
|
|
46058
|
+
return withScanNote(text2, project);
|
|
46014
46059
|
}
|
|
46015
46060
|
async tokens(o) {
|
|
46016
46061
|
await this.connect();
|
package/package.json
CHANGED