Fix SourceRange values in OrderedCommands to match the TS type (#4785)
* Fix SourceRange type to match WASM commands * Update artifact graph test snap * Update artifact graph test
This commit is contained in:
@ -13,7 +13,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
12,
|
12,
|
||||||
31,
|
31,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"id": "UUID",
|
"id": "UUID",
|
||||||
@ -33,7 +33,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
37,
|
37,
|
||||||
64,
|
64,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"id": "UUID",
|
"id": "UUID",
|
||||||
@ -60,7 +60,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
70,
|
70,
|
||||||
86,
|
86,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -83,7 +83,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
92,
|
92,
|
||||||
119,
|
119,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeCutId": "UUID",
|
"edgeCutId": "UUID",
|
||||||
@ -107,7 +107,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
125,
|
125,
|
||||||
150,
|
150,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -130,7 +130,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
156,
|
156,
|
||||||
203,
|
203,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -153,7 +153,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
209,
|
209,
|
||||||
217,
|
217,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [],
|
"edgeIds": [],
|
||||||
@ -177,7 +177,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
231,
|
231,
|
||||||
254,
|
254,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -320,7 +320,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
260,
|
260,
|
||||||
299,
|
299,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"consumedEdgeId": "UUID",
|
"consumedEdgeId": "UUID",
|
||||||
@ -340,7 +340,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
350,
|
350,
|
||||||
377,
|
377,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"id": "UUID",
|
"id": "UUID",
|
||||||
@ -366,7 +366,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
383,
|
383,
|
||||||
398,
|
398,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -389,7 +389,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
404,
|
404,
|
||||||
420,
|
420,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -412,7 +412,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
426,
|
426,
|
||||||
473,
|
473,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
@ -435,7 +435,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
479,
|
479,
|
||||||
487,
|
487,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [],
|
"edgeIds": [],
|
||||||
@ -459,7 +459,7 @@ Map {
|
|||||||
"range": [
|
"range": [
|
||||||
501,
|
501,
|
||||||
522,
|
522,
|
||||||
0,
|
true,
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
"edgeIds": [
|
"edgeIds": [
|
||||||
|
@ -661,7 +661,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
sweepId: '',
|
sweepId: '',
|
||||||
codeRef: {
|
codeRef: {
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
range: [37, 64, 0],
|
range: [37, 64, true],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
@ -674,7 +674,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: [],
|
surfaceIds: [],
|
||||||
edgeIds: [],
|
edgeIds: [],
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254, 0],
|
range: [231, 254, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -685,7 +685,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
planeId: expect.any(String),
|
planeId: expect.any(String),
|
||||||
sweepId: expect.any(String),
|
sweepId: expect.any(String),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [37, 64, 0],
|
range: [37, 64, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
solid2dId: expect.any(String),
|
solid2dId: expect.any(String),
|
||||||
@ -699,7 +699,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceId: '',
|
surfaceId: '',
|
||||||
edgeIds: [],
|
edgeIds: [],
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [70, 86, 0],
|
range: [70, 86, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -710,7 +710,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
planeId: expect.any(String),
|
planeId: expect.any(String),
|
||||||
sweepId: expect.any(String),
|
sweepId: expect.any(String),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [37, 64, 0],
|
range: [37, 64, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
solid2dId: expect.any(String),
|
solid2dId: expect.any(String),
|
||||||
@ -725,7 +725,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
edgeIds: [],
|
edgeIds: [],
|
||||||
surfaceId: '',
|
surfaceId: '',
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [260, 299, 0],
|
range: [260, 299, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -736,7 +736,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceId: expect.any(String),
|
surfaceId: expect.any(String),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [92, 119, 0],
|
range: [92, 119, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
edgeCutId: expect.any(String),
|
edgeCutId: expect.any(String),
|
||||||
@ -758,7 +758,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceId: expect.any(String),
|
surfaceId: expect.any(String),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [156, 203, 0],
|
range: [156, 203, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -770,7 +770,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: expect.any(Array),
|
surfaceIds: expect.any(Array),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254, 0],
|
range: [231, 254, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -789,7 +789,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceId: expect.any(String),
|
surfaceId: expect.any(String),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [125, 150, 0],
|
range: [125, 150, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -801,7 +801,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: expect.any(Array),
|
surfaceIds: expect.any(Array),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254, 0],
|
range: [231, 254, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -820,7 +820,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceId: expect.any(String),
|
surfaceId: expect.any(String),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [92, 119, 0],
|
range: [92, 119, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
edgeCutId: expect.any(String),
|
edgeCutId: expect.any(String),
|
||||||
@ -833,7 +833,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: expect.any(Array),
|
surfaceIds: expect.any(Array),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254, 0],
|
range: [231, 254, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -852,7 +852,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceId: expect.any(String),
|
surfaceId: expect.any(String),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [70, 86, 0],
|
range: [70, 86, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -864,7 +864,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: expect.any(Array),
|
surfaceIds: expect.any(Array),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254, 0],
|
range: [231, 254, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -884,7 +884,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: expect.any(Array),
|
surfaceIds: expect.any(Array),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254, 0],
|
range: [231, 254, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -904,7 +904,7 @@ describe('testing getArtifactsToUpdate', () => {
|
|||||||
surfaceIds: expect.any(Array),
|
surfaceIds: expect.any(Array),
|
||||||
edgeIds: expect.any(Array),
|
edgeIds: expect.any(Array),
|
||||||
codeRef: {
|
codeRef: {
|
||||||
range: [231, 254, 0],
|
range: [231, 254, true],
|
||||||
pathToNode: [['body', '']],
|
pathToNode: [['body', '']],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
import { defaultSourceRange, Program, SourceRange } from 'lang/wasm'
|
import {
|
||||||
|
defaultRustSourceRange,
|
||||||
|
defaultSourceRange,
|
||||||
|
Program,
|
||||||
|
RustSourceRange,
|
||||||
|
SourceRange,
|
||||||
|
sourceRangeFromRust,
|
||||||
|
} from 'lang/wasm'
|
||||||
import { VITE_KC_API_WS_MODELING_URL, VITE_KC_DEV_TOKEN } from 'env'
|
import { VITE_KC_API_WS_MODELING_URL, VITE_KC_DEV_TOKEN } from 'env'
|
||||||
import { Models } from '@kittycad/lib'
|
import { Models } from '@kittycad/lib'
|
||||||
import { exportSave } from 'lib/exportSave'
|
import { exportSave } from 'lib/exportSave'
|
||||||
@ -1302,8 +1309,8 @@ export enum EngineCommandManagerEvents {
|
|||||||
|
|
||||||
interface PendingMessage {
|
interface PendingMessage {
|
||||||
command: EngineCommand
|
command: EngineCommand
|
||||||
range: SourceRange
|
range: RustSourceRange
|
||||||
idToRangeMap: { [key: string]: SourceRange }
|
idToRangeMap: { [key: string]: RustSourceRange }
|
||||||
resolve: (data: [Models['WebSocketResponse_type']]) => void
|
resolve: (data: [Models['WebSocketResponse_type']]) => void
|
||||||
reject: (reason: string) => void
|
reject: (reason: string) => void
|
||||||
promise: Promise<[Models['WebSocketResponse_type']]>
|
promise: Promise<[Models['WebSocketResponse_type']]>
|
||||||
@ -1993,7 +2000,7 @@ export class EngineCommandManager extends EventTarget {
|
|||||||
{
|
{
|
||||||
command,
|
command,
|
||||||
idToRangeMap: {},
|
idToRangeMap: {},
|
||||||
range: defaultSourceRange(),
|
range: defaultRustSourceRange(),
|
||||||
},
|
},
|
||||||
true // isSceneCommand
|
true // isSceneCommand
|
||||||
)
|
)
|
||||||
@ -2024,9 +2031,9 @@ export class EngineCommandManager extends EventTarget {
|
|||||||
return Promise.reject(new Error('rangeStr is undefined'))
|
return Promise.reject(new Error('rangeStr is undefined'))
|
||||||
if (commandStr === undefined)
|
if (commandStr === undefined)
|
||||||
return Promise.reject(new Error('commandStr is undefined'))
|
return Promise.reject(new Error('commandStr is undefined'))
|
||||||
const range: SourceRange = JSON.parse(rangeStr)
|
const range: RustSourceRange = JSON.parse(rangeStr)
|
||||||
const command: EngineCommand = JSON.parse(commandStr)
|
const command: EngineCommand = JSON.parse(commandStr)
|
||||||
const idToRangeMap: { [key: string]: SourceRange } =
|
const idToRangeMap: { [key: string]: RustSourceRange } =
|
||||||
JSON.parse(idToRangeStr)
|
JSON.parse(idToRangeStr)
|
||||||
|
|
||||||
// Current executeAst is stale, going to interrupt, a new executeAst will trigger
|
// Current executeAst is stale, going to interrupt, a new executeAst will trigger
|
||||||
@ -2069,10 +2076,14 @@ export class EngineCommandManager extends EventTarget {
|
|||||||
if (message.command.type === 'modeling_cmd_req') {
|
if (message.command.type === 'modeling_cmd_req') {
|
||||||
this.orderedCommands.push({
|
this.orderedCommands.push({
|
||||||
command: message.command,
|
command: message.command,
|
||||||
range: message.range,
|
range: sourceRangeFromRust(message.range),
|
||||||
})
|
})
|
||||||
} else if (message.command.type === 'modeling_cmd_batch_req') {
|
} else if (message.command.type === 'modeling_cmd_batch_req') {
|
||||||
message.command.requests.forEach((req) => {
|
message.command.requests.forEach((req) => {
|
||||||
|
const cmdId = req.cmd_id || ''
|
||||||
|
const range = cmdId
|
||||||
|
? sourceRangeFromRust(message.idToRangeMap[cmdId])
|
||||||
|
: defaultSourceRange()
|
||||||
const cmd: EngineCommand = {
|
const cmd: EngineCommand = {
|
||||||
type: 'modeling_cmd_req',
|
type: 'modeling_cmd_req',
|
||||||
cmd_id: req.cmd_id,
|
cmd_id: req.cmd_id,
|
||||||
@ -2080,7 +2091,7 @@ export class EngineCommandManager extends EventTarget {
|
|||||||
}
|
}
|
||||||
this.orderedCommands.push({
|
this.orderedCommands.push({
|
||||||
command: cmd,
|
command: cmd,
|
||||||
range: message.idToRangeMap[req.cmd_id || ''],
|
range,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@ export type { BinaryPart } from '../wasm-lib/kcl/bindings/BinaryPart'
|
|||||||
export type { Literal } from '../wasm-lib/kcl/bindings/Literal'
|
export type { Literal } from '../wasm-lib/kcl/bindings/Literal'
|
||||||
export type { LiteralValue } from '../wasm-lib/kcl/bindings/LiteralValue'
|
export type { LiteralValue } from '../wasm-lib/kcl/bindings/LiteralValue'
|
||||||
export type { ArrayExpression } from '../wasm-lib/kcl/bindings/ArrayExpression'
|
export type { ArrayExpression } from '../wasm-lib/kcl/bindings/ArrayExpression'
|
||||||
|
export type { SourceRange as RustSourceRange } from 'wasm-lib/kcl/bindings/SourceRange'
|
||||||
|
|
||||||
export type SyntaxType =
|
export type SyntaxType =
|
||||||
| 'Program'
|
| 'Program'
|
||||||
@ -117,6 +118,13 @@ export function defaultSourceRange(): SourceRange {
|
|||||||
return [0, 0, true]
|
return [0, 0, true]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a default RustSourceRange for testing or as a placeholder.
|
||||||
|
*/
|
||||||
|
export function defaultRustSourceRange(): RustSourceRange {
|
||||||
|
return [0, 0, 0]
|
||||||
|
}
|
||||||
|
|
||||||
export const wasmUrl = () => {
|
export const wasmUrl = () => {
|
||||||
// For when we're in electron (file based) or web server (network based)
|
// For when we're in electron (file based) or web server (network based)
|
||||||
// For some reason relative paths don't work as expected. Otherwise we would
|
// For some reason relative paths don't work as expected. Otherwise we would
|
||||||
|
Reference in New Issue
Block a user