@abaplint/runtime 2.6.43 → 2.7.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.
@@ -1,7 +1,7 @@
1
- export declare class Console {
2
- private data;
1
+ export interface Console {
3
2
  clear(): void;
4
3
  add(data: string): void;
5
4
  get(): string;
6
5
  getTrimmed(): string;
6
+ isEmpty(): boolean;
7
7
  }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=console.js.map
@@ -0,0 +1,9 @@
1
+ import { Console } from "./console";
2
+ export declare class MemoryConsole implements Console {
3
+ private data;
4
+ clear(): void;
5
+ add(data: string): void;
6
+ get(): string;
7
+ isEmpty(): boolean;
8
+ getTrimmed(): string;
9
+ }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Console = void 0;
4
- class Console {
3
+ exports.MemoryConsole = void 0;
4
+ class MemoryConsole {
5
5
  constructor() {
6
6
  this.data = "";
7
7
  }
@@ -14,9 +14,12 @@ class Console {
14
14
  get() {
15
15
  return this.data;
16
16
  }
17
+ isEmpty() {
18
+ return this.data === "";
19
+ }
17
20
  getTrimmed() {
18
21
  return this.data.split("\n").map(a => a.trimEnd()).join("\n");
19
22
  }
20
23
  }
21
- exports.Console = Console;
22
- //# sourceMappingURL=console.js.map
24
+ exports.MemoryConsole = MemoryConsole;
25
+ //# sourceMappingURL=memory_console.js.map
@@ -0,0 +1,9 @@
1
+ import { Console } from "./console";
2
+ export declare class StandardOutConsole implements Console {
3
+ private empty;
4
+ clear(): void;
5
+ add(data: string): void;
6
+ get(): string;
7
+ isEmpty(): boolean;
8
+ getTrimmed(): string;
9
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StandardOutConsole = void 0;
4
+ class StandardOutConsole {
5
+ constructor() {
6
+ this.empty = true;
7
+ }
8
+ clear() {
9
+ throw new Error("transpiler runtime: not supported for stdio console");
10
+ }
11
+ add(data) {
12
+ process.stdout.write(data);
13
+ this.empty = false;
14
+ }
15
+ get() {
16
+ return "";
17
+ }
18
+ isEmpty() {
19
+ return this.empty;
20
+ }
21
+ getTrimmed() {
22
+ throw new Error("transpiler runtime: not supported for stdio console");
23
+ }
24
+ }
25
+ exports.StandardOutConsole = StandardOutConsole;
26
+ //# sourceMappingURL=standard_out_console.js.map
@@ -1,4 +1,4 @@
1
- import { Console } from "./console";
1
+ import { Console } from "./console/console";
2
2
  import { DatabaseClient } from "./db/db";
3
3
  import * as RFC from "./rfc";
4
4
  export declare class Context {
@@ -1,4 +1,3 @@
1
- import { Console } from "./console";
2
1
  import { Context } from "./context";
3
2
  import { OffsetLength } from "./offset_length";
4
3
  import { Statements } from "./statements";
@@ -13,7 +12,9 @@ import * as types from "./types";
13
12
  import { expandIN } from "./expand_in";
14
13
  import { expandDynamic } from "./expand_dynamic";
15
14
  import { ClassicError } from "./classic_error";
16
- export { UnitTestResult, RFC, types, DB };
15
+ import { Console } from "./console/console";
16
+ import { MemoryConsole } from "./console/memory_console";
17
+ export { UnitTestResult, RFC, types, DB, MemoryConsole };
17
18
  export declare class ABAP {
18
19
  FunctionModules: {
19
20
  [name: string]: any;
@@ -48,5 +49,5 @@ export declare class ABAP {
48
49
  expandDynamic: typeof expandDynamic;
49
50
  ClassicError: typeof ClassicError;
50
51
  readonly context: Context;
51
- constructor();
52
+ constructor(console?: Console);
52
53
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ABAP = exports.DB = exports.types = exports.RFC = exports.UnitTestResult = void 0;
4
- const console_1 = require("./console");
3
+ exports.ABAP = exports.MemoryConsole = exports.DB = exports.types = exports.RFC = exports.UnitTestResult = void 0;
5
4
  const context_1 = require("./context");
6
5
  const offset_length_1 = require("./offset_length");
7
6
  const statements_1 = require("./statements");
@@ -20,8 +19,11 @@ exports.types = types;
20
19
  const expand_in_1 = require("./expand_in");
21
20
  const expand_dynamic_1 = require("./expand_dynamic");
22
21
  const classic_error_1 = require("./classic_error");
22
+ const standard_out_console_1 = require("./console/standard_out_console");
23
+ const memory_console_1 = require("./console/memory_console");
24
+ Object.defineProperty(exports, "MemoryConsole", { enumerable: true, get: function () { return memory_console_1.MemoryConsole; } });
23
25
  class ABAP {
24
- constructor() {
26
+ constructor(console) {
25
27
  // global objects
26
28
  this.FunctionModules = {};
27
29
  this.Classes = {};
@@ -40,7 +42,7 @@ class ABAP {
40
42
  this.expandDynamic = expand_dynamic_1.expandDynamic;
41
43
  this.ClassicError = classic_error_1.ClassicError;
42
44
  this.context = new context_1.Context();
43
- this.console = new console_1.Console();
45
+ this.console = console ? console : new standard_out_console_1.StandardOutConsole();
44
46
  this.context.console = this.console;
45
47
  this.statements = new statements_1.Statements(this.context);
46
48
  // todo, this should not be a singleton, it should be part of this instance
@@ -12,7 +12,7 @@ class WriteStatement {
12
12
  this.context.console.add("\n");
13
13
  }
14
14
  else {
15
- if ((options === null || options === void 0 ? void 0 : options.newLine) === true && this.context.console.get().length > 0) {
15
+ if ((options === null || options === void 0 ? void 0 : options.newLine) === true && this.context.console.isEmpty() === false) {
16
16
  this.context.console.add("\n");
17
17
  }
18
18
  let result = "";
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@abaplint/runtime",
3
- "version": "2.6.43",
3
+ "version": "2.7.0",
4
4
  "description": "Transpiler - Runtime",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
7
+ "funding": "https://github.com/sponsors/larshp",
7
8
  "repository": {
8
9
  "type": "git",
9
10
  "url": "git+https://github.com/abaplint/transpiler.git"