@sjcrh/proteinpaint-front 2.63.0 → 2.63.2

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/bundles.tgz CHANGED
Binary file
package/package.json CHANGED
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "name": "@sjcrh/proteinpaint-front",
3
- "version": "2.63.0",
3
+ "version": "2.63.2",
4
+ "browser": "src/app.js",
4
5
  "main": "src/index.js",
5
6
  "bin": "init.js",
6
7
  "scripts": {
7
8
  "dev": "webpack --env NODE_ENV=development --watch --progress --color",
9
+ "//TODO": "# delete webpack use, once esbuild migration is fully tested and unlikely to be reverted",
8
10
  "prepack": "rm -rf public/bin && rm -rf *.tgz && webpack && tar -czf bundles.tgz public/bin",
9
- "test:unit": "echo 'TODO: front integration tests'",
11
+ "test:unit": "echo 'TODO: front unit tests'",
10
12
  "test:integration": "echo 'TODO: front integration tests'"
11
13
  },
12
14
  "devDependencies": {
13
- "@sjcrh/proteinpaint-client": "2.63.0",
15
+ "@sjcrh/proteinpaint-client": "2.63.2",
14
16
  "webpack": "^5.76.0",
15
17
  "webpack-cli": "^4.9.2",
16
18
  "webpack-node-externals": "^3.0.0",
package/src/app.js ADDED
@@ -0,0 +1,34 @@
1
+ // KEEP THIS ppsrc DECLARATION AT THE TOP SCOPE !!!
2
+ // need to know the script src when pp is first loaded
3
+ // the source context may be lost after the pp script is loaded
4
+ // and a different script gets loaded in the page
5
+ const ppsrc = (document && document.currentScript && document.currentScript.src) || ''
6
+ const hostpath = ppsrc.replace('/proteinpaint.js', '')
7
+
8
+ // NOTE: stylesheets are currently handled by a custom esbuild plugin
9
+ // load the bundled css
10
+ // let link = document.createElement('link')
11
+ // link.rel = 'stylesheet'
12
+ // // NOTE: hostpath is required when PP is used by an external embedder/portal/html
13
+ // link.href = `${hostpath}/dist/app.css`
14
+ // document.head.appendChild(link)
15
+
16
+ window.runproteinpaint = async arg => {
17
+ // requires the following symlink to be present:
18
+ // public/bin -> proteinpaint-client/dist symlink
19
+ //
20
+ // NOTE: hostpath is required when PP is used by an external embedder/portal/html
21
+ //
22
+ const { runproteinpaint } = await import(`${hostpath}/dist/app.js`)
23
+ if (arg) {
24
+ // assume that this script is loaded from a full image service,
25
+ // where the expected server base path is the parent path of /bin
26
+ if (!arg.host) arg.host = hostpath.replace('/bin', '')
27
+ return await runproteinpaint(arg)
28
+ }
29
+ window.runproteinpaint = runproteinpaint
30
+ }
31
+
32
+ // allow runpp script src code to load, even before being called,
33
+ // so it's ready sooner when called
34
+ window.runproteinpaint()