@avs/go 0.13.71891 → 0.14.71999
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/README.md +2 -2
- package/dist/avs-go.min.js +349 -2
- package/lib/avs-three.module.min.js +2 -2
- package/package.json +9 -10
- package/rollup.config.js +16 -0
- package/src/avs-element-base.js +119 -0
- package/src/avs-go-dataviz.js +540 -372
- package/src/avs-go-dynamic-html.js +108 -100
- package/src/avs-go-info.js +104 -76
- package/src/avs-go.js +23 -0
- package/src/constants.js +1 -1
- package/src/avs-data-source-mixin.js +0 -61
- package/src/avs-http-mixin.js +0 -197
- package/src/avs-stream-mixin.js +0 -65
- package/webpack.config.js +0 -29
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avs/go",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "AVS
|
|
3
|
+
"version": "0.14.71999",
|
|
4
|
+
"description": "AVS/Go",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"keywords": [
|
|
6
|
-
"
|
|
7
|
-
"polymer 3.0",
|
|
7
|
+
"lit",
|
|
8
8
|
"image",
|
|
9
9
|
"svg",
|
|
10
10
|
"three.js",
|
|
@@ -21,15 +21,14 @@
|
|
|
21
21
|
"directory": "packages/core"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build": "
|
|
25
|
-
"
|
|
26
|
-
"start": "http-server -o demo/jsonView.html",
|
|
24
|
+
"build": "rollup -c",
|
|
25
|
+
"start": "http-server -o demo/jsonView.html",
|
|
27
26
|
"type-check": "echo 'No TypeScript in core package'"
|
|
28
27
|
},
|
|
29
28
|
"license": "Apache-2.0",
|
|
30
29
|
"dependencies": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"three": "0.
|
|
30
|
+
"dompurify": "^3.4.2",
|
|
31
|
+
"lit": "^3.3.2",
|
|
32
|
+
"three": "0.184.0"
|
|
34
33
|
}
|
|
35
34
|
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import terser from '@rollup/plugin-terser';
|
|
2
|
+
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
input: [
|
|
6
|
+
'src/avs-go.js'
|
|
7
|
+
],
|
|
8
|
+
plugins: [
|
|
9
|
+
nodeResolve(),
|
|
10
|
+
terser()
|
|
11
|
+
],
|
|
12
|
+
output: {
|
|
13
|
+
file: 'dist/avs-go.min.js',
|
|
14
|
+
format: 'umd'
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2018 Advanced Visual Systems Inc.
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*
|
|
17
|
+
* This product includes software developed at
|
|
18
|
+
* Advanced Visual Systems Inc. (http://www.avs.com)
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { LitElement } from 'lit';
|
|
22
|
+
import { VERSION } from './constants.js';
|
|
23
|
+
|
|
24
|
+
export class AvsElementBase extends LitElement {
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Generate a HTTP request.
|
|
28
|
+
* @param url URL to an instance of AVS/Go server or file to get.
|
|
29
|
+
* @param model Model content to POST to the server (or undefined to generate a GET request).
|
|
30
|
+
*/
|
|
31
|
+
_httpRequest(url, onLoad, onError, model) {
|
|
32
|
+
if (!url) {
|
|
33
|
+
this._dispatchErrorEvent("'url' property must point to an instance of AVS/Go server.");
|
|
34
|
+
onError();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Assembly the request body
|
|
38
|
+
const verArray = VERSION.split('.');
|
|
39
|
+
const version = [parseInt(verArray[0]), parseInt(verArray[1]), parseInt(verArray[2])];
|
|
40
|
+
const body = {
|
|
41
|
+
source: this.localName,
|
|
42
|
+
model: model,
|
|
43
|
+
version: version
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Send the request
|
|
47
|
+
fetch(url, {
|
|
48
|
+
method: model ? 'POST' : 'GET',
|
|
49
|
+
headers: {
|
|
50
|
+
'Content-Type': 'application/json'
|
|
51
|
+
},
|
|
52
|
+
body: model ? JSON.stringify(body) : undefined
|
|
53
|
+
})
|
|
54
|
+
.then(response => response.json())
|
|
55
|
+
.then(response => {
|
|
56
|
+
if (response.error) {
|
|
57
|
+
this._processServerError(response.error);
|
|
58
|
+
if (onError) {
|
|
59
|
+
onError();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (onLoad) {
|
|
63
|
+
onLoad(response);
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
.catch(error => {
|
|
67
|
+
this._dispatchErrorEvent(error);
|
|
68
|
+
if (onError) {
|
|
69
|
+
onError();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param error
|
|
76
|
+
*/
|
|
77
|
+
_processServerError(error) {
|
|
78
|
+
if (!error) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const goException = JSON.parse(decodeURIComponent(error.replace(/\+/g, '%20')));
|
|
83
|
+
let output = "An error occurred on the AVS/Go server";
|
|
84
|
+
|
|
85
|
+
for (const key in goException) {
|
|
86
|
+
if (goException.hasOwnProperty(key)) {
|
|
87
|
+
if (output != "") {
|
|
88
|
+
output += "\n ";
|
|
89
|
+
}
|
|
90
|
+
output += key + ": ";
|
|
91
|
+
const child = goException[key];
|
|
92
|
+
if (child === Object(child)) {
|
|
93
|
+
output = output + JSON.stringify(child);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
output = output + goException[key];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
this._dispatchErrorEvent(output);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @param {any} error
|
|
107
|
+
*/
|
|
108
|
+
_dispatchErrorEvent(error) {
|
|
109
|
+
/**
|
|
110
|
+
* Error message from AVS/Go Web Component or Server.
|
|
111
|
+
* @event avs-error
|
|
112
|
+
*/
|
|
113
|
+
this.dispatchEvent(new CustomEvent('avs-error', {
|
|
114
|
+
bubbles: true,
|
|
115
|
+
composed: true,
|
|
116
|
+
detail: error
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
}
|