@dronedeploy/rocos-js-sdk 3.0.11 → 3.0.12
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/api/StreamRegister.d.ts +3 -3
- package/cjs/api/StreamRegister.js +6 -6
- package/cjs/api/streams/telemetry/TelemetryStreamAbstract.js +8 -7
- package/cjs/helpers/kscript/Context.d.ts +14 -8
- package/cjs/helpers/kscript/Context.js +59 -22
- package/cjs/helpers/kscript/kscript.js +1 -1
- package/cjs/helpers/kscript/nodes/Identifier.js +1 -1
- package/cjs/helpers/kscript/nodes/Node.d.ts +0 -1
- package/cjs/helpers/kscript/nodes/Node.js +0 -1
- package/cjs/helpers/kscript/nodes/Program.js +8 -5
- package/cjs/helpers/kscript/nodes/VariableDeclaration.d.ts +8 -0
- package/cjs/helpers/kscript/nodes/VariableDeclaration.js +43 -0
- package/cjs/helpers/kscript/nodes/expressions/ArrowFunctionExpression.js +11 -4
- package/cjs/helpers/kscript/nodes/expressions/AssignmentExpression.d.ts +8 -0
- package/cjs/helpers/kscript/nodes/expressions/AssignmentExpression.js +33 -0
- package/cjs/helpers/kscript/nodes/expressions/BinaryExpression.d.ts +2 -0
- package/cjs/helpers/kscript/nodes/expressions/BinaryExpression.js +16 -0
- package/cjs/helpers/kscript/nodes/expressions/NewExpression.d.ts +9 -0
- package/cjs/helpers/kscript/nodes/expressions/NewExpression.js +44 -0
- package/cjs/helpers/kscript/nodes/expressions/index.d.ts +2 -1
- package/cjs/helpers/kscript/nodes/expressions/index.js +5 -3
- package/cjs/helpers/kscript/nodes/nodeTypes.d.ts +9 -1
- package/cjs/helpers/kscript/nodes/nodeTypes.js +9 -1
- package/cjs/helpers/kscript/nodes/statements/BlockStatement.d.ts +8 -0
- package/cjs/helpers/kscript/nodes/statements/BlockStatement.js +29 -0
- package/cjs/helpers/kscript/nodes/statements/ReturnStatement.d.ts +12 -0
- package/cjs/helpers/kscript/nodes/statements/ReturnStatement.js +33 -0
- package/cjs/helpers/kscript/nodes/statements/SwitchStatement.d.ts +9 -0
- package/cjs/helpers/kscript/nodes/statements/SwitchStatement.js +52 -0
- package/cjs/helpers/kscript/nodes/statements/index.d.ts +4 -0
- package/cjs/helpers/kscript/nodes/statements/index.js +14 -0
- package/cjs/services/BaseStreamService.js +1 -1
- package/cjs/services/WebRTCSignallingService.js +1 -2
- package/esm/api/StreamRegister.d.ts +3 -3
- package/esm/api/StreamRegister.js +6 -6
- package/esm/api/streams/telemetry/TelemetryStreamAbstract.js +8 -7
- package/esm/helpers/kscript/Context.d.ts +14 -8
- package/esm/helpers/kscript/Context.js +59 -22
- package/esm/helpers/kscript/kscript.js +1 -1
- package/esm/helpers/kscript/nodes/Identifier.js +1 -1
- package/esm/helpers/kscript/nodes/Node.d.ts +0 -1
- package/esm/helpers/kscript/nodes/Node.js +0 -1
- package/esm/helpers/kscript/nodes/Program.js +8 -5
- package/esm/helpers/kscript/nodes/VariableDeclaration.d.ts +8 -0
- package/esm/helpers/kscript/nodes/VariableDeclaration.js +37 -0
- package/esm/helpers/kscript/nodes/expressions/ArrowFunctionExpression.js +11 -4
- package/esm/helpers/kscript/nodes/expressions/AssignmentExpression.d.ts +8 -0
- package/esm/helpers/kscript/nodes/expressions/AssignmentExpression.js +27 -0
- package/esm/helpers/kscript/nodes/expressions/BinaryExpression.d.ts +2 -0
- package/esm/helpers/kscript/nodes/expressions/BinaryExpression.js +16 -0
- package/esm/helpers/kscript/nodes/expressions/NewExpression.d.ts +9 -0
- package/esm/helpers/kscript/nodes/expressions/NewExpression.js +38 -0
- package/esm/helpers/kscript/nodes/expressions/index.d.ts +2 -1
- package/esm/helpers/kscript/nodes/expressions/index.js +2 -1
- package/esm/helpers/kscript/nodes/nodeTypes.d.ts +9 -1
- package/esm/helpers/kscript/nodes/nodeTypes.js +9 -1
- package/esm/helpers/kscript/nodes/statements/BlockStatement.d.ts +8 -0
- package/esm/helpers/kscript/nodes/statements/BlockStatement.js +23 -0
- package/esm/helpers/kscript/nodes/statements/ReturnStatement.d.ts +12 -0
- package/esm/helpers/kscript/nodes/statements/ReturnStatement.js +25 -0
- package/esm/helpers/kscript/nodes/statements/SwitchStatement.d.ts +9 -0
- package/esm/helpers/kscript/nodes/statements/SwitchStatement.js +46 -0
- package/esm/helpers/kscript/nodes/statements/index.d.ts +4 -0
- package/esm/helpers/kscript/nodes/statements/index.js +4 -0
- package/esm/services/BaseStreamService.js +1 -1
- package/esm/services/WebRTCSignallingService.js +1 -2
- package/package.json +1 -1
- /package/cjs/helpers/kscript/nodes/{expressions → statements}/ExpressionStatement.d.ts +0 -0
- /package/cjs/helpers/kscript/nodes/{expressions → statements}/ExpressionStatement.js +0 -0
- /package/esm/helpers/kscript/nodes/{expressions → statements}/ExpressionStatement.d.ts +0 -0
- /package/esm/helpers/kscript/nodes/{expressions → statements}/ExpressionStatement.js +0 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
import Node from '../Node';
|
2
|
+
import { construct } from '../../utils';
|
3
|
+
export default class NewExpressionNode extends Node {
|
4
|
+
constructor(node, context) {
|
5
|
+
super(node, context, 'NewExpression');
|
6
|
+
}
|
7
|
+
validate(validateChildren = false) {
|
8
|
+
if (!this.context.isFunctionCallAllowed)
|
9
|
+
throw new Error('Constructors are not allowed');
|
10
|
+
if (!validateChildren) {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
construct(this.node.callee, this.context).validate(true);
|
14
|
+
for (const arg of this.node.arguments) {
|
15
|
+
construct(arg, this.context).validate(true);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
run() {
|
19
|
+
this.validate();
|
20
|
+
const callee = construct(this.node.callee, this.context).run();
|
21
|
+
if (typeof callee !== 'function') {
|
22
|
+
throw new Error('callee is not a function');
|
23
|
+
}
|
24
|
+
const args = this.spreadArgs(this.node.arguments);
|
25
|
+
return new (Function.prototype.bind.apply(callee, [null, ...args]))();
|
26
|
+
}
|
27
|
+
spreadArgs(args) {
|
28
|
+
return args.reduce((acc, arg) => {
|
29
|
+
if (arg.type === 'SpreadElement') {
|
30
|
+
acc.push(...construct(arg.argument, this.context).run());
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
acc.push(construct(arg, this.context).run());
|
34
|
+
}
|
35
|
+
return acc;
|
36
|
+
}, []);
|
37
|
+
}
|
38
|
+
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
export { default as ExpressionStatement } from './ExpressionStatement';
|
2
1
|
export { default as ArrayExpression } from './ArrayExpression';
|
3
2
|
export { default as ObjectExpression } from './ObjectExpression';
|
4
3
|
export { default as BinaryExpression } from './BinaryExpression';
|
@@ -9,3 +8,5 @@ export { default as CallExpression } from './CallExpression';
|
|
9
8
|
export { default as ArrowFunctionExpression } from './ArrowFunctionExpression';
|
10
9
|
export { default as MemberExpression } from './MemberExpression';
|
11
10
|
export { default as ChainExpression } from './ChainExpression';
|
11
|
+
export { default as NewExpression } from './NewExpression';
|
12
|
+
export { default as AssignmentExpression } from './AssignmentExpression';
|
@@ -1,4 +1,3 @@
|
|
1
|
-
export { default as ExpressionStatement } from './ExpressionStatement';
|
2
1
|
export { default as ArrayExpression } from './ArrayExpression';
|
3
2
|
export { default as ObjectExpression } from './ObjectExpression';
|
4
3
|
export { default as BinaryExpression } from './BinaryExpression';
|
@@ -9,3 +8,5 @@ export { default as CallExpression } from './CallExpression';
|
|
9
8
|
export { default as ArrowFunctionExpression } from './ArrowFunctionExpression';
|
10
9
|
export { default as MemberExpression } from './MemberExpression';
|
11
10
|
export { default as ChainExpression } from './ChainExpression';
|
11
|
+
export { default as NewExpression } from './NewExpression';
|
12
|
+
export { default as AssignmentExpression } from './AssignmentExpression';
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import { ArrayExpression, ArrowFunctionExpression, BinaryExpression, CallExpression, ChainExpression, ConditionalExpression,
|
1
|
+
import { ArrayExpression, ArrowFunctionExpression, AssignmentExpression, BinaryExpression, CallExpression, ChainExpression, ConditionalExpression, LogicalExpression, MemberExpression, NewExpression, ObjectExpression, UnaryExpression } from './expressions';
|
2
|
+
import { BlockStatement, ExpressionStatement, ReturnStatement, SwitchStatement } from './statements';
|
2
3
|
import { AnyNode } from 'acorn';
|
3
4
|
import type Context from '../Context';
|
4
5
|
import Identifier from './Identifier';
|
@@ -6,6 +7,7 @@ import Literal from './Literal';
|
|
6
7
|
import Node from './Node';
|
7
8
|
import Program from './Program';
|
8
9
|
import TemplateLiteral from './TemplateLiteral';
|
10
|
+
import VariableDeclaration from './VariableDeclaration';
|
9
11
|
type NodeConstructor = {
|
10
12
|
new (node: AnyNode, scope: Context): Node<AnyNode>;
|
11
13
|
};
|
@@ -27,6 +29,12 @@ declare const nodes: {
|
|
27
29
|
readonly CallExpression: typeof CallExpression;
|
28
30
|
readonly MemberExpression: typeof MemberExpression;
|
29
31
|
readonly ChainExpression: typeof ChainExpression;
|
32
|
+
readonly NewExpression: typeof NewExpression;
|
33
|
+
readonly BlockStatement: typeof BlockStatement;
|
34
|
+
readonly ReturnStatement: typeof ReturnStatement;
|
35
|
+
readonly VariableDeclaration: typeof VariableDeclaration;
|
36
|
+
readonly AssignmentExpression: typeof AssignmentExpression;
|
37
|
+
readonly SwitchStatement: typeof SwitchStatement;
|
30
38
|
};
|
31
39
|
export type NodeType = keyof typeof nodes;
|
32
40
|
declare const _default: NodeMap;
|
@@ -1,8 +1,10 @@
|
|
1
|
-
import { ArrayExpression, ArrowFunctionExpression, BinaryExpression, CallExpression, ChainExpression, ConditionalExpression,
|
1
|
+
import { ArrayExpression, ArrowFunctionExpression, AssignmentExpression, BinaryExpression, CallExpression, ChainExpression, ConditionalExpression, LogicalExpression, MemberExpression, NewExpression, ObjectExpression, UnaryExpression, } from './expressions';
|
2
|
+
import { BlockStatement, ExpressionStatement, ReturnStatement, SwitchStatement } from './statements';
|
2
3
|
import Identifier from './Identifier';
|
3
4
|
import Literal from './Literal';
|
4
5
|
import Program from './Program';
|
5
6
|
import TemplateLiteral from './TemplateLiteral';
|
7
|
+
import VariableDeclaration from './VariableDeclaration';
|
6
8
|
const nodes = {
|
7
9
|
Program,
|
8
10
|
Literal,
|
@@ -20,5 +22,11 @@ const nodes = {
|
|
20
22
|
CallExpression,
|
21
23
|
MemberExpression,
|
22
24
|
ChainExpression,
|
25
|
+
NewExpression,
|
26
|
+
BlockStatement,
|
27
|
+
ReturnStatement,
|
28
|
+
VariableDeclaration,
|
29
|
+
AssignmentExpression,
|
30
|
+
SwitchStatement,
|
23
31
|
};
|
24
32
|
export default new Map(Object.entries(nodes));
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { AnyNode, BlockStatement } from 'acorn';
|
2
|
+
import Context from '../../Context';
|
3
|
+
import Node from '../Node';
|
4
|
+
export default class BlockStatementNode extends Node<BlockStatement> {
|
5
|
+
constructor(node: AnyNode, context: Context);
|
6
|
+
validate(validateChildren?: boolean): void;
|
7
|
+
run(): unknown;
|
8
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import Node from '../Node';
|
2
|
+
import { construct } from '../../utils';
|
3
|
+
export default class BlockStatementNode extends Node {
|
4
|
+
constructor(node, context) {
|
5
|
+
super(node, context.newChild(), 'BlockStatement');
|
6
|
+
}
|
7
|
+
validate(validateChildren = false) {
|
8
|
+
if (!validateChildren) {
|
9
|
+
return;
|
10
|
+
}
|
11
|
+
for (const statement of this.node.body) {
|
12
|
+
construct(statement, this.context).validate(true);
|
13
|
+
}
|
14
|
+
}
|
15
|
+
run() {
|
16
|
+
this.validate();
|
17
|
+
let result;
|
18
|
+
for (const statement of this.node.body) {
|
19
|
+
result = construct(statement, this.context).run();
|
20
|
+
}
|
21
|
+
return result;
|
22
|
+
}
|
23
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { AnyNode, ReturnStatement } from 'acorn';
|
2
|
+
import type Context from '../../Context';
|
3
|
+
import Node from '../Node';
|
4
|
+
export declare class ReturnStatementError extends Error {
|
5
|
+
readonly value: unknown;
|
6
|
+
constructor(value: unknown);
|
7
|
+
}
|
8
|
+
export default class ReturnStatementNode extends Node<ReturnStatement> {
|
9
|
+
constructor(node: AnyNode, context: Context);
|
10
|
+
validate(validateChildren?: boolean): void;
|
11
|
+
run(): unknown;
|
12
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import Node from '../Node';
|
2
|
+
import { construct } from '../../utils';
|
3
|
+
export class ReturnStatementError extends Error {
|
4
|
+
constructor(value) {
|
5
|
+
super('Illegal return statement');
|
6
|
+
this.value = value;
|
7
|
+
}
|
8
|
+
}
|
9
|
+
export default class ReturnStatementNode extends Node {
|
10
|
+
constructor(node, context) {
|
11
|
+
super(node, context, 'ReturnStatement');
|
12
|
+
}
|
13
|
+
validate(validateChildren = false) {
|
14
|
+
const arg = this.node.argument;
|
15
|
+
if (!validateChildren || arg === undefined || arg === null) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
construct(arg, this.context).validate(true);
|
19
|
+
}
|
20
|
+
run() {
|
21
|
+
this.validate();
|
22
|
+
const result = this.node.argument ? construct(this.node.argument, this.context).run() : undefined;
|
23
|
+
throw new ReturnStatementError(result);
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { AnyNode, SwitchStatement } from 'acorn';
|
2
|
+
import Context from '../../Context';
|
3
|
+
import Node from '../Node';
|
4
|
+
export default class SwitchStatementNode extends Node<SwitchStatement> {
|
5
|
+
constructor(node: AnyNode, context: Context);
|
6
|
+
private test_match;
|
7
|
+
validate(validateChildren?: boolean): void;
|
8
|
+
run(): unknown;
|
9
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import Node from '../Node';
|
2
|
+
import { construct } from '../../utils';
|
3
|
+
export default class SwitchStatementNode extends Node {
|
4
|
+
constructor(node, context) {
|
5
|
+
super(node, context, 'SwitchStatement');
|
6
|
+
}
|
7
|
+
test_match(test, discriminant) {
|
8
|
+
if (!test) {
|
9
|
+
return true;
|
10
|
+
}
|
11
|
+
const testValue = construct(test, this.context).run();
|
12
|
+
return testValue === discriminant;
|
13
|
+
}
|
14
|
+
validate(validateChildren = false) {
|
15
|
+
if (!validateChildren) {
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
construct(this.node.discriminant, this.context).validate(true);
|
19
|
+
for (const c of this.node.cases) {
|
20
|
+
if (c.test) {
|
21
|
+
construct(c.test, this.context).validate(true);
|
22
|
+
}
|
23
|
+
for (const s of c.consequent) {
|
24
|
+
construct(s, this.context).validate(true);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
run() {
|
29
|
+
this.validate();
|
30
|
+
const discriminant = construct(this.node.discriminant, this.context).run();
|
31
|
+
let result;
|
32
|
+
let matched = false;
|
33
|
+
for (const c of this.node.cases) {
|
34
|
+
if (!matched && this.test_match(c.test, discriminant)) {
|
35
|
+
matched = true;
|
36
|
+
}
|
37
|
+
if (!matched) {
|
38
|
+
continue;
|
39
|
+
}
|
40
|
+
for (const s of c.consequent) {
|
41
|
+
result = construct(s, this.context).run();
|
42
|
+
}
|
43
|
+
}
|
44
|
+
return result;
|
45
|
+
}
|
46
|
+
}
|
@@ -41,7 +41,7 @@ export class BaseStreamService {
|
|
41
41
|
this.status = msg === SubscriberStatusEnum.STOPPED || msg === SubscriberStatusEnum.ALIVE;
|
42
42
|
this.status$.next(msg);
|
43
43
|
});
|
44
|
-
|
44
|
+
streamRegister.addStream(stream);
|
45
45
|
await this.initStream(stream);
|
46
46
|
}
|
47
47
|
return { stream, isNew };
|
@@ -50,8 +50,7 @@ export class WebRTCSignallingService {
|
|
50
50
|
this.status = msg === SubscriberStatusEnum.STOPPED || msg === SubscriberStatusEnum.ALIVE;
|
51
51
|
this.status$.next(msg);
|
52
52
|
});
|
53
|
-
|
54
|
-
await streamRegister.addStream(stream);
|
53
|
+
streamRegister.addStream(stream);
|
55
54
|
await this.initStream(stream);
|
56
55
|
}
|
57
56
|
return stream;
|
package/package.json
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|