@operato/scene-restful 7.3.9 → 7.3.19
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 +2 -2
- package/CHANGELOG.md +0 -699
- package/demo/index.html +0 -116
- package/demo/things-scene-restful.html +0 -5
- package/demo/things-theme.html +0 -178
- package/src/index.ts +0 -5
- package/src/jsonp.ts +0 -85
- package/src/restful.ts +0 -453
- package/test/basic-test.html +0 -67
- package/test/index.html +0 -24
- package/test/unit/test-restful.js +0 -33
- package/test/unit/util.js +0 -22
- package/tsconfig.json +0 -24
- package/tsconfig.tsbuildinfo +0 -1
package/demo/index.html
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
@license
|
|
3
|
-
Copyright © HatioLab Inc. All rights reserved.
|
|
4
|
-
-->
|
|
5
|
-
<!doctype html>
|
|
6
|
-
<html>
|
|
7
|
-
<head>
|
|
8
|
-
<meta charset="utf-8">
|
|
9
|
-
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
|
10
|
-
<title>restful Demo</title>
|
|
11
|
-
<script src="../../webcomponentsjs/webcomponents-lite.min.js"></script>
|
|
12
|
-
|
|
13
|
-
<link rel="import" href="../../things-scene-viewer/things-scene-viewer.html">
|
|
14
|
-
<link rel="import" href="../../things-scene-viewer/things-scene-layer.html">
|
|
15
|
-
<link rel="import" href="../../things-scene-viewer/things-scene-handler.html">
|
|
16
|
-
|
|
17
|
-
<link rel="import" href="../../things-designer-elements/things-editor-properties.html">
|
|
18
|
-
|
|
19
|
-
<link rel="import" href="./things-scene-restful.html">
|
|
20
|
-
|
|
21
|
-
<link rel="import" href="./things-theme.html">
|
|
22
|
-
|
|
23
|
-
<style is="custom-style" include="things-theme">
|
|
24
|
-
things-scene-viewer {
|
|
25
|
-
display: block;
|
|
26
|
-
width: 640px;
|
|
27
|
-
height: 480px;
|
|
28
|
-
}
|
|
29
|
-
</style>
|
|
30
|
-
</head>
|
|
31
|
-
<body unresolved>
|
|
32
|
-
|
|
33
|
-
<template is="dom-bind" id="app">
|
|
34
|
-
<p>An example of <code><restful></code>:</p>
|
|
35
|
-
|
|
36
|
-
<things-scene-viewer id='scene'
|
|
37
|
-
scene='{{scene}}'
|
|
38
|
-
selected='{{selected}}'
|
|
39
|
-
model='[[model]]'
|
|
40
|
-
mode="0">
|
|
41
|
-
<things-scene-layer type="selection-layer"></things-scene-layer>
|
|
42
|
-
<things-scene-layer type="modeling-layer"></things-scene-layer>
|
|
43
|
-
<things-scene-handler type="text-editor"></things-scene-handler>
|
|
44
|
-
<things-scene-handler type="move-handler"></things-scene-handler>
|
|
45
|
-
</things-scene-viewer>
|
|
46
|
-
|
|
47
|
-
<p>Properties</p>
|
|
48
|
-
<things-editor-properties id='props' target="{{props}}" props="[[selected.0.nature.properties]]">
|
|
49
|
-
</things-editor-properties>
|
|
50
|
-
|
|
51
|
-
</template>
|
|
52
|
-
|
|
53
|
-
<script>
|
|
54
|
-
window.addEventListener('WebComponentsReady', function(e) {
|
|
55
|
-
var app = document.querySelector('#app')
|
|
56
|
-
|
|
57
|
-
app.props = {}
|
|
58
|
-
|
|
59
|
-
setTimeout(function() {
|
|
60
|
-
app.scene.on('selected', function(after) {
|
|
61
|
-
var target = after[0]
|
|
62
|
-
var props = {}
|
|
63
|
-
if(target) {
|
|
64
|
-
target.nature.properties.forEach(function(prop) {
|
|
65
|
-
var property = prop.property
|
|
66
|
-
props[property] = target.model[property]
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
app.props = props
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
app.$.props.addEventListener('change', function() {
|
|
74
|
-
app.selected[0].set(app.props)
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
app.model = {
|
|
78
|
-
width: 640,
|
|
79
|
-
height: 480,
|
|
80
|
-
components: [{
|
|
81
|
-
type: 'restful',
|
|
82
|
-
top: 100,
|
|
83
|
-
left: 100,
|
|
84
|
-
width:200,
|
|
85
|
-
height: 70,
|
|
86
|
-
fontSize: 40,
|
|
87
|
-
fillStyle: '#00ff00',
|
|
88
|
-
fontColor: '#FF0000',
|
|
89
|
-
strokeStyle: '#000',
|
|
90
|
-
lineWidth: 5,
|
|
91
|
-
value: 40,
|
|
92
|
-
text: '#{value}',
|
|
93
|
-
lineCap: 'round',
|
|
94
|
-
url: 'http://factory.hatiolab.com/rest/publishers/initData?subject=/elidom/stomp/topic/hatiolab-hq/smart/SCENE-22',
|
|
95
|
-
period: 60
|
|
96
|
-
}, {
|
|
97
|
-
type: 'rect',
|
|
98
|
-
id: 'ss3Text',
|
|
99
|
-
top: 100,
|
|
100
|
-
left: 100,
|
|
101
|
-
width:200,
|
|
102
|
-
height: 70,
|
|
103
|
-
fontSize: 40,
|
|
104
|
-
fillStyle: '#00ff00',
|
|
105
|
-
fontColor: '#FF0000',
|
|
106
|
-
strokeStyle: '#000',
|
|
107
|
-
lineWidth: 5,
|
|
108
|
-
value: 40,
|
|
109
|
-
text: '#{data}',
|
|
110
|
-
lineCap: 'round'
|
|
111
|
-
}]
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
</script>
|
|
115
|
-
</body>
|
|
116
|
-
</html>
|
package/demo/things-theme.html
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
@license
|
|
3
|
-
Copyright © HatioLab Inc. All rights reserved.
|
|
4
|
-
-->
|
|
5
|
-
<dom-module id="things-theme">
|
|
6
|
-
<template>
|
|
7
|
-
<style>
|
|
8
|
-
:root {
|
|
9
|
-
/* element reset style */
|
|
10
|
-
--paper-badge-background: rgba(0, 0, 0, 0.2);
|
|
11
|
-
--paper-badge-margin-left: -25px;
|
|
12
|
-
--paper-fab-background: var(--things-secondary-color);
|
|
13
|
-
--paper-fab-background: tomato;
|
|
14
|
-
--paper-input-container-focus-color: var(--things-secondary-color);
|
|
15
|
-
--paper-toolbar-background: transparent;
|
|
16
|
-
|
|
17
|
-
/* common style */
|
|
18
|
-
--border-radius-clear: {
|
|
19
|
-
-webkit-border-radius: 0px;
|
|
20
|
-
-moz-border-radius: 0px;
|
|
21
|
-
border-radius: 0px;
|
|
22
|
-
}
|
|
23
|
-
--things-default-padding: {
|
|
24
|
-
padding: 15px;
|
|
25
|
-
}
|
|
26
|
-
--things-tight-padding: {
|
|
27
|
-
padding: 7px;
|
|
28
|
-
}
|
|
29
|
-
--things-loose-padding: {
|
|
30
|
-
padding: 30px;
|
|
31
|
-
}
|
|
32
|
-
--things-table-padding: {
|
|
33
|
-
padding: 15px 15px 0 15px;
|
|
34
|
-
}
|
|
35
|
-
--things-padding-clear: {
|
|
36
|
-
padding: 0;
|
|
37
|
-
}
|
|
38
|
-
--things-default-margin: {
|
|
39
|
-
margin: 15px;
|
|
40
|
-
}
|
|
41
|
-
--things-margin-clear: {
|
|
42
|
-
margin: 0;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/* color style */
|
|
46
|
-
--things-primary-color: #826960;
|
|
47
|
-
--things-secondary-color: #aa866a;
|
|
48
|
-
--things-focus-background-color: #867f7c;
|
|
49
|
-
--things-primary-background-color: #826960;
|
|
50
|
-
--things-secondary-background-color: #aa866a;
|
|
51
|
-
--things-lightgrey-background-color: rgba(0, 0, 0, 0.15);
|
|
52
|
-
--things-white-color: #fff;
|
|
53
|
-
--things-error-color: var(--paper-deep-orange-700);
|
|
54
|
-
--things-primary-text-color: #726765;
|
|
55
|
-
--things-green-text-color: var(--paper-green-600);
|
|
56
|
-
--things-dark-text-color: #585858;
|
|
57
|
-
|
|
58
|
-
/* properties panel style */
|
|
59
|
-
--things-properties-panel: {
|
|
60
|
-
display: block;
|
|
61
|
-
width: 270px;
|
|
62
|
-
min-width: 270px;
|
|
63
|
-
background-color: var(--paper-blue-grey-50);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/* form style */
|
|
67
|
-
--things-label: {
|
|
68
|
-
position: relative;
|
|
69
|
-
top: -3px;
|
|
70
|
-
width: 25%;
|
|
71
|
-
min-height: 20px;
|
|
72
|
-
display: inline-block;
|
|
73
|
-
margin-bottom: 10px;
|
|
74
|
-
color: var(--things-primary-text-color);
|
|
75
|
-
font-size: 12px;
|
|
76
|
-
text-align: right;
|
|
77
|
-
font-weight: 100;
|
|
78
|
-
line-height: 1.6;
|
|
79
|
-
}
|
|
80
|
-
--things-input: {
|
|
81
|
-
width: 65%;
|
|
82
|
-
margin-bottom: 10px;
|
|
83
|
-
padding: 3px 5px 2px 5px;
|
|
84
|
-
-webkit-border-radius: 4px;
|
|
85
|
-
-moz-border-radius: 4px;
|
|
86
|
-
border-radius: 4px;
|
|
87
|
-
border: 1px solid rgba(0, 0, 0, 0.15);
|
|
88
|
-
font-size: 15px;
|
|
89
|
-
font-weight: 300;
|
|
90
|
-
}
|
|
91
|
-
--things-input-readonly-important: {
|
|
92
|
-
background-color: transparent;
|
|
93
|
-
padding: 0 0 0 3px;
|
|
94
|
-
position: relative;
|
|
95
|
-
top: -2px;
|
|
96
|
-
border-color: transparent;
|
|
97
|
-
font-weight: 600;
|
|
98
|
-
color: var(--things-primary-text-color);
|
|
99
|
-
}
|
|
100
|
-
--things-textarea-label-width: 12.25%;
|
|
101
|
-
--things-textarea-width: 94.5%;
|
|
102
|
-
--things-textarea: {
|
|
103
|
-
-webkit-border-radius: 4px;
|
|
104
|
-
-moz-border-radius: 4px;
|
|
105
|
-
border-radius: 4px;
|
|
106
|
-
border: 1px solid rgba(0, 0, 0, 0.2);
|
|
107
|
-
color: var(--things-primary-text-color);
|
|
108
|
-
font-size: 13px;
|
|
109
|
-
width: 100%;
|
|
110
|
-
height: 84%;
|
|
111
|
-
padding: 1%;
|
|
112
|
-
}
|
|
113
|
-
--things-fieldset: {
|
|
114
|
-
border: none;
|
|
115
|
-
margin: 0;
|
|
116
|
-
padding: 9px 0 0 0;
|
|
117
|
-
border-bottom: 1px solid #cfd8dc;
|
|
118
|
-
color: var(--things-primary-text-color);
|
|
119
|
-
font-size: 12px;
|
|
120
|
-
}
|
|
121
|
-
--things-fieldset-legend: {
|
|
122
|
-
padding: 9px 0 0 7px;
|
|
123
|
-
font-size: 11px;
|
|
124
|
-
color: #e46c2e;
|
|
125
|
-
font-weight: bold;
|
|
126
|
-
text-transform: capitalize;
|
|
127
|
-
}
|
|
128
|
-
--things-select: {
|
|
129
|
-
max-width: 69%;
|
|
130
|
-
min-width: 50%;
|
|
131
|
-
margin-bottom: 10px;
|
|
132
|
-
padding: 3px 20px 2px 5px;
|
|
133
|
-
-webkit-border-radius: 4px;
|
|
134
|
-
-moz-border-radius: 4px;
|
|
135
|
-
border-radius: 4px;
|
|
136
|
-
border: 1px solid rgba(0, 0, 0, 0.15);
|
|
137
|
-
font-size: 15px;
|
|
138
|
-
font-weight: 300;
|
|
139
|
-
-webkit-appearance: none;
|
|
140
|
-
}
|
|
141
|
-
--things-input-color: {
|
|
142
|
-
position: relative;
|
|
143
|
-
margin-left: -30px;
|
|
144
|
-
width: 25px;
|
|
145
|
-
height: 21px;
|
|
146
|
-
border: none;
|
|
147
|
-
padding: 0;
|
|
148
|
-
}
|
|
149
|
-
--things-properties-icon-only-label: {
|
|
150
|
-
width: 30px;
|
|
151
|
-
height: 24px;
|
|
152
|
-
margin-top: 2px;
|
|
153
|
-
margin-bottom: 5px;
|
|
154
|
-
}
|
|
155
|
-
--things-editor-colorbar: {
|
|
156
|
-
border: 1px solid #ccc;
|
|
157
|
-
}
|
|
158
|
-
--things-editor-color-input-text: {
|
|
159
|
-
@apply (--things-input);
|
|
160
|
-
}
|
|
161
|
-
--things-editor-color-input-color: {
|
|
162
|
-
border: none;
|
|
163
|
-
background-color: transparent;
|
|
164
|
-
margin-left: -27px;
|
|
165
|
-
position: relative;
|
|
166
|
-
width: 20px;
|
|
167
|
-
}
|
|
168
|
-
--things-dropdown-item: {
|
|
169
|
-
min-height: 30px;
|
|
170
|
-
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
|
171
|
-
padding: 0 10px;
|
|
172
|
-
font-size: 13px;
|
|
173
|
-
color: var(--things-primary-text-color);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
</style>
|
|
177
|
-
</template>
|
|
178
|
-
</dom-module>
|
package/src/index.ts
DELETED
package/src/jsonp.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { debug } from '@hatiolab/things-scene'
|
|
2
|
-
|
|
3
|
-
var count = 0
|
|
4
|
-
|
|
5
|
-
function noop() {}
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* JSONP handler
|
|
9
|
-
*
|
|
10
|
-
* Options:
|
|
11
|
-
* - param {String} qs parameter (`callback`)
|
|
12
|
-
* - prefix {String} qs parameter (`__jp`)
|
|
13
|
-
* - name {String} qs parameter (`prefix` + incr)
|
|
14
|
-
* - timeout {Number} how long after a timeout error is emitted (`60000`)
|
|
15
|
-
*
|
|
16
|
-
* @param {String} url
|
|
17
|
-
* @param {Object|Function} optional options / callback
|
|
18
|
-
* @param {Function} optional callback
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
export default function jsonp(
|
|
22
|
-
url: string,
|
|
23
|
-
opts: { prefix?: string; name?: string; param?: string; timeout?: number },
|
|
24
|
-
fn: (self: any, data?: any) => void
|
|
25
|
-
) {
|
|
26
|
-
if ('function' == typeof opts) {
|
|
27
|
-
fn = opts
|
|
28
|
-
opts = {}
|
|
29
|
-
}
|
|
30
|
-
if (!opts) opts = {}
|
|
31
|
-
|
|
32
|
-
var prefix = opts.prefix || '__jp'
|
|
33
|
-
|
|
34
|
-
// use the callback name that was passed if one was provided.
|
|
35
|
-
// otherwise generate a unique name by incrementing our counter.
|
|
36
|
-
var id = opts.name || prefix + count++
|
|
37
|
-
|
|
38
|
-
var param = opts.param || 'callback'
|
|
39
|
-
var timeout = null != opts.timeout ? opts.timeout : 60000
|
|
40
|
-
var enc = encodeURIComponent
|
|
41
|
-
var target = document.getElementsByTagName('script')[0] || document.head
|
|
42
|
-
var script: HTMLScriptElement
|
|
43
|
-
var timer: number
|
|
44
|
-
|
|
45
|
-
if (timeout) {
|
|
46
|
-
timer = setTimeout(function () {
|
|
47
|
-
cleanup()
|
|
48
|
-
if (fn) fn(new Error('Timeout'))
|
|
49
|
-
}, timeout)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function cleanup() {
|
|
53
|
-
if (script.parentNode) script.parentNode.removeChild(script)
|
|
54
|
-
//@ts-ignore
|
|
55
|
-
window[id] = noop
|
|
56
|
-
if (timer) clearTimeout(timer)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function cancel() {
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
if (window[id]) {
|
|
62
|
-
cleanup()
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
//@ts-ignore
|
|
67
|
-
window[id] = function (data) {
|
|
68
|
-
debug('jsonp got', data)
|
|
69
|
-
cleanup()
|
|
70
|
-
if (fn) fn(null, data)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// add qs component
|
|
74
|
-
url += (~url.indexOf('?') ? '&' : '?') + param + '=' + enc(id)
|
|
75
|
-
url = url.replace('?&', '?')
|
|
76
|
-
|
|
77
|
-
debug('jsonp req "%s"', url)
|
|
78
|
-
|
|
79
|
-
// create script
|
|
80
|
-
script = document.createElement('script')
|
|
81
|
-
script.src = url
|
|
82
|
-
target.parentNode?.insertBefore(script, target)
|
|
83
|
-
|
|
84
|
-
return cancel
|
|
85
|
-
}
|