webpipe-js 2.0.27 → 2.0.29

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.
package/dist/index.cjs CHANGED
@@ -29,6 +29,8 @@ __export(index_exports, {
29
29
  formatTags: () => formatTags,
30
30
  formatWhen: () => formatWhen,
31
31
  getPipelineRanges: () => getPipelineRanges,
32
+ getTestLetVariableRanges: () => getTestLetVariableRanges,
33
+ getTestLetVariables: () => getTestLetVariables,
32
34
  getVariableRanges: () => getVariableRanges,
33
35
  parseProgram: () => parseProgram,
34
36
  parseProgramWithDiagnostics: () => parseProgramWithDiagnostics,
@@ -55,6 +57,9 @@ var Parser = class {
55
57
  this.diagnostics = [];
56
58
  this.pipelineRanges = /* @__PURE__ */ new Map();
57
59
  this.variableRanges = /* @__PURE__ */ new Map();
60
+ this.testLetVariables = [];
61
+ this.currentDescribeName = null;
62
+ this.currentTestName = null;
58
63
  this.text = text;
59
64
  this.len = text.length;
60
65
  }
@@ -67,6 +72,9 @@ var Parser = class {
67
72
  getVariableRanges() {
68
73
  return new Map(this.variableRanges);
69
74
  }
75
+ getTestLetVariables() {
76
+ return [...this.testLetVariables];
77
+ }
70
78
  report(message, start, end, severity) {
71
79
  this.diagnostics.push({ message, start, end, severity });
72
80
  }
@@ -1053,7 +1061,18 @@ var Parser = class {
1053
1061
  parseLetBinding() {
1054
1062
  this.expect("let");
1055
1063
  this.skipInlineSpaces();
1064
+ const nameStart = this.pos;
1056
1065
  const name = this.parseIdentifier();
1066
+ const nameEnd = this.pos;
1067
+ if (this.currentDescribeName !== null) {
1068
+ this.testLetVariables.push({
1069
+ name,
1070
+ describeName: this.currentDescribeName,
1071
+ testName: this.currentTestName || void 0,
1072
+ start: nameStart,
1073
+ end: nameEnd
1074
+ });
1075
+ }
1057
1076
  this.skipInlineSpaces();
1058
1077
  this.expect("=");
1059
1078
  this.skipInlineSpaces();
@@ -1111,6 +1130,7 @@ var Parser = class {
1111
1130
  const name = this.consumeWhile((c) => c !== '"');
1112
1131
  this.expect('"');
1113
1132
  this.skipSpaces();
1133
+ this.currentTestName = name;
1114
1134
  const mocks = [];
1115
1135
  while (true) {
1116
1136
  const m = this.tryParse(() => this.parseMock());
@@ -1199,6 +1219,7 @@ var Parser = class {
1199
1219
  if (!c) break;
1200
1220
  conditions.push(c);
1201
1221
  }
1222
+ this.currentTestName = null;
1202
1223
  return {
1203
1224
  name,
1204
1225
  mocks: [...mocks, ...extraMocks],
@@ -1220,6 +1241,7 @@ var Parser = class {
1220
1241
  this.expect('"');
1221
1242
  const inlineComment = this.parseInlineComment();
1222
1243
  this.skipSpaces();
1244
+ this.currentDescribeName = name;
1223
1245
  const variables = [];
1224
1246
  const mocks = [];
1225
1247
  const tests = [];
@@ -1247,6 +1269,7 @@ var Parser = class {
1247
1269
  }
1248
1270
  break;
1249
1271
  }
1272
+ this.currentDescribeName = null;
1250
1273
  return { name, variables, mocks, tests, inlineComment: inlineComment || void 0 };
1251
1274
  }
1252
1275
  };
@@ -1269,6 +1292,21 @@ function getVariableRanges(text) {
1269
1292
  parser.parseProgram();
1270
1293
  return parser.getVariableRanges();
1271
1294
  }
1295
+ function getTestLetVariables(text) {
1296
+ const parser = new Parser(text);
1297
+ parser.parseProgram();
1298
+ return parser.getTestLetVariables();
1299
+ }
1300
+ function getTestLetVariableRanges(text) {
1301
+ const parser = new Parser(text);
1302
+ parser.parseProgram();
1303
+ const variables = parser.getTestLetVariables();
1304
+ const map = /* @__PURE__ */ new Map();
1305
+ for (const v of variables) {
1306
+ map.set(v.name, { start: v.start, end: v.end });
1307
+ }
1308
+ return map;
1309
+ }
1272
1310
  var ParseFailure = class extends Error {
1273
1311
  constructor(message, at) {
1274
1312
  super(message);
@@ -1657,6 +1695,8 @@ function formatWhen(when) {
1657
1695
  formatTags,
1658
1696
  formatWhen,
1659
1697
  getPipelineRanges,
1698
+ getTestLetVariableRanges,
1699
+ getTestLetVariables,
1660
1700
  getVariableRanges,
1661
1701
  parseProgram,
1662
1702
  parseProgramWithDiagnostics,
@@ -212,6 +212,13 @@ interface ParseDiagnostic {
212
212
  end: number;
213
213
  severity: DiagnosticSeverity;
214
214
  }
215
+ interface TestLetVariable {
216
+ name: string;
217
+ describeName: string;
218
+ testName?: string;
219
+ start: number;
220
+ end: number;
221
+ }
215
222
  declare function parseProgram(text: string): Program;
216
223
  declare function parseProgramWithDiagnostics(text: string): {
217
224
  program: Program;
@@ -225,6 +232,11 @@ declare function getVariableRanges(text: string): Map<string, {
225
232
  start: number;
226
233
  end: number;
227
234
  }>;
235
+ declare function getTestLetVariables(text: string): TestLetVariable[];
236
+ declare function getTestLetVariableRanges(text: string): Map<string, {
237
+ start: number;
238
+ end: number;
239
+ }>;
228
240
  declare function printRoute(route: Route): string;
229
241
  declare function printConfig(config: Config): string;
230
242
  declare function printPipeline(pipeline: NamedPipeline): string;
@@ -247,4 +259,4 @@ declare function formatTagExpr(expr: TagExpr): string;
247
259
  declare function formatPipelineRef(ref: PipelineRef): string[];
248
260
  declare function formatWhen(when: When): string;
249
261
 
250
- export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type DispatchBranch, type DomAssertType, type GraphQLSchema, type It, type LetValueFormat, type Mock, type MutationResolver, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type QueryResolver, type ResultBranch, type ResultBranchType, type Route, type Tag, type TagExpr, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTagExpr, formatTags, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
262
+ export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type DispatchBranch, type DomAssertType, type GraphQLSchema, type It, type LetValueFormat, type Mock, type MutationResolver, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type QueryResolver, type ResultBranch, type ResultBranchType, type Route, type Tag, type TagExpr, type TestLetVariable, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTagExpr, formatTags, formatWhen, getPipelineRanges, getTestLetVariableRanges, getTestLetVariables, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
package/dist/index.d.ts CHANGED
@@ -212,6 +212,13 @@ interface ParseDiagnostic {
212
212
  end: number;
213
213
  severity: DiagnosticSeverity;
214
214
  }
215
+ interface TestLetVariable {
216
+ name: string;
217
+ describeName: string;
218
+ testName?: string;
219
+ start: number;
220
+ end: number;
221
+ }
215
222
  declare function parseProgram(text: string): Program;
216
223
  declare function parseProgramWithDiagnostics(text: string): {
217
224
  program: Program;
@@ -225,6 +232,11 @@ declare function getVariableRanges(text: string): Map<string, {
225
232
  start: number;
226
233
  end: number;
227
234
  }>;
235
+ declare function getTestLetVariables(text: string): TestLetVariable[];
236
+ declare function getTestLetVariableRanges(text: string): Map<string, {
237
+ start: number;
238
+ end: number;
239
+ }>;
228
240
  declare function printRoute(route: Route): string;
229
241
  declare function printConfig(config: Config): string;
230
242
  declare function printPipeline(pipeline: NamedPipeline): string;
@@ -247,4 +259,4 @@ declare function formatTagExpr(expr: TagExpr): string;
247
259
  declare function formatPipelineRef(ref: PipelineRef): string[];
248
260
  declare function formatWhen(when: When): string;
249
261
 
250
- export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type DispatchBranch, type DomAssertType, type GraphQLSchema, type It, type LetValueFormat, type Mock, type MutationResolver, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type QueryResolver, type ResultBranch, type ResultBranchType, type Route, type Tag, type TagExpr, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTagExpr, formatTags, formatWhen, getPipelineRanges, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
262
+ export { type Comment, type Condition, type Config, type ConfigProperty, type ConfigType, type ConfigValue, type Describe, type DiagnosticSeverity, type DispatchBranch, type DomAssertType, type GraphQLSchema, type It, type LetValueFormat, type Mock, type MutationResolver, type NamedPipeline, type ParseDiagnostic, type Pipeline, type PipelineRef, type PipelineStep, type Program, type QueryResolver, type ResultBranch, type ResultBranchType, type Route, type Tag, type TagExpr, type TestLetVariable, type Variable, type When, formatConfigValue, formatPipelineRef, formatPipelineStep, formatStepConfig, formatTag, formatTagExpr, formatTags, formatWhen, getPipelineRanges, getTestLetVariableRanges, getTestLetVariables, getVariableRanges, parseProgram, parseProgramWithDiagnostics, prettyPrint, printComment, printCondition, printConfig, printDescribe, printGraphQLSchema, printMock, printMutationResolver, printPipeline, printQueryResolver, printRoute, printTest, printVariable };
package/dist/index.mjs CHANGED
@@ -5,6 +5,9 @@ var Parser = class {
5
5
  this.diagnostics = [];
6
6
  this.pipelineRanges = /* @__PURE__ */ new Map();
7
7
  this.variableRanges = /* @__PURE__ */ new Map();
8
+ this.testLetVariables = [];
9
+ this.currentDescribeName = null;
10
+ this.currentTestName = null;
8
11
  this.text = text;
9
12
  this.len = text.length;
10
13
  }
@@ -17,6 +20,9 @@ var Parser = class {
17
20
  getVariableRanges() {
18
21
  return new Map(this.variableRanges);
19
22
  }
23
+ getTestLetVariables() {
24
+ return [...this.testLetVariables];
25
+ }
20
26
  report(message, start, end, severity) {
21
27
  this.diagnostics.push({ message, start, end, severity });
22
28
  }
@@ -1003,7 +1009,18 @@ var Parser = class {
1003
1009
  parseLetBinding() {
1004
1010
  this.expect("let");
1005
1011
  this.skipInlineSpaces();
1012
+ const nameStart = this.pos;
1006
1013
  const name = this.parseIdentifier();
1014
+ const nameEnd = this.pos;
1015
+ if (this.currentDescribeName !== null) {
1016
+ this.testLetVariables.push({
1017
+ name,
1018
+ describeName: this.currentDescribeName,
1019
+ testName: this.currentTestName || void 0,
1020
+ start: nameStart,
1021
+ end: nameEnd
1022
+ });
1023
+ }
1007
1024
  this.skipInlineSpaces();
1008
1025
  this.expect("=");
1009
1026
  this.skipInlineSpaces();
@@ -1061,6 +1078,7 @@ var Parser = class {
1061
1078
  const name = this.consumeWhile((c) => c !== '"');
1062
1079
  this.expect('"');
1063
1080
  this.skipSpaces();
1081
+ this.currentTestName = name;
1064
1082
  const mocks = [];
1065
1083
  while (true) {
1066
1084
  const m = this.tryParse(() => this.parseMock());
@@ -1149,6 +1167,7 @@ var Parser = class {
1149
1167
  if (!c) break;
1150
1168
  conditions.push(c);
1151
1169
  }
1170
+ this.currentTestName = null;
1152
1171
  return {
1153
1172
  name,
1154
1173
  mocks: [...mocks, ...extraMocks],
@@ -1170,6 +1189,7 @@ var Parser = class {
1170
1189
  this.expect('"');
1171
1190
  const inlineComment = this.parseInlineComment();
1172
1191
  this.skipSpaces();
1192
+ this.currentDescribeName = name;
1173
1193
  const variables = [];
1174
1194
  const mocks = [];
1175
1195
  const tests = [];
@@ -1197,6 +1217,7 @@ var Parser = class {
1197
1217
  }
1198
1218
  break;
1199
1219
  }
1220
+ this.currentDescribeName = null;
1200
1221
  return { name, variables, mocks, tests, inlineComment: inlineComment || void 0 };
1201
1222
  }
1202
1223
  };
@@ -1219,6 +1240,21 @@ function getVariableRanges(text) {
1219
1240
  parser.parseProgram();
1220
1241
  return parser.getVariableRanges();
1221
1242
  }
1243
+ function getTestLetVariables(text) {
1244
+ const parser = new Parser(text);
1245
+ parser.parseProgram();
1246
+ return parser.getTestLetVariables();
1247
+ }
1248
+ function getTestLetVariableRanges(text) {
1249
+ const parser = new Parser(text);
1250
+ parser.parseProgram();
1251
+ const variables = parser.getTestLetVariables();
1252
+ const map = /* @__PURE__ */ new Map();
1253
+ for (const v of variables) {
1254
+ map.set(v.name, { start: v.start, end: v.end });
1255
+ }
1256
+ return map;
1257
+ }
1222
1258
  var ParseFailure = class extends Error {
1223
1259
  constructor(message, at) {
1224
1260
  super(message);
@@ -1606,6 +1642,8 @@ export {
1606
1642
  formatTags,
1607
1643
  formatWhen,
1608
1644
  getPipelineRanges,
1645
+ getTestLetVariableRanges,
1646
+ getTestLetVariables,
1609
1647
  getVariableRanges,
1610
1648
  parseProgram,
1611
1649
  parseProgramWithDiagnostics,
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "webpipe-js",
3
- "version": "2.0.27",
3
+ "version": "2.0.29",
4
4
  "description": "Web Pipe parser",
5
5
  "license": "ISC",
6
6
  "author": "William Cotton",
7
- "type": "module",
8
7
  "main": "./dist/index.cjs",
9
8
  "module": "./dist/index.mjs",
10
9
  "types": "./dist/index.d.ts",