@driftsys/markspec 0.12.0 → 0.13.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.
Files changed (317) hide show
  1. package/esm/ast/build.d.ts.map +1 -1
  2. package/esm/ast/build.js +19 -5
  3. package/esm/ast/equivalence.js +14 -2
  4. package/esm/ast/nodes.d.ts +15 -3
  5. package/esm/ast/nodes.d.ts.map +1 -1
  6. package/esm/compiler/inverses.d.ts.map +1 -1
  7. package/esm/compiler/inverses.js +18 -3
  8. package/esm/compiler/mod.d.ts +34 -1
  9. package/esm/compiler/mod.d.ts.map +1 -1
  10. package/esm/compiler/mod.js +112 -48
  11. package/esm/compiler/schema.d.ts +3 -2
  12. package/esm/compiler/schema.d.ts.map +1 -1
  13. package/esm/compiler/schema.js +6 -3
  14. package/esm/config/markspec.d.ts +2 -2
  15. package/esm/config/mod.d.ts.map +1 -1
  16. package/esm/config/mod.js +47 -5
  17. package/esm/criteria/scenarios.d.ts +55 -0
  18. package/esm/criteria/scenarios.d.ts.map +1 -0
  19. package/esm/criteria/scenarios.js +133 -0
  20. package/esm/discovery/mod.d.ts +20 -1
  21. package/esm/discovery/mod.d.ts.map +1 -1
  22. package/esm/discovery/mod.js +105 -17
  23. package/esm/discovery/projects.d.ts +6 -4
  24. package/esm/discovery/projects.d.ts.map +1 -1
  25. package/esm/discovery/projects.js +27 -17
  26. package/esm/formatter/entry_body.d.ts +13 -12
  27. package/esm/formatter/entry_body.d.ts.map +1 -1
  28. package/esm/formatter/entry_body.js +25 -17
  29. package/esm/formatter/feature_file.d.ts +40 -0
  30. package/esm/formatter/feature_file.d.ts.map +1 -0
  31. package/esm/formatter/feature_file.js +88 -0
  32. package/esm/formatter/md_equiv.d.ts +6 -5
  33. package/esm/formatter/md_equiv.d.ts.map +1 -1
  34. package/esm/formatter/md_equiv.js +6 -5
  35. package/esm/formatter/mod.d.ts +25 -3
  36. package/esm/formatter/mod.d.ts.map +1 -1
  37. package/esm/formatter/mod.js +267 -27
  38. package/esm/formatter/tab_markers.d.ts +15 -0
  39. package/esm/formatter/tab_markers.d.ts.map +1 -0
  40. package/esm/formatter/tab_markers.js +133 -0
  41. package/esm/gates/mod.d.ts +2 -2
  42. package/esm/gates/mod.d.ts.map +1 -1
  43. package/esm/gates/mod.js +18 -3
  44. package/esm/gherkin/load.d.ts +35 -0
  45. package/esm/gherkin/load.d.ts.map +1 -0
  46. package/esm/gherkin/load.js +39 -0
  47. package/esm/gherkin/parse.d.ts +11 -0
  48. package/esm/gherkin/parse.d.ts.map +1 -0
  49. package/esm/gherkin/parse.js +311 -0
  50. package/esm/gherkin/position.d.ts +23 -0
  51. package/esm/gherkin/position.d.ts.map +1 -0
  52. package/esm/gherkin/position.js +21 -0
  53. package/esm/gherkin/procedure.d.ts +76 -0
  54. package/esm/gherkin/procedure.d.ts.map +1 -0
  55. package/esm/gherkin/procedure.js +164 -0
  56. package/esm/gherkin/project.d.ts +35 -0
  57. package/esm/gherkin/project.d.ts.map +1 -0
  58. package/esm/gherkin/project.js +64 -0
  59. package/esm/gherkin/role.d.ts +23 -0
  60. package/esm/gherkin/role.d.ts.map +1 -0
  61. package/esm/gherkin/role.js +28 -0
  62. package/esm/gherkin/types.d.ts +118 -0
  63. package/esm/gherkin/types.d.ts.map +1 -0
  64. package/esm/gherkin/types.js +12 -0
  65. package/esm/lock/acquire_compile.d.ts +12 -4
  66. package/esm/lock/acquire_compile.d.ts.map +1 -1
  67. package/esm/lock/acquire_compile.js +15 -5
  68. package/esm/lock/canonical_edges.d.ts +6 -2
  69. package/esm/lock/canonical_edges.d.ts.map +1 -1
  70. package/esm/lock/canonical_edges.js +10 -3
  71. package/esm/lock/model.d.ts +5 -0
  72. package/esm/lock/model.d.ts.map +1 -1
  73. package/esm/lock/parser.d.ts.map +1 -1
  74. package/esm/lock/parser.js +2 -0
  75. package/esm/lock/resolve.d.ts +6 -2
  76. package/esm/lock/resolve.d.ts.map +1 -1
  77. package/esm/lock/resolve.js +36 -4
  78. package/esm/lock/serializer.d.ts.map +1 -1
  79. package/esm/lock/serializer.js +7 -1
  80. package/esm/lock/upstream_deps.js +1 -1
  81. package/esm/mod.d.ts +24 -6
  82. package/esm/mod.d.ts.map +1 -1
  83. package/esm/mod.js +19 -5
  84. package/esm/model/mod.d.ts +43 -2
  85. package/esm/model/mod.d.ts.map +1 -1
  86. package/esm/model/mod.js +1 -1
  87. package/esm/model/relations.d.ts +9 -0
  88. package/esm/model/relations.d.ts.map +1 -1
  89. package/esm/model/relations.js +16 -1
  90. package/esm/parser/attributes.d.ts +82 -3
  91. package/esm/parser/attributes.d.ts.map +1 -1
  92. package/esm/parser/attributes.js +199 -32
  93. package/esm/parser/body_tokens.d.ts +1 -1
  94. package/esm/parser/body_tokens.d.ts.map +1 -1
  95. package/esm/parser/body_tokens.js +49 -35
  96. package/esm/parser/feature_file.d.ts +116 -0
  97. package/esm/parser/feature_file.d.ts.map +1 -0
  98. package/esm/parser/feature_file.js +540 -0
  99. package/esm/parser/markdown.d.ts +7 -0
  100. package/esm/parser/markdown.d.ts.map +1 -1
  101. package/esm/parser/markdown.js +129 -40
  102. package/esm/parser/mod.d.ts +18 -0
  103. package/esm/parser/mod.d.ts.map +1 -1
  104. package/esm/parser/mod.js +51 -0
  105. package/esm/parser/translate.d.ts.map +1 -1
  106. package/esm/parser/translate.js +5 -0
  107. package/esm/refs/mod.d.ts +8 -3
  108. package/esm/refs/mod.d.ts.map +1 -1
  109. package/esm/refs/mod.js +20 -7
  110. package/esm/refs/split.d.ts +58 -0
  111. package/esm/refs/split.d.ts.map +1 -0
  112. package/esm/refs/split.js +137 -0
  113. package/esm/reporter/mod.d.ts +7 -0
  114. package/esm/reporter/mod.d.ts.map +1 -1
  115. package/esm/reporter/mod.js +113 -3
  116. package/esm/sync/mapping.d.ts +4 -3
  117. package/esm/sync/mapping.d.ts.map +1 -1
  118. package/esm/sync/mapping.js +52 -9
  119. package/esm/util/display_id.d.ts +20 -0
  120. package/esm/util/display_id.d.ts.map +1 -0
  121. package/esm/util/display_id.js +19 -0
  122. package/esm/validator/attributes.d.ts.map +1 -1
  123. package/esm/validator/attributes.js +4 -1
  124. package/esm/validator/block_role.d.ts +40 -0
  125. package/esm/validator/block_role.d.ts.map +1 -0
  126. package/esm/validator/block_role.js +109 -0
  127. package/esm/validator/feature_ac.d.ts.map +1 -1
  128. package/esm/validator/feature_ac.js +6 -1
  129. package/esm/validator/feature_parse.d.ts +35 -0
  130. package/esm/validator/feature_parse.d.ts.map +1 -0
  131. package/esm/validator/feature_parse.js +69 -0
  132. package/esm/validator/locators.d.ts +36 -0
  133. package/esm/validator/locators.d.ts.map +1 -0
  134. package/esm/validator/locators.js +184 -0
  135. package/esm/validator/mod.d.ts +10 -1
  136. package/esm/validator/mod.d.ts.map +1 -1
  137. package/esm/validator/mod.js +38 -14
  138. package/esm/validator/normalize.d.ts.map +1 -1
  139. package/esm/validator/normalize.js +8 -3
  140. package/esm/validator/per_type_attrs.d.ts +3 -3
  141. package/esm/validator/per_type_attrs.js +3 -3
  142. package/esm/validator/pipeline.d.ts +10 -16
  143. package/esm/validator/pipeline.d.ts.map +1 -1
  144. package/esm/validator/pipeline.js +37 -16
  145. package/esm/validator/procedure.d.ts +22 -0
  146. package/esm/validator/procedure.d.ts.map +1 -0
  147. package/esm/validator/procedure.js +58 -0
  148. package/esm/validator/trace_types.d.ts.map +1 -1
  149. package/esm/validator/trace_types.js +4 -3
  150. package/esm/validator/traceability.d.ts.map +1 -1
  151. package/esm/validator/traceability.js +4 -1
  152. package/esm/validator/type_resolution.d.ts +5 -3
  153. package/esm/validator/type_resolution.d.ts.map +1 -1
  154. package/esm/validator/type_resolution.js +14 -2
  155. package/esm/validator/types.d.ts +11 -0
  156. package/esm/validator/types.d.ts.map +1 -1
  157. package/esm/validator/types.js +26 -4
  158. package/esm/validator/uxil_family.d.ts +1 -1
  159. package/package.json +3 -1
  160. package/script/ast/build.d.ts.map +1 -1
  161. package/script/ast/build.js +19 -5
  162. package/script/ast/equivalence.js +14 -2
  163. package/script/ast/nodes.d.ts +15 -3
  164. package/script/ast/nodes.d.ts.map +1 -1
  165. package/script/compiler/inverses.d.ts.map +1 -1
  166. package/script/compiler/inverses.js +18 -3
  167. package/script/compiler/mod.d.ts +34 -1
  168. package/script/compiler/mod.d.ts.map +1 -1
  169. package/script/compiler/mod.js +110 -46
  170. package/script/compiler/schema.d.ts +3 -2
  171. package/script/compiler/schema.d.ts.map +1 -1
  172. package/script/compiler/schema.js +6 -3
  173. package/script/config/markspec.d.ts +2 -2
  174. package/script/config/mod.d.ts.map +1 -1
  175. package/script/config/mod.js +47 -5
  176. package/script/criteria/scenarios.d.ts +55 -0
  177. package/script/criteria/scenarios.d.ts.map +1 -0
  178. package/script/criteria/scenarios.js +139 -0
  179. package/script/discovery/mod.d.ts +20 -1
  180. package/script/discovery/mod.d.ts.map +1 -1
  181. package/script/discovery/mod.js +106 -17
  182. package/script/discovery/projects.d.ts +6 -4
  183. package/script/discovery/projects.d.ts.map +1 -1
  184. package/script/discovery/projects.js +27 -17
  185. package/script/formatter/entry_body.d.ts +13 -12
  186. package/script/formatter/entry_body.d.ts.map +1 -1
  187. package/script/formatter/entry_body.js +25 -17
  188. package/script/formatter/feature_file.d.ts +40 -0
  189. package/script/formatter/feature_file.d.ts.map +1 -0
  190. package/script/formatter/feature_file.js +92 -0
  191. package/script/formatter/md_equiv.d.ts +6 -5
  192. package/script/formatter/md_equiv.d.ts.map +1 -1
  193. package/script/formatter/md_equiv.js +6 -5
  194. package/script/formatter/mod.d.ts +25 -3
  195. package/script/formatter/mod.d.ts.map +1 -1
  196. package/script/formatter/mod.js +266 -26
  197. package/script/formatter/tab_markers.d.ts +15 -0
  198. package/script/formatter/tab_markers.d.ts.map +1 -0
  199. package/script/formatter/tab_markers.js +141 -0
  200. package/script/gates/mod.d.ts +2 -2
  201. package/script/gates/mod.d.ts.map +1 -1
  202. package/script/gates/mod.js +18 -3
  203. package/script/gherkin/load.d.ts +35 -0
  204. package/script/gherkin/load.d.ts.map +1 -0
  205. package/script/gherkin/load.js +76 -0
  206. package/script/gherkin/parse.d.ts +11 -0
  207. package/script/gherkin/parse.d.ts.map +1 -0
  208. package/script/gherkin/parse.js +314 -0
  209. package/script/gherkin/position.d.ts +23 -0
  210. package/script/gherkin/position.d.ts.map +1 -0
  211. package/script/gherkin/position.js +24 -0
  212. package/script/gherkin/procedure.d.ts +76 -0
  213. package/script/gherkin/procedure.d.ts.map +1 -0
  214. package/script/gherkin/procedure.js +169 -0
  215. package/script/gherkin/project.d.ts +35 -0
  216. package/script/gherkin/project.d.ts.map +1 -0
  217. package/script/gherkin/project.js +67 -0
  218. package/script/gherkin/role.d.ts +23 -0
  219. package/script/gherkin/role.d.ts.map +1 -0
  220. package/script/gherkin/role.js +31 -0
  221. package/script/gherkin/types.d.ts +118 -0
  222. package/script/gherkin/types.d.ts.map +1 -0
  223. package/script/gherkin/types.js +13 -0
  224. package/script/lock/acquire_compile.d.ts +12 -4
  225. package/script/lock/acquire_compile.d.ts.map +1 -1
  226. package/script/lock/acquire_compile.js +15 -5
  227. package/script/lock/canonical_edges.d.ts +6 -2
  228. package/script/lock/canonical_edges.d.ts.map +1 -1
  229. package/script/lock/canonical_edges.js +10 -3
  230. package/script/lock/model.d.ts +5 -0
  231. package/script/lock/model.d.ts.map +1 -1
  232. package/script/lock/parser.d.ts.map +1 -1
  233. package/script/lock/parser.js +2 -0
  234. package/script/lock/resolve.d.ts +6 -2
  235. package/script/lock/resolve.d.ts.map +1 -1
  236. package/script/lock/resolve.js +36 -4
  237. package/script/lock/serializer.d.ts.map +1 -1
  238. package/script/lock/serializer.js +7 -1
  239. package/script/lock/upstream_deps.js +1 -1
  240. package/script/mod.d.ts +24 -6
  241. package/script/mod.d.ts.map +1 -1
  242. package/script/mod.js +48 -6
  243. package/script/model/mod.d.ts +43 -2
  244. package/script/model/mod.d.ts.map +1 -1
  245. package/script/model/mod.js +2 -1
  246. package/script/model/relations.d.ts +9 -0
  247. package/script/model/relations.d.ts.map +1 -1
  248. package/script/model/relations.js +17 -1
  249. package/script/parser/attributes.d.ts +82 -3
  250. package/script/parser/attributes.d.ts.map +1 -1
  251. package/script/parser/attributes.js +205 -33
  252. package/script/parser/body_tokens.d.ts +1 -1
  253. package/script/parser/body_tokens.d.ts.map +1 -1
  254. package/script/parser/body_tokens.js +49 -35
  255. package/script/parser/feature_file.d.ts +116 -0
  256. package/script/parser/feature_file.d.ts.map +1 -0
  257. package/script/parser/feature_file.js +548 -0
  258. package/script/parser/markdown.d.ts +7 -0
  259. package/script/parser/markdown.d.ts.map +1 -1
  260. package/script/parser/markdown.js +128 -39
  261. package/script/parser/mod.d.ts +18 -0
  262. package/script/parser/mod.d.ts.map +1 -1
  263. package/script/parser/mod.js +52 -1
  264. package/script/parser/translate.d.ts.map +1 -1
  265. package/script/parser/translate.js +5 -0
  266. package/script/refs/mod.d.ts +8 -3
  267. package/script/refs/mod.d.ts.map +1 -1
  268. package/script/refs/mod.js +20 -7
  269. package/script/refs/split.d.ts +58 -0
  270. package/script/refs/split.d.ts.map +1 -0
  271. package/script/refs/split.js +145 -0
  272. package/script/reporter/mod.d.ts +7 -0
  273. package/script/reporter/mod.d.ts.map +1 -1
  274. package/script/reporter/mod.js +113 -3
  275. package/script/sync/mapping.d.ts +4 -3
  276. package/script/sync/mapping.d.ts.map +1 -1
  277. package/script/sync/mapping.js +52 -9
  278. package/script/util/display_id.d.ts +20 -0
  279. package/script/util/display_id.d.ts.map +1 -0
  280. package/script/util/display_id.js +22 -0
  281. package/script/validator/attributes.d.ts.map +1 -1
  282. package/script/validator/attributes.js +4 -1
  283. package/script/validator/block_role.d.ts +40 -0
  284. package/script/validator/block_role.d.ts.map +1 -0
  285. package/script/validator/block_role.js +112 -0
  286. package/script/validator/feature_ac.d.ts.map +1 -1
  287. package/script/validator/feature_ac.js +6 -1
  288. package/script/validator/feature_parse.d.ts +35 -0
  289. package/script/validator/feature_parse.d.ts.map +1 -0
  290. package/script/validator/feature_parse.js +73 -0
  291. package/script/validator/locators.d.ts +36 -0
  292. package/script/validator/locators.d.ts.map +1 -0
  293. package/script/validator/locators.js +188 -0
  294. package/script/validator/mod.d.ts +10 -1
  295. package/script/validator/mod.d.ts.map +1 -1
  296. package/script/validator/mod.js +38 -14
  297. package/script/validator/normalize.d.ts.map +1 -1
  298. package/script/validator/normalize.js +8 -3
  299. package/script/validator/per_type_attrs.d.ts +3 -3
  300. package/script/validator/per_type_attrs.js +3 -3
  301. package/script/validator/pipeline.d.ts +10 -16
  302. package/script/validator/pipeline.d.ts.map +1 -1
  303. package/script/validator/pipeline.js +36 -16
  304. package/script/validator/procedure.d.ts +22 -0
  305. package/script/validator/procedure.d.ts.map +1 -0
  306. package/script/validator/procedure.js +61 -0
  307. package/script/validator/trace_types.d.ts.map +1 -1
  308. package/script/validator/trace_types.js +4 -3
  309. package/script/validator/traceability.d.ts.map +1 -1
  310. package/script/validator/traceability.js +4 -1
  311. package/script/validator/type_resolution.d.ts +5 -3
  312. package/script/validator/type_resolution.d.ts.map +1 -1
  313. package/script/validator/type_resolution.js +14 -2
  314. package/script/validator/types.d.ts +11 -0
  315. package/script/validator/types.d.ts.map +1 -1
  316. package/script/validator/types.js +27 -4
  317. package/script/validator/uxil_family.d.ts +1 -1
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @module core/gherkin/load
3
+ *
4
+ * Lazy loader for the `@cucumber/gherkin` parser. The parser is imported
5
+ * dynamically, so commands that never read Gherkin blocks do not load it.
6
+ */
7
+ import type { Dialect } from "@cucumber/gherkin";
8
+ import type { GherkinDocument } from "@cucumber/messages";
9
+ /** The parts of the Gherkin parser that MarkSpec uses. */
10
+ export interface GherkinApi {
11
+ /**
12
+ * Parse Gherkin source text. Builds a new parser for each call, because
13
+ * the parser keeps state. Throws the library's composite error when the
14
+ * text is not valid Gherkin.
15
+ */
16
+ parse(text: string): GherkinDocument;
17
+ /** Language dialects, keyed by language code (for example `fr`). */
18
+ readonly dialects: Record<string, Dialect>;
19
+ }
20
+ /** The two parser modules, as the importer returns them. */
21
+ type ParserModules = [
22
+ typeof import("@cucumber/gherkin"),
23
+ typeof import("@cucumber/messages")
24
+ ];
25
+ /**
26
+ * Load the Gherkin parser. The result is cached; a failed load is not
27
+ * cached, so a later call tries again.
28
+ *
29
+ * @param importer - Replaces the module import. Internal, for tests.
30
+ */
31
+ export declare function loadGherkin(importer?: () => Promise<ParserModules>): Promise<GherkinApi>;
32
+ /** The parser when it is already loaded, otherwise `undefined`. */
33
+ export declare function loadedGherkin(): GherkinApi | undefined;
34
+ export {};
35
+ //# sourceMappingURL=load.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../src/gherkin/load.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,0DAA0D;AAC1D,MAAM,WAAW,UAAU;IACzB;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,CAAC;IACrC,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C;AAKD,4DAA4D;AAC5D,KAAK,aAAa,GAAG;IACnB,cAAc,mBAAmB,CAAC;IAClC,cAAc,oBAAoB,CAAC;CACpC,CAAC;AASF;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,QAAQ,GAAE,MAAM,OAAO,CAAC,aAAa,CAAiB,GACrD,OAAO,CAAC,UAAU,CAAC,CAuBrB;AAED,mEAAmE;AACnE,wBAAgB,aAAa,IAAI,UAAU,GAAG,SAAS,CAEtD"}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/gherkin/load
4
+ *
5
+ * Lazy loader for the `@cucumber/gherkin` parser. The parser is imported
6
+ * dynamically, so commands that never read Gherkin blocks do not load it.
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
20
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
21
+ }) : function(o, v) {
22
+ o["default"] = v;
23
+ });
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.loadGherkin = loadGherkin;
43
+ exports.loadedGherkin = loadedGherkin;
44
+ let loaded;
45
+ let pending;
46
+ /** Imports the two parser modules. */
47
+ const importModules = () => Promise.all([
48
+ Promise.resolve().then(() => __importStar(require("@cucumber/gherkin"))),
49
+ Promise.resolve().then(() => __importStar(require("@cucumber/messages"))),
50
+ ]);
51
+ /**
52
+ * Load the Gherkin parser. The result is cached; a failed load is not
53
+ * cached, so a later call tries again.
54
+ *
55
+ * @param importer - Replaces the module import. Internal, for tests.
56
+ */
57
+ function loadGherkin(importer = importModules) {
58
+ if (loaded)
59
+ return Promise.resolve(loaded);
60
+ pending ??= importer().then(([{ AstBuilder, GherkinClassicTokenMatcher, Parser, dialects }, { IdGenerator },]) => {
61
+ const api = {
62
+ parse: (text) => new Parser(new AstBuilder(IdGenerator.incrementing()), new GherkinClassicTokenMatcher()).parse(text),
63
+ dialects,
64
+ };
65
+ loaded = api;
66
+ return api;
67
+ }).catch((err) => {
68
+ pending = undefined;
69
+ throw err;
70
+ });
71
+ return pending;
72
+ }
73
+ /** The parser when it is already loaded, otherwise `undefined`. */
74
+ function loadedGherkin() {
75
+ return loaded;
76
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @module core/gherkin/parse
3
+ *
4
+ * Wraps, parses and normalizes one Gherkin block into a {@linkcode FeatureAst}.
5
+ * The function is pure: it takes the loaded parser as an argument.
6
+ */
7
+ import type { GherkinApi } from "./load.js";
8
+ import type { FeatureParse } from "./types.js";
9
+ /** Parse and normalize one Gherkin block. */
10
+ export declare function parseFeature(api: GherkinApi, source: string): FeatureParse;
11
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/gherkin/parse.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAEV,YAAY,EAMb,MAAM,YAAY,CAAC;AA4DpB,6CAA6C;AAC7C,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAoQ1E"}
@@ -0,0 +1,314 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/gherkin/parse
4
+ *
5
+ * Wraps, parses and normalizes one Gherkin block into a {@linkcode FeatureAst}.
6
+ * The function is pure: it takes the loaded parser as an argument.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.parseFeature = parseFeature;
10
+ const LANGUAGE_RE = /^\s*#\s*language\s*:\s*([A-Za-z-]+)\s*$/;
11
+ // `keywordType` values of `StepKeywordType` in `@cucumber/messages`.
12
+ const KEYWORD_BY_TYPE = {
13
+ Context: "given",
14
+ Action: "when",
15
+ Outcome: "then",
16
+ Unknown: "step",
17
+ };
18
+ function wrapSource(api, source) {
19
+ const lines = source.split("\n");
20
+ // The language comment may follow blank or comment lines, as in the parser.
21
+ let start = 0;
22
+ let language = "en";
23
+ let languageLine = 0;
24
+ for (let i = 0; i < lines.length; i++) {
25
+ const trimmed = lines[i].trim();
26
+ if (trimmed !== "" && !trimmed.startsWith("#"))
27
+ break;
28
+ const match = LANGUAGE_RE.exec(lines[i].replace(/\r$/, ""));
29
+ if (match) {
30
+ language = match[1];
31
+ start = i + 1;
32
+ languageLine = i + 1;
33
+ break;
34
+ }
35
+ }
36
+ const featureWords = api.dialects[language]?.feature ?? ["Feature"];
37
+ for (let i = start; i < lines.length; i++) {
38
+ const trimmed = lines[i].trim();
39
+ if (trimmed === "" || trimmed.startsWith("#") || trimmed.startsWith("@"))
40
+ continue;
41
+ if (featureWords.some((word) => trimmed.startsWith(`${word}:`))) {
42
+ return { text: source, language, syntheticLine: 0, languageLine };
43
+ }
44
+ break;
45
+ }
46
+ const synthetic = `${featureWords[0]}:`;
47
+ const wrapped = [...lines.slice(0, start), synthetic, ...lines.slice(start)];
48
+ return {
49
+ text: wrapped.join("\n"),
50
+ language,
51
+ syntheticLine: start + 1,
52
+ languageLine,
53
+ };
54
+ }
55
+ /** Parse and normalize one Gherkin block. */
56
+ function parseFeature(api, source) {
57
+ const wrap = wrapSource(api, source);
58
+ const shift = (line) => wrap.syntheticLine > 0 && line > wrap.syntheticLine ? line - 1 : line;
59
+ let document;
60
+ try {
61
+ document = api.parse(wrap.text);
62
+ }
63
+ catch (err) {
64
+ const first = err
65
+ .errors?.[0];
66
+ const location = first?.location;
67
+ return {
68
+ ok: false,
69
+ line: location ? Math.max(1, shift(location.line)) : 1,
70
+ column: location?.column ?? 1,
71
+ message: first?.message ??
72
+ (err instanceof Error ? err.message : String(err)),
73
+ };
74
+ }
75
+ const parsed = document.feature;
76
+ if (!parsed) {
77
+ return {
78
+ ok: false,
79
+ line: 1,
80
+ column: 1,
81
+ message: "no Feature found in the Gherkin block",
82
+ };
83
+ }
84
+ const sourceLines = source.split("\n");
85
+ // Exclusive end column of a source line, after trailing whitespace.
86
+ const lineEnd = (line) => (sourceLines[line - 1] ?? "").trimEnd().length + 1;
87
+ const sections = [];
88
+ const synthetic = wrap.syntheticLine > 0;
89
+ const section = (keyword, at) => {
90
+ const line = shift(at.line);
91
+ const column = at.column ?? 1;
92
+ sections.push({
93
+ keyword,
94
+ range: {
95
+ start: { line, column },
96
+ end: { line, column: column + keyword.length + 1 },
97
+ },
98
+ });
99
+ };
100
+ if (!synthetic)
101
+ section(parsed.keyword, parsed.location);
102
+ const step = (s) => {
103
+ const keyword = s.keyword.trimEnd();
104
+ const startLine = shift(s.location.line);
105
+ const column = s.location.column ?? 1;
106
+ let endLine = startLine;
107
+ let endColumn = column + s.keyword.length + s.text.length;
108
+ if (s.docString) {
109
+ // The content cannot give the closing line: an empty doc string and
110
+ // one that holds a single blank line both have content "". Find the
111
+ // first line after the opening one that starts with the delimiter.
112
+ const open = shift(s.docString.location.line);
113
+ const delimiter = s.docString.delimiter;
114
+ let close = open + 1;
115
+ while (close < sourceLines.length &&
116
+ !(sourceLines[close - 1] ?? "").trimStart().startsWith(delimiter))
117
+ close++;
118
+ endLine = close;
119
+ endColumn = lineEnd(endLine);
120
+ }
121
+ if (s.dataTable) {
122
+ const last = s.dataTable.rows[s.dataTable.rows.length - 1];
123
+ if (last) {
124
+ endLine = shift(last.location.line);
125
+ endColumn = lineEnd(endLine);
126
+ }
127
+ }
128
+ return {
129
+ keyword,
130
+ normalized: normalizeStep(api, wrap.language, s),
131
+ text: s.text,
132
+ ...(s.docString
133
+ ? {
134
+ docString: {
135
+ ...(s.docString.mediaType
136
+ ? { mediaType: s.docString.mediaType }
137
+ : {}),
138
+ content: s.docString.content,
139
+ },
140
+ }
141
+ : {}),
142
+ ...(s.dataTable
143
+ ? {
144
+ dataTable: s.dataTable.rows.map((r) => r.cells.map((c) => c.value)),
145
+ }
146
+ : {}),
147
+ range: {
148
+ start: { line: startLine, column },
149
+ end: { line: endLine, column: endColumn },
150
+ },
151
+ };
152
+ };
153
+ const examples = (e) => {
154
+ section(e.keyword, e.location);
155
+ const rows = e.tableBody;
156
+ const lastRow = rows[rows.length - 1] ?? e.tableHeader;
157
+ const start = shift(e.location.line);
158
+ return {
159
+ name: e.name.trim(),
160
+ keyword: e.keyword,
161
+ tags: e.tags.map((t) => t.name),
162
+ header: e.tableHeader?.cells.map((c) => c.value) ?? [],
163
+ rows: rows.map((r) => r.cells.map((c) => c.value)),
164
+ range: {
165
+ start: { line: start, column: e.location.column ?? 1 },
166
+ end: lastRow
167
+ ? {
168
+ line: shift(lastRow.location.line),
169
+ column: lineEnd(shift(lastRow.location.line)),
170
+ }
171
+ : {
172
+ line: start,
173
+ column: (e.location.column ?? 1) + e.keyword.length + 1,
174
+ },
175
+ },
176
+ };
177
+ };
178
+ const scenarios = [];
179
+ const scenario = (s, background, ruleName) => {
180
+ section(s.keyword, s.location);
181
+ const steps = s.steps.map(step);
182
+ const exs = s.examples.map(examples);
183
+ const start = shift(s.location.line);
184
+ const column = s.location.column ?? 1;
185
+ const tail = [...steps, ...exs].map((x) => x.range.end);
186
+ const end = tail.length > 0
187
+ ? tail.reduce((a, b) => b.line > a.line || (b.line === a.line && b.column > a.column) ? b : a)
188
+ : { line: start, column: column + s.keyword.length + 1 };
189
+ // Last description line: the last text line of the scenario's own head,
190
+ // ignoring blank and comment lines.
191
+ let descriptionEndLine;
192
+ if (s.description.trim() !== "") {
193
+ // The description ends before the first step, the next tag line or the
194
+ // next structural keyword, whichever comes first.
195
+ let bound = steps[0]?.range.start.line ?? sourceLines.length + 1;
196
+ const dialect = api.dialects[wrap.language];
197
+ const words = dialect
198
+ ? [
199
+ ...dialect.feature,
200
+ ...dialect.background,
201
+ ...dialect.rule,
202
+ ...dialect.scenario,
203
+ ...dialect.scenarioOutline,
204
+ ...dialect.examples,
205
+ ]
206
+ : ["Feature", "Background", "Rule", "Scenario", "Examples"];
207
+ for (let line = start + 1; line < bound; line++) {
208
+ const text = (sourceLines[line - 1] ?? "").trim();
209
+ if (text.startsWith("@") || words.some((w) => text.startsWith(`${w}:`))) {
210
+ bound = line;
211
+ break;
212
+ }
213
+ }
214
+ for (let line = bound - 1; line > start; line--) {
215
+ const text = (sourceLines[line - 1] ?? "").trim();
216
+ if (text !== "" && !text.startsWith("#")) {
217
+ descriptionEndLine = line;
218
+ break;
219
+ }
220
+ }
221
+ }
222
+ scenarios.push({
223
+ name: s.name.trim(),
224
+ keyword: s.keyword,
225
+ tags: s.tags.map((t) => t.name),
226
+ ...(ruleName !== undefined ? { ruleName } : {}),
227
+ description: s.description,
228
+ ...(descriptionEndLine !== undefined ? { descriptionEndLine } : {}),
229
+ isOutline: s.examples.length > 0 ||
230
+ isOutlineKeyword(api, wrap.language, s.keyword),
231
+ background,
232
+ steps,
233
+ examples: exs,
234
+ range: { start: { line: start, column }, end },
235
+ });
236
+ };
237
+ const backgrounds = [];
238
+ const backgroundSteps = (b) => {
239
+ section(b.keyword, b.location);
240
+ const steps = b.steps.map(step);
241
+ backgrounds.push(...steps);
242
+ return steps;
243
+ };
244
+ let featureBackground = [];
245
+ for (const child of parsed.children) {
246
+ if (child.background) {
247
+ featureBackground = [
248
+ ...featureBackground,
249
+ ...backgroundSteps(child.background),
250
+ ];
251
+ }
252
+ else if (child.scenario) {
253
+ scenario(child.scenario, featureBackground, undefined);
254
+ }
255
+ else if (child.rule) {
256
+ const rule = child.rule;
257
+ section(rule.keyword, rule.location);
258
+ let ruleBackground = featureBackground;
259
+ for (const inner of rule.children) {
260
+ if (inner.background) {
261
+ ruleBackground = [
262
+ ...ruleBackground,
263
+ ...backgroundSteps(inner.background),
264
+ ];
265
+ }
266
+ else if (inner.scenario) {
267
+ scenario(inner.scenario, ruleBackground, rule.name.trim());
268
+ }
269
+ }
270
+ }
271
+ }
272
+ // The parser consumes a `# language:` header and does not list it as a
273
+ // comment, so it is added back at its own line.
274
+ const comments = document.comments.map((c) => ({
275
+ line: shift(c.location.line),
276
+ text: c.text.trim(),
277
+ }));
278
+ if (wrap.languageLine > 0 && !comments.some((c) => c.line === wrap.languageLine)) {
279
+ comments.push({
280
+ line: wrap.languageLine,
281
+ text: (sourceLines[wrap.languageLine - 1] ?? "").trim(),
282
+ });
283
+ comments.sort((a, b) => a.line - b.line);
284
+ }
285
+ return {
286
+ ok: true,
287
+ feature: {
288
+ name: parsed.name.trim(),
289
+ keyword: parsed.keyword,
290
+ synthetic,
291
+ language: parsed.language || wrap.language,
292
+ description: parsed.description,
293
+ tags: parsed.tags.map((t) => t.name),
294
+ scenarios,
295
+ backgrounds,
296
+ sections,
297
+ comments,
298
+ },
299
+ };
300
+ }
301
+ function normalizeStep(api, language, s) {
302
+ const type = s.keywordType ?? "Unknown";
303
+ // The parser reports And and But alike as Conjunction. A dialect may use
304
+ // one word for both; such a word counts as `but` only when it is in the
305
+ // `but` table, so a shared word is normalized as `but`.
306
+ if (type !== "Conjunction")
307
+ return KEYWORD_BY_TYPE[type] ?? "step";
308
+ const but = api.dialects[language]?.but ?? ["But "];
309
+ return but.some((word) => word.trim() === s.keyword.trim()) ? "but" : "and";
310
+ }
311
+ function isOutlineKeyword(api, language, keyword) {
312
+ const outline = api.dialects[language]?.scenarioOutline ?? [];
313
+ return outline.includes(keyword);
314
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @module core/gherkin/position
3
+ *
4
+ * Maps a position inside a Gherkin block to a line of the file.
5
+ */
6
+ import type { GherkinRange } from "./types.js";
7
+ import type { Entry } from "../model/mod.js";
8
+ /**
9
+ * Return the 1-based file line of `sourceLine`, a 1-based line of the
10
+ * authored block text of `node` (the same lines `FeatureAst` ranges use).
11
+ * The result matches the lines `buildCriteria` reports and needs no further
12
+ * translation. In Markdown, `bodyStartLine` is a file line and `node.range`
13
+ * is relative to the body. In a source doc comment, `bodyStartLine` stays
14
+ * relative to the extracted comment text, and `translateEntryLocations`
15
+ * (`parser/translate.ts`) shifts `node.range` by the comment's file offset
16
+ * instead; the sum is the file line in both cases.
17
+ */
18
+ export declare function featureFileLine(entry: Entry,
19
+ /** The feature block: a body-AST `FeatureNode`. */
20
+ node: {
21
+ readonly range: GherkinRange;
22
+ }, sourceLine: number): number;
23
+ //# sourceMappingURL=position.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../src/gherkin/position.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,KAAK;AACZ,mDAAmD;AACnD,IAAI,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAA;CAAE,EACtC,UAAU,EAAE,MAAM,GACjB,MAAM,CAGR"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /**
3
+ * @module core/gherkin/position
4
+ *
5
+ * Maps a position inside a Gherkin block to a line of the file.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.featureFileLine = featureFileLine;
9
+ /**
10
+ * Return the 1-based file line of `sourceLine`, a 1-based line of the
11
+ * authored block text of `node` (the same lines `FeatureAst` ranges use).
12
+ * The result matches the lines `buildCriteria` reports and needs no further
13
+ * translation. In Markdown, `bodyStartLine` is a file line and `node.range`
14
+ * is relative to the body. In a source doc comment, `bodyStartLine` stays
15
+ * relative to the extracted comment text, and `translateEntryLocations`
16
+ * (`parser/translate.ts`) shifts `node.range` by the comment's file offset
17
+ * instead; the sum is the file line in both cases.
18
+ */
19
+ function featureFileLine(entry,
20
+ /** The feature block: a body-AST `FeatureNode`. */
21
+ node, sourceLine) {
22
+ const bodyStart = entry.bodyStartLine ?? (entry.location.line + 1);
23
+ return bodyStart + node.range.start.line + sourceLine - 1;
24
+ }
@@ -0,0 +1,76 @@
1
+ /**
2
+ * @module core/gherkin/procedure
3
+ *
4
+ * Procedure view of a Gherkin scenario. This module resolves the role of each
5
+ * step (precondition, action or outcome). It is a pure function of the
6
+ * normalized AST; nothing is stored on the AST.
7
+ */
8
+ import type { FeatureAst, GherkinComment, ScenarioAst, StepAst } from "./types.js";
9
+ /** What a step does in a procedure. */
10
+ export type StepRole = "precondition" | "action" | "outcome";
11
+ /**
12
+ * Resolve the role of each step, in order.
13
+ *
14
+ * `Given` is a precondition, `When` is an action, `Then` is an outcome, and a
15
+ * `*` step is always an action. `And` and `But` take the role of the step
16
+ * before them; a first `And` or `But` is an action.
17
+ */
18
+ export declare function stepRoles(steps: readonly StepAst[]): StepRole[];
19
+ /** A step of the scenario, with its resolved role and where it came from. */
20
+ export interface ProcedureStepRef {
21
+ readonly step: StepAst;
22
+ readonly role: StepRole;
23
+ readonly origin: "background" | "scenario";
24
+ }
25
+ /** One numbered step of a procedure: its setup, actions and expected results. */
26
+ export interface ProcedureStep {
27
+ /** 1-based position in the scenario. */
28
+ readonly n: number;
29
+ /**
30
+ * The `# Step` label above the step's first line, without the `#`
31
+ * (for example `Step 1`). Absent when the step has no label. It never
32
+ * changes `n`.
33
+ */
34
+ readonly label?: string;
35
+ /** Preconditions that follow the first non-precondition step. */
36
+ readonly setup: readonly ProcedureStepRef[];
37
+ readonly actions: readonly ProcedureStepRef[];
38
+ readonly expected: readonly ProcedureStepRef[];
39
+ }
40
+ /** The procedure view of one scenario. */
41
+ export interface ScenarioProcedure {
42
+ /** Background steps, then the leading precondition steps of the scenario. */
43
+ readonly preconditions: readonly ProcedureStepRef[];
44
+ readonly steps: readonly ProcedureStep[];
45
+ /**
46
+ * `# Step` labels inside the scenario's range that do not label a step: one
47
+ * before a leading precondition or a step that does not open a procedure
48
+ * step, one with a description line between it and the step, one with no
49
+ * step after it (including one before `Examples:`), or a
50
+ * second label above the same step. Labels outside every scenario are
51
+ * reported by {@linkcode unplacedStepLabels}.
52
+ */
53
+ readonly unplacedLabels: readonly GherkinComment[];
54
+ }
55
+ /**
56
+ * Derive the procedure view of a scenario.
57
+ *
58
+ * Preconditions are the scenario's background steps followed by its leading
59
+ * precondition steps. The remaining steps are paired in order: an action after
60
+ * an expected result, or a precondition after an action or expected result,
61
+ * opens a new step. Examples of an outline are not expanded.
62
+ *
63
+ * `comments` are the block's comments. A `# Step` comment inside the
64
+ * scenario's range labels the procedure step that starts at the next step
65
+ * line; any other label is returned in `unplacedLabels`.
66
+ */
67
+ export declare function scenarioProcedure(scenario: ScenarioAst, comments?: readonly GherkinComment[]): ScenarioProcedure;
68
+ /**
69
+ * Every `# Step` label of a feature block that labels no step, each once, in
70
+ * document order. A label inside a scenario's range is unplaced when
71
+ * {@linkcode scenarioProcedure} leaves it unplaced; a label outside every
72
+ * scenario (in a Background, a Rule header, after a scenario's last step, or
73
+ * between scenarios) is always unplaced.
74
+ */
75
+ export declare function unplacedStepLabels(feature: FeatureAst): GherkinComment[];
76
+ //# sourceMappingURL=procedure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../../src/gherkin/procedure.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,WAAW,EACX,OAAO,EACR,MAAM,YAAY,CAAC;AAEpB,uCAAuC;AACvC,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE7D;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,QAAQ,EAAE,CAyB/D;AAED,6EAA6E;AAC7E,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,CAAC;CAC5C;AAED,iFAAiF;AACjF,MAAM,WAAW,aAAa;IAC5B,wCAAwC;IACxC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC9C,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;CAChD;AAED,0CAA0C;AAC1C,MAAM,WAAW,iBAAiB;IAChC,6EAA6E;IAC7E,QAAQ,CAAC,aAAa,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACpD,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IACzC;;;;;;;OAOG;IACH,QAAQ,CAAC,cAAc,EAAE,SAAS,cAAc,EAAE,CAAC;CACpD;AASD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,WAAW,EACrB,QAAQ,GAAE,SAAS,cAAc,EAAO,GACvC,iBAAiB,CAgFnB;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,UAAU,GAAG,cAAc,EAAE,CAiBxE"}