@figma/code-connect 1.5.2 → 2.0.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/commands/connect.d.ts +6 -1
- package/dist/commands/connect.d.ts.map +1 -1
- package/dist/commands/connect.js +48 -24
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/preview_collapse.d.ts +7 -0
- package/dist/commands/preview_collapse.d.ts.map +1 -0
- package/dist/commands/preview_collapse.js +31 -0
- package/dist/commands/preview_collapse.js.map +1 -0
- package/dist/commands/preview_utils.d.ts +13 -1
- package/dist/commands/preview_utils.d.ts.map +1 -1
- package/dist/commands/preview_utils.js +95 -38
- package/dist/commands/preview_utils.js.map +1 -1
- package/dist/common/updates.d.ts +1 -4
- package/dist/common/updates.d.ts.map +1 -1
- package/dist/common/updates.js +3 -18
- package/dist/common/updates.js.map +1 -1
- package/dist/connect/wizard/run_wizard.d.ts.map +1 -1
- package/dist/connect/wizard/run_wizard.js +5 -2
- package/dist/connect/wizard/run_wizard.js.map +1 -1
- package/dist/react/parser.d.ts.map +1 -1
- package/dist/react/parser.js +6 -9
- package/dist/react/parser.js.map +1 -1
- package/figma-types-no-require.d.ts +1 -0
- package/figma-types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview_utils.d.ts","sourceRoot":"","sources":["../../src/commands/preview_utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAA6D,MAAM,WAAW,CAAA;AAElG,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG1D,OAAO,EAAyB,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC/E,OAAO,EAAE,OAAO,EAAgB,MAAM,iBAAiB,CAAA;AAEvD,OAAO,EAIL,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACvB,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"preview_utils.d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AY,EAAE,MAAM,EAAE,CAAA;IACtB,QAAQ,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IAC9E,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AAUD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EAAE,EACjB,4BAA4B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,EAAE,CAAC,GACnE,MAAM,EAAE,EAAE,CAyBZ;AA0DD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAKvE;AAkBD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,aAAa,EAAE,EACtB,OAAO,EAAE,MAAM,EACf,sBAAsB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,GAC3D,aAAa,EAAE,CA8FjB;AAwID,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAWhE;AAmLD;;GAEG;AACH,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,cAAc,iBA6EvE"}
|
|
@@ -37,6 +37,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.collectNodesToPreview = collectNodesToPreview;
|
|
40
|
+
exports.fetchComponentPropertyDefinitionsBatch = fetchComponentPropertyDefinitionsBatch;
|
|
40
41
|
exports.fetchComponentPropertyDefinitions = fetchComponentPropertyDefinitions;
|
|
41
42
|
exports.parsePropsArg = parsePropsArg;
|
|
42
43
|
exports.filterTemplatesForNodes = filterTemplatesForNodes;
|
|
@@ -48,6 +49,7 @@ exports.parseMaxCombinationsArg = parseMaxCombinationsArg;
|
|
|
48
49
|
exports.chunkNodeIdsForPreview = chunkNodeIdsForPreview;
|
|
49
50
|
exports.parseMissingProperty = parseMissingProperty;
|
|
50
51
|
exports.chunkOutcomeToResults = chunkOutcomeToResults;
|
|
52
|
+
exports.validatePreviewOptions = validatePreviewOptions;
|
|
51
53
|
exports.handlePreview = handlePreview;
|
|
52
54
|
const fs_1 = __importDefault(require("fs"));
|
|
53
55
|
const path_1 = __importDefault(require("path"));
|
|
@@ -61,6 +63,7 @@ const figma_rest_api_1 = require("../connect/figma_rest_api");
|
|
|
61
63
|
const fetch_1 = require("../common/fetch");
|
|
62
64
|
const property_list_table_1 = require("./property_list_table");
|
|
63
65
|
const property_combinations_1 = require("../connect/property_combinations");
|
|
66
|
+
const preview_collapse_1 = require("./preview_collapse");
|
|
64
67
|
/**
|
|
65
68
|
* Collect nodes to preview from file arguments.
|
|
66
69
|
* Matches by exact path first, then by basename.
|
|
@@ -140,48 +143,83 @@ async function collectNodesToPreview(files, allCodeConnectObjects, dir, cmd) {
|
|
|
140
143
|
}
|
|
141
144
|
return nodesToPreview;
|
|
142
145
|
}
|
|
146
|
+
// Keep the comma-separated `ids` query comfortably below common URL limits while still
|
|
147
|
+
// loading a few hundred components from the same design-system file together.
|
|
148
|
+
const PROPERTY_SCHEMA_BATCH_SIZE = 200;
|
|
143
149
|
/**
|
|
144
|
-
* Fetch
|
|
150
|
+
* Fetch property definitions for several nodes in one REST `files/:key/nodes` request.
|
|
151
|
+
* That endpoint accepts comma-separated IDs, and loading the same file once per node is
|
|
152
|
+
* especially expensive for large design-system files.
|
|
145
153
|
*/
|
|
146
|
-
async function
|
|
154
|
+
async function fetchNodeSchemaBatch(baseApiUrl, fileKey, nodeIds, accessToken) {
|
|
147
155
|
try {
|
|
148
|
-
const nodesUrl = `${baseApiUrl}/files/${fileKey}/nodes?ids=${
|
|
156
|
+
const nodesUrl = `${baseApiUrl}/files/${fileKey}/nodes?ids=${nodeIds.join(',')}`;
|
|
149
157
|
const resp = await fetch_1.request.get(nodesUrl, { headers: (0, figma_rest_api_1.getHeaders)(accessToken) });
|
|
150
158
|
if (resp.response.status !== 200) {
|
|
151
|
-
logging_1.logger.debug(`files/nodes returned ${resp.response.status} for ${
|
|
152
|
-
return { status: 'error' };
|
|
159
|
+
logging_1.logger.debug(`files/nodes returned ${resp.response.status} for ${nodeIds.length} node(s)`);
|
|
160
|
+
return Object.fromEntries(nodeIds.map((nodeId) => [nodeId, { status: 'error' }]));
|
|
153
161
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
return Object.fromEntries(nodeIds.map((nodeId) => {
|
|
163
|
+
const node = resp.data.nodes?.[nodeId];
|
|
164
|
+
const componentSetId = node?.components?.[nodeId]?.componentSetId || undefined;
|
|
165
|
+
const defs = node?.document?.componentPropertyDefinitions;
|
|
166
|
+
if (defs && Object.keys(defs).length > 0) {
|
|
167
|
+
return [nodeId, { status: 'ok', defs, componentSetId }];
|
|
168
|
+
}
|
|
169
|
+
logging_1.logger.debug(`files/nodes returned no componentPropertyDefinitions for ${nodeId}`);
|
|
170
|
+
return [nodeId, { status: 'empty', componentSetId }];
|
|
171
|
+
}));
|
|
161
172
|
}
|
|
162
173
|
catch (err) {
|
|
163
174
|
const detail = (0, fetch_1.isFetchError)(err) ? `status ${err.response?.status}` : String(err);
|
|
164
|
-
logging_1.logger.debug(`files/nodes fetch failed for ${
|
|
165
|
-
return { status: 'error' };
|
|
175
|
+
logging_1.logger.debug(`files/nodes fetch failed for ${nodeIds.length} node(s) (${detail})`);
|
|
176
|
+
return Object.fromEntries(nodeIds.map((nodeId) => [nodeId, { status: 'error' }]));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async function fetchNodeSchemas(baseApiUrl, fileKey, nodeIds, accessToken) {
|
|
180
|
+
const results = {};
|
|
181
|
+
for (const batch of chunkArray([...new Set(nodeIds)], PROPERTY_SCHEMA_BATCH_SIZE)) {
|
|
182
|
+
Object.assign(results, await fetchNodeSchemaBatch(baseApiUrl, fileKey, batch, accessToken));
|
|
166
183
|
}
|
|
184
|
+
return results;
|
|
167
185
|
}
|
|
168
186
|
/**
|
|
169
|
-
* Fetch
|
|
187
|
+
* Fetch components' property definitions in batches: first the requested nodes, then
|
|
188
|
+
* any parent component sets discovered in those responses.
|
|
170
189
|
*/
|
|
190
|
+
async function fetchComponentPropertyDefinitionsBatch(baseApiUrl, fileKey, nodeIds, accessToken) {
|
|
191
|
+
const uniqueNodeIds = [...new Set(nodeIds)];
|
|
192
|
+
const nodeSchemas = await fetchNodeSchemas(baseApiUrl, fileKey, uniqueNodeIds, accessToken);
|
|
193
|
+
const requestedNodeIds = new Set(uniqueNodeIds);
|
|
194
|
+
const componentSetIds = [
|
|
195
|
+
...new Set(Object.values(nodeSchemas)
|
|
196
|
+
.map((node) => (node.status === 'error' ? undefined : node.componentSetId))
|
|
197
|
+
.filter((id) => !!id && !requestedNodeIds.has(id))),
|
|
198
|
+
];
|
|
199
|
+
const componentSetSchemas = await fetchNodeSchemas(baseApiUrl, fileKey, componentSetIds, accessToken);
|
|
200
|
+
return Object.fromEntries(uniqueNodeIds.map((nodeId) => {
|
|
201
|
+
const node = nodeSchemas[nodeId] ?? { status: 'error' };
|
|
202
|
+
if (node.status === 'error')
|
|
203
|
+
return [nodeId, { status: 'error' }];
|
|
204
|
+
// Variant child → resolve to the parent COMPONENT_SET (whose schema carries the
|
|
205
|
+
// variant axes). Fall back to the variant's own defs if the set can't be fetched.
|
|
206
|
+
if (node.componentSetId) {
|
|
207
|
+
const set = nodeSchemas[node.componentSetId] ?? componentSetSchemas[node.componentSetId];
|
|
208
|
+
if (set?.status === 'ok')
|
|
209
|
+
return [nodeId, { status: 'ok', defs: set.defs }];
|
|
210
|
+
logging_1.logger.debug(`Component set ${node.componentSetId} for variant ${nodeId} had no usable schema ` +
|
|
211
|
+
`(${set?.status ?? 'error'}); using the variant's own definitions`);
|
|
212
|
+
}
|
|
213
|
+
return [
|
|
214
|
+
nodeId,
|
|
215
|
+
node.status === 'ok' ? { status: 'ok', defs: node.defs } : { status: 'empty' },
|
|
216
|
+
];
|
|
217
|
+
}));
|
|
218
|
+
}
|
|
219
|
+
/** Fetch one component's property definitions. */
|
|
171
220
|
async function fetchComponentPropertyDefinitions(baseApiUrl, fileKey, nodeId, accessToken) {
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
return { status: 'error' };
|
|
175
|
-
// Variant child → resolve to the parent COMPONENT_SET (whose schema carries the
|
|
176
|
-
// variant axes). Fall back to the variant's own defs if the set can't be fetched.
|
|
177
|
-
if (node.componentSetId) {
|
|
178
|
-
const set = await fetchNodeSchema(baseApiUrl, fileKey, node.componentSetId, accessToken);
|
|
179
|
-
if (set.status === 'ok')
|
|
180
|
-
return { status: 'ok', defs: set.defs };
|
|
181
|
-
logging_1.logger.debug(`Component set ${node.componentSetId} for variant ${nodeId} had no usable schema ` +
|
|
182
|
-
`(${set.status}); using the variant's own definitions`);
|
|
183
|
-
}
|
|
184
|
-
return node.status === 'ok' ? { status: 'ok', defs: node.defs } : { status: 'empty' };
|
|
221
|
+
const results = await fetchComponentPropertyDefinitionsBatch(baseApiUrl, fileKey, [nodeId], accessToken);
|
|
222
|
+
return results[nodeId] ?? { status: 'error' };
|
|
185
223
|
}
|
|
186
224
|
/** Case-insensitive lookup of a `ComponentPropertyType` from a `--props` prefix token. */
|
|
187
225
|
function parsePropertyTypePrefix(token) {
|
|
@@ -326,9 +364,12 @@ function displayResults(results) {
|
|
|
326
364
|
console.log(` ${yellow(`⚠ ${result.unresolvedInstances.length} nested instance(s) not Code Connected: ${names}`)}`);
|
|
327
365
|
};
|
|
328
366
|
for (const result of results) {
|
|
329
|
-
|
|
367
|
+
const otherCombinations = (result.propertyCombinationCount ?? 1) - 1;
|
|
368
|
+
const moreCombinations = otherCombinations > 0
|
|
369
|
+
? ` (+${otherCombinations} more property combination${otherCombinations > 1 ? 's' : ''})`
|
|
370
|
+
: '';
|
|
330
371
|
const combinationSuffix = result.propertyCombinationLabel
|
|
331
|
-
? ` ${gray(`— ${result.propertyCombinationLabel}`)}`
|
|
372
|
+
? ` ${gray(`— ${result.propertyCombinationLabel}${moreCombinations}`)}`
|
|
332
373
|
: '';
|
|
333
374
|
if (result.success && result.snippet) {
|
|
334
375
|
const componentInfo = result.component ? ` ${gray(`→ ${result.component}`)}` : '';
|
|
@@ -654,12 +695,21 @@ async function handleInspect({ nodesByFileKey, configuredApiUrl, accessToken, ou
|
|
|
654
695
|
(0, property_list_table_1.displayPropertyList)(items);
|
|
655
696
|
}
|
|
656
697
|
}
|
|
698
|
+
/**
|
|
699
|
+
* `--unique` implies `--all`, so errors about combination expansion should name
|
|
700
|
+
* the flag the user actually typed rather than the one commander set on their
|
|
701
|
+
* behalf.
|
|
702
|
+
*/
|
|
703
|
+
function expandFlagName(cmd) {
|
|
704
|
+
return cmd.unique ? '--unique' : '--all';
|
|
705
|
+
}
|
|
657
706
|
function validatePreviewOptions(cmd) {
|
|
658
707
|
if (cmd.all && cmd.props) {
|
|
659
|
-
|
|
708
|
+
const implied = cmd.unique ? ' (which implies --all)' : '';
|
|
709
|
+
(0, logging_1.exitWithError)(`Cannot combine --props and ${expandFlagName(cmd)}${implied}; use one or the other`);
|
|
660
710
|
}
|
|
661
711
|
if (cmd.maxCombinations !== undefined && !cmd.all) {
|
|
662
|
-
(0, logging_1.exitWithError)('--max-combinations can only be used with --all');
|
|
712
|
+
(0, logging_1.exitWithError)('--max-combinations can only be used with --all or --unique');
|
|
663
713
|
}
|
|
664
714
|
}
|
|
665
715
|
async function buildPropertyPreviewInputs({ enabled, baseApiUrl, fileKey, nodes, accessToken, propsPairs, maxCombinations, }) {
|
|
@@ -667,8 +717,10 @@ async function buildPropertyPreviewInputs({ enabled, baseApiUrl, fileKey, nodes,
|
|
|
667
717
|
return {};
|
|
668
718
|
const propertyCombinationsByNodeId = {};
|
|
669
719
|
const availablePropsByNodeId = {};
|
|
670
|
-
|
|
671
|
-
|
|
720
|
+
const uniqueNodeIds = [...new Set(nodes.map((n) => n.nodeId))];
|
|
721
|
+
const definitionsByNodeId = await fetchComponentPropertyDefinitionsBatch(baseApiUrl, fileKey, uniqueNodeIds, accessToken);
|
|
722
|
+
for (const nodeId of uniqueNodeIds) {
|
|
723
|
+
const result = definitionsByNodeId[nodeId] ?? { status: 'error' };
|
|
672
724
|
if (result.status === 'error') {
|
|
673
725
|
logging_1.logger.warn(`Couldn't fetch property definitions for node ${nodeId} (ensure your token has the ` +
|
|
674
726
|
`Code Connect: Write and File content: Read scopes); rendering its default property combination only`);
|
|
@@ -778,9 +830,10 @@ async function handlePreview(files, cmd) {
|
|
|
778
830
|
const outputFormat = cmd.output || 'table';
|
|
779
831
|
const configuredApiUrl = cmd.apiUrl || projectInfo.config.apiUrl;
|
|
780
832
|
if (cmd.all && (!files || files.length === 0)) {
|
|
781
|
-
|
|
833
|
+
const flag = expandFlagName(cmd);
|
|
834
|
+
(0, logging_1.exitWithError)(`${flag} requires a specific component, e.g. \`figma connect preview Button.figma.ts ${flag}\``);
|
|
782
835
|
}
|
|
783
|
-
const allCodeConnectObjects = await (0, connect_1.getCodeConnectObjects)(cmd, projectInfo, true);
|
|
836
|
+
const allCodeConnectObjects = await (0, connect_1.getCodeConnectObjects)(cmd, projectInfo, { silent: true });
|
|
784
837
|
const nodesToCheck = files && files.length > 0
|
|
785
838
|
? await collectNodesToPreview(files, allCodeConnectObjects, dir, cmd)
|
|
786
839
|
: collectAllLocalNodesToPreview(allCodeConnectObjects, dir, cmd);
|
|
@@ -820,8 +873,12 @@ async function handlePreview(files, cmd) {
|
|
|
820
873
|
results.push(...fileResults);
|
|
821
874
|
}
|
|
822
875
|
await validateRenderedSnippets(results);
|
|
823
|
-
|
|
824
|
-
if (
|
|
876
|
+
const outputResults = cmd.unique ? (0, preview_collapse_1.collapsePreviewResults)(results) : results;
|
|
877
|
+
if (cmd.unique && outputResults.length !== results.length) {
|
|
878
|
+
logging_1.logger.info(`${outputResults.length} distinct of ${results.length} rendered property combinations`);
|
|
879
|
+
}
|
|
880
|
+
await outputPreviewResults(outputResults, outputFormat);
|
|
881
|
+
if (outputResults.every((r) => !r.success)) {
|
|
825
882
|
process.exit(1);
|
|
826
883
|
}
|
|
827
884
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview_utils.js","sourceRoot":"","sources":["../../src/commands/preview_utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,sDA0FC;AAqED,8EAqBC;AA0BD,sCAmBC;AAKD,0DAWC;AAiBD,oDAqBC;AAMD,kDAcC;AAMD,sCAsBC;AAUD,wCA0DC;AAgBD,0DAYC;AA6CD,wDA4BC;AA8DD,oDAKC;AAkBD,sDAmGC;AAsTD,sCAoEC;AA1lCD,4CAAmB;AACnB,gDAAuB;AACvB,kDAAyB;AACzB,mDAAoC;AACpC,uCAAkG;AAClG,+CAAyD;AAEzD,sDAAsD;AACtD,gDAAmD;AACnD,8DAA+E;AAC/E,2CAAuD;AACvD,+DAAkF;AAClF,4EAMyC;AAkCzC;;;GAGG;AACI,KAAK,UAAU,qBAAqB,CACzC,KAAe,EACf,qBAAwC,EACxC,GAAW,EACX,GAAgB;IAEhB,MAAM,cAAc,GAAoB,EAAE,CAAA;IAE1C,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;QAC7B,MAAM,YAAY,GAAG,cAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;QAEvF,uBAAuB;QACvB,IAAI,YAAE,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,YAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YACtE,MAAM,IAAI,GAAG,qBAAqB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,CAAC,EAAE,CAAC;QAC9D,MAAM,WAAW,GAAG,MAAM,mBAAmB,CAAC;YAC5C,OAAO;YACP,KAAK;YACL,gBAAgB;YAChB,WAAW;YACX,GAAG;YACH,qBAAqB;YACrB,0BAA0B,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,UAAU;YACnD,UAAU;YACV,eAAe;SAChB,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAA;IAC9B,CAAC;IAED,MAAM,wBAAwB,CAAC,OAAO,CAAC,CAAA;IACvC,MAAM,oBAAoB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;IAEjD,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport chalk from 'chalk'\nimport * as prettier from 'prettier'\nimport { BaseCommand, getCodeConnectObjects, getAccessTokenOrExit, setupHandler } from './connect'\nimport { exitWithError, logger } from '../common/logging'\nimport { CodeConnectJSON } from '../connect/figma_connect'\nimport { parseFigmaNode } from '../connect/validation'\nimport { getProjectInfo } from '../connect/project'\nimport { getApiUrl, getHeaders, FigmaRestApi } from '../connect/figma_rest_api'\nimport { request, isFetchError } from '../common/fetch'\nimport { displayPropertyList, type PropertyListItem } from './property_list_table'\nimport {\n enumeratePropertyCombinations,\n buildPropertyCombinationFromProps,\n toAvailableProperties,\n type PropertyCombination,\n type AvailableProperty,\n} from '../connect/property_combinations'\n\ntype PreviewCommand = BaseCommand & { output?: string }\n\nexport interface NodeToPreview {\n fileKey: string\n nodeId: string\n url: string\n filePath: string\n}\n\nexport interface PreviewResult {\n url: string\n nodeId: string\n filePath: string\n success: boolean\n snippet?: string\n language?: string\n component?: string\n error?: string\n /** Present when this result is one property combination of an expanded (--all) render. */\n propertyCombinationLabel?: string\n /** `kind: \"transport\"` marks a server/network failure, in which case no property vocabulary is attached. */\n errorDetails?: {\n kind?: string\n missingProperty?: string\n availableProperties?: AvailableProperty[]\n }\n /** Nested instances/slots that rendered as placeholders. Not an error — the snippet still rendered. */\n unresolvedInstances?: Array<{ guid: string; name?: string; kind: 'instance' | 'slot' }>\n}\n\ntype NodesByFileKey = Record<string, NodeToPreview[]>\n\n/**\n * Collect nodes to preview from file arguments.\n * Matches by exact path first, then by basename.\n */\nexport async function collectNodesToPreview(\n files: string[],\n allCodeConnectObjects: CodeConnectJSON[],\n dir: string,\n cmd: BaseCommand,\n): Promise<NodeToPreview[]> {\n const nodesToPreview: NodeToPreview[] = []\n\n for (const filePath of files) {\n const resolvedPath = path.isAbsolute(filePath) ? filePath : path.resolve(dir, filePath)\n\n // Try exact path first\n if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile()) {\n const docs = allCodeConnectObjects.filter(\n (d) => path.resolve(d._codeConnectFilePath || '') === resolvedPath,\n )\n if (docs.length > 0) {\n if (docs.length === 1) {\n logger.info(`Found: ${filePath}`)\n } else {\n logger.info(`Found ${docs.length} component definition(s) in ${filePath}`)\n }\n for (const doc of docs) {\n const parsed = parseFigmaNode(cmd.verbose, doc, true)\n if (parsed) {\n nodesToPreview.push({\n fileKey: parsed.fileKey,\n nodeId: parsed.nodeId,\n url: doc.figmaNode,\n filePath: path.relative(dir, doc._codeConnectFilePath || ''),\n })\n } else {\n logger.error(`Failed to parse figmaNode from file: ${filePath}`)\n }\n }\n } else {\n logger.error(`Not a valid Code Connect file: ${filePath}`)\n }\n continue\n }\n\n // Fall back to basename matching\n const fileName = path.basename(filePath)\n if (cmd.verbose) {\n logger.debug(`Searching for files matching: ${fileName}`)\n logger.debug(`Total Code Connect objects: ${allCodeConnectObjects.length}`)\n }\n\n const matches = allCodeConnectObjects.filter(\n (d) => path.basename(d._codeConnectFilePath || '') === fileName,\n )\n\n if (matches.length === 0) {\n logger.error(`No files found matching: ${filePath}`)\n continue\n }\n\n if (matches.length === 1) {\n logger.info(`Found: ${matches[0]._codeConnectFilePath}`)\n } else {\n const uniqueFiles = new Set(matches.map((d) => d._codeConnectFilePath))\n if (uniqueFiles.size === 1) {\n logger.info(\n `Found ${matches.length} component definition(s) in ${path.relative(dir, Array.from(uniqueFiles)[0] || '')}`,\n )\n } else {\n logger.info(`Found ${matches.length} component definition(s) in ${uniqueFiles.size} files:`)\n for (const fp of uniqueFiles) {\n const count = matches.filter((d) => d._codeConnectFilePath === fp).length\n logger.info(\n ` - ${path.relative(dir, fp || '')} (${count} definition${count > 1 ? 's' : ''})`,\n )\n }\n }\n }\n\n for (const doc of matches) {\n const parsed = parseFigmaNode(cmd.verbose, doc, true)\n if (parsed) {\n nodesToPreview.push({\n fileKey: parsed.fileKey,\n nodeId: parsed.nodeId,\n url: doc.figmaNode,\n filePath: path.relative(dir, doc._codeConnectFilePath || ''),\n })\n }\n }\n }\n\n return nodesToPreview\n}\n\n/**\n * Outcome of fetching a component's property definitions.\n * - `ok`: definitions were found (includes VARIANT axes).\n * - `empty`: the node was fetched successfully but exposes no properties/variants\n * (e.g. a component with no variant axes or component properties, or a plain\n * frame). This is not an error — there is simply nothing to vary.\n * - `error`: the fetch failed (network / non-200), e.g. the token is missing a\n * required scope (Code Connect: Write and File content: Read).\n */\nexport type ComponentPropertyDefinitionsResult =\n | { status: 'ok'; defs: Record<string, FigmaRestApi.ComponentPropertyDefinition> }\n | { status: 'empty' }\n | { status: 'error' }\n\n/** A single node's schema plus its parent COMPONENT_SET id (set only for a variant child). */\ntype NodeSchemaResult =\n | {\n status: 'ok'\n defs: Record<string, FigmaRestApi.ComponentPropertyDefinition>\n componentSetId?: string\n }\n | { status: 'empty'; componentSetId?: string }\n | { status: 'error' }\n\n/**\n * Fetch one node's property definitions from the REST `files/:key/nodes` endpoint.\n */\nasync function fetchNodeSchema(\n baseApiUrl: string,\n fileKey: string,\n nodeId: string,\n accessToken: string,\n): Promise<NodeSchemaResult> {\n try {\n const nodesUrl = `${baseApiUrl}/files/${fileKey}/nodes?ids=${nodeId}`\n const resp = await request.get<{\n nodes: Record<\n string,\n {\n document?: {\n componentPropertyDefinitions?: Record<string, FigmaRestApi.ComponentPropertyDefinition>\n }\n // Per-node component metadata; a variant member carries its parent set id here.\n components?: Record<string, { componentSetId?: string }>\n }\n >\n }>(nodesUrl, { headers: getHeaders(accessToken) })\n if (resp.response.status !== 200) {\n logger.debug(`files/nodes returned ${resp.response.status} for ${nodeId}`)\n return { status: 'error' }\n }\n const node = resp.data.nodes?.[nodeId]\n const componentSetId = node?.components?.[nodeId]?.componentSetId || undefined\n const defs = node?.document?.componentPropertyDefinitions\n if (defs && Object.keys(defs).length > 0) return { status: 'ok', defs, componentSetId }\n logger.debug(`files/nodes returned no componentPropertyDefinitions for ${nodeId}`)\n return { status: 'empty', componentSetId }\n } catch (err) {\n const detail = isFetchError(err) ? `status ${err.response?.status}` : String(err)\n logger.debug(`files/nodes fetch failed for ${nodeId} (${detail})`)\n return { status: 'error' }\n }\n}\n\n/**\n * Fetch a component's property definitions from the REST `files/:key/nodes` endpoint.\n */\nexport async function fetchComponentPropertyDefinitions(\n baseApiUrl: string,\n fileKey: string,\n nodeId: string,\n accessToken: string,\n): Promise<ComponentPropertyDefinitionsResult> {\n const node = await fetchNodeSchema(baseApiUrl, fileKey, nodeId, accessToken)\n if (node.status === 'error') return { status: 'error' }\n\n // Variant child → resolve to the parent COMPONENT_SET (whose schema carries the\n // variant axes). Fall back to the variant's own defs if the set can't be fetched.\n if (node.componentSetId) {\n const set = await fetchNodeSchema(baseApiUrl, fileKey, node.componentSetId, accessToken)\n if (set.status === 'ok') return { status: 'ok', defs: set.defs }\n logger.debug(\n `Component set ${node.componentSetId} for variant ${nodeId} had no usable schema ` +\n `(${set.status}); using the variant's own definitions`,\n )\n }\n\n return node.status === 'ok' ? { status: 'ok', defs: node.defs } : { status: 'empty' }\n}\n\n/** Case-insensitive lookup of a `ComponentPropertyType` from a `--props` prefix token. */\nfunction parsePropertyTypePrefix(token: string): FigmaRestApi.ComponentPropertyType | undefined {\n const upper = token.trim().toUpperCase()\n return (Object.values(FigmaRestApi.ComponentPropertyType) as string[]).includes(upper)\n ? (upper as FigmaRestApi.ComponentPropertyType)\n : undefined\n}\n\ntype ParsedPropertyPair = {\n name: string\n value: string\n type?: FigmaRestApi.ComponentPropertyType\n}\n\n/**\n * Parse a single `--props` argument into a name/value pair, with an optional\n * `TYPE:` prefix to disambiguate properties that share a name but differ in\n * type (e.g. a BOOLEAN and a TEXT property both named `textMsg`).\n * Example: --props Variant=Primary \"Has Icon=true\" \"BOOLEAN:textMsg=false\"\n *\n * The prefix is only recognized when the token before the first `:` matches a\n * known property type (case-insensitive); otherwise the whole name-part is kept\n * as the property name, so real names containing `:` are preserved.\n */\nexport function parsePropsArg(props: string[]): ParsedPropertyPair[] {\n return props\n .flatMap((arg) => arg.split(','))\n .map((pair) => pair.trim())\n .filter((pair) => pair.length > 0)\n .map((pair) => {\n const eq = pair.indexOf('=')\n const namePart = (eq === -1 ? pair : pair.slice(0, eq)).trim()\n const value = eq === -1 ? '' : pair.slice(eq + 1).trim()\n\n const colon = namePart.indexOf(':')\n if (colon !== -1) {\n const type = parsePropertyTypePrefix(namePart.slice(0, colon))\n if (type) {\n return { name: namePart.slice(colon + 1).trim(), value, type }\n }\n }\n return { name: namePart, value }\n })\n}\n\n/**\n * Filter templates to only those matching the requested node IDs.\n */\nexport function filterTemplatesForNodes(\n nodeIds: string[],\n allTemplates: CodeConnectJSON[],\n): CodeConnectJSON[] {\n return allTemplates.filter((template) => {\n if (!template.figmaNode) return false\n const nodeIdMatch = template.figmaNode.match(/node-id=([^&\\s]+)/)\n if (!nodeIdMatch?.[1]) return false\n const templateNodeId = nodeIdMatch[1].replace(/-/g, ':')\n return nodeIds.includes(templateNodeId)\n })\n}\n\n/**\n * Aliases for Code Connect labels that don't directly match a Prettier language name.\n */\nconst CC_LABEL_ALIASES: Record<string, string> = {\n react: 'typescript',\n code: 'typescript',\n}\n\n/**\n * Map from Code Connect language labels to Prettier parser names,\n * built lazily from Prettier's getSupportInfo() on first access.\n * Lazy to avoid triggering plugin loading at module import time.\n */\nlet _prettierParserMap: Record<string, string> | null = null\n\nexport function getPrettierParserMap(): Record<string, string> {\n if (_prettierParserMap) return _prettierParserMap\n\n const info = prettier.getSupportInfo() as {\n languages: Array<{ name: string; parsers?: string[] }>\n }\n _prettierParserMap = {}\n\n for (const lang of info.languages) {\n if (lang.parsers?.[0]) {\n _prettierParserMap[lang.name.toLowerCase()] = lang.parsers[0]\n }\n }\n\n for (const [alias, target] of Object.entries(CC_LABEL_ALIASES)) {\n if (_prettierParserMap[target]) {\n _prettierParserMap[alias] = _prettierParserMap[target]\n }\n }\n\n return _prettierParserMap\n}\n\n/**\n * Check if a snippet can be parsed by Prettier.\n * Returns true for languages without a Prettier parser (nothing to validate).\n */\nexport async function isPrettierParseable(snippet: string, language?: string): Promise<boolean> {\n const lang = language?.toLowerCase()\n const parser = lang ? getPrettierParserMap()[lang] : 'typescript'\n\n if (!parser) {\n return true\n }\n\n try {\n await prettier.format(snippet, { parser })\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Format snippet with Prettier.\n * Returns the snippet unmodified for languages Prettier doesn't support.\n */\nexport async function formatSnippet(snippet: string, language?: string): Promise<string> {\n const lang = language?.toLowerCase()\n const parser = lang ? getPrettierParserMap()[lang] : 'typescript'\n\n if (!parser) {\n return snippet\n }\n\n try {\n let formatted = await prettier.format(snippet, {\n parser,\n semi: false,\n singleQuote: true,\n printWidth: 80,\n tabWidth: 2,\n })\n formatted = formatted.replace(/^;\\s*/, '')\n return formatted\n } catch {\n logger.info(`Autoformatting couldn't be applied: language not supported or code is malformed`)\n return snippet\n }\n}\n\n/**\n * Display results with terminal colors\n */\nconst purple = chalk.ansi256(93)\nconst red = chalk.ansi256(196)\nconst gray = chalk.ansi256(243)\nconst yellow = chalk.ansi256(179)\n\nexport function displayResults(results: PreviewResult[]): void {\n console.log('')\n const successCount = results.filter((r) => r.success).length\n const errorCount = results.filter((r) => !r.success).length\n\n // A muted note when nested children rendered as placeholders (not an error).\n const printUnresolved = (result: PreviewResult) => {\n if (!result.unresolvedInstances?.length) return\n const names = result.unresolvedInstances.map((u) => u.name || u.guid).join(', ')\n console.log(\n ` ${yellow(`⚠ ${result.unresolvedInstances.length} nested instance(s) not Code Connected: ${names}`)}`,\n )\n }\n\n for (const result of results) {\n // When expanding property combinations, label the header with the specific combination.\n const combinationSuffix = result.propertyCombinationLabel\n ? ` ${gray(`— ${result.propertyCombinationLabel}`)}`\n : ''\n if (result.success && result.snippet) {\n const componentInfo = result.component ? ` ${gray(`→ ${result.component}`)}` : ''\n console.log(\n `${purple('●')} ${chalk.bold(result.filePath)}${componentInfo}${combinationSuffix}`,\n )\n console.log(` ${gray(result.url)}`)\n console.log('')\n\n const indentedSnippet = result.snippet\n .trim()\n .split('\\n')\n .map((line) => ' ' + line)\n .join('\\n')\n console.log(indentedSnippet)\n printUnresolved(result)\n console.log('')\n } else {\n const componentInfo = result.component ? ` ${gray(`(${result.component})`)}` : ''\n console.log(`${red('✕')} ${chalk.bold(result.filePath)}${componentInfo}${combinationSuffix}`)\n console.log(` ${gray(result.url)}`)\n console.log(` ${red('Error:')} ${result.error}`)\n // One-line repair hint: the offending property and the real vocabulary.\n // (Transport errors carry no vocabulary — nothing to hint.)\n const available = result.errorDetails?.availableProperties?.map((p) => p.name).join(', ')\n const missingProperty = result.errorDetails?.missingProperty\n if (missingProperty && available) {\n console.log(\n ` ${gray(`property \"${missingProperty}\" not found — available: ${available}`)}`,\n )\n } else if (available) {\n console.log(` ${gray(`available properties: ${available}`)}`)\n }\n printUnresolved(result)\n console.log('')\n }\n }\n\n const failed = errorCount > 0 ? red(`${errorCount} failed`) : gray(`${errorCount} failed`)\n console.log(`${chalk.bold('Summary:')} ${purple(`${successCount} succeeded`)}, ${failed}`)\n}\n\n// The server caps inbound request bodies at 5MB. The figmaDocs payload\n// (one Code Connect template per requested component) dominates the body size,\n// so for projects with many components we split into smaller chunks and send\n// them in parallel rather than risking a 413.\nconst PREVIEW_CHUNK_SIZE = 50\n// Bound the number of chunks in flight at once. Without this cap, large\n// libraries (~1k+ components) trigger N parallel preview requests, which\n// overwhelms upstream token validation and causes spurious 403 \"Invalid\n// token\" responses for the chunks that queue up too long.\nconst PREVIEW_MAX_CONCURRENCY = 5\n// Mirrors MAX_PROPERTY_COMBINATIONS_PER_REQUEST in pixie/code_connect_preview_handler.ts.\n// `--all` caps enumeration here and warns rather than sending a request that fails wholesale.\nconst MAX_PROPERTY_COMBINATIONS = 500\n\nexport function parseMaxCombinationsArg(value: string | undefined): number {\n if (value === undefined) {\n return MAX_PROPERTY_COMBINATIONS\n }\n const parsed = Number(value)\n if (!Number.isInteger(parsed) || parsed < 1) {\n exitWithError('--max-combinations must be a positive integer')\n }\n if (parsed > MAX_PROPERTY_COMBINATIONS) {\n exitWithError(`--max-combinations cannot exceed ${MAX_PROPERTY_COMBINATIONS}`)\n }\n return parsed\n}\n\ntype PreviewResponseData = {\n status: number\n error: boolean\n meta: {\n results: Array<{\n nodeId: string\n nodeUrl: string\n snippet?: string\n language?: string\n component?: string\n error?: string\n propertyCombinationLabel?: string\n errorKind?: string\n unresolvedInstances?: Array<{ guid: string; name?: string; kind: 'instance' | 'slot' }>\n }>\n }\n}\n\ntype ChunkOutcome = {\n chunkNodeIds: string[]\n response: Awaited<ReturnType<typeof request.post<PreviewResponseData>>> | null\n error: unknown\n}\n\nfunction chunkArray<T>(arr: T[], size: number): T[][] {\n const chunks: T[][] = []\n for (let i = 0; i < arr.length; i += size) {\n chunks.push(arr.slice(i, i + size))\n }\n return chunks\n}\n\n/**\n * Split node IDs into request chunks that respect BOTH the node-count cap\n * (PREVIEW_CHUNK_SIZE) and, when rendering property combinations, the server's\n * per-request combination cap (MAX_PROPERTY_COMBINATIONS).\n *\n * The server sums combinations across every node in a request and rejects the\n * whole request if the total exceeds the cap, so bundling by node count alone\n * can push several individually-valid nodes over the limit and fail them all.\n * Each node is already truncated to <= MAX_PROPERTY_COMBINATIONS upstream, so a\n * single node always fits (worst case: one node per chunk).\n */\nexport function chunkNodeIdsForPreview(\n nodeIds: string[],\n propertyCombinationsByNodeId?: Record<string, PropertyCombination[]>,\n): string[][] {\n if (!propertyCombinationsByNodeId) {\n return chunkArray(nodeIds, PREVIEW_CHUNK_SIZE)\n }\n\n const chunks: string[][] = []\n let current: string[] = []\n let currentCombinations = 0\n for (const nodeId of nodeIds) {\n const count = propertyCombinationsByNodeId[nodeId]?.length ?? 0\n // Close the current chunk before adding this node would breach either cap.\n if (\n current.length > 0 &&\n (current.length >= PREVIEW_CHUNK_SIZE ||\n currentCombinations + count > MAX_PROPERTY_COMBINATIONS)\n ) {\n chunks.push(current)\n current = []\n currentCombinations = 0\n }\n current.push(nodeId)\n currentCombinations += count\n }\n if (current.length > 0) chunks.push(current)\n return chunks\n}\n\nasync function runInWaves<T, R>(\n items: T[],\n fn: (item: T) => Promise<R>,\n maxConcurrency: number,\n): Promise<R[]> {\n const out: R[] = []\n for (let i = 0; i < items.length; i += maxConcurrency) {\n const wave = items.slice(i, i + maxConcurrency)\n const settled = await Promise.all(wave.map(fn))\n out.push(...settled)\n }\n return out\n}\n\nfunction sendPreviewChunk({\n chunkNodeIds,\n requiredTemplates,\n baseApiUrl,\n fileKey,\n accessToken,\n propertyCombinationsByNodeId,\n}: {\n chunkNodeIds: string[]\n requiredTemplates: CodeConnectJSON[]\n baseApiUrl: string\n fileKey: string\n accessToken: string\n propertyCombinationsByNodeId?: Record<string, PropertyCombination[]>\n}): Promise<ChunkOutcome> {\n const chunkTemplates = filterTemplatesForNodes(chunkNodeIds, requiredTemplates)\n // Only include property combinations for the node IDs in this chunk.\n let renderCombinations: Record<string, PropertyCombination[]> | undefined\n if (propertyCombinationsByNodeId) {\n renderCombinations = {}\n for (const nodeId of chunkNodeIds) {\n if (propertyCombinationsByNodeId[nodeId]) {\n renderCombinations[nodeId] = propertyCombinationsByNodeId[nodeId]\n }\n }\n }\n return request\n .post<PreviewResponseData>(\n `${baseApiUrl}/code_connect/preview_snippets?file_key=${fileKey}`,\n {\n nodeIds: chunkNodeIds,\n figmaDocs: { all: chunkTemplates },\n ...(renderCombinations && Object.keys(renderCombinations).length > 0\n ? { renderCombinations }\n : {}),\n },\n { headers: getHeaders(accessToken) },\n )\n .then((response) => ({ chunkNodeIds, response, error: null as unknown }))\n .catch((err: unknown) => ({ chunkNodeIds, response: null, error: err }))\n}\n\n/**\n * Parse the offending property name out of a \"property not found\" render error,\n * e.g. `PropertyNotFoundError: property 'Varient' not found` -> `Varient`.\n */\nexport function parseMissingProperty(error?: string): string | undefined {\n if (!error) return undefined\n const match =\n error.match(/propert(?:y|ies)[^'\"`]*['\"`]([^'\"`]+)['\"`]/i) ?? error.match(/['\"`]([^'\"`]+)['\"`]/)\n return match?.[1]\n}\n\n/** Build `errorDetails` for a failed result. Undefined when there's no property context (not --all). */\nfunction buildErrorDetails(\n error: string | undefined,\n errorKind: string | undefined,\n availableProperties: AvailableProperty[] | undefined,\n): PreviewResult['errorDetails'] {\n // Transport failure: network/backend problem, not a bad property — carry only the kind.\n if (errorKind === 'transport') return { kind: 'transport' }\n if (!availableProperties) return undefined\n const details: NonNullable<PreviewResult['errorDetails']> = { availableProperties }\n if (errorKind) details.kind = errorKind\n const missingProperty = parseMissingProperty(error)\n if (missingProperty) details.missingProperty = missingProperty\n return details\n}\n\nexport function chunkOutcomeToResults(\n outcome: ChunkOutcome,\n nodes: NodeToPreview[],\n fileKey: string,\n availablePropsByNodeId?: Record<string, AvailableProperty[]>,\n): PreviewResult[] {\n const { chunkNodeIds, response, error } = outcome\n const results: PreviewResult[] = []\n\n if (error) {\n const errorMsg = isFetchError(error)\n ? error.data?.message || error.response.statusText\n : String(error)\n // 503 means the server-side killswitch is on — surface the server's\n // message directly without the per-file/per-node noise so the user\n // sees a single clear line during an incident.\n if (isFetchError(error) && error.response.status === 503) {\n exitWithError(errorMsg)\n } else {\n logger.error(`Failed to preview components in file ${fileKey}: ${errorMsg}`)\n for (const nodeId of chunkNodeIds) {\n for (const node of nodes.filter((n) => n.nodeId === nodeId)) {\n results.push({\n url: node.url,\n nodeId: node.nodeId,\n filePath: node.filePath,\n success: false,\n error: errorMsg,\n // Chunk-level failure is a server/network error, not a template problem.\n errorDetails: { kind: 'transport' },\n })\n }\n }\n }\n return results\n }\n\n if (response!.response.status === 200 && response!.data.meta?.results) {\n // Track match index per nodeId so duplicate node IDs get the correct file attribution.\n // The server returns results in the same order as the templates we sent. Each chunk's\n // nodeIds are disjoint (we dedupe before chunking), so per-chunk indexing is correct.\n // Property-combination results are expanded renders of one node, not one result per\n // matching template, so they should not consume this per-template index.\n const nodeMatchIndex: Record<string, number> = {}\n for (const result of response!.data.meta.results) {\n const idx = nodeMatchIndex[result.nodeId] ?? 0\n const matchingNodes = nodes.filter((n) => n.nodeId === result.nodeId)\n const node = result.propertyCombinationLabel\n ? matchingNodes[0]\n : matchingNodes[idx] || matchingNodes[0]\n if (!result.propertyCombinationLabel) {\n nodeMatchIndex[result.nodeId] = idx + 1\n }\n const error = result.error || (!result.snippet ? 'No snippet returned by server' : undefined)\n const success = !result.error && !!result.snippet\n results.push({\n url: node?.url || result.nodeUrl,\n nodeId: result.nodeId,\n filePath: node?.filePath || '',\n success,\n snippet: result.snippet,\n language: result.language,\n component: result.component,\n error,\n ...(result.propertyCombinationLabel\n ? { propertyCombinationLabel: result.propertyCombinationLabel }\n : {}),\n ...(result.unresolvedInstances?.length\n ? { unresolvedInstances: result.unresolvedInstances }\n : {}),\n ...(success\n ? {}\n : {\n errorDetails: buildErrorDetails(\n error,\n result.errorKind,\n availablePropsByNodeId?.[result.nodeId],\n ),\n }),\n })\n }\n return results\n }\n\n for (const nodeId of chunkNodeIds) {\n for (const node of nodes.filter((n) => n.nodeId === nodeId)) {\n const error = `API request failed with status ${response!.response.status}`\n results.push({\n url: node.url,\n nodeId: node.nodeId,\n filePath: node.filePath,\n success: false,\n error,\n // Non-2xx from the endpoint is a transport-level failure, not a template problem.\n errorDetails: { kind: 'transport' },\n })\n }\n }\n return results\n}\n\nasync function previewFile({\n fileKey,\n nodes,\n baseApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n propertyCombinationsByNodeId,\n availablePropsByNodeId,\n}: {\n fileKey: string\n nodes: NodeToPreview[]\n baseApiUrl: string\n accessToken: string\n dir: string\n allCodeConnectObjects: CodeConnectJSON[]\n propertyCombinationsByNodeId?: Record<string, PropertyCombination[]>\n availablePropsByNodeId?: Record<string, AvailableProperty[]>\n}): Promise<PreviewResult[]> {\n const allNodeIds = nodes.map((n) => n.nodeId)\n // Deduplicate — multiple figma.connect() calls may share the same nodeId;\n // the individual templates are sent in figmaDocs and the server iterates per-template.\n const nodeIds = [...new Set(allNodeIds)]\n\n // Only send templates from the requested files — other files' templates\n // for the same nodeId exist on the server and shouldn't be rendered individually.\n const requestedFilePaths = new Set(nodes.map((n) => path.resolve(dir, n.filePath)))\n const requiredTemplates = filterTemplatesForNodes(allNodeIds, allCodeConnectObjects).filter((t) =>\n requestedFilePaths.has(path.resolve(t._codeConnectFilePath || '')),\n )\n\n const chunks = chunkNodeIdsForPreview(nodeIds, propertyCombinationsByNodeId)\n const outcomes = await runInWaves(\n chunks,\n (chunkNodeIds) =>\n sendPreviewChunk({\n chunkNodeIds,\n requiredTemplates,\n baseApiUrl,\n fileKey,\n accessToken,\n propertyCombinationsByNodeId,\n }),\n PREVIEW_MAX_CONCURRENCY,\n )\n\n return outcomes.flatMap((outcome) =>\n chunkOutcomeToResults(outcome, nodes, fileKey, availablePropsByNodeId),\n )\n}\n\nfunction collectAllLocalNodesToPreview(\n allCodeConnectObjects: CodeConnectJSON[],\n dir: string,\n cmd: BaseCommand,\n): NodeToPreview[] {\n const nodesToCheck: NodeToPreview[] = []\n for (const doc of allCodeConnectObjects) {\n const parsed = parseFigmaNode(cmd.verbose, doc, true)\n if (parsed) {\n nodesToCheck.push({\n fileKey: parsed.fileKey,\n nodeId: parsed.nodeId,\n url: doc.figmaNode,\n filePath: path.relative(dir, doc._codeConnectFilePath || ''),\n })\n }\n }\n return nodesToCheck\n}\n\nfunction groupNodesByFileKey(nodes: NodeToPreview[]): NodesByFileKey {\n const nodesByFileKey: NodesByFileKey = {}\n for (const node of nodes) {\n nodesByFileKey[node.fileKey] ??= []\n nodesByFileKey[node.fileKey].push(node)\n }\n return nodesByFileKey\n}\n\nasync function handleInspect({\n nodesByFileKey,\n configuredApiUrl,\n accessToken,\n outputFormat,\n}: {\n nodesByFileKey: NodesByFileKey\n configuredApiUrl?: string\n accessToken: string\n outputFormat: string\n}): Promise<void> {\n const items: PropertyListItem[] = []\n const seen = new Set<string>()\n for (const [fileKey, nodes] of Object.entries(nodesByFileKey)) {\n const baseApiUrl = getApiUrl(nodes[0].url, configuredApiUrl)\n for (const node of nodes) {\n const dedupeKey = `${node.filePath}::${node.nodeId}`\n if (seen.has(dedupeKey)) continue\n seen.add(dedupeKey)\n const result = await fetchComponentPropertyDefinitions(\n baseApiUrl,\n fileKey,\n node.nodeId,\n accessToken,\n )\n if (result.status === 'error') {\n logger.warn(`Couldn't fetch property definitions for node ${node.nodeId}`)\n } else if (result.status === 'empty') {\n logger.info(`Node ${node.nodeId} has no component properties or variants.`)\n }\n items.push({\n filePath: node.filePath,\n nodeId: node.nodeId,\n availableProperties: result.status === 'ok' ? toAvailableProperties(result.defs) : [],\n })\n }\n }\n\n if (outputFormat === 'json') {\n console.log(JSON.stringify(items, null, 2))\n } else {\n displayPropertyList(items)\n }\n}\n\nfunction validatePreviewOptions(cmd: PreviewCommand): void {\n if (cmd.all && cmd.props) {\n exitWithError('Cannot combine --props and --all; use one or the other')\n }\n\n if (cmd.maxCombinations !== undefined && !cmd.all) {\n exitWithError('--max-combinations can only be used with --all')\n }\n}\n\nasync function buildPropertyPreviewInputs({\n enabled,\n baseApiUrl,\n fileKey,\n nodes,\n accessToken,\n propsPairs,\n maxCombinations,\n}: {\n enabled: boolean\n baseApiUrl: string\n fileKey: string\n nodes: NodeToPreview[]\n accessToken: string\n propsPairs?: ParsedPropertyPair[]\n maxCombinations: number\n}): Promise<{\n propertyCombinationsByNodeId?: Record<string, PropertyCombination[]>\n availablePropsByNodeId?: Record<string, AvailableProperty[]>\n}> {\n if (!enabled) return {}\n\n const propertyCombinationsByNodeId: Record<string, PropertyCombination[]> = {}\n const availablePropsByNodeId: Record<string, AvailableProperty[]> = {}\n for (const nodeId of [...new Set(nodes.map((n) => n.nodeId))]) {\n const result = await fetchComponentPropertyDefinitions(baseApiUrl, fileKey, nodeId, accessToken)\n if (result.status === 'error') {\n logger.warn(\n `Couldn't fetch property definitions for node ${nodeId} (ensure your token has the ` +\n `Code Connect: Write and File content: Read scopes); rendering its default property combination only`,\n )\n continue\n }\n if (result.status === 'empty') {\n // Not an error: the component simply has no properties or variants to vary.\n if (propsPairs) {\n logger.warn(\n `Node ${nodeId} has no component properties or variants, so --props ` +\n `(${propsPairs.map((p) => p.name).join(', ')}) has no effect; rendering its only property combination.`,\n )\n } else {\n logger.info(\n `Node ${nodeId} has no component properties or variants to vary; rendering its only property combination.`,\n )\n }\n continue\n }\n\n const defs = result.defs\n if (propsPairs) {\n const { propertyCombination, availableProperties, unknown, invalid, ambiguous } =\n buildPropertyCombinationFromProps(defs, propsPairs)\n if (unknown.length > 0) {\n logger.warn(\n `Unknown propert${unknown.length > 1 ? 'ies' : 'y'} for node ${nodeId}: ${unknown.join(', ')}. ` +\n `Available: ${availableProperties.map((p) => p.name).join(', ')}`,\n )\n }\n for (const { name, value, options } of invalid) {\n logger.warn(\n `\"${value}\" is not a valid value for ${name} on node ${nodeId}. Options: ${options.join(', ')}`,\n )\n }\n for (const { name, types } of ambiguous) {\n logger.warn(\n `Property \"${name}\" on node ${nodeId} matches multiple types (${types.join(', ')}); ` +\n `prefix the value with a type to disambiguate, e.g. ${types[0]}:${name}=... . Skipping.`,\n )\n }\n availablePropsByNodeId[nodeId] = availableProperties\n propertyCombinationsByNodeId[nodeId] = [propertyCombination]\n } else {\n const { propertyCombinations, availableProperties, truncated } =\n enumeratePropertyCombinations(defs, {\n maxCombinations,\n })\n availablePropsByNodeId[nodeId] = availableProperties\n if (truncated) {\n logger.warn(\n `Node ${nodeId} has ${truncated.total} property combinations, exceeding the ${truncated.cap}-combination ` +\n `preview limit; rendering the first ${truncated.cap}. Use --props to preview a ` +\n `specific property combination.`,\n )\n }\n if (propertyCombinations.length > 0) {\n propertyCombinationsByNodeId[nodeId] = propertyCombinations\n }\n }\n }\n\n return { propertyCombinationsByNodeId, availablePropsByNodeId }\n}\n\nasync function previewNodesForFile({\n fileKey,\n nodes,\n configuredApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n renderPropertyCombinations,\n propsPairs,\n maxCombinations,\n}: {\n fileKey: string\n nodes: NodeToPreview[]\n configuredApiUrl?: string\n accessToken: string\n dir: string\n allCodeConnectObjects: CodeConnectJSON[]\n renderPropertyCombinations: boolean\n propsPairs?: ParsedPropertyPair[]\n maxCombinations: number\n}): Promise<PreviewResult[]> {\n const baseApiUrl = getApiUrl(nodes[0].url, configuredApiUrl)\n const { propertyCombinationsByNodeId, availablePropsByNodeId } = await buildPropertyPreviewInputs(\n {\n enabled: renderPropertyCombinations,\n baseApiUrl,\n fileKey,\n nodes,\n accessToken,\n propsPairs,\n maxCombinations,\n },\n )\n\n return previewFile({\n fileKey,\n nodes,\n baseApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n propertyCombinationsByNodeId,\n availablePropsByNodeId,\n })\n}\n\nasync function validateRenderedSnippets(results: PreviewResult[]): Promise<void> {\n for (const result of results) {\n if (result.success && result.snippet) {\n const prettierValid = await isPrettierParseable(result.snippet, result.language)\n if (!prettierValid) {\n // Prettier can parse this language but failed — mark as error\n result.success = false\n result.error = 'Snippet has syntax errors and may not be valid code'\n }\n }\n }\n}\n\nasync function outputPreviewResults(results: PreviewResult[], outputFormat: string): Promise<void> {\n if (outputFormat === 'json') {\n console.log(JSON.stringify(results, null, 2))\n return\n }\n\n const formattedResults: PreviewResult[] = await Promise.all(\n results.map(async (result) => {\n if (result.success && result.snippet) {\n const formattedSnippet = await formatSnippet(result.snippet, result.language)\n return { ...result, snippet: formattedSnippet }\n }\n return result\n }),\n )\n displayResults(formattedResults)\n}\n\n/**\n * Handle the preview command\n */\nexport async function handlePreview(files: string[], cmd: PreviewCommand) {\n setupHandler(cmd)\n\n const dir = cmd.dir ?? process.cwd()\n const projectInfo = await getProjectInfo(dir, cmd.config)\n const accessToken = getAccessTokenOrExit(cmd)\n const outputFormat = cmd.output || 'table'\n const configuredApiUrl = cmd.apiUrl || projectInfo.config.apiUrl\n\n if (cmd.all && (!files || files.length === 0)) {\n exitWithError(\n '--all requires a specific component, e.g. `figma connect preview Button.figma.ts --all`',\n )\n }\n\n const allCodeConnectObjects = await getCodeConnectObjects(cmd, projectInfo, true)\n\n const nodesToCheck =\n files && files.length > 0\n ? await collectNodesToPreview(files, allCodeConnectObjects, dir, cmd)\n : collectAllLocalNodesToPreview(allCodeConnectObjects, dir, cmd)\n if (!files || files.length === 0) {\n logger.info('Previewing all local Code Connect files...')\n }\n\n if (nodesToCheck.length === 0) {\n exitWithError('No valid Code Connect files found to preview')\n }\n\n logger.info(`Previewing ${nodesToCheck.length} component(s)...`)\n const nodesByFileKey = groupNodesByFileKey(nodesToCheck)\n\n if (cmd.inspect) {\n await handleInspect({\n nodesByFileKey,\n configuredApiUrl,\n accessToken,\n outputFormat,\n })\n return\n }\n\n validatePreviewOptions(cmd)\n const maxCombinations = parseMaxCombinationsArg(cmd.maxCombinations)\n const propsPairs = cmd.props ? parsePropsArg(cmd.props) : undefined\n\n const results: PreviewResult[] = []\n for (const [fileKey, nodes] of Object.entries(nodesByFileKey)) {\n const fileResults = await previewNodesForFile({\n fileKey,\n nodes,\n configuredApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n renderPropertyCombinations: cmd.all || !!propsPairs,\n propsPairs,\n maxCombinations,\n })\n results.push(...fileResults)\n }\n\n await validateRenderedSnippets(results)\n await outputPreviewResults(results, outputFormat)\n\n if (results.every((r) => !r.success)) {\n process.exit(1)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"preview_utils.js","sourceRoot":"","sources":["../../src/commands/preview_utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,sDA0FC;AA+FD,wFA6CC;AAGD,8EAcC;AA0BD,sCAmBC;AAKD,0DAWC;AAiBD,oDAqBC;AAMD,kDAcC;AAMD,sCAsBC;AAUD,wCA8DC;AAgBD,0DAYC;AA6CD,wDA4BC;AA8DD,oDAKC;AAkBD,sDAmGC;AAwID,wDAWC;AAsLD,sCA6EC;AAtsCD,4CAAmB;AACnB,gDAAuB;AACvB,kDAAyB;AACzB,mDAAoC;AACpC,uCAAkG;AAClG,+CAAyD;AAEzD,sDAAsD;AACtD,gDAAmD;AACnD,8DAA+E;AAC/E,2CAAuD;AACvD,+DAAkF;AAClF,4EAMyC;AACzC,yDAA2D;AA0C3D;;;GAGG;AACI,KAAK,UAAU,qBAAqB,CACzC,KAAe,EACf,qBAAwC,EACxC,GAAW,EACX,GAAgB;IAEhB,MAAM,cAAc,GAAoB,EAAE,CAAA;IAE1C,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;QAC7B,MAAM,YAAY,GAAG,cAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAA;QAEvF,uBAAuB;QACvB,IAAI,YAAE,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,YAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YACtE,MAAM,IAAI,GAAG,qBAAqB,CAAC,MAAM,CACvC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAI,CAAC,OAAO,CAA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AC,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport chalk from 'chalk'\nimport * as prettier from 'prettier'\nimport { BaseCommand, getCodeConnectObjects, getAccessTokenOrExit, setupHandler } from './connect'\nimport { exitWithError, logger } from '../common/logging'\nimport { CodeConnectJSON } from '../connect/figma_connect'\nimport { parseFigmaNode } from '../connect/validation'\nimport { getProjectInfo } from '../connect/project'\nimport { getApiUrl, getHeaders, FigmaRestApi } from '../connect/figma_rest_api'\nimport { request, isFetchError } from '../common/fetch'\nimport { displayPropertyList, type PropertyListItem } from './property_list_table'\nimport {\n enumeratePropertyCombinations,\n buildPropertyCombinationFromProps,\n toAvailableProperties,\n type PropertyCombination,\n type AvailableProperty,\n} from '../connect/property_combinations'\nimport { collapsePreviewResults } from './preview_collapse'\n\ntype PreviewCommand = BaseCommand & { output?: string }\n\nexport interface NodeToPreview {\n fileKey: string\n nodeId: string\n url: string\n filePath: string\n}\n\nexport interface PreviewResult {\n url: string\n nodeId: string\n filePath: string\n success: boolean\n snippet?: string\n language?: string\n component?: string\n error?: string\n /** Present when this result is one property combination of an expanded (--all) render. */\n propertyCombinationLabel?: string\n /**\n * With `--unique`, the labels of all property combinations that produced this\n * identical output (the full `--all` cartesian often collapses to far fewer\n * distinct snippets).\n */\n propertyCombinationLabels?: string[]\n /** With `--unique`, how many property combinations produced this identical output. */\n propertyCombinationCount?: number\n /** `kind: \"transport\"` marks a server/network failure, in which case no property vocabulary is attached. */\n errorDetails?: {\n kind?: string\n missingProperty?: string\n availableProperties?: AvailableProperty[]\n }\n /** Nested instances/slots that rendered as placeholders. Not an error — the snippet still rendered. */\n unresolvedInstances?: Array<{ guid: string; name?: string; kind: 'instance' | 'slot' }>\n}\n\ntype NodesByFileKey = Record<string, NodeToPreview[]>\n\n/**\n * Collect nodes to preview from file arguments.\n * Matches by exact path first, then by basename.\n */\nexport async function collectNodesToPreview(\n files: string[],\n allCodeConnectObjects: CodeConnectJSON[],\n dir: string,\n cmd: BaseCommand,\n): Promise<NodeToPreview[]> {\n const nodesToPreview: NodeToPreview[] = []\n\n for (const filePath of files) {\n const resolvedPath = path.isAbsolute(filePath) ? filePath : path.resolve(dir, filePath)\n\n // Try exact path first\n if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile()) {\n const docs = allCodeConnectObjects.filter(\n (d) => path.resolve(d._codeConnectFilePath || '') === resolvedPath,\n )\n if (docs.length > 0) {\n if (docs.length === 1) {\n logger.info(`Found: ${filePath}`)\n } else {\n logger.info(`Found ${docs.length} component definition(s) in ${filePath}`)\n }\n for (const doc of docs) {\n const parsed = parseFigmaNode(cmd.verbose, doc, true)\n if (parsed) {\n nodesToPreview.push({\n fileKey: parsed.fileKey,\n nodeId: parsed.nodeId,\n url: doc.figmaNode,\n filePath: path.relative(dir, doc._codeConnectFilePath || ''),\n })\n } else {\n logger.error(`Failed to parse figmaNode from file: ${filePath}`)\n }\n }\n } else {\n logger.error(`Not a valid Code Connect file: ${filePath}`)\n }\n continue\n }\n\n // Fall back to basename matching\n const fileName = path.basename(filePath)\n if (cmd.verbose) {\n logger.debug(`Searching for files matching: ${fileName}`)\n logger.debug(`Total Code Connect objects: ${allCodeConnectObjects.length}`)\n }\n\n const matches = allCodeConnectObjects.filter(\n (d) => path.basename(d._codeConnectFilePath || '') === fileName,\n )\n\n if (matches.length === 0) {\n logger.error(`No files found matching: ${filePath}`)\n continue\n }\n\n if (matches.length === 1) {\n logger.info(`Found: ${matches[0]._codeConnectFilePath}`)\n } else {\n const uniqueFiles = new Set(matches.map((d) => d._codeConnectFilePath))\n if (uniqueFiles.size === 1) {\n logger.info(\n `Found ${matches.length} component definition(s) in ${path.relative(dir, Array.from(uniqueFiles)[0] || '')}`,\n )\n } else {\n logger.info(`Found ${matches.length} component definition(s) in ${uniqueFiles.size} files:`)\n for (const fp of uniqueFiles) {\n const count = matches.filter((d) => d._codeConnectFilePath === fp).length\n logger.info(\n ` - ${path.relative(dir, fp || '')} (${count} definition${count > 1 ? 's' : ''})`,\n )\n }\n }\n }\n\n for (const doc of matches) {\n const parsed = parseFigmaNode(cmd.verbose, doc, true)\n if (parsed) {\n nodesToPreview.push({\n fileKey: parsed.fileKey,\n nodeId: parsed.nodeId,\n url: doc.figmaNode,\n filePath: path.relative(dir, doc._codeConnectFilePath || ''),\n })\n }\n }\n }\n\n return nodesToPreview\n}\n\n/**\n * Outcome of fetching a component's property definitions.\n * - `ok`: definitions were found (includes VARIANT axes).\n * - `empty`: the node was fetched successfully but exposes no properties/variants\n * (e.g. a component with no variant axes or component properties, or a plain\n * frame). This is not an error — there is simply nothing to vary.\n * - `error`: the fetch failed (network / non-200), e.g. the token is missing a\n * required scope (Code Connect: Write and File content: Read).\n */\nexport type ComponentPropertyDefinitionsResult =\n | { status: 'ok'; defs: Record<string, FigmaRestApi.ComponentPropertyDefinition> }\n | { status: 'empty' }\n | { status: 'error' }\n\n/** A single node's schema plus its parent COMPONENT_SET id (set only for a variant child). */\ntype NodeSchemaResult =\n | {\n status: 'ok'\n defs: Record<string, FigmaRestApi.ComponentPropertyDefinition>\n componentSetId?: string\n }\n | { status: 'empty'; componentSetId?: string }\n | { status: 'error' }\n\n// Keep the comma-separated `ids` query comfortably below common URL limits while still\n// loading a few hundred components from the same design-system file together.\nconst PROPERTY_SCHEMA_BATCH_SIZE = 200\n\ntype FetchedNode = {\n document?: {\n componentPropertyDefinitions?: Record<string, FigmaRestApi.ComponentPropertyDefinition>\n }\n // Per-node component metadata; a variant member carries its parent set id here.\n components?: Record<string, { componentSetId?: string }>\n}\n\n/**\n * Fetch property definitions for several nodes in one REST `files/:key/nodes` request.\n * That endpoint accepts comma-separated IDs, and loading the same file once per node is\n * especially expensive for large design-system files.\n */\nasync function fetchNodeSchemaBatch(\n baseApiUrl: string,\n fileKey: string,\n nodeIds: string[],\n accessToken: string,\n): Promise<Record<string, NodeSchemaResult>> {\n try {\n const nodesUrl = `${baseApiUrl}/files/${fileKey}/nodes?ids=${nodeIds.join(',')}`\n const resp = await request.get<{\n nodes: Record<string, FetchedNode>\n }>(nodesUrl, { headers: getHeaders(accessToken) })\n if (resp.response.status !== 200) {\n logger.debug(`files/nodes returned ${resp.response.status} for ${nodeIds.length} node(s)`)\n return Object.fromEntries(nodeIds.map((nodeId) => [nodeId, { status: 'error' }]))\n }\n\n return Object.fromEntries(\n nodeIds.map((nodeId): [string, NodeSchemaResult] => {\n const node = resp.data.nodes?.[nodeId]\n const componentSetId = node?.components?.[nodeId]?.componentSetId || undefined\n const defs = node?.document?.componentPropertyDefinitions\n if (defs && Object.keys(defs).length > 0) {\n return [nodeId, { status: 'ok', defs, componentSetId }]\n }\n logger.debug(`files/nodes returned no componentPropertyDefinitions for ${nodeId}`)\n return [nodeId, { status: 'empty', componentSetId }]\n }),\n )\n } catch (err) {\n const detail = isFetchError(err) ? `status ${err.response?.status}` : String(err)\n logger.debug(`files/nodes fetch failed for ${nodeIds.length} node(s) (${detail})`)\n return Object.fromEntries(nodeIds.map((nodeId) => [nodeId, { status: 'error' }]))\n }\n}\n\nasync function fetchNodeSchemas(\n baseApiUrl: string,\n fileKey: string,\n nodeIds: string[],\n accessToken: string,\n): Promise<Record<string, NodeSchemaResult>> {\n const results: Record<string, NodeSchemaResult> = {}\n for (const batch of chunkArray([...new Set(nodeIds)], PROPERTY_SCHEMA_BATCH_SIZE)) {\n Object.assign(results, await fetchNodeSchemaBatch(baseApiUrl, fileKey, batch, accessToken))\n }\n return results\n}\n\n/**\n * Fetch components' property definitions in batches: first the requested nodes, then\n * any parent component sets discovered in those responses.\n */\nexport async function fetchComponentPropertyDefinitionsBatch(\n baseApiUrl: string,\n fileKey: string,\n nodeIds: string[],\n accessToken: string,\n): Promise<Record<string, ComponentPropertyDefinitionsResult>> {\n const uniqueNodeIds = [...new Set(nodeIds)]\n const nodeSchemas = await fetchNodeSchemas(baseApiUrl, fileKey, uniqueNodeIds, accessToken)\n const requestedNodeIds = new Set(uniqueNodeIds)\n const componentSetIds = [\n ...new Set(\n Object.values(nodeSchemas)\n .map((node) => (node.status === 'error' ? undefined : node.componentSetId))\n .filter((id): id is string => !!id && !requestedNodeIds.has(id)),\n ),\n ]\n const componentSetSchemas = await fetchNodeSchemas(\n baseApiUrl,\n fileKey,\n componentSetIds,\n accessToken,\n )\n\n return Object.fromEntries(\n uniqueNodeIds.map((nodeId): [string, ComponentPropertyDefinitionsResult] => {\n const node = nodeSchemas[nodeId] ?? { status: 'error' }\n if (node.status === 'error') return [nodeId, { status: 'error' }]\n\n // Variant child → resolve to the parent COMPONENT_SET (whose schema carries the\n // variant axes). Fall back to the variant's own defs if the set can't be fetched.\n if (node.componentSetId) {\n const set = nodeSchemas[node.componentSetId] ?? componentSetSchemas[node.componentSetId]\n if (set?.status === 'ok') return [nodeId, { status: 'ok', defs: set.defs }]\n logger.debug(\n `Component set ${node.componentSetId} for variant ${nodeId} had no usable schema ` +\n `(${set?.status ?? 'error'}); using the variant's own definitions`,\n )\n }\n\n return [\n nodeId,\n node.status === 'ok' ? { status: 'ok', defs: node.defs } : { status: 'empty' },\n ]\n }),\n )\n}\n\n/** Fetch one component's property definitions. */\nexport async function fetchComponentPropertyDefinitions(\n baseApiUrl: string,\n fileKey: string,\n nodeId: string,\n accessToken: string,\n): Promise<ComponentPropertyDefinitionsResult> {\n const results = await fetchComponentPropertyDefinitionsBatch(\n baseApiUrl,\n fileKey,\n [nodeId],\n accessToken,\n )\n\n return results[nodeId] ?? { status: 'error' }\n}\n\n/** Case-insensitive lookup of a `ComponentPropertyType` from a `--props` prefix token. */\nfunction parsePropertyTypePrefix(token: string): FigmaRestApi.ComponentPropertyType | undefined {\n const upper = token.trim().toUpperCase()\n return (Object.values(FigmaRestApi.ComponentPropertyType) as string[]).includes(upper)\n ? (upper as FigmaRestApi.ComponentPropertyType)\n : undefined\n}\n\ntype ParsedPropertyPair = {\n name: string\n value: string\n type?: FigmaRestApi.ComponentPropertyType\n}\n\n/**\n * Parse a single `--props` argument into a name/value pair, with an optional\n * `TYPE:` prefix to disambiguate properties that share a name but differ in\n * type (e.g. a BOOLEAN and a TEXT property both named `textMsg`).\n * Example: --props Variant=Primary \"Has Icon=true\" \"BOOLEAN:textMsg=false\"\n *\n * The prefix is only recognized when the token before the first `:` matches a\n * known property type (case-insensitive); otherwise the whole name-part is kept\n * as the property name, so real names containing `:` are preserved.\n */\nexport function parsePropsArg(props: string[]): ParsedPropertyPair[] {\n return props\n .flatMap((arg) => arg.split(','))\n .map((pair) => pair.trim())\n .filter((pair) => pair.length > 0)\n .map((pair) => {\n const eq = pair.indexOf('=')\n const namePart = (eq === -1 ? pair : pair.slice(0, eq)).trim()\n const value = eq === -1 ? '' : pair.slice(eq + 1).trim()\n\n const colon = namePart.indexOf(':')\n if (colon !== -1) {\n const type = parsePropertyTypePrefix(namePart.slice(0, colon))\n if (type) {\n return { name: namePart.slice(colon + 1).trim(), value, type }\n }\n }\n return { name: namePart, value }\n })\n}\n\n/**\n * Filter templates to only those matching the requested node IDs.\n */\nexport function filterTemplatesForNodes(\n nodeIds: string[],\n allTemplates: CodeConnectJSON[],\n): CodeConnectJSON[] {\n return allTemplates.filter((template) => {\n if (!template.figmaNode) return false\n const nodeIdMatch = template.figmaNode.match(/node-id=([^&\\s]+)/)\n if (!nodeIdMatch?.[1]) return false\n const templateNodeId = nodeIdMatch[1].replace(/-/g, ':')\n return nodeIds.includes(templateNodeId)\n })\n}\n\n/**\n * Aliases for Code Connect labels that don't directly match a Prettier language name.\n */\nconst CC_LABEL_ALIASES: Record<string, string> = {\n react: 'typescript',\n code: 'typescript',\n}\n\n/**\n * Map from Code Connect language labels to Prettier parser names,\n * built lazily from Prettier's getSupportInfo() on first access.\n * Lazy to avoid triggering plugin loading at module import time.\n */\nlet _prettierParserMap: Record<string, string> | null = null\n\nexport function getPrettierParserMap(): Record<string, string> {\n if (_prettierParserMap) return _prettierParserMap\n\n const info = prettier.getSupportInfo() as {\n languages: Array<{ name: string; parsers?: string[] }>\n }\n _prettierParserMap = {}\n\n for (const lang of info.languages) {\n if (lang.parsers?.[0]) {\n _prettierParserMap[lang.name.toLowerCase()] = lang.parsers[0]\n }\n }\n\n for (const [alias, target] of Object.entries(CC_LABEL_ALIASES)) {\n if (_prettierParserMap[target]) {\n _prettierParserMap[alias] = _prettierParserMap[target]\n }\n }\n\n return _prettierParserMap\n}\n\n/**\n * Check if a snippet can be parsed by Prettier.\n * Returns true for languages without a Prettier parser (nothing to validate).\n */\nexport async function isPrettierParseable(snippet: string, language?: string): Promise<boolean> {\n const lang = language?.toLowerCase()\n const parser = lang ? getPrettierParserMap()[lang] : 'typescript'\n\n if (!parser) {\n return true\n }\n\n try {\n await prettier.format(snippet, { parser })\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Format snippet with Prettier.\n * Returns the snippet unmodified for languages Prettier doesn't support.\n */\nexport async function formatSnippet(snippet: string, language?: string): Promise<string> {\n const lang = language?.toLowerCase()\n const parser = lang ? getPrettierParserMap()[lang] : 'typescript'\n\n if (!parser) {\n return snippet\n }\n\n try {\n let formatted = await prettier.format(snippet, {\n parser,\n semi: false,\n singleQuote: true,\n printWidth: 80,\n tabWidth: 2,\n })\n formatted = formatted.replace(/^;\\s*/, '')\n return formatted\n } catch {\n logger.info(`Autoformatting couldn't be applied: language not supported or code is malformed`)\n return snippet\n }\n}\n\n/**\n * Display results with terminal colors\n */\nconst purple = chalk.ansi256(93)\nconst red = chalk.ansi256(196)\nconst gray = chalk.ansi256(243)\nconst yellow = chalk.ansi256(179)\n\nexport function displayResults(results: PreviewResult[]): void {\n console.log('')\n const successCount = results.filter((r) => r.success).length\n const errorCount = results.filter((r) => !r.success).length\n\n // A muted note when nested children rendered as placeholders (not an error).\n const printUnresolved = (result: PreviewResult) => {\n if (!result.unresolvedInstances?.length) return\n const names = result.unresolvedInstances.map((u) => u.name || u.guid).join(', ')\n console.log(\n ` ${yellow(`⚠ ${result.unresolvedInstances.length} nested instance(s) not Code Connected: ${names}`)}`,\n )\n }\n\n for (const result of results) {\n const otherCombinations = (result.propertyCombinationCount ?? 1) - 1\n const moreCombinations =\n otherCombinations > 0\n ? ` (+${otherCombinations} more property combination${otherCombinations > 1 ? 's' : ''})`\n : ''\n const combinationSuffix = result.propertyCombinationLabel\n ? ` ${gray(`— ${result.propertyCombinationLabel}${moreCombinations}`)}`\n : ''\n if (result.success && result.snippet) {\n const componentInfo = result.component ? ` ${gray(`→ ${result.component}`)}` : ''\n console.log(\n `${purple('●')} ${chalk.bold(result.filePath)}${componentInfo}${combinationSuffix}`,\n )\n console.log(` ${gray(result.url)}`)\n console.log('')\n\n const indentedSnippet = result.snippet\n .trim()\n .split('\\n')\n .map((line) => ' ' + line)\n .join('\\n')\n console.log(indentedSnippet)\n printUnresolved(result)\n console.log('')\n } else {\n const componentInfo = result.component ? ` ${gray(`(${result.component})`)}` : ''\n console.log(`${red('✕')} ${chalk.bold(result.filePath)}${componentInfo}${combinationSuffix}`)\n console.log(` ${gray(result.url)}`)\n console.log(` ${red('Error:')} ${result.error}`)\n // One-line repair hint: the offending property and the real vocabulary.\n // (Transport errors carry no vocabulary — nothing to hint.)\n const available = result.errorDetails?.availableProperties?.map((p) => p.name).join(', ')\n const missingProperty = result.errorDetails?.missingProperty\n if (missingProperty && available) {\n console.log(\n ` ${gray(`property \"${missingProperty}\" not found — available: ${available}`)}`,\n )\n } else if (available) {\n console.log(` ${gray(`available properties: ${available}`)}`)\n }\n printUnresolved(result)\n console.log('')\n }\n }\n\n const failed = errorCount > 0 ? red(`${errorCount} failed`) : gray(`${errorCount} failed`)\n console.log(`${chalk.bold('Summary:')} ${purple(`${successCount} succeeded`)}, ${failed}`)\n}\n\n// The server caps inbound request bodies at 5MB. The figmaDocs payload\n// (one Code Connect template per requested component) dominates the body size,\n// so for projects with many components we split into smaller chunks and send\n// them in parallel rather than risking a 413.\nconst PREVIEW_CHUNK_SIZE = 50\n// Bound the number of chunks in flight at once. Without this cap, large\n// libraries (~1k+ components) trigger N parallel preview requests, which\n// overwhelms upstream token validation and causes spurious 403 \"Invalid\n// token\" responses for the chunks that queue up too long.\nconst PREVIEW_MAX_CONCURRENCY = 5\n// Mirrors MAX_PROPERTY_COMBINATIONS_PER_REQUEST in pixie/code_connect_preview_handler.ts.\n// `--all` caps enumeration here and warns rather than sending a request that fails wholesale.\nconst MAX_PROPERTY_COMBINATIONS = 500\n\nexport function parseMaxCombinationsArg(value: string | undefined): number {\n if (value === undefined) {\n return MAX_PROPERTY_COMBINATIONS\n }\n const parsed = Number(value)\n if (!Number.isInteger(parsed) || parsed < 1) {\n exitWithError('--max-combinations must be a positive integer')\n }\n if (parsed > MAX_PROPERTY_COMBINATIONS) {\n exitWithError(`--max-combinations cannot exceed ${MAX_PROPERTY_COMBINATIONS}`)\n }\n return parsed\n}\n\ntype PreviewResponseData = {\n status: number\n error: boolean\n meta: {\n results: Array<{\n nodeId: string\n nodeUrl: string\n snippet?: string\n language?: string\n component?: string\n error?: string\n propertyCombinationLabel?: string\n errorKind?: string\n unresolvedInstances?: Array<{ guid: string; name?: string; kind: 'instance' | 'slot' }>\n }>\n }\n}\n\ntype ChunkOutcome = {\n chunkNodeIds: string[]\n response: Awaited<ReturnType<typeof request.post<PreviewResponseData>>> | null\n error: unknown\n}\n\nfunction chunkArray<T>(arr: T[], size: number): T[][] {\n const chunks: T[][] = []\n for (let i = 0; i < arr.length; i += size) {\n chunks.push(arr.slice(i, i + size))\n }\n return chunks\n}\n\n/**\n * Split node IDs into request chunks that respect BOTH the node-count cap\n * (PREVIEW_CHUNK_SIZE) and, when rendering property combinations, the server's\n * per-request combination cap (MAX_PROPERTY_COMBINATIONS).\n *\n * The server sums combinations across every node in a request and rejects the\n * whole request if the total exceeds the cap, so bundling by node count alone\n * can push several individually-valid nodes over the limit and fail them all.\n * Each node is already truncated to <= MAX_PROPERTY_COMBINATIONS upstream, so a\n * single node always fits (worst case: one node per chunk).\n */\nexport function chunkNodeIdsForPreview(\n nodeIds: string[],\n propertyCombinationsByNodeId?: Record<string, PropertyCombination[]>,\n): string[][] {\n if (!propertyCombinationsByNodeId) {\n return chunkArray(nodeIds, PREVIEW_CHUNK_SIZE)\n }\n\n const chunks: string[][] = []\n let current: string[] = []\n let currentCombinations = 0\n for (const nodeId of nodeIds) {\n const count = propertyCombinationsByNodeId[nodeId]?.length ?? 0\n // Close the current chunk before adding this node would breach either cap.\n if (\n current.length > 0 &&\n (current.length >= PREVIEW_CHUNK_SIZE ||\n currentCombinations + count > MAX_PROPERTY_COMBINATIONS)\n ) {\n chunks.push(current)\n current = []\n currentCombinations = 0\n }\n current.push(nodeId)\n currentCombinations += count\n }\n if (current.length > 0) chunks.push(current)\n return chunks\n}\n\nasync function runInWaves<T, R>(\n items: T[],\n fn: (item: T) => Promise<R>,\n maxConcurrency: number,\n): Promise<R[]> {\n const out: R[] = []\n for (let i = 0; i < items.length; i += maxConcurrency) {\n const wave = items.slice(i, i + maxConcurrency)\n const settled = await Promise.all(wave.map(fn))\n out.push(...settled)\n }\n return out\n}\n\nfunction sendPreviewChunk({\n chunkNodeIds,\n requiredTemplates,\n baseApiUrl,\n fileKey,\n accessToken,\n propertyCombinationsByNodeId,\n}: {\n chunkNodeIds: string[]\n requiredTemplates: CodeConnectJSON[]\n baseApiUrl: string\n fileKey: string\n accessToken: string\n propertyCombinationsByNodeId?: Record<string, PropertyCombination[]>\n}): Promise<ChunkOutcome> {\n const chunkTemplates = filterTemplatesForNodes(chunkNodeIds, requiredTemplates)\n // Only include property combinations for the node IDs in this chunk.\n let renderCombinations: Record<string, PropertyCombination[]> | undefined\n if (propertyCombinationsByNodeId) {\n renderCombinations = {}\n for (const nodeId of chunkNodeIds) {\n if (propertyCombinationsByNodeId[nodeId]) {\n renderCombinations[nodeId] = propertyCombinationsByNodeId[nodeId]\n }\n }\n }\n return request\n .post<PreviewResponseData>(\n `${baseApiUrl}/code_connect/preview_snippets?file_key=${fileKey}`,\n {\n nodeIds: chunkNodeIds,\n figmaDocs: { all: chunkTemplates },\n ...(renderCombinations && Object.keys(renderCombinations).length > 0\n ? { renderCombinations }\n : {}),\n },\n { headers: getHeaders(accessToken) },\n )\n .then((response) => ({ chunkNodeIds, response, error: null as unknown }))\n .catch((err: unknown) => ({ chunkNodeIds, response: null, error: err }))\n}\n\n/**\n * Parse the offending property name out of a \"property not found\" render error,\n * e.g. `PropertyNotFoundError: property 'Varient' not found` -> `Varient`.\n */\nexport function parseMissingProperty(error?: string): string | undefined {\n if (!error) return undefined\n const match =\n error.match(/propert(?:y|ies)[^'\"`]*['\"`]([^'\"`]+)['\"`]/i) ?? error.match(/['\"`]([^'\"`]+)['\"`]/)\n return match?.[1]\n}\n\n/** Build `errorDetails` for a failed result. Undefined when there's no property context (not --all). */\nfunction buildErrorDetails(\n error: string | undefined,\n errorKind: string | undefined,\n availableProperties: AvailableProperty[] | undefined,\n): PreviewResult['errorDetails'] {\n // Transport failure: network/backend problem, not a bad property — carry only the kind.\n if (errorKind === 'transport') return { kind: 'transport' }\n if (!availableProperties) return undefined\n const details: NonNullable<PreviewResult['errorDetails']> = { availableProperties }\n if (errorKind) details.kind = errorKind\n const missingProperty = parseMissingProperty(error)\n if (missingProperty) details.missingProperty = missingProperty\n return details\n}\n\nexport function chunkOutcomeToResults(\n outcome: ChunkOutcome,\n nodes: NodeToPreview[],\n fileKey: string,\n availablePropsByNodeId?: Record<string, AvailableProperty[]>,\n): PreviewResult[] {\n const { chunkNodeIds, response, error } = outcome\n const results: PreviewResult[] = []\n\n if (error) {\n const errorMsg = isFetchError(error)\n ? error.data?.message || error.response.statusText\n : String(error)\n // 503 means the server-side killswitch is on — surface the server's\n // message directly without the per-file/per-node noise so the user\n // sees a single clear line during an incident.\n if (isFetchError(error) && error.response.status === 503) {\n exitWithError(errorMsg)\n } else {\n logger.error(`Failed to preview components in file ${fileKey}: ${errorMsg}`)\n for (const nodeId of chunkNodeIds) {\n for (const node of nodes.filter((n) => n.nodeId === nodeId)) {\n results.push({\n url: node.url,\n nodeId: node.nodeId,\n filePath: node.filePath,\n success: false,\n error: errorMsg,\n // Chunk-level failure is a server/network error, not a template problem.\n errorDetails: { kind: 'transport' },\n })\n }\n }\n }\n return results\n }\n\n if (response!.response.status === 200 && response!.data.meta?.results) {\n // Track match index per nodeId so duplicate node IDs get the correct file attribution.\n // The server returns results in the same order as the templates we sent. Each chunk's\n // nodeIds are disjoint (we dedupe before chunking), so per-chunk indexing is correct.\n // Property-combination results are expanded renders of one node, not one result per\n // matching template, so they should not consume this per-template index.\n const nodeMatchIndex: Record<string, number> = {}\n for (const result of response!.data.meta.results) {\n const idx = nodeMatchIndex[result.nodeId] ?? 0\n const matchingNodes = nodes.filter((n) => n.nodeId === result.nodeId)\n const node = result.propertyCombinationLabel\n ? matchingNodes[0]\n : matchingNodes[idx] || matchingNodes[0]\n if (!result.propertyCombinationLabel) {\n nodeMatchIndex[result.nodeId] = idx + 1\n }\n const error = result.error || (!result.snippet ? 'No snippet returned by server' : undefined)\n const success = !result.error && !!result.snippet\n results.push({\n url: node?.url || result.nodeUrl,\n nodeId: result.nodeId,\n filePath: node?.filePath || '',\n success,\n snippet: result.snippet,\n language: result.language,\n component: result.component,\n error,\n ...(result.propertyCombinationLabel\n ? { propertyCombinationLabel: result.propertyCombinationLabel }\n : {}),\n ...(result.unresolvedInstances?.length\n ? { unresolvedInstances: result.unresolvedInstances }\n : {}),\n ...(success\n ? {}\n : {\n errorDetails: buildErrorDetails(\n error,\n result.errorKind,\n availablePropsByNodeId?.[result.nodeId],\n ),\n }),\n })\n }\n return results\n }\n\n for (const nodeId of chunkNodeIds) {\n for (const node of nodes.filter((n) => n.nodeId === nodeId)) {\n const error = `API request failed with status ${response!.response.status}`\n results.push({\n url: node.url,\n nodeId: node.nodeId,\n filePath: node.filePath,\n success: false,\n error,\n // Non-2xx from the endpoint is a transport-level failure, not a template problem.\n errorDetails: { kind: 'transport' },\n })\n }\n }\n return results\n}\n\nasync function previewFile({\n fileKey,\n nodes,\n baseApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n propertyCombinationsByNodeId,\n availablePropsByNodeId,\n}: {\n fileKey: string\n nodes: NodeToPreview[]\n baseApiUrl: string\n accessToken: string\n dir: string\n allCodeConnectObjects: CodeConnectJSON[]\n propertyCombinationsByNodeId?: Record<string, PropertyCombination[]>\n availablePropsByNodeId?: Record<string, AvailableProperty[]>\n}): Promise<PreviewResult[]> {\n const allNodeIds = nodes.map((n) => n.nodeId)\n // Deduplicate — multiple figma.connect() calls may share the same nodeId;\n // the individual templates are sent in figmaDocs and the server iterates per-template.\n const nodeIds = [...new Set(allNodeIds)]\n\n // Only send templates from the requested files — other files' templates\n // for the same nodeId exist on the server and shouldn't be rendered individually.\n const requestedFilePaths = new Set(nodes.map((n) => path.resolve(dir, n.filePath)))\n const requiredTemplates = filterTemplatesForNodes(allNodeIds, allCodeConnectObjects).filter((t) =>\n requestedFilePaths.has(path.resolve(t._codeConnectFilePath || '')),\n )\n\n const chunks = chunkNodeIdsForPreview(nodeIds, propertyCombinationsByNodeId)\n const outcomes = await runInWaves(\n chunks,\n (chunkNodeIds) =>\n sendPreviewChunk({\n chunkNodeIds,\n requiredTemplates,\n baseApiUrl,\n fileKey,\n accessToken,\n propertyCombinationsByNodeId,\n }),\n PREVIEW_MAX_CONCURRENCY,\n )\n\n return outcomes.flatMap((outcome) =>\n chunkOutcomeToResults(outcome, nodes, fileKey, availablePropsByNodeId),\n )\n}\n\nfunction collectAllLocalNodesToPreview(\n allCodeConnectObjects: CodeConnectJSON[],\n dir: string,\n cmd: BaseCommand,\n): NodeToPreview[] {\n const nodesToCheck: NodeToPreview[] = []\n for (const doc of allCodeConnectObjects) {\n const parsed = parseFigmaNode(cmd.verbose, doc, true)\n if (parsed) {\n nodesToCheck.push({\n fileKey: parsed.fileKey,\n nodeId: parsed.nodeId,\n url: doc.figmaNode,\n filePath: path.relative(dir, doc._codeConnectFilePath || ''),\n })\n }\n }\n return nodesToCheck\n}\n\nfunction groupNodesByFileKey(nodes: NodeToPreview[]): NodesByFileKey {\n const nodesByFileKey: NodesByFileKey = {}\n for (const node of nodes) {\n nodesByFileKey[node.fileKey] ??= []\n nodesByFileKey[node.fileKey].push(node)\n }\n return nodesByFileKey\n}\n\nasync function handleInspect({\n nodesByFileKey,\n configuredApiUrl,\n accessToken,\n outputFormat,\n}: {\n nodesByFileKey: NodesByFileKey\n configuredApiUrl?: string\n accessToken: string\n outputFormat: string\n}): Promise<void> {\n const items: PropertyListItem[] = []\n const seen = new Set<string>()\n for (const [fileKey, nodes] of Object.entries(nodesByFileKey)) {\n const baseApiUrl = getApiUrl(nodes[0].url, configuredApiUrl)\n for (const node of nodes) {\n const dedupeKey = `${node.filePath}::${node.nodeId}`\n if (seen.has(dedupeKey)) continue\n seen.add(dedupeKey)\n const result = await fetchComponentPropertyDefinitions(\n baseApiUrl,\n fileKey,\n node.nodeId,\n accessToken,\n )\n if (result.status === 'error') {\n logger.warn(`Couldn't fetch property definitions for node ${node.nodeId}`)\n } else if (result.status === 'empty') {\n logger.info(`Node ${node.nodeId} has no component properties or variants.`)\n }\n items.push({\n filePath: node.filePath,\n nodeId: node.nodeId,\n availableProperties: result.status === 'ok' ? toAvailableProperties(result.defs) : [],\n })\n }\n }\n\n if (outputFormat === 'json') {\n console.log(JSON.stringify(items, null, 2))\n } else {\n displayPropertyList(items)\n }\n}\n\n/**\n * `--unique` implies `--all`, so errors about combination expansion should name\n * the flag the user actually typed rather than the one commander set on their\n * behalf.\n */\nfunction expandFlagName(cmd: PreviewCommand): '--all' | '--unique' {\n return cmd.unique ? '--unique' : '--all'\n}\n\nexport function validatePreviewOptions(cmd: PreviewCommand): void {\n if (cmd.all && cmd.props) {\n const implied = cmd.unique ? ' (which implies --all)' : ''\n exitWithError(\n `Cannot combine --props and ${expandFlagName(cmd)}${implied}; use one or the other`,\n )\n }\n\n if (cmd.maxCombinations !== undefined && !cmd.all) {\n exitWithError('--max-combinations can only be used with --all or --unique')\n }\n}\n\nasync function buildPropertyPreviewInputs({\n enabled,\n baseApiUrl,\n fileKey,\n nodes,\n accessToken,\n propsPairs,\n maxCombinations,\n}: {\n enabled: boolean\n baseApiUrl: string\n fileKey: string\n nodes: NodeToPreview[]\n accessToken: string\n propsPairs?: ParsedPropertyPair[]\n maxCombinations: number\n}): Promise<{\n propertyCombinationsByNodeId?: Record<string, PropertyCombination[]>\n availablePropsByNodeId?: Record<string, AvailableProperty[]>\n}> {\n if (!enabled) return {}\n\n const propertyCombinationsByNodeId: Record<string, PropertyCombination[]> = {}\n const availablePropsByNodeId: Record<string, AvailableProperty[]> = {}\n const uniqueNodeIds = [...new Set(nodes.map((n) => n.nodeId))]\n const definitionsByNodeId = await fetchComponentPropertyDefinitionsBatch(\n baseApiUrl,\n fileKey,\n uniqueNodeIds,\n accessToken,\n )\n for (const nodeId of uniqueNodeIds) {\n const result = definitionsByNodeId[nodeId] ?? { status: 'error' }\n if (result.status === 'error') {\n logger.warn(\n `Couldn't fetch property definitions for node ${nodeId} (ensure your token has the ` +\n `Code Connect: Write and File content: Read scopes); rendering its default property combination only`,\n )\n continue\n }\n if (result.status === 'empty') {\n // Not an error: the component simply has no properties or variants to vary.\n if (propsPairs) {\n logger.warn(\n `Node ${nodeId} has no component properties or variants, so --props ` +\n `(${propsPairs.map((p) => p.name).join(', ')}) has no effect; rendering its only property combination.`,\n )\n } else {\n logger.info(\n `Node ${nodeId} has no component properties or variants to vary; rendering its only property combination.`,\n )\n }\n continue\n }\n\n const defs = result.defs\n if (propsPairs) {\n const { propertyCombination, availableProperties, unknown, invalid, ambiguous } =\n buildPropertyCombinationFromProps(defs, propsPairs)\n if (unknown.length > 0) {\n logger.warn(\n `Unknown propert${unknown.length > 1 ? 'ies' : 'y'} for node ${nodeId}: ${unknown.join(', ')}. ` +\n `Available: ${availableProperties.map((p) => p.name).join(', ')}`,\n )\n }\n for (const { name, value, options } of invalid) {\n logger.warn(\n `\"${value}\" is not a valid value for ${name} on node ${nodeId}. Options: ${options.join(', ')}`,\n )\n }\n for (const { name, types } of ambiguous) {\n logger.warn(\n `Property \"${name}\" on node ${nodeId} matches multiple types (${types.join(', ')}); ` +\n `prefix the value with a type to disambiguate, e.g. ${types[0]}:${name}=... . Skipping.`,\n )\n }\n availablePropsByNodeId[nodeId] = availableProperties\n propertyCombinationsByNodeId[nodeId] = [propertyCombination]\n } else {\n const { propertyCombinations, availableProperties, truncated } =\n enumeratePropertyCombinations(defs, {\n maxCombinations,\n })\n availablePropsByNodeId[nodeId] = availableProperties\n if (truncated) {\n logger.warn(\n `Node ${nodeId} has ${truncated.total} property combinations, exceeding the ${truncated.cap}-combination ` +\n `preview limit; rendering the first ${truncated.cap}. Use --props to preview a ` +\n `specific property combination.`,\n )\n }\n if (propertyCombinations.length > 0) {\n propertyCombinationsByNodeId[nodeId] = propertyCombinations\n }\n }\n }\n\n return { propertyCombinationsByNodeId, availablePropsByNodeId }\n}\n\nasync function previewNodesForFile({\n fileKey,\n nodes,\n configuredApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n renderPropertyCombinations,\n propsPairs,\n maxCombinations,\n}: {\n fileKey: string\n nodes: NodeToPreview[]\n configuredApiUrl?: string\n accessToken: string\n dir: string\n allCodeConnectObjects: CodeConnectJSON[]\n renderPropertyCombinations: boolean\n propsPairs?: ParsedPropertyPair[]\n maxCombinations: number\n}): Promise<PreviewResult[]> {\n const baseApiUrl = getApiUrl(nodes[0].url, configuredApiUrl)\n const { propertyCombinationsByNodeId, availablePropsByNodeId } = await buildPropertyPreviewInputs(\n {\n enabled: renderPropertyCombinations,\n baseApiUrl,\n fileKey,\n nodes,\n accessToken,\n propsPairs,\n maxCombinations,\n },\n )\n\n return previewFile({\n fileKey,\n nodes,\n baseApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n propertyCombinationsByNodeId,\n availablePropsByNodeId,\n })\n}\n\nasync function validateRenderedSnippets(results: PreviewResult[]): Promise<void> {\n for (const result of results) {\n if (result.success && result.snippet) {\n const prettierValid = await isPrettierParseable(result.snippet, result.language)\n if (!prettierValid) {\n // Prettier can parse this language but failed — mark as error\n result.success = false\n result.error = 'Snippet has syntax errors and may not be valid code'\n }\n }\n }\n}\n\nasync function outputPreviewResults(results: PreviewResult[], outputFormat: string): Promise<void> {\n if (outputFormat === 'json') {\n console.log(JSON.stringify(results, null, 2))\n return\n }\n\n const formattedResults: PreviewResult[] = await Promise.all(\n results.map(async (result) => {\n if (result.success && result.snippet) {\n const formattedSnippet = await formatSnippet(result.snippet, result.language)\n return { ...result, snippet: formattedSnippet }\n }\n return result\n }),\n )\n displayResults(formattedResults)\n}\n\n/**\n * Handle the preview command\n */\nexport async function handlePreview(files: string[], cmd: PreviewCommand) {\n setupHandler(cmd)\n\n const dir = cmd.dir ?? process.cwd()\n const projectInfo = await getProjectInfo(dir, cmd.config)\n const accessToken = getAccessTokenOrExit(cmd)\n const outputFormat = cmd.output || 'table'\n const configuredApiUrl = cmd.apiUrl || projectInfo.config.apiUrl\n\n if (cmd.all && (!files || files.length === 0)) {\n const flag = expandFlagName(cmd)\n exitWithError(\n `${flag} requires a specific component, e.g. \\`figma connect preview Button.figma.ts ${flag}\\``,\n )\n }\n\n const allCodeConnectObjects = await getCodeConnectObjects(cmd, projectInfo, { silent: true })\n\n const nodesToCheck =\n files && files.length > 0\n ? await collectNodesToPreview(files, allCodeConnectObjects, dir, cmd)\n : collectAllLocalNodesToPreview(allCodeConnectObjects, dir, cmd)\n if (!files || files.length === 0) {\n logger.info('Previewing all local Code Connect files...')\n }\n\n if (nodesToCheck.length === 0) {\n exitWithError('No valid Code Connect files found to preview')\n }\n\n logger.info(`Previewing ${nodesToCheck.length} component(s)...`)\n const nodesByFileKey = groupNodesByFileKey(nodesToCheck)\n\n if (cmd.inspect) {\n await handleInspect({\n nodesByFileKey,\n configuredApiUrl,\n accessToken,\n outputFormat,\n })\n return\n }\n\n validatePreviewOptions(cmd)\n const maxCombinations = parseMaxCombinationsArg(cmd.maxCombinations)\n const propsPairs = cmd.props ? parsePropsArg(cmd.props) : undefined\n\n const results: PreviewResult[] = []\n for (const [fileKey, nodes] of Object.entries(nodesByFileKey)) {\n const fileResults = await previewNodesForFile({\n fileKey,\n nodes,\n configuredApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n renderPropertyCombinations: cmd.all || !!propsPairs,\n propsPairs,\n maxCombinations,\n })\n results.push(...fileResults)\n }\n\n await validateRenderedSnippets(results)\n\n const outputResults = cmd.unique ? collapsePreviewResults(results) : results\n if (cmd.unique && outputResults.length !== results.length) {\n logger.info(\n `${outputResults.length} distinct of ${results.length} rendered property combinations`,\n )\n }\n\n await outputPreviewResults(outputResults, outputFormat)\n\n if (outputResults.every((r) => !r.success)) {\n process.exit(1)\n }\n}\n"]}
|
package/dist/common/updates.d.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { BaseCommand } from '../commands/connect';
|
|
2
2
|
import { Command } from 'commander';
|
|
3
|
-
export declare function flagParserBasedCodeConnect(): void;
|
|
4
3
|
type CommandArgs<T extends BaseCommand> = [...any[], T, Command];
|
|
5
|
-
export declare function
|
|
6
|
-
hideDeprecationWarning?: boolean;
|
|
7
|
-
}): (...args: CommandArgs<T>) => void | Promise<void>;
|
|
4
|
+
export declare function withUpdateCheck<T extends BaseCommand>(fn: (...args: any[]) => void | Promise<void>): (...args: CommandArgs<T>) => void | Promise<void>;
|
|
8
5
|
export declare function exitWithUpdateCheck(errorCode?: number): never;
|
|
9
6
|
export declare function updateCli(): void;
|
|
10
7
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updates.d.ts","sourceRoot":"","sources":["../../src/common/updates.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"updates.d.ts","sourceRoot":"","sources":["../../src/common/updates.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AASnC,KAAK,WAAW,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAA;AAIhE,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,EAGnD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAEpC,GAAG,MAAM,WAAW,CAAC,CAAC,CAAC,0BAqBhC;AAyCD,wBAAgB,mBAAmB,CAAC,SAAS,SAAI,GAAG,KAAK,CAKxD;AAkBD,wBAAgB,SAAS,SAGxB"}
|