@panoramax/web-viewer 3.0.2-develop-a8ea8e60
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/.dockerignore +6 -0
- package/.gitlab-ci.yml +71 -0
- package/CHANGELOG.md +428 -0
- package/CODE_OF_CONDUCT.md +134 -0
- package/Dockerfile +14 -0
- package/LICENSE +21 -0
- package/README.md +39 -0
- package/build/editor.html +1 -0
- package/build/index.css +36 -0
- package/build/index.css.map +1 -0
- package/build/index.html +1 -0
- package/build/index.js +25 -0
- package/build/index.js.map +1 -0
- package/build/map.html +1 -0
- package/build/viewer.html +1 -0
- package/config/env.js +104 -0
- package/config/getHttpsConfig.js +66 -0
- package/config/getPackageJson.js +25 -0
- package/config/jest/babelTransform.js +29 -0
- package/config/jest/cssTransform.js +14 -0
- package/config/jest/fileTransform.js +40 -0
- package/config/modules.js +134 -0
- package/config/paths.js +72 -0
- package/config/pnpTs.js +35 -0
- package/config/webpack/persistentCache/createEnvironmentHash.js +9 -0
- package/config/webpack.config.js +885 -0
- package/config/webpackDevServer.config.js +127 -0
- package/docs/01_Start.md +149 -0
- package/docs/02_Usage.md +828 -0
- package/docs/03_URL_settings.md +140 -0
- package/docs/04_Advanced_examples.md +214 -0
- package/docs/05_Compatibility.md +85 -0
- package/docs/09_Develop.md +62 -0
- package/docs/90_Releases.md +27 -0
- package/docs/images/class_diagram.drawio +129 -0
- package/docs/images/class_diagram.jpg +0 -0
- package/docs/images/screenshot.jpg +0 -0
- package/mkdocs.yml +45 -0
- package/package.json +254 -0
- package/public/editor.html +54 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +59 -0
- package/public/map.html +53 -0
- package/public/viewer.html +67 -0
- package/scripts/build.js +217 -0
- package/scripts/start.js +176 -0
- package/scripts/test.js +52 -0
- package/src/Editor.css +37 -0
- package/src/Editor.js +359 -0
- package/src/StandaloneMap.js +114 -0
- package/src/Viewer.css +203 -0
- package/src/Viewer.js +1186 -0
- package/src/components/CoreView.css +64 -0
- package/src/components/CoreView.js +159 -0
- package/src/components/Loader.css +56 -0
- package/src/components/Loader.js +111 -0
- package/src/components/Map.css +65 -0
- package/src/components/Map.js +841 -0
- package/src/components/Photo.css +36 -0
- package/src/components/Photo.js +687 -0
- package/src/img/arrow_360.svg +14 -0
- package/src/img/arrow_flat.svg +11 -0
- package/src/img/arrow_triangle.svg +10 -0
- package/src/img/arrow_turn.svg +9 -0
- package/src/img/bg_aerial.jpg +0 -0
- package/src/img/bg_streets.jpg +0 -0
- package/src/img/loader_base.jpg +0 -0
- package/src/img/loader_hd.jpg +0 -0
- package/src/img/logo_dead.svg +91 -0
- package/src/img/marker.svg +17 -0
- package/src/img/marker_blue.svg +20 -0
- package/src/img/switch_big.svg +44 -0
- package/src/img/switch_mini.svg +48 -0
- package/src/index.js +10 -0
- package/src/translations/de.json +163 -0
- package/src/translations/en.json +164 -0
- package/src/translations/eo.json +6 -0
- package/src/translations/es.json +164 -0
- package/src/translations/fi.json +1 -0
- package/src/translations/fr.json +164 -0
- package/src/translations/hu.json +133 -0
- package/src/translations/nl.json +1 -0
- package/src/translations/zh_Hant.json +136 -0
- package/src/utils/API.js +709 -0
- package/src/utils/Exif.js +198 -0
- package/src/utils/I18n.js +75 -0
- package/src/utils/Map.js +382 -0
- package/src/utils/PhotoAdapter.js +45 -0
- package/src/utils/Utils.js +568 -0
- package/src/utils/Widgets.js +477 -0
- package/src/viewer/URLHash.js +334 -0
- package/src/viewer/Widgets.css +711 -0
- package/src/viewer/Widgets.js +1196 -0
- package/tests/Editor.test.js +125 -0
- package/tests/StandaloneMap.test.js +44 -0
- package/tests/Viewer.test.js +363 -0
- package/tests/__snapshots__/Editor.test.js.snap +300 -0
- package/tests/__snapshots__/StandaloneMap.test.js.snap +30 -0
- package/tests/__snapshots__/Viewer.test.js.snap +195 -0
- package/tests/components/CoreView.test.js +91 -0
- package/tests/components/Loader.test.js +38 -0
- package/tests/components/Map.test.js +230 -0
- package/tests/components/Photo.test.js +335 -0
- package/tests/components/__snapshots__/Loader.test.js.snap +15 -0
- package/tests/components/__snapshots__/Map.test.js.snap +767 -0
- package/tests/components/__snapshots__/Photo.test.js.snap +205 -0
- package/tests/data/Map_geocoder_ban.json +36 -0
- package/tests/data/Map_geocoder_nominatim.json +56 -0
- package/tests/data/Viewer_pictures_1.json +148 -0
- package/tests/setupTests.js +5 -0
- package/tests/utils/API.test.js +906 -0
- package/tests/utils/Exif.test.js +124 -0
- package/tests/utils/I18n.test.js +28 -0
- package/tests/utils/Map.test.js +105 -0
- package/tests/utils/Utils.test.js +300 -0
- package/tests/utils/Widgets.test.js +107 -0
- package/tests/utils/__snapshots__/API.test.js.snap +132 -0
- package/tests/utils/__snapshots__/Exif.test.js.snap +43 -0
- package/tests/utils/__snapshots__/Map.test.js.snap +48 -0
- package/tests/utils/__snapshots__/Utils.test.js.snap +41 -0
- package/tests/utils/__snapshots__/Widgets.test.js.snap +44 -0
- package/tests/viewer/URLHash.test.js +537 -0
- package/tests/viewer/Widgets.test.js +127 -0
- package/tests/viewer/__snapshots__/URLHash.test.js.snap +98 -0
- package/tests/viewer/__snapshots__/Widgets.test.js.snap +393 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
|
|
5
|
+
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
|
|
6
|
+
const ignoredFiles = require('react-dev-utils/ignoredFiles');
|
|
7
|
+
const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');
|
|
8
|
+
const paths = require('./paths');
|
|
9
|
+
const getHttpsConfig = require('./getHttpsConfig');
|
|
10
|
+
|
|
11
|
+
const host = process.env.HOST || '0.0.0.0';
|
|
12
|
+
const sockHost = process.env.WDS_SOCKET_HOST;
|
|
13
|
+
const sockPath = process.env.WDS_SOCKET_PATH; // default: '/ws'
|
|
14
|
+
const sockPort = process.env.WDS_SOCKET_PORT;
|
|
15
|
+
|
|
16
|
+
module.exports = function (proxy, allowedHost) {
|
|
17
|
+
const disableFirewall =
|
|
18
|
+
!proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true';
|
|
19
|
+
return {
|
|
20
|
+
// WebpackDevServer 2.4.3 introduced a security fix that prevents remote
|
|
21
|
+
// websites from potentially accessing local content through DNS rebinding:
|
|
22
|
+
// https://github.com/webpack/webpack-dev-server/issues/887
|
|
23
|
+
// https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
|
|
24
|
+
// However, it made several existing use cases such as development in cloud
|
|
25
|
+
// environment or subdomains in development significantly more complicated:
|
|
26
|
+
// https://github.com/facebook/create-react-app/issues/2271
|
|
27
|
+
// https://github.com/facebook/create-react-app/issues/2233
|
|
28
|
+
// While we're investigating better solutions, for now we will take a
|
|
29
|
+
// compromise. Since our WDS configuration only serves files in the `public`
|
|
30
|
+
// folder we won't consider accessing them a vulnerability. However, if you
|
|
31
|
+
// use the `proxy` feature, it gets more dangerous because it can expose
|
|
32
|
+
// remote code execution vulnerabilities in backends like Django and Rails.
|
|
33
|
+
// So we will disable the host check normally, but enable it if you have
|
|
34
|
+
// specified the `proxy` setting. Finally, we let you override it if you
|
|
35
|
+
// really know what you're doing with a special environment variable.
|
|
36
|
+
// Note: ["localhost", ".localhost"] will support subdomains - but we might
|
|
37
|
+
// want to allow setting the allowedHosts manually for more complex setups
|
|
38
|
+
allowedHosts: disableFirewall ? 'all' : [allowedHost],
|
|
39
|
+
headers: {
|
|
40
|
+
'Access-Control-Allow-Origin': '*',
|
|
41
|
+
'Access-Control-Allow-Methods': '*',
|
|
42
|
+
'Access-Control-Allow-Headers': '*',
|
|
43
|
+
},
|
|
44
|
+
// Enable gzip compression of generated files.
|
|
45
|
+
compress: true,
|
|
46
|
+
static: {
|
|
47
|
+
// By default WebpackDevServer serves physical files from current directory
|
|
48
|
+
// in addition to all the virtual build products that it serves from memory.
|
|
49
|
+
// This is confusing because those files won’t automatically be available in
|
|
50
|
+
// production build folder unless we copy them. However, copying the whole
|
|
51
|
+
// project directory is dangerous because we may expose sensitive files.
|
|
52
|
+
// Instead, we establish a convention that only files in `public` directory
|
|
53
|
+
// get served. Our build script will copy `public` into the `build` folder.
|
|
54
|
+
// In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
|
|
55
|
+
// <link rel="icon" href="%PUBLIC_URL%/favicon.ico">
|
|
56
|
+
// In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
|
|
57
|
+
// Note that we only recommend to use `public` folder as an escape hatch
|
|
58
|
+
// for files like `favicon.ico`, `manifest.json`, and libraries that are
|
|
59
|
+
// for some reason broken when imported through webpack. If you just want to
|
|
60
|
+
// use an image, put it in `src` and `import` it from JavaScript instead.
|
|
61
|
+
directory: paths.appPublic,
|
|
62
|
+
publicPath: [paths.publicUrlOrPath],
|
|
63
|
+
// By default files from `contentBase` will not trigger a page reload.
|
|
64
|
+
watch: {
|
|
65
|
+
// Reportedly, this avoids CPU overload on some systems.
|
|
66
|
+
// https://github.com/facebook/create-react-app/issues/293
|
|
67
|
+
// src/node_modules is not ignored to support absolute imports
|
|
68
|
+
// https://github.com/facebook/create-react-app/issues/1065
|
|
69
|
+
ignored: ignoredFiles(paths.appSrc),
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
client: {
|
|
73
|
+
webSocketURL: {
|
|
74
|
+
// Enable custom sockjs pathname for websocket connection to hot reloading server.
|
|
75
|
+
// Enable custom sockjs hostname, pathname and port for websocket connection
|
|
76
|
+
// to hot reloading server.
|
|
77
|
+
hostname: sockHost,
|
|
78
|
+
pathname: sockPath,
|
|
79
|
+
port: sockPort,
|
|
80
|
+
},
|
|
81
|
+
overlay: {
|
|
82
|
+
errors: true,
|
|
83
|
+
warnings: false,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
devMiddleware: {
|
|
87
|
+
// It is important to tell WebpackDevServer to use the same "publicPath" path as
|
|
88
|
+
// we specified in the webpack config. When homepage is '.', default to serving
|
|
89
|
+
// from the root.
|
|
90
|
+
// remove last slash so user can land on `/test` instead of `/test/`
|
|
91
|
+
publicPath: paths.publicUrlOrPath.slice(0, -1),
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
https: getHttpsConfig(),
|
|
95
|
+
host,
|
|
96
|
+
historyApiFallback: {
|
|
97
|
+
// Paths with dots should still use the history fallback.
|
|
98
|
+
// See https://github.com/facebook/create-react-app/issues/387.
|
|
99
|
+
disableDotRule: true,
|
|
100
|
+
index: paths.publicUrlOrPath,
|
|
101
|
+
},
|
|
102
|
+
// `proxy` is run between `before` and `after` `webpack-dev-server` hooks
|
|
103
|
+
proxy,
|
|
104
|
+
onBeforeSetupMiddleware(devServer) {
|
|
105
|
+
// Keep `evalSourceMapMiddleware`
|
|
106
|
+
// middlewares before `redirectServedPath` otherwise will not have any effect
|
|
107
|
+
// This lets us fetch source contents from webpack for the error overlay
|
|
108
|
+
devServer.app.use(evalSourceMapMiddleware(devServer));
|
|
109
|
+
|
|
110
|
+
if (fs.existsSync(paths.proxySetup)) {
|
|
111
|
+
// This registers user provided middleware for proxy reasons
|
|
112
|
+
require(paths.proxySetup)(devServer.app);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
onAfterSetupMiddleware(devServer) {
|
|
116
|
+
// Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
|
|
117
|
+
devServer.app.use(redirectServedPath(paths.publicUrlOrPath));
|
|
118
|
+
|
|
119
|
+
// This service worker file is effectively a 'no-op' that will reset any
|
|
120
|
+
// previous service worker registered for the same host:port combination.
|
|
121
|
+
// We do this in development to avoid hitting the production cache if
|
|
122
|
+
// it used the same host and port.
|
|
123
|
+
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
|
|
124
|
+
devServer.app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
};
|
package/docs/01_Start.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Web viewer documentation
|
|
2
|
+
|
|
3
|
+
Welcome to Panoramax __Web Viewer__ documentation ! It will help you through all phases of setup, run and develop on Panoramax JS pictures viewer.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
!!! note
|
|
8
|
+
|
|
9
|
+
If at some point you're lost or need help, you can contact us through [issues](https://gitlab.com/panoramax/clients/web-viewer/-/issues) or by [email](mailto:panieravide@riseup.net).
|
|
10
|
+
|
|
11
|
+
## Install the viewer
|
|
12
|
+
|
|
13
|
+
Many options are available for installing the viewer.
|
|
14
|
+
|
|
15
|
+
=== ":simple-npm: NPM"
|
|
16
|
+
|
|
17
|
+
Panoramax viewer is available on NPM as [@panoramax/web-viewer](https://www.npmjs.com/package/@panoramax/web-viewer) package.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @panoramax/web-viewer
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
If you want the latest version (corresponding to the `develop` git branch), you can use the `develop` NPM dist-tag:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @panoramax/web-viewer@develop
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
=== ":material-web: Hosted"
|
|
30
|
+
|
|
31
|
+
You can rely on various providers offering hosted NPM packages, for example JSDelivr.
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<!-- You may use another version than 3.0.2, just change the release in URL -->
|
|
35
|
+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/@panoramax/web-viewer@3.0.2/build/index.css" />
|
|
36
|
+
<script src="https://cdn.jsdelivr.net/npm/@panoramax/web-viewer@3.0.2/build/index.js"></script>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
=== ":material-code-tags: Source code"
|
|
40
|
+
|
|
41
|
+
You can install and use Panoramax web client based on code provided in this repository.
|
|
42
|
+
|
|
43
|
+
This library relies on __Node.js 16__, which should be installed on your computer. Then, you can build the library using these commands:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
git clone https://gitlab.com/panoramax/clients/web-viewer.git
|
|
47
|
+
cd web-viewer/
|
|
48
|
+
npm install
|
|
49
|
+
npm build
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Basic usage
|
|
54
|
+
|
|
55
|
+
First, you need to make sure everything is ready to create the viewer:
|
|
56
|
+
|
|
57
|
+
=== ":fontawesome-brands-js: Old-school JS"
|
|
58
|
+
|
|
59
|
+
Make sure to have both JS and CSS code available in your HTML `head` part:
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<!-- Change the actual path depending of where you installed the library -->
|
|
63
|
+
<link rel="stylesheet" type="text/css" href="web-viewer/build/index.css" />
|
|
64
|
+
<script src="web-viewer/build/index.js"></script>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
And you also node a `div` somewhere in your HTML:
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<div id="viewer" style="width: 500px; height: 300px"></div>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Then, the div is populated with this JavaScript code:
|
|
74
|
+
|
|
75
|
+
```js
|
|
76
|
+
let myViewer = new Panoramax.Viewer(
|
|
77
|
+
"viewer", // Div ID
|
|
78
|
+
"https://api.panoramax.xyz/api", // STAC API endpoint
|
|
79
|
+
{ map: true } // Viewer options
|
|
80
|
+
);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
=== ":fontawesome-brands-node-js: New-style JS"
|
|
84
|
+
|
|
85
|
+
Make sure to import both JS and CSS in your code:
|
|
86
|
+
|
|
87
|
+
```js
|
|
88
|
+
import Panoramax from '@panoramax/web-viewer';
|
|
89
|
+
import '@panoramax/web-viewer/build/index.css';
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
And have access in some way to a classic `div` HTML element:
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
const myDiv = document.getElementById("viewer");
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Then, the div is populated with this JavaScript code:
|
|
99
|
+
|
|
100
|
+
```js
|
|
101
|
+
let myViewer = new Panoramax.Viewer(
|
|
102
|
+
myDiv, // Div Element
|
|
103
|
+
"https://api.panoramax.xyz/api", // STAC API endpoint
|
|
104
|
+
{ map: true } // Viewer options
|
|
105
|
+
);
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
Beyond classic viewer, other widgets are available and [can be tested online](https://viewer.geovisio.fr/):
|
|
110
|
+
|
|
111
|
+
__Standalone-map__
|
|
112
|
+
|
|
113
|
+
A simple map for showing coverage only.
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
var myMap = new Panoramax.StandaloneMap(
|
|
117
|
+
"map", // Div ID
|
|
118
|
+
"https://api.panoramax.xyz/api" // STAC API endpoint
|
|
119
|
+
);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
__Editor__
|
|
123
|
+
|
|
124
|
+
A map and photo viewer, focused on a single sequence, for previewing edits made to it.
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
var myEditor = new Panoramax.Editor(
|
|
128
|
+
"editor", // Div ID
|
|
129
|
+
"https://api.panoramax.xyz/api", // STAC API endpoint
|
|
130
|
+
{
|
|
131
|
+
selectedSequence: "id-to-an-existing-sequence", // Sequence ID (mandatory)
|
|
132
|
+
selectedPicture: "id-to-a-picture-in-this-sequence" // Picture ID (optional)
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## User interface
|
|
138
|
+
|
|
139
|
+
### Keyboard shortcuts
|
|
140
|
+
|
|
141
|
+
All interactions with the viewer can be done using the mouse, and some can be also done using keyboard.
|
|
142
|
+
|
|
143
|
+
* __Arrows__ (or 2/4/8/6 on keypad): move inside the picture, or move the map
|
|
144
|
+
* __Page up/down__ (or 3/9 on keypad) : go to next or previous picture in sequence
|
|
145
|
+
* __+ / -__ : zoom picture or map in or out
|
|
146
|
+
* __*__ (or 5 on keypad) : move picture or map to its center
|
|
147
|
+
* __Home / ↖️__ (or 7 on keypad) : switch map and picture as main shown component
|
|
148
|
+
* __End__ (or 1 on keypad) : hide minimized map or picture
|
|
149
|
+
* __Space__ : play or pause current sequence
|