harmonyc 0.17.0 → 0.18.1

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.
@@ -134,11 +134,14 @@ export class VitestGenerator {
134
134
  return this.saveToVariable(p.saveToVariable);
135
135
  }
136
136
  const name = p.toSingleLineString();
137
- this.tf.print(`(context.task.meta.phrases.push(${str(p.toString())}),`, p.start, name);
137
+ this.tf.print(`(context.task.meta.phrases.push(${str(p.toString())}),`);
138
138
  if (p instanceof Response && p.saveToVariable) {
139
139
  this.saveToVariable(p.saveToVariable, '');
140
140
  }
141
- this.tf.print(`await ${f}.${functionName(p)}(${args.join(', ')}));`, p.start, name);
141
+ this.tf.printn(`await ${f}.`);
142
+ this.tf.write(`${functionName(p)}(${args.join(', ')})`, p.start, name);
143
+ this.tf.write(`);`);
144
+ this.tf.nl();
142
145
  }
143
146
  setVariable(action) {
144
147
  this.tf.print(`(context.task.meta.variables ??= {})[${str(action.variableName)}] = ${action.value.toCode(this)};`);
@@ -3,25 +3,18 @@ import { Location } from '../model/model.ts';
3
3
  export declare class OutFile {
4
4
  name: string;
5
5
  sourceFile: string;
6
- lines: string[];
7
6
  level: number;
8
7
  sm: SourceNode;
9
8
  indentSpaces: number;
10
9
  constructor(name: string, sourceFile: string);
11
10
  indent(fn: () => void): void;
11
+ private get currentIndent();
12
12
  clear(): void;
13
- append(s: string): void;
14
- print(line: string, start?: Location, name?: string, end?: Location): this;
15
- loc(location: Location | undefined, name?: string): this;
13
+ printn(line: string, start?: Location, name?: string, end?: Location): void;
14
+ print(line: string, start?: Location, name?: string, end?: Location): void;
15
+ write(line: string, start?: Location, name?: string, end?: Location): void;
16
+ nl(): void;
16
17
  get sourceMap(): import("source-map-js").RawSourceMap;
17
18
  get valueWithoutSourceMap(): string;
18
19
  get value(): string;
19
- get currentLineEnd(): {
20
- line: number;
21
- column: number;
22
- };
23
- get currentLineStart(): {
24
- line: number;
25
- column: number;
26
- };
27
20
  }
@@ -3,7 +3,6 @@ export class OutFile {
3
3
  constructor(name, sourceFile) {
4
4
  this.name = name;
5
5
  this.sourceFile = sourceFile;
6
- this.lines = [];
7
6
  this.level = 0;
8
7
  this.indentSpaces = 2;
9
8
  this.sm = new SourceNode(0, 0, sourceFile);
@@ -17,17 +16,20 @@ export class OutFile {
17
16
  this.level--;
18
17
  }
19
18
  }
19
+ get currentIndent() {
20
+ return ' '.repeat(this.level * this.indentSpaces);
21
+ }
20
22
  clear() {
21
23
  this.sm = new SourceNode(0, 0, this.sourceFile);
22
24
  }
23
- append(s) {
24
- if (this.lines.length === 0)
25
- this.lines.push('');
26
- this.lines[this.lines.length - 1] += s;
25
+ printn(line, start, name, end) {
26
+ this.write(this.currentIndent + line, start, name, end);
27
27
  }
28
28
  print(line, start, name, end) {
29
- const chunk = ' '.repeat(this.level * this.indentSpaces) + line + '\n';
30
- this.lines.push(chunk);
29
+ this.write(this.currentIndent + line + '\n', start, name, end);
30
+ }
31
+ write(line, start, name, end) {
32
+ const chunk = line;
31
33
  if (start) {
32
34
  this.sm.add(new SourceNode(start.line, start.column, this.sourceFile, chunk, name));
33
35
  }
@@ -37,12 +39,9 @@ export class OutFile {
37
39
  if (end) {
38
40
  this.sm.add(new SourceNode(end.line, end.column, this.sourceFile));
39
41
  }
40
- return this;
41
42
  }
42
- loc(location, name) {
43
- if (!location)
44
- return this;
45
- return this;
43
+ nl() {
44
+ this.write('\n');
46
45
  }
47
46
  get sourceMap() {
48
47
  return this.sm.toStringWithSourceMap({ file: this.name }).map.toJSON();
@@ -58,18 +57,4 @@ export class OutFile {
58
57
  `ceMappingURL=data:application/json,${encodeURIComponent(map.toString())}`;
59
58
  return res;
60
59
  }
61
- get currentLineEnd() {
62
- var _a, _b;
63
- return {
64
- line: this.lines.length,
65
- column: (_b = (_a = this.lines.at(-1)) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0,
66
- };
67
- }
68
- get currentLineStart() {
69
- var _a, _b, _c;
70
- return {
71
- line: this.lines.length + 1,
72
- column: (_c = (_b = (_a = this.lines.at(-1)) === null || _a === void 0 ? void 0 : _a.match(/^\s*/)) === null || _b === void 0 ? void 0 : _b[0].length) !== null && _c !== void 0 ? _c : 0,
73
- };
74
- }
75
60
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "harmonyc",
3
3
  "description": "Harmony Code - model-driven BDD for Vitest",
4
- "version": "0.17.0",
4
+ "version": "0.18.1",
5
5
  "author": "Bernát Kalló",
6
6
  "type": "module",
7
7
  "bin": {