@stencil/core 2.19.1-0 → 2.19.2-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.
- package/cli/index.cjs +2 -2
- package/cli/index.js +2 -2
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/stencil.js +455 -418
- package/compiler/stencil.min.js +2 -2
- package/dependencies.json +1 -1
- package/dev-server/client/index.js +1 -1
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +2 -2
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +5 -2
- package/internal/app-data/package.json +1 -1
- package/internal/client/css-shim.js +1 -1
- 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/shadow-css.js +1 -1
- package/internal/hydrate/package.json +1 -1
- package/internal/package.json +1 -1
- package/internal/stencil-private.d.ts +1 -4
- package/internal/stencil-public-compiler.d.ts +1 -0
- package/internal/stencil-public-docs.d.ts +1 -1
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +1 -1
- package/mock-doc/index.js +1 -1
- package/mock-doc/package.json +1 -1
- package/package.json +1 -1
- package/screenshot/package.json +1 -1
- package/sys/node/index.js +1 -1
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +2 -2
- package/testing/jest/jest-serializer.d.ts +1 -2
- package/testing/package.json +1 -1
package/compiler/stencil.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
Stencil Compiler v2.19.
|
|
2
|
+
Stencil Compiler v2.19.2-0 | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
4
|
(function(exports) {
|
|
5
5
|
'use strict';
|
|
@@ -2039,7 +2039,7 @@ const process$3 = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), p
|
|
|
2039
2039
|
'default': process_1
|
|
2040
2040
|
});
|
|
2041
2041
|
|
|
2042
|
-
const buildId = '
|
|
2042
|
+
const buildId = '20221027170342';
|
|
2043
2043
|
const minfyJsId = 'terser5.6.1_7';
|
|
2044
2044
|
const optimizeCssId = 'autoprefixer10.4.12_postcss8.4.18_7';
|
|
2045
2045
|
const parse5Version = '7.1.1';
|
|
@@ -2047,8 +2047,8 @@ const rollupVersion = '2.42.3';
|
|
|
2047
2047
|
const sizzleVersion = '2.42.3';
|
|
2048
2048
|
const terserVersion = '5.6.1';
|
|
2049
2049
|
const typescriptVersion = '4.7.4';
|
|
2050
|
-
const vermoji = '
|
|
2051
|
-
const version$3 = '2.19.
|
|
2050
|
+
const vermoji = '🌵';
|
|
2051
|
+
const version$3 = '2.19.2-0';
|
|
2052
2052
|
const versions = {
|
|
2053
2053
|
stencil: version$3,
|
|
2054
2054
|
parse5: parse5Version,
|
|
@@ -9449,6 +9449,9 @@ const nodeRequire = (id) => {
|
|
|
9449
9449
|
sourceText = sourceText.replace(/export\s+\w+\s+(\w+)/gm, 'exports.$1');
|
|
9450
9450
|
}
|
|
9451
9451
|
try {
|
|
9452
|
+
// we need to coerce because of the requirements for the arguments to
|
|
9453
|
+
// this function. It's safe enough since it's already wrapped in a
|
|
9454
|
+
// `try { } catch`.
|
|
9452
9455
|
module._compile(sourceText, fileName);
|
|
9453
9456
|
}
|
|
9454
9457
|
catch (e) {
|
|
@@ -52212,7 +52215,7 @@ const removeCollectionImports = (compilerCtx) => {
|
|
|
52212
52215
|
}
|
|
52213
52216
|
}
|
|
52214
52217
|
if (madeUpdates) {
|
|
52215
|
-
return t.
|
|
52218
|
+
return t.factory.updateSourceFile(tsSourceFile, statements);
|
|
52216
52219
|
}
|
|
52217
52220
|
return tsSourceFile;
|
|
52218
52221
|
};
|
|
@@ -52535,201 +52538,8 @@ const getHydratedFlagHead = (h) => {
|
|
|
52535
52538
|
return initial + hydrated;
|
|
52536
52539
|
};
|
|
52537
52540
|
|
|
52538
|
-
|
|
52539
|
-
|
|
52540
|
-
* and rebuild.
|
|
52541
|
-
*/
|
|
52542
|
-
class BuildContext {
|
|
52543
|
-
constructor(config, compilerCtx) {
|
|
52544
|
-
this.buildId = -1;
|
|
52545
|
-
this.buildMessages = [];
|
|
52546
|
-
this.buildResults = null;
|
|
52547
|
-
this.bundleBuildCount = 0;
|
|
52548
|
-
this.collections = [];
|
|
52549
|
-
this.completedTasks = [];
|
|
52550
|
-
this.components = [];
|
|
52551
|
-
this.componentGraph = new Map();
|
|
52552
|
-
this.data = {};
|
|
52553
|
-
this.buildStats = undefined;
|
|
52554
|
-
this.diagnostics = [];
|
|
52555
|
-
this.dirsAdded = [];
|
|
52556
|
-
this.dirsDeleted = [];
|
|
52557
|
-
this.entryModules = [];
|
|
52558
|
-
this.filesAdded = [];
|
|
52559
|
-
this.filesChanged = [];
|
|
52560
|
-
this.filesDeleted = [];
|
|
52561
|
-
this.filesUpdated = [];
|
|
52562
|
-
this.filesWritten = [];
|
|
52563
|
-
this.globalStyle = undefined;
|
|
52564
|
-
this.hasConfigChanges = false;
|
|
52565
|
-
this.hasFinished = false;
|
|
52566
|
-
this.hasHtmlChanges = false;
|
|
52567
|
-
this.hasPrintedResults = false;
|
|
52568
|
-
this.hasServiceWorkerChanges = false;
|
|
52569
|
-
this.hasScriptChanges = true;
|
|
52570
|
-
this.hasStyleChanges = true;
|
|
52571
|
-
this.hydrateAppFilePath = null;
|
|
52572
|
-
this.indexBuildCount = 0;
|
|
52573
|
-
this.indexDoc = undefined;
|
|
52574
|
-
this.isRebuild = false;
|
|
52575
|
-
this.moduleFiles = [];
|
|
52576
|
-
this.outputs = [];
|
|
52577
|
-
this.packageJson = {};
|
|
52578
|
-
this.packageJsonFilePath = null;
|
|
52579
|
-
this.pendingCopyTasks = [];
|
|
52580
|
-
this.requiresFullBuild = true;
|
|
52581
|
-
this.scriptsAdded = [];
|
|
52582
|
-
this.scriptsDeleted = [];
|
|
52583
|
-
this.startTime = Date.now();
|
|
52584
|
-
this.styleBuildCount = 0;
|
|
52585
|
-
this.stylesPromise = null;
|
|
52586
|
-
this.stylesUpdated = [];
|
|
52587
|
-
this.timeSpan = null;
|
|
52588
|
-
this.transpileBuildCount = 0;
|
|
52589
|
-
this.config = config;
|
|
52590
|
-
this.compilerCtx = compilerCtx;
|
|
52591
|
-
this.buildId = ++this.compilerCtx.activeBuildId;
|
|
52592
|
-
this.debug = config.logger.debug.bind(config.logger);
|
|
52593
|
-
}
|
|
52594
|
-
start() {
|
|
52595
|
-
// get the build id from the incremented activeBuildId
|
|
52596
|
-
// print out a good message
|
|
52597
|
-
const msg = `${this.isRebuild ? 'rebuild' : 'build'}, ${this.config.fsNamespace}, ${this.config.devMode ? 'dev' : 'prod'} mode, started`;
|
|
52598
|
-
const buildLog = {
|
|
52599
|
-
buildId: this.buildId,
|
|
52600
|
-
messages: [],
|
|
52601
|
-
progress: 0,
|
|
52602
|
-
};
|
|
52603
|
-
this.compilerCtx.events.emit('buildLog', buildLog);
|
|
52604
|
-
// create a timespan for this build
|
|
52605
|
-
this.timeSpan = this.createTimeSpan(msg);
|
|
52606
|
-
// create a build timestamp for this build
|
|
52607
|
-
this.timestamp = getBuildTimestamp();
|
|
52608
|
-
// debug log our new build
|
|
52609
|
-
this.debug(`start build, ${this.timestamp}`);
|
|
52610
|
-
const buildStart = {
|
|
52611
|
-
buildId: this.buildId,
|
|
52612
|
-
timestamp: this.timestamp,
|
|
52613
|
-
};
|
|
52614
|
-
this.compilerCtx.events.emit('buildStart', buildStart);
|
|
52615
|
-
}
|
|
52616
|
-
createTimeSpan(msg, debug) {
|
|
52617
|
-
if (!this.hasFinished || debug) {
|
|
52618
|
-
if (debug) {
|
|
52619
|
-
if (this.config.watch) {
|
|
52620
|
-
msg = `${this.config.logger.cyan('[' + this.buildId + ']')} ${msg}`;
|
|
52621
|
-
}
|
|
52622
|
-
}
|
|
52623
|
-
const timeSpan = this.config.logger.createTimeSpan(msg, debug, this.buildMessages);
|
|
52624
|
-
if (!debug && this.compilerCtx.events) {
|
|
52625
|
-
const buildLog = {
|
|
52626
|
-
buildId: this.buildId,
|
|
52627
|
-
messages: this.buildMessages,
|
|
52628
|
-
progress: getProgress(this.completedTasks),
|
|
52629
|
-
};
|
|
52630
|
-
this.compilerCtx.events.emit('buildLog', buildLog);
|
|
52631
|
-
}
|
|
52632
|
-
return {
|
|
52633
|
-
duration: () => {
|
|
52634
|
-
return timeSpan.duration();
|
|
52635
|
-
},
|
|
52636
|
-
finish: (finishedMsg, color, bold, newLineSuffix) => {
|
|
52637
|
-
if (!this.hasFinished || debug) {
|
|
52638
|
-
if (debug) {
|
|
52639
|
-
if (this.config.watch) {
|
|
52640
|
-
finishedMsg = `${this.config.logger.cyan('[' + this.buildId + ']')} ${finishedMsg}`;
|
|
52641
|
-
}
|
|
52642
|
-
}
|
|
52643
|
-
timeSpan.finish(finishedMsg, color, bold, newLineSuffix);
|
|
52644
|
-
if (!debug) {
|
|
52645
|
-
const buildLog = {
|
|
52646
|
-
buildId: this.buildId,
|
|
52647
|
-
messages: this.buildMessages.slice(),
|
|
52648
|
-
progress: getProgress(this.completedTasks),
|
|
52649
|
-
};
|
|
52650
|
-
this.compilerCtx.events.emit('buildLog', buildLog);
|
|
52651
|
-
}
|
|
52652
|
-
}
|
|
52653
|
-
return timeSpan.duration();
|
|
52654
|
-
},
|
|
52655
|
-
};
|
|
52656
|
-
}
|
|
52657
|
-
return {
|
|
52658
|
-
duration() {
|
|
52659
|
-
return 0;
|
|
52660
|
-
},
|
|
52661
|
-
finish() {
|
|
52662
|
-
return 0;
|
|
52663
|
-
},
|
|
52664
|
-
};
|
|
52665
|
-
}
|
|
52666
|
-
debug(msg) {
|
|
52667
|
-
this.config.logger.debug(msg);
|
|
52668
|
-
}
|
|
52669
|
-
get hasError() {
|
|
52670
|
-
return hasError(this.diagnostics);
|
|
52671
|
-
}
|
|
52672
|
-
get hasWarning() {
|
|
52673
|
-
return hasWarning(this.diagnostics);
|
|
52674
|
-
}
|
|
52675
|
-
progress(t) {
|
|
52676
|
-
this.completedTasks.push(t);
|
|
52677
|
-
}
|
|
52678
|
-
async validateTypesBuild() {
|
|
52679
|
-
if (this.hasError) {
|
|
52680
|
-
// no need to wait on this one since
|
|
52681
|
-
// we already aborted this build
|
|
52682
|
-
return;
|
|
52683
|
-
}
|
|
52684
|
-
if (!this.validateTypesPromise) {
|
|
52685
|
-
// there is no pending validate types promise
|
|
52686
|
-
// so it probably already finished
|
|
52687
|
-
// so no need to wait on anything
|
|
52688
|
-
return;
|
|
52689
|
-
}
|
|
52690
|
-
if (!this.config.watch) {
|
|
52691
|
-
// this is not a watch build, so we need to make
|
|
52692
|
-
// sure that the type validation has finished
|
|
52693
|
-
this.debug(`build, non-watch, waiting on validateTypes`);
|
|
52694
|
-
await this.validateTypesPromise;
|
|
52695
|
-
this.debug(`build, non-watch, finished waiting on validateTypes`);
|
|
52696
|
-
}
|
|
52697
|
-
}
|
|
52698
|
-
}
|
|
52699
|
-
/**
|
|
52700
|
-
* Generate a timestamp of the format `YYYY-MM-DDThh:mm:ss`, using the number of seconds that have elapsed since
|
|
52701
|
-
* January 01, 1970, and the time this function was called
|
|
52702
|
-
* @returns the generated timestamp
|
|
52703
|
-
*/
|
|
52704
|
-
const getBuildTimestamp = () => {
|
|
52705
|
-
const d = new Date();
|
|
52706
|
-
// YYYY-MM-DDThh:mm:ss
|
|
52707
|
-
let timestamp = d.getUTCFullYear() + '-';
|
|
52708
|
-
timestamp += ('0' + (d.getUTCMonth() + 1)).slice(-2) + '-';
|
|
52709
|
-
timestamp += ('0' + d.getUTCDate()).slice(-2) + 'T';
|
|
52710
|
-
timestamp += ('0' + d.getUTCHours()).slice(-2) + ':';
|
|
52711
|
-
timestamp += ('0' + d.getUTCMinutes()).slice(-2) + ':';
|
|
52712
|
-
timestamp += ('0' + d.getUTCSeconds()).slice(-2);
|
|
52713
|
-
return timestamp;
|
|
52714
|
-
};
|
|
52715
|
-
const getProgress = (completedTasks) => {
|
|
52716
|
-
let progressIndex = 0;
|
|
52717
|
-
const taskKeys = Object.keys(ProgressTask);
|
|
52718
|
-
taskKeys.forEach((taskKey, index) => {
|
|
52719
|
-
if (completedTasks.includes(ProgressTask[taskKey])) {
|
|
52720
|
-
progressIndex = index;
|
|
52721
|
-
}
|
|
52722
|
-
});
|
|
52723
|
-
return (progressIndex + 1) / taskKeys.length;
|
|
52724
|
-
};
|
|
52725
|
-
const ProgressTask = {
|
|
52726
|
-
emptyOutputTargets: {},
|
|
52727
|
-
transpileApp: {},
|
|
52728
|
-
generateStyles: {},
|
|
52729
|
-
generateOutputTargets: {},
|
|
52730
|
-
validateTypesBuild: {},
|
|
52731
|
-
writeBuildFiles: {},
|
|
52732
|
-
};
|
|
52541
|
+
const DEV_MODULE_CACHE_BUSTER = 0;
|
|
52542
|
+
const DEV_MODULE_DIR = `~dev-module`;
|
|
52733
52543
|
|
|
52734
52544
|
const devNodeModuleResolveId = async (config, inMemoryFs, resolvedId, importee) => {
|
|
52735
52545
|
if (!shouldCheckDevModule(resolvedId, importee)) {
|
|
@@ -52756,6 +52566,14 @@ const devNodeModuleResolveId = async (config, inMemoryFs, resolvedId, importee)
|
|
|
52756
52566
|
resolvedId.external = true;
|
|
52757
52567
|
return resolvedId;
|
|
52758
52568
|
};
|
|
52569
|
+
const shouldCheckDevModule = (resolvedId, importee) => resolvedId &&
|
|
52570
|
+
importee &&
|
|
52571
|
+
resolvedId.id &&
|
|
52572
|
+
resolvedId.id.includes('node_modules') &&
|
|
52573
|
+
(resolvedId.id.endsWith('.js') || resolvedId.id.endsWith('.mjs')) &&
|
|
52574
|
+
!resolvedId.external &&
|
|
52575
|
+
!importee.startsWith('.') &&
|
|
52576
|
+
!importee.startsWith('/');
|
|
52759
52577
|
const getPackageJsonPath = (resolvedPath, importee) => {
|
|
52760
52578
|
let currentPath = resolvedPath;
|
|
52761
52579
|
for (let i = 0; i < 10; i++) {
|
|
@@ -52769,130 +52587,6 @@ const getPackageJsonPath = (resolvedPath, importee) => {
|
|
|
52769
52587
|
}
|
|
52770
52588
|
return null;
|
|
52771
52589
|
};
|
|
52772
|
-
const compilerRequest = async (config, compilerCtx, data) => {
|
|
52773
|
-
const results = {
|
|
52774
|
-
path: data.path,
|
|
52775
|
-
nodeModuleId: null,
|
|
52776
|
-
nodeModuleVersion: null,
|
|
52777
|
-
nodeResolvedPath: null,
|
|
52778
|
-
cachePath: null,
|
|
52779
|
-
cacheHit: false,
|
|
52780
|
-
content: '',
|
|
52781
|
-
status: 404,
|
|
52782
|
-
};
|
|
52783
|
-
try {
|
|
52784
|
-
const parsedUrl = parseDevModuleUrl(config, data.path);
|
|
52785
|
-
Object.assign(results, parsedUrl);
|
|
52786
|
-
if (parsedUrl.nodeModuleId) {
|
|
52787
|
-
if (!parsedUrl.nodeModuleVersion) {
|
|
52788
|
-
results.content = `/* invalid module version */`;
|
|
52789
|
-
results.status = 400;
|
|
52790
|
-
return results;
|
|
52791
|
-
}
|
|
52792
|
-
if (!parsedUrl.nodeResolvedPath) {
|
|
52793
|
-
results.content = `/* invalid resolved path */`;
|
|
52794
|
-
results.status = 400;
|
|
52795
|
-
return results;
|
|
52796
|
-
}
|
|
52797
|
-
const useCache = await useDevModuleCache(config, parsedUrl.nodeResolvedPath);
|
|
52798
|
-
let cachePath = null;
|
|
52799
|
-
if (useCache) {
|
|
52800
|
-
cachePath = getDevModuleCachePath(config, parsedUrl);
|
|
52801
|
-
const cachedContent = await config.sys.readFile(cachePath);
|
|
52802
|
-
if (typeof cachedContent === 'string') {
|
|
52803
|
-
results.content = cachedContent;
|
|
52804
|
-
results.cachePath = cachePath;
|
|
52805
|
-
results.cacheHit = true;
|
|
52806
|
-
results.status = 200;
|
|
52807
|
-
return results;
|
|
52808
|
-
}
|
|
52809
|
-
}
|
|
52810
|
-
await bundleDevModule(config, compilerCtx, parsedUrl, results);
|
|
52811
|
-
if (results.status === 200 && useCache) {
|
|
52812
|
-
results.cachePath = cachePath;
|
|
52813
|
-
writeCachedFile(config, results);
|
|
52814
|
-
}
|
|
52815
|
-
}
|
|
52816
|
-
else {
|
|
52817
|
-
results.content = `/* invalid dev module */`;
|
|
52818
|
-
results.status = 400;
|
|
52819
|
-
return results;
|
|
52820
|
-
}
|
|
52821
|
-
}
|
|
52822
|
-
catch (e) {
|
|
52823
|
-
if (e) {
|
|
52824
|
-
if (e instanceof Error && e.stack) {
|
|
52825
|
-
results.content = `/*\n${e.stack}\n*/`;
|
|
52826
|
-
}
|
|
52827
|
-
else {
|
|
52828
|
-
results.content = `/*\n${e}\n*/`;
|
|
52829
|
-
}
|
|
52830
|
-
}
|
|
52831
|
-
results.status = 500;
|
|
52832
|
-
}
|
|
52833
|
-
return results;
|
|
52834
|
-
};
|
|
52835
|
-
const bundleDevModule = async (config, compilerCtx, parsedUrl, results) => {
|
|
52836
|
-
const buildCtx = new BuildContext(config, compilerCtx);
|
|
52837
|
-
try {
|
|
52838
|
-
const inputOpts = getRollupOptions(config, compilerCtx, buildCtx, {
|
|
52839
|
-
id: parsedUrl.nodeModuleId,
|
|
52840
|
-
platform: 'client',
|
|
52841
|
-
inputs: {
|
|
52842
|
-
index: parsedUrl.nodeResolvedPath,
|
|
52843
|
-
},
|
|
52844
|
-
});
|
|
52845
|
-
const rollupBuild = await rollup(inputOpts);
|
|
52846
|
-
const outputOpts = {
|
|
52847
|
-
banner: generatePreamble(config),
|
|
52848
|
-
format: 'es',
|
|
52849
|
-
};
|
|
52850
|
-
if (parsedUrl.nodeModuleId) {
|
|
52851
|
-
const commentPath = relative$1(config.rootDir, parsedUrl.nodeResolvedPath);
|
|
52852
|
-
outputOpts.intro = `/**\n * Dev Node Module: ${parsedUrl.nodeModuleId}, v${parsedUrl.nodeModuleVersion}\n * Entry: ${commentPath}\n * DEVELOPMENT PURPOSES ONLY!!\n */`;
|
|
52853
|
-
inputOpts.input = parsedUrl.nodeResolvedPath;
|
|
52854
|
-
}
|
|
52855
|
-
const r = await rollupBuild.generate(outputOpts);
|
|
52856
|
-
if (buildCtx.hasError) {
|
|
52857
|
-
results.status = 500;
|
|
52858
|
-
results.content = `console.error(${JSON.stringify(buildCtx.diagnostics)})`;
|
|
52859
|
-
}
|
|
52860
|
-
else if (r && r.output && r.output.length > 0) {
|
|
52861
|
-
results.content = r.output[0].code;
|
|
52862
|
-
results.status = 200;
|
|
52863
|
-
}
|
|
52864
|
-
}
|
|
52865
|
-
catch (e) {
|
|
52866
|
-
results.status = 500;
|
|
52867
|
-
const errorMsg = e instanceof Error ? e.stack : e + '';
|
|
52868
|
-
results.content = `console.error(${JSON.stringify(errorMsg)})`;
|
|
52869
|
-
}
|
|
52870
|
-
};
|
|
52871
|
-
const useDevModuleCache = async (config, p) => {
|
|
52872
|
-
if (config.enableCache) {
|
|
52873
|
-
for (let i = 0; i < 10; i++) {
|
|
52874
|
-
const n = basename(p);
|
|
52875
|
-
if (n === 'node_modules') {
|
|
52876
|
-
return true;
|
|
52877
|
-
}
|
|
52878
|
-
const isSymbolicLink = await config.sys.isSymbolicLink(p);
|
|
52879
|
-
if (isSymbolicLink) {
|
|
52880
|
-
return false;
|
|
52881
|
-
}
|
|
52882
|
-
p = dirname(p);
|
|
52883
|
-
}
|
|
52884
|
-
}
|
|
52885
|
-
return false;
|
|
52886
|
-
};
|
|
52887
|
-
const writeCachedFile = async (config, results) => {
|
|
52888
|
-
try {
|
|
52889
|
-
await config.sys.createDir(config.cacheDir);
|
|
52890
|
-
config.sys.writeFile(results.cachePath, results.content);
|
|
52891
|
-
}
|
|
52892
|
-
catch (e) {
|
|
52893
|
-
console.error(e);
|
|
52894
|
-
}
|
|
52895
|
-
};
|
|
52896
52590
|
const serializeDevNodeModuleUrl = (config, moduleId, moduleVersion, resolvedPath) => {
|
|
52897
52591
|
resolvedPath = relative$1(config.rootDir, resolvedPath);
|
|
52898
52592
|
let id = `/${DEV_MODULE_DIR}/`;
|
|
@@ -52901,42 +52595,6 @@ const serializeDevNodeModuleUrl = (config, moduleId, moduleVersion, resolvedPath
|
|
|
52901
52595
|
id += '?p=' + encodeURIComponent(resolvedPath);
|
|
52902
52596
|
return id;
|
|
52903
52597
|
};
|
|
52904
|
-
const parseDevModuleUrl = (config, u) => {
|
|
52905
|
-
const parsedUrl = {
|
|
52906
|
-
nodeModuleId: null,
|
|
52907
|
-
nodeModuleVersion: null,
|
|
52908
|
-
nodeResolvedPath: null,
|
|
52909
|
-
};
|
|
52910
|
-
if (u && u.includes(DEV_MODULE_DIR) && u.endsWith('.js')) {
|
|
52911
|
-
const url = new URL(u, 'https://stenciljs.com');
|
|
52912
|
-
let reqPath = basename(url.pathname);
|
|
52913
|
-
reqPath = reqPath.substring(0, reqPath.length - 3);
|
|
52914
|
-
const splt = reqPath.split('@');
|
|
52915
|
-
if (splt.length === 2) {
|
|
52916
|
-
parsedUrl.nodeModuleId = decodeURIComponent(splt[0]);
|
|
52917
|
-
parsedUrl.nodeModuleVersion = decodeURIComponent(splt[1]);
|
|
52918
|
-
parsedUrl.nodeResolvedPath = url.searchParams.get('p');
|
|
52919
|
-
if (parsedUrl.nodeResolvedPath) {
|
|
52920
|
-
parsedUrl.nodeResolvedPath = decodeURIComponent(parsedUrl.nodeResolvedPath);
|
|
52921
|
-
parsedUrl.nodeResolvedPath = join(config.rootDir, parsedUrl.nodeResolvedPath);
|
|
52922
|
-
}
|
|
52923
|
-
}
|
|
52924
|
-
}
|
|
52925
|
-
return parsedUrl;
|
|
52926
|
-
};
|
|
52927
|
-
const getDevModuleCachePath = (config, parsedUrl) => {
|
|
52928
|
-
return join(config.cacheDir, `dev_module_${parsedUrl.nodeModuleId}_${parsedUrl.nodeModuleVersion}_${DEV_MODULE_CACHE_BUSTER}.log`);
|
|
52929
|
-
};
|
|
52930
|
-
const DEV_MODULE_CACHE_BUSTER = 0;
|
|
52931
|
-
const DEV_MODULE_DIR = `~dev-module`;
|
|
52932
|
-
const shouldCheckDevModule = (resolvedId, importee) => resolvedId &&
|
|
52933
|
-
importee &&
|
|
52934
|
-
resolvedId.id &&
|
|
52935
|
-
resolvedId.id.includes('node_modules') &&
|
|
52936
|
-
(resolvedId.id.endsWith('.js') || resolvedId.id.endsWith('.mjs')) &&
|
|
52937
|
-
!resolvedId.external &&
|
|
52938
|
-
!importee.startsWith('.') &&
|
|
52939
|
-
!importee.startsWith('/');
|
|
52940
52598
|
|
|
52941
52599
|
const extFormatPlugin = (config) => {
|
|
52942
52600
|
return {
|
|
@@ -54950,7 +54608,21 @@ const convertValueToLiteral = (val, refs = null) => {
|
|
|
54950
54608
|
}
|
|
54951
54609
|
return objectToObjectLiteral(val, refs);
|
|
54952
54610
|
}
|
|
54953
|
-
|
|
54611
|
+
// the remainder of the implementation of this function was derived from the deprecated `createLiteral` function
|
|
54612
|
+
// found in typescript@4.8.4
|
|
54613
|
+
if (typeof val === 'number') {
|
|
54614
|
+
return t.factory.createNumericLiteral(val);
|
|
54615
|
+
}
|
|
54616
|
+
if (typeof val === 'object' && 'base10Value' in val) {
|
|
54617
|
+
return t.factory.createBigIntLiteral(val);
|
|
54618
|
+
}
|
|
54619
|
+
if (typeof val === 'boolean') {
|
|
54620
|
+
return val ? t.factory.createTrue() : t.factory.createFalse();
|
|
54621
|
+
}
|
|
54622
|
+
if (typeof val === 'string') {
|
|
54623
|
+
return t.factory.createStringLiteral(val, undefined);
|
|
54624
|
+
}
|
|
54625
|
+
return t.factory.createStringLiteralFromNode(val);
|
|
54954
54626
|
};
|
|
54955
54627
|
/**
|
|
54956
54628
|
* Convert a JavaScript Array instance to TypeScript's Intermediate
|
|
@@ -54968,7 +54640,7 @@ const arrayToArrayLiteral = (list, refs) => {
|
|
|
54968
54640
|
const newList = list.map((l) => {
|
|
54969
54641
|
return convertValueToLiteral(l, refs);
|
|
54970
54642
|
});
|
|
54971
|
-
return t.
|
|
54643
|
+
return t.factory.createArrayLiteralExpression(newList);
|
|
54972
54644
|
};
|
|
54973
54645
|
/**
|
|
54974
54646
|
* Convert a JavaScript object (i.e. an object existing at runtime) to the
|
|
@@ -54991,7 +54663,7 @@ const objectToObjectLiteral = (obj, refs) => {
|
|
|
54991
54663
|
}
|
|
54992
54664
|
refs.add(obj);
|
|
54993
54665
|
const newProperties = Object.keys(obj).map((key) => {
|
|
54994
|
-
const prop = t.factory.createPropertyAssignment(t.
|
|
54666
|
+
const prop = t.factory.createPropertyAssignment(t.factory.createStringLiteral(key), convertValueToLiteral(obj[key], refs));
|
|
54995
54667
|
return prop;
|
|
54996
54668
|
});
|
|
54997
54669
|
return t.factory.createObjectLiteralExpression(newProperties, true);
|
|
@@ -55433,12 +55105,12 @@ const createImportStatement = (importFnNames, importPath) => {
|
|
|
55433
55105
|
? t.factory.createIdentifier(importFnName)
|
|
55434
55106
|
: undefined, t.factory.createIdentifier(importAs));
|
|
55435
55107
|
});
|
|
55436
|
-
return t.createImportDeclaration(undefined, undefined, t.createImportClause(undefined, t.createNamedImports(importSpecifiers)), t.
|
|
55108
|
+
return t.factory.createImportDeclaration(undefined, undefined, t.factory.createImportClause(false, undefined, t.factory.createNamedImports(importSpecifiers)), t.factory.createStringLiteral(importPath));
|
|
55437
55109
|
};
|
|
55438
55110
|
const createRequireStatement = (importFnNames, importPath) => {
|
|
55439
55111
|
// CommonJS require()
|
|
55440
55112
|
// const { a, b, c } = require(importPath);
|
|
55441
|
-
const importBinding = t.createObjectBindingPattern(importFnNames.map((importKey) => {
|
|
55113
|
+
const importBinding = t.factory.createObjectBindingPattern(importFnNames.map((importKey) => {
|
|
55442
55114
|
const splt = importKey.split(' as ');
|
|
55443
55115
|
let importAs = importKey;
|
|
55444
55116
|
let importFnName = importKey;
|
|
@@ -55446,10 +55118,10 @@ const createRequireStatement = (importFnNames, importPath) => {
|
|
|
55446
55118
|
importAs = splt[1];
|
|
55447
55119
|
importFnName = splt[0];
|
|
55448
55120
|
}
|
|
55449
|
-
return t.createBindingElement(undefined, importFnName, importAs);
|
|
55121
|
+
return t.factory.createBindingElement(undefined, importFnName, importAs);
|
|
55450
55122
|
}));
|
|
55451
|
-
return t.createVariableStatement(undefined, t.createVariableDeclarationList([
|
|
55452
|
-
t.createVariableDeclaration(importBinding, undefined, t.factory.createCallExpression(t.factory.createIdentifier('require'), [], [t.
|
|
55123
|
+
return t.factory.createVariableStatement(undefined, t.factory.createVariableDeclarationList([
|
|
55124
|
+
t.factory.createVariableDeclaration(importBinding, undefined, undefined, t.factory.createCallExpression(t.factory.createIdentifier('require'), [], [t.factory.createStringLiteral(importPath)])),
|
|
55453
55125
|
], t.NodeFlags.Const));
|
|
55454
55126
|
};
|
|
55455
55127
|
|
|
@@ -55628,10 +55300,10 @@ const addModuleMetadataProxies = (tsSourceFile, moduleFile) => {
|
|
|
55628
55300
|
const statements = tsSourceFile.statements.slice();
|
|
55629
55301
|
addCoreRuntimeApi(moduleFile, RUNTIME_APIS.proxyCustomElement);
|
|
55630
55302
|
statements.push(...moduleFile.cmps.map(addComponentMetadataProxy));
|
|
55631
|
-
return t.
|
|
55303
|
+
return t.factory.updateSourceFile(tsSourceFile, statements);
|
|
55632
55304
|
};
|
|
55633
55305
|
const addComponentMetadataProxy = (compilerMeta) => {
|
|
55634
|
-
return t.
|
|
55306
|
+
return t.factory.createExpressionStatement(createComponentMetadataProxy(compilerMeta));
|
|
55635
55307
|
};
|
|
55636
55308
|
/**
|
|
55637
55309
|
* Create a call expression for wrapping a component in a proxy. This call expression takes a form:
|
|
@@ -55684,13 +55356,13 @@ const addImports = (transformOpts, tsSourceFile, importFnNames, importPath) => {
|
|
|
55684
55356
|
const newRequire = createRequireStatement(importFnNames, importPath);
|
|
55685
55357
|
const statements = tsSourceFile.statements.slice();
|
|
55686
55358
|
statements.splice(2, 0, newRequire);
|
|
55687
|
-
return t.
|
|
55359
|
+
return t.factory.updateSourceFile(tsSourceFile, statements);
|
|
55688
55360
|
}
|
|
55689
55361
|
// ESM Imports
|
|
55690
55362
|
const newImport = createImportStatement(importFnNames, importPath);
|
|
55691
55363
|
const statements = tsSourceFile.statements.slice();
|
|
55692
55364
|
statements.unshift(newImport);
|
|
55693
|
-
return t.
|
|
55365
|
+
return t.factory.updateSourceFile(tsSourceFile, statements);
|
|
55694
55366
|
};
|
|
55695
55367
|
|
|
55696
55368
|
/**
|
|
@@ -55767,18 +55439,21 @@ const defineCustomElement = (tsSourceFile, moduleFile, transformOpts) => {
|
|
|
55767
55439
|
// remove commonjs exports keyword from component classes
|
|
55768
55440
|
statements = removeComponentCjsExport(statements, moduleFile);
|
|
55769
55441
|
}
|
|
55770
|
-
return t.
|
|
55442
|
+
return t.factory.updateSourceFile(tsSourceFile, statements);
|
|
55771
55443
|
};
|
|
55772
55444
|
const addDefineCustomElement = (moduleFile, compilerMeta) => {
|
|
55773
55445
|
if (compilerMeta.isPlain) {
|
|
55774
55446
|
// add customElements.define('cmp-a', CmpClass);
|
|
55775
|
-
return t.
|
|
55447
|
+
return t.factory.createExpressionStatement(t.factory.createCallExpression(t.factory.createPropertyAccessExpression(t.factory.createIdentifier('customElements'), t.factory.createIdentifier('define')), [], [
|
|
55448
|
+
t.factory.createStringLiteral(compilerMeta.tagName),
|
|
55449
|
+
t.factory.createIdentifier(compilerMeta.componentClassName),
|
|
55450
|
+
]));
|
|
55776
55451
|
}
|
|
55777
55452
|
addCoreRuntimeApi(moduleFile, RUNTIME_APIS.defineCustomElement);
|
|
55778
55453
|
const compactMeta = formatComponentRuntimeMeta(compilerMeta, true);
|
|
55779
55454
|
const liternalCmpClassName = t.factory.createIdentifier(compilerMeta.componentClassName);
|
|
55780
55455
|
const liternalMeta = convertValueToLiteral(compactMeta);
|
|
55781
|
-
return t.
|
|
55456
|
+
return t.factory.createExpressionStatement(t.factory.createCallExpression(t.factory.createIdentifier(DEFINE_CUSTOM_ELEMENT), [], [liternalCmpClassName, liternalMeta]));
|
|
55782
55457
|
};
|
|
55783
55458
|
const removeComponentCjsExport = (statements, moduleFile) => {
|
|
55784
55459
|
const cmpClassNames = new Set(moduleFile.cmps.map((cmp) => cmp.componentClassName));
|
|
@@ -55838,7 +55513,7 @@ const updateEsmStyleImports = (transformOpts, tsSourceFile, moduleFile) => {
|
|
|
55838
55513
|
}
|
|
55839
55514
|
}
|
|
55840
55515
|
statements.splice(lastImportIndex + 1, 0, ...styleImports);
|
|
55841
|
-
return t.
|
|
55516
|
+
return t.factory.updateSourceFile(tsSourceFile, statements);
|
|
55842
55517
|
}
|
|
55843
55518
|
return tsSourceFile;
|
|
55844
55519
|
};
|
|
@@ -55859,7 +55534,7 @@ const updateEsmStyleImportPath = (transformOpts, tsSourceFile, statements, cmp,
|
|
|
55859
55534
|
const createEsmStyleImport = (transformOpts, tsSourceFile, cmp, style) => {
|
|
55860
55535
|
const importName = t.factory.createIdentifier(style.styleIdentifier);
|
|
55861
55536
|
const importPath = getStyleImportPath(transformOpts, tsSourceFile, cmp, style, style.externalStyles[0].absolutePath);
|
|
55862
|
-
return t.createImportDeclaration(undefined, undefined, t.createImportClause(importName, undefined), t.
|
|
55537
|
+
return t.factory.createImportDeclaration(undefined, undefined, t.factory.createImportClause(false, importName, undefined), t.factory.createStringLiteral(importPath));
|
|
55863
55538
|
};
|
|
55864
55539
|
const updateCjsStyleRequires = (transformOpts, tsSourceFile, moduleFile) => {
|
|
55865
55540
|
const styleRequires = [];
|
|
@@ -55872,15 +55547,15 @@ const updateCjsStyleRequires = (transformOpts, tsSourceFile, moduleFile) => {
|
|
|
55872
55547
|
});
|
|
55873
55548
|
});
|
|
55874
55549
|
if (styleRequires.length > 0) {
|
|
55875
|
-
return t.
|
|
55550
|
+
return t.factory.updateSourceFile(tsSourceFile, [...styleRequires, ...tsSourceFile.statements]);
|
|
55876
55551
|
}
|
|
55877
55552
|
return tsSourceFile;
|
|
55878
55553
|
};
|
|
55879
55554
|
const createCjsStyleRequire = (transformOpts, tsSourceFile, cmp, style) => {
|
|
55880
55555
|
const importName = t.factory.createIdentifier(style.styleIdentifier);
|
|
55881
55556
|
const importPath = getStyleImportPath(transformOpts, tsSourceFile, cmp, style, style.externalStyles[0].absolutePath);
|
|
55882
|
-
return t.createVariableStatement(undefined, t.createVariableDeclarationList([
|
|
55883
|
-
t.createVariableDeclaration(importName, undefined, t.factory.createCallExpression(t.factory.createIdentifier('require'), [], [t.
|
|
55557
|
+
return t.factory.createVariableStatement(undefined, t.factory.createVariableDeclarationList([
|
|
55558
|
+
t.factory.createVariableDeclaration(importName, undefined, undefined, t.factory.createCallExpression(t.factory.createIdentifier('require'), [], [t.factory.createStringLiteral(importPath)])),
|
|
55884
55559
|
], t.NodeFlags.Const));
|
|
55885
55560
|
};
|
|
55886
55561
|
const getStyleImportPath = (transformOpts, tsSourceFile, cmp, style, importPath) => {
|
|
@@ -55900,7 +55575,7 @@ const transformHostData = (classElements, moduleFile) => {
|
|
|
55900
55575
|
const renderIndex = classElements.findIndex((e) => t.isMethodDeclaration(e) && e.name.escapedText === 'render');
|
|
55901
55576
|
if (renderIndex >= 0) {
|
|
55902
55577
|
const renderMethod = classElements[renderIndex];
|
|
55903
|
-
classElements[renderIndex] = t.
|
|
55578
|
+
classElements[renderIndex] = t.factory.updateMethodDeclaration(renderMethod, renderMethod.decorators, renderMethod.modifiers, renderMethod.asteriskToken, t.factory.createIdentifier(INTERNAL_RENDER), renderMethod.questionToken, renderMethod.typeParameters, renderMethod.parameters, renderMethod.type, renderMethod.body);
|
|
55904
55579
|
}
|
|
55905
55580
|
classElements.push(syntheticRender(moduleFile, renderIndex >= 0));
|
|
55906
55581
|
}
|
|
@@ -55925,7 +55600,7 @@ const syntheticRender = (moduleFile, hasRender) => {
|
|
|
55925
55600
|
* }
|
|
55926
55601
|
*/
|
|
55927
55602
|
return t.factory.createMethodDeclaration(undefined, undefined, undefined, 'render', undefined, undefined, undefined, undefined, t.factory.createBlock([
|
|
55928
|
-
t.
|
|
55603
|
+
t.factory.createReturnStatement(t.factory.createCallExpression(t.factory.createIdentifier(H), undefined, hArguments)),
|
|
55929
55604
|
]));
|
|
55930
55605
|
};
|
|
55931
55606
|
const INTERNAL_RENDER = '__stencil_render';
|
|
@@ -55976,7 +55651,7 @@ const updateComponentClass = (transformOpts, classNode, heritageClauses, members
|
|
|
55976
55651
|
return m.kind !== t.SyntaxKind.ExportKeyword;
|
|
55977
55652
|
});
|
|
55978
55653
|
}
|
|
55979
|
-
return t.updateClassDeclaration(classNode, classNode.decorators, classModifiers, classNode.name, classNode.typeParameters, heritageClauses, members);
|
|
55654
|
+
return t.factory.updateClassDeclaration(classNode, classNode.decorators, classModifiers, classNode.name, classNode.typeParameters, heritageClauses, members);
|
|
55980
55655
|
}
|
|
55981
55656
|
// ESM with export
|
|
55982
55657
|
return createConstClass(transformOpts, classNode, heritageClauses, members);
|
|
@@ -55989,10 +55664,10 @@ const createConstClass = (transformOpts, classNode, heritageClauses, members) =>
|
|
|
55989
55664
|
});
|
|
55990
55665
|
const constModifiers = [];
|
|
55991
55666
|
if (transformOpts.componentExport !== 'customelement') {
|
|
55992
|
-
constModifiers.push(t.createModifier(t.SyntaxKind.ExportKeyword));
|
|
55667
|
+
constModifiers.push(t.factory.createModifier(t.SyntaxKind.ExportKeyword));
|
|
55993
55668
|
}
|
|
55994
|
-
return t.createVariableStatement(constModifiers, t.createVariableDeclarationList([
|
|
55995
|
-
t.createVariableDeclaration(className, undefined, t.createClassExpression(classModifiers, undefined, classNode.typeParameters, heritageClauses, members)),
|
|
55669
|
+
return t.factory.createVariableStatement(constModifiers, t.factory.createVariableDeclarationList([
|
|
55670
|
+
t.factory.createVariableDeclaration(className, undefined, undefined, t.factory.createClassExpression(undefined, classModifiers, undefined, classNode.typeParameters, heritageClauses, members)),
|
|
55996
55671
|
], t.NodeFlags.Const));
|
|
55997
55672
|
};
|
|
55998
55673
|
|
|
@@ -56032,10 +55707,10 @@ const addNativeConnectedCallback = (classMembers, cmp) => {
|
|
|
56032
55707
|
const addCreateEvents = (moduleFile, cmp) => {
|
|
56033
55708
|
return cmp.events.map((ev) => {
|
|
56034
55709
|
addCoreRuntimeApi(moduleFile, RUNTIME_APIS.createEvent);
|
|
56035
|
-
return t.
|
|
55710
|
+
return t.factory.createExpressionStatement(t.factory.createAssignment(t.factory.createPropertyAccessExpression(t.factory.createThis(), t.factory.createIdentifier(ev.method)), t.factory.createCallExpression(t.factory.createIdentifier(CREATE_EVENT), undefined, [
|
|
56036
55711
|
t.factory.createThis(),
|
|
56037
|
-
t.
|
|
56038
|
-
t.
|
|
55712
|
+
t.factory.createStringLiteral(ev.name),
|
|
55713
|
+
t.factory.createNumericLiteral(computeFlags(ev)),
|
|
56039
55714
|
])));
|
|
56040
55715
|
});
|
|
56041
55716
|
};
|
|
@@ -56068,7 +55743,7 @@ const addLegacyProps = (moduleFile, cmp) => {
|
|
|
56068
55743
|
const getStatement = (propName, method, arg) => {
|
|
56069
55744
|
return t.factory.createExpressionStatement(t.factory.createAssignment(t.factory.createPropertyAccessExpression(t.factory.createThis(), propName), t.factory.createCallExpression(t.factory.createIdentifier(method), undefined, [
|
|
56070
55745
|
t.factory.createThis(),
|
|
56071
|
-
t.
|
|
55746
|
+
t.factory.createStringLiteral(arg),
|
|
56072
55747
|
])));
|
|
56073
55748
|
};
|
|
56074
55749
|
|
|
@@ -56092,7 +55767,7 @@ const updateNativeConstructor = (classMembers, moduleFile, cmp, ensureSuper) =>
|
|
|
56092
55767
|
statements = [createNativeConstructorSuper(), ...statements];
|
|
56093
55768
|
}
|
|
56094
55769
|
}
|
|
56095
|
-
classMembers[cstrMethodIndex] = t.
|
|
55770
|
+
classMembers[cstrMethodIndex] = t.factory.updateConstructorDeclaration(cstrMethod, cstrMethod.decorators, cstrMethod.modifiers, cstrMethod.parameters, t.factory.updateBlock(cstrMethod.body, statements));
|
|
56096
55771
|
}
|
|
56097
55772
|
else {
|
|
56098
55773
|
// create a constructor()
|
|
@@ -56104,7 +55779,7 @@ const updateNativeConstructor = (classMembers, moduleFile, cmp, ensureSuper) =>
|
|
|
56104
55779
|
if (ensureSuper) {
|
|
56105
55780
|
statements = [createNativeConstructorSuper(), ...statements];
|
|
56106
55781
|
}
|
|
56107
|
-
const cstrMethod = t.
|
|
55782
|
+
const cstrMethod = t.factory.createConstructorDeclaration(undefined, undefined, undefined, t.factory.createBlock(statements, true));
|
|
56108
55783
|
classMembers.unshift(cstrMethod);
|
|
56109
55784
|
}
|
|
56110
55785
|
};
|
|
@@ -56122,7 +55797,7 @@ const nativeInit = (moduleFile, cmp) => {
|
|
|
56122
55797
|
return initStatements;
|
|
56123
55798
|
};
|
|
56124
55799
|
const nativeRegisterHostStatement = () => {
|
|
56125
|
-
return t.
|
|
55800
|
+
return t.factory.createExpressionStatement(t.factory.createCallExpression(t.factory.createPropertyAccessExpression(t.factory.createThis(), t.factory.createIdentifier('__registerHost')), undefined, undefined));
|
|
56126
55801
|
};
|
|
56127
55802
|
/**
|
|
56128
55803
|
* Generates an expression statement for attaching a shadow DOM tree to an element.
|
|
@@ -56143,7 +55818,7 @@ const addNativeElementGetter = (classMembers, cmp) => {
|
|
|
56143
55818
|
// is transformed into:
|
|
56144
55819
|
// get element() { return this; }
|
|
56145
55820
|
if (cmp.elementRef) {
|
|
56146
|
-
classMembers.push(t.
|
|
55821
|
+
classMembers.push(t.factory.createGetAccessorDeclaration(undefined, undefined, cmp.elementRef, [], undefined, t.factory.createBlock([t.factory.createReturnStatement(t.factory.createThis())])));
|
|
56147
55822
|
}
|
|
56148
55823
|
};
|
|
56149
55824
|
|
|
@@ -56331,7 +56006,7 @@ const updateStencilCoreImports = (updatedCoreImportPath) => {
|
|
|
56331
56006
|
newStatements.push(s);
|
|
56332
56007
|
});
|
|
56333
56008
|
if (madeChanges) {
|
|
56334
|
-
return t.
|
|
56009
|
+
return t.factory.updateSourceFile(tsSourceFile, newStatements, tsSourceFile.isDeclarationFile, tsSourceFile.referencedFiles, tsSourceFile.typeReferenceDirectives, tsSourceFile.hasNoDefaultLib, tsSourceFile.libReferenceDirectives);
|
|
56335
56010
|
}
|
|
56336
56011
|
return tsSourceFile;
|
|
56337
56012
|
};
|
|
@@ -56859,23 +56534,23 @@ const getCustomElementBundleCustomTransformer = (config, compilerCtx) => {
|
|
|
56859
56534
|
|
|
56860
56535
|
const updateLazyComponentConstructor = (classMembers, moduleFile, cmp) => {
|
|
56861
56536
|
const cstrMethodArgs = [
|
|
56862
|
-
t.
|
|
56537
|
+
t.factory.createParameterDeclaration(undefined, undefined, undefined, t.factory.createIdentifier(HOST_REF_ARG)),
|
|
56863
56538
|
];
|
|
56864
56539
|
const cstrMethodIndex = classMembers.findIndex((m) => m.kind === t.SyntaxKind.Constructor);
|
|
56865
56540
|
if (cstrMethodIndex >= 0) {
|
|
56866
56541
|
// add to the existing constructor()
|
|
56867
56542
|
const cstrMethod = classMembers[cstrMethodIndex];
|
|
56868
|
-
const body = t.updateBlock(cstrMethod.body, [
|
|
56543
|
+
const body = t.factory.updateBlock(cstrMethod.body, [
|
|
56869
56544
|
registerInstanceStatement(moduleFile),
|
|
56870
56545
|
...addCreateEvents(moduleFile, cmp),
|
|
56871
56546
|
...cstrMethod.body.statements,
|
|
56872
56547
|
...addLegacyProps(moduleFile, cmp),
|
|
56873
56548
|
]);
|
|
56874
|
-
classMembers[cstrMethodIndex] = t.
|
|
56549
|
+
classMembers[cstrMethodIndex] = t.factory.updateConstructorDeclaration(cstrMethod, cstrMethod.decorators, cstrMethod.modifiers, cstrMethodArgs, body);
|
|
56875
56550
|
}
|
|
56876
56551
|
else {
|
|
56877
56552
|
// create a constructor()
|
|
56878
|
-
const cstrMethod = t.
|
|
56553
|
+
const cstrMethod = t.factory.createConstructorDeclaration(undefined, undefined, cstrMethodArgs, t.factory.createBlock([
|
|
56879
56554
|
registerInstanceStatement(moduleFile),
|
|
56880
56555
|
...addCreateEvents(moduleFile, cmp),
|
|
56881
56556
|
...addLegacyProps(moduleFile, cmp),
|
|
@@ -56885,7 +56560,7 @@ const updateLazyComponentConstructor = (classMembers, moduleFile, cmp) => {
|
|
|
56885
56560
|
};
|
|
56886
56561
|
const registerInstanceStatement = (moduleFile) => {
|
|
56887
56562
|
addCoreRuntimeApi(moduleFile, RUNTIME_APIS.registerInstance);
|
|
56888
|
-
return t.
|
|
56563
|
+
return t.factory.createExpressionStatement(t.factory.createCallExpression(t.factory.createIdentifier(REGISTER_INSTANCE), undefined, [
|
|
56889
56564
|
t.factory.createThis(),
|
|
56890
56565
|
t.factory.createIdentifier(HOST_REF_ARG),
|
|
56891
56566
|
]));
|
|
@@ -56898,8 +56573,8 @@ const addLazyElementGetter = (classMembers, moduleFile, cmp) => {
|
|
|
56898
56573
|
// get element() { return __stencil_getElement(this); }
|
|
56899
56574
|
if (cmp.elementRef) {
|
|
56900
56575
|
addCoreRuntimeApi(moduleFile, RUNTIME_APIS.getElement);
|
|
56901
|
-
classMembers.push(t.
|
|
56902
|
-
t.
|
|
56576
|
+
classMembers.push(t.factory.createGetAccessorDeclaration(undefined, undefined, cmp.elementRef, [], undefined, t.factory.createBlock([
|
|
56577
|
+
t.factory.createReturnStatement(t.factory.createCallExpression(t.factory.createIdentifier(GET_ELEMENT), undefined, [
|
|
56903
56578
|
t.factory.createThis(),
|
|
56904
56579
|
])),
|
|
56905
56580
|
])));
|
|
@@ -57055,7 +56730,7 @@ const getHydrateAttrsToReflect = (cmp) => {
|
|
|
57055
56730
|
};
|
|
57056
56731
|
|
|
57057
56732
|
const updateHydrateComponentClass = (classNode, moduleFile, cmp) => {
|
|
57058
|
-
return t.updateClassDeclaration(classNode, classNode.decorators, classNode.modifiers, classNode.name, classNode.typeParameters, classNode.heritageClauses, updateHydrateHostComponentMembers(classNode, moduleFile, cmp));
|
|
56733
|
+
return t.factory.updateClassDeclaration(classNode, classNode.decorators, classNode.modifiers, classNode.name, classNode.typeParameters, classNode.heritageClauses, updateHydrateHostComponentMembers(classNode, moduleFile, cmp));
|
|
57059
56734
|
};
|
|
57060
56735
|
const updateHydrateHostComponentMembers = (classNode, moduleFile, cmp) => {
|
|
57061
56736
|
const classMembers = removeStaticMetaProperties(classNode);
|
|
@@ -57807,7 +57482,7 @@ const lazyComponentTransform = (compilerCtx, transformOpts) => {
|
|
|
57807
57482
|
}
|
|
57808
57483
|
tsSourceFile = addImports(transformOpts, tsSourceFile, moduleFile.coreRuntimeApis, transformOpts.coreImportPath);
|
|
57809
57484
|
if (styleStatements.length > 0) {
|
|
57810
|
-
tsSourceFile = t.
|
|
57485
|
+
tsSourceFile = t.factory.updateSourceFile(tsSourceFile, [...tsSourceFile.statements, ...styleStatements]);
|
|
57811
57486
|
}
|
|
57812
57487
|
return tsSourceFile;
|
|
57813
57488
|
};
|
|
@@ -58703,6 +58378,202 @@ const generateCustomDocs = async (config, docsData, outputTargets) => {
|
|
|
58703
58378
|
}));
|
|
58704
58379
|
};
|
|
58705
58380
|
|
|
58381
|
+
/**
|
|
58382
|
+
* A new BuildCtx object is created for every build
|
|
58383
|
+
* and rebuild.
|
|
58384
|
+
*/
|
|
58385
|
+
class BuildContext {
|
|
58386
|
+
constructor(config, compilerCtx) {
|
|
58387
|
+
this.buildId = -1;
|
|
58388
|
+
this.buildMessages = [];
|
|
58389
|
+
this.buildResults = null;
|
|
58390
|
+
this.bundleBuildCount = 0;
|
|
58391
|
+
this.collections = [];
|
|
58392
|
+
this.completedTasks = [];
|
|
58393
|
+
this.components = [];
|
|
58394
|
+
this.componentGraph = new Map();
|
|
58395
|
+
this.data = {};
|
|
58396
|
+
this.buildStats = undefined;
|
|
58397
|
+
this.diagnostics = [];
|
|
58398
|
+
this.dirsAdded = [];
|
|
58399
|
+
this.dirsDeleted = [];
|
|
58400
|
+
this.entryModules = [];
|
|
58401
|
+
this.filesAdded = [];
|
|
58402
|
+
this.filesChanged = [];
|
|
58403
|
+
this.filesDeleted = [];
|
|
58404
|
+
this.filesUpdated = [];
|
|
58405
|
+
this.filesWritten = [];
|
|
58406
|
+
this.globalStyle = undefined;
|
|
58407
|
+
this.hasConfigChanges = false;
|
|
58408
|
+
this.hasFinished = false;
|
|
58409
|
+
this.hasHtmlChanges = false;
|
|
58410
|
+
this.hasPrintedResults = false;
|
|
58411
|
+
this.hasServiceWorkerChanges = false;
|
|
58412
|
+
this.hasScriptChanges = true;
|
|
58413
|
+
this.hasStyleChanges = true;
|
|
58414
|
+
this.hydrateAppFilePath = null;
|
|
58415
|
+
this.indexBuildCount = 0;
|
|
58416
|
+
this.indexDoc = undefined;
|
|
58417
|
+
this.isRebuild = false;
|
|
58418
|
+
this.moduleFiles = [];
|
|
58419
|
+
this.outputs = [];
|
|
58420
|
+
this.packageJson = {};
|
|
58421
|
+
this.packageJsonFilePath = null;
|
|
58422
|
+
this.pendingCopyTasks = [];
|
|
58423
|
+
this.requiresFullBuild = true;
|
|
58424
|
+
this.scriptsAdded = [];
|
|
58425
|
+
this.scriptsDeleted = [];
|
|
58426
|
+
this.startTime = Date.now();
|
|
58427
|
+
this.styleBuildCount = 0;
|
|
58428
|
+
this.stylesPromise = null;
|
|
58429
|
+
this.stylesUpdated = [];
|
|
58430
|
+
this.timeSpan = null;
|
|
58431
|
+
this.transpileBuildCount = 0;
|
|
58432
|
+
this.config = config;
|
|
58433
|
+
this.compilerCtx = compilerCtx;
|
|
58434
|
+
this.buildId = ++this.compilerCtx.activeBuildId;
|
|
58435
|
+
this.debug = config.logger.debug.bind(config.logger);
|
|
58436
|
+
}
|
|
58437
|
+
start() {
|
|
58438
|
+
// get the build id from the incremented activeBuildId
|
|
58439
|
+
// print out a good message
|
|
58440
|
+
const msg = `${this.isRebuild ? 'rebuild' : 'build'}, ${this.config.fsNamespace}, ${this.config.devMode ? 'dev' : 'prod'} mode, started`;
|
|
58441
|
+
const buildLog = {
|
|
58442
|
+
buildId: this.buildId,
|
|
58443
|
+
messages: [],
|
|
58444
|
+
progress: 0,
|
|
58445
|
+
};
|
|
58446
|
+
this.compilerCtx.events.emit('buildLog', buildLog);
|
|
58447
|
+
// create a timespan for this build
|
|
58448
|
+
this.timeSpan = this.createTimeSpan(msg);
|
|
58449
|
+
// create a build timestamp for this build
|
|
58450
|
+
this.timestamp = getBuildTimestamp();
|
|
58451
|
+
// debug log our new build
|
|
58452
|
+
this.debug(`start build, ${this.timestamp}`);
|
|
58453
|
+
const buildStart = {
|
|
58454
|
+
buildId: this.buildId,
|
|
58455
|
+
timestamp: this.timestamp,
|
|
58456
|
+
};
|
|
58457
|
+
this.compilerCtx.events.emit('buildStart', buildStart);
|
|
58458
|
+
}
|
|
58459
|
+
createTimeSpan(msg, debug) {
|
|
58460
|
+
if (!this.hasFinished || debug) {
|
|
58461
|
+
if (debug) {
|
|
58462
|
+
if (this.config.watch) {
|
|
58463
|
+
msg = `${this.config.logger.cyan('[' + this.buildId + ']')} ${msg}`;
|
|
58464
|
+
}
|
|
58465
|
+
}
|
|
58466
|
+
const timeSpan = this.config.logger.createTimeSpan(msg, debug, this.buildMessages);
|
|
58467
|
+
if (!debug && this.compilerCtx.events) {
|
|
58468
|
+
const buildLog = {
|
|
58469
|
+
buildId: this.buildId,
|
|
58470
|
+
messages: this.buildMessages,
|
|
58471
|
+
progress: getProgress(this.completedTasks),
|
|
58472
|
+
};
|
|
58473
|
+
this.compilerCtx.events.emit('buildLog', buildLog);
|
|
58474
|
+
}
|
|
58475
|
+
return {
|
|
58476
|
+
duration: () => {
|
|
58477
|
+
return timeSpan.duration();
|
|
58478
|
+
},
|
|
58479
|
+
finish: (finishedMsg, color, bold, newLineSuffix) => {
|
|
58480
|
+
if (!this.hasFinished || debug) {
|
|
58481
|
+
if (debug) {
|
|
58482
|
+
if (this.config.watch) {
|
|
58483
|
+
finishedMsg = `${this.config.logger.cyan('[' + this.buildId + ']')} ${finishedMsg}`;
|
|
58484
|
+
}
|
|
58485
|
+
}
|
|
58486
|
+
timeSpan.finish(finishedMsg, color, bold, newLineSuffix);
|
|
58487
|
+
if (!debug) {
|
|
58488
|
+
const buildLog = {
|
|
58489
|
+
buildId: this.buildId,
|
|
58490
|
+
messages: this.buildMessages.slice(),
|
|
58491
|
+
progress: getProgress(this.completedTasks),
|
|
58492
|
+
};
|
|
58493
|
+
this.compilerCtx.events.emit('buildLog', buildLog);
|
|
58494
|
+
}
|
|
58495
|
+
}
|
|
58496
|
+
return timeSpan.duration();
|
|
58497
|
+
},
|
|
58498
|
+
};
|
|
58499
|
+
}
|
|
58500
|
+
return {
|
|
58501
|
+
duration() {
|
|
58502
|
+
return 0;
|
|
58503
|
+
},
|
|
58504
|
+
finish() {
|
|
58505
|
+
return 0;
|
|
58506
|
+
},
|
|
58507
|
+
};
|
|
58508
|
+
}
|
|
58509
|
+
debug(msg) {
|
|
58510
|
+
this.config.logger.debug(msg);
|
|
58511
|
+
}
|
|
58512
|
+
get hasError() {
|
|
58513
|
+
return hasError(this.diagnostics);
|
|
58514
|
+
}
|
|
58515
|
+
get hasWarning() {
|
|
58516
|
+
return hasWarning(this.diagnostics);
|
|
58517
|
+
}
|
|
58518
|
+
progress(t) {
|
|
58519
|
+
this.completedTasks.push(t);
|
|
58520
|
+
}
|
|
58521
|
+
async validateTypesBuild() {
|
|
58522
|
+
if (this.hasError) {
|
|
58523
|
+
// no need to wait on this one since
|
|
58524
|
+
// we already aborted this build
|
|
58525
|
+
return;
|
|
58526
|
+
}
|
|
58527
|
+
if (!this.validateTypesPromise) {
|
|
58528
|
+
// there is no pending validate types promise
|
|
58529
|
+
// so it probably already finished
|
|
58530
|
+
// so no need to wait on anything
|
|
58531
|
+
return;
|
|
58532
|
+
}
|
|
58533
|
+
if (!this.config.watch) {
|
|
58534
|
+
// this is not a watch build, so we need to make
|
|
58535
|
+
// sure that the type validation has finished
|
|
58536
|
+
this.debug(`build, non-watch, waiting on validateTypes`);
|
|
58537
|
+
await this.validateTypesPromise;
|
|
58538
|
+
this.debug(`build, non-watch, finished waiting on validateTypes`);
|
|
58539
|
+
}
|
|
58540
|
+
}
|
|
58541
|
+
}
|
|
58542
|
+
/**
|
|
58543
|
+
* Generate a timestamp of the format `YYYY-MM-DDThh:mm:ss`, using the number of seconds that have elapsed since
|
|
58544
|
+
* January 01, 1970, and the time this function was called
|
|
58545
|
+
* @returns the generated timestamp
|
|
58546
|
+
*/
|
|
58547
|
+
const getBuildTimestamp = () => {
|
|
58548
|
+
const d = new Date();
|
|
58549
|
+
// YYYY-MM-DDThh:mm:ss
|
|
58550
|
+
let timestamp = d.getUTCFullYear() + '-';
|
|
58551
|
+
timestamp += ('0' + (d.getUTCMonth() + 1)).slice(-2) + '-';
|
|
58552
|
+
timestamp += ('0' + d.getUTCDate()).slice(-2) + 'T';
|
|
58553
|
+
timestamp += ('0' + d.getUTCHours()).slice(-2) + ':';
|
|
58554
|
+
timestamp += ('0' + d.getUTCMinutes()).slice(-2) + ':';
|
|
58555
|
+
timestamp += ('0' + d.getUTCSeconds()).slice(-2);
|
|
58556
|
+
return timestamp;
|
|
58557
|
+
};
|
|
58558
|
+
const getProgress = (completedTasks) => {
|
|
58559
|
+
let progressIndex = 0;
|
|
58560
|
+
const taskKeys = Object.keys(ProgressTask);
|
|
58561
|
+
taskKeys.forEach((taskKey, index) => {
|
|
58562
|
+
if (completedTasks.includes(ProgressTask[taskKey])) {
|
|
58563
|
+
progressIndex = index;
|
|
58564
|
+
}
|
|
58565
|
+
});
|
|
58566
|
+
return (progressIndex + 1) / taskKeys.length;
|
|
58567
|
+
};
|
|
58568
|
+
const ProgressTask = {
|
|
58569
|
+
emptyOutputTargets: {},
|
|
58570
|
+
transpileApp: {},
|
|
58571
|
+
generateStyles: {},
|
|
58572
|
+
generateOutputTargets: {},
|
|
58573
|
+
validateTypesBuild: {},
|
|
58574
|
+
writeBuildFiles: {},
|
|
58575
|
+
};
|
|
58576
|
+
|
|
58706
58577
|
const AUTO_GENERATE_COMMENT = `<!-- Auto Generated Below -->`;
|
|
58707
58578
|
const NOTE = `*Built with [StencilJS](https://stenciljs.com/)*`;
|
|
58708
58579
|
|
|
@@ -61391,7 +61262,7 @@ const styleToStatic = (newMembers, componentOptions) => {
|
|
|
61391
61262
|
// @Component({
|
|
61392
61263
|
// styles: ":host {...}"
|
|
61393
61264
|
// })
|
|
61394
|
-
newMembers.push(createStaticGetter('styles', t.
|
|
61265
|
+
newMembers.push(createStaticGetter('styles', t.factory.createStringLiteral(styles)));
|
|
61395
61266
|
}
|
|
61396
61267
|
}
|
|
61397
61268
|
else if (componentOptions.styles) {
|
|
@@ -61568,7 +61439,7 @@ const elementDecoratorsToStatic = (diagnostics, decoratedMembers, typeChecker, n
|
|
|
61568
61439
|
.map((prop) => parseElementDecorator(diagnostics, typeChecker, prop))
|
|
61569
61440
|
.filter((element) => !!element);
|
|
61570
61441
|
if (elementRefs.length > 0) {
|
|
61571
|
-
newMembers.push(createStaticGetter('elementRef', t.
|
|
61442
|
+
newMembers.push(createStaticGetter('elementRef', t.factory.createStringLiteral(elementRefs[0])));
|
|
61572
61443
|
if (elementRefs.length > 1) {
|
|
61573
61444
|
const error = buildError(diagnostics);
|
|
61574
61445
|
error.messageText = `It's not valid to add more than one Element() decorator`;
|
|
@@ -62380,7 +62251,7 @@ const parseMethodDecorator = (config, diagnostics, tsSourceFile, typeChecker, me
|
|
|
62380
62251
|
},
|
|
62381
62252
|
};
|
|
62382
62253
|
validateReferences(diagnostics, methodMeta.complexType.references, method.type || method.name);
|
|
62383
|
-
const staticProp = t.factory.createPropertyAssignment(t.
|
|
62254
|
+
const staticProp = t.factory.createPropertyAssignment(t.factory.createStringLiteral(methodName), convertValueToLiteral(methodMeta));
|
|
62384
62255
|
return staticProp;
|
|
62385
62256
|
};
|
|
62386
62257
|
const isTypePromise = (typeStr) => {
|
|
@@ -62471,7 +62342,7 @@ const parsePropDecorator = (diagnostics, typeChecker, prop, watchable) => {
|
|
|
62471
62342
|
if (initializer) {
|
|
62472
62343
|
propMeta.defaultValue = initializer.getText();
|
|
62473
62344
|
}
|
|
62474
|
-
const staticProp = t.factory.createPropertyAssignment(t.
|
|
62345
|
+
const staticProp = t.factory.createPropertyAssignment(t.factory.createStringLiteral(propName), convertValueToLiteral(propMeta));
|
|
62475
62346
|
watchable.add(propName);
|
|
62476
62347
|
return staticProp;
|
|
62477
62348
|
};
|
|
@@ -62729,7 +62600,7 @@ const visitClassDeclaration = (config, diagnostics, typeChecker, classNode) => {
|
|
|
62729
62600
|
// class' constructor which instantiate them there instead.
|
|
62730
62601
|
const updatedClassFields = handleClassFields(classNode, filteredMethodsAndFields);
|
|
62731
62602
|
validateMethods(diagnostics, classMembers);
|
|
62732
|
-
return t.updateClassDeclaration(classNode, filterDecorators(classNode, CLASS_DECORATORS_TO_REMOVE), classNode.modifiers, classNode.name, classNode.typeParameters, classNode.heritageClauses, updatedClassFields);
|
|
62603
|
+
return t.factory.updateClassDeclaration(classNode, filterDecorators(classNode, CLASS_DECORATORS_TO_REMOVE), classNode.modifiers, classNode.name, classNode.typeParameters, classNode.heritageClauses, updatedClassFields);
|
|
62733
62604
|
};
|
|
62734
62605
|
/**
|
|
62735
62606
|
* Take a list of `ClassElement` AST nodes and remove any decorators from
|
|
@@ -62753,7 +62624,7 @@ const removeStencilMethodDecorators = (classMembers, diagnostics) => {
|
|
|
62753
62624
|
const newDecorators = filterDecorators(member, MEMBER_DECORATORS_TO_REMOVE);
|
|
62754
62625
|
if (currentDecorators !== newDecorators) {
|
|
62755
62626
|
if (t.isMethodDeclaration(member)) {
|
|
62756
|
-
return t.
|
|
62627
|
+
return t.factory.updateMethodDeclaration(member, newDecorators, member.modifiers, member.asteriskToken, member.name, member.questionToken, member.typeParameters, member.parameters, member.type, member.body);
|
|
62757
62628
|
}
|
|
62758
62629
|
else if (t.isPropertyDeclaration(member)) {
|
|
62759
62630
|
if (shouldInitializeInConstructor(member)) {
|
|
@@ -62766,7 +62637,7 @@ const removeStencilMethodDecorators = (classMembers, diagnostics) => {
|
|
|
62766
62637
|
}
|
|
62767
62638
|
else {
|
|
62768
62639
|
// update the property to remove decorators
|
|
62769
|
-
return t.
|
|
62640
|
+
return t.factory.updatePropertyDeclaration(member, newDecorators, member.modifiers, member.name, member.questionToken, member.type, member.initializer);
|
|
62770
62641
|
}
|
|
62771
62642
|
}
|
|
62772
62643
|
else {
|
|
@@ -62965,14 +62836,29 @@ function handleClassFields(classNode, classMembers) {
|
|
|
62965
62836
|
* @returns a list of updated class elements
|
|
62966
62837
|
*/
|
|
62967
62838
|
const updateConstructor = (classNode, classMembers, statements) => {
|
|
62839
|
+
var _a, _b, _c;
|
|
62968
62840
|
const constructorIndex = classMembers.findIndex((m) => m.kind === t.SyntaxKind.Constructor);
|
|
62969
62841
|
const constructorMethod = classMembers[constructorIndex];
|
|
62970
62842
|
if (constructorIndex >= 0 && t.isConstructorDeclaration(constructorMethod)) {
|
|
62971
|
-
const
|
|
62843
|
+
const constructorBodyStatements = (_b = (_a = constructorMethod.body) === null || _a === void 0 ? void 0 : _a.statements) !== null && _b !== void 0 ? _b : t.factory.createNodeArray();
|
|
62844
|
+
const hasSuper = constructorBodyStatements.some((s) => s.kind === t.SyntaxKind.SuperKeyword);
|
|
62972
62845
|
if (!hasSuper && needsSuper(classNode)) {
|
|
62973
|
-
|
|
62846
|
+
// if there is no super and it needs one the statements comprising the
|
|
62847
|
+
// body of the constructor should be:
|
|
62848
|
+
//
|
|
62849
|
+
// 1. the `super()` call
|
|
62850
|
+
// 2. the new statements we've created to initialize fields
|
|
62851
|
+
// 3. the statements currently comprising the body of the constructor
|
|
62852
|
+
statements = [createConstructorBodyWithSuper(), ...statements, ...constructorBodyStatements];
|
|
62974
62853
|
}
|
|
62975
|
-
|
|
62854
|
+
else {
|
|
62855
|
+
// if no super is needed then the body of the constructor should be:
|
|
62856
|
+
//
|
|
62857
|
+
// 1. the new statements we've created to initialize fields
|
|
62858
|
+
// 2. the statements currently comprising the body of the constructor
|
|
62859
|
+
statements = [...statements, ...constructorBodyStatements];
|
|
62860
|
+
}
|
|
62861
|
+
classMembers[constructorIndex] = t.factory.updateConstructorDeclaration(constructorMethod, constructorMethod.decorators, constructorMethod.modifiers, constructorMethod.parameters, t.factory.updateBlock((_c = constructorMethod === null || constructorMethod === void 0 ? void 0 : constructorMethod.body) !== null && _c !== void 0 ? _c : t.factory.createBlock([]), statements));
|
|
62976
62862
|
}
|
|
62977
62863
|
else {
|
|
62978
62864
|
// we don't seem to have a constructor, so let's create one and stick it
|
|
@@ -62981,7 +62867,7 @@ const updateConstructor = (classNode, classMembers, statements) => {
|
|
|
62981
62867
|
statements = [createConstructorBodyWithSuper(), ...statements];
|
|
62982
62868
|
}
|
|
62983
62869
|
classMembers = [
|
|
62984
|
-
t.factory.createConstructorDeclaration(undefined, undefined,
|
|
62870
|
+
t.factory.createConstructorDeclaration(undefined, undefined, [], t.factory.createBlock(statements, true)),
|
|
62985
62871
|
...classMembers,
|
|
62986
62872
|
];
|
|
62987
62873
|
}
|
|
@@ -63175,7 +63061,7 @@ const addComponentMetaStatic = (cmpNode, cmpMeta) => {
|
|
|
63175
63061
|
const publicCompilerMeta = getPublicCompilerMeta(cmpMeta);
|
|
63176
63062
|
const cmpMetaStaticProp = createStaticGetter('COMPILER_META', convertValueToLiteral(publicCompilerMeta));
|
|
63177
63063
|
const classMembers = [...cmpNode.members, cmpMetaStaticProp];
|
|
63178
|
-
return t.updateClassDeclaration(cmpNode, cmpNode.decorators, cmpNode.modifiers, cmpNode.name, cmpNode.typeParameters, cmpNode.heritageClauses, classMembers);
|
|
63064
|
+
return t.factory.updateClassDeclaration(cmpNode, cmpNode.decorators, cmpNode.modifiers, cmpNode.name, cmpNode.typeParameters, cmpNode.heritageClauses, classMembers);
|
|
63179
63065
|
};
|
|
63180
63066
|
const getPublicCompilerMeta = (cmpMeta) => {
|
|
63181
63067
|
const publicCompilerMeta = Object.assign({}, cmpMeta);
|
|
@@ -65081,6 +64967,157 @@ const createFullBuild = async (config, compilerCtx) => {
|
|
|
65081
64967
|
});
|
|
65082
64968
|
};
|
|
65083
64969
|
|
|
64970
|
+
const compilerRequest = async (config, compilerCtx, data) => {
|
|
64971
|
+
const results = {
|
|
64972
|
+
path: data.path,
|
|
64973
|
+
nodeModuleId: null,
|
|
64974
|
+
nodeModuleVersion: null,
|
|
64975
|
+
nodeResolvedPath: null,
|
|
64976
|
+
cachePath: null,
|
|
64977
|
+
cacheHit: false,
|
|
64978
|
+
content: '',
|
|
64979
|
+
status: 404,
|
|
64980
|
+
};
|
|
64981
|
+
try {
|
|
64982
|
+
const parsedUrl = parseDevModuleUrl(config, data.path);
|
|
64983
|
+
Object.assign(results, parsedUrl);
|
|
64984
|
+
if (parsedUrl.nodeModuleId) {
|
|
64985
|
+
if (!parsedUrl.nodeModuleVersion) {
|
|
64986
|
+
results.content = `/* invalid module version */`;
|
|
64987
|
+
results.status = 400;
|
|
64988
|
+
return results;
|
|
64989
|
+
}
|
|
64990
|
+
if (!parsedUrl.nodeResolvedPath) {
|
|
64991
|
+
results.content = `/* invalid resolved path */`;
|
|
64992
|
+
results.status = 400;
|
|
64993
|
+
return results;
|
|
64994
|
+
}
|
|
64995
|
+
const useCache = await useDevModuleCache(config, parsedUrl.nodeResolvedPath);
|
|
64996
|
+
let cachePath = null;
|
|
64997
|
+
if (useCache) {
|
|
64998
|
+
cachePath = getDevModuleCachePath(config, parsedUrl);
|
|
64999
|
+
const cachedContent = await config.sys.readFile(cachePath);
|
|
65000
|
+
if (typeof cachedContent === 'string') {
|
|
65001
|
+
results.content = cachedContent;
|
|
65002
|
+
results.cachePath = cachePath;
|
|
65003
|
+
results.cacheHit = true;
|
|
65004
|
+
results.status = 200;
|
|
65005
|
+
return results;
|
|
65006
|
+
}
|
|
65007
|
+
}
|
|
65008
|
+
await bundleDevModule(config, compilerCtx, parsedUrl, results);
|
|
65009
|
+
if (results.status === 200 && useCache) {
|
|
65010
|
+
results.cachePath = cachePath;
|
|
65011
|
+
writeCachedFile(config, results);
|
|
65012
|
+
}
|
|
65013
|
+
}
|
|
65014
|
+
else {
|
|
65015
|
+
results.content = `/* invalid dev module */`;
|
|
65016
|
+
results.status = 400;
|
|
65017
|
+
return results;
|
|
65018
|
+
}
|
|
65019
|
+
}
|
|
65020
|
+
catch (e) {
|
|
65021
|
+
if (e) {
|
|
65022
|
+
if (e instanceof Error && e.stack) {
|
|
65023
|
+
results.content = `/*\n${e.stack}\n*/`;
|
|
65024
|
+
}
|
|
65025
|
+
else {
|
|
65026
|
+
results.content = `/*\n${e}\n*/`;
|
|
65027
|
+
}
|
|
65028
|
+
}
|
|
65029
|
+
results.status = 500;
|
|
65030
|
+
}
|
|
65031
|
+
return results;
|
|
65032
|
+
};
|
|
65033
|
+
const bundleDevModule = async (config, compilerCtx, parsedUrl, results) => {
|
|
65034
|
+
const buildCtx = new BuildContext(config, compilerCtx);
|
|
65035
|
+
try {
|
|
65036
|
+
const inputOpts = getRollupOptions(config, compilerCtx, buildCtx, {
|
|
65037
|
+
id: parsedUrl.nodeModuleId,
|
|
65038
|
+
platform: 'client',
|
|
65039
|
+
inputs: {
|
|
65040
|
+
index: parsedUrl.nodeResolvedPath,
|
|
65041
|
+
},
|
|
65042
|
+
});
|
|
65043
|
+
const rollupBuild = await rollup(inputOpts);
|
|
65044
|
+
const outputOpts = {
|
|
65045
|
+
banner: generatePreamble(config),
|
|
65046
|
+
format: 'es',
|
|
65047
|
+
};
|
|
65048
|
+
if (parsedUrl.nodeModuleId) {
|
|
65049
|
+
const commentPath = relative$1(config.rootDir, parsedUrl.nodeResolvedPath);
|
|
65050
|
+
outputOpts.intro = `/**\n * Dev Node Module: ${parsedUrl.nodeModuleId}, v${parsedUrl.nodeModuleVersion}\n * Entry: ${commentPath}\n * DEVELOPMENT PURPOSES ONLY!!\n */`;
|
|
65051
|
+
inputOpts.input = parsedUrl.nodeResolvedPath;
|
|
65052
|
+
}
|
|
65053
|
+
const r = await rollupBuild.generate(outputOpts);
|
|
65054
|
+
if (buildCtx.hasError) {
|
|
65055
|
+
results.status = 500;
|
|
65056
|
+
results.content = `console.error(${JSON.stringify(buildCtx.diagnostics)})`;
|
|
65057
|
+
}
|
|
65058
|
+
else if (r && r.output && r.output.length > 0) {
|
|
65059
|
+
results.content = r.output[0].code;
|
|
65060
|
+
results.status = 200;
|
|
65061
|
+
}
|
|
65062
|
+
}
|
|
65063
|
+
catch (e) {
|
|
65064
|
+
results.status = 500;
|
|
65065
|
+
const errorMsg = e instanceof Error ? e.stack : e + '';
|
|
65066
|
+
results.content = `console.error(${JSON.stringify(errorMsg)})`;
|
|
65067
|
+
}
|
|
65068
|
+
};
|
|
65069
|
+
const useDevModuleCache = async (config, p) => {
|
|
65070
|
+
if (config.enableCache) {
|
|
65071
|
+
for (let i = 0; i < 10; i++) {
|
|
65072
|
+
const n = basename(p);
|
|
65073
|
+
if (n === 'node_modules') {
|
|
65074
|
+
return true;
|
|
65075
|
+
}
|
|
65076
|
+
const isSymbolicLink = await config.sys.isSymbolicLink(p);
|
|
65077
|
+
if (isSymbolicLink) {
|
|
65078
|
+
return false;
|
|
65079
|
+
}
|
|
65080
|
+
p = dirname(p);
|
|
65081
|
+
}
|
|
65082
|
+
}
|
|
65083
|
+
return false;
|
|
65084
|
+
};
|
|
65085
|
+
const writeCachedFile = async (config, results) => {
|
|
65086
|
+
try {
|
|
65087
|
+
await config.sys.createDir(config.cacheDir);
|
|
65088
|
+
config.sys.writeFile(results.cachePath, results.content);
|
|
65089
|
+
}
|
|
65090
|
+
catch (e) {
|
|
65091
|
+
console.error(e);
|
|
65092
|
+
}
|
|
65093
|
+
};
|
|
65094
|
+
const parseDevModuleUrl = (config, u) => {
|
|
65095
|
+
const parsedUrl = {
|
|
65096
|
+
nodeModuleId: null,
|
|
65097
|
+
nodeModuleVersion: null,
|
|
65098
|
+
nodeResolvedPath: null,
|
|
65099
|
+
};
|
|
65100
|
+
if (u && u.includes(DEV_MODULE_DIR) && u.endsWith('.js')) {
|
|
65101
|
+
const url = new URL(u, 'https://stenciljs.com');
|
|
65102
|
+
let reqPath = basename(url.pathname);
|
|
65103
|
+
reqPath = reqPath.substring(0, reqPath.length - 3);
|
|
65104
|
+
const splt = reqPath.split('@');
|
|
65105
|
+
if (splt.length === 2) {
|
|
65106
|
+
parsedUrl.nodeModuleId = decodeURIComponent(splt[0]);
|
|
65107
|
+
parsedUrl.nodeModuleVersion = decodeURIComponent(splt[1]);
|
|
65108
|
+
parsedUrl.nodeResolvedPath = url.searchParams.get('p');
|
|
65109
|
+
if (parsedUrl.nodeResolvedPath) {
|
|
65110
|
+
parsedUrl.nodeResolvedPath = decodeURIComponent(parsedUrl.nodeResolvedPath);
|
|
65111
|
+
parsedUrl.nodeResolvedPath = join(config.rootDir, parsedUrl.nodeResolvedPath);
|
|
65112
|
+
}
|
|
65113
|
+
}
|
|
65114
|
+
}
|
|
65115
|
+
return parsedUrl;
|
|
65116
|
+
};
|
|
65117
|
+
const getDevModuleCachePath = (config, parsedUrl) => {
|
|
65118
|
+
return join(config.cacheDir, `dev_module_${parsedUrl.nodeModuleId}_${parsedUrl.nodeModuleVersion}_${DEV_MODULE_CACHE_BUSTER}.log`);
|
|
65119
|
+
};
|
|
65120
|
+
|
|
65084
65121
|
const filesChanged = (buildCtx) => {
|
|
65085
65122
|
// files changed include updated, added and deleted
|
|
65086
65123
|
return unique([...buildCtx.filesUpdated, ...buildCtx.filesAdded, ...buildCtx.filesDeleted]).sort();
|
|
@@ -68017,7 +68054,7 @@ const validateTesting = (config, diagnostics) => {
|
|
|
68017
68054
|
return join(testing.rootDir, ignorePattern);
|
|
68018
68055
|
});
|
|
68019
68056
|
((_a = config.outputTargets) !== null && _a !== void 0 ? _a : [])
|
|
68020
|
-
.filter((o) => (isOutputTargetDist(o) || isOutputTargetWww(o)) && o.dir)
|
|
68057
|
+
.filter((o) => (isOutputTargetDist(o) || isOutputTargetWww(o)) && !!o.dir)
|
|
68021
68058
|
.forEach((outputTarget) => {
|
|
68022
68059
|
var _a;
|
|
68023
68060
|
(_a = testing.testPathIgnorePatterns) === null || _a === void 0 ? void 0 : _a.push(outputTarget.dir);
|
|
@@ -69089,7 +69126,7 @@ const getComponentPathContent = (componentGraph, outputTarget) => {
|
|
|
69089
69126
|
const dependencies = [
|
|
69090
69127
|
{
|
|
69091
69128
|
name: "@stencil/core",
|
|
69092
|
-
version: "2.19.
|
|
69129
|
+
version: "2.19.2-0",
|
|
69093
69130
|
main: "compiler/stencil.js",
|
|
69094
69131
|
resources: [
|
|
69095
69132
|
"package.json",
|