pubo-web 1.0.4-alpha.0

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.
Files changed (50) hide show
  1. package/dist/pubo-web.js +13 -0
  2. package/es/file/download.d.ts +1 -0
  3. package/es/file/download.js +14 -0
  4. package/es/file/parser.d.ts +3 -0
  5. package/es/file/parser.js +35 -0
  6. package/es/index.d.ts +7 -0
  7. package/es/index.js +7 -0
  8. package/es/load-script/index.d.ts +1 -0
  9. package/es/load-script/index.js +88 -0
  10. package/es/ros/factory/configure.d.ts +14 -0
  11. package/es/ros/factory/configure.js +230 -0
  12. package/es/ros/factory/index.d.ts +32 -0
  13. package/es/ros/factory/index.js +116 -0
  14. package/es/ros/factory/super.d.ts +11 -0
  15. package/es/ros/factory/super.js +43 -0
  16. package/es/ros/index.d.ts +7 -0
  17. package/es/ros/index.js +10 -0
  18. package/es/ros/ros3d/inject.d.ts +6 -0
  19. package/es/ros/ros3d/inject.js +39 -0
  20. package/es/ros/ros3d/utils.d.ts +11 -0
  21. package/es/ros/ros3d/utils.js +249 -0
  22. package/es/ros/ros3d/viewer.d.ts +19 -0
  23. package/es/ros/ros3d/viewer.js +244 -0
  24. package/es/storage/index.d.ts +16 -0
  25. package/es/storage/index.js +65 -0
  26. package/lib/file/download.d.ts +1 -0
  27. package/lib/file/download.js +21 -0
  28. package/lib/file/parser.d.ts +3 -0
  29. package/lib/file/parser.js +44 -0
  30. package/lib/index.d.ts +7 -0
  31. package/lib/index.js +72 -0
  32. package/lib/load-script/index.d.ts +1 -0
  33. package/lib/load-script/index.js +95 -0
  34. package/lib/ros/factory/configure.d.ts +14 -0
  35. package/lib/ros/factory/configure.js +243 -0
  36. package/lib/ros/factory/index.d.ts +32 -0
  37. package/lib/ros/factory/index.js +130 -0
  38. package/lib/ros/factory/super.d.ts +11 -0
  39. package/lib/ros/factory/super.js +50 -0
  40. package/lib/ros/index.d.ts +7 -0
  41. package/lib/ros/index.js +19 -0
  42. package/lib/ros/ros3d/inject.d.ts +6 -0
  43. package/lib/ros/ros3d/inject.js +46 -0
  44. package/lib/ros/ros3d/utils.d.ts +11 -0
  45. package/lib/ros/ros3d/utils.js +272 -0
  46. package/lib/ros/ros3d/viewer.d.ts +19 -0
  47. package/lib/ros/ros3d/viewer.js +259 -0
  48. package/lib/storage/index.d.ts +16 -0
  49. package/lib/storage/index.js +72 -0
  50. package/package.json +26 -0
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+
8
+ for (var p in s) {
9
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
+ }
11
+ }
12
+
13
+ return t;
14
+ };
15
+
16
+ return __assign.apply(this, arguments);
17
+ };
18
+
19
+ var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
20
+ function adopt(value) {
21
+ return value instanceof P ? value : new P(function (resolve) {
22
+ resolve(value);
23
+ });
24
+ }
25
+
26
+ return new (P || (P = Promise))(function (resolve, reject) {
27
+ function fulfilled(value) {
28
+ try {
29
+ step(generator.next(value));
30
+ } catch (e) {
31
+ reject(e);
32
+ }
33
+ }
34
+
35
+ function rejected(value) {
36
+ try {
37
+ step(generator["throw"](value));
38
+ } catch (e) {
39
+ reject(e);
40
+ }
41
+ }
42
+
43
+ function step(result) {
44
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
45
+ }
46
+
47
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
48
+ });
49
+ };
50
+
51
+ var __generator = this && this.__generator || function (thisArg, body) {
52
+ var _ = {
53
+ label: 0,
54
+ sent: function sent() {
55
+ if (t[0] & 1) throw t[1];
56
+ return t[1];
57
+ },
58
+ trys: [],
59
+ ops: []
60
+ },
61
+ f,
62
+ y,
63
+ t,
64
+ g;
65
+ return g = {
66
+ next: verb(0),
67
+ "throw": verb(1),
68
+ "return": verb(2)
69
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
70
+ return this;
71
+ }), g;
72
+
73
+ function verb(n) {
74
+ return function (v) {
75
+ return step([n, v]);
76
+ };
77
+ }
78
+
79
+ function step(op) {
80
+ if (f) throw new TypeError("Generator is already executing.");
81
+
82
+ while (_) {
83
+ try {
84
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
85
+ if (y = 0, t) op = [op[0] & 2, t.value];
86
+
87
+ switch (op[0]) {
88
+ case 0:
89
+ case 1:
90
+ t = op;
91
+ break;
92
+
93
+ case 4:
94
+ _.label++;
95
+ return {
96
+ value: op[1],
97
+ done: false
98
+ };
99
+
100
+ case 5:
101
+ _.label++;
102
+ y = op[1];
103
+ op = [0];
104
+ continue;
105
+
106
+ case 7:
107
+ op = _.ops.pop();
108
+
109
+ _.trys.pop();
110
+
111
+ continue;
112
+
113
+ default:
114
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
115
+ _ = 0;
116
+ continue;
117
+ }
118
+
119
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
120
+ _.label = op[1];
121
+ break;
122
+ }
123
+
124
+ if (op[0] === 6 && _.label < t[1]) {
125
+ _.label = t[1];
126
+ t = op;
127
+ break;
128
+ }
129
+
130
+ if (t && _.label < t[2]) {
131
+ _.label = t[2];
132
+
133
+ _.ops.push(op);
134
+
135
+ break;
136
+ }
137
+
138
+ if (t[2]) _.ops.pop();
139
+
140
+ _.trys.pop();
141
+
142
+ continue;
143
+ }
144
+
145
+ op = body.call(thisArg, _);
146
+ } catch (e) {
147
+ op = [6, e];
148
+ y = 0;
149
+ } finally {
150
+ f = t = 0;
151
+ }
152
+ }
153
+
154
+ if (op[0] & 5) throw op[1];
155
+ return {
156
+ value: op[0] ? op[1] : void 0,
157
+ done: true
158
+ };
159
+ }
160
+ };
161
+
162
+ var __importDefault = this && this.__importDefault || function (mod) {
163
+ return mod && mod.__esModule ? mod : {
164
+ "default": mod
165
+ };
166
+ };
167
+
168
+ Object.defineProperty(exports, "__esModule", {
169
+ value: true
170
+ });
171
+ exports.RosConfigure = void 0;
172
+
173
+ var roslib_1 = __importDefault(require("roslib"));
174
+
175
+ var RosConfigure =
176
+ /** @class */
177
+ function () {
178
+ function RosConfigure(getConfig) {
179
+ this._conf = null;
180
+ this._ros = null;
181
+ this.getConfig = getConfig;
182
+ }
183
+
184
+ Object.defineProperty(RosConfigure.prototype, "conf", {
185
+ get: function get() {
186
+ var initialValues = {};
187
+
188
+ if (!this._conf) {
189
+ return initialValues;
190
+ }
191
+
192
+ return __assign({}, this._conf);
193
+ },
194
+ enumerable: false,
195
+ configurable: true
196
+ });
197
+ Object.defineProperty(RosConfigure.prototype, "ros", {
198
+ get: function get() {
199
+ if (!this._ros) {
200
+ throw Error('please init first!');
201
+ }
202
+
203
+ return this._ros;
204
+ },
205
+ enumerable: false,
206
+ configurable: true
207
+ });
208
+
209
+ RosConfigure.prototype.init = function () {
210
+ return __awaiter(this, void 0, void 0, function () {
211
+ var _a;
212
+
213
+ return __generator(this, function (_b) {
214
+ switch (_b.label) {
215
+ case 0:
216
+ if (this._conf) {
217
+ return [2
218
+ /*return*/
219
+ ];
220
+ }
221
+
222
+ _a = this;
223
+ return [4
224
+ /*yield*/
225
+ , this.getConfig()];
226
+
227
+ case 1:
228
+ _a._conf = _b.sent();
229
+ this._ros = new roslib_1["default"].Ros({
230
+ url: this._conf.ros_bridge_url
231
+ });
232
+ return [2
233
+ /*return*/
234
+ ];
235
+ }
236
+ });
237
+ });
238
+ };
239
+
240
+ return RosConfigure;
241
+ }();
242
+
243
+ exports.RosConfigure = RosConfigure;
@@ -0,0 +1,32 @@
1
+ import ROSLIB from 'roslib';
2
+ import { RosConfigure } from './configure';
3
+ import type { CreateFactory } from './super';
4
+ interface RosActionConfig {
5
+ serverName: string;
6
+ actionName: string;
7
+ }
8
+ interface TopicType {
9
+ name: string;
10
+ messageType: string;
11
+ }
12
+ interface RoseServiceConfig {
13
+ name: string;
14
+ serviceType: string;
15
+ }
16
+ declare type RoseServiceFunc = (payload: any) => Promise<any>;
17
+ declare type RoseActionFunc = (goalMessage: any) => Promise<any>;
18
+ interface RosTopic extends ROSLIB.Topic {
19
+ publishMessage: (payload: any) => void;
20
+ }
21
+ declare type RosTopicFunc = () => RosTopic;
22
+ export declare class RosUtils {
23
+ private readonly configure;
24
+ constructor(configure: RosConfigure);
25
+ private readonly publishService;
26
+ private readonly publishAction;
27
+ private readonly rosTopic;
28
+ createRosService: CreateFactory<RoseServiceConfig, RoseServiceFunc>;
29
+ createRosAction: CreateFactory<RosActionConfig, RoseActionFunc>;
30
+ createRosTopic: CreateFactory<TopicType, RosTopicFunc>;
31
+ }
32
+ export {};
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+
8
+ for (var p in s) {
9
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
+ }
11
+ }
12
+
13
+ return t;
14
+ };
15
+
16
+ return __assign.apply(this, arguments);
17
+ };
18
+
19
+ var __importDefault = this && this.__importDefault || function (mod) {
20
+ return mod && mod.__esModule ? mod : {
21
+ "default": mod
22
+ };
23
+ };
24
+
25
+ Object.defineProperty(exports, "__esModule", {
26
+ value: true
27
+ });
28
+ exports.RosUtils = void 0;
29
+
30
+ var roslib_1 = __importDefault(require("roslib"));
31
+
32
+ var super_1 = require("./super");
33
+
34
+ var RosUtils =
35
+ /** @class */
36
+ function () {
37
+ function RosUtils(configure) {
38
+ var _this = this;
39
+
40
+ this.configure = null;
41
+
42
+ this.publishService = function (_a) {
43
+ var name = _a.name,
44
+ serviceType = _a.serviceType,
45
+ payload = _a.payload;
46
+ return new Promise(function (resolve, reject) {
47
+ var service = new roslib_1["default"].Service({
48
+ ros: _this.configure.ros,
49
+ name: name,
50
+ serviceType: serviceType
51
+ });
52
+ var request = new roslib_1["default"].ServiceRequest(payload);
53
+ service.callService(request, resolve, reject);
54
+ });
55
+ };
56
+
57
+ this.publishAction = function (_a) {
58
+ var serverName = _a.serverName,
59
+ actionName = _a.actionName,
60
+ goalMessage = _a.goalMessage;
61
+ return new Promise(function (resolve, reject) {
62
+ var actionClient = new roslib_1["default"].ActionClient({
63
+ ros: _this.configure.ros,
64
+ serverName: serverName,
65
+ actionName: actionName,
66
+ timeout: 0
67
+ });
68
+ var goal = new roslib_1["default"].Goal({
69
+ actionClient: actionClient,
70
+ goalMessage: goalMessage
71
+ });
72
+ goal.on('result', function (result) {
73
+ return resolve(result);
74
+ });
75
+ goal.on('error', function (err) {
76
+ return reject(err);
77
+ });
78
+ goal.send();
79
+ });
80
+ };
81
+
82
+ this.rosTopic = function (props) {
83
+ var topic = new roslib_1["default"].Topic(__assign({
84
+ ros: _this.configure.ros
85
+ }, props));
86
+
87
+ topic.publishMessage = function (payload) {
88
+ if (typeof topic.publish === 'function') {
89
+ topic.publish(new roslib_1["default"].Message(payload));
90
+ }
91
+ };
92
+
93
+ return topic;
94
+ };
95
+
96
+ this.createRosService = function (services) {
97
+ return super_1.superFactory(function (options) {
98
+ return function (payload) {
99
+ return _this.publishService(__assign(__assign({}, options), {
100
+ payload: payload
101
+ }));
102
+ };
103
+ })(services);
104
+ };
105
+
106
+ this.createRosAction = function (actions) {
107
+ return super_1.superFactory(function (options) {
108
+ return function (goalMessage) {
109
+ return _this.publishAction(__assign(__assign({}, options), {
110
+ goalMessage: goalMessage
111
+ }));
112
+ };
113
+ })(actions);
114
+ };
115
+
116
+ this.createRosTopic = function (topic) {
117
+ return super_1.superFactory(function (options) {
118
+ return function () {
119
+ return _this.rosTopic(options);
120
+ };
121
+ })(topic);
122
+ };
123
+
124
+ this.configure = configure;
125
+ }
126
+
127
+ return RosUtils;
128
+ }();
129
+
130
+ exports.RosUtils = RosUtils;
@@ -0,0 +1,11 @@
1
+ declare type OptionsObject<T, C> = {
2
+ [key in keyof T]: C;
3
+ };
4
+ declare type ProductsObject<T, F> = {
5
+ [key in keyof T]: F;
6
+ };
7
+ declare type Factory<C> = (config: C) => any;
8
+ export declare type CreateFactory<C, F> = <T>(apis: OptionsObject<T, C>) => ProductsObject<T, F>;
9
+ export declare type SuperFactory = <C, F>(factory: Factory<C>) => CreateFactory<C, F>;
10
+ export declare const superFactory: SuperFactory;
11
+ export {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ var __values = this && this.__values || function (o) {
4
+ var s = typeof Symbol === "function" && Symbol.iterator,
5
+ m = s && o[s],
6
+ i = 0;
7
+ if (m) return m.call(o);
8
+ if (o && typeof o.length === "number") return {
9
+ next: function next() {
10
+ if (o && i >= o.length) o = void 0;
11
+ return {
12
+ value: o && o[i++],
13
+ done: !o
14
+ };
15
+ }
16
+ };
17
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
18
+ };
19
+
20
+ Object.defineProperty(exports, "__esModule", {
21
+ value: true
22
+ });
23
+ exports.superFactory = void 0;
24
+
25
+ exports.superFactory = function (factory) {
26
+ return function (options) {
27
+ var e_1, _a;
28
+
29
+ var product = {};
30
+
31
+ try {
32
+ for (var _b = __values(Object.keys(options)), _c = _b.next(); !_c.done; _c = _b.next()) {
33
+ var key = _c.value;
34
+ product[key] = factory(options[key]);
35
+ }
36
+ } catch (e_1_1) {
37
+ e_1 = {
38
+ error: e_1_1
39
+ };
40
+ } finally {
41
+ try {
42
+ if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
43
+ } finally {
44
+ if (e_1) throw e_1.error;
45
+ }
46
+ }
47
+
48
+ return product;
49
+ };
50
+ };
@@ -0,0 +1,7 @@
1
+ import { RosUtils } from './factory';
2
+ import type { RosConfigure } from './factory/configure';
3
+ import { RosViewer } from './ros3d/viewer';
4
+ export declare const createConfigureRos: (rosConfigure: RosConfigure) => {
5
+ rosUtils: RosUtils;
6
+ createRosViewer(): RosViewer;
7
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createConfigureRos = void 0;
7
+
8
+ var factory_1 = require("./factory");
9
+
10
+ var viewer_1 = require("./ros3d/viewer");
11
+
12
+ exports.createConfigureRos = function (rosConfigure) {
13
+ return {
14
+ rosUtils: new factory_1.RosUtils(rosConfigure),
15
+ createRosViewer: function createRosViewer() {
16
+ return new viewer_1.RosViewer(rosConfigure);
17
+ }
18
+ };
19
+ };
@@ -0,0 +1,6 @@
1
+ export declare class InjectUtil {
2
+ state: any;
3
+ inject(obj: any, options: any): any;
4
+ install(key: string, value: any): void;
5
+ remove(key: string): void;
6
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var __assign = this && this.__assign || function () {
4
+ __assign = Object.assign || function (t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+
8
+ for (var p in s) {
9
+ if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
10
+ }
11
+ }
12
+
13
+ return t;
14
+ };
15
+
16
+ return __assign.apply(this, arguments);
17
+ };
18
+
19
+ Object.defineProperty(exports, "__esModule", {
20
+ value: true
21
+ });
22
+ exports.InjectUtil = void 0;
23
+
24
+ var InjectUtil =
25
+ /** @class */
26
+ function () {
27
+ function InjectUtil() {
28
+ this.state = {};
29
+ }
30
+
31
+ InjectUtil.prototype.inject = function (obj, options) {
32
+ return new obj(__assign(__assign({}, this.state), options));
33
+ };
34
+
35
+ InjectUtil.prototype.install = function (key, value) {
36
+ this.state[key] = value;
37
+ };
38
+
39
+ InjectUtil.prototype.remove = function (key) {
40
+ delete this.state[key];
41
+ };
42
+
43
+ return InjectUtil;
44
+ }();
45
+
46
+ exports.InjectUtil = InjectUtil;
@@ -0,0 +1,11 @@
1
+ export declare function getRainbowColor(pct: number): any;
2
+ export declare function colormap(x: number): any;
3
+ export declare function loadLib(url: string): Promise<any>;
4
+ export declare const basePointCloudOptions: {
5
+ colorsrc: string;
6
+ material: {
7
+ size: number;
8
+ };
9
+ max_pts: number;
10
+ colormap: typeof colormap;
11
+ };