@rstest/core 0.8.5 → 0.9.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.
- package/LICENSE.md +2 -2
- package/dist/0~130.js +0 -1
- package/dist/0~1472.js +2 -2
- package/dist/0~2173.js +104 -74
- package/dist/{0~3919.js → 0~262.js} +31 -30
- package/dist/0~3062.js +1 -1
- package/dist/0~3346.js +1 -1
- package/dist/0~5835.js +17 -4
- package/dist/0~6923.js +11 -3
- package/dist/0~7583.js +2 -2
- package/dist/0~7882.js +37 -36
- package/dist/0~89.js +50 -31
- package/dist/0~9634.js +5 -5
- package/dist/0~9744.js +1014 -0
- package/dist/1294.js +1 -0
- package/dist/3160.js +14 -64
- package/dist/{5960.js → 4597.js} +0 -1
- package/dist/6151.js +3119 -51
- package/dist/9131.js +178 -100
- package/dist/browser-runtime/389.js +3398 -362
- package/dist/browser-runtime/index.d.ts +40 -10
- package/dist/browser.d.ts +53 -10
- package/dist/index.d.ts +44 -79
- package/dist/mockRuntimeCode.js +15 -9
- package/dist/worker.d.ts +13 -1521
- package/dist/worker.js +14 -8
- package/package.json +18 -15
- package/dist/0~1981.js +0 -2
- package/dist/0~9348.js +0 -951
- package/dist/721.js +0 -8
package/LICENSE.md
CHANGED
|
@@ -748,7 +748,7 @@ Licensed under MIT license in the repository at LinusU/buffer-from.
|
|
|
748
748
|
|
|
749
749
|
### cac
|
|
750
750
|
|
|
751
|
-
Licensed under MIT license in the repository at
|
|
751
|
+
Licensed under MIT license in the repository at git+https://github.com/cacjs/cac.git.
|
|
752
752
|
|
|
753
753
|
> The MIT License (MIT)
|
|
754
754
|
>
|
|
@@ -1209,7 +1209,7 @@ Licensed under MIT license in the repository at git://github.com/paulmillr/readd
|
|
|
1209
1209
|
|
|
1210
1210
|
### rslog
|
|
1211
1211
|
|
|
1212
|
-
Licensed under MIT license in the repository at https://github.com/
|
|
1212
|
+
Licensed under MIT license in the repository at https://github.com/rstackjs/rslog.git.
|
|
1213
1213
|
|
|
1214
1214
|
> MIT License
|
|
1215
1215
|
>
|
package/dist/0~130.js
CHANGED
|
@@ -2,7 +2,6 @@ import "node:module";
|
|
|
2
2
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
3
3
|
import { AssertionError, strict } from "node:assert";
|
|
4
4
|
import { Console } from "node:console";
|
|
5
|
-
import "./721.js";
|
|
6
5
|
import { prettyTime, color } from "./3160.js";
|
|
7
6
|
const external_node_util_ = __webpack_require__("node:util");
|
|
8
7
|
const RealDate = Date;
|
package/dist/0~1472.js
CHANGED
|
@@ -4,7 +4,7 @@ import { pathToFileURL } from "./6198.js";
|
|
|
4
4
|
import "./1157.js";
|
|
5
5
|
import { logger as logger_logger, color } from "./3160.js";
|
|
6
6
|
async function loadBrowserModule(options = {}) {
|
|
7
|
-
const coreVersion = "0.
|
|
7
|
+
const coreVersion = "0.9.1";
|
|
8
8
|
const { projectRoots = [] } = options;
|
|
9
9
|
let browserModule;
|
|
10
10
|
let browserVersion;
|
|
@@ -18,7 +18,7 @@ async function loadBrowserModule(options = {}) {
|
|
|
18
18
|
];
|
|
19
19
|
for (const base of uniqueBases)try {
|
|
20
20
|
const userRequire = createRequire(base);
|
|
21
|
-
const browserPath = userRequire.resolve('@rstest/browser');
|
|
21
|
+
const browserPath = userRequire.resolve('@rstest/browser/internal');
|
|
22
22
|
const browserPkgPath = userRequire.resolve('@rstest/browser/package.json');
|
|
23
23
|
browserModule = await import(pathToFileURL(browserPath).href);
|
|
24
24
|
const browserPkg = userRequire(browserPkgPath);
|
package/dist/0~2173.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
3
|
+
import { logger as logger_logger, isTTY, color, clearScreen } from "./3160.js";
|
|
2
4
|
import { resolveShardedEntries, getTestEntries } from "./1157.js";
|
|
3
5
|
import { createCoverageProvider } from "./5734.js";
|
|
4
6
|
import { prepareRsbuild, createPool, createRsbuildServer, runGlobalTeardown, runGlobalSetup } from "./0~89.js";
|
|
5
7
|
import { loadBrowserModule } from "./0~1472.js";
|
|
6
|
-
import { logger as logger_logger, isTTY, color, clearScreen } from "./3160.js";
|
|
7
8
|
const isCliShortcutsEnabled = ()=>isTTY('stdin');
|
|
8
9
|
async function setupCliShortcuts({ closeServer, runAll, updateSnapshot, runFailedTests, runWithTestNamePattern, runWithFileFilters }) {
|
|
9
10
|
const { createInterface, emitKeypressEvents } = await import("node:readline");
|
|
@@ -21,7 +22,7 @@ async function setupCliShortcuts({ closeServer, runAll, updateSnapshot, runFaile
|
|
|
21
22
|
process.stdout.write('\r\x1b[2K');
|
|
22
23
|
} catch {}
|
|
23
24
|
};
|
|
24
|
-
const promptInput =
|
|
25
|
+
const promptInput = (promptText, onComplete)=>{
|
|
25
26
|
if (isPrompting) return;
|
|
26
27
|
isPrompting = true;
|
|
27
28
|
let buffer = '';
|
|
@@ -32,6 +33,10 @@ async function setupCliShortcuts({ closeServer, runAll, updateSnapshot, runFaile
|
|
|
32
33
|
const onPromptKey = async (str, key)=>{
|
|
33
34
|
if (!isPrompting) return;
|
|
34
35
|
if (key.ctrl && 'c' === key.name) return void process.kill(process.pid, 'SIGINT');
|
|
36
|
+
if (key.ctrl && 'z' === key.name) {
|
|
37
|
+
if ('win32' !== process.platform) process.kill(process.pid, 'SIGTSTP');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
35
40
|
if ('return' === key.name || 'enter' === key.name) {
|
|
36
41
|
process.stdin.off('keypress', onPromptKey);
|
|
37
42
|
process.stdout.write('\n');
|
|
@@ -83,9 +88,9 @@ async function setupCliShortcuts({ closeServer, runAll, updateSnapshot, runFaile
|
|
|
83
88
|
{
|
|
84
89
|
key: 't',
|
|
85
90
|
description: `${color.bold('t')} ${color.dim('filter by a test name regex pattern')}`,
|
|
86
|
-
action:
|
|
91
|
+
action: ()=>{
|
|
87
92
|
clearCurrentInputLine();
|
|
88
|
-
|
|
93
|
+
promptInput('Enter test name pattern (empty to clear): ', async (pattern)=>{
|
|
89
94
|
await runWithTestNamePattern(pattern);
|
|
90
95
|
});
|
|
91
96
|
}
|
|
@@ -93,9 +98,9 @@ async function setupCliShortcuts({ closeServer, runAll, updateSnapshot, runFaile
|
|
|
93
98
|
{
|
|
94
99
|
key: 'p',
|
|
95
100
|
description: `${color.bold('p')} ${color.dim('filter by a filename regex pattern')}`,
|
|
96
|
-
action:
|
|
101
|
+
action: ()=>{
|
|
97
102
|
clearCurrentInputLine();
|
|
98
|
-
|
|
103
|
+
promptInput('Enter file name pattern (empty to clear): ', async (input)=>{
|
|
99
104
|
const filters = input ? input.split(/\s+/).filter(Boolean) : void 0;
|
|
100
105
|
await runWithFileFilters(filters);
|
|
101
106
|
});
|
|
@@ -123,6 +128,10 @@ async function setupCliShortcuts({ closeServer, runAll, updateSnapshot, runFaile
|
|
|
123
128
|
const handleKeypress = (str, key)=>{
|
|
124
129
|
if (isPrompting) return;
|
|
125
130
|
if (key.ctrl && 'c' === key.name) return void process.kill(process.pid, 'SIGINT');
|
|
131
|
+
if (key.ctrl && 'z' === key.name) {
|
|
132
|
+
if ('win32' !== process.platform) process.kill(process.pid, 'SIGTSTP');
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
126
135
|
for (const shortcut of shortcuts)if (str === shortcut.key) {
|
|
127
136
|
clearCurrentInputLine();
|
|
128
137
|
shortcut.action();
|
|
@@ -145,6 +154,7 @@ async function setupCliShortcuts({ closeServer, runAll, updateSnapshot, runFaile
|
|
|
145
154
|
rl.close();
|
|
146
155
|
};
|
|
147
156
|
}
|
|
157
|
+
const external_node_os_ = __webpack_require__("node:os");
|
|
148
158
|
async function runBrowserModeTests(context, browserProjects, options) {
|
|
149
159
|
const projectRoots = browserProjects.map((p)=>p.rootPath);
|
|
150
160
|
const { validateBrowserConfig, runBrowserTests } = await loadBrowserModule({
|
|
@@ -153,6 +163,10 @@ async function runBrowserModeTests(context, browserProjects, options) {
|
|
|
153
163
|
validateBrowserConfig(context);
|
|
154
164
|
return runBrowserTests(context, options);
|
|
155
165
|
}
|
|
166
|
+
const getSignalExitCode = (signal)=>{
|
|
167
|
+
const signalNumber = external_node_os_.constants.signals[signal];
|
|
168
|
+
return 'number' == typeof signalNumber ? 128 + signalNumber : 1;
|
|
169
|
+
};
|
|
156
170
|
async function runTests(context) {
|
|
157
171
|
const browserProjects = context.projects.filter((project)=>project.normalizedConfig.browser.enabled);
|
|
158
172
|
const nodeProjects = context.projects.filter((project)=>!project.normalizedConfig.browser.enabled);
|
|
@@ -214,7 +228,7 @@ async function runTests(context) {
|
|
|
214
228
|
skipOnTestRunEnd: shouldUnifyReporter,
|
|
215
229
|
shardedEntries: shard ? browserEntries : void 0
|
|
216
230
|
});
|
|
217
|
-
browserResultPromise.catch(()=>
|
|
231
|
+
browserResultPromise.catch(()=>void 0);
|
|
218
232
|
}
|
|
219
233
|
if (!hasNodeTestsToRun) {
|
|
220
234
|
if (browserResultPromise) await browserResultPromise;
|
|
@@ -326,73 +340,86 @@ async function runTests(context) {
|
|
|
326
340
|
const buildTime = testStart - buildStart;
|
|
327
341
|
const testTime = Date.now() - testStart;
|
|
328
342
|
const browserResult = browserResultPromise ? await browserResultPromise : void 0;
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
343
|
+
const browserResolveSourcemap = browserResult?.resolveSourcemap;
|
|
344
|
+
const browserClose = browserResult?.close;
|
|
345
|
+
try {
|
|
346
|
+
const nodeResourceByAssetName = new Map();
|
|
347
|
+
for (const item of returns)for (const assetName of item.assetNames)nodeResourceByAssetName.set(assetName, item.getSourceMaps);
|
|
348
|
+
const getSourcemap = async (sourcePath)=>{
|
|
349
|
+
if (browserResolveSourcemap) {
|
|
350
|
+
const resolved = await browserResolveSourcemap(sourcePath);
|
|
351
|
+
if (resolved.handled) return resolved.sourcemap;
|
|
352
|
+
}
|
|
353
|
+
const getSourceMaps = nodeResourceByAssetName.get(sourcePath);
|
|
354
|
+
const sourceMap = (await getSourceMaps?.([
|
|
355
|
+
sourcePath
|
|
356
|
+
]))?.[sourcePath];
|
|
357
|
+
return sourceMap ? JSON.parse(sourceMap) : null;
|
|
358
|
+
};
|
|
359
|
+
const duration = shouldUnifyReporter && browserResult ? {
|
|
360
|
+
totalTime: testTime + buildTime + browserResult.duration.totalTime,
|
|
361
|
+
buildTime: buildTime + browserResult.duration.buildTime,
|
|
362
|
+
testTime: testTime + browserResult.duration.testTime
|
|
363
|
+
} : {
|
|
364
|
+
totalTime: testTime + buildTime,
|
|
365
|
+
buildTime,
|
|
366
|
+
testTime
|
|
367
|
+
};
|
|
368
|
+
const results = returns.flatMap((r)=>r.results);
|
|
369
|
+
const testResults = returns.flatMap((r)=>r.testResults);
|
|
370
|
+
const errors = returns.flatMap((r)=>r.errors || []);
|
|
371
|
+
if (shouldUnifyReporter && browserResult?.results) results.push(...browserResult.results);
|
|
372
|
+
if (shouldUnifyReporter && browserResult?.testResults) testResults.push(...browserResult.testResults);
|
|
373
|
+
if (shouldUnifyReporter && browserResult?.unhandledErrors) errors.push(...browserResult.unhandledErrors);
|
|
374
|
+
context.updateReporterResultState(results, testResults, currentDeletedEntries);
|
|
375
|
+
const nodeHasFailure = results.some((r)=>'fail' === r.status) || errors.length;
|
|
376
|
+
const browserHasFailure = shouldUnifyReporter && browserResult?.hasFailure;
|
|
377
|
+
if (0 === results.length && !errors.length) {
|
|
378
|
+
if ('watch' === command) if ('on-demand' === mode) logger_logger.log(color.yellow('No test files need re-run.'));
|
|
379
|
+
else logger_logger.log(color.yellow('No test files found.'));
|
|
380
|
+
else {
|
|
381
|
+
const code = context.normalizedConfig.passWithNoTests ? 0 : 1;
|
|
382
|
+
const message = `No test files found, exiting with code ${code}.`;
|
|
383
|
+
if (0 === code) logger_logger.log(color.yellow(message));
|
|
384
|
+
else logger_logger.error(color.red(message));
|
|
385
|
+
process.exitCode = code;
|
|
386
|
+
}
|
|
387
|
+
if ('all' === mode) {
|
|
388
|
+
if (context.fileFilters?.length) logger_logger.log(color.gray('filter: '), context.fileFilters.join(color.gray(', ')));
|
|
389
|
+
allProjects.forEach((p)=>{
|
|
390
|
+
if (allProjects.length > 1) {
|
|
391
|
+
logger_logger.log('');
|
|
392
|
+
logger_logger.log(color.gray('project:'), p.name);
|
|
393
|
+
}
|
|
394
|
+
logger_logger.log(color.gray('root:'), p.rootPath);
|
|
395
|
+
logger_logger.log(color.gray('include:'), p.normalizedConfig.include.join(color.gray(', ')));
|
|
396
|
+
logger_logger.log(color.gray('exclude:'), p.normalizedConfig.exclude.patterns.join(color.gray(', ')));
|
|
397
|
+
});
|
|
398
|
+
}
|
|
356
399
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
400
|
+
const isFailure = nodeHasFailure || browserHasFailure;
|
|
401
|
+
if (isFailure) process.exitCode = 1;
|
|
402
|
+
for (const reporter of reporters)await reporter.onTestRunEnd?.({
|
|
403
|
+
results: context.reporterResults.results,
|
|
404
|
+
testResults: context.reporterResults.testResults,
|
|
405
|
+
unhandledErrors: errors,
|
|
406
|
+
snapshotSummary: snapshotManager.summary,
|
|
407
|
+
duration,
|
|
408
|
+
getSourcemap,
|
|
409
|
+
filterRerunTestPaths: currentEntries.length ? currentEntries.map((e)=>e.testPath) : void 0
|
|
410
|
+
});
|
|
411
|
+
if (coverageProvider && (!isFailure || coverage.reportOnFailure)) {
|
|
412
|
+
const { generateCoverage } = await import("./0~4403.js").then((mod)=>({
|
|
413
|
+
generateCoverage: mod.generateCoverage
|
|
414
|
+
}));
|
|
415
|
+
await generateCoverage(context, results, coverageProvider);
|
|
368
416
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
unhandledErrors: errors,
|
|
376
|
-
snapshotSummary: snapshotManager.summary,
|
|
377
|
-
duration,
|
|
378
|
-
getSourcemap: async (name)=>{
|
|
379
|
-
const resource = returns.find((r)=>r.assetNames.includes(name));
|
|
380
|
-
const sourceMap = (await resource?.getSourceMaps([
|
|
381
|
-
name
|
|
382
|
-
]))?.[name];
|
|
383
|
-
return sourceMap ? JSON.parse(sourceMap) : null;
|
|
384
|
-
},
|
|
385
|
-
filterRerunTestPaths: currentEntries.length ? currentEntries.map((e)=>e.testPath) : void 0
|
|
386
|
-
});
|
|
387
|
-
if (coverageProvider && (!isFailure || coverage.reportOnFailure)) {
|
|
388
|
-
const { generateCoverage } = await import("./0~4403.js").then((mod)=>({
|
|
389
|
-
generateCoverage: mod.generateCoverage
|
|
390
|
-
}));
|
|
391
|
-
await generateCoverage(context, results, coverageProvider);
|
|
392
|
-
}
|
|
393
|
-
if (isFailure) {
|
|
394
|
-
const bail = context.normalizedConfig.bail;
|
|
395
|
-
if (bail && context.stateManager.getCountOfFailedTests() >= bail) logger_logger.log(color.yellow(`Test run aborted due to reaching the bail limit of ${bail} failed test(s).`));
|
|
417
|
+
if (isFailure) {
|
|
418
|
+
const bail = context.normalizedConfig.bail;
|
|
419
|
+
if (bail && context.stateManager.getCountOfFailedTests() >= bail) logger_logger.log(color.yellow(`Test run aborted due to reaching the bail limit of ${bail} failed test(s).`));
|
|
420
|
+
}
|
|
421
|
+
} finally{
|
|
422
|
+
await browserClose?.();
|
|
396
423
|
}
|
|
397
424
|
};
|
|
398
425
|
if ('watch' === command) {
|
|
@@ -412,10 +439,11 @@ async function runTests(context) {
|
|
|
412
439
|
const handleSignal = async (signal)=>{
|
|
413
440
|
logger_logger.log(color.yellow(`\nReceived ${signal}, cleaning up...`));
|
|
414
441
|
await cleanup();
|
|
415
|
-
process.exit(
|
|
442
|
+
process.exit(getSignalExitCode(signal));
|
|
416
443
|
};
|
|
417
444
|
process.on('SIGINT', handleSignal);
|
|
418
445
|
process.on('SIGTERM', handleSignal);
|
|
446
|
+
process.on('SIGTSTP', handleSignal);
|
|
419
447
|
const afterTestsWatchRun = ()=>{
|
|
420
448
|
logger_logger.log(color.green(' Waiting for file changes...'));
|
|
421
449
|
if (enableCliShortcuts) if (snapshotManager.summary.unmatched) logger_logger.log(` ${color.dim('press')} ${color.yellow(color.bold('u'))} ${color.dim('to update snapshot')}${color.dim(', press')} ${color.bold('h')} ${color.dim('to show help')}\n`);
|
|
@@ -535,11 +563,12 @@ async function runTests(context) {
|
|
|
535
563
|
const handleSignal = async (signal)=>{
|
|
536
564
|
logger_logger.log(color.yellow(`\nReceived ${signal}, cleaning up...`));
|
|
537
565
|
await cleanup();
|
|
538
|
-
process.exit(
|
|
566
|
+
process.exit(getSignalExitCode(signal));
|
|
539
567
|
};
|
|
540
568
|
process.on('exit', unExpectedExit);
|
|
541
569
|
process.on('SIGINT', handleSignal);
|
|
542
570
|
process.on('SIGTERM', handleSignal);
|
|
571
|
+
process.on('SIGTSTP', handleSignal);
|
|
543
572
|
try {
|
|
544
573
|
await run();
|
|
545
574
|
isTeardown = true;
|
|
@@ -550,6 +579,7 @@ async function runTests(context) {
|
|
|
550
579
|
process.off('exit', unExpectedExit);
|
|
551
580
|
process.off('SIGINT', handleSignal);
|
|
552
581
|
process.off('SIGTERM', handleSignal);
|
|
582
|
+
process.off('SIGTSTP', handleSignal);
|
|
553
583
|
}
|
|
554
584
|
}
|
|
555
585
|
}
|
|
@@ -24,7 +24,7 @@ __webpack_require__.add({
|
|
|
24
24
|
return token;
|
|
25
25
|
};
|
|
26
26
|
},
|
|
27
|
-
"../../node_modules/.pnpm/@babel+code-frame@7.
|
|
27
|
+
"../../node_modules/.pnpm/@babel+code-frame@7.29.0/node_modules/@babel/code-frame/lib/index.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
28
28
|
var picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
29
29
|
var jsTokens = __webpack_require__("../../node_modules/.pnpm/js-tokens@4.0.0/node_modules/js-tokens/index.js");
|
|
30
30
|
var helperValidatorIdentifier = __webpack_require__("../../node_modules/.pnpm/@babel+helper-validator-identifier@7.28.5/node_modules/@babel/helper-validator-identifier/lib/index.js");
|
|
@@ -65,29 +65,29 @@ __webpack_require__.add({
|
|
|
65
65
|
const NEWLINE$1 = /\r\n|[\n\r\u2028\u2029]/;
|
|
66
66
|
const BRACKET = /^[()[\]{}]$/;
|
|
67
67
|
let tokenize;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
68
|
+
const JSX_TAG = /^[a-z][\w-]*$/i;
|
|
69
|
+
const getTokenType = function(token, offset, text) {
|
|
70
|
+
if ("name" === token.type) {
|
|
71
|
+
const tokenValue = token.value;
|
|
72
|
+
if (helperValidatorIdentifier.isKeyword(tokenValue) || helperValidatorIdentifier.isStrictReservedWord(tokenValue, true) || sometimesKeywords.has(tokenValue)) return "keyword";
|
|
73
|
+
if (JSX_TAG.test(tokenValue) && ("<" === text[offset - 1] || "</" === text.slice(offset - 2, offset))) return "jsxIdentifier";
|
|
74
|
+
const firstChar = String.fromCodePoint(tokenValue.codePointAt(0));
|
|
75
|
+
if (firstChar !== firstChar.toLowerCase()) return "capitalized";
|
|
76
|
+
}
|
|
77
|
+
if ("punctuator" === token.type && BRACKET.test(token.value)) return "bracket";
|
|
78
|
+
if ("invalid" === token.type && ("@" === token.value || "#" === token.value)) return "punctuator";
|
|
79
|
+
return token.type;
|
|
80
|
+
};
|
|
81
|
+
tokenize = function*(text) {
|
|
82
|
+
let match;
|
|
83
|
+
while(match = jsTokens.default.exec(text)){
|
|
84
|
+
const token = jsTokens.matchToToken(match);
|
|
85
|
+
yield {
|
|
86
|
+
type: getTokenType(token, match.index, text),
|
|
87
|
+
value: token.value
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
91
|
function highlight(text) {
|
|
92
92
|
if ("" === text) return "";
|
|
93
93
|
const defs = getDefs(true);
|
|
@@ -97,16 +97,16 @@ __webpack_require__.add({
|
|
|
97
97
|
return highlighted;
|
|
98
98
|
}
|
|
99
99
|
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
|
|
100
|
-
function getMarkerLines(loc, source, opts) {
|
|
100
|
+
function getMarkerLines(loc, source, opts, startLineBaseZero) {
|
|
101
101
|
const startLoc = Object.assign({
|
|
102
102
|
column: 0,
|
|
103
103
|
line: -1
|
|
104
104
|
}, loc.start);
|
|
105
105
|
const endLoc = Object.assign({}, startLoc, loc.end);
|
|
106
106
|
const { linesAbove = 2, linesBelow = 3 } = opts || {};
|
|
107
|
-
const startLine = startLoc.line;
|
|
107
|
+
const startLine = startLoc.line - startLineBaseZero;
|
|
108
108
|
const startColumn = startLoc.column;
|
|
109
|
-
const endLine = endLoc.line;
|
|
109
|
+
const endLine = endLoc.line - startLineBaseZero;
|
|
110
110
|
const endColumn = endLoc.column;
|
|
111
111
|
let start = Math.max(startLine - (linesAbove + 1), 0);
|
|
112
112
|
let end = Math.min(source.length, endLine + linesBelow);
|
|
@@ -152,15 +152,16 @@ __webpack_require__.add({
|
|
|
152
152
|
}
|
|
153
153
|
function codeFrameColumns(rawLines, loc, opts = {}) {
|
|
154
154
|
const shouldHighlight = opts.forceColor || isColorSupported() && opts.highlightCode;
|
|
155
|
+
const startLineBaseZero = (opts.startLine || 1) - 1;
|
|
155
156
|
const defs = getDefs(shouldHighlight);
|
|
156
157
|
const lines = rawLines.split(NEWLINE);
|
|
157
|
-
const { start, end, markerLines } = getMarkerLines(loc, lines, opts);
|
|
158
|
+
const { start, end, markerLines } = getMarkerLines(loc, lines, opts, startLineBaseZero);
|
|
158
159
|
const hasColumns = loc.start && "number" == typeof loc.start.column;
|
|
159
|
-
const numberMaxWidth = String(end).length;
|
|
160
|
+
const numberMaxWidth = String(end + startLineBaseZero).length;
|
|
160
161
|
const highlightedLines = shouldHighlight ? highlight(rawLines) : rawLines;
|
|
161
162
|
let frame = highlightedLines.split(NEWLINE, end).slice(start, end).map((line, index)=>{
|
|
162
163
|
const number = start + 1 + index;
|
|
163
|
-
const paddedNumber = ` ${number}`.slice(-numberMaxWidth);
|
|
164
|
+
const paddedNumber = ` ${number + startLineBaseZero}`.slice(-numberMaxWidth);
|
|
164
165
|
const gutter = ` ${paddedNumber} |`;
|
|
165
166
|
const hasMarker = markerLines[number];
|
|
166
167
|
const lastMarkerLine = !markerLines[number + 1];
|
package/dist/0~3062.js
CHANGED
|
@@ -262,7 +262,7 @@ function getWindowKeys(global, win, additionalKeys = []) {
|
|
|
262
262
|
}));
|
|
263
263
|
}
|
|
264
264
|
function isClassLike(name) {
|
|
265
|
-
return name[0]
|
|
265
|
+
return name[0] && name.startsWith(name[0].toUpperCase());
|
|
266
266
|
}
|
|
267
267
|
function installGlobal(global, win, options = {}) {
|
|
268
268
|
const { bindFunctions = true } = options || {};
|
package/dist/0~3346.js
CHANGED
package/dist/0~5835.js
CHANGED
|
@@ -2,7 +2,7 @@ import "node:module";
|
|
|
2
2
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
3
3
|
import { logger as logger_logger } from "./3160.js";
|
|
4
4
|
import { createRequire as external_node_module_createRequire } from "./4881.js";
|
|
5
|
-
import { pathToFileURL } from "./6198.js";
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from "./6198.js";
|
|
6
6
|
import { node_vm, asModule, shouldInterop, interopModule } from "./0~3346.js";
|
|
7
7
|
import { posix } from "./7011.js";
|
|
8
8
|
const external_node_path_ = __webpack_require__("path");
|
|
@@ -38,9 +38,20 @@ const createRequire = (filename, distPath, rstestContext, assetFiles, interopDef
|
|
|
38
38
|
require.main = _require.main;
|
|
39
39
|
return require;
|
|
40
40
|
};
|
|
41
|
-
const defineRstestDynamicImport = ({ testPath, interopDefault, returnModule = false })=>async (specifier, importAttributes)=>{
|
|
41
|
+
const defineRstestDynamicImport = ({ testPath, interopDefault, returnModule = false, assetFiles })=>async (specifier, importAttributes)=>{
|
|
42
42
|
const resolvedPath = (0, external_node_path_.isAbsolute)(specifier) ? pathToFileURL(specifier) : import.meta.resolve(specifier, pathToFileURL(testPath));
|
|
43
43
|
const modulePath = 'string' == typeof resolvedPath ? resolvedPath : resolvedPath.pathname;
|
|
44
|
+
if (modulePath.endsWith('.wasm')) {
|
|
45
|
+
const normalizedPath = posix.normalize(modulePath.startsWith('file://') ? fileURLToPath(modulePath) : modulePath);
|
|
46
|
+
const content = assetFiles[normalizedPath];
|
|
47
|
+
if (content) {
|
|
48
|
+
const wasmBuffer = Buffer.from(content, 'base64');
|
|
49
|
+
const wasmModule = await WebAssembly.compile(wasmBuffer);
|
|
50
|
+
const wasmInstance = await WebAssembly.instantiate(wasmModule);
|
|
51
|
+
const exports = wasmInstance.exports;
|
|
52
|
+
return returnModule ? asModule(exports, exports) : exports;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
44
55
|
if (importAttributes?.with?.rstest) delete importAttributes.with.rstest;
|
|
45
56
|
if (modulePath.endsWith('.json')) {
|
|
46
57
|
const importedModule = await import(modulePath, {
|
|
@@ -106,7 +117,8 @@ const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles
|
|
|
106
117
|
},
|
|
107
118
|
__rstest_dynamic_import__: defineRstestDynamicImport({
|
|
108
119
|
testPath,
|
|
109
|
-
interopDefault
|
|
120
|
+
interopDefault,
|
|
121
|
+
assetFiles
|
|
110
122
|
}),
|
|
111
123
|
__dirname: fileDir,
|
|
112
124
|
__filename: testPath,
|
|
@@ -121,7 +133,8 @@ const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles
|
|
|
121
133
|
importModuleDynamically: (specifier, _referencer, importAttributes)=>defineRstestDynamicImport({
|
|
122
134
|
testPath,
|
|
123
135
|
interopDefault,
|
|
124
|
-
returnModule: true
|
|
136
|
+
returnModule: true,
|
|
137
|
+
assetFiles
|
|
125
138
|
})(specifier, importAttributes)
|
|
126
139
|
});
|
|
127
140
|
fn(...Object.values(context));
|
package/dist/0~6923.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
3
3
|
import { logger as logger_logger } from "./3160.js";
|
|
4
|
-
import { pathToFileURL } from "./6198.js";
|
|
4
|
+
import { fileURLToPath, pathToFileURL } from "./6198.js";
|
|
5
5
|
import { node_vm, interopModule, shouldInterop } from "./0~3346.js";
|
|
6
6
|
import { posix } from "./7011.js";
|
|
7
7
|
const external_node_path_ = __webpack_require__("path");
|
|
@@ -15,8 +15,16 @@ const isRelativePath = (p)=>/^\.\.?\//.test(p);
|
|
|
15
15
|
const defineRstestDynamicImport = ({ distPath, testPath, assetFiles, interopDefault, returnModule, esmMode })=>async (specifier, importAttributes)=>{
|
|
16
16
|
const currentDirectory = posix.dirname(distPath);
|
|
17
17
|
const joinedPath = isRelativePath(specifier) ? posix.join(currentDirectory, specifier) : specifier;
|
|
18
|
-
const
|
|
18
|
+
const normalizedPath = posix.normalize(joinedPath.startsWith('file://') ? fileURLToPath(joinedPath) : joinedPath);
|
|
19
|
+
const content = assetFiles[normalizedPath];
|
|
19
20
|
if (content) try {
|
|
21
|
+
if (specifier.endsWith('.wasm')) {
|
|
22
|
+
const wasmBuffer = Buffer.from(content, 'base64');
|
|
23
|
+
const wasmModule = await WebAssembly.compile(wasmBuffer);
|
|
24
|
+
const wasmInstance = await WebAssembly.instantiate(wasmModule);
|
|
25
|
+
const exports = wasmInstance.exports;
|
|
26
|
+
return returnModule ? await asModule(exports) : exports;
|
|
27
|
+
}
|
|
20
28
|
return await loadModule({
|
|
21
29
|
codeContent: content,
|
|
22
30
|
testPath,
|
|
@@ -88,7 +96,7 @@ const asModule = async (something, context, unlinked)=>{
|
|
|
88
96
|
context
|
|
89
97
|
});
|
|
90
98
|
if (unlinked) return syntheticModule;
|
|
91
|
-
await syntheticModule.link(()=>
|
|
99
|
+
await syntheticModule.link(()=>void 0);
|
|
92
100
|
await syntheticModule.evaluate();
|
|
93
101
|
return syntheticModule;
|
|
94
102
|
};
|
package/dist/0~7583.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import "node:module";
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
4
|
import { lstat, open as promises_open, readdir, realpath as promises_realpath, stat as promises_stat } from "fs/promises";
|
|
5
|
+
import { EventEmitter } from "events";
|
|
6
|
+
import { Readable } from "node:stream";
|
|
5
7
|
import "./3160.js";
|
|
6
8
|
import { readdir as promises_readdir, lstat as promises_lstat, promises_stat as promises_promises_stat, realpath as external_node_fs_promises_realpath } from "./1157.js";
|
|
7
|
-
import { Readable } from "./0~1981.js";
|
|
8
|
-
import { EventEmitter } from "./9131.js";
|
|
9
9
|
const external_node_path_ = __webpack_require__("path");
|
|
10
10
|
const EntryTypes = {
|
|
11
11
|
FILE_TYPE: 'files',
|