@abaplint/transpiler 2.10.59 → 2.10.61

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.
@@ -45,8 +45,8 @@ class Transpiler {
45
45
  objects: [],
46
46
  unitTestScript: new unit_test_1.UnitTest().unitTestScript(reg, this.options?.skip),
47
47
  unitTestScriptOpen: new unit_test_1.UnitTest().unitTestScriptOpen(reg, this.options?.skip),
48
- initializationScript: new initialization_1.Initialization().script(reg, dbSetup, this.options?.extraSetup),
49
- initializationScript2: new initialization_1.Initialization().script(reg, dbSetup, this.options?.extraSetup, true),
48
+ initializationScript: new initialization_1.Initialization().script(reg, dbSetup, this.options),
49
+ initializationScript2: new initialization_1.Initialization().script(reg, dbSetup, this.options, true),
50
50
  databaseSetup: dbSetup,
51
51
  reg: reg,
52
52
  };
@@ -1,8 +1,9 @@
1
1
  import { DatabaseSetupResult } from "./db/database_setup_result";
2
2
  import * as abaplint from "@abaplint/core";
3
+ import { ITranspilerOptions } from "./types";
3
4
  export declare function escapeNamespaceFilename(filename: string): string;
4
5
  export declare class Initialization {
5
- script(reg: abaplint.IRegistry, dbSetup: DatabaseSetupResult, extraSetup?: string, useImport?: boolean): string;
6
+ script(reg: abaplint.IRegistry, dbSetup: DatabaseSetupResult, options: ITranspilerOptions | undefined, useImport?: boolean): string;
6
7
  private buildImports;
7
8
  private hasClassConstructor;
8
9
  }
@@ -9,7 +9,7 @@ function escapeNamespaceFilename(filename) {
9
9
  return filename.replace(/\//g, "%23");
10
10
  }
11
11
  class Initialization {
12
- script(reg, dbSetup, extraSetup, useImport) {
12
+ script(reg, dbSetup, options, useImport) {
13
13
  let ret = "";
14
14
  if (useImport === true) {
15
15
  ret = `/* eslint-disable import/newline-after-import */
@@ -20,7 +20,7 @@ import "./_top.mjs";\n`;
20
20
  import runtime from "@abaplint/runtime";
21
21
  globalThis.abap = new runtime.ABAP();\n`;
22
22
  }
23
- ret += `${this.buildImports(reg, useImport)}
23
+ ret += `${this.buildImports(reg, useImport, options)}
24
24
 
25
25
  export async function initializeABAP() {\n`;
26
26
  ret += ` const sqlite = [];\n`;
@@ -43,17 +43,17 @@ export async function initializeABAP() {\n`;
43
43
  ret += ` insert.push(\`${i}\`);\n`;
44
44
  }
45
45
  ret += `\n`;
46
- if (extraSetup === undefined || extraSetup === "") {
46
+ if (options?.extraSetup === undefined || options?.extraSetup === "") {
47
47
  ret += `// no setup logic specified in config\n`;
48
48
  }
49
49
  else {
50
- ret += ` const {setup} = await import("${extraSetup}");\n` +
50
+ ret += ` const {setup} = await import("${options?.extraSetup}");\n` +
51
51
  ` await setup(globalThis.abap, schemas, insert);\n`;
52
52
  }
53
53
  ret += `}`;
54
54
  return ret;
55
55
  }
56
- buildImports(reg, useImport) {
56
+ buildImports(reg, useImport, options) {
57
57
  // note: ES modules are hoised, so use the dynamic import(), due to setting of globalThis.abap
58
58
  // some sorting required: eg. a class constructor using constant from interface
59
59
  const list = [];
@@ -92,7 +92,7 @@ export async function initializeABAP() {\n`;
92
92
  }
93
93
  else if (obj instanceof abaplint.Objects.Interface
94
94
  || obj instanceof abaplint.Objects.FunctionGroup
95
- // hmm || obj instanceof abaplint.Objects.Program
95
+ || (options?.importProg === true && obj instanceof abaplint.Objects.Program)
96
96
  || obj instanceof abaplint.Objects.Class) {
97
97
  list.push(name);
98
98
  }
@@ -30,10 +30,10 @@ class DataTranspiler {
30
30
  }
31
31
  const ret = new chunk_1.Chunk()
32
32
  .appendString("let ")
33
- .append(traversal_1.Traversal.prefixVariable(traversal_1.Traversal.escapeNamespace(found.getName().toLowerCase())), token, traversal)
33
+ .appendString(traversal_1.Traversal.prefixVariable(traversal_1.Traversal.escapeNamespace(found.getName().toLowerCase())))
34
34
  .appendString(" = " + new transpile_types_1.TranspileTypes().toType(found.getType()))
35
- .append(";", node.getLastToken(), traversal)
36
- .append(value, node.getLastToken(), traversal);
35
+ .appendString(";")
36
+ .appendString(value);
37
37
  return ret;
38
38
  }
39
39
  static buildValue(node, name, traversal) {
@@ -22,9 +22,9 @@ class FieldSymbolTranspiler {
22
22
  }
23
23
  if (name) {
24
24
  return new chunk_1.Chunk()
25
- .append("let ", node, traversal)
26
- .appendChunk(new field_symbol_1.FieldSymbolTranspiler().transpile(name, traversal))
27
- .append(" = new abap.types.FieldSymbol(" + new transpile_types_1.TranspileTypes().toType(found.getType()) + ");", node.getLastToken(), traversal);
25
+ .appendString("let ")
26
+ .appendString(new field_symbol_1.FieldSymbolTranspiler().transpile(name, traversal).getCode())
27
+ .appendString(" = new abap.types.FieldSymbol(" + new transpile_types_1.TranspileTypes().toType(found.getType()) + ");");
28
28
  }
29
29
  throw new Error("FieldSymbolTranspiler, name not found");
30
30
  }
@@ -61,4 +61,6 @@ export interface ITranspilerOptions {
61
61
  skipReposrc?: boolean;
62
62
  /** ignore source map */
63
63
  ignoreSourceMap?: boolean;
64
+ /** import programs */
65
+ importProg?: boolean;
64
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler",
3
- "version": "2.10.59",
3
+ "version": "2.10.61",
4
4
  "description": "Transpiler",
5
5
  "main": "build/src/index.js",
6
6
  "typings": "build/src/index.d.ts",
@@ -29,14 +29,14 @@
29
29
  "author": "abaplint",
30
30
  "license": "MIT",
31
31
  "dependencies": {
32
- "@abaplint/core": "^2.113.125",
32
+ "@abaplint/core": "^2.113.131",
33
33
  "source-map": "^0.7.4"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/chai": "^4.3.20",
37
37
  "@types/mocha": "^10.0.10",
38
38
  "chai": "^4.5.0",
39
- "mocha": "^11.5.0",
39
+ "mocha": "^11.7.1",
40
40
  "source-map-support": "^0.5.21",
41
41
  "typescript": "^5.8.3"
42
42
  }