diff --git a/CHANGELOG.md b/CHANGELOG.md index e6c3ab3f..11991ab4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### 🚨 Breaking changes +- Changed the `name` attribute to `type` when drawing objects. + ### ✨ Enhancements ### 🐛 Bug fixes diff --git a/README.md b/README.md index e4125b17..f13bf7b6 100644 --- a/README.md +++ b/README.md @@ -30,13 +30,13 @@ const objects = [ stack_frame: true, }, { - name: "str", + type: "str", id: 19, value: "David is cool!", style: ["highlight"], }, { - name: "int", + type: "int", id: 13, value: 7, }, diff --git a/demo/src/__tests__/SvgDisplay.spec.tsx b/demo/src/__tests__/SvgDisplay.spec.tsx index cd8641d0..bbb8ebd0 100644 --- a/demo/src/__tests__/SvgDisplay.spec.tsx +++ b/demo/src/__tests__/SvgDisplay.spec.tsx @@ -36,15 +36,13 @@ describe("SvgDisplay", () => { stack_frame: true, }, { - isClass: false, - name: "str", + type: "str", id: 19, value: "David is cool!", style: ["highlight"], }, { - isClass: false, - name: "int", + type: "int", id: 13, value: 7, }, diff --git a/demo/src/sample/automated-layout/data.json b/demo/src/sample/automated-layout/data.json index 52f659fb..ea1efcbc 100644 --- a/demo/src/sample/automated-layout/data.json +++ b/demo/src/sample/automated-layout/data.json @@ -14,11 +14,10 @@ "stack_frame": true }, { - "isClass": false, - "name": "list", + "type": "list", "id": 84, "value": [32, 10, 90, 57], "show_indexes": true }, - { "isClass": false, "name": "None", "id": 13, "value": "None" } + { "type": "None", "id": 13, "value": "None" } ] diff --git a/demo/src/sample/blanks/data.json b/demo/src/sample/blanks/data.json index 4da3da9c..4b8e1d0d 100644 --- a/demo/src/sample/blanks/data.json +++ b/demo/src/sample/blanks/data.json @@ -7,7 +7,7 @@ "stack_frame": true }, { - "name": "BLANK", + "type": "BLANK", "width": 100, "height": 200, "stack_frame": true @@ -20,49 +20,43 @@ "stack_frame": true }, { - "isClass": false, - "name": "list", + "type": "list", "id": 82, "value": [19, 43, 28, 49] }, { - "isClass": false, - "name": "list", + "type": "list", "id": 84, "value": [32, 10, 90, 57], "show_indexes": true }, { - "isClass": false, - "name": "int", + "type": "int", "id": 19, "value": 1969 }, { - "name": "BLANK", + "type": "BLANK", "width": 100, "height": 200 }, { - "isClass": false, - "name": "bool", + "type": "bool", "id": 32, "value": true }, { - "isClass": false, - "name": "str", + "type": "str", "id": 43, "value": "David is cool" }, { - "name": "BLANK", + "type": "BLANK", "width": 200, "height": 150 }, { - "isClass": false, - "name": "tuple", + "type": "tuple", "id": 11, "value": [82, 76] } diff --git a/demo/src/sample/manual-layout/data.json b/demo/src/sample/manual-layout/data.json index 83f54d69..9bd28849 100644 --- a/demo/src/sample/manual-layout/data.json +++ b/demo/src/sample/manual-layout/data.json @@ -9,26 +9,23 @@ "stack_frame": true }, { - "isClass": false, "x": 1050, "y": 500, - "name": "dict", + "type": "dict", "id": 10, "value": { "x": 81, "y": 100, "z": 121 } }, { - "isClass": false, "x": 1050, "y": 40, - "name": "tuple", + "type": "tuple", "id": 11, "value": [82, 76] }, { - "isClass": false, "x": 750, "y": 250, - "name": "bool", + "type": "bool", "id": 32, "value": true } diff --git a/demo/src/sample/simple/data.json b/demo/src/sample/simple/data.json index c674b886..085b14be 100644 --- a/demo/src/sample/simple/data.json +++ b/demo/src/sample/simple/data.json @@ -7,15 +7,13 @@ "stack_frame": true }, { - "isClass": false, - "name": "str", + "type": "str", "id": 19, "value": "David is cool!", "style": ["highlight"] }, { - "isClass": false, - "name": "int", + "type": "int", "id": 13, "value": 7 } diff --git a/demo/src/sample/styling/data.json b/demo/src/sample/styling/data.json index 814fc349..0839e29a 100644 --- a/demo/src/sample/styling/data.json +++ b/demo/src/sample/styling/data.json @@ -10,10 +10,9 @@ "style": ["highlight"] }, { - "isClass": false, "x": 350, "y": 350, - "name": "list", + "type": "list", "id": 54, "value": [19, 43, 28, 49], "style": { @@ -21,36 +20,32 @@ } }, { - "isClass": false, "x": 750, "y": 500, - "name": "str", + "type": "str", "id": 43, "value": "David is cool", "style": "highlight" }, { - "isClass": false, "x": 1050, "y": 260, - "name": "set", + "type": "set", "id": 90, "value": [36, 49, 64] }, { - "isClass": false, "x": 1050, "y": 500, - "name": "dict", + "type": "dict", "id": 10, "value": { "x": 81, "y": 100, "z": 121 }, "style": { "text_id": { "font-style": "italic" } } }, { - "isClass": false, "x": 750, "y": 750, - "name": "None", + "type": "None", "id": 13, "value": "None", "style": { diff --git a/docs/docs/02-object_structure.md b/docs/docs/02-object_structure.md index 6637022f..7fd3c8e0 100644 --- a/docs/docs/02-object_structure.md +++ b/docs/docs/02-object_structure.md @@ -10,23 +10,23 @@ the array of objects to be drawn. To be successfully rendered, the array must contain objects that strictly follow a specific structure. Every object must contain the following attributes: -- `isClass` - `boolean`: denotes whether the object to be drawn is a user-defined class (or a stack-frame) or a built-in - object. Pass true to draw a class or a stack-frame, and false to draw any built-in types. -- `name` - `string`: denotes the type of the object to draw (if `isClass===true`, then this is the name of the - corresponding class or stackframe). -- If the user want to hardcode the coordinates (implying the `automation` parameter of `draw` is false), each object +- `isClass` - `boolean`: denotes whether the object to be drawn is a user-defined class (or a stack frame) or a built-in + object. This has a default value of `false` and should be manually set to `true` only when drawing a class or stack frame. +- `name` - `string`: The name of the class or stack frame to be drawn. Note that this attribute is only applicable if the object's `isClass` attribute is true. Otherwise, this attribute can be excluded from the input. +- `type` - `string`: The type of the object to be drawn. If no objects are being drawn, this attribute can be excluded from the input. +- If the user wants to hardcode the coordinates (implying the `automation` parameter of `draw` is false), each object must include `x` and `y` attributes (for x-y coordinates). -- `id` - `string`|`number`: denotes the id value of this object. If we are to draw a StackFrame, then this MUST be `null`. +- `id` - `string`|`number`: denotes the id value of this object. If we are to draw a stack frame, then this MUST be `null`. - `value` - `*`: denotes the value of the object. This could be anything, from an empty string to a JS object, which would be passed for the purpose of drawing a user-defined class object, a - stackframe, or a dictionary. - **Note that in such cases where we want to do draw a 'container' + stack frame, or a dictionary. + **Note that in such cases where we want to draw a 'container' object (an object that contains other objects), we pass a _JS object_ where the keys are the attributes/variables and the values are the id's of the corresponding objects (not the objects themselves)**. - `stack_frame` - `boolean`: denotes whether a stack frame will be drawn or not. NOTE that this is only - applicable if the object's `isClass` attribute is true (since the - `MemoryModel.drawClass` covers both classes and stack-frames). By default, + applicable if the object's `isClass` attribute is `true` (since the + `MemoryModel.drawClass` covers both classes and stack frames). By default, `stack_frame` is set to null (_which is false_). - `show_indexes` - `boolean`: This is applicable only when drawing tuples or lists (when drawSequence method will be used). It denotes whether the memory box of the underlying @@ -40,31 +40,43 @@ must contain the following attributes: ### Examples ```javascript -{"isClass": true, "name": "__main__", "id": null, "value": {"lst1": 82, "lst2": 84, "p": 99, "d": 10, "t": 11}, "stack_frame": true}, -{"name": "BLANK", "width": 100, "height": 200, "stack_frame" : true}, -{"isClass": true, "name": "func", "id": null, "value": {"age": 12, "name": 17}, "stack_frame": true}, +{ + "isClass": true, + "name": "__main__", + "id": null, + "value": {"lst1": 82, "lst2": 84, "p": 99, "d": 10, "t": 11}, + "stack_frame": true +} + +{ + "isClass": true, + "name": "func", + "id": null, + "value": {"age": 12, "name": 17}, + "stack_frame": true +} -{"name": "BLANK", "width": 100, "height": 200, "stack_frame" : true} +{"type": "BLANK", "width": 100, "height": 200, "stack_frame" : true} -{"isClass": false, "name": "list", "id": 82, "value": [19, 43, 28, 49]} +{"type": "list", "id": 82, "value": [19, 43, 28, 49]} -{"isClass": false, "name": "list", "id": 84, "value": [32, 10, 90, 57], "show_indexes": true} +{"type": "list", "id": 84, "value": [32, 10, 90, 57], "show_indexes": true} -{"isClass": false, "name": "int", "id": 19, "value": 1969} +{"type": "int", "id": 19, "value": 1969} -{"isClass": false, "name": "bool", "id": 32, "value": true} +{"type": "bool", "id": 32, "value": true} -{"name": "BLANK", "width": 200, "height": 100} +{"type": "BLANK", "width": 200, "height": 100} -{"isClass": false, "name": "str", "id": 43, "value": "David is cool"} +{"type": "str", "id": 43, "value": "David is cool"} -{"isClass": false, "name": "tuple", "id": 11, "value": [82, 76]} +{"type": "tuple", "id": 11, "value": [82, 76]} -{"isClass": false, "name": "set", "id": 90, "value": [36, 49, 64]} +{"type": "set", "id": 90, "value": [36, 49, 64]} -{"isClass": false, "name": "dict", "id": 10, "value": {"x": 81, "y": 100, "z": 121}} +{"type": "dict", "id": 10, "value": {"x": 81, "y": 100, "z": 121}} -{"isClass": false, "name": "None", "id": 13, "value": "None", +{"type": "None", "id": 13, "value": "None", "style": { "text_value" : {"font-style": "italic"}, "box_id": {"fill": "red", "fillStyle": "dots"}, diff --git a/docs/docs/99-api/examples/automation_demo/automation_demo.json b/docs/docs/99-api/examples/automation_demo/automation_demo.json index 52f659fb..ea1efcbc 100644 --- a/docs/docs/99-api/examples/automation_demo/automation_demo.json +++ b/docs/docs/99-api/examples/automation_demo/automation_demo.json @@ -14,11 +14,10 @@ "stack_frame": true }, { - "isClass": false, - "name": "list", + "type": "list", "id": 84, "value": [32, 10, 90, 57], "show_indexes": true }, - { "isClass": false, "name": "None", "id": 13, "value": "None" } + { "type": "None", "id": 13, "value": "None" } ] diff --git a/docs/docs/99-api/examples/automation_demo/more_specific_demos/demo_A.js b/docs/docs/99-api/examples/automation_demo/more_specific_demos/demo_A.js index 040b2aa4..20467e56 100644 --- a/docs/docs/99-api/examples/automation_demo/more_specific_demos/demo_A.js +++ b/docs/docs/99-api/examples/automation_demo/more_specific_demos/demo_A.js @@ -20,8 +20,8 @@ const listOfObjs = [ value: { age: 12, name: 17 }, stack_frame: false, }, - { isClass: false, name: "list", id: 82, value: [19, 43, 28, 49] }, - { isClass: false, name: "int", id: 19, value: 1969 }, + { type: "list", id: 82, value: [19, 43, 28, 49] }, + { type: "int", id: 19, value: 1969 }, ]; const { objs, canvas_height, canvas_width } = drawAutomatedOtherItems( diff --git a/docs/docs/99-api/examples/automation_demo/more_specific_demos/demo_C.js b/docs/docs/99-api/examples/automation_demo/more_specific_demos/demo_C.js index 473e9dbe..f60c6461 100644 --- a/docs/docs/99-api/examples/automation_demo/more_specific_demos/demo_C.js +++ b/docs/docs/99-api/examples/automation_demo/more_specific_demos/demo_C.js @@ -10,13 +10,7 @@ * - ~/examples/automation_demo/more_specific_demos/draw_automated.svg */ -const { - drawAutomated, - separateJSON, - getSize, - drawAutomatedOtherItems, - MemoryModel, -} = require("memory-viz"); +const { drawAutomated } = require("memory-viz"); const fs = require("fs"); const WIDTH = 1300; diff --git a/docs/docs/99-api/examples/blankspaces_demo/blankspaces_demo.js b/docs/docs/99-api/examples/blankspaces_demo/blankspaces_demo.js index cffe5fc1..bc822d16 100644 --- a/docs/docs/99-api/examples/blankspaces_demo/blankspaces_demo.js +++ b/docs/docs/99-api/examples/blankspaces_demo/blankspaces_demo.js @@ -2,7 +2,7 @@ * This file demonstrates the ability to leave "blanks" when the 'automated.md' option is on. * * To define a blank box, you specify it as an object in the array (the classic array of objects) with three attributes: - * - name: This must be equal to "BLANK" + * - type: This must be equal to "BLANK" * - width: the desired width of the blank box (I say box but in reality there aren't any borders) * - height: the desired height of the blank box * @@ -27,7 +27,7 @@ const listOfObjs = [ value: { lst1: 82, lst2: 84, p: 99, d: 10, t: 11 }, stack_frame: true, }, - { name: "BLANK", width: 100, height: 200, stack_frame: true }, + { type: "BLANK", width: 100, height: 200, stack_frame: true }, { isClass: true, name: "func", @@ -35,20 +35,19 @@ const listOfObjs = [ value: { age: 12, name: 17 }, stack_frame: true, }, - { isClass: false, name: "list", id: 82, value: [19, 43, 28, 49] }, + { type: "list", id: 82, value: [19, 43, 28, 49] }, { - isClass: false, - name: "list", + type: "list", id: 84, value: [32, 10, 90, 57], show_indexes: true, }, - { isClass: false, name: "int", id: 19, value: 1969 }, - { name: "BLANK", width: 100, height: 200 }, - { isClass: false, name: "bool", id: 32, value: true }, - { isClass: false, name: "str", id: 43, value: "David is cool" }, - { name: "BLANK", width: 200, height: 150 }, - { isClass: false, name: "tuple", id: 11, value: [82, 76] }, + { type: "int", id: 19, value: 1969 }, + { type: "BLANK", width: 100, height: 200 }, + { type: "bool", id: 32, value: true }, + { type: "str", id: 43, value: "David is cool" }, + { type: "BLANK", width: 200, height: 150 }, + { type: "tuple", id: 11, value: [82, 76] }, ]; const configuration = { diff --git a/docs/docs/99-api/examples/manual_demo/manual_demo.json b/docs/docs/99-api/examples/manual_demo/manual_demo.json index 83f54d69..9bd28849 100644 --- a/docs/docs/99-api/examples/manual_demo/manual_demo.json +++ b/docs/docs/99-api/examples/manual_demo/manual_demo.json @@ -9,26 +9,23 @@ "stack_frame": true }, { - "isClass": false, "x": 1050, "y": 500, - "name": "dict", + "type": "dict", "id": 10, "value": { "x": 81, "y": 100, "z": 121 } }, { - "isClass": false, "x": 1050, "y": 40, - "name": "tuple", + "type": "tuple", "id": 11, "value": [82, 76] }, { - "isClass": false, "x": 750, "y": 250, - "name": "bool", + "type": "bool", "id": 32, "value": true } diff --git a/docs/docs/99-api/examples/simple_demo/simple_demo.js b/docs/docs/99-api/examples/simple_demo/simple_demo.js index cae37d58..cb982fff 100644 --- a/docs/docs/99-api/examples/simple_demo/simple_demo.js +++ b/docs/docs/99-api/examples/simple_demo/simple_demo.js @@ -16,13 +16,12 @@ const objects = [ stack_frame: true, }, { - isClass: false, - name: "str", + type: "str", id: 19, value: "David is cool!", style: ["highlight"], }, - { isClass: false, name: "int", id: 13, value: 7 }, + { type: "int", id: 13, value: 7 }, ]; const m = draw(objects, true, { width: 1300 }); diff --git a/docs/docs/99-api/examples/style_demo/nostyle_demo.js b/docs/docs/99-api/examples/style_demo/nostyle_demo.js index bd5a5ed4..3b793bee 100644 --- a/docs/docs/99-api/examples/style_demo/nostyle_demo.js +++ b/docs/docs/99-api/examples/style_demo/nostyle_demo.js @@ -30,38 +30,34 @@ const objs = [ stack_frame: true, }, { - isClass: false, x: 350, y: 350, - name: "list", + type: "list", id: 54, value: [19, 43, 28, 49], }, { - isClass: false, x: 750, y: 500, - name: "str", + type: "str", id: 43, value: "David is cool", }, { - isClass: false, x: 1050, y: 260, - name: "set", + type: "set", id: 90, value: [36, 49, 64], }, { - isClass: false, x: 1050, y: 500, - name: "dict", + type: "dict", id: 10, value: { x: 81, y: 100, z: 121 }, }, - { isClass: false, x: 750, y: 750, name: "None", id: 13, value: "None" }, + { x: 750, y: 750, type: "None", id: 13, value: "None" }, ]; const m = draw(objs, true, configuration); diff --git a/docs/docs/99-api/examples/style_demo/presets_demo.js b/docs/docs/99-api/examples/style_demo/presets_demo.js index 5c6e94f7..01b0ded5 100644 --- a/docs/docs/99-api/examples/style_demo/presets_demo.js +++ b/docs/docs/99-api/examples/style_demo/presets_demo.js @@ -31,40 +31,36 @@ const objs = [ style: ["highlight_type"], }, { - isClass: false, x: 350, y: 350, - name: "list", + type: "list", id: 54, value: [19, 43, 28, 49], style: ["hide_type"], }, { - isClass: false, x: 750, y: 500, - name: "str", + type: "str", id: 43, value: "David is cool", style: ["highlight", "hide_type"], }, { - isClass: false, x: 1050, y: 40, - name: "tuple", + type: "tuple", id: 11, value: [82, 76], style: ["highlight"], }, { - isClass: false, x: 1050, y: 260, - name: "set", + type: "set", id: 90, value: [36, 49, 64], style: ["fade"], diff --git a/docs/docs/99-api/examples/style_demo/style_demo.js b/docs/docs/99-api/examples/style_demo/style_demo.js index 9a51afef..ee58bddd 100644 --- a/docs/docs/99-api/examples/style_demo/style_demo.js +++ b/docs/docs/99-api/examples/style_demo/style_demo.js @@ -38,45 +38,40 @@ const objs = [ style: ["highlight"], // Notice style is passed in as an array. }, { - isClass: false, x: 350, y: 350, - name: "list", + type: "list", id: 54, value: [19, 43, 28, 49], style: { text_id: { "font-style": "italic", "font-size": "x-large" } }, }, { - isClass: false, x: 750, y: 500, - name: "str", + type: "str", id: 43, value: "David is cool", style: "highlight", }, { - isClass: false, x: 1050, y: 260, - name: "set", + type: "set", id: 90, value: [36, 49, 64], }, { - isClass: false, x: 1050, y: 500, - name: "dict", + type: "dict", id: 10, value: { x: 81, y: 100, z: 121 }, style: { text_id: { "font-style": "italic" } }, }, // Notice that style is passed in as an Object. { - isClass: false, x: 750, y: 750, - name: "None", + type: "None", id: 13, value: "None", style: { diff --git a/docs/src/pages/index.md b/docs/src/pages/index.md index 034b931a..96f43644 100644 --- a/docs/src/pages/index.md +++ b/docs/src/pages/index.md @@ -35,13 +35,12 @@ const objects = [ stack_frame: true, }, { - isClass: false, - name: "str", + type: "str", id: 19, value: "David is cool!", style: ["highlight"], }, - { isClass: false, name: "int", id: 13, value: 7 }, + { type: "int", id: 13, value: 7 }, ]; const m = draw(objects, true, { width: 1300 }); diff --git a/memory-viz/README.md b/memory-viz/README.md index 6f34b6fb..f8c43e6f 100644 --- a/memory-viz/README.md +++ b/memory-viz/README.md @@ -30,13 +30,13 @@ const objects = [ stack_frame: true, }, { - name: "str", + type: "str", id: 19, value: "David is cool!", style: ["highlight"], }, { - name: "int", + type: "int", id: 13, value: 7, }, diff --git a/memory-viz/src/automate.ts b/memory-viz/src/automate.ts index 4b285f64..6f42b770 100644 --- a/memory-viz/src/automate.ts +++ b/memory-viz/src/automate.ts @@ -149,7 +149,7 @@ function drawAutomatedOtherItems( const START_X = sf_endpoint + PADDING; for (const item of objs) { - if (item.name !== "BLANK") { + if (item.type !== "BLANK") { const dimensions = getSize(item); item.height = dimensions.height; item.width = dimensions.width; @@ -232,7 +232,7 @@ function drawAutomatedOtherItems( // Additional -- to extend the program for the BLANK option. const objs_filtered = objs.filter((item) => { - return item.name !== "BLANK"; + return item.type !== "BLANK"; }); objs = objs_filtered; @@ -254,7 +254,7 @@ function separateObjects(objects) { for (const item of objects) { if ( - item.name === "BLANK" && + item.type === "BLANK" && (item.width === undefined || item.height === undefined) ) { console.log( diff --git a/memory-viz/src/memory_model.ts b/memory-viz/src/memory_model.ts index 0d0b24e6..8d4446ca 100644 --- a/memory-viz/src/memory_model.ts +++ b/memory-viz/src/memory_model.ts @@ -758,14 +758,18 @@ export class MemoryModel { * * @param {object[]} objects - the list of objects (including stack-frames) to be drawn. * Each object in 'objects' must include the following structure: - * @param {boolean} objects[*].isClass - Whether a user-defined class (or a stack-frame) or a built-in + * @param {boolean} objects[*].isClass = false - Whether a user-defined class (or a stack-frame) or a built-in * object will be drawn. Pass true to draw a class or a stack-frame, * and false to draw any of the types found in the 'immutable' - * and 'collections' constants. + * and 'collections' constants. This has a default value of false and should + * be manually set to true only when drawing a class or stack-frame. * @param {number} objects[*].x - Value for x coordinate of top left corner * @param {number} objects[*].y - Value for y coordinate of top left corner - * @param {string} objects[*].name - The type of the object to draw (if isClass===true, then this is the name of the - * corresponding class or stackframe). + * @param {string} objects[*].name - The name of the class or stack frame to be drawn. Note that this attribute is only + * applicable if the object's 'isClass' attribute is true. If no classes or stack frames + * are being drawn, this attribute can be excluded from the input. + * @param {string} objects[*].type - The type of the object to be drawn. If no objects are being drawn, this attribute + * can be excluded from the input. * @param {number} objects[*].id - The id value of this object. If we are to draw a StackFrame, then this MUST be 'null'. * @param {*} objects[*].value - The value of the object. This could be anything, from an empty string to a JS object, * which would be passed for the purpose of drawing a user-defined class object, a @@ -828,7 +832,7 @@ export class MemoryModel { const size = this.drawObject( obj.x, obj.y, - obj.name, + obj.type, obj.id, obj.value, obj.show_indexes, diff --git a/memory-viz/src/style.ts b/memory-viz/src/style.ts index 47568691..5641a380 100644 --- a/memory-viz/src/style.ts +++ b/memory-viz/src/style.ts @@ -68,9 +68,9 @@ function populateStyleObject(object, seed) { let object_type; - if (primitives.includes(object.name)) { + if (primitives.includes(object.type)) { object_type = "primitive"; - } else if (collections.includes(object.name)) { + } else if (collections.includes(object.type)) { object_type = "collection"; } else if (object.stack_frame) { object_type = "stackframe"; diff --git a/memory-viz/src/tests/draw.spec.tsx b/memory-viz/src/tests/draw.spec.tsx index e287862e..63a43f15 100644 --- a/memory-viz/src/tests/draw.spec.tsx +++ b/memory-viz/src/tests/draw.spec.tsx @@ -12,13 +12,12 @@ describe("draw function", () => { stack_frame: true, }, { - isClass: false, - name: "str", + type: "str", id: 19, value: "David is cool!", style: ["highlight"], }, - { isClass: false, name: "int", id: 13, value: 7 }, + { type: "int", id: 13, value: 7 }, ]; const m: InstanceType = draw(objects, true, { width: 1300, @@ -29,9 +28,7 @@ describe("draw function", () => { }); it("renders a bool", () => { - const objects: Array = [ - { isClass: false, name: "bool", id: 32, value: true }, - ]; + const objects: Array = [{ type: "bool", id: 32, value: true }]; const m: InstanceType = draw(objects, true, { width: 1300, seed: 12345, @@ -41,9 +38,7 @@ describe("draw function", () => { }); it("renders an int", () => { - const objects: Array = [ - { isClass: false, name: "int", id: 32, value: 7 }, - ]; + const objects: Array = [{ type: "int", id: 32, value: 7 }]; const m: InstanceType = draw(objects, true, { width: 1300, seed: 12345, @@ -53,9 +48,7 @@ describe("draw function", () => { }); it("renders a float", () => { - const objects: Array = [ - { isClass: false, name: "float", id: 32, value: 7.0 }, - ]; + const objects: Array = [{ type: "float", id: 32, value: 7.0 }]; const m: InstanceType = draw(objects, true, { width: 1300, seed: 12345, @@ -66,7 +59,7 @@ describe("draw function", () => { it("renders a str", () => { const objects: Array = [ - { isClass: false, name: "str", id: 32, value: "winter" }, + { type: "str", id: 32, value: "winter" }, ]; const m: InstanceType = draw(objects, true, { width: 1300, @@ -78,7 +71,7 @@ describe("draw function", () => { it("renders a set", () => { const objects: Array = [ - { isClass: false, name: "set", id: 32, value: [10, 11, 12] }, + { type: "set", id: 32, value: [10, 11, 12] }, ]; const m: InstanceType = draw(objects, true, { width: 1300, @@ -89,9 +82,7 @@ describe("draw function", () => { }); it("renders an empty set", () => { - const objects: Array = [ - { isClass: false, name: "set", id: 32, value: [] }, - ]; + const objects: Array = [{ type: "set", id: 32, value: [] }]; const m: InstanceType = draw(objects, true, { width: 1300, seed: 12345, @@ -103,8 +94,7 @@ describe("draw function", () => { it("renders a list with indexes showing", () => { const objects: Array = [ { - isClass: false, - name: "list", + type: "list", id: 32, value: [10, 11, 12], show_indexes: true, @@ -120,7 +110,7 @@ describe("draw function", () => { it("renders a list without indexes showing", () => { const objects: Array = [ - { isClass: false, name: "list", id: 32, value: [10, 11, 12] }, + { type: "list", id: 32, value: [10, 11, 12] }, ]; const m: InstanceType = draw(objects, true, { width: 1300, @@ -131,9 +121,7 @@ describe("draw function", () => { }); it("renders an empty list", () => { - const objects: Array = [ - { isClass: false, name: "list", id: 32, value: [] }, - ]; + const objects: Array = [{ type: "list", id: 32, value: [] }]; const m: InstanceType = draw(objects, true, { width: 1300, seed: 12345, @@ -145,8 +133,7 @@ describe("draw function", () => { it("renders a tuple with indexes showing", () => { const objects: Array = [ { - isClass: false, - name: "tuple", + type: "tuple", id: 32, value: [10, 11, 12], show_indexes: true, @@ -162,7 +149,7 @@ describe("draw function", () => { it("renders a tuple without indexes showing", () => { const objects: Array = [ - { isClass: false, name: "tuple", id: 32, value: [10, 11, 12] }, + { type: "tuple", id: 32, value: [10, 11, 12] }, ]; const m: InstanceType = draw(objects, true, { width: 1300, @@ -173,9 +160,7 @@ describe("draw function", () => { }); it("renders an empty tuple", () => { - const objects: Array = [ - { isClass: false, name: "tuple", id: 32, value: [] }, - ]; + const objects: Array = [{ type: "tuple", id: 32, value: [] }]; const m: InstanceType = draw(objects, true, { width: 1300, seed: 12345, @@ -187,8 +172,7 @@ describe("draw function", () => { it("renders a dict", () => { const objects: Array = [ { - isClass: false, - name: "dict", + type: "dict", id: 10, value: { x: 81, y: 100, z: 121 }, }, @@ -202,9 +186,7 @@ describe("draw function", () => { }); it("renders an empty dict", () => { - const objects: Array = [ - { isClass: false, name: "dict", id: 32, value: {} }, - ]; + const objects: Array = [{ type: "dict", id: 32, value: {} }]; const m: InstanceType = draw(objects, true, { width: 1300, seed: 12345, @@ -215,7 +197,7 @@ describe("draw function", () => { it("renders an object with no type and no value", () => { const objects: Array = [ - { isClass: false, name: "None", id: 13, value: "None" }, + { type: "None", id: 13, value: "None" }, ]; const m: InstanceType = draw(objects, true, { width: 1300, @@ -227,7 +209,7 @@ describe("draw function", () => { it("renders a blank space", () => { const objects: Array = [ - { name: "BLANK", width: 100, height: 200 }, + { type: "BLANK", width: 100, height: 200 }, ]; const m: InstanceType = draw(objects, true, { width: 1300, @@ -249,8 +231,7 @@ describe("draw function", () => { stack_frame: true, }, { - isClass: false, - name: "int", + type: "int", id: 13, value: 7, }, @@ -288,10 +269,9 @@ describe("draw function", () => { it("renders a bool using manual layout", () => { const objects: Array = [ { - isClass: false, x: 750, y: 250, - name: "bool", + type: "bool", id: 32, value: true, }, @@ -306,19 +286,17 @@ describe("draw function", () => { it("renders blank spaces in automatic layout", () => { const objects: Array = [ { - isClass: false, - name: "int", + type: "int", id: 98, value: 42, }, { - name: "BLANK", + type: "BLANK", width: 100, height: 200, }, { - isClass: false, - name: "str", + type: "str", id: 99, value: "life", }, @@ -334,8 +312,7 @@ describe("draw function", () => { it("formats non-stack frame objects in automatic layout", () => { const objects: Array = [ { - isClass: false, - name: "int", + type: "int", id: 98, value: 42, }, @@ -348,14 +325,12 @@ describe("draw function", () => { }, }, { - isClass: false, - name: "list", + type: "list", id: 54, value: [19, 42, 22, 63], }, { - isClass: false, - name: "str", + type: "str", id: 12, value: "banana", }, @@ -390,15 +365,13 @@ describe("draw function", () => { stack_frame: true, }, { - isClass: false, - name: "list", + type: "list", id: 84, value: [17, 8], show_indexes: true, }, { - isClass: false, - name: "None", + type: "None", id: 10, value: "None", }, @@ -414,8 +387,7 @@ describe("draw function", () => { it("renders custom style (without presets)", () => { const objects: Array = [ { - isClass: false, - name: "str", + type: "str", id: 19, value: "David is cool!", style: { @@ -449,8 +421,7 @@ describe("draw function", () => { style: ["highlight"], }, { - isClass: false, - name: "str", + type: "str", id: 42, value: "highlight!", style: ["highlight"], @@ -477,8 +448,7 @@ describe("draw function", () => { style: ["highlight_id"], }, { - isClass: false, - name: "str", + type: "str", id: 42, value: "highlight id!", style: ["highlight_id"], @@ -505,8 +475,7 @@ describe("draw function", () => { style: ["highlight_type"], }, { - isClass: false, - name: "str", + type: "str", id: 42, value: "highlight type!", style: ["highlight_type"], @@ -533,8 +502,7 @@ describe("draw function", () => { style: ["hide"], }, { - isClass: false, - name: "str", + type: "str", id: 42, value: "hide!", style: ["hide"], @@ -561,8 +529,7 @@ describe("draw function", () => { style: ["hide_id"], }, { - isClass: false, - name: "str", + type: "str", id: 42, value: "hide id!", style: ["hide_id"], @@ -589,8 +556,7 @@ describe("draw function", () => { style: ["hide_container"], }, { - isClass: false, - name: "str", + type: "str", id: 42, value: "hide container!", style: ["hide_container"], @@ -617,8 +583,7 @@ describe("draw function", () => { style: ["fade"], }, { - isClass: false, - name: "str", + type: "str", id: 42, value: "fade!", style: ["fade"], @@ -645,8 +610,7 @@ describe("draw function", () => { style: ["fade_type"], }, { - isClass: false, - name: "str", + type: "str", id: 42, value: "fade_type!", style: ["fade_type"], @@ -673,8 +637,7 @@ describe("draw function", () => { style: ["fade_id"], }, { - isClass: false, - name: "str", + type: "str", id: 42, value: "fade id!", style: ["fade_id"], @@ -700,8 +663,7 @@ describe("draw function", () => { style: ["highlight", "fade", "hide_id"], }, { - isClass: false, - name: "str", + type: "str", id: 42, value: "combination!", style: ["hide_id", "highlight_type"],