@krokodilushka/mavlink-parser-browserify 0.1.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.
@@ -0,0 +1,3 @@
1
+ FROM node:24.13-alpine3.22
2
+
3
+ RUN apk add --no-cache git
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "mavlink-parser-browserify devcontainer",
3
+ "build": {
4
+ "dockerfile": "Dockerfile"
5
+ },
6
+ "mounts": [
7
+ "source=${localWorkspaceFolder},target=/app,type=bind,consistency=cached"
8
+ ]
9
+ }
package/LICENSE ADDED
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ <sup>If you're looking for the officially supported bindings for JavaScript see the [pymavlink](https://github.com/ArduPilot/pymavlink/tree/master/generator/javascript) project.</sup>
2
+
3
+ # MavLink Parser for the browser
4
+
5
+ Mavlink-parser-browserify is a copy of [node-mavlink](https://github.com/ArduPilot/node-mavlink). Unfortunately, the original node-mavlink library has a dependency on the [node UDP/datagram sockets module (dgram)](https://nodejs.org/api/dgram.html). This is an issue when trying to run node-mavlink in a browser-only environment from Webpack 5 lost polyfill.
6
+
7
+ This work is simply the [node-mavlink](https://github.com/ArduPilot/node-mavlink) striped of its dependency on dgram (and the functionalities linked to it).
@@ -0,0 +1,5 @@
1
+ export * from "mavlink-mappings";
2
+ export * from "./lib/utils";
3
+ export * from "./lib/logger";
4
+ export * from "./lib/mavlink";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("mavlink-mappings"), exports);
18
+ __exportStar(require("./lib/utils"), exports);
19
+ __exportStar(require("./lib/logger"), exports);
20
+ __exportStar(require("./lib/mavlink"), exports);
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Level of the log entry
3
+ */
4
+ export declare enum LogLevel {
5
+ trace = 5,
6
+ debug = 4,
7
+ info = 3,
8
+ warn = 2,
9
+ error = 1,
10
+ fatal = 0
11
+ }
12
+ type LoggerEvents = 'log';
13
+ type LoggerEventHandler = (context: string, level: LogLevel, message: any[]) => void;
14
+ /**
15
+ * Simplified interface for logging facilities
16
+ */
17
+ export declare class Logger {
18
+ private static readonly events;
19
+ private static registry;
20
+ /**
21
+ * Gets a logger by name
22
+ *
23
+ * @param context logger context
24
+ */
25
+ static getLogger(context: any): Logger;
26
+ /**
27
+ * Binds an event handler
28
+ *
29
+ * @param event event to react to
30
+ * @param handler event handler
31
+ */
32
+ static on(event: LoggerEvents, handler: (context: any, level: LogLevel, message: string) => void): void;
33
+ /**
34
+ * Removes an event handler
35
+ *
36
+ * @param event event to react to
37
+ * @param handler event handler
38
+ */
39
+ static off(event: LoggerEvents, handler: LoggerEventHandler): void;
40
+ private context;
41
+ /**
42
+ * Constructs a new logger instance
43
+ *
44
+ * @param context logger context
45
+ */
46
+ constructor(context: string);
47
+ /**
48
+ * Sends a log message if the trace level is enabled for this logger
49
+ *
50
+ * @param args parameters for the log entry
51
+ */
52
+ trace(...args: any): void;
53
+ /**
54
+ * Sends a log message if the debug level is enabled for this logger
55
+ *
56
+ * @param args parameters for the log entry
57
+ */
58
+ debug(...args: any): void;
59
+ /**
60
+ * Sends a log message if the info level is enabled for this logger
61
+ *
62
+ * @param args parameters for the log entry
63
+ */
64
+ info(...args: any): void;
65
+ /**
66
+ * Sends a log message if the warn level is enabled for this logger
67
+ *
68
+ * @param args parameters for the log entry
69
+ */
70
+ warn(...args: any): void;
71
+ /**
72
+ * Sends a log message if the error level is enabled for this logger
73
+ *
74
+ * @param args parameters for the log entry
75
+ */
76
+ error(...args: any): void;
77
+ /**
78
+ * Sends a log message if the fatal level is enabled for this logger
79
+ *
80
+ * @param args parameters for the log entry
81
+ */
82
+ fatal(...args: any): void;
83
+ }
84
+ export {};
85
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../lib/logger.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,oBAAY,QAAQ;IAClB,KAAK,IAAQ;IACb,KAAK,IAAQ;IACb,IAAI,IAAS;IACb,IAAI,IAAS;IACb,KAAK,IAAQ;IACb,KAAK,IAAQ;CACd;AAGD,KAAK,YAAY,GAAG,KAAK,CAAA;AACzB,KAAK,kBAAkB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;AAEpF;;GAEG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAmC;IACjE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAqB;IAE5C;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG;IAY7B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI;IAIhG;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,kBAAkB;IAI3D,OAAO,CAAC,OAAO,CAAQ;IAEvB;;;;OAIG;gBACS,OAAO,EAAE,MAAM;IAK3B;;;;OAIG;IACH,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG;IAIlB;;;;OAIG;IACH,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG;IAIlB;;;;OAIG;IACH,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG;IAIjB;;;;OAIG;IACH,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG;IAIjB;;;;OAIG;IACH,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG;IAIlB;;;;OAIG;IACH,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG;CAGnB"}
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Logger = exports.LogLevel = void 0;
4
+ const events_1 = require("events");
5
+ /**
6
+ * Level of the log entry
7
+ */
8
+ var LogLevel;
9
+ (function (LogLevel) {
10
+ LogLevel[LogLevel["trace"] = 5] = "trace";
11
+ LogLevel[LogLevel["debug"] = 4] = "debug";
12
+ LogLevel[LogLevel["info"] = 3] = "info";
13
+ LogLevel[LogLevel["warn"] = 2] = "warn";
14
+ LogLevel[LogLevel["error"] = 1] = "error";
15
+ LogLevel[LogLevel["fatal"] = 0] = "fatal";
16
+ })(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
17
+ /**
18
+ * Simplified interface for logging facilities
19
+ */
20
+ class Logger {
21
+ static events = new events_1.EventEmitter();
22
+ static registry = {};
23
+ /**
24
+ * Gets a logger by name
25
+ *
26
+ * @param context logger context
27
+ */
28
+ static getLogger(context) {
29
+ let name = '';
30
+ if (typeof context === 'function')
31
+ name = context.name;
32
+ else if (typeof context === 'object')
33
+ name = context.constructor.name;
34
+ else if (typeof context === 'string')
35
+ name = context;
36
+ else
37
+ throw new Error(`Do not know how to get logger for ${context} (${typeof context})`);
38
+ if (!Logger.registry[name])
39
+ Logger.registry[name] = new Logger(name);
40
+ return Logger.registry[name];
41
+ }
42
+ /**
43
+ * Binds an event handler
44
+ *
45
+ * @param event event to react to
46
+ * @param handler event handler
47
+ */
48
+ static on(event, handler) {
49
+ this.events.on(event, handler);
50
+ }
51
+ /**
52
+ * Removes an event handler
53
+ *
54
+ * @param event event to react to
55
+ * @param handler event handler
56
+ */
57
+ static off(event, handler) {
58
+ this.events.off(event, handler);
59
+ }
60
+ context;
61
+ /**
62
+ * Constructs a new logger instance
63
+ *
64
+ * @param context logger context
65
+ */
66
+ constructor(context) {
67
+ this.context = context;
68
+ Logger.events.emit('logger-created', Logger.registry[context]);
69
+ }
70
+ /**
71
+ * Sends a log message if the trace level is enabled for this logger
72
+ *
73
+ * @param args parameters for the log entry
74
+ */
75
+ trace(...args) {
76
+ Logger.events.emit('log', { context: this.context, level: LogLevel.trace, message: args });
77
+ }
78
+ /**
79
+ * Sends a log message if the debug level is enabled for this logger
80
+ *
81
+ * @param args parameters for the log entry
82
+ */
83
+ debug(...args) {
84
+ Logger.events.emit('log', { context: this.context, level: LogLevel.debug, message: args });
85
+ }
86
+ /**
87
+ * Sends a log message if the info level is enabled for this logger
88
+ *
89
+ * @param args parameters for the log entry
90
+ */
91
+ info(...args) {
92
+ Logger.events.emit('log', { context: this.context, level: LogLevel.info, message: args });
93
+ }
94
+ /**
95
+ * Sends a log message if the warn level is enabled for this logger
96
+ *
97
+ * @param args parameters for the log entry
98
+ */
99
+ warn(...args) {
100
+ Logger.events.emit('log', { context: this.context, level: LogLevel.warn, message: args });
101
+ }
102
+ /**
103
+ * Sends a log message if the error level is enabled for this logger
104
+ *
105
+ * @param args parameters for the log entry
106
+ */
107
+ error(...args) {
108
+ Logger.events.emit('log', { context: this.context, level: LogLevel.error, message: args });
109
+ }
110
+ /**
111
+ * Sends a log message if the fatal level is enabled for this logger
112
+ *
113
+ * @param args parameters for the log entry
114
+ */
115
+ fatal(...args) {
116
+ Logger.events.emit('log', { context: this.context, level: LogLevel.fatal, message: args });
117
+ }
118
+ }
119
+ exports.Logger = Logger;