Rust artifact graph (#5068)
* Start porting artifact graph creation to Rust * Add most of artifact graph creation * Add handling loft command from recent PR * Refactor artifact merge code so that it errors when a new artifact type is added * Add sweep subtype * Finish implementation of build artifact graph * Fix wasm.ts to use new combined generated ts-rs file * Fix Rust lints * Fix lints * Fix up replacement code * Add artifact graph to WASM outcome * Add artifact graph to simulation test output * Add new artifact graph output snapshots * Fix wall field and reduce unreachable code * Change field order for subtype * Change subtype to be determined from the request, like the TS * Fix plane sweep_id * Condense code * Change ID types to be properly optional * Change to favor the new ID, the same as TS * Fix to make error impossible * Rename artifact type tag values to match TS * Fix name of field on Cap * Update outputs * Change to use Rust source range * Update output snapshots * Add conversion to mermaid mind map and add to snapshot tests * Add new mermaid mind map output * Add flowchart * Remove raw artifact graph from tests * Remove JSON artifact graph output * Update output file with header * Update output after adding flowchart * Fix flowchart to not have duplicate edges, one in each direction * Fix not not output duplicate edges in flowcharts * Change flowchart edge style to be more obvious when a direction is missing * Update output after deduplication of edges * Fix not not skip sketch-on-face artifacts * Add docs * Fix edge iteration order to be stable * Update output after fixing order * Port TS artifactGraph.test.ts tests to simulation tests * Add grouping segments and solid2ds with their path * Update output flowcharts since grouping paths * Remove TS artifactGraph tests * Remove unused d3 dependencies * Fix to track loft ID on paths * Add command ID to error messages * Move artifact graph test code to a separate file since it's a large file * Reduce function visibility * Remove TS artifact graph code * Fix spelling error with serde * Add TODO for edge cut consumed ID * Add comment about mermaid edge rank * Fix mermaid flowchart edge cuts to appear as children of their edges * Update output since fixing flowchart order * Fix to always build the artifact graph even when there's a KCL error * Add artifact graph to error output * Change optional ID merge to match TS * Remove redundant SourceRange definition * Remove Rust-flavored default source range function * Add helper for source range creation * Update doc comment for the website * Update docs after doc comment change * Fix to save engine responses in execution cache * Remove unused import * Fix to not call WASM function before beforeAll callback is run * Remove more unused imports
This commit is contained in:
@ -12,6 +12,7 @@ import {
|
||||
VariableDeclaration,
|
||||
Identifier,
|
||||
sketchFromKclValue,
|
||||
topLevelRange,
|
||||
} from 'lang/wasm'
|
||||
import {
|
||||
getNodeFromPath,
|
||||
@ -222,7 +223,7 @@ const commonConstraintInfoHelper = (
|
||||
code.slice(input1.start, input1.end),
|
||||
stdLibFnName,
|
||||
isArr ? abbreviatedInputs[0].arrayInput : abbreviatedInputs[0].objInput,
|
||||
[input1.start, input1.end, true],
|
||||
topLevelRange(input1.start, input1.end),
|
||||
pathToFirstArg
|
||||
)
|
||||
)
|
||||
@ -234,7 +235,7 @@ const commonConstraintInfoHelper = (
|
||||
code.slice(input2.start, input2.end),
|
||||
stdLibFnName,
|
||||
isArr ? abbreviatedInputs[1].arrayInput : abbreviatedInputs[1].objInput,
|
||||
[input2.start, input2.end, true],
|
||||
topLevelRange(input2.start, input2.end),
|
||||
pathToSecondArg
|
||||
)
|
||||
)
|
||||
@ -266,7 +267,7 @@ const horzVertConstraintInfoHelper = (
|
||||
callee.name,
|
||||
stdLibFnName,
|
||||
undefined,
|
||||
[callee.start, callee.end, true],
|
||||
topLevelRange(callee.start, callee.end),
|
||||
pathToCallee
|
||||
),
|
||||
constrainInfo(
|
||||
@ -275,7 +276,7 @@ const horzVertConstraintInfoHelper = (
|
||||
code.slice(firstArg.start, firstArg.end),
|
||||
stdLibFnName,
|
||||
abbreviatedInput,
|
||||
[firstArg.start, firstArg.end, true],
|
||||
topLevelRange(firstArg.start, firstArg.end),
|
||||
pathToFirstArg
|
||||
),
|
||||
]
|
||||
@ -905,7 +906,7 @@ export const tangentialArcTo: SketchLineHelper = {
|
||||
callee.name,
|
||||
'tangentialArcTo',
|
||||
undefined,
|
||||
[callee.start, callee.end, true],
|
||||
topLevelRange(callee.start, callee.end),
|
||||
pathToCallee
|
||||
),
|
||||
constrainInfo(
|
||||
@ -914,7 +915,7 @@ export const tangentialArcTo: SketchLineHelper = {
|
||||
code.slice(firstArg.elements[0].start, firstArg.elements[0].end),
|
||||
'tangentialArcTo',
|
||||
0,
|
||||
[firstArg.elements[0].start, firstArg.elements[0].end, true],
|
||||
topLevelRange(firstArg.elements[0].start, firstArg.elements[0].end),
|
||||
pathToFirstArg
|
||||
),
|
||||
constrainInfo(
|
||||
@ -923,7 +924,7 @@ export const tangentialArcTo: SketchLineHelper = {
|
||||
code.slice(firstArg.elements[1].start, firstArg.elements[1].end),
|
||||
'tangentialArcTo',
|
||||
1,
|
||||
[firstArg.elements[1].start, firstArg.elements[1].end, true],
|
||||
topLevelRange(firstArg.elements[1].start, firstArg.elements[1].end),
|
||||
pathToSecondArg
|
||||
),
|
||||
]
|
||||
@ -1052,7 +1053,7 @@ export const circle: SketchLineHelper = {
|
||||
code.slice(radiusDetails.expr.start, radiusDetails.expr.end),
|
||||
'circle',
|
||||
'radius',
|
||||
[radiusDetails.expr.start, radiusDetails.expr.end, true],
|
||||
topLevelRange(radiusDetails.expr.start, radiusDetails.expr.end),
|
||||
pathToRadiusLiteral
|
||||
),
|
||||
{
|
||||
@ -1061,11 +1062,10 @@ export const circle: SketchLineHelper = {
|
||||
isConstrained: isNotLiteralArrayOrStatic(
|
||||
centerDetails.expr.elements[0]
|
||||
),
|
||||
sourceRange: [
|
||||
sourceRange: topLevelRange(
|
||||
centerDetails.expr.elements[0].start,
|
||||
centerDetails.expr.elements[0].end,
|
||||
true,
|
||||
],
|
||||
centerDetails.expr.elements[0].end
|
||||
),
|
||||
pathToNode: pathToXArg,
|
||||
value: code.slice(
|
||||
centerDetails.expr.elements[0].start,
|
||||
@ -1083,11 +1083,10 @@ export const circle: SketchLineHelper = {
|
||||
isConstrained: isNotLiteralArrayOrStatic(
|
||||
centerDetails.expr.elements[1]
|
||||
),
|
||||
sourceRange: [
|
||||
sourceRange: topLevelRange(
|
||||
centerDetails.expr.elements[1].start,
|
||||
centerDetails.expr.elements[1].end,
|
||||
true,
|
||||
],
|
||||
centerDetails.expr.elements[1].end
|
||||
),
|
||||
pathToNode: pathToYArg,
|
||||
value: code.slice(
|
||||
centerDetails.expr.elements[1].start,
|
||||
@ -1763,7 +1762,7 @@ export const angledLineThatIntersects: SketchLineHelper = {
|
||||
code.slice(angle.start, angle.end),
|
||||
'angledLineThatIntersects',
|
||||
'angle',
|
||||
[angle.start, angle.end, true],
|
||||
topLevelRange(angle.start, angle.end),
|
||||
pathToAngleProp
|
||||
)
|
||||
)
|
||||
@ -1782,7 +1781,7 @@ export const angledLineThatIntersects: SketchLineHelper = {
|
||||
code.slice(offset.start, offset.end),
|
||||
'angledLineThatIntersects',
|
||||
'offset',
|
||||
[offset.start, offset.end, true],
|
||||
topLevelRange(offset.start, offset.end),
|
||||
pathToOffsetProp
|
||||
)
|
||||
)
|
||||
@ -1801,7 +1800,7 @@ export const angledLineThatIntersects: SketchLineHelper = {
|
||||
code.slice(tag.start, tag.end),
|
||||
'angledLineThatIntersects',
|
||||
'intersectTag',
|
||||
[tag.start, tag.end, true],
|
||||
topLevelRange(tag.start, tag.end),
|
||||
pathToTagProp
|
||||
)
|
||||
returnVal.push(info)
|
||||
|
Reference in New Issue
Block a user