@stencil/core 2.14.2 → 2.15.2
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/bin/stencil +14 -15
- package/cli/index.cjs +153 -66
- package/cli/index.js +153 -66
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/stencil.js +417 -106
- package/compiler/stencil.min.js +2 -2
- package/dependencies.json +1 -1
- package/dev-server/client/index.js +3 -3
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +3 -3
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +2 -2
- package/internal/app-data/package.json +1 -1
- package/internal/client/css-shim.js +2 -2
- package/internal/client/dom.js +1 -1
- package/internal/client/index.js +1 -1
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +1 -1
- package/internal/client/patch-esm.js +1 -1
- package/internal/client/polyfills/css-shim.js +1 -1
- package/internal/client/shadow-css.js +1 -1
- package/internal/hydrate/package.json +1 -1
- package/internal/hydrate/runner.d.ts +1 -1
- package/internal/hydrate/runner.js +1 -1
- package/internal/package.json +1 -1
- package/internal/stencil-private.d.ts +39 -3
- package/internal/stencil-public-compiler.d.ts +21 -15
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +13 -3
- package/mock-doc/index.d.ts +4 -0
- package/mock-doc/index.js +13 -3
- package/mock-doc/package.json +1 -1
- package/package.json +5 -5
- package/screenshot/package.json +1 -1
- package/sys/node/autoprefixer.js +1 -1
- package/sys/node/index.js +2046 -1338
- package/sys/node/node-fetch.js +1 -1
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +8 -8
- package/testing/package.json +1 -1
package/bin/stencil
CHANGED
|
@@ -18,16 +18,14 @@ if (isNodeLT(minimumVersion)) {
|
|
|
18
18
|
currentVersion +
|
|
19
19
|
', however Stencil requires v' +
|
|
20
20
|
minimumVersion +
|
|
21
|
-
'.0 or greater. It is recommended to use an Active LTS version of Node (https://nodejs.org/en/about/releases/).\n'
|
|
21
|
+
'.0 or greater. It is recommended to use an Active LTS version of Node (https://nodejs.org/en/about/releases/).\n'
|
|
22
22
|
);
|
|
23
23
|
process.exit(1);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (isNodeLT(futureDeprecationMinVersion)) {
|
|
27
27
|
console.warn(
|
|
28
|
-
'\nIn an upcoming major release of Stencil, Node v' +
|
|
29
|
-
recommendedVersion +
|
|
30
|
-
'.0 or higher will be required.\n'
|
|
28
|
+
'\nIn an upcoming major release of Stencil, Node v' + recommendedVersion + '.0 or higher will be required.\n'
|
|
31
29
|
);
|
|
32
30
|
} else if (isNodeLT(recommendedVersion)) {
|
|
33
31
|
console.warn(
|
|
@@ -35,7 +33,7 @@ if (isNodeLT(futureDeprecationMinVersion)) {
|
|
|
35
33
|
currentVersion +
|
|
36
34
|
", however Stencil's recommendation is v" +
|
|
37
35
|
recommendedVersion +
|
|
38
|
-
'.0 or greater. Note that future versions of Stencil will eventually remove support for non-LTS Node versions and an Active LTS version is recommended (https://nodejs.org/en/about/releases/).\n'
|
|
36
|
+
'.0 or greater. Note that future versions of Stencil will eventually remove support for non-LTS Node versions and an Active LTS version is recommended (https://nodejs.org/en/about/releases/).\n'
|
|
39
37
|
);
|
|
40
38
|
}
|
|
41
39
|
|
|
@@ -46,13 +44,14 @@ var nodeSys = nodeApi.createNodeSys({ process: process, logger: nodeLogger });
|
|
|
46
44
|
|
|
47
45
|
nodeApi.setupNodeProcess({ process: process, logger: nodeLogger });
|
|
48
46
|
|
|
49
|
-
cli
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
cli
|
|
48
|
+
.run({
|
|
49
|
+
args: process.argv.slice(2),
|
|
50
|
+
logger: nodeLogger,
|
|
51
|
+
sys: nodeSys,
|
|
52
|
+
checkVersion: nodeApi.checkVersion,
|
|
53
|
+
})
|
|
54
|
+
.catch(function (err) {
|
|
55
|
+
console.error('uncaught error', err);
|
|
56
|
+
process.exit(1);
|
|
57
|
+
});
|
package/cli/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Stencil CLI (CommonJS) v2.
|
|
2
|
+
Stencil CLI (CommonJS) v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
4
|
'use strict';
|
|
5
5
|
|
|
@@ -259,15 +259,16 @@ const pathComponents = (path, rootLength) => {
|
|
|
259
259
|
* @returns an error message if the tag has an invalid name, undefined if the tag name passes all checks
|
|
260
260
|
*/
|
|
261
261
|
const validateComponentTag = (tag) => {
|
|
262
|
+
// we want to check this first since we call some String.prototype methods below
|
|
263
|
+
if (typeof tag !== 'string') {
|
|
264
|
+
return `Tag "${tag}" must be a string type`;
|
|
265
|
+
}
|
|
262
266
|
if (tag !== tag.trim()) {
|
|
263
267
|
return `Tag can not contain white spaces`;
|
|
264
268
|
}
|
|
265
269
|
if (tag !== tag.toLowerCase()) {
|
|
266
270
|
return `Tag can not contain upper case characters`;
|
|
267
271
|
}
|
|
268
|
-
if (typeof tag !== 'string') {
|
|
269
|
-
return `Tag "${tag}" must be a string type`;
|
|
270
|
-
}
|
|
271
272
|
if (tag.length === 0) {
|
|
272
273
|
return `Received empty tag value`;
|
|
273
274
|
}
|
|
@@ -329,9 +330,19 @@ const parseFlags = (args, sys) => {
|
|
|
329
330
|
});
|
|
330
331
|
return flags;
|
|
331
332
|
};
|
|
333
|
+
/**
|
|
334
|
+
* Parse command line arguments that are whitelisted via the BOOLEAN_ARG_OPTS,
|
|
335
|
+
* STRING_ARG_OPTS, and NUMBER_ARG_OPTS arrays in this file. Handles leading
|
|
336
|
+
* dashes on arguments, aliases that are defined for a small number of argument
|
|
337
|
+
* types, and parsing values for non-boolean arguments (e.g. port number).
|
|
338
|
+
*
|
|
339
|
+
* @param flags a ConfigFlags object
|
|
340
|
+
* @param args an array of command-line arguments to parse
|
|
341
|
+
* @param knownArgs an array to which all recognized, legal arguments are added
|
|
342
|
+
*/
|
|
332
343
|
const parseArgs = (flags, args, knownArgs) => {
|
|
333
|
-
|
|
334
|
-
const alias =
|
|
344
|
+
BOOLEAN_ARG_OPTS.forEach((booleanName) => {
|
|
345
|
+
const alias = ARG_OPTS_ALIASES[booleanName];
|
|
335
346
|
const flagKey = configCase(booleanName);
|
|
336
347
|
if (typeof flags[flagKey] !== 'boolean') {
|
|
337
348
|
flags[flagKey] = null;
|
|
@@ -359,8 +370,8 @@ const parseArgs = (flags, args, knownArgs) => {
|
|
|
359
370
|
}
|
|
360
371
|
});
|
|
361
372
|
});
|
|
362
|
-
|
|
363
|
-
const alias =
|
|
373
|
+
STRING_ARG_OPTS.forEach((stringName) => {
|
|
374
|
+
const alias = ARG_OPTS_ALIASES[stringName];
|
|
364
375
|
const flagKey = configCase(stringName);
|
|
365
376
|
if (typeof flags[flagKey] !== 'string') {
|
|
366
377
|
flags[flagKey] = null;
|
|
@@ -403,8 +414,8 @@ const parseArgs = (flags, args, knownArgs) => {
|
|
|
403
414
|
}
|
|
404
415
|
}
|
|
405
416
|
});
|
|
406
|
-
|
|
407
|
-
const alias =
|
|
417
|
+
NUMBER_ARG_OPTS.forEach((numberName) => {
|
|
418
|
+
const alias = ARG_OPTS_ALIASES[numberName];
|
|
408
419
|
const flagKey = configCase(numberName);
|
|
409
420
|
if (typeof flags[flagKey] !== 'number') {
|
|
410
421
|
flags[flagKey] = null;
|
|
@@ -448,50 +459,56 @@ const parseArgs = (flags, args, knownArgs) => {
|
|
|
448
459
|
};
|
|
449
460
|
const configCase = (prop) => {
|
|
450
461
|
prop = dashToPascalCase(prop);
|
|
451
|
-
return prop.charAt(0).toLowerCase() + prop.
|
|
462
|
+
return prop.charAt(0).toLowerCase() + prop.slice(1);
|
|
452
463
|
};
|
|
453
|
-
const
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
464
|
+
const BOOLEAN_ARG_OPTS = [
|
|
465
|
+
'build',
|
|
466
|
+
'cache',
|
|
467
|
+
'check-version',
|
|
468
|
+
'ci',
|
|
469
|
+
'compare',
|
|
470
|
+
'debug',
|
|
471
|
+
'dev',
|
|
472
|
+
'devtools',
|
|
473
|
+
'docs',
|
|
474
|
+
'e2e',
|
|
475
|
+
'es5',
|
|
476
|
+
'esm',
|
|
477
|
+
'headless',
|
|
478
|
+
'help',
|
|
479
|
+
'log',
|
|
480
|
+
'open',
|
|
481
|
+
'prerender',
|
|
482
|
+
'prerender-external',
|
|
483
|
+
'prod',
|
|
484
|
+
'profile',
|
|
485
|
+
'service-worker',
|
|
486
|
+
'screenshot',
|
|
487
|
+
'serve',
|
|
488
|
+
'skip-node-check',
|
|
489
|
+
'spec',
|
|
490
|
+
'ssr',
|
|
491
|
+
'stats',
|
|
492
|
+
'update-screenshot',
|
|
493
|
+
'verbose',
|
|
494
|
+
'version',
|
|
495
|
+
'watch',
|
|
496
|
+
];
|
|
497
|
+
const NUMBER_ARG_OPTS = ['max-workers', 'port'];
|
|
498
|
+
const STRING_ARG_OPTS = [
|
|
499
|
+
'address',
|
|
500
|
+
'config',
|
|
501
|
+
'docs-json',
|
|
502
|
+
'emulate',
|
|
503
|
+
'log-level',
|
|
504
|
+
'root',
|
|
505
|
+
'screenshot-connector',
|
|
506
|
+
];
|
|
507
|
+
const ARG_OPTS_ALIASES = {
|
|
508
|
+
config: 'c',
|
|
509
|
+
help: 'h',
|
|
510
|
+
port: 'p',
|
|
511
|
+
version: 'v',
|
|
495
512
|
};
|
|
496
513
|
const getNpmConfigEnvArgs = (sys) => {
|
|
497
514
|
// process.env.npm_config_argv
|
|
@@ -513,7 +530,7 @@ const getNpmConfigEnvArgs = (sys) => {
|
|
|
513
530
|
const dependencies = [
|
|
514
531
|
{
|
|
515
532
|
name: "@stencil/core",
|
|
516
|
-
version: "2.
|
|
533
|
+
version: "2.15.2",
|
|
517
534
|
main: "compiler/stencil.js",
|
|
518
535
|
resources: [
|
|
519
536
|
"package.json",
|
|
@@ -1290,7 +1307,14 @@ const IS_NODE_ENV = typeof global !== 'undefined' &&
|
|
|
1290
1307
|
(!global.origin || typeof global.origin !== 'string');
|
|
1291
1308
|
|
|
1292
1309
|
/**
|
|
1293
|
-
* Task to generate component boilerplate.
|
|
1310
|
+
* Task to generate component boilerplate and write it to disk. This task can
|
|
1311
|
+
* cause the program to exit with an error under various circumstances, such as
|
|
1312
|
+
* being called in an inappropriate place, being asked to overwrite files that
|
|
1313
|
+
* already exist, etc.
|
|
1314
|
+
*
|
|
1315
|
+
* @param coreCompiler the CoreCompiler we're using currently, here we're
|
|
1316
|
+
* mainly accessing the `path` module
|
|
1317
|
+
* @param config the user-supplied config, which we need here to access `.sys`.
|
|
1294
1318
|
*/
|
|
1295
1319
|
const taskGenerate = async (coreCompiler, config) => {
|
|
1296
1320
|
if (!IS_NODE_ENV) {
|
|
@@ -1320,10 +1344,16 @@ const taskGenerate = async (coreCompiler, config) => {
|
|
|
1320
1344
|
const testFolder = extensionsToGenerate.some(isTest) ? 'test' : '';
|
|
1321
1345
|
const outDir = path.join(absoluteSrcDir, 'components', dir, componentName);
|
|
1322
1346
|
await config.sys.createDir(path.join(outDir, testFolder), { recursive: true });
|
|
1323
|
-
const
|
|
1347
|
+
const filesToGenerate = extensionsToGenerate.map((extension) => ({
|
|
1348
|
+
extension,
|
|
1349
|
+
path: getFilepathForFile(coreCompiler, outDir, componentName, extension),
|
|
1350
|
+
}));
|
|
1351
|
+
await checkForOverwrite(filesToGenerate, config);
|
|
1352
|
+
const writtenFiles = await Promise.all(filesToGenerate.map((file) => getBoilerplateAndWriteFile(config, componentName, extensionsToGenerate.includes('css'), file))).catch((error) => config.logger.error(error));
|
|
1324
1353
|
if (!writtenFiles) {
|
|
1325
1354
|
return config.sys.exit(1);
|
|
1326
1355
|
}
|
|
1356
|
+
// TODO(STENCIL-424): Investigate moving these console.log calls to config.logger.info
|
|
1327
1357
|
console.log();
|
|
1328
1358
|
console.log(`${config.logger.gray('$')} stencil generate ${input}`);
|
|
1329
1359
|
console.log();
|
|
@@ -1333,6 +1363,9 @@ const taskGenerate = async (coreCompiler, config) => {
|
|
|
1333
1363
|
};
|
|
1334
1364
|
/**
|
|
1335
1365
|
* Show a checkbox prompt to select the files to be generated.
|
|
1366
|
+
*
|
|
1367
|
+
* @returns a read-only array of `GenerableExtension`, the extensions that the user has decided
|
|
1368
|
+
* to generate
|
|
1336
1369
|
*/
|
|
1337
1370
|
const chooseFilesToGenerate = async () => {
|
|
1338
1371
|
const { prompt } = await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('../sys/node/prompts.js')); });
|
|
@@ -1348,22 +1381,76 @@ const chooseFilesToGenerate = async () => {
|
|
|
1348
1381
|
})).filesToGenerate;
|
|
1349
1382
|
};
|
|
1350
1383
|
/**
|
|
1351
|
-
* Get a
|
|
1384
|
+
* Get a filepath for a file we want to generate!
|
|
1385
|
+
*
|
|
1386
|
+
* The filepath for a given file depends on the path, the user-supplied
|
|
1387
|
+
* component name, the extension, and whether we're inside of a test directory.
|
|
1388
|
+
*
|
|
1389
|
+
* @param coreCompiler the compiler we're using, here to acces the `.path` module
|
|
1390
|
+
* @param path path to where we're going to generate the component
|
|
1391
|
+
* @param componentName the user-supplied name for the generated component
|
|
1392
|
+
* @param extension the file extension
|
|
1393
|
+
* @returns the full filepath to the component (with a possible `test` directory
|
|
1394
|
+
* added)
|
|
1352
1395
|
*/
|
|
1353
|
-
const
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1396
|
+
const getFilepathForFile = (coreCompiler, path, componentName, extension) => isTest(extension)
|
|
1397
|
+
? coreCompiler.path.join(path, 'test', `${componentName}.${extension}`)
|
|
1398
|
+
: coreCompiler.path.join(path, `${componentName}.${extension}`);
|
|
1399
|
+
/**
|
|
1400
|
+
* Get the boilerplate for a file and write it to disk
|
|
1401
|
+
*
|
|
1402
|
+
* @param config the current config, needed for file operations
|
|
1403
|
+
* @param componentName the component name (user-supplied)
|
|
1404
|
+
* @param withCss are we generating CSS?
|
|
1405
|
+
* @param file the file we want to write
|
|
1406
|
+
* @returns a `Promise<string>` which holds the full filepath we've written to,
|
|
1407
|
+
* used to print out a little summary of our activity to the user.
|
|
1408
|
+
*/
|
|
1409
|
+
const getBoilerplateAndWriteFile = async (config, componentName, withCss, file) => {
|
|
1410
|
+
const boilerplate = getBoilerplateByExtension(componentName, file.extension, withCss);
|
|
1411
|
+
await config.sys.writeFile(file.path, boilerplate);
|
|
1412
|
+
return file.path;
|
|
1413
|
+
};
|
|
1414
|
+
/**
|
|
1415
|
+
* Check to see if any of the files we plan to write already exist and would
|
|
1416
|
+
* therefore be overwritten if we proceed, because we'd like to not overwrite
|
|
1417
|
+
* people's code!
|
|
1418
|
+
*
|
|
1419
|
+
* This function will check all the filepaths and if it finds any files log an
|
|
1420
|
+
* error and exit with an error code. If it doesn't find anything it will just
|
|
1421
|
+
* peacefully return `Promise<void>`.
|
|
1422
|
+
*
|
|
1423
|
+
* @param files the files we want to check
|
|
1424
|
+
* @param config the Config object, used here to get access to `sys.readFile`
|
|
1425
|
+
*/
|
|
1426
|
+
const checkForOverwrite = async (files, config) => {
|
|
1427
|
+
const alreadyPresent = [];
|
|
1428
|
+
await Promise.all(files.map(async ({ path }) => {
|
|
1429
|
+
if ((await config.sys.readFile(path)) !== undefined) {
|
|
1430
|
+
alreadyPresent.push(path);
|
|
1431
|
+
}
|
|
1432
|
+
}));
|
|
1433
|
+
if (alreadyPresent.length > 0) {
|
|
1434
|
+
config.logger.error('Generating code would overwrite the following files:', ...alreadyPresent.map((path) => '\t' + path));
|
|
1435
|
+
await config.sys.exit(1);
|
|
1436
|
+
}
|
|
1361
1437
|
};
|
|
1438
|
+
/**
|
|
1439
|
+
* Check if an extension is for a test
|
|
1440
|
+
*
|
|
1441
|
+
* @param extension the extension we want to check
|
|
1442
|
+
* @returns a boolean indicating whether or not its a test
|
|
1443
|
+
*/
|
|
1362
1444
|
const isTest = (extension) => {
|
|
1363
1445
|
return extension === 'e2e.ts' || extension === 'spec.tsx';
|
|
1364
1446
|
};
|
|
1365
1447
|
/**
|
|
1366
1448
|
* Get the boilerplate for a file by its extension.
|
|
1449
|
+
*
|
|
1450
|
+
* @param tagName the name of the component we're generating
|
|
1451
|
+
* @param extension the file extension we want boilerplate for (.css, tsx, etc)
|
|
1452
|
+
* @param withCss a boolean indicating whether we're generating a CSS file
|
|
1453
|
+
* @returns a string container the file boilerplate for the supplied extension
|
|
1367
1454
|
*/
|
|
1368
1455
|
const getBoilerplateByExtension = (tagName, extension, withCss) => {
|
|
1369
1456
|
switch (extension) {
|
|
@@ -1453,7 +1540,7 @@ describe('${name}', () => {
|
|
|
1453
1540
|
/**
|
|
1454
1541
|
* Convert a dash case string to pascal case.
|
|
1455
1542
|
*/
|
|
1456
|
-
const toPascalCase = (str) => str.split('-').reduce((res, part) => res + part[0].toUpperCase() + part.
|
|
1543
|
+
const toPascalCase = (str) => str.split('-').reduce((res, part) => res + part[0].toUpperCase() + part.slice(1), '');
|
|
1457
1544
|
|
|
1458
1545
|
const taskTelemetry = async (config, sys, logger) => {
|
|
1459
1546
|
const prompt = logger.dim(sys.details.platform === 'windows' ? '>' : '$');
|