figma-local 1.4.0 → 1.5.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/package.json +1 -1
- package/src/index.js +14 -14
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -8560,14 +8560,14 @@ Examples:
|
|
|
8560
8560
|
if (!sel || sel.length === 0) return { error: 'Nothing selected in Figma. Select a frame or layer first.' };
|
|
8561
8561
|
const node = sel[0];
|
|
8562
8562
|
function walk(n, depth) {
|
|
8563
|
-
if (depth >
|
|
8563
|
+
if (depth > 20) return { type: n.type, name: n.name };
|
|
8564
8564
|
const obj = { type: n.type, name: n.name };
|
|
8565
8565
|
if (n.width) obj.w = Math.round(n.width);
|
|
8566
8566
|
if (n.height) obj.h = Math.round(n.height);
|
|
8567
|
-
if (n.type === 'TEXT') obj.text = n.characters
|
|
8567
|
+
if (n.type === 'TEXT') obj.text = n.characters;
|
|
8568
8568
|
if (n.fills && n.fills.length) obj.fills = n.fills.map(f => f.type === 'SOLID' ? { r: Math.round(f.color.r*255), g: Math.round(f.color.g*255), b: Math.round(f.color.b*255) } : { type: f.type });
|
|
8569
8569
|
if (n.cornerRadius) obj.radius = n.cornerRadius;
|
|
8570
|
-
if (n.children) obj.children = n.children.
|
|
8570
|
+
if (n.children) obj.children = n.children.map(c => walk(c, depth + 1));
|
|
8571
8571
|
return obj;
|
|
8572
8572
|
}
|
|
8573
8573
|
return { selected: sel.length, node: walk(node, 0) };
|
|
@@ -8598,14 +8598,14 @@ Examples:
|
|
|
8598
8598
|
const node = figma.getNodeById('${nodeId}');
|
|
8599
8599
|
if (!node) return { error: 'Node ${nodeId} not found on the current page.' };
|
|
8600
8600
|
function walk(n, depth) {
|
|
8601
|
-
if (depth >
|
|
8601
|
+
if (depth > 20) return { type: n.type, name: n.name };
|
|
8602
8602
|
const obj = { type: n.type, name: n.name };
|
|
8603
8603
|
if (n.width) obj.w = Math.round(n.width);
|
|
8604
8604
|
if (n.height) obj.h = Math.round(n.height);
|
|
8605
|
-
if (n.type === 'TEXT') obj.text = n.characters
|
|
8605
|
+
if (n.type === 'TEXT') obj.text = n.characters;
|
|
8606
8606
|
if (n.fills && n.fills.length) obj.fills = n.fills.map(f => f.type === 'SOLID' ? { r: Math.round(f.color.r*255), g: Math.round(f.color.g*255), b: Math.round(f.color.b*255) } : { type: f.type });
|
|
8607
8607
|
if (n.cornerRadius) obj.radius = n.cornerRadius;
|
|
8608
|
-
if (n.children) obj.children = n.children.
|
|
8608
|
+
if (n.children) obj.children = n.children.map(c => walk(c, depth + 1));
|
|
8609
8609
|
return obj;
|
|
8610
8610
|
}
|
|
8611
8611
|
return { nodeId: '${nodeId}', node: walk(node, 0) };
|
|
@@ -8999,7 +8999,7 @@ const INSPECT_CODE = `(function() {
|
|
|
8999
8999
|
// Children summary
|
|
9000
9000
|
if (node.children && node.children.length > 0) {
|
|
9001
9001
|
spec.childCount = node.children.length;
|
|
9002
|
-
spec.children = node.children.
|
|
9002
|
+
spec.children = node.children.map(function(c) {
|
|
9003
9003
|
return { name: c.name, type: c.type, w: c.width ? Math.round(c.width) : undefined, h: c.height ? Math.round(c.height) : undefined };
|
|
9004
9004
|
});
|
|
9005
9005
|
}
|
|
@@ -9007,9 +9007,9 @@ const INSPECT_CODE = `(function() {
|
|
|
9007
9007
|
return spec;
|
|
9008
9008
|
}
|
|
9009
9009
|
|
|
9010
|
-
// Inspect all selected nodes
|
|
9010
|
+
// Inspect all selected nodes
|
|
9011
9011
|
var results = [];
|
|
9012
|
-
var count =
|
|
9012
|
+
var count = sel.length;
|
|
9013
9013
|
for (var i = 0; i < count; i++) {
|
|
9014
9014
|
results.push(inspectNode(sel[i]));
|
|
9015
9015
|
}
|
|
@@ -9083,7 +9083,7 @@ Examples:
|
|
|
9083
9083
|
${options.node ? `node = figma.getNodeById('${options.node}');` : ''}
|
|
9084
9084
|
${options.link ? `node = figma.getNodeById('${parseNodeIdFromLink(options.link)}');` : ''}
|
|
9085
9085
|
if (!node || !node.children) return [];
|
|
9086
|
-
return node.children.
|
|
9086
|
+
return node.children.map(function(c) { return c.id; });
|
|
9087
9087
|
})()`;
|
|
9088
9088
|
const childIds = await daemonExec('eval', { code: childIdsCode });
|
|
9089
9089
|
if (Array.isArray(childIds)) {
|
|
@@ -9199,7 +9199,7 @@ function formatInspectSpec(spec) {
|
|
|
9199
9199
|
if (t.textAlign) lines.push(` Text align: ${t.textAlign}`);
|
|
9200
9200
|
if (t.textDecoration) lines.push(` Decoration: ${t.textDecoration}`);
|
|
9201
9201
|
if (t.textTransform) lines.push(` Transform: ${t.textTransform}`);
|
|
9202
|
-
if (t.content) lines.push(` Content: "${t.content
|
|
9202
|
+
if (t.content) lines.push(` Content: "${t.content}"`);
|
|
9203
9203
|
}
|
|
9204
9204
|
|
|
9205
9205
|
// Effects
|
|
@@ -9530,7 +9530,7 @@ function formatCSS(node) {
|
|
|
9530
9530
|
}
|
|
9531
9531
|
lines.push('}');
|
|
9532
9532
|
if (node.text) {
|
|
9533
|
-
lines.push(chalk.gray(`/* Content: "${node.text
|
|
9533
|
+
lines.push(chalk.gray(`/* Content: "${node.text}" */`));
|
|
9534
9534
|
}
|
|
9535
9535
|
return lines.join('\n');
|
|
9536
9536
|
}
|
|
@@ -9610,7 +9610,7 @@ function formatTailwind(node) {
|
|
|
9610
9610
|
const lines = [];
|
|
9611
9611
|
lines.push(chalk.gray(`{/* ${node.name} */}`));
|
|
9612
9612
|
lines.push(`className="${classes.join(' ')}"`);
|
|
9613
|
-
if (node.text) lines.push(chalk.gray(`{/* "${node.text
|
|
9613
|
+
if (node.text) lines.push(chalk.gray(`{/* "${node.text}" */}`));
|
|
9614
9614
|
return lines.join('\n');
|
|
9615
9615
|
}
|
|
9616
9616
|
|
|
@@ -9889,7 +9889,7 @@ const DOCUMENT_CODE = `(function() {
|
|
|
9889
9889
|
}
|
|
9890
9890
|
|
|
9891
9891
|
function extractNode(node, depth) {
|
|
9892
|
-
if (depth >
|
|
9892
|
+
if (depth > 30) return null;
|
|
9893
9893
|
var n = { name: node.name, type: node.type };
|
|
9894
9894
|
|
|
9895
9895
|
// Dimensions
|