@lvce-editor/test-with-playwright-worker 22.12.1 → 22.13.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/dist/svgScreenshot.js +37 -15
- package/dist/workerMain.js +116 -25
- package/package.json +1 -1
package/dist/svgScreenshot.js
CHANGED
|
@@ -215,6 +215,10 @@ var SvgScreenshot = (function (exports) {
|
|
|
215
215
|
// correctly by all compliant CSS consumers.
|
|
216
216
|
const STYLE_TAG = /(<)(\/?style\b)/gi;
|
|
217
217
|
const COMMENT_OPEN = /(<)(!--)/g;
|
|
218
|
+
|
|
219
|
+
// Characters that end an at-rule name, mirroring RE_AT_END in the tokenizer.
|
|
220
|
+
// Params starting with anything else need a space to stay separate tokens.
|
|
221
|
+
const AT_NAME_END = /[\t\n\f\r "#'()/;[\\\]{}]/;
|
|
218
222
|
function escapeHTMLInCSS(str) {
|
|
219
223
|
if (typeof str !== 'string') return str;
|
|
220
224
|
if (!str.includes('<')) return str;
|
|
@@ -240,12 +244,13 @@ var SvgScreenshot = (function (exports) {
|
|
|
240
244
|
function atruleStart(str, node) {
|
|
241
245
|
let name = '@' + node.name;
|
|
242
246
|
let params = node.params ? str.rawValue(node, 'params') : '';
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
+
let afterName = node.raws.afterName;
|
|
248
|
+
if (typeof afterName === 'undefined') {
|
|
249
|
+
afterName = params ? ' ' : '';
|
|
250
|
+
} else if (afterName === '' && params && !AT_NAME_END.test(params[0])) {
|
|
251
|
+
afterName = ' ';
|
|
247
252
|
}
|
|
248
|
-
return name + params;
|
|
253
|
+
return name + afterName + params;
|
|
249
254
|
}
|
|
250
255
|
function pushBody(str, stack, node) {
|
|
251
256
|
let nodes = node.nodes;
|
|
@@ -257,10 +262,19 @@ var SvgScreenshot = (function (exports) {
|
|
|
257
262
|
let semicolon = str.raw(node, 'semicolon');
|
|
258
263
|
let isDocument = node.type === 'document';
|
|
259
264
|
for (let i = nodes.length - 1; i >= 0; i--) {
|
|
265
|
+
let child = nodes[i];
|
|
266
|
+
let childSemicolon = last !== i || semicolon;
|
|
267
|
+
// A childless at-rule or a custom property declaration that still has
|
|
268
|
+
// following siblings must be terminated. Without the semicolon those
|
|
269
|
+
// trailing comments are folded into the at-rule's prelude or the custom
|
|
270
|
+
// property's value and disappear when the output is re-parsed.
|
|
271
|
+
if (!childSemicolon && i < nodes.length - 1 && (child.type === 'atrule' && !child.nodes || child.type === 'decl' && child.prop.startsWith('--'))) {
|
|
272
|
+
childSemicolon = true;
|
|
273
|
+
}
|
|
260
274
|
stack.push({
|
|
261
275
|
document: isDocument,
|
|
262
|
-
node:
|
|
263
|
-
semicolon:
|
|
276
|
+
node: child,
|
|
277
|
+
semicolon: childSemicolon
|
|
264
278
|
});
|
|
265
279
|
}
|
|
266
280
|
}
|
|
@@ -1724,15 +1738,12 @@ var SvgScreenshot = (function (exports) {
|
|
|
1724
1738
|
}
|
|
1725
1739
|
loadFile(path, cssFile, trusted) {
|
|
1726
1740
|
if (!trusted && !this.unsafeMap) {
|
|
1727
|
-
if (!/\.map$/i.test(path))
|
|
1741
|
+
if (!/\.map$/i.test(path)) return undefined;
|
|
1742
|
+
if (!cssFile) return undefined;
|
|
1743
|
+
let rel = relative(dirname(cssFile), path);
|
|
1744
|
+
if (rel === '..' || rel.startsWith('..' + sep) || isAbsolute(rel)) {
|
|
1728
1745
|
return undefined;
|
|
1729
1746
|
}
|
|
1730
|
-
if (cssFile) {
|
|
1731
|
-
let relativePath = relative(dirname(cssFile), path);
|
|
1732
|
-
if (relativePath === '..' || relativePath.startsWith('..' + sep) || isAbsolute(relativePath)) {
|
|
1733
|
-
return undefined;
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
1747
|
}
|
|
1737
1748
|
this.root = dirname(path);
|
|
1738
1749
|
if (existsSync(path)) {
|
|
@@ -3493,11 +3504,22 @@ var SvgScreenshot = (function (exports) {
|
|
|
3493
3504
|
if (hasRequiredWarning) return warning;
|
|
3494
3505
|
hasRequiredWarning = 1;
|
|
3495
3506
|
|
|
3507
|
+
let Container = requireContainer();
|
|
3508
|
+
let {
|
|
3509
|
+
my
|
|
3510
|
+
} = requireSymbols();
|
|
3496
3511
|
class Warning {
|
|
3497
3512
|
constructor(text, opts = {}) {
|
|
3498
3513
|
this.type = 'warning';
|
|
3499
3514
|
this.text = text;
|
|
3500
3515
|
if (opts.node && opts.node.source) {
|
|
3516
|
+
if (!opts.node[my]) {
|
|
3517
|
+
// The node comes from another PostCSS copy in node_modules, so it does
|
|
3518
|
+
// not have this copy’s methods. Container#normalize() rebuilds such
|
|
3519
|
+
// nodes on insert, but a node passed straight to Result#warn() never
|
|
3520
|
+
// goes through it.
|
|
3521
|
+
Container.rebuild(opts.node);
|
|
3522
|
+
}
|
|
3501
3523
|
let range = opts.node.rangeBy(opts);
|
|
3502
3524
|
this.line = range.start.line;
|
|
3503
3525
|
this.column = range.start.column;
|
|
@@ -4242,7 +4264,7 @@ var SvgScreenshot = (function (exports) {
|
|
|
4242
4264
|
let Root = requireRoot();
|
|
4243
4265
|
class Processor {
|
|
4244
4266
|
constructor(plugins = []) {
|
|
4245
|
-
this.version = '8.5.
|
|
4267
|
+
this.version = '8.5.23';
|
|
4246
4268
|
this.plugins = this.normalize(plugins);
|
|
4247
4269
|
}
|
|
4248
4270
|
normalize(plugins) {
|
package/dist/workerMain.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { join, dirname, basename } from 'node:path';
|
|
2
|
-
import { readFile, writeFile, readdir,
|
|
1
|
+
import { join, dirname, basename, extname } from 'node:path';
|
|
2
|
+
import { readFile, writeFile, readdir, rm, mkdir, access, mkdtemp } from 'node:fs/promises';
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
4
4
|
import IstanbulCoverage from 'istanbul-lib-coverage';
|
|
5
5
|
import v8ToIstanbul from 'v8-to-istanbul';
|
|
@@ -514,7 +514,10 @@ const constructError = (message, type, name) => {
|
|
|
514
514
|
if (ErrorConstructor === Error) {
|
|
515
515
|
const error = new Error(message);
|
|
516
516
|
if (name && name !== 'VError') {
|
|
517
|
-
error
|
|
517
|
+
Object.defineProperty(error, 'name', {
|
|
518
|
+
configurable: true,
|
|
519
|
+
value: name
|
|
520
|
+
});
|
|
518
521
|
}
|
|
519
522
|
return error;
|
|
520
523
|
}
|
|
@@ -545,31 +548,45 @@ const getParentStack = error => {
|
|
|
545
548
|
};
|
|
546
549
|
const MethodNotFound = -32601;
|
|
547
550
|
const Custom = -32001;
|
|
551
|
+
const setStack = (error, stack) => {
|
|
552
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, 'stack');
|
|
553
|
+
if (descriptor) {
|
|
554
|
+
if (!descriptor.configurable && !descriptor.writable) {
|
|
555
|
+
return;
|
|
556
|
+
}
|
|
557
|
+
if (!descriptor.configurable && descriptor.writable) {
|
|
558
|
+
error.stack = stack;
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
Object.defineProperty(error, 'stack', {
|
|
563
|
+
configurable: true,
|
|
564
|
+
value: stack,
|
|
565
|
+
writable: true
|
|
566
|
+
});
|
|
567
|
+
};
|
|
548
568
|
const restoreExistingError = (error, currentStack) => {
|
|
549
569
|
if (typeof error.stack === 'string') {
|
|
550
|
-
error
|
|
570
|
+
setStack(error, `${error.stack}${NewLine}${currentStack}`);
|
|
551
571
|
}
|
|
552
572
|
return error;
|
|
553
573
|
};
|
|
554
574
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
555
575
|
const restoredError = new JsonRpcError(error.message);
|
|
556
576
|
const parentStack = getParentStack(error);
|
|
557
|
-
restoredError
|
|
577
|
+
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
558
578
|
return restoredError;
|
|
559
579
|
};
|
|
560
580
|
const restoreStackFromData = (restoredError, error, currentStack) => {
|
|
561
581
|
if (error.data.stack && error.data.type && error.message) {
|
|
562
|
-
restoredError
|
|
582
|
+
setStack(restoredError, `${error.data.type}: ${error.message}${NewLine}${error.data.stack}${NewLine}${currentStack}`);
|
|
563
583
|
return;
|
|
564
584
|
}
|
|
565
585
|
if (error.data.stack) {
|
|
566
|
-
restoredError
|
|
586
|
+
setStack(restoredError, error.data.stack);
|
|
567
587
|
}
|
|
568
588
|
};
|
|
569
589
|
const applyDataProperties = (restoredError, error) => {
|
|
570
|
-
if (!error.data) {
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
590
|
restoreStackFromData(restoredError, error, getCurrentStack());
|
|
574
591
|
if (error.data.codeFrame) {
|
|
575
592
|
// @ts-ignore
|
|
@@ -590,7 +607,7 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
590
607
|
const indexNewLine = getNewLineIndex(lowerStack);
|
|
591
608
|
const parentStack = getParentStack(error);
|
|
592
609
|
// @ts-ignore
|
|
593
|
-
restoredError
|
|
610
|
+
setStack(restoredError, `${parentStack}${lowerStack.slice(indexNewLine)}`);
|
|
594
611
|
}
|
|
595
612
|
if (error.codeFrame) {
|
|
596
613
|
// @ts-ignore
|
|
@@ -989,6 +1006,41 @@ const getTests = async testSrc => {
|
|
|
989
1006
|
}
|
|
990
1007
|
};
|
|
991
1008
|
|
|
1009
|
+
const selector = 'script.RendererWorkerTrace';
|
|
1010
|
+
const getFileName = test => {
|
|
1011
|
+
const name = basename(test);
|
|
1012
|
+
return `${name.slice(0, -extname(name).length)}.json`;
|
|
1013
|
+
};
|
|
1014
|
+
const prepareDirectory = async directory => {
|
|
1015
|
+
await rm(directory, {
|
|
1016
|
+
force: true,
|
|
1017
|
+
recursive: true
|
|
1018
|
+
});
|
|
1019
|
+
await mkdir(directory, {
|
|
1020
|
+
recursive: true
|
|
1021
|
+
});
|
|
1022
|
+
};
|
|
1023
|
+
const exportTrace = async ({
|
|
1024
|
+
directory,
|
|
1025
|
+
page,
|
|
1026
|
+
test
|
|
1027
|
+
}) => {
|
|
1028
|
+
let text;
|
|
1029
|
+
try {
|
|
1030
|
+
text = await page.evaluate(traceSelector => {
|
|
1031
|
+
return globalThis.document.querySelector(traceSelector)?.textContent || undefined;
|
|
1032
|
+
}, selector);
|
|
1033
|
+
} catch {
|
|
1034
|
+
return false;
|
|
1035
|
+
}
|
|
1036
|
+
if (!text) {
|
|
1037
|
+
return false;
|
|
1038
|
+
}
|
|
1039
|
+
JSON.parse(text);
|
|
1040
|
+
await writeFile(join(directory, getFileName(test)), `${text}\n`);
|
|
1041
|
+
return true;
|
|
1042
|
+
};
|
|
1043
|
+
|
|
992
1044
|
const Cli = 6001;
|
|
993
1045
|
|
|
994
1046
|
const browserScriptCache = {};
|
|
@@ -1267,14 +1319,22 @@ const getTestState = (testOverlayState, text) => {
|
|
|
1267
1319
|
* @param {number} port
|
|
1268
1320
|
* @param {boolean} traceFocus
|
|
1269
1321
|
*/
|
|
1270
|
-
const getUrlFromTestFile = (absolutePath, port, traceFocus) => {
|
|
1322
|
+
const getUrlFromTestFile = (absolutePath, port, traceFocus, traceRendererWorker) => {
|
|
1271
1323
|
const baseName = basename(absolutePath);
|
|
1272
1324
|
const htmlFileName = baseName.slice(0, -'.js'.length) + '.html';
|
|
1273
|
-
const
|
|
1325
|
+
const url = new URL(`http://localhost:${port}/tests/${htmlFileName}`);
|
|
1274
1326
|
if (traceFocus) {
|
|
1275
|
-
|
|
1327
|
+
url.searchParams.set('traceFocus', 'true');
|
|
1328
|
+
}
|
|
1329
|
+
if (traceRendererWorker) {
|
|
1330
|
+
url.searchParams.set('traceRendererWorker', 'true');
|
|
1276
1331
|
}
|
|
1277
|
-
return
|
|
1332
|
+
return url.href;
|
|
1333
|
+
};
|
|
1334
|
+
const navigateToTest = async (page, url) => {
|
|
1335
|
+
await page.goto(url, {
|
|
1336
|
+
waitUntil: 'domcontentloaded'
|
|
1337
|
+
});
|
|
1278
1338
|
};
|
|
1279
1339
|
const runTest = async ({
|
|
1280
1340
|
page,
|
|
@@ -1283,17 +1343,16 @@ const runTest = async ({
|
|
|
1283
1343
|
test,
|
|
1284
1344
|
testSrc,
|
|
1285
1345
|
timeout,
|
|
1286
|
-
traceFocus
|
|
1346
|
+
traceFocus,
|
|
1347
|
+
traceRendererWorker
|
|
1287
1348
|
}) => {
|
|
1288
1349
|
const start = performance.now();
|
|
1289
1350
|
try {
|
|
1290
1351
|
const {
|
|
1291
1352
|
expect
|
|
1292
1353
|
} = await import('@playwright/test');
|
|
1293
|
-
const url = getUrlFromTestFile(test, port, traceFocus);
|
|
1294
|
-
await page
|
|
1295
|
-
waitUntil: 'networkidle'
|
|
1296
|
-
});
|
|
1354
|
+
const url = getUrlFromTestFile(test, port, traceFocus ?? false, traceRendererWorker ?? false);
|
|
1355
|
+
await navigateToTest(page, url);
|
|
1297
1356
|
const testOverlay = page.locator('#TestOverlay');
|
|
1298
1357
|
await expect(testOverlay).toBeVisible({
|
|
1299
1358
|
timeout
|
|
@@ -1371,6 +1430,7 @@ const runTests = async ({
|
|
|
1371
1430
|
onResult,
|
|
1372
1431
|
page,
|
|
1373
1432
|
port,
|
|
1433
|
+
rendererWorkerTraceDirectory,
|
|
1374
1434
|
svgScreenshotOptions,
|
|
1375
1435
|
tests,
|
|
1376
1436
|
testSrc,
|
|
@@ -1391,10 +1451,18 @@ const runTests = async ({
|
|
|
1391
1451
|
testSrc,
|
|
1392
1452
|
timeout,
|
|
1393
1453
|
traceFocus: traceFocus ?? false,
|
|
1454
|
+
traceRendererWorker: rendererWorkerTraceDirectory !== undefined,
|
|
1394
1455
|
...(svgScreenshotOptions && {
|
|
1395
1456
|
svgScreenshotOptions
|
|
1396
1457
|
})
|
|
1397
1458
|
});
|
|
1459
|
+
if (rendererWorkerTraceDirectory) {
|
|
1460
|
+
await exportTrace({
|
|
1461
|
+
directory: rendererWorkerTraceDirectory,
|
|
1462
|
+
page,
|
|
1463
|
+
test
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1398
1466
|
await onResult(result);
|
|
1399
1467
|
// @ts-ignore
|
|
1400
1468
|
const resultCounts = getResultCounts$1(result.status);
|
|
@@ -1441,11 +1509,14 @@ const getResultCounts = status => {
|
|
|
1441
1509
|
};
|
|
1442
1510
|
}
|
|
1443
1511
|
};
|
|
1444
|
-
const getAllTestsUrl = (port, filter, traceFocus) => {
|
|
1512
|
+
const getAllTestsUrl = (port, filter, traceFocus, traceRendererWorker) => {
|
|
1445
1513
|
const url = new URL(`http://localhost:${port}/tests/_all.html`);
|
|
1446
1514
|
if (traceFocus) {
|
|
1447
1515
|
url.searchParams.set('traceFocus', 'true');
|
|
1448
1516
|
}
|
|
1517
|
+
if (traceRendererWorker) {
|
|
1518
|
+
url.searchParams.set('traceRendererWorker', 'true');
|
|
1519
|
+
}
|
|
1449
1520
|
if (filter) {
|
|
1450
1521
|
url.searchParams.set('filter', filter);
|
|
1451
1522
|
}
|
|
@@ -1538,13 +1609,14 @@ const runTestsWithReusedPage = async ({
|
|
|
1538
1609
|
onResult,
|
|
1539
1610
|
page,
|
|
1540
1611
|
port,
|
|
1612
|
+
rendererWorkerTraceDirectory,
|
|
1541
1613
|
timeout,
|
|
1542
1614
|
traceFocus
|
|
1543
1615
|
}) => {
|
|
1544
1616
|
const start = performance.now();
|
|
1545
1617
|
let results;
|
|
1546
1618
|
try {
|
|
1547
|
-
const url = getAllTestsUrl(port, filter, traceFocus ?? false);
|
|
1619
|
+
const url = getAllTestsUrl(port, filter, traceFocus ?? false, rendererWorkerTraceDirectory !== undefined);
|
|
1548
1620
|
await page.goto(url, {
|
|
1549
1621
|
timeout,
|
|
1550
1622
|
waitUntil: 'networkidle'
|
|
@@ -1554,6 +1626,13 @@ const runTestsWithReusedPage = async ({
|
|
|
1554
1626
|
} catch (error) {
|
|
1555
1627
|
results = [getFailedAllTestsResult(error, start)];
|
|
1556
1628
|
}
|
|
1629
|
+
if (rendererWorkerTraceDirectory) {
|
|
1630
|
+
await exportTrace({
|
|
1631
|
+
directory: rendererWorkerTraceDirectory,
|
|
1632
|
+
page,
|
|
1633
|
+
test: '_all.html'
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1557
1636
|
let failed = 0;
|
|
1558
1637
|
let passed = 0;
|
|
1559
1638
|
let skipped = 0;
|
|
@@ -1803,7 +1882,7 @@ const getPort = () => {
|
|
|
1803
1882
|
};
|
|
1804
1883
|
|
|
1805
1884
|
const getPossibleServerPaths = cwd => {
|
|
1806
|
-
const toTry = ['@lvce-editor/server', pathToFileURL(join(cwd, '..', 'server', 'node_modules', '@lvce-editor', 'server', 'index.js')).toString(), pathToFileURL(join(cwd, '..', 'build', 'node_modules', '@lvce-editor', 'server', 'index.js')).toString(), pathToFileURL(join(cwd, '..', '..', '..', 'packages', 'server', 'node_modules', '@lvce-editor', 'server', 'index.js')).toString()];
|
|
1885
|
+
const toTry = ['@lvce-editor/server', pathToFileURL(join(cwd, '..', '..', 'node_modules', '@lvce-editor', 'server', 'index.js')).toString(), pathToFileURL(join(cwd, '..', 'server', 'node_modules', '@lvce-editor', 'server', 'index.js')).toString(), pathToFileURL(join(cwd, '..', 'build', 'node_modules', '@lvce-editor', 'server', 'index.js')).toString(), pathToFileURL(join(cwd, '..', '..', '..', 'packages', 'server', 'node_modules', '@lvce-editor', 'server', 'index.js')).toString()];
|
|
1807
1886
|
return toTry;
|
|
1808
1887
|
};
|
|
1809
1888
|
|
|
@@ -2117,8 +2196,9 @@ const tearDownTests = async ({
|
|
|
2117
2196
|
* @param {string} filter
|
|
2118
2197
|
* @param {boolean} reusePage
|
|
2119
2198
|
* @param {boolean} coverage
|
|
2199
|
+
* @param {boolean} traceRendererWorker
|
|
2120
2200
|
*/
|
|
2121
|
-
const runAllTests = async (extensionPath, testPath, cwd, browser, headless, timeout, runtimeOptions, traceFocus, filter, reusePage, svgScreenshotOptions, coverage) => {
|
|
2201
|
+
const runAllTests = async (extensionPath, testPath, cwd, browser, headless, timeout, runtimeOptions, traceFocus, filter, reusePage, svgScreenshotOptions, coverage, traceRendererWorker) => {
|
|
2122
2202
|
string(extensionPath);
|
|
2123
2203
|
string(testPath);
|
|
2124
2204
|
string(cwd);
|
|
@@ -2128,6 +2208,7 @@ const runAllTests = async (extensionPath, testPath, cwd, browser, headless, time
|
|
|
2128
2208
|
object(runtimeOptions);
|
|
2129
2209
|
boolean(reusePage);
|
|
2130
2210
|
boolean(coverage);
|
|
2211
|
+
boolean(traceRendererWorker);
|
|
2131
2212
|
if (svgScreenshotOptions !== undefined) {
|
|
2132
2213
|
object(svgScreenshotOptions);
|
|
2133
2214
|
}
|
|
@@ -2137,6 +2218,10 @@ const runAllTests = async (extensionPath, testPath, cwd, browser, headless, time
|
|
|
2137
2218
|
signal
|
|
2138
2219
|
} = controller;
|
|
2139
2220
|
const testSrc = join(testPath, 'src');
|
|
2221
|
+
const rendererWorkerTraceDirectory = join(cwd, 'renderer-worker-traces');
|
|
2222
|
+
if (traceRendererWorker) {
|
|
2223
|
+
await prepareDirectory(rendererWorkerTraceDirectory);
|
|
2224
|
+
}
|
|
2140
2225
|
const onResult = async result => {
|
|
2141
2226
|
await rpc.invoke(HandleResult, result);
|
|
2142
2227
|
};
|
|
@@ -2202,7 +2287,10 @@ const runAllTests = async (extensionPath, testPath, cwd, browser, headless, time
|
|
|
2202
2287
|
page,
|
|
2203
2288
|
port,
|
|
2204
2289
|
timeout,
|
|
2205
|
-
traceFocus
|
|
2290
|
+
traceFocus,
|
|
2291
|
+
...(traceRendererWorker && {
|
|
2292
|
+
rendererWorkerTraceDirectory
|
|
2293
|
+
})
|
|
2206
2294
|
});
|
|
2207
2295
|
}
|
|
2208
2296
|
});
|
|
@@ -2225,6 +2313,9 @@ const runAllTests = async (extensionPath, testPath, cwd, browser, headless, time
|
|
|
2225
2313
|
testSrc,
|
|
2226
2314
|
timeout,
|
|
2227
2315
|
traceFocus,
|
|
2316
|
+
...(traceRendererWorker && {
|
|
2317
|
+
rendererWorkerTraceDirectory
|
|
2318
|
+
}),
|
|
2228
2319
|
...(svgScreenshotOptions && {
|
|
2229
2320
|
svgScreenshotOptions
|
|
2230
2321
|
})
|