@lynxwall/cucumber-tsflow 7.1.2 → 7.3.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 (117) hide show
  1. package/README.md +154 -61
  2. package/lib/api/convert-configuration.d.ts +7 -0
  3. package/lib/api/convert-configuration.js +65 -0
  4. package/lib/api/convert-configuration.js.map +1 -0
  5. package/lib/api/index.d.ts +1 -0
  6. package/lib/api/index.js +1 -0
  7. package/lib/api/index.js.map +1 -1
  8. package/lib/api/load-configuration.d.ts +3 -2
  9. package/lib/api/load-configuration.js +78 -18
  10. package/lib/api/load-configuration.js.map +1 -1
  11. package/lib/api/run-cucumber.d.ts +5 -1
  12. package/lib/api/run-cucumber.js +12 -0
  13. package/lib/api/run-cucumber.js.map +1 -1
  14. package/lib/api/wrapper.mjs +1 -0
  15. package/lib/bindings/binding-context.d.ts +54 -3
  16. package/lib/bindings/binding-context.js +80 -5
  17. package/lib/bindings/binding-context.js.map +1 -1
  18. package/lib/bindings/binding-decorator.js +85 -36
  19. package/lib/bindings/binding-decorator.js.map +1 -1
  20. package/lib/bindings/binding-registry.js +10 -0
  21. package/lib/bindings/binding-registry.js.map +1 -1
  22. package/lib/bindings/hook-decorators.js +44 -19
  23. package/lib/bindings/hook-decorators.js.map +1 -1
  24. package/lib/bindings/step-decorators.js +120 -51
  25. package/lib/bindings/step-decorators.js.map +1 -1
  26. package/lib/bindings/types.js.map +1 -1
  27. package/lib/cli/argv-parser.d.ts +1 -0
  28. package/lib/cli/argv-parser.js +2 -2
  29. package/lib/cli/argv-parser.js.map +1 -1
  30. package/lib/cli/index.js +1 -4
  31. package/lib/cli/index.js.map +1 -1
  32. package/lib/runtime/make-runtime.d.ts +3 -2
  33. package/lib/runtime/make-runtime.js.map +1 -1
  34. package/lib/runtime/message-collector.d.ts +1 -1
  35. package/lib/runtime/message-collector.js.map +1 -1
  36. package/lib/runtime/parallel/adapter.d.ts +3 -2
  37. package/lib/runtime/parallel/adapter.js +2 -1
  38. package/lib/runtime/parallel/adapter.js.map +1 -1
  39. package/lib/runtime/parallel/run-worker.js +3 -2
  40. package/lib/runtime/parallel/run-worker.js.map +1 -1
  41. package/lib/runtime/parallel/worker.d.ts +3 -2
  42. package/lib/runtime/parallel/worker.js +4 -2
  43. package/lib/runtime/parallel/worker.js.map +1 -1
  44. package/lib/runtime/test-case-runner.d.ts +2 -1
  45. package/lib/runtime/test-case-runner.js +8 -5
  46. package/lib/runtime/test-case-runner.js.map +1 -1
  47. package/lib/runtime/{parallel/types.d.ts → types.d.ts} +12 -1
  48. package/lib/runtime/types.js.map +1 -0
  49. package/lib/transpilers/esbuild-transpiler.d.ts +1 -1
  50. package/lib/transpilers/esbuild-transpiler.js.map +1 -1
  51. package/lib/transpilers/esbuild.js +18 -1
  52. package/lib/transpilers/esbuild.js.map +1 -1
  53. package/lib/transpilers/esm/esbuild-transpiler-cjs.js +2174 -0
  54. package/lib/transpilers/esm/esbuild-transpiler.mjs +19 -0
  55. package/lib/transpilers/esm/esbuild.mjs +141 -0
  56. package/lib/transpilers/esm/esmbuild-transpiler.d.ts +4 -0
  57. package/lib/transpilers/esm/esmbuild-transpiler.js +19 -0
  58. package/lib/transpilers/esm/esmbuild-transpiler.js.map +1 -0
  59. package/lib/transpilers/esm/esmbuild.d.ts +12 -0
  60. package/lib/transpilers/esm/esmbuild.js +72 -0
  61. package/lib/transpilers/esm/esmbuild.js.map +1 -0
  62. package/lib/transpilers/esm/esmnode.js +8 -0
  63. package/lib/transpilers/esm/esmnode.js.map +1 -0
  64. package/lib/transpilers/esm/esmvue.js +29 -0
  65. package/lib/transpilers/esm/esmvue.js.map +1 -0
  66. package/lib/transpilers/esm/esnode-loader.mjs +9 -0
  67. package/lib/transpilers/esm/esvue-loader.mjs +9 -0
  68. package/lib/transpilers/esm/loader-utils.mjs +278 -0
  69. package/lib/transpilers/esm/tsnode-esm.js +25 -0
  70. package/lib/transpilers/esm/tsnode-esm.js.map +1 -0
  71. package/lib/{esnode.js → transpilers/esm/tsnode-exp-esm.js} +8 -6
  72. package/lib/transpilers/esm/tsnode-exp-esm.js.map +1 -0
  73. package/lib/transpilers/esm/tsnode-loader.mjs +107 -0
  74. package/lib/transpilers/esm/tsnode-service.mjs +40 -0
  75. package/lib/transpilers/esm/tsvue-esm.d.ts +1 -0
  76. package/lib/{tsvue.js → transpilers/esm/tsvue-esm.js} +8 -5
  77. package/lib/transpilers/esm/tsvue-esm.js.map +1 -0
  78. package/lib/transpilers/esm/tsvue-exp-esm.d.ts +1 -0
  79. package/lib/transpilers/esm/tsvue-exp-esm.js +40 -0
  80. package/lib/transpilers/esm/tsvue-exp-esm.js.map +1 -0
  81. package/lib/transpilers/esm/vue-jsdom-setup.mjs +19 -0
  82. package/lib/transpilers/esm/vue-loader.mjs +113 -0
  83. package/lib/transpilers/esm/vue-sfc-compiler.mjs +216 -0
  84. package/lib/transpilers/esnode.d.ts +1 -0
  85. package/lib/transpilers/esnode.js +8 -0
  86. package/lib/transpilers/esnode.js.map +1 -0
  87. package/lib/transpilers/esvue.d.ts +1 -0
  88. package/lib/transpilers/esvue.js +29 -0
  89. package/lib/transpilers/esvue.js.map +1 -0
  90. package/lib/transpilers/tsnode-exp.d.ts +1 -0
  91. package/lib/transpilers/tsnode-exp.js +19 -0
  92. package/lib/transpilers/tsnode-exp.js.map +1 -0
  93. package/lib/transpilers/tsnode.d.ts +1 -0
  94. package/lib/{tsnode.js → transpilers/tsnode.js} +5 -2
  95. package/lib/transpilers/tsnode.js.map +1 -0
  96. package/lib/transpilers/tsvue-exp.d.ts +1 -0
  97. package/lib/transpilers/tsvue-exp.js +40 -0
  98. package/lib/transpilers/tsvue-exp.js.map +1 -0
  99. package/lib/transpilers/tsvue.d.ts +1 -0
  100. package/lib/{esvue.js → transpilers/tsvue.js} +9 -7
  101. package/lib/transpilers/tsvue.js.map +1 -0
  102. package/lib/transpilers/vue-sfc/index.js.map +1 -1
  103. package/lib/tsconfig.node.tsbuildinfo +1 -1
  104. package/lib/version.d.ts +1 -1
  105. package/lib/version.js +1 -1
  106. package/lib/version.js.map +1 -1
  107. package/package.json +38 -25
  108. package/lib/esnode.js.map +0 -1
  109. package/lib/esvue.js.map +0 -1
  110. package/lib/runtime/parallel/types.js.map +0 -1
  111. package/lib/tsnode.js.map +0 -1
  112. package/lib/tsvue.js.map +0 -1
  113. /package/lib/runtime/{parallel/types.js → types.js} +0 -0
  114. /package/lib/{esnode.d.ts → transpilers/esm/esmnode.d.ts} +0 -0
  115. /package/lib/{esvue.d.ts → transpilers/esm/esmvue.d.ts} +0 -0
  116. /package/lib/{tsnode.d.ts → transpilers/esm/tsnode-esm.d.ts} +0 -0
  117. /package/lib/{tsvue.d.ts → transpilers/esm/tsnode-exp-esm.d.ts} +0 -0
@@ -0,0 +1,19 @@
1
+ // This file gets transpiled to CJS via scripts/build-esm-transpiler-cjs as part of the build
2
+
3
+ import { transpileCode } from './esbuild.mjs';
4
+
5
+ export function create(_createOptions) {
6
+ return {
7
+ transpile(input, options) {
8
+ const result = transpileCode(input, options.fileName);
9
+
10
+ return {
11
+ outputText: result.output,
12
+ sourceMapText: result.sourceMap
13
+ };
14
+ }
15
+ };
16
+ }
17
+
18
+ // Also export as default in case ts-node expects that
19
+ export default { create };
@@ -0,0 +1,141 @@
1
+ import { transformSync } from 'esbuild';
2
+ import path from 'path';
3
+ import { loadConfig } from 'tsconfig-paths';
4
+ import { pathToFileURL } from 'url';
5
+
6
+ export const defaultOptions = {
7
+ debug: true
8
+ };
9
+
10
+ // Cache for tsconfig data
11
+ let tsconfigCache = null;
12
+
13
+ function loadTsConfigPaths() {
14
+ if (tsconfigCache) return tsconfigCache;
15
+
16
+ try {
17
+ const configLoaderResult = loadConfig(process.cwd());
18
+ if (configLoaderResult.resultType === 'success') {
19
+ tsconfigCache = {
20
+ absoluteBaseUrl: configLoaderResult.absoluteBaseUrl,
21
+ paths: configLoaderResult.paths
22
+ };
23
+ }
24
+ } catch (error) {
25
+ console.error('Failed to load tsconfig for aliases:', error);
26
+ }
27
+
28
+ return tsconfigCache || { paths: {} };
29
+ }
30
+
31
+ // Add this function to handle path replacements
32
+ function rewritePathMappings(code) {
33
+ const { absoluteBaseUrl, paths } = loadTsConfigPaths();
34
+
35
+ if (!paths || !absoluteBaseUrl) return code;
36
+
37
+ let modifiedCode = code;
38
+
39
+ // Process each path mapping
40
+ for (const [pattern, replacements] of Object.entries(paths)) {
41
+ // Convert @fixtures/* to a regex pattern
42
+ const searchPattern = pattern.replace('/*', '');
43
+ const replacementPath = replacements[0].replace('/*', '');
44
+
45
+ // Create regex to match imports/exports
46
+ const regex = new RegExp(`(from\\s+['"])${searchPattern}(/[^'"]+)?(['"])`, 'g');
47
+
48
+ modifiedCode = modifiedCode.replace(regex, (match, prefix, subPath, suffix) => {
49
+ // If subPath is provided, remove leading slash
50
+ const pathSuffix = subPath ? subPath.substring(1) : '';
51
+ // Calculate the absolute path
52
+ const absolutePath = path.resolve(absoluteBaseUrl, replacementPath, pathSuffix);
53
+ // Convert to file URL for ESM
54
+ const fileUrl = pathToFileURL(absolutePath).href;
55
+
56
+ return `${prefix}${fileUrl}${suffix}`;
57
+ });
58
+ }
59
+
60
+ return modifiedCode;
61
+ }
62
+ const commonOptions = {
63
+ format: 'esm',
64
+ logLevel: 'info',
65
+ target: ['es2022'],
66
+ minify: false,
67
+ sourcemap: 'external',
68
+ platform: 'node'
69
+ };
70
+
71
+ if (process.env.CUCUMBER_EXPERIMENTAL_DECORATORS === 'true') {
72
+ commonOptions.tsconfigRaw = {
73
+ compilerOptions: {
74
+ experimentalDecorators: true,
75
+ importsNotUsedAsValues: 'remove',
76
+ strict: true
77
+ }
78
+ };
79
+ } else {
80
+ commonOptions.tsconfigRaw = {
81
+ compilerOptions: {
82
+ importsNotUsedAsValues: 'remove',
83
+ strict: true
84
+ }
85
+ };
86
+ }
87
+
88
+ export const loaders = {
89
+ '.js': 'js',
90
+ '.mjs': 'js',
91
+ '.cjs': 'js',
92
+ '.jsx': 'jsx',
93
+ '.ts': 'ts',
94
+ '.tsx': 'tsx',
95
+ '.json': 'json'
96
+ };
97
+
98
+ export const supports = filename => {
99
+ // Don't transpile TypeScript files - they're handled by TypeScript compiler
100
+ if (filename.endsWith('.ts') || filename.endsWith('.tsx')) return false;
101
+
102
+ // Don't transpile cucumber-tsflow's lib files - they're CommonJS
103
+ if (filename.includes('cucumber-tsflow/lib') || filename.includes('cucumber-tsflow\\lib')) {
104
+ return false;
105
+ }
106
+
107
+ // Don't transpile node_modules
108
+ if (filename.includes('node_modules')) return false;
109
+
110
+ // Only transpile files in the test project
111
+ if (!filename.includes('cucumber-tsflow-specs')) return false;
112
+
113
+ return path.extname(filename) in loaders;
114
+ };
115
+
116
+ const getLoaders = options => {
117
+ const ret = { ...loaders };
118
+ if (typeof options.esbuild?.loader === 'object') {
119
+ for (const [e, l] of Object.entries(options.esbuild.loader)) ret[e] = l;
120
+ }
121
+ return ret;
122
+ };
123
+
124
+ // In esbuild.mjs
125
+ export const transpileCode = (code, filename, ext, _options) => {
126
+ const options = { ...defaultOptions, ..._options };
127
+ const loadersMap = getLoaders(options);
128
+ const loaderExt = ext != undefined ? ext : path.extname(filename);
129
+
130
+ // Rewrite path mappings before transpiling
131
+ let processedCode = rewritePathMappings(code);
132
+
133
+ const ret = transformSync(processedCode, {
134
+ ...commonOptions,
135
+ ...(options.esbuild || {}),
136
+ loader: loadersMap[loaderExt],
137
+ sourcefile: filename
138
+ });
139
+
140
+ return { output: ret.code, sourceMap: ret.map };
141
+ };
@@ -0,0 +1,4 @@
1
+ import { TranspileOptions, Transpiler, TranspileOutput } from 'ts-node';
2
+ export declare class EsmbuildTranspiler implements Transpiler {
3
+ transpile: (input: string, options: TranspileOptions) => TranspileOutput;
4
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EsmbuildTranspiler = void 0;
4
+ const esmbuild_1 = require("./esmbuild");
5
+ const create = (_createOptions) => {
6
+ return new EsmbuildTranspiler();
7
+ };
8
+ class EsmbuildTranspiler {
9
+ transpile = (input, options) => {
10
+ const result = (0, esmbuild_1.transpileCode)(input, options.fileName);
11
+ return {
12
+ outputText: result.output,
13
+ sourceMapText: result.sourceMap
14
+ };
15
+ };
16
+ }
17
+ exports.EsmbuildTranspiler = EsmbuildTranspiler;
18
+ exports.create = create;
19
+ //# sourceMappingURL=esmbuild-transpiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esmbuild-transpiler.js","sourceRoot":"","sources":["../../../src/transpilers/esm/esmbuild-transpiler.ts"],"names":[],"mappings":";;;AACA,yCAA2C;AAE3C,MAAM,MAAM,GAAG,CAAC,cAAuC,EAAc,EAAE;IACtE,OAAO,IAAI,kBAAkB,EAAE,CAAC;AACjC,CAAC,CAAC;AAEF,MAAa,kBAAkB;IAC9B,SAAS,GAAG,CAAC,KAAa,EAAE,OAAyB,EAAmB,EAAE;QACzE,MAAM,MAAM,GAAG,IAAA,wBAAa,EAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEtD,OAAO;YACN,UAAU,EAAE,MAAM,CAAC,MAAM;YACzB,aAAa,EAAE,MAAM,CAAC,SAAS;SACZ,CAAC;IACtB,CAAC,CAAC;CACF;AATD,gDASC;AAED,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC","sourcesContent":["import { CreateTranspilerOptions, TranspileOptions, Transpiler, TranspileOutput } from 'ts-node';\r\nimport { transpileCode } from './esmbuild';\r\n\r\nconst create = (_createOptions: CreateTranspilerOptions): Transpiler => {\r\n\treturn new EsmbuildTranspiler();\r\n};\r\n\r\nexport class EsmbuildTranspiler implements Transpiler {\r\n\ttranspile = (input: string, options: TranspileOptions): TranspileOutput => {\r\n\t\tconst result = transpileCode(input, options.fileName);\r\n\r\n\t\treturn {\r\n\t\t\toutputText: result.output,\r\n\t\t\tsourceMapText: result.sourceMap\r\n\t\t} as TranspileOutput;\r\n\t};\r\n}\r\n\r\nexports.create = create;\r\n"]}
@@ -0,0 +1,12 @@
1
+ import { Loader, CommonOptions, TransformOptions, BuildOptions } from 'esbuild';
2
+ export type TranspileOptions = {
3
+ debug: boolean;
4
+ esbuild?: CommonOptions & TransformOptions & BuildOptions;
5
+ };
6
+ export type TranspileResults = {
7
+ output: string;
8
+ sourceMap?: string;
9
+ };
10
+ export declare const loaders: Record<string, Loader>;
11
+ export declare const supports: (filename: string) => boolean;
12
+ export declare const transpileCode: (code: string, filename: string, ext?: string, _options?: Partial<TranspileOptions>) => TranspileResults;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.transpileCode = exports.supports = exports.loaders = void 0;
7
+ const esbuild_1 = require("esbuild");
8
+ const path_1 = __importDefault(require("path"));
9
+ const defaultOptions = {
10
+ debug: true
11
+ };
12
+ const commonOptions = {
13
+ format: 'esm',
14
+ logLevel: 'info',
15
+ target: [`esnext`],
16
+ minify: false,
17
+ sourcemap: 'external'
18
+ };
19
+ if (global.experimentalDecorators) {
20
+ commonOptions.tsconfigRaw = {
21
+ compilerOptions: {
22
+ experimentalDecorators: true,
23
+ importsNotUsedAsValues: 'remove',
24
+ strict: true
25
+ }
26
+ };
27
+ }
28
+ else {
29
+ commonOptions.tsconfigRaw = {
30
+ compilerOptions: {
31
+ importsNotUsedAsValues: 'remove',
32
+ strict: true
33
+ }
34
+ };
35
+ }
36
+ exports.loaders = {
37
+ '.js': 'js',
38
+ '.mjs': 'js',
39
+ '.cjs': 'js',
40
+ '.jsx': 'jsx',
41
+ '.ts': 'ts',
42
+ '.tsx': 'tsx',
43
+ '.json': 'json'
44
+ };
45
+ const supports = (filename) => {
46
+ if (filename.includes('node_modules') || filename.includes('cucumber-tsflow/lib'))
47
+ return false;
48
+ return path_1.default.extname(filename) in exports.loaders;
49
+ };
50
+ exports.supports = supports;
51
+ const getLoaders = (options) => {
52
+ const ret = { ...exports.loaders };
53
+ if (typeof options.esbuild?.loader == 'object') {
54
+ for (const [e, l] of Object.entries(options.esbuild.loader))
55
+ ret[e] = l;
56
+ }
57
+ return ret;
58
+ };
59
+ const transpileCode = (code, filename, ext, _options) => {
60
+ const options = { ...defaultOptions, ..._options };
61
+ const loaders = getLoaders(options);
62
+ const loaderExt = ext != undefined ? ext : path_1.default.extname(filename);
63
+ const ret = (0, esbuild_1.transformSync)(code, {
64
+ ...commonOptions,
65
+ ...options.esbuild,
66
+ loader: loaders[loaderExt],
67
+ sourcefile: filename
68
+ });
69
+ return { output: ret.code, sourceMap: ret.map };
70
+ };
71
+ exports.transpileCode = transpileCode;
72
+ //# sourceMappingURL=esmbuild.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esmbuild.js","sourceRoot":"","sources":["../../../src/transpilers/esm/esmbuild.ts"],"names":[],"mappings":";;;;;;AAAA,qCAA+F;AAC/F,gDAAwB;AAMxB,MAAM,cAAc,GAAqB;IACxC,KAAK,EAAE,IAAI;CACX,CAAC;AAEF,MAAM,aAAa,GAAkB;IACpC,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,MAAM;IAChB,MAAM,EAAE,CAAC,QAAQ,CAAC;IAClB,MAAM,EAAE,KAAK;IACb,SAAS,EAAE,UAAU;CACrB,CAAC;AAEF,IAAI,MAAM,CAAC,sBAAsB,EAAE,CAAC;IACnC,aAAa,CAAC,WAAW,GAAG;QAC3B,eAAe,EAAE;YAChB,sBAAsB,EAAE,IAAI;YAC5B,sBAAsB,EAAE,QAAQ;YAChC,MAAM,EAAE,IAAI;SACZ;KACD,CAAC;AACH,CAAC;KAAM,CAAC;IACP,aAAa,CAAC,WAAW,GAAG;QAC3B,eAAe,EAAE;YAChB,sBAAsB,EAAE,QAAQ;YAChC,MAAM,EAAE,IAAI;SACZ;KACD,CAAC;AACH,CAAC;AAOY,QAAA,OAAO,GAA2B;IAC9C,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,MAAM;CACf,CAAC;AAEK,MAAM,QAAQ,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC5C,IAAI,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC,qBAAqB,CAAC;QAAE,OAAO,KAAK,CAAC;IAChG,OAAO,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,eAAO,CAAC;AAC1C,CAAC,CAAC;AAHW,QAAA,QAAQ,YAGnB;AAEF,MAAM,UAAU,GAAG,CAAC,OAAyB,EAAE,EAAE;IAChD,MAAM,GAAG,GAAG,EAAE,GAAG,eAAO,EAAE,CAAC;IAC3B,IAAI,OAAO,OAAO,CAAC,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,CAAC;QAChD,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAW,CAAC;IACnF,CAAC;IACD,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC;AAEK,MAAM,aAAa,GAAG,CAC5B,IAAY,EACZ,QAAgB,EAChB,GAAY,EACZ,QAAoC,EACjB,EAAE;IACrB,MAAM,OAAO,GAAqB,EAAE,GAAG,cAAc,EAAE,GAAG,QAAQ,EAAE,CAAC;IACrE,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAElE,MAAM,GAAG,GAAG,IAAA,uBAAa,EAAC,IAAI,EAAE;QAC/B,GAAG,aAAa;QAChB,GAAI,OAAO,CAAC,OAAwC;QACpD,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC;QAC1B,UAAU,EAAE,QAAQ;KACpB,CAAC,CAAC;IACH,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,CAAC,GAAG,EAAE,CAAC;AACjD,CAAC,CAAC;AAjBW,QAAA,aAAa,iBAiBxB","sourcesContent":["import { Loader, transformSync, CommonOptions, TransformOptions, BuildOptions } from 'esbuild';\r\nimport path from 'path';\r\n\r\nexport type TranspileOptions = {\r\n\tdebug: boolean;\r\n\tesbuild?: CommonOptions & TransformOptions & BuildOptions;\r\n};\r\nconst defaultOptions: TranspileOptions = {\r\n\tdebug: true\r\n};\r\n\r\nconst commonOptions: CommonOptions = {\r\n\tformat: 'esm',\r\n\tlogLevel: 'info',\r\n\ttarget: [`esnext`],\r\n\tminify: false,\r\n\tsourcemap: 'external'\r\n};\r\n\r\nif (global.experimentalDecorators) {\r\n\tcommonOptions.tsconfigRaw = {\r\n\t\tcompilerOptions: {\r\n\t\t\texperimentalDecorators: true,\r\n\t\t\timportsNotUsedAsValues: 'remove',\r\n\t\t\tstrict: true\r\n\t\t}\r\n\t};\r\n} else {\r\n\tcommonOptions.tsconfigRaw = {\r\n\t\tcompilerOptions: {\r\n\t\t\timportsNotUsedAsValues: 'remove',\r\n\t\t\tstrict: true\r\n\t\t}\r\n\t};\r\n}\r\n\r\nexport type TranspileResults = {\r\n\toutput: string;\r\n\tsourceMap?: string;\r\n};\r\n\r\nexport const loaders: Record<string, Loader> = {\r\n\t'.js': 'js',\r\n\t'.mjs': 'js',\r\n\t'.cjs': 'js',\r\n\t'.jsx': 'jsx',\r\n\t'.ts': 'ts',\r\n\t'.tsx': 'tsx',\r\n\t'.json': 'json'\r\n};\r\n\r\nexport const supports = (filename: string) => {\r\n\tif (filename.includes('node_modules') || filename.includes('cucumber-tsflow/lib')) return false;\r\n\treturn path.extname(filename) in loaders;\r\n};\r\n\r\nconst getLoaders = (options: TranspileOptions) => {\r\n\tconst ret = { ...loaders };\r\n\tif (typeof options.esbuild?.loader == 'object') {\r\n\t\tfor (const [e, l] of Object.entries(options.esbuild.loader)) ret[e] = l as Loader;\r\n\t}\r\n\treturn ret;\r\n};\r\n\r\nexport const transpileCode = (\r\n\tcode: string,\r\n\tfilename: string,\r\n\text?: string,\r\n\t_options?: Partial<TranspileOptions>\r\n): TranspileResults => {\r\n\tconst options: TranspileOptions = { ...defaultOptions, ..._options };\r\n\tconst loaders = getLoaders(options);\r\n\tconst loaderExt = ext != undefined ? ext : path.extname(filename);\r\n\r\n\tconst ret = transformSync(code, {\r\n\t\t...commonOptions,\r\n\t\t...(options.esbuild as TransformOptions | undefined),\r\n\t\tloader: loaders[loaderExt],\r\n\t\tsourcefile: filename\r\n\t});\r\n\treturn { output: ret.code, sourceMap: ret.map };\r\n};\r\n"]}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require('ts-node/esm').register({
4
+ transpileOnly: true,
5
+ transpiler: '@lynxwall/cucumber-tsflow/lib/transpilers/esm/esmbuild-transpiler'
6
+ });
7
+ require('tsconfig-paths').register();
8
+ //# sourceMappingURL=esmnode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esmnode.js","sourceRoot":"","sources":["../../../src/transpilers/esm/esmnode.ts"],"names":[],"mappings":";;AAAA,OAAO,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC;IAC/B,aAAa,EAAE,IAAI;IACnB,UAAU,EAAE,mEAAmE;CAC/E,CAAC,CAAC;AAEH,OAAO,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["require('ts-node/esm').register({\r\n\ttranspileOnly: true,\r\n\ttranspiler: '@lynxwall/cucumber-tsflow/lib/transpilers/esm/esmbuild-transpiler'\r\n});\r\n\r\nrequire('tsconfig-paths').register();\r\n"]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const hooks = require('require-extension-hooks');
7
+ const vue_sfc_1 = __importDefault(require("../vue-sfc"));
8
+ require('ts-node/esm').register({
9
+ transpileOnly: true,
10
+ transpiler: '@lynxwall/cucumber-tsflow/lib/transpilers/esm/esmbuild-transpiler'
11
+ });
12
+ require('tsconfig-paths').register();
13
+ // Register jsdom globally and set SVGElement on global
14
+ require('jsdom-global')();
15
+ global.SVGElement = global.window.SVGElement;
16
+ hooks('vue').push(function (params) {
17
+ try {
18
+ const transformer = new vue_sfc_1.default({
19
+ exclude: ['(?:^|/)node_modules/', '(?:^|/)cucumber-tsflow/lib/']
20
+ });
21
+ const transformResult = transformer.transformCode(params.content, params.filename);
22
+ return transformResult.code;
23
+ }
24
+ catch (err) {
25
+ console.log(err);
26
+ }
27
+ return params.content;
28
+ });
29
+ //# sourceMappingURL=esmvue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esmvue.js","sourceRoot":"","sources":["../../../src/transpilers/esm/esmvue.ts"],"names":[],"mappings":";;;;;AAAA,MAAM,KAAK,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;AACjD,yDAAwC;AAExC,OAAO,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC;IAC/B,aAAa,EAAE,IAAI;IACnB,UAAU,EAAE,mEAAmE;CAC/E,CAAC,CAAC;AAEH,OAAO,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,CAAC;AAErC,uDAAuD;AACvD,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;AACzB,MAAc,CAAC,UAAU,GAAI,MAAc,CAAC,MAAM,CAAC,UAAU,CAAC;AAE/D,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,UAAU,MAAW;IACtC,IAAI,CAAC;QACJ,MAAM,WAAW,GAAG,IAAI,iBAAc,CAAC;YACtC,OAAO,EAAE,CAAC,sBAAsB,EAAE,6BAA6B,CAAC;SAChE,CAAC,CAAC;QACH,MAAM,eAAe,GAAG,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;QAEnF,OAAO,eAAe,CAAC,IAAI,CAAC;IAC7B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["const hooks = require('require-extension-hooks');\r\nimport VueTransformer from '../vue-sfc';\r\n\r\nrequire('ts-node/esm').register({\r\n\ttranspileOnly: true,\r\n\ttranspiler: '@lynxwall/cucumber-tsflow/lib/transpilers/esm/esmbuild-transpiler'\r\n});\r\n\r\nrequire('tsconfig-paths').register();\r\n\r\n// Register jsdom globally and set SVGElement on global\r\nrequire('jsdom-global')();\r\n(global as any).SVGElement = (global as any).window.SVGElement;\r\n\r\nhooks('vue').push(function (params: any) {\r\n\ttry {\r\n\t\tconst transformer = new VueTransformer({\r\n\t\t\texclude: ['(?:^|/)node_modules/', '(?:^|/)cucumber-tsflow/lib/']\r\n\t\t});\r\n\t\tconst transformResult = transformer.transformCode(params.content, params.filename);\r\n\r\n\t\treturn transformResult.code;\r\n\t} catch (err) {\r\n\t\tconsole.log(err);\r\n\t}\r\n\treturn params.content;\r\n});\r\n"]}
@@ -0,0 +1,9 @@
1
+ import { createEsbuildLoader } from './loader-utils.mjs';
2
+
3
+ // Create and export the loader with default options
4
+ const loader = createEsbuildLoader({
5
+ loaderName: 'esnode-loader',
6
+ handleVue: false
7
+ });
8
+
9
+ export const { resolve, load, getFormat, transformSource } = loader;
@@ -0,0 +1,9 @@
1
+ import { createEsbuildLoader } from './loader-utils.mjs';
2
+
3
+ // Create and export the loader with Vue support
4
+ const loader = createEsbuildLoader({
5
+ loaderName: 'esvue-loader',
6
+ handleVue: true
7
+ });
8
+
9
+ export const { resolve, load, getFormat, transformSource } = loader;
@@ -0,0 +1,278 @@
1
+ import { compileVueSFC } from './vue-sfc-compiler.mjs';
2
+ import { fileURLToPath, pathToFileURL } from 'url';
3
+ import { existsSync } from 'fs';
4
+ import path from 'path';
5
+ import { createMatchPath, loadConfig } from 'tsconfig-paths';
6
+ import { createEsmHooks } from './tsnode-service.mjs';
7
+
8
+ // Shared asset extensions
9
+ export const ASSET_EXTENSIONS = [
10
+ '.jpg',
11
+ '.jpeg',
12
+ '.png',
13
+ '.gif',
14
+ '.svg',
15
+ '.webp',
16
+ '.ico',
17
+ '.woff',
18
+ '.woff2',
19
+ '.ttf',
20
+ '.eot'
21
+ ];
22
+ export const CODE_EXTENSIONS = ['.vue', '.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'];
23
+
24
+ // TSConfig paths initialization
25
+ let matchPath;
26
+ export function initializeTsconfigPaths() {
27
+ if (matchPath) return matchPath;
28
+
29
+ try {
30
+ const configLoaderResult = loadConfig(process.cwd());
31
+ if (configLoaderResult.resultType === 'success') {
32
+ matchPath = createMatchPath(
33
+ configLoaderResult.absoluteBaseUrl,
34
+ configLoaderResult.paths,
35
+ configLoaderResult.mainFields,
36
+ configLoaderResult.addMatchAll
37
+ );
38
+ } else {
39
+ console.warn('>>> loader: no tsconfig paths found');
40
+ }
41
+ } catch (error) {
42
+ console.error('>>> loader: failed to load tsconfig paths:', error);
43
+ }
44
+
45
+ return matchPath;
46
+ }
47
+
48
+ // Extension resolution helper
49
+ export async function resolveWithExtensions(specifier, parentURL, extensions = CODE_EXTENSIONS) {
50
+ let resolvedPath;
51
+
52
+ if (specifier.startsWith('file://')) {
53
+ // Handle file:// URLs
54
+ resolvedPath = fileURLToPath(specifier);
55
+ } else {
56
+ // Handle relative paths
57
+ const parentPath = fileURLToPath(parentURL);
58
+ const parentDir = path.dirname(parentPath);
59
+ resolvedPath = path.resolve(parentDir, specifier);
60
+ }
61
+ // Try various extensions
62
+ for (const ext of extensions) {
63
+ const fullPath = resolvedPath + ext;
64
+
65
+ if (existsSync(fullPath)) {
66
+ const result = pathToFileURL(fullPath).href;
67
+ return result;
68
+ }
69
+ }
70
+
71
+ // Try index files
72
+ for (const ext of extensions) {
73
+ const indexPath = path.join(resolvedPath, 'index' + ext);
74
+ if (existsSync(indexPath)) {
75
+ return pathToFileURL(indexPath).href;
76
+ }
77
+ }
78
+
79
+ return null;
80
+ }
81
+
82
+ // TSConfig path mapping resolver
83
+ export function resolveTsconfigPaths(specifier) {
84
+ const matchPath = initializeTsconfigPaths();
85
+
86
+ if (matchPath && !specifier.startsWith('.') && !specifier.startsWith('/') && !specifier.startsWith('file:')) {
87
+ const mapped = matchPath(specifier);
88
+
89
+ if (mapped) {
90
+ return {
91
+ url: pathToFileURL(mapped).href,
92
+ shortCircuit: true
93
+ };
94
+ }
95
+ }
96
+
97
+ return null;
98
+ }
99
+
100
+ // Asset loader helper
101
+ export function loadAsset(url) {
102
+ const filePath = fileURLToPath(url);
103
+ return {
104
+ format: 'module',
105
+ source: `export default ${JSON.stringify(filePath)};`,
106
+ shortCircuit: true
107
+ };
108
+ }
109
+
110
+ // Vue style configuration helper
111
+ export function shouldEnableVueStyle() {
112
+ // Check if styles should be enabled (from environment or config)
113
+ // Vue styles are disabled by default. However, user could enable them when importing from compiled libraries
114
+ return (
115
+ global.enableVueStyle === true ||
116
+ process.env.CUCUMBER_ENABLE_VUE_STYLE === 'true' ||
117
+ process.env.enableVueStyle === 'true'
118
+ );
119
+ }
120
+
121
+ export async function loadVue(url, context, nextLoad) {
122
+ const { source } = await nextLoad(url, { ...context, format: 'module' });
123
+ const code = source.toString();
124
+ const filename = fileURLToPath(url);
125
+
126
+ const compiled = compileVueSFC(code, filename, {
127
+ enableStyle: shouldEnableVueStyle()
128
+ });
129
+
130
+ return {
131
+ format: 'module',
132
+ source: compiled.code,
133
+ shortCircuit: true
134
+ };
135
+ }
136
+
137
+ /**
138
+ * Resolves module specifiers with support for TypeScript paths, extensions, and more
139
+ * @param {string} specifier - The module specifier to resolve
140
+ * @param {object} context - The loader context
141
+ * @param {object} options - Resolution options
142
+ * @param {string} options.logPrefix - Prefix for log messages
143
+ * @param {boolean} options.checkExtensions - Whether to try adding extensions
144
+ * @param {boolean} options.handleTsFiles - Whether to delegate .ts files to ts-node
145
+ * @param {object} options.tsNodeHooks - The ts-node hooks (if handleTsFiles is true)
146
+ * @param {function} options.nextResolve - The next resolver in the chain
147
+ * @returns {Promise<object|null>} The resolution result or null
148
+ */
149
+ export async function resolveSpecifier(specifier, context, options = {}) {
150
+ const { checkExtensions = true, handleTsFiles = false, tsNodeHooks = null, nextResolve } = options;
151
+
152
+ // 1. Handle TypeScript path mappings first
153
+ const mappedResult = resolveTsconfigPaths(specifier);
154
+ if (mappedResult) {
155
+ // Check if the mapped result needs extension resolution
156
+ const mappedUrl = mappedResult.url;
157
+ if (checkExtensions && !path.extname(mappedUrl)) {
158
+ // Try to resolve with extensions
159
+ const resolved = await resolveWithExtensions(mappedUrl, context.parentURL);
160
+ if (resolved) {
161
+ return { url: resolved, shortCircuit: true };
162
+ }
163
+ }
164
+
165
+ return mappedResult;
166
+ }
167
+
168
+ // 2. Handle TypeScript files if requested
169
+ if (handleTsFiles && tsNodeHooks && (specifier.endsWith('.ts') || specifier.endsWith('.tsx'))) {
170
+ try {
171
+ return await tsNodeHooks.resolve(specifier, context, nextResolve);
172
+ } catch (error) {
173
+ // Fall through to extension resolution
174
+ }
175
+ }
176
+
177
+ // 3. Extension resolution for relative imports and file:// URLs
178
+ if (checkExtensions && (specifier.startsWith('.') || specifier.startsWith('/') || specifier.startsWith('file://'))) {
179
+ const hasExtension = path.extname(specifier) !== '';
180
+
181
+ if (!hasExtension && context.parentURL) {
182
+ const resolved = await resolveWithExtensions(specifier, context.parentURL);
183
+ if (resolved) {
184
+ return { url: resolved, shortCircuit: true };
185
+ }
186
+ }
187
+ }
188
+
189
+ // 4. No resolution found
190
+ return null;
191
+ }
192
+
193
+ // Cache for different ESM hooks by transpiler path
194
+ const esmHooksCache = new Map();
195
+
196
+ export async function getEsmHooks(transpilerPath, loaderName = 'loader') {
197
+ if (esmHooksCache.has(transpilerPath)) {
198
+ return esmHooksCache.get(transpilerPath);
199
+ }
200
+
201
+ try {
202
+ const hooks = await createEsmHooks(transpilerPath);
203
+ esmHooksCache.set(transpilerPath, hooks);
204
+ return hooks;
205
+ } catch (error) {
206
+ console.error(`>>> ${loaderName}: Failed to load ESM hooks with transpiler ${transpilerPath}:`, error);
207
+ throw error;
208
+ }
209
+ }
210
+
211
+ // Helper to create hook exports
212
+ export function createHookExports(getHooksFn) {
213
+ return {
214
+ getFormat: async (...args) => (await getHooksFn()).getFormat(...args),
215
+ transformSource: async (...args) => (await getHooksFn()).transformSource(...args)
216
+ };
217
+ }
218
+
219
+ // Common loader factory for esbuild-based loaders
220
+ export function createEsbuildLoader(options = {}) {
221
+ const {
222
+ loaderName = 'loader',
223
+ handleVue = false,
224
+ transpilerPath = '@lynxwall/cucumber-tsflow/lib/transpilers/esm/esbuild-transpiler-cjs'
225
+ } = options;
226
+
227
+ const getLocalEsmHooks = () => getEsmHooks(transpilerPath, loaderName);
228
+
229
+ return {
230
+ resolve: async (specifier, context, nextResolve) => {
231
+ const resolved = await resolveSpecifier(specifier, context, {
232
+ checkExtensions: true,
233
+ handleTsFiles: true,
234
+ tsNodeHooks: await getLocalEsmHooks(),
235
+ nextResolve
236
+ });
237
+
238
+ if (resolved) {
239
+ return resolved;
240
+ }
241
+
242
+ return nextResolve(specifier, context);
243
+ },
244
+
245
+ load: async (url, context, nextLoad) => {
246
+ // Handle asset files
247
+ const ext = path.extname(url).toLowerCase();
248
+ if (ASSET_EXTENSIONS.includes(ext)) {
249
+ return loadAsset(url);
250
+ }
251
+
252
+ // Handle Vue files if enabled
253
+ if (handleVue && url.endsWith('.vue')) {
254
+ try {
255
+ return loadVue(url, context, nextLoad);
256
+ } catch (error) {
257
+ console.error(`>>> ${loaderName}: Failed to compile Vue SFC ${url}:`, error);
258
+ throw new Error(`Failed to compile Vue SFC ${url}: ${error.message}`);
259
+ }
260
+ }
261
+
262
+ // Handle TypeScript files
263
+ if (url.endsWith('.ts') || url.endsWith('.tsx')) {
264
+ try {
265
+ const tsNodeHooks = await getLocalEsmHooks();
266
+ return tsNodeHooks.load(url, context, nextLoad);
267
+ } catch (error) {
268
+ console.error(`>>> ${loaderName}: ts-node failed for ${url}:`, error);
269
+ throw error;
270
+ }
271
+ }
272
+
273
+ return nextLoad(url, context);
274
+ },
275
+
276
+ ...createHookExports(getLocalEsmHooks)
277
+ };
278
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require('ts-node').register({
4
+ compilerOptions: {
5
+ module: 'es2022',
6
+ target: 'ESNext',
7
+ moduleResolution: 'node',
8
+ esModuleInterop: true,
9
+ strict: true,
10
+ allowJs: true,
11
+ allowSyntheticDefaultImports: true,
12
+ experimentalDecorators: false,
13
+ resolveJsonModule: true,
14
+ skipLibCheck: true,
15
+ forceConsistentCasingInFileNames: true,
16
+ lib: ['es2022', 'esnext.decorators']
17
+ },
18
+ 'ts-node': {
19
+ esm: true,
20
+ experimentalSpecifierResolution: 'node'
21
+ },
22
+ transpileOnly: true
23
+ });
24
+ require('tsconfig-paths').register();
25
+ //# sourceMappingURL=tsnode-esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsnode-esm.js","sourceRoot":"","sources":["../../../src/transpilers/esm/tsnode-esm.ts"],"names":[],"mappings":";;AAAA,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC;IAC3B,eAAe,EAAE;QAChB,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,QAAQ;QAChB,gBAAgB,EAAE,MAAM;QACxB,eAAe,EAAE,IAAI;QACrB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,IAAI;QACb,4BAA4B,EAAE,IAAI;QAClC,sBAAsB,EAAE,KAAK;QAC7B,iBAAiB,EAAE,IAAI;QACvB,YAAY,EAAE,IAAI;QAClB,gCAAgC,EAAE,IAAI;QACtC,GAAG,EAAE,CAAC,QAAQ,EAAE,mBAAmB,CAAC;KACpC;IACD,SAAS,EAAE;QACV,GAAG,EAAE,IAAI;QACT,+BAA+B,EAAE,MAAM;KACvC;IACD,aAAa,EAAE,IAAI;CACnB,CAAC,CAAC;AAEH,OAAO,CAAC,gBAAgB,CAAC,CAAC,QAAQ,EAAE,CAAC","sourcesContent":["require('ts-node').register({\r\n\tcompilerOptions: {\r\n\t\tmodule: 'es2022',\r\n\t\ttarget: 'ESNext',\r\n\t\tmoduleResolution: 'node',\r\n\t\tesModuleInterop: true,\r\n\t\tstrict: true,\r\n\t\tallowJs: true,\r\n\t\tallowSyntheticDefaultImports: true,\r\n\t\texperimentalDecorators: false,\r\n\t\tresolveJsonModule: true,\r\n\t\tskipLibCheck: true,\r\n\t\tforceConsistentCasingInFileNames: true,\r\n\t\tlib: ['es2022', 'esnext.decorators']\r\n\t},\r\n\t'ts-node': {\r\n\t\tesm: true,\r\n\t\texperimentalSpecifierResolution: 'node'\r\n\t},\r\n\ttranspileOnly: true\r\n});\r\n\r\nrequire('tsconfig-paths').register();\r\n"]}