ui-layout-manager-dev 0.0.11 → 0.0.13

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.
Files changed (26) hide show
  1. package/dist/cjs/index.js +3 -3
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/esm/Worker/LayoutWorker.js +25 -14
  4. package/dist/esm/index.js +3 -3
  5. package/dist/esm/index.js.map +1 -1
  6. package/package.json +3 -2
  7. package/src/components/LayoutManager/Components/Container/Container.scss +0 -12
  8. package/src/components/LayoutManager/Components/HandleBar/HandleBar.jsx +22 -3
  9. package/src/components/LayoutManager/Components/HandleBar/HandleBar.scss +1 -0
  10. package/src/components/LayoutManager/Components/RootContainer/RootContainer.jsx +71 -14
  11. package/src/components/LayoutManager/Components/RootContainer/RootContainer.scss +6 -0
  12. package/src/components/LayoutManager/Controller/Worker/HandleRulesEnforcer.js +23 -12
  13. package/src/components/LayoutManager/Controller/Worker/LayoutEditor.js +2 -2
  14. package/src/components/LayoutManager/LayoutManager.jsx +9 -5
  15. package/src/components/LayoutManager/Providers/DragProvider.js +87 -0
  16. package/src/stories/LayoutManager.stories.js +14 -2
  17. package/src/stories/layouts/vsCode/default.json +2 -2
  18. package/src/stories/layouts/vsCode/sample1.json +93 -154
  19. package/src/stories/layouts/vsCode/workbench.json +144 -0
  20. package/src/stories/sample_components/fileeditor/FileEditor.jsx +48 -0
  21. package/src/stories/sample_components/fileeditor/workspace_sample.json +1 -0
  22. package/src/stories/sample_components/filetree/FileTree.jsx +26 -0
  23. package/src/stories/sample_components/filetree/workspace_sample.json +1 -0
  24. package/src/stories/sample_components/map/MapSample.jsx +1 -1
  25. package/src/stories/sample_components/editor/EditorVSCode.jsx +0 -11
  26. package/src/stories/sample_components/editor/filetree.json +0 -1
@@ -10,33 +10,18 @@
10
10
  {
11
11
  "containerId": "header",
12
12
  "type": "container",
13
- "size": {
14
- "initial": {
15
- "value": 25,
16
- "unit": "px",
17
- "type": "fixed"
18
- }
19
- }
13
+ "size": { "initial": { "value": 25, "unit": "px", "type": "fixed" }}
20
14
  },
21
15
  {
22
16
  "containerId": "mainBody",
23
17
  "type": "container",
24
- "size": {
25
- "initial": {
26
- "type": "fill"
27
- }
28
- }
18
+ "size": { "initial": { "type": "fill" }}
29
19
  },
30
20
  {
31
21
  "containerId": "footer",
32
22
  "type": "container",
33
- "size": {
34
- "initial": {
35
- "value": 25,
36
- "unit": "px",
37
- "type": "fixed"
38
- }
39
- }
23
+ "size": { "initial": { "value": 25, "unit": "px", "type": "fixed" }},
24
+ "collapse": { "value": 400, "condition": "lessThan", "relative": "parent" }
40
25
  }
41
26
  ]
42
27
  },
@@ -46,196 +31,150 @@
46
31
  },
47
32
  "mainBody": {
48
33
  "id": "mainBody",
34
+ "background": "#3c3c3c",
49
35
  "type": "split",
50
36
  "orientation": "horizontal",
51
37
  "children": [
52
38
  {
53
- "containerId": "leftMenu",
39
+ "containerId": "sidebar",
54
40
  "type": "container",
55
- "size": {
56
- "initial": {
57
- "value": 200,
58
- "unit": "px",
59
- "type": "fixed"
60
- },
61
- "min": {
62
- "value": 150,
63
- "unit": "px"
64
- },
65
- "max": {
66
- "value": 400,
67
- "unit": "px"
68
- }
69
- },
70
- "collapse": {
71
- "value": 500,
72
- "condition": "lessThan",
73
- "relative": "parent"
74
- }
41
+ "size": { "initial": { "value": 50, "unit": "px", "type": "fixed" }},
42
+ "collapse": { "value": 400, "condition": "lessThan", "relative": "parent" },
43
+ "showHandlebar": true
75
44
  },
76
45
  {
77
- "type": "handleBar",
78
- "sibling1": "leftMenu",
79
- "sibling2": "treeView"
80
- },
81
- {
82
- "containerId": "treeView",
46
+ "containerId": "contentContainer",
83
47
  "type": "container",
84
- "size": {
85
- "initial": {
86
- "type": "fill"
87
- }
88
- }
89
- },
90
- {
91
- "type": "handleBar",
92
- "sibling1": "treeView",
93
- "sibling2": "rightMenu"
94
- },
48
+ "size": { "initial": { "type": "fill" }}
49
+ }
50
+ ]
51
+ },
52
+ "contentContainer": {
53
+ "id": "contentContainer",
54
+ "background": "#3c3c3c",
55
+ "type": "split",
56
+ "orientation": "vertical",
57
+ "children": [
95
58
  {
96
- "containerId": "rightMenu",
59
+ "containerId": "content",
97
60
  "type": "container",
98
- "size": {
99
- "initial": {
100
- "value": 200,
101
- "unit": "px",
102
- "type": "fixed"
103
- },
104
- "min": {
105
- "value": 150,
106
- "unit": "px"
107
- },
108
- "max": {
109
- "value": 400,
110
- "unit": "px"
111
- }
112
- },
113
- "collapse": {
114
- "value": 700,
115
- "condition": "lessThan",
116
- "relative": "parent"
117
- }
61
+ "size": { "initial": { "type": "fill" }}
118
62
  }
119
63
  ]
120
64
  },
121
- "footer": {
122
- "id": "footer",
123
- "background": "#007acc"
124
- },
125
- "leftMenu": {
126
- "id": "leftMenu",
65
+ "content": {
66
+ "id": "content",
67
+ "background": "#007acc",
127
68
  "type": "split",
128
- "orientation": "vertical",
69
+ "orientation": "horizontal",
129
70
  "children": [
130
71
  {
131
- "containerId": "leftMenuContainer1",
72
+ "containerId": "menuContainer",
132
73
  "type": "container",
133
- "size": {
134
- "initial": {
135
- "value": 200,
136
- "unit": "px",
137
- "type": "fixed"
138
- }
139
- }
74
+ "size": {
75
+ "initial": { "value": 400, "unit": "px", "type": "fixed" },
76
+ "min": { "value": 200, "unit": "px"},
77
+ "max": { "value": 500, "unit": "px"}
78
+ },
79
+ "collapse": { "value": 700, "condition": "lessThan", "relative": "parent" }
140
80
  },
141
81
  {
142
82
  "type": "handleBar",
143
- "sibling1": "leftMenuContainer1",
144
- "sibling2": "leftMenuContainer2"
83
+ "sibling1": "menuContainer",
84
+ "sibling2": "editorContainer"
145
85
  },
146
86
  {
147
- "containerId": "leftMenuContainer2",
87
+ "containerId": "editorContainer",
148
88
  "type": "container",
149
- "size": {
150
- "initial": {
151
- "type": "fill"
152
- }
153
- }
89
+ "size": { "initial": { "type": "fill" }}
154
90
  },
155
91
  {
156
92
  "type": "handleBar",
157
- "sibling1": "leftMenuContainer2",
158
- "sibling2": "leftMenuContainer3"
93
+ "sibling1": "editorContainer",
94
+ "sibling2": "rightMenuContainer"
159
95
  },
160
96
  {
161
- "containerId": "leftMenuContainer3",
97
+ "containerId": "rightMenuContainer",
162
98
  "type": "container",
163
- "size": {
164
- "initial": {
165
- "type": "fill"
166
- }
167
- }
99
+ "size": {
100
+ "initial": { "value": 200, "unit": "px", "type": "fixed" },
101
+ "min": { "value": 100, "unit": "px"},
102
+ "max": { "value": 300, "unit": "px"}
103
+ },
104
+ "collapse": { "value": 900, "condition": "lessThan", "relative": "parent" }
168
105
  }
169
106
  ]
170
107
  },
171
- "treeView": {
172
- "id": "treeView",
173
- "type": "container",
174
- "background": "#252526"
108
+ "footer": {
109
+ "id": "footer",
110
+ "background": "#007acc"
175
111
  },
176
- "rightMenu": {
177
- "id": "rightMenu",
112
+ "sidebar": {
113
+ "id": "sidebar",
114
+ "background": "#333"
115
+ },
116
+ "menuContainer": {
117
+ "id": "menuContainer",
118
+ "background": "#252526",
178
119
  "type": "split",
179
120
  "orientation": "vertical",
180
121
  "children": [
181
122
  {
182
- "containerId": "rightMenuContainer1",
123
+ "containerId": "fileTabsContainer",
183
124
  "type": "container",
184
- "size": {
185
- "initial": {
186
- "type": "fill"
187
- }
188
- }
125
+ "size": {
126
+ "initial": { "value": 200, "unit": "px", "type": "fixed" }
127
+ },
128
+ "collapse": { "value": 500, "condition": "lessThan", "relative": "parent" }
189
129
  },
190
130
  {
191
- "type": "handleBar"
131
+ "type": "handleBar",
132
+ "sibling1": "fileTabsContainer",
133
+ "sibling2": "stackContainer"
192
134
  },
193
135
  {
194
- "containerId": "rightMenuContainer2",
136
+ "containerId": "stackContainer",
195
137
  "type": "container",
196
- "size": {
197
- "initial": {
198
- "type": "fill"
199
- }
200
- }
138
+ "size": { "initial": { "type": "fill" }}
201
139
  },
202
140
  {
203
- "type": "handleBar"
141
+ "type": "handleBar",
142
+ "sibling1": "stackContainer",
143
+ "sibling2": "stackContainer2"
204
144
  },
205
145
  {
206
- "containerId": "rightMenuContainer3",
146
+ "containerId": "stackContainer2",
207
147
  "type": "container",
208
- "size": {
209
- "initial": {
210
- "type": "fill"
211
- }
212
- }
148
+ "size": {
149
+ "initial": { "value": 200, "unit": "px", "type": "fixed" }
150
+ },
151
+ "collapse": { "value": 500, "condition": "lessThan", "relative": "parent" }
213
152
  }
214
153
  ]
215
154
  },
216
- "leftMenuContainer1": {
217
- "id": "leftMenuContainer1",
218
- "background": "#333"
219
- },
220
- "leftMenuContainer2": {
221
- "id": "leftMenuContainer2",
222
- "background": "#333"
155
+ "fileTabsContainer": {
156
+ "id": "fileTabsContainer",
157
+ "component": "FileBrowser",
158
+ "background": "#1e1e1e"
223
159
  },
224
- "leftMenuContainer3": {
225
- "id": "leftMenuContainer3",
226
- "background": "#333"
160
+ "stackContainer": {
161
+ "id": "stackContainer",
162
+ "component": "Stack",
163
+ "background": "#1e1e1e"
227
164
  },
228
- "rightMenuContainer1": {
229
- "id": "rightMenuContainer1",
230
- "background": "#333"
165
+ "stackContainer2": {
166
+ "id": "stackContainer2",
167
+ "component":"MapSample",
168
+ "background": "#1e1e1e"
231
169
  },
232
- "rightMenuContainer2": {
233
- "id": "rightMenuContainer2",
234
- "background": "#444"
170
+ "editorContainer": {
171
+ "id": "editorContainer",
172
+ "component": "EditorVSCode",
173
+ "background": "#1e1e1e"
235
174
  },
236
- "rightMenuContainer3": {
237
- "id": "rightMenuContainer3",
238
- "background": "#333"
175
+ "rightMenuContainer": {
176
+ "id": "rightMenuContainer",
177
+ "background": "#252526"
239
178
  }
240
179
  }
241
180
  }
@@ -0,0 +1,144 @@
1
+ {
2
+ "title": "Workbench Layout Configuration A",
3
+ "layoutRoot": "root",
4
+ "containers": {
5
+ "root": {
6
+ "id": "root",
7
+ "type": "split",
8
+ "orientation": "vertical",
9
+ "children": [
10
+ {
11
+ "containerId": "header",
12
+ "type": "container",
13
+ "size": { "initial": { "value": 25, "unit": "px", "type": "fixed" }}
14
+ },
15
+ {
16
+ "containerId": "mainBody",
17
+ "type": "container",
18
+ "size": { "initial": { "type": "fill" }}
19
+ },
20
+ {
21
+ "containerId": "footer",
22
+ "type": "container",
23
+ "size": { "initial": { "value": 25, "unit": "px", "type": "fixed" }},
24
+ "collapse": { "value": 400, "condition": "lessThan", "relative": "parent" }
25
+ }
26
+ ]
27
+ },
28
+ "header": {
29
+ "id": "header",
30
+ "background": "#3c3c3c"
31
+ },
32
+ "mainBody": {
33
+ "id": "mainBody",
34
+ "background": "#3c3c3c",
35
+ "type": "split",
36
+ "orientation": "horizontal",
37
+ "children": [
38
+ {
39
+ "containerId": "sidebar",
40
+ "type": "container",
41
+ "size": { "initial": { "value": 50, "unit": "px", "type": "fixed" }},
42
+ "collapse": { "value": 400, "condition": "lessThan", "relative": "parent" },
43
+ "showHandlebar": true
44
+ },
45
+ {
46
+ "containerId": "contentContainer",
47
+ "type": "container",
48
+ "size": { "initial": { "type": "fill" }}
49
+ }
50
+ ]
51
+ },
52
+ "contentContainer": {
53
+ "id": "contentContainer",
54
+ "background": "#3c3c3c",
55
+ "type": "split",
56
+ "orientation": "vertical",
57
+ "children": [
58
+ {
59
+ "containerId": "content",
60
+ "type": "container",
61
+ "size": { "initial": { "type": "fill" }}
62
+ },
63
+ {
64
+ "type": "handleBar",
65
+ "sibling1": "content",
66
+ "sibling2": "terminal"
67
+ },
68
+ {
69
+ "containerId": "terminal",
70
+ "type": "container",
71
+ "size": {
72
+ "initial": { "value": 200, "unit": "px", "type": "fixed" },
73
+ "min": { "value": 100, "unit": "px"}
74
+ },
75
+ "collapse": { "value": 500, "condition": "lessThan", "relative": "parent" }
76
+ }
77
+ ]
78
+ },
79
+ "terminal": {
80
+ "id": "terminal",
81
+ "component": "Flow",
82
+ "background": "#252526"
83
+ },
84
+ "content": {
85
+ "id": "content",
86
+ "background": "#007acc",
87
+ "type": "split",
88
+ "orientation": "horizontal",
89
+ "children": [
90
+ {
91
+ "containerId": "menuContainer",
92
+ "type": "container",
93
+ "size": {
94
+ "initial": { "value": 400, "unit": "px", "type": "fixed" },
95
+ "min": { "value": 200, "unit": "px"},
96
+ "max": { "value": 500, "unit": "px"}
97
+ },
98
+ "collapse": { "value": 700, "condition": "lessThan", "relative": "parent" }
99
+ },
100
+ {
101
+ "type": "handleBar",
102
+ "sibling1": "menuContainer",
103
+ "sibling2": "editorContainer"
104
+ },
105
+ {
106
+ "containerId": "editorContainer",
107
+ "type": "container",
108
+ "size": { "initial": { "type": "fill" }}
109
+ }
110
+ ]
111
+ },
112
+ "footer": {
113
+ "id": "footer",
114
+ "background": "#007acc"
115
+ },
116
+ "sidebar": {
117
+ "id": "sidebar",
118
+ "background": "#333"
119
+ },
120
+ "menuContainer": {
121
+ "id": "menuContainer",
122
+ "background": "#252526",
123
+ "type": "split",
124
+ "orientation": "vertical",
125
+ "children": [
126
+ {
127
+ "containerId": "fileTabsContainer",
128
+ "type": "container",
129
+ "size": { "initial": { "type": "fill" }}
130
+ }
131
+ ]
132
+ },
133
+ "fileTabsContainer": {
134
+ "id": "fileTabsContainer",
135
+ "component": "FileTree",
136
+ "background": "#1e1e1e"
137
+ },
138
+ "editorContainer": {
139
+ "id": "editorContainer",
140
+ "component": "FileEditor",
141
+ "background": "#1e1e1e"
142
+ }
143
+ }
144
+ }
@@ -0,0 +1,48 @@
1
+
2
+ import { useRef, useLayoutEffect, useEffect } from "react";
3
+ import { Editor } from 'sample-ui-component-library';
4
+ import fileTree from "./workspace_sample.json";
5
+
6
+ import { useDragState } from "../../../components/LayoutManager/Providers/DragProvider";
7
+
8
+ const flattenTree = (tree, level = 0) =>
9
+ tree.flatMap(node => [
10
+ { ...node, level },
11
+ ...(node.children ? flattenTree(node.children, level + 1) : [])
12
+ ]);
13
+
14
+
15
+ const FileEditor = () => {
16
+ const editorRef = useRef(null);
17
+
18
+ const { drop } = useDragState();
19
+
20
+ useEffect(() => {
21
+ if (!drop?.overId) {
22
+ return;
23
+ }
24
+
25
+ const activeType = drop.activeData.type;
26
+ const overType = drop.overData.type;
27
+ if (activeType === "EditorTab" && overType === "EditorTabGutter") {
28
+ editorRef.current.moveTab(drop.activeData.node.uid, drop.overData.index);
29
+ } else if (activeType === "FileTreeNode" && overType === "EditorTabGutter") {
30
+ editorRef.current.addTab(drop.activeData.node, drop.overData.index);
31
+ }
32
+ }, [drop]);
33
+
34
+ useLayoutEffect(() => {
35
+ editorRef.current.setTabGroupId("tab-group-1");
36
+ flattenTree(fileTree.tree).forEach((node) => {
37
+ if (node.type === "file") {
38
+ editorRef.current.addTab(node);
39
+ }
40
+ });
41
+ }, []);
42
+
43
+ return (
44
+ <Editor ref={editorRef} />
45
+ );
46
+ };
47
+
48
+ export default FileEditor;
@@ -0,0 +1 @@
1
+ {"tree":[{"name":"library_manager_single_threaded","type":"folder","uid":"dir-ba56de84-31dd-4ccf-ae98-a98b0581f803","children":[{"name":"library_manager.py","type":"file","uid":"dir-3d7aaf8e-6224-4eb7-8301-936447fef430","content":"import sys\n\ndef place_book_on_shelf(book_shelf, name, genre):\n '''\n This function places the given book on the shelf \n in a slot determined by the first letter of its name.\n \n :param book_shelf: Bookshelf to place the book on.\n :param name: Name of the book.\n :param genre: Genre of the book.\n '''\n print(f\"Accepted book: {name} (Genre: {genre})\")\n \n firstLetter = name[0].upper()\n\n if (firstLetter not in book_shelf):\n book_shelf[firstLetter] = []\n else:\n print(\"Slot for book already exists.\")\n\n book_shelf[firstLetter].append(name)\n\n return book_shelf\n\ndef accept_book():\n '''\n Accepts a book and genre from the user and returns it.\n '''\n print(\"\\nEnter book details:\")\n \n name = input(\"Book name: \")\n\n genre = input(\"Genre: \")\n\n return {\"name\":name, \"genre\":genre}\n\n\ndef library_manager():\n '''\n Runs the library manager to accept books until the user decides to stop.\n '''\n book_shelf = {}\n\n while True:\n book_details = accept_book()\n book_shelf = place_book_on_shelf(\n book_shelf, \n book_details[\"name\"], \n book_details[\"genre\"]\n )\n\n more = input(\"Add another book? (y): \").lower()\n \n if more != \"y\":\n break\n\n print(\"Exiting library manager, goodbye.\")\n\nif __name__ == \"__main__\":\n sys.exit(library_manager())\n "},{"name":"readme","type":"file","uid":"dir-5aa507ee-e43d-4d77-b49a-b6e0b1da36f5","content":"This is version 1 of the library manager and it contains a simple implementation that accepts a book name and genre before placing it on the shelf. It places it on the shelf using the first letter of the book name. It continues to accept books until the user decides to stop.\n\nThis version of the library manager will also use instrumentation to identify abstractions by line to overcome the limitations of existing techniques."}]},{"name":"text_translator","type":"folder","uid":"dir-cbb97582-e3da-403e-aa7f-a524a5a7cff7","children":[{"name":"FrenchTranslator.py","type":"file","uid":"dir-516008b2-e80c-4a3a-bb00-d651885ac15d","content":"import threading\nimport queue\nfrom deep_translator import GoogleTranslator # type: ignore\n\nclass FrenchTranslator(threading.Thread):\n def __init__(self, id, queue, packerQueue):\n super().__init__(daemon=True)\n self.queue = queue\n self.id = id\n self.packerQueue = packerQueue\n self.start()\n\n def run(self):\n while True:\n try:\n job = self.queue.get(timeout=10)\n except queue.Empty:\n continue\n\n translatedMsg = GoogleTranslator(source=\"auto\", target=\"french\").translate(job[\"value\"][\"data\"])\n self.packerQueue.put({\n \"uid\": job[\"uid\"],\n \"value\": {\n \"language\": \"french\",\n \"original\": job[\"value\"][\"data\"],\n \"translated\": translatedMsg\n }\n })"},{"name":"Packer.py","type":"file","uid":"dir-e5085241-ff4f-434d-85ab-7f50e673ea4d","content":"import threading\nimport queue\nfrom TransactionDB import TransactionDB\n\nclass PackerThread(threading.Thread):\n def __init__(self, queue):\n super().__init__(daemon=True)\n self.queue = queue\n self.items = {}\n self.start()\n\n def run(self):\n self.db = TransactionDB()\n while True:\n try:\n translatedJobPart = self.queue.get(timeout=10)\n except queue.Empty:\n continue\n\n self.db.addTranslation(translatedJobPart)\n\n if self.db.isDone(translatedJobPart[\"uid\"]):\n self.db.setDone(translatedJobPart[\"uid\"])"},{"name":"SpanishTranslator.py","type":"file","uid":"dir-b2a78dfd-aa94-4068-a5f7-24c396d88825","content":"import threading\nimport queue\nfrom deep_translator import GoogleTranslator # type: ignore\n\nclass SpanishTranslator(threading.Thread):\n def __init__(self, id, queue, packerQueue):\n super().__init__(daemon=True)\n self.queue = queue\n self.id = id\n self.packerQueue = packerQueue\n self.start()\n\n def run(self):\n while True:\n try:\n job = self.queue.get(timeout=10)\n except queue.Empty:\n continue\n\n translatedMsg = GoogleTranslator(source=\"auto\", target=\"spanish\").translate(job[\"value\"][\"data\"])\n self.packerQueue.put({\n \"uid\": job[\"uid\"],\n \"value\": {\n \"language\": \"spanish\",\n \"original\": job[\"value\"][\"data\"],\n \"translated\": translatedMsg\n }\n })"},{"name":"TamilTranslator.py","type":"file","uid":"dir-594ff411-b916-4a88-9077-3d5b8ff7f871","content":"import threading\nimport queue\nfrom deep_translator import GoogleTranslator # type: ignore\n\nclass TamilTranslator(threading.Thread):\n def __init__(self, id, queue, packerQueue):\n super().__init__(daemon=True)\n self.queue = queue\n self.id = id\n self.packerQueue = packerQueue\n self.start()\n\n def run(self):\n while True:\n try:\n job = self.queue.get(timeout=10)\n except queue.Empty:\n continue\n\n translatedMsg = GoogleTranslator(source=\"auto\", target=\"tamil\").translate(job[\"value\"][\"data\"])\n self.packerQueue.put({\n \"uid\": job[\"uid\"],\n \"value\": {\n \"language\": \"tamil\",\n \"original\": job[\"value\"][\"data\"],\n \"translated\": translatedMsg\n }\n })"},{"name":"readme","type":"file","uid":"dir-f6459410-1634-4dbc-8d76-35896822158d","content":"This folder contains a text translator that uses three workers to translate the text and uses a packer to add the results to a cabinet."}]}]}
@@ -0,0 +1,26 @@
1
+ // @ts-nocheck
2
+ import { useRef, useLayoutEffect } from "react";
3
+ import { FileBrowser } from 'sample-ui-component-library';
4
+ import tree from "./workspace_sample.json"
5
+
6
+ const FileTree = () => {
7
+ const fileBrowserRef = useRef(null);
8
+
9
+ useLayoutEffect(() => {
10
+ fileBrowserRef.current.addFileTree(tree.tree);
11
+
12
+ setTimeout(() => {
13
+ fileBrowserRef.current.selectNode("dir-f6459410-1634-4dbc-8d76-35896822158d");
14
+ }, 3000);
15
+ }, []);
16
+
17
+ const onSelectFile = (node) => {
18
+ console.log("Selected Node:", node);
19
+ }
20
+
21
+ return (
22
+ <FileBrowser ref={fileBrowserRef} onSelectFile={onSelectFile} />
23
+ );
24
+ };
25
+
26
+ export default FileTree;
@@ -0,0 +1 @@
1
+ {"tree":[{"name":"library_manager_single_threaded","type":"folder","uid":"dir-ba56de84-31dd-4ccf-ae98-a98b0581f803","children":[{"name":"library_manager.py","type":"file","uid":"dir-3d7aaf8e-6224-4eb7-8301-936447fef430","content":"import sys\n\ndef place_book_on_shelf(book_shelf, name, genre):\n '''\n This function places the given book on the shelf \n in a slot determined by the first letter of its name.\n \n :param book_shelf: Bookshelf to place the book on.\n :param name: Name of the book.\n :param genre: Genre of the book.\n '''\n print(f\"Accepted book: {name} (Genre: {genre})\")\n \n firstLetter = name[0].upper()\n\n if (firstLetter not in book_shelf):\n book_shelf[firstLetter] = []\n else:\n print(\"Slot for book already exists.\")\n\n book_shelf[firstLetter].append(name)\n\n return book_shelf\n\ndef accept_book():\n '''\n Accepts a book and genre from the user and returns it.\n '''\n print(\"\\nEnter book details:\")\n \n name = input(\"Book name: \")\n\n genre = input(\"Genre: \")\n\n return {\"name\":name, \"genre\":genre}\n\n\ndef library_manager():\n '''\n Runs the library manager to accept books until the user decides to stop.\n '''\n book_shelf = {}\n\n while True:\n book_details = accept_book()\n book_shelf = place_book_on_shelf(\n book_shelf, \n book_details[\"name\"], \n book_details[\"genre\"]\n )\n\n more = input(\"Add another book? (y): \").lower()\n \n if more != \"y\":\n break\n\n print(\"Exiting library manager, goodbye.\")\n\nif __name__ == \"__main__\":\n sys.exit(library_manager())\n "},{"name":"readme","type":"file","uid":"dir-5aa507ee-e43d-4d77-b49a-b6e0b1da36f5","content":"This is version 1 of the library manager and it contains a simple implementation that accepts a book name and genre before placing it on the shelf. It places it on the shelf using the first letter of the book name. It continues to accept books until the user decides to stop.\n\nThis version of the library manager will also use instrumentation to identify abstractions by line to overcome the limitations of existing techniques."}]},{"name":"text_translator","type":"folder","uid":"dir-cbb97582-e3da-403e-aa7f-a524a5a7cff7","children":[{"name":"FrenchTranslator.py","type":"file","uid":"dir-516008b2-e80c-4a3a-bb00-d651885ac15d","content":"import threading\nimport queue\nfrom deep_translator import GoogleTranslator # type: ignore\n\nclass FrenchTranslator(threading.Thread):\n def __init__(self, id, queue, packerQueue):\n super().__init__(daemon=True)\n self.queue = queue\n self.id = id\n self.packerQueue = packerQueue\n self.start()\n\n def run(self):\n while True:\n try:\n job = self.queue.get(timeout=10)\n except queue.Empty:\n continue\n\n translatedMsg = GoogleTranslator(source=\"auto\", target=\"french\").translate(job[\"value\"][\"data\"])\n self.packerQueue.put({\n \"uid\": job[\"uid\"],\n \"value\": {\n \"language\": \"french\",\n \"original\": job[\"value\"][\"data\"],\n \"translated\": translatedMsg\n }\n })"},{"name":"Packer.py","type":"file","uid":"dir-e5085241-ff4f-434d-85ab-7f50e673ea4d","content":"import threading\nimport queue\nfrom TransactionDB import TransactionDB\n\nclass PackerThread(threading.Thread):\n def __init__(self, queue):\n super().__init__(daemon=True)\n self.queue = queue\n self.items = {}\n self.start()\n\n def run(self):\n self.db = TransactionDB()\n while True:\n try:\n translatedJobPart = self.queue.get(timeout=10)\n except queue.Empty:\n continue\n\n self.db.addTranslation(translatedJobPart)\n\n if self.db.isDone(translatedJobPart[\"uid\"]):\n self.db.setDone(translatedJobPart[\"uid\"])"},{"name":"SpanishTranslator.py","type":"file","uid":"dir-b2a78dfd-aa94-4068-a5f7-24c396d88825","content":"import threading\nimport queue\nfrom deep_translator import GoogleTranslator # type: ignore\n\nclass SpanishTranslator(threading.Thread):\n def __init__(self, id, queue, packerQueue):\n super().__init__(daemon=True)\n self.queue = queue\n self.id = id\n self.packerQueue = packerQueue\n self.start()\n\n def run(self):\n while True:\n try:\n job = self.queue.get(timeout=10)\n except queue.Empty:\n continue\n\n translatedMsg = GoogleTranslator(source=\"auto\", target=\"spanish\").translate(job[\"value\"][\"data\"])\n self.packerQueue.put({\n \"uid\": job[\"uid\"],\n \"value\": {\n \"language\": \"spanish\",\n \"original\": job[\"value\"][\"data\"],\n \"translated\": translatedMsg\n }\n })"},{"name":"TamilTranslator.py","type":"file","uid":"dir-594ff411-b916-4a88-9077-3d5b8ff7f871","content":"import threading\nimport queue\nfrom deep_translator import GoogleTranslator # type: ignore\n\nclass TamilTranslator(threading.Thread):\n def __init__(self, id, queue, packerQueue):\n super().__init__(daemon=True)\n self.queue = queue\n self.id = id\n self.packerQueue = packerQueue\n self.start()\n\n def run(self):\n while True:\n try:\n job = self.queue.get(timeout=10)\n except queue.Empty:\n continue\n\n translatedMsg = GoogleTranslator(source=\"auto\", target=\"tamil\").translate(job[\"value\"][\"data\"])\n self.packerQueue.put({\n \"uid\": job[\"uid\"],\n \"value\": {\n \"language\": \"tamil\",\n \"original\": job[\"value\"][\"data\"],\n \"translated\": translatedMsg\n }\n })"},{"name":"readme","type":"file","uid":"dir-f6459410-1634-4dbc-8d76-35896822158d","content":"This folder contains a text translator that uses three workers to translate the text and uses a packer to add the results to a cabinet."}]}]}
@@ -37,7 +37,7 @@ const MapSample = () => {
37
37
  }
38
38
  }, []);
39
39
 
40
- return <div ref={containerRef} style={{ backgroundColor:"#00000", height: "100%", width: "100%" }} />;
40
+ return <div ref={containerRef} style={{ backgroundColor:"#000000", height: "100%", width: "100%" }} />;
41
41
  };
42
42
 
43
43
  export default MapSample;
@@ -1,11 +0,0 @@
1
- // EditorVSCode.js
2
- import { Viewer } from 'sample-ui-component-library';
3
- import fileTree from "./filetree.json"
4
-
5
- const EditorVSCode = () => {
6
- return (
7
- <Viewer systemTree={fileTree.fileTrees} />
8
- );
9
- };
10
-
11
- export default EditorVSCode;