@abi-software/scaffoldvuer 1.6.0 → 1.6.2-wc

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/scaffoldvuer",
3
- "version": "1.6.0",
3
+ "version": "1.6.2-wc",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,6 +9,7 @@
9
9
  "scripts": {
10
10
  "serve": "vite --host --force",
11
11
  "build-bundle": "vite build",
12
+ "build-wc": "vite build -c vite.web-component.js",
12
13
  "build-static": "vite build -c vite.static-build.js",
13
14
  "vuese-gen": "node vuese-generator.js",
14
15
  "vuese-watch": "node vuese-generator.js watch",
@@ -54,7 +55,7 @@
54
55
  "vue": "^3.4.21",
55
56
  "vue-router": "^4.2.5",
56
57
  "vue3-component-svg-sprite": "^0.0.1",
57
- "zincjs": "^1.11.4"
58
+ "zincjs": "^1.11.5"
58
59
  },
59
60
  "devDependencies": {
60
61
  "@vitejs/plugin-vue": "^4.6.2",
@@ -70,7 +71,8 @@
70
71
  "vite": "^5.0.10",
71
72
  "vite-plugin-node-polyfills": "^0.21.0",
72
73
  "vitepress": "^1.0.0-rc.42",
73
- "vue-docgen-api": "^4.79.2"
74
+ "vue-docgen-api": "^4.79.2",
75
+ "vue-web-component-wrapper": "^1.6.9"
74
76
  },
75
77
  "eslintConfig": {
76
78
  "root": true,
package/src/App.vue CHANGED
@@ -29,6 +29,7 @@
29
29
  :marker-labels="markerLabels"
30
30
  :enableLocalAnnotations="false"
31
31
  @open-map="openMap"
32
+ @on-error="onError"
32
33
  @on-ready="onReady"
33
34
  @scaffold-selected="onSelected"
34
35
  @scaffold-navigated="onNavigated"
@@ -184,6 +185,9 @@
184
185
  <el-col :span="auto">
185
186
  <el-switch v-model="renderInfoOn" active-text="Renderer Info" active-color="#8300bf" />
186
187
  </el-col>
188
+ <el-button size="small" @click="PrintViewport()">
189
+ Print Viewport
190
+ </el-button>
187
191
  </el-row>
188
192
 
189
193
  <template v-if="renderInfoOn && rendererInfo">
@@ -597,6 +601,10 @@ export default {
597
601
  this.$refs.scaffold.getDynamicSelectedCoordinates();
598
602
  this.rendererInfo = this.$refs.scaffold.getRendererInfo();
599
603
  },
604
+ PrintViewport: function() {
605
+ const scene = this.$refs.scaffold.$module.scene;
606
+ console.log(scene.getZincCameraControls().getCurrentViewport());
607
+ },
600
608
  fetchSuggestions: function (term, cb) {
601
609
  if (term === "" || !this.$refs.scaffold) {
602
610
  cb([]);
@@ -640,6 +648,17 @@ export default {
640
648
  }
641
649
  });
642
650
  },
651
+ onError: function(payload) {
652
+ if (payload?.type === "download-error") {
653
+ const dropZone = this.$refs.dropzone;
654
+ if (dropZone) {
655
+ const realFilename = dropZone.findRealFilename(payload.xhr.responseURL);
656
+ if (realFilename) {
657
+ console.error(`External Resource ${realFilename}`);
658
+ }
659
+ }
660
+ }
661
+ },
643
662
  onReady: function () {
644
663
  if (this.consoleOn) console.log(this.$refs.scaffold)
645
664
  if (this.readyCallback) {
@@ -1,11 +1,19 @@
1
- import Vue from 'vue'
2
- import vueCustomElement from 'vue-custom-element';
1
+ import { defineCustomElementSFC } from 'vue-web-component-wrapper';
2
+ import { createPinia, setActivePinia } from "pinia";
3
+ import { useMainStore } from '@/store/index'
3
4
 
4
- Vue.use(vueCustomElement);
5
+ import ScaffoldVuerComponent from "./components/ScaffoldVuer.vue";
5
6
 
6
- import ScaffoldVuer from "./components/ScaffoldVuer.vue";
7
+ setActivePinia(createPinia());
8
+ const mainStore = useMainStore();
9
+ const token = document.cookie.split("; ").find((row) => row.startsWith("user-token"));
10
+ if (mainStore && token) {
11
+ mainStore.setUserToken(token.split("=")[1]);
12
+ }
7
13
 
8
- Vue.customElement("scaffoldvuer-wc", ScaffoldVuer);
14
+ const ScaffoldVuer = defineCustomElementSFC(ScaffoldVuerComponent, { shadowRoot: false });
15
+
16
+ customElements.define("scaffoldvuer-wc", ScaffoldVuer);
9
17
 
10
18
  /*
11
19
  const wrappedElement = wrap(Vue, ScaffoldVuer);
@@ -13,6 +13,7 @@
13
13
 
14
14
  <script>
15
15
  /* eslint-disable no-alert, no-console */
16
+ import { markRaw } from 'vue';
16
17
  import { SimpleDropzone } from "simple-dropzone";
17
18
  import path from "path";
18
19
 
@@ -26,7 +27,8 @@ export default {
26
27
  name: "DropZone",
27
28
  data: function () {
28
29
  return {
29
- objectURLs: [],
30
+ objectURLs: markRaw([]),
31
+ filesMapping: markRaw({}),
30
32
  };
31
33
  },
32
34
  mounted: function () {
@@ -39,6 +41,9 @@ export default {
39
41
  });
40
42
  },
41
43
  methods: {
44
+ findRealFilename: function(objectURL) {
45
+ return this.filesMapping[objectURL]
46
+ },
42
47
  processTextureFile: function(textureData, flatarray) {
43
48
  if (textureData && textureData.images && textureData.images.source) {
44
49
  const images = textureData.images.source;
@@ -50,6 +55,7 @@ export default {
50
55
  const objectURL = URL.createObjectURL(flatarray[index][1]);
51
56
  this.objectURLs.push(objectURL);
52
57
  textureData.images.source[i] = objectURL;
58
+ this.filesMapping[objectURL] = images[i];
53
59
  }
54
60
  }
55
61
  const content = JSON.stringify(textureData);
@@ -65,6 +71,7 @@ export default {
65
71
  const re = new RegExp(key, "g");
66
72
  content = content.replace(re, objectURL);
67
73
  this.objectURLs.push(objectURL);
74
+ this.filesMapping[objectURL] = key;
68
75
  }
69
76
  }
70
77
  const data = JSON.parse(content);
@@ -93,7 +100,8 @@ export default {
93
100
  },
94
101
  revokeURLs: function () {
95
102
  this.objectURLs.forEach(objectURL => URL.revokeObjectURL(objectURL));
96
- this.objectURLs = [];
103
+ this.objectURLs.length = 0;
104
+ this.filesMapping = markRaw({});
97
105
  },
98
106
  localDrop: function (fileMap) {
99
107
  this.revokeURLs();
@@ -1338,7 +1338,7 @@ export default {
1338
1338
  this.$module.selectObjectOnPick = true;
1339
1339
  } else if (type === 'tool') {
1340
1340
  this.activeDrawTool = icon;
1341
- this.createData.shape = this.activeDrawTool;
1341
+ this.createData.shape = this.activeDrawTool ? this.activeDrawTool : '';
1342
1342
  this.$module.selectObjectOnPick = false;
1343
1343
  }
1344
1344
  },
@@ -1544,6 +1544,16 @@ export default {
1544
1544
  });
1545
1545
  zincObjects = event.zincObjects;
1546
1546
  }
1547
+ let id = undefined;
1548
+ let regionPath = undefined;
1549
+ if (event.identifiers.length > 0 && event.identifiers[0]) {
1550
+ id = event.identifiers[0].data.id
1551
+ ? event.identifiers[0].data.id
1552
+ : event.identifiers[0].data.group;
1553
+ if (event.identifiers[0].data.region) {
1554
+ regionPath = event.identifiers[0].data.region;
1555
+ }
1556
+ }
1547
1557
  /*
1548
1558
  * Event Type 1: Selected
1549
1559
  * Event Type 2: Highlighted
@@ -1551,6 +1561,8 @@ export default {
1551
1561
  */
1552
1562
  if (event.eventType == 1) {
1553
1563
  if (this.viewingMode === 'Annotation') {
1564
+ this.tData.label = id;
1565
+ this.tData.region = regionPath;
1554
1566
  this.activateAnnotationMode(names, event);
1555
1567
  } else {
1556
1568
  if (this.$refs.scaffoldTreeControls) {
@@ -1566,7 +1578,7 @@ export default {
1566
1578
  //identifiers.
1567
1579
  if (event.identifiers.length === 1) {
1568
1580
  this.lastSelected.isSearch = false;
1569
- this.lastSelected.region = event.identifiers[0].data.region;
1581
+ this.lastSelected.region = regionPath;
1570
1582
  this.lastSelected.group = event.identifiers[0].data.group;
1571
1583
  } else if (event.identifiers.length === 0) {
1572
1584
  this.lastSelected.isSearch = false;
@@ -1590,21 +1602,13 @@ export default {
1590
1602
  }
1591
1603
  }
1592
1604
  if (event.identifiers.length > 0 && event.identifiers[0]) {
1593
- let id = event.identifiers[0].data.id
1594
- ? event.identifiers[0].data.id
1595
- : event.identifiers[0].data.group;
1596
1605
  if (event.identifiers[0].coords) {
1597
1606
  this.tData.active = false;
1598
- if (!this.annotationSidebar) {
1607
+ if (this.viewingMode !== "Annotation" || !this.annotationSidebar) {
1599
1608
  this.tData.visible = true;
1600
1609
  }
1601
1610
  this.tData.label = id;
1602
- if (event.identifiers[0].data.region) {
1603
- this.tData.region = event.identifiers[0].data.region;
1604
- }
1605
- else {
1606
- this.tData.region = undefined;
1607
- }
1611
+ this.tData.region = regionPath;
1608
1612
  this.tData.x = event.identifiers[0].coords.x;
1609
1613
  this.tData.y = event.identifiers[0].coords.y;
1610
1614
  this.createEditTemporaryLines(event.identifiers);
@@ -2205,6 +2209,11 @@ export default {
2205
2209
  }
2206
2210
  }
2207
2211
  },
2212
+ downloadErrorCallback: function() {
2213
+ return (error) => {
2214
+ this.$emit('on-error', error);
2215
+ }
2216
+ },
2208
2217
  setURLFinishCallback: function (options) {
2209
2218
  return () => {
2210
2219
  this.localAnnotationsList.length = 0;
@@ -2364,6 +2373,9 @@ export default {
2364
2373
  this.isReady = false;
2365
2374
  this.$_searchIndex.removeAll();
2366
2375
  this.hideRegionTooltip();
2376
+ this.$module.setDownloadErrorCallback(
2377
+ this.downloadErrorCallback()
2378
+ );
2367
2379
  this.$module.setFinishDownloadCallback(
2368
2380
  this.setURLFinishCallback({
2369
2381
  background: state?.background,
@@ -40,6 +40,7 @@ const OrgansSceneData = function() {
40
40
  const organPartAddedCallbacks = new Array();
41
41
  const organPartRemovedCallbacks = new Array();
42
42
  let finishDownloadCallback = undefined;
43
+ let downloadErrorCallback = undefined;
43
44
  const modelsLoader = ModelsLoaderIn;
44
45
  this.NDCCameraControl = undefined;
45
46
  _this.typeName = "Organ Viewer";
@@ -187,6 +188,16 @@ const OrgansSceneData = function() {
187
188
  finishDownloadCallback = undefined;
188
189
  }
189
190
 
191
+
192
+ this.setDownloadErrorCallback = function(callback) {
193
+ if (typeof(callback === "function"))
194
+ downloadErrorCallback = callback;
195
+ }
196
+
197
+ this.unsetDownloadErrorCallback = function() {
198
+ downloadErrorCallback = undefined;
199
+ }
200
+
190
201
  this.getNamedObjectsToScreenCoordinates = function(name, camera) {
191
202
  const vector = new THREE.Vector3();
192
203
  vector.setFromMatrixPosition( obj.matrixWorld );
@@ -435,11 +446,22 @@ const OrgansSceneData = function() {
435
446
  finishDownloadCallback();
436
447
  }
437
448
  }
438
-
439
- const singleItemDownloadCompletedCallback = function(systemName, partName, useDefautColour) {
440
- return function(geometry) {
441
- addOrganPart(systemName, partName, useDefautColour, geometry);
442
- _this.settingsChanged();
449
+
450
+ //The payload can either be a zinc object when the loading is successful or
451
+ //an object containg the details of error message on failure.
452
+ //We only use it to handle an error
453
+ const singleItemFinishCallback = function() {
454
+ return function(payload) {
455
+
456
+ if (payload?.type === "Error") {
457
+ if (downloadErrorCallback) {
458
+ const error = {
459
+ xhr: payload.xhr,
460
+ type: "download-error",
461
+ };
462
+ downloadErrorCallback(error);
463
+ }
464
+ }
443
465
  }
444
466
  }
445
467
 
@@ -549,7 +571,7 @@ const OrgansSceneData = function() {
549
571
  _this.sceneData.metaURL = url;
550
572
  organScene.addZincObjectAddedCallbacks(_addOrganPartCallback(systemName, partName, false));
551
573
  organScene.addZincObjectRemovedCallbacks(_removeOrganPartCallback(undefined, partName, false));
552
- organScene.loadMetadataURL(url, undefined, downloadCompletedCallback());
574
+ organScene.loadMetadataURL(url, singleItemFinishCallback(), downloadCompletedCallback());
553
575
  _this.scene = organScene;
554
576
  _this.zincRenderer.setCurrentScene(organScene);
555
577
  _this.graphicsHighlight.reset();
@@ -150,7 +150,6 @@ export class SearchIndex
150
150
  let results = undefined;
151
151
  if (text.length > 2 && ["'", '"'].includes(text.slice(0, 1))) {
152
152
  text = text.replaceAll(text.slice(0, 1), '')
153
- console.log(text)
154
153
  results = this._searchEngine.search(text, {prefix: true, combineWith: 'AND'})
155
154
  } else if (text.length > 1) {
156
155
  results = this._searchEngine.search(text, {prefix: true})
@@ -0,0 +1,36 @@
1
+ import { defineConfig } from 'vite'
2
+ import rootConfig from './vite.config.js'
3
+ import { nodePolyfills } from 'vite-plugin-node-polyfills'
4
+ import vue from '@vitejs/plugin-vue'
5
+
6
+ // defineWorkspace provides a nice type hinting DX
7
+ export default defineConfig((configEnv) => {
8
+ const config = rootConfig(configEnv);
9
+ config.css.extract = false
10
+ config.plugins.push(
11
+ nodePolyfills({
12
+ // To add only specific polyfills, add them here. If no option is passed, adds all polyfills
13
+ include: ['path']
14
+ })
15
+ );
16
+ // config.plugins.push(
17
+ // cssInjectedByJsPlugin()
18
+ // );
19
+ config.plugins[0] = vue({
20
+ template: {
21
+ compilerOptions: {
22
+ isCustomElement: (tag) => tag.includes('scaffoldvuer-wc')
23
+ }
24
+ }
25
+ }),
26
+ config.build = {
27
+ lib: {
28
+ entry: './src/ScaffoldVuer-wc.js',
29
+ name: 'scaffoldvuer-wc',
30
+ // the proper extensions will be added
31
+ fileName: 'scaffoldvuer-wc'
32
+ },
33
+ }
34
+
35
+ return config;
36
+ })