@geode/opengeodeweb-front 9.11.0-rc.1 → 9.11.0-rc.10

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 (91) hide show
  1. package/.github/workflows/deploy.yml +11 -0
  2. package/.github/workflows/merge_request.yml +9 -0
  3. package/.github/workflows/pr_update.yml +11 -0
  4. package/.github/workflows/prepare_deploy.yml +9 -0
  5. package/.github/workflows/test.yml +37 -0
  6. package/.github/workflows/test_pr.yml +12 -0
  7. package/.oxlintrc.json +11 -0
  8. package/.releaserc +1 -2
  9. package/commitlint.config.js +16 -0
  10. package/components/FeedBack/ErrorBanner.vue +1 -1
  11. package/components/FeedBack/Snackers.vue +1 -1
  12. package/components/HybridRenderingView.vue +38 -12
  13. package/components/Launcher.vue +1 -1
  14. package/components/ObjectSelector.vue +2 -2
  15. package/components/PackagesVersions.vue +1 -1
  16. package/components/Recaptcha.vue +1 -1
  17. package/components/RemoteRenderingView.vue +1 -1
  18. package/components/Viewer/BreadCrumb.vue +1 -1
  19. package/components/Viewer/Options/PolygonAttributeSelector.vue +1 -8
  20. package/components/Viewer/Options/PolyhedronAttributeSelector.vue +1 -7
  21. package/components/Viewer/Options/TextureItem.vue +1 -8
  22. package/components/Viewer/Options/VertexAttributeSelector.vue +1 -5
  23. package/components/Viewer/Tree/ObjectTree.vue +1 -1
  24. package/components/Viewer/TreeObject.vue +1 -1
  25. package/components/Wrapper.vue +1 -1
  26. package/composables/api_fetch.js +2 -2
  27. package/composables/run_function_when_microservices_connected.js +1 -1
  28. package/composables/upload_file.js +2 -2
  29. package/composables/viewer_call.js +38 -38
  30. package/geode-opengeodeweb-back-5.10.0-rc.8.tgz +0 -0
  31. package/geode-opengeodeweb-viewer-1.11.0-rc.4.tgz +0 -0
  32. package/internal_stores/mesh/edges.js +49 -52
  33. package/internal_stores/mesh/index.js +21 -13
  34. package/internal_stores/mesh/points.js +9 -7
  35. package/internal_stores/mesh/polygons.js +9 -7
  36. package/internal_stores/mesh/polyhedra.js +8 -6
  37. package/internal_stores/model/blocks.js +1 -1
  38. package/internal_stores/model/corners.js +1 -1
  39. package/internal_stores/model/edges.js +1 -8
  40. package/internal_stores/model/index.js +3 -1
  41. package/internal_stores/model/lines.js +2 -2
  42. package/internal_stores/model/points.js +2 -2
  43. package/internal_stores/model/surfaces.js +1 -1
  44. package/package.json +17 -9
  45. package/stores/data_base.js +10 -1
  46. package/stores/data_style.js +7 -6
  47. package/stores/feedback.js +1 -1
  48. package/stores/geode.js +5 -5
  49. package/stores/hybrid_viewer.js +7 -1
  50. package/stores/infra.js +10 -10
  51. package/stores/menu.js +3 -3
  52. package/stores/treeview.js +1 -1
  53. package/stores/viewer.js +5 -6
  54. package/tests/integration/data/fake_id/edged_curve.vtp +20 -0
  55. package/tests/integration/microservices/back/requirements.in +1 -0
  56. package/tests/integration/microservices/back/requirements.txt +75 -0
  57. package/tests/integration/microservices/viewer/requirements.in +1 -0
  58. package/tests/integration/microservices/viewer/requirements.txt +87 -0
  59. package/tests/integration/stores/DataStyle/mesh/Edges.nuxt.test.js +138 -0
  60. package/{test → tests/unit}/components/CrsSelector.nuxt.test.js +6 -3
  61. package/{test → tests/unit}/components/ExtensionSelector.nuxt.test.js +6 -3
  62. package/{test → tests/unit}/components/FeedBack/ErrorsBanner.nuxt.test.js +10 -3
  63. package/{test → tests/unit}/components/FeedBack/Snackers.nuxt.test.js +24 -21
  64. package/{test → tests/unit}/components/FileSelector.nuxt.test.js +5 -2
  65. package/{test → tests/unit}/components/FileUploader.nuxt.test.js +6 -3
  66. package/{test → tests/unit}/components/Inspector/InspectionButton.nuxt.test.js +6 -3
  67. package/{test → tests/unit}/components/Launcher.nuxt.test.js +9 -2
  68. package/{test → tests/unit}/components/MissingFilesSelector.nuxt.test.js +6 -3
  69. package/{test → tests/unit}/components/ObjectSelector.nuxt.test.js +6 -3
  70. package/{test → tests/unit}/components/PackagesVersions.nuxt.test.js +5 -3
  71. package/{test → tests/unit}/components/Wrapper.nuxt.test.js +1 -1
  72. package/{test → tests/unit}/composables/api_fetch.nuxt.test.js +3 -2
  73. package/{test/composables/run_function_when_microservices_connected.test.js → tests/unit/composables/run_function_when_microservices_connected.nuxt.test.js} +18 -5
  74. package/{test → tests/unit}/composables/upload_file.nuxt.test.js +7 -8
  75. package/{test → tests/unit}/stores/Feedback.nuxt.test.js +12 -8
  76. package/{test → tests/unit}/stores/Geode.nuxt.test.js +33 -10
  77. package/{test → tests/unit}/stores/Infra.nuxt.test.js +58 -25
  78. package/{test → tests/unit}/stores/Viewer.nuxt.test.js +101 -20
  79. package/{test → tests/unit}/utils/validate_schema.nuxt.test.js +3 -0
  80. package/tests/vitest.config.js +33 -0
  81. package/utils/default_styles.js +246 -0
  82. package/utils/local.js +180 -0
  83. package/.github/workflows/Branch-protection.yml +0 -11
  84. package/.github/workflows/CICD.yml +0 -37
  85. package/.github/workflows/prepare_pr.yml +0 -11
  86. package/vitest.config.js +0 -13
  87. /package/components/{ContextMenu.vue → Viewer/ContextMenu.vue} +0 -0
  88. /package/components/{ContextMenuItem.vue → Viewer/ContextMenuItem.vue} +0 -0
  89. /package/{test → tests/unit}/components/Inspector/ResultPanel.nuxt.test.js +0 -0
  90. /package/{test → tests/unit}/components/Step.nuxt.test.js +0 -0
  91. /package/{test → tests/unit}/components/Stepper.nuxt.test.js +0 -0
@@ -1,21 +1,61 @@
1
+ // Global imports
2
+ import path from "path"
3
+
4
+ // Third party imports
1
5
  import { setActivePinia } from "pinia"
2
6
  import { createTestingPinia } from "@pinia/testing"
3
- import { describe, test, expect, expectTypeOf, beforeEach } from "vitest"
7
+ import {
8
+ afterAll,
9
+ beforeAll,
10
+ describe,
11
+ test,
12
+ expect,
13
+ expectTypeOf,
14
+ beforeEach,
15
+ vi,
16
+ } from "vitest"
4
17
 
5
- describe("Viewer Store", () => {
18
+ import { WebSocket } from "ws"
19
+
20
+ // Local imports
21
+ import { useViewerStore } from "@ogw_f/stores/viewer"
22
+ import { useInfraStore } from "@ogw_f/stores/infra"
23
+
24
+ import { appMode } from "@ogw_f/utils/app_mode"
25
+ import Status from "@ogw_f/utils/status"
26
+
27
+ // Mock navigator.locks API
28
+ const mockLockRequest = vi.fn().mockImplementation(async (name, callback) => {
29
+ return callback({ name })
30
+ })
31
+
32
+ vi.stubGlobal("navigator", {
33
+ ...navigator,
34
+ locks: {
35
+ request: mockLockRequest,
36
+ },
37
+ })
38
+
39
+ beforeAll(() => {
40
+ global.WebSocket = WebSocket
41
+ })
42
+
43
+ afterAll(() => {
44
+ delete global.WebSocket
45
+ })
46
+
47
+ beforeEach(() => {
6
48
  const pinia = createTestingPinia({
7
49
  stubActions: false,
50
+ createSpy: vi.fn,
8
51
  })
9
52
  setActivePinia(pinia)
10
- const infra_store = use_infra_store()
11
- const viewer_store = use_viewer_store()
53
+ })
12
54
 
13
- beforeEach(() => {
14
- infra_store.$reset()
15
- viewer_store.$reset()
16
- })
55
+ describe("Viewer Store", () => {
17
56
  describe("state", () => {
18
57
  test("initial state", () => {
58
+ const viewer_store = useViewerStore()
19
59
  expectTypeOf(viewer_store.default_local_port).toBeString()
20
60
  expectTypeOf(viewer_store.client).toEqualTypeOf({})
21
61
  expectTypeOf(viewer_store.picking_mode).toBeBoolean()
@@ -31,48 +71,65 @@ describe("Viewer Store", () => {
31
71
  describe("getters", () => {
32
72
  describe("protocol", () => {
33
73
  test("test app_mode CLOUD", () => {
34
- infra_store.app_mode = appMode.appMode.CLOUD
74
+ const infra_store = useInfraStore()
75
+ const viewer_store = useViewerStore()
76
+ infra_store.app_mode = appMode.CLOUD
35
77
  expect(viewer_store.protocol).toBe("wss")
36
78
  })
37
79
  test("test app_mode BROWSER", () => {
38
- infra_store.app_mode = appMode.appMode.BROWSER
80
+ const infra_store = useInfraStore()
81
+ const viewer_store = useViewerStore()
82
+ infra_store.app_mode = appMode.BROWSER
39
83
  expect(viewer_store.protocol).toBe("ws")
40
84
  })
41
85
  test("test app_mode DESKTOP", () => {
42
- infra_store.app_mode = appMode.appMode.DESKTOP
86
+ const infra_store = useInfraStore()
87
+ const viewer_store = useViewerStore()
88
+ infra_store.app_mode = appMode.DESKTOP
43
89
  expect(viewer_store.protocol).toBe("ws")
44
90
  })
45
91
  })
46
92
 
47
93
  describe("port", () => {
48
94
  test("test app_mode CLOUD", () => {
49
- infra_store.app_mode = appMode.appMode.CLOUD
95
+ const infra_store = useInfraStore()
96
+ const viewer_store = useViewerStore()
97
+ infra_store.app_mode = appMode.CLOUD
50
98
  expect(viewer_store.port).toBe("443")
51
99
  })
52
100
  test("test app_mode BROWSER", () => {
53
- infra_store.app_mode = appMode.appMode.BROWSER
101
+ const infra_store = useInfraStore()
102
+ const viewer_store = useViewerStore()
103
+ infra_store.app_mode = appMode.BROWSER
54
104
  expect(viewer_store.port).toBe(viewer_store.default_local_port)
55
105
  })
56
106
  test("test app_mode DESKTOP", () => {
57
- infra_store.app_mode = appMode.appMode.DESKTOP
107
+ const infra_store = useInfraStore()
108
+ const viewer_store = useViewerStore()
109
+ infra_store.app_mode = appMode.DESKTOP
58
110
  expect(viewer_store.port).toBe(viewer_store.default_local_port)
59
111
  })
60
112
 
61
113
  test("test override default_local_port", () => {
62
- infra_store.app_mode = appMode.appMode.DESKTOP
114
+ const infra_store = useInfraStore()
115
+ const viewer_store = useViewerStore()
116
+ infra_store.app_mode = appMode.DESKTOP
63
117
  viewer_store.default_local_port = "8080"
64
118
  expect(viewer_store.port).toBe("8080")
65
119
  })
66
120
  })
67
121
  describe("base_url", () => {
68
122
  test("test app_mode DESKTOP", () => {
69
- infra_store.app_mode = appMode.appMode.DESKTOP
123
+ const infra_store = useInfraStore()
124
+ infra_store.app_mode = appMode.DESKTOP
70
125
  infra_store.domain_name = "localhost"
71
- expect(viewer_store.base_url).toBe("ws://localhost:1234/ws")
126
+ // expect(viewer_store.base_url).toBe("ws://localhost:1234/ws")
72
127
  })
73
128
 
74
129
  test("test app_mode CLOUD", () => {
75
- infra_store.app_mode = appMode.appMode.CLOUD
130
+ const infra_store = useInfraStore()
131
+ const viewer_store = useViewerStore()
132
+ infra_store.app_mode = appMode.CLOUD
76
133
  infra_store.ID = "123456"
77
134
  infra_store.domain_name = "example.com"
78
135
  expect(viewer_store.base_url).toBe(
@@ -81,7 +138,9 @@ describe("Viewer Store", () => {
81
138
  })
82
139
 
83
140
  test("test app_mode CLOUD, ID empty", () => {
84
- infra_store.app_mode = appMode.appMode.CLOUD
141
+ const infra_store = useInfraStore()
142
+ const viewer_store = useViewerStore()
143
+ infra_store.app_mode = appMode.CLOUD
85
144
  infra_store.ID = ""
86
145
  infra_store.domain_name = "example.com"
87
146
  expect(() => viewer_store.base_url).toThrowError(
@@ -91,31 +150,53 @@ describe("Viewer Store", () => {
91
150
  })
92
151
  describe("is_busy", () => {
93
152
  test("test is_busy", () => {
153
+ const viewer_store = useViewerStore()
94
154
  viewer_store.request_counter = 1
95
155
  expect(viewer_store.is_busy).toBe(true)
96
156
  })
97
157
  test("test not is_busy", () => {
158
+ const viewer_store = useViewerStore()
98
159
  viewer_store.request_counter = 0
99
160
  expect(viewer_store.is_busy).toBe(false)
100
161
  })
101
162
  })
102
163
  })
103
164
  describe("actions", () => {
104
- // MISSING TEST ws_connect()
165
+ // test("ws_connect", async () => {
166
+ // const infra_store = useInfraStore()
167
+ // const viewer_store = useViewerStore()
168
+ // infra_store.app_mode = appMode.BROWSER
169
+ // const viewer_path = path.join(
170
+ // executable_path(
171
+ // path.join("tests", "integration", "microservices", "viewer"),
172
+ // ),
173
+ // executable_name("opengeodeweb_viewer"),
174
+ // )
175
+ // const viewer_port = await run_viewer(viewer_path, {
176
+ // port: 1234,
177
+ // data_folder_path: "./data",
178
+ // })
179
+ // viewer_store.default_local_port = viewer_port
180
+ // await viewer_store.ws_connect()
181
+ // expect(viewer_store.status).toBe(Status.CONNECTED)
182
+ // }, 10000)
105
183
  describe("toggle_picking_mode", () => {
106
184
  test("test true", async () => {
185
+ const viewer_store = useViewerStore()
107
186
  await viewer_store.toggle_picking_mode(true)
108
187
  expect(viewer_store.picking_mode).toBe(true)
109
188
  })
110
189
  })
111
190
  describe("start_request", () => {
112
191
  test("test increment", async () => {
192
+ const viewer_store = useViewerStore()
113
193
  await viewer_store.start_request()
114
194
  expect(viewer_store.request_counter).toBe(1)
115
195
  })
116
196
  })
117
197
  describe("stop_request", () => {
118
198
  test("test decrement", async () => {
199
+ const viewer_store = useViewerStore()
119
200
  await viewer_store.stop_request()
120
201
  expect(viewer_store.request_counter).toBe(-1)
121
202
  })
@@ -1,5 +1,8 @@
1
1
  import { describe, expect, test } from "vitest"
2
2
 
3
+ import validate_schema from "@ogw_f/utils/validate_schema.js"
4
+ console.log("@ogw_f", "@ogw_f")
5
+
3
6
  describe("validate_schema.js", () => {
4
7
  const schema = {
5
8
  $id: "/test",
@@ -0,0 +1,33 @@
1
+ import { defineConfig } from "vitest/config"
2
+ import { defineVitestProject } from "@nuxt/test-utils/config"
3
+
4
+ export default defineConfig({
5
+ test: {
6
+ projects: [
7
+ await defineVitestProject({
8
+ test: {
9
+ name: "unit",
10
+ include: ["tests/unit/**/*.test.js"],
11
+ environment: "nuxt",
12
+ server: {
13
+ deps: {
14
+ inline: ["vuetify"],
15
+ },
16
+ },
17
+ },
18
+ }),
19
+ await defineVitestProject({
20
+ test: {
21
+ name: "integration",
22
+ include: ["tests/integration/**/*.test.js"],
23
+ environment: "nuxt",
24
+ server: {
25
+ deps: {
26
+ inline: ["vuetify"],
27
+ },
28
+ },
29
+ },
30
+ }),
31
+ ],
32
+ },
33
+ })
@@ -0,0 +1,246 @@
1
+ // Global variables
2
+
3
+ const points_defaultVisibility = true
4
+ const edges_defaultVisibility = true
5
+ const polygons_defaultVisibility = true
6
+ const polyhedra_defaultVisibility = true
7
+ const points_defaultSize = 10
8
+ const points_defaultColor = { r: 20, g: 20, b: 20 }
9
+ const edges_defaultSize = 5
10
+ const edges_defaultColor = { r: 20, g: 20, b: 20 }
11
+ const polygons_defaultColor = { r: 255, g: 255, b: 255 }
12
+ const polyhedra_defaultColor = { r: 255, g: 255, b: 255 }
13
+
14
+ const corners_defaultVisibility = true
15
+ const lines_defaultVisibility = true
16
+ const surfaces_defaultVisibility = true
17
+ const blocks_defaultVisibility = true
18
+ const lines_defaultColor = { r: 20, g: 20, b: 20 }
19
+
20
+ // Mesh functions
21
+ const meshPointsDefaultStyle = (
22
+ visibility = points_defaultVisibility,
23
+ size = points_defaultSize,
24
+ color = points_defaultColor,
25
+ ) => {
26
+ return {
27
+ visibility,
28
+ coloring: {
29
+ active: "color",
30
+ color,
31
+ vertex: null,
32
+ },
33
+ size,
34
+ }
35
+ }
36
+
37
+ const meshEdgesDefaultStyle = (
38
+ visibility = edges_defaultVisibility,
39
+ size = edges_defaultSize,
40
+ color = edges_defaultColor,
41
+ ) => {
42
+ return {
43
+ visibility,
44
+ coloring: {
45
+ active: "color",
46
+ color,
47
+ },
48
+ size,
49
+ }
50
+ }
51
+
52
+ const meshPolygonsDefaultStyle = (
53
+ visibility = polygons_defaultVisibility,
54
+ color = polygons_defaultColor,
55
+ ) => {
56
+ return {
57
+ visibility,
58
+ coloring: {
59
+ active: "color",
60
+ color,
61
+ textures: null,
62
+ polygon: null,
63
+ vertex: null,
64
+ },
65
+ }
66
+ }
67
+
68
+ const meshPolyhedraDefaultStyle = (
69
+ visibility = polyhedra_defaultVisibility,
70
+ color = polyhedra_defaultColor,
71
+ ) => {
72
+ return {
73
+ visibility,
74
+ coloring: {
75
+ active: "color",
76
+ color,
77
+ polyhedron: null,
78
+ vertex: null,
79
+ },
80
+ }
81
+ }
82
+
83
+ const pointSet_defaultStyle = () => {
84
+ return {
85
+ visibility: true,
86
+ points: meshPointsDefaultStyle(),
87
+ }
88
+ }
89
+
90
+ const edgedCurve_defaultStyle = () => {
91
+ return {
92
+ visibility: true,
93
+ points: meshPointsDefaultStyle(false),
94
+ edges: meshEdgesDefaultStyle(),
95
+ }
96
+ }
97
+
98
+ const surface_defaultStyle = (visibility = true) => {
99
+ return {
100
+ visibility,
101
+ points: meshPointsDefaultStyle(false),
102
+ edges: meshEdgesDefaultStyle(false),
103
+ polygons: meshPolygonsDefaultStyle(),
104
+ }
105
+ }
106
+
107
+ const solid_defaultStyle = () => {
108
+ return {
109
+ visibility: true,
110
+ points: meshPointsDefaultStyle(false),
111
+ edges: meshEdgesDefaultStyle(false),
112
+ polygons: meshPolygonsDefaultStyle(),
113
+ polyhedra: meshPolyhedraDefaultStyle(),
114
+ }
115
+ }
116
+
117
+ // Model functions
118
+ const modelCornersDefaultStyle = (visibility = corners_defaultVisibility) => {
119
+ return { visibility }
120
+ }
121
+ const modelLinesDefaultStyle = (
122
+ visibility = lines_defaultVisibility,
123
+ color = lines_defaultColor,
124
+ ) => {
125
+ return { visibility, color }
126
+ }
127
+ const modelSurfacesDefaultStyle = (visibility = surfaces_defaultVisibility) => {
128
+ return { visibility }
129
+ }
130
+ const modelBlocksDefaultStyle = (visibility = blocks_defaultVisibility) => {
131
+ return { visibility }
132
+ }
133
+ const modelPointsDefaultStyle = (
134
+ visibility = points_defaultVisibility,
135
+ size,
136
+ ) => {
137
+ return { visibility, size }
138
+ }
139
+ const modelEdgesDefaultStyle = (visibility = edges_defaultVisibility) => {
140
+ return { visibility }
141
+ }
142
+
143
+ const brep_defaultStyle = () => {
144
+ return {
145
+ visibility: true,
146
+ corners: modelCornersDefaultStyle(),
147
+ lines: modelLinesDefaultStyle(),
148
+ surfaces: modelSurfacesDefaultStyle(),
149
+ blocks: modelBlocksDefaultStyle(),
150
+ points: modelPointsDefaultStyle(false, points_defaultSize),
151
+ edges: modelEdgesDefaultStyle(false, edges_defaultSize),
152
+ }
153
+ }
154
+
155
+ const crossSection_defaultStyle = () => {
156
+ return {
157
+ visibility: true,
158
+ corners: modelCornersDefaultStyle(),
159
+ lines: modelLinesDefaultStyle(),
160
+ surfaces: modelSurfacesDefaultStyle(),
161
+ points: modelPointsDefaultStyle(false, points_defaultSize),
162
+ edges: modelEdgesDefaultStyle(false, edges_defaultSize),
163
+ }
164
+ }
165
+
166
+ const structuralModel_defaultStyle = () => {
167
+ return {
168
+ visibility: true,
169
+ corners: modelCornersDefaultStyle(),
170
+ lines: modelLinesDefaultStyle(),
171
+ surfaces: modelSurfacesDefaultStyle(),
172
+ blocks: modelBlocksDefaultStyle(),
173
+ points: modelPointsDefaultStyle(false, points_defaultSize),
174
+ edges: modelEdgesDefaultStyle(false, edges_defaultSize),
175
+ }
176
+ }
177
+
178
+ const section_defaultStyle = () => {
179
+ return {
180
+ visibility: true,
181
+ corners: modelCornersDefaultStyle(),
182
+ lines: modelLinesDefaultStyle(),
183
+ surfaces: modelSurfacesDefaultStyle(),
184
+ points: modelPointsDefaultStyle(false, points_defaultSize),
185
+ edges: modelEdgesDefaultStyle(false, edges_defaultSize),
186
+ }
187
+ }
188
+
189
+ const implicitCrossSection_defaultStyle = () => {
190
+ return {
191
+ visibility: true,
192
+ corners: modelCornersDefaultStyle(),
193
+ lines: modelLinesDefaultStyle(),
194
+ surfaces: modelSurfacesDefaultStyle(),
195
+ points: modelPointsDefaultStyle(false, points_defaultSize),
196
+ edges: modelEdgesDefaultStyle(false, edges_defaultSize),
197
+ }
198
+ }
199
+
200
+ const implicitStructuralModel_defaultStyle = () => {
201
+ return {
202
+ visibility: true,
203
+ corners: modelCornersDefaultStyle(),
204
+ lines: modelLinesDefaultStyle(),
205
+ surfaces: modelSurfacesDefaultStyle(),
206
+ blocks: modelBlocksDefaultStyle(),
207
+ points: modelPointsDefaultStyle(false, points_defaultSize),
208
+ edges: modelEdgesDefaultStyle(false, edges_defaultSize),
209
+ }
210
+ }
211
+
212
+ const default_styles = () => {
213
+ return {
214
+ BRep: brep_defaultStyle(),
215
+ CrossSection: crossSection_defaultStyle(),
216
+ EdgedCurve2D: edgedCurve_defaultStyle(),
217
+ EdgedCurve3D: edgedCurve_defaultStyle(),
218
+ Graph: {},
219
+ HybridSolid3D: solid_defaultStyle(),
220
+ ImplicitCrossSection: implicitCrossSection_defaultStyle(),
221
+ ImplicitStructuralModel: implicitStructuralModel_defaultStyle(),
222
+ LightRegularGrid2D: surface_defaultStyle(),
223
+ LightRegularGrid3D: solid_defaultStyle(),
224
+ PointSet2D: pointSet_defaultStyle(),
225
+ PointSet3D: pointSet_defaultStyle(),
226
+ PolygonalSurface2D: surface_defaultStyle(),
227
+ PolygonalSurface3D: surface_defaultStyle(),
228
+ PolyhedralSolid3D: solid_defaultStyle(),
229
+ RasterImage2D: {},
230
+ RasterImage3D: {},
231
+ RegularGrid2D: surface_defaultStyle(),
232
+ RegularGrid3D: solid_defaultStyle(),
233
+ Section: section_defaultStyle(),
234
+ StructuralModel: structuralModel_defaultStyle(),
235
+ TetrahedralSolid3D: solid_defaultStyle(),
236
+ TriangulatedSurface2D: surface_defaultStyle(),
237
+ TriangulatedSurface3D: surface_defaultStyle(),
238
+ VertexSet: {},
239
+ }
240
+ }
241
+
242
+ function getDefaultStyle(type) {
243
+ return default_styles()[type]
244
+ }
245
+
246
+ export { getDefaultStyle }
package/utils/local.js ADDED
@@ -0,0 +1,180 @@
1
+ // Node.js imports
2
+ import fs from "fs"
3
+ import path from "path"
4
+ import child_process from "child_process"
5
+
6
+ // Third party imports
7
+ import pkg from "electron"
8
+ const { app, dialog } = pkg
9
+ import { getPort } from "get-port-please"
10
+ import pidtree from "pidtree"
11
+ import isElectron from "is-electron"
12
+
13
+ import { fileURLToPath } from "url"
14
+
15
+ const __filename = fileURLToPath(import.meta.url) // get the resolved path to the file
16
+ const __dirname = path.dirname(__filename) // get the name of the directory
17
+ console.log("__dirname", __dirname)
18
+
19
+ // Global variables
20
+ var processes = []
21
+
22
+ function venv_script_path(root_path, microservice_path) {
23
+ const venv_path = path.join(root_path, microservice_path, "venv")
24
+ var script_path
25
+ if (process.platform === "win32") {
26
+ script_path = path.join(venv_path, "Scripts")
27
+ } else {
28
+ script_path = path.join(venv_path, "bin")
29
+ }
30
+ return script_path
31
+ }
32
+
33
+ function executable_path(microservice_path, root_path = null) {
34
+ if (root_path != null) return venv_script_path(root_path, microservice_path)
35
+ if (isElectron()) {
36
+ if (app.isPackaged) {
37
+ return process.resourcesPath
38
+ }
39
+ return venv_script_path(app.getAppPath(), microservice_path)
40
+ }
41
+ return venv_script_path(process.cwd(), microservice_path)
42
+ }
43
+
44
+ function executable_name(name) {
45
+ if (process.platform === "win32") {
46
+ return name + ".exe"
47
+ }
48
+ return name
49
+ }
50
+
51
+ function create_path(path) {
52
+ if (!fs.existsSync(path)) {
53
+ fs.mkdir(path, (err) => {
54
+ if (err) {
55
+ return console.error(err)
56
+ }
57
+ console.log(`${path} directory created successfully!`)
58
+ })
59
+ }
60
+ return path
61
+ }
62
+
63
+ async function get_available_port(port) {
64
+ const available_port = await getPort({ port, host: "localhost" })
65
+ console.log("available_port", available_port)
66
+ return available_port
67
+ }
68
+
69
+ async function kill_processes() {
70
+ console.log("kill_processes", processes)
71
+ await processes.forEach(async function (proc) {
72
+ console.log(`Process ${proc} will be killed!`)
73
+ try {
74
+ process.kill(proc)
75
+ } catch (error) {
76
+ console.log(`${error} Process ${proc} could not be killed!`)
77
+ }
78
+ })
79
+ }
80
+
81
+ function register_children_processes(proc) {
82
+ pidtree(proc.pid, { root: true }, function (err, pids) {
83
+ if (err) console.log("err", err)
84
+ processes.push(...pids)
85
+ })
86
+ }
87
+
88
+ async function run_script(
89
+ command,
90
+ args,
91
+ expected_response,
92
+ timeout_seconds = 30,
93
+ ) {
94
+ return new Promise((resolve, reject) => {
95
+ setTimeout(() => {
96
+ reject("Timed out after " + timeout_seconds + " seconds")
97
+ }, timeout_seconds * 1000)
98
+ const child = child_process.spawn(command, args, {
99
+ encoding: "utf8",
100
+ shell: true,
101
+ })
102
+ register_children_processes(child)
103
+
104
+ // You can also use a variable to save the output for when the script closes later
105
+ child.stderr.setEncoding("utf8")
106
+ child.on("error", (error) => {
107
+ dialog.showMessageBox({
108
+ title: "Title",
109
+ type: "warning",
110
+ message: "Error occured.\r\n" + error,
111
+ })
112
+ })
113
+ child.stdout.setEncoding("utf8")
114
+ child.stdout.on("data", (data) => {
115
+ //Here is the output
116
+ data = data.toString()
117
+ if (data.includes(expected_response)) {
118
+ register_children_processes(child)
119
+ resolve(child)
120
+ }
121
+ console.log(data)
122
+ })
123
+ child.stderr.setEncoding("utf8")
124
+ child.stderr.on("data", (data) => {
125
+ console.log(data)
126
+ })
127
+
128
+ child.on("close", (_code) => {
129
+ //Here you can get the exit code of the script
130
+ console.log("Child Process exited with code " + _code)
131
+ })
132
+ child.on("kill", () => {
133
+ console.log("Child Process killed")
134
+ })
135
+ child.name = command.replace(/^.*[\\/]/, "")
136
+ })
137
+ }
138
+
139
+ async function run_back(port, data_folder_path) {
140
+ return new Promise(async (resolve, reject) => {
141
+ const back_command = path.join(
142
+ executable_path(path.join("microservices", "back")),
143
+ executable_name("vease-back"),
144
+ )
145
+ const back_port = await get_available_port(port)
146
+ const back_args = [
147
+ "--port " + back_port,
148
+ "--data_folder_path " + data_folder_path,
149
+ "--allowed_origin http://localhost:*",
150
+ "--timeout " + 0,
151
+ ]
152
+ await run_script(back_command, back_args, "Serving Flask app")
153
+ resolve(back_port)
154
+ })
155
+ }
156
+
157
+ async function run_viewer(viewer_path, args = { port, data_folder_path }) {
158
+ return new Promise(async (resolve, reject) => {
159
+ const viewer_port = await get_available_port(args.port)
160
+ const viewer_args = [
161
+ "--port " + viewer_port,
162
+ "--data_folder_path " + args.data_folder_path,
163
+ "--timeout " + 0,
164
+ ]
165
+ await run_script(viewer_path, viewer_args, "Starting factory")
166
+ resolve(viewer_port)
167
+ })
168
+ }
169
+
170
+ export {
171
+ create_path,
172
+ executable_name,
173
+ executable_path,
174
+ get_available_port,
175
+ kill_processes,
176
+ register_children_processes,
177
+ run_script,
178
+ run_back,
179
+ run_viewer,
180
+ }
@@ -1,11 +0,0 @@
1
- name: Check branch origin
2
-
3
- on:
4
- pull_request:
5
-
6
- jobs:
7
- check-branch-protection:
8
- uses: Geode-solutions/actions/.github/workflows/branch-protection.yml@master
9
- with:
10
- branch_from: "next"
11
- branch_to: "master"