@stencil/core 5.0.0-beta.13 → 5.0.0-beta.15

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.
@@ -1,9 +1,9 @@
1
1
  import { n as __require } from "./rolldown-runtime-BhDjJH2R.mjs";
2
- import { S as HYDRATED_CSS } from "./client-NHI55T4R.mjs";
2
+ import { E as SERVER_BUILD_FLAGS, T as HYDRATED_CSS, w as CLIENT_BUILD_FLAGS } from "./client-BUal4Vkx.mjs";
3
3
  import { $ as VALID_CONFIG_OUTPUT_TARGETS, A as DIST_LAZY, D as COPY, E as COLLECTION_MANIFEST_FILE_NAME, J as STANDALONE, L as EVENT_FLAGS, P as DOCS_JSON, Q as TYPES, R as GENERATED_DTS, S as ASSETS, T as COLLECTION_APP_DATA_FILE_NAME, U as LOADER_BUNDLE, X as STYLE_EXT, Y as STATS, a as isBoolean$1, b as unique, c as isFunction, d as isObject, et as WATCH_FLAGS, f as isString$1, g as sortBy, i as fromEntries, l as isIterable, m as noop, p as mergeIntoWith, r as flatOne, t as dashToPascalCase, u as isNumber$1, v as toDashCase, w as COLLECTION, y as toTitleCase, z as GLOBAL_STYLE } from "./helpers-Cpp3qc3u.mjs";
4
4
  import { E as escapeRegExpSpecialCharacters, S as formatComponentRuntimeMeta, T as byteSize, _ as loadRolldownDiagnostics, a as getSourceMappingUrlForEndOfFile, b as splitLineBreaks, c as err, f as augmentDiagnosticWithNode, g as isRolldownError, h as createOnWarnFn, i as getInlineSourceMappingUrlLinker, l as map, m as loadTypeScriptDiagnostics, n as validateComponentTag, p as loadTypeScriptDiagnostic, r as isRemoteUrl, s as rolldownToStencilSourceMap, t as validateComponentModes, u as ok, w as stringifyRuntimeData, x as isRootPath, y as normalizeDiagnostics } from "./validation-DAdGTrys.mjs";
5
- import { $ as catchError, A as isOutputTargetDocsVscode, B as relativeImport, C as isOutputTargetDistLazy, D as isOutputTargetDocsCustomElementsManifest, E as isOutputTargetDocsCustom, F as isOutputTargetStandalone, G as normalizeFsPathQuery, H as join$2, I as isOutputTargetStats, J as resolve$2, K as normalizePath, L as isOutputTargetTypes, M as isOutputTargetLoaderBundle, N as isOutputTargetSsr, O as isOutputTargetDocsJson, P as isOutputTargetSsrWasm, Q as buildWarn, R as isOutputTargetWww, S as isOutputTargetCustom, T as isOutputTargetDocsAgentSkill, W as normalizeFsPath, X as buildError, Z as buildJsonFileError, a as hasDependency, b as isOutputTargetCollection, d as parsePackageJson, et as hasError, f as readOnlyArrayHasStringMember, g as getComponentsDtsSrcFilePath, h as filterExcludedComponents, i as getTextDocs, j as isOutputTargetGlobalStyle, k as isOutputTargetDocsReadme, l as isTsFile, m as filterActiveTargets, n as createJsVarName, o as isDtsFile, p as readPackageJson, q as relative$1, r as generatePreamble, rt as isGlob, t as addDocBlock, tt as hasWarning, u as isTsxFile, v as getComponentsFromModules, w as isOutputTargetDocs, x as isOutputTargetCopy, y as isOutputTargetAssets, z as isValidConfigOutputTarget } from "./util-IKfWWLJo.mjs";
6
- import { i as CustomElementsExportBehaviorOptions, o as buildEvents, r as createNodeLogger, t as createNodeSys } from "./node-DrwzfDH1.mjs";
5
+ import { $ as catchError, A as isOutputTargetDocsVscode, B as relativeImport, C as isOutputTargetDistLazy, D as isOutputTargetDocsCustomElementsManifest, E as isOutputTargetDocsCustom, F as isOutputTargetStandalone, G as normalizeFsPathQuery, H as join$2, I as isOutputTargetStats, J as resolve$2, K as normalizePath, L as isOutputTargetTypes, M as isOutputTargetLoaderBundle, N as isOutputTargetSsr, O as isOutputTargetDocsJson, P as isOutputTargetSsrWasm, Q as buildWarn, R as isOutputTargetWww, S as isOutputTargetCustom, T as isOutputTargetDocsAgentSkill, V as shouldExcludeComponent, W as normalizeFsPath, X as buildError, Z as buildJsonFileError, a as hasDependency, b as isOutputTargetCollection, d as parsePackageJson, et as hasError, f as readOnlyArrayHasStringMember, g as getComponentsDtsSrcFilePath, h as filterExcludedComponents, i as getTextDocs, j as isOutputTargetGlobalStyle, k as isOutputTargetDocsReadme, l as isTsFile, m as filterActiveTargets, n as createJsVarName, o as isDtsFile, p as readPackageJson, q as relative$1, r as generatePreamble, rt as isGlob, t as addDocBlock, tt as hasWarning, u as isTsxFile, v as getComponentsFromModules, w as isOutputTargetDocs, x as isOutputTargetCopy, y as isOutputTargetAssets, z as isValidConfigOutputTarget } from "./util-IKfWWLJo.mjs";
6
+ import { i as CustomElementsExportBehaviorOptions, o as buildEvents, r as createNodeLogger, t as createNodeSys } from "./node-v9OHhp0m.mjs";
7
7
  import ts, { default as ts$1 } from "typescript";
8
8
  import { readFileSync } from "node:fs";
9
9
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
@@ -343,7 +343,7 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
343
343
  else return shallowPart.trim();
344
344
  }).join(", ");
345
345
  };
346
- const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
346
+ const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer") || selector.startsWith("@container");
347
347
  const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
348
348
  return processRules(cssText, (rule) => {
349
349
  let selector = rule.selector;
@@ -462,9 +462,9 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
462
462
  };
463
463
  //#endregion
464
464
  //#region src/version.ts
465
- const version = "5.0.0-beta.13";
466
- const buildId = "1790721042";
467
- const vermoji = "🌎";
465
+ const version = "5.0.0-beta.15";
466
+ const buildId = "1790976317";
467
+ const vermoji = "📣";
468
468
  /**
469
469
  * Get the installed version of a tool/dependency.
470
470
  * Handles packages with exports maps that point to subdirectories.
@@ -2293,12 +2293,10 @@ const updateBuildConditionals = (config, b) => {
2293
2293
  const CREATE_EVENT = "__stencil_createEvent";
2294
2294
  const DEFINE_CUSTOM_ELEMENT = "__stencil_defineCustomElement";
2295
2295
  const GET_ELEMENT = "__stencil_getElement";
2296
- const HOST = "__stencil_Host";
2297
2296
  const HTML_ELEMENT = "HTMLElement";
2298
2297
  const PROXY_CUSTOM_ELEMENT = "__stencil_proxyCustomElement";
2299
2298
  const REGISTER_INSTANCE = "__stencil_registerInstance";
2300
2299
  const REGISTER_HOST = "__stencil_registerHost";
2301
- const H = "__stencil_h";
2302
2300
  const TRANSFORM_TAG = "__stencil_transformTag";
2303
2301
  const GET_REGISTRY = "__stencil_getRegistry";
2304
2302
  const INJECT_SIDE_EFFECT_STYLE = "__stencil_injectSideEffectStyle";
@@ -2306,9 +2304,7 @@ const RUNTIME_APIS = {
2306
2304
  createEvent: `createEvent as ${CREATE_EVENT}`,
2307
2305
  defineCustomElement: `defineCustomElement as ${DEFINE_CUSTOM_ELEMENT}`,
2308
2306
  getElement: `getElement as ${GET_ELEMENT}`,
2309
- h: `h as ${H}`,
2310
2307
  legacyH: `h`,
2311
- Host: `Host as ${HOST}`,
2312
2308
  HTMLElement: HTML_ELEMENT,
2313
2309
  proxyCustomElement: `proxyCustomElement as ${PROXY_CUSTOM_ELEMENT}`,
2314
2310
  registerHost: `registerHost as ${REGISTER_HOST}`,
@@ -3811,10 +3807,11 @@ const mapImportsToPathAliases = (config, destinationFilePath, outputTarget) => {
3811
3807
  const outputCollection = async (config, compilerCtx, buildCtx, changedModuleFiles) => {
3812
3808
  const outputTargets = config.outputTargets.filter(isOutputTargetCollection);
3813
3809
  if (outputTargets.length === 0) return;
3810
+ const collectionModuleFiles = changedModuleFiles.filter((mod) => config.devMode || !mod.cmps.some((cmp) => shouldExcludeComponent(cmp.tagName, config.excludeComponents)));
3814
3811
  const bundlingEventMessage = `generate collection${config.sourceMap ? " + source maps" : ""}`;
3815
3812
  const timespan = buildCtx.createTimeSpan(`${bundlingEventMessage} started`, true);
3816
3813
  try {
3817
- await Promise.all(changedModuleFiles.map(async (mod) => {
3814
+ await Promise.all(collectionModuleFiles.map(async (mod) => {
3818
3815
  let code = mod.staticSourceFileText;
3819
3816
  if (config.preamble) code = `${generatePreamble(config)}\n${code}`;
3820
3817
  const mapCode = mod.sourceMapFileText;
@@ -3883,7 +3880,7 @@ const serializeCollectionManifest = (config, compilerCtx, buildCtx) => {
3883
3880
  buildFlags.constructableCSS = true;
3884
3881
  buildFlags.cssAnnotations = true;
3885
3882
  const collectionManifest = {
3886
- entries: buildCtx.moduleFiles.filter((mod) => !mod.isCollectionDependency && mod.cmps.length > 0).map((mod) => relative$1(config.srcDir, mod.jsFilePath)),
3883
+ entries: buildCtx.moduleFiles.filter((mod) => !mod.isCollectionDependency && mod.cmps.length > 0 && (config.devMode || !mod.cmps.some((cmp) => shouldExcludeComponent(cmp.tagName, config.excludeComponents)))).map((mod) => relative$1(config.srcDir, mod.jsFilePath)),
3887
3884
  mixins: buildCtx.moduleFiles.filter((mod) => !mod.isCollectionDependency && mod.hasExportableMixins && mod.cmps.length === 0).map((mod) => relative$1(config.srcDir, mod.jsFilePath)),
3888
3885
  compiler: {
3889
3886
  name: "@stencil/core",
@@ -4497,7 +4494,7 @@ const appDataPlugin = (config, compilerCtx, buildCtx, buildConditionals, platfor
4497
4494
  name: "appDataPlugin",
4498
4495
  resolveId: {
4499
4496
  filter: { id: /^@stencil\/core\/app-(data|globals)$/ },
4500
- handler(id, importer) {
4497
+ handler(id) {
4501
4498
  if (id === "@stencil/core/app-data" || id === "@stencil/core/app-globals") {
4502
4499
  if (platform === "worker") this.error("@stencil/core packages cannot be imported from a worker.");
4503
4500
  return id;
@@ -4686,19 +4683,6 @@ const appendNamespace = (config, s) => {
4686
4683
  };
4687
4684
  //#endregion
4688
4685
  //#region src/compiler/sys/fetch/fetch-utils.ts
4689
- /**
4690
- * A fetch wrapper which dispatches to `sys.fetch` if present, and otherwise
4691
- * uses `global.fetch`.
4692
- *
4693
- * @param sys a compiler system object
4694
- * @param input a `RequestInfo` object
4695
- * @param init an optional `RequestInit` object
4696
- * @returns a Promise wrapping a response
4697
- */
4698
- const httpFetch = (sys, input, init) => {
4699
- if (sys && isFunction(sys.fetch)) return sys.fetch(input, init);
4700
- return fetch(input, init);
4701
- };
4702
4686
  const packageVersions = /* @__PURE__ */ new Map();
4703
4687
  const known404Urls = /* @__PURE__ */ new Set();
4704
4688
  /**
@@ -4769,7 +4753,7 @@ const writeFetchSuccessAsync = async (sys, inMemoryFs, url, filePath, content, p
4769
4753
  const fetchModuleAsync = async (sys, inMemoryFs, pkgVersions, url, filePath) => {
4770
4754
  if (skipFilePathFetch(filePath) || known404Urls.has(url) || skipUrlFetch(url)) return;
4771
4755
  try {
4772
- const rsp = await httpFetch(sys, url);
4756
+ const rsp = await fetch(url);
4773
4757
  if (rsp) {
4774
4758
  if (rsp.ok) {
4775
4759
  const content = await rsp.clone().text();
@@ -4836,13 +4820,11 @@ const coreResolvePlugin = (config, compilerCtx, platform, externalRuntime, lazyL
4836
4820
  if (filePath && !filePath.startsWith("\0")) {
4837
4821
  filePath = normalizeFsPath(filePath);
4838
4822
  if (filePath === internalClient || filePath === internalSsr) {
4839
- if (platform === "worker") return `
4840
- export const Build = {
4841
- isDev: ${config.devMode},
4842
- isBrowser: true,
4843
- isServer: false,
4844
- isTesting: false,
4845
- };`;
4823
+ if (platform === "worker") return `export const Build = ${JSON.stringify({
4824
+ ...CLIENT_BUILD_FLAGS,
4825
+ isDev: config.devMode,
4826
+ isTesting: false
4827
+ })};`;
4846
4828
  const cached = transformedCodeCache.get(filePath);
4847
4829
  if (cached) return cached;
4848
4830
  let code = await compilerCtx.fs.readFile(filePath);
@@ -4955,6 +4937,139 @@ const buildConditionalsPlugin = (config, buildConditionals) => {
4955
4937
  };
4956
4938
  };
4957
4939
  //#endregion
4940
+ //#region src/compiler/bundle/build-flags-plugin.ts
4941
+ const STENCIL_CORE_IMPORT_RE = /^@stencil\/core(?:\/runtime(?:\/(?:client(?:\/(?:standalone|lazy))?|server))?)?$/;
4942
+ const BUILD_IMPORT_RE = /\bimport\s*\{[^}]*\bBuild\b[^}]*\}\s*from\s*['"]@stencil\/core/;
4943
+ /**
4944
+ * Rolldown plugin that folds user-code `Build.<flag>` reads to literals (see {@link foldBuildFlags}),
4945
+ * so rolldown can tree-shake gated branches - and anything only they import - before chunking.
4946
+ *
4947
+ * Only flags whose value is fixed for this bundle are folded. With an external runtime,
4948
+ * `isDev` / `isTesting` come from the consumer's app-data, so they're left as runtime reads.
4949
+ *
4950
+ * @param bundleOpts the options for this bundle
4951
+ * @returns a rolldown plugin
4952
+ */
4953
+ const buildFlagsPlugin = (bundleOpts) => {
4954
+ const flags = getFoldableBuildFlags(bundleOpts);
4955
+ return {
4956
+ name: "stencil-build-flags",
4957
+ transform: {
4958
+ filter: { code: BUILD_IMPORT_RE },
4959
+ handler(code, id) {
4960
+ if (id.startsWith("\0")) return null;
4961
+ const folded = foldBuildFlags(code, id.split("?")[0], flags);
4962
+ return folded === null ? null : {
4963
+ code: folded,
4964
+ map: null
4965
+ };
4966
+ }
4967
+ }
4968
+ };
4969
+ };
4970
+ /**
4971
+ * The `Build` flags with a fixed value in this bundle.
4972
+ *
4973
+ * @param bundleOpts the options for this bundle
4974
+ * @returns the foldable flags
4975
+ */
4976
+ const getFoldableBuildFlags = (bundleOpts) => {
4977
+ if (bundleOpts.platform === "ssr") return { ...SERVER_BUILD_FLAGS };
4978
+ const flags = { ...CLIENT_BUILD_FLAGS };
4979
+ const conditionals = bundleOpts.conditionals;
4980
+ if (bundleOpts.platform === "client" && !bundleOpts.externalRuntime && conditionals) {
4981
+ if (typeof conditionals.isDev === "boolean") flags.isDev = conditionals.isDev;
4982
+ if (typeof conditionals.isTesting === "boolean") flags.isTesting = conditionals.isTesting;
4983
+ }
4984
+ return flags;
4985
+ };
4986
+ /**
4987
+ * Replaces `Build.<flag>` reads (where `Build` is imported from `@stencil/core`) with literals,
4988
+ * letting bundlers / minify-ers drop dead branches. Neither oxc nor terser can fold a property
4989
+ * read on the runtime's `Build` object.
4990
+ *
4991
+ * e.g. with `{ isServer: false }`:
4992
+ * ```ts
4993
+ * if (Build.isServer) { … } // before
4994
+ * if (false ) { … } // after
4995
+ * ```
4996
+ *
4997
+ * Replacements are padded to the original length (newlines kept), so an existing sourcemap
4998
+ * for `code` stays valid. A `Build` binding that is shadowed or written to in the module is left alone.
4999
+ *
5000
+ * @param code JS or TS source
5001
+ * @param fileName used to pick the parser's script kind
5002
+ * @param flags the flag values to fold; flags not present are left as runtime reads
5003
+ * @returns the folded code, or `null` if nothing was folded
5004
+ */
5005
+ const foldBuildFlags = (code, fileName, flags) => {
5006
+ if (!BUILD_IMPORT_RE.test(code)) return null;
5007
+ const sourceFile = ts.createSourceFile(fileName, code, ts.ScriptTarget.Latest, true, getScriptKind(fileName));
5008
+ const buildSpecifiers = /* @__PURE__ */ new Set();
5009
+ for (const stmt of sourceFile.statements) if (ts.isImportDeclaration(stmt) && stmt.importClause?.phaseModifier !== ts.SyntaxKind.TypeKeyword && ts.isStringLiteral(stmt.moduleSpecifier) && STENCIL_CORE_IMPORT_RE.test(stmt.moduleSpecifier.text) && stmt.importClause?.namedBindings && ts.isNamedImports(stmt.importClause.namedBindings)) {
5010
+ for (const el of stmt.importClause.namedBindings.elements) if (!el.isTypeOnly && (el.propertyName ?? el.name).text === "Build") buildSpecifiers.add(el);
5011
+ }
5012
+ if (buildSpecifiers.size === 0) return null;
5013
+ const locals = new Set([...buildSpecifiers].map((el) => el.name.text));
5014
+ const unsafe = /* @__PURE__ */ new Set();
5015
+ const reads = [];
5016
+ const visit = (node) => {
5017
+ if (ts.isIdentifier(node) && locals.has(node.text)) {
5018
+ const parent = node.parent;
5019
+ if (isDeclarationName(node) && !buildSpecifiers.has(parent)) unsafe.add(node.text);
5020
+ else {
5021
+ const flag = getAccessedFlag(parent, node);
5022
+ if (flag !== void 0) {
5023
+ const access = parent;
5024
+ if (isWriteTarget(access)) unsafe.add(node.text);
5025
+ else {
5026
+ const value = flags[flag];
5027
+ if (typeof value === "boolean") reads.push({
5028
+ local: node.text,
5029
+ start: access.getStart(sourceFile),
5030
+ end: access.end,
5031
+ value
5032
+ });
5033
+ }
5034
+ }
5035
+ }
5036
+ }
5037
+ ts.forEachChild(node, visit);
5038
+ };
5039
+ visit(sourceFile);
5040
+ const toFold = reads.filter((r) => !unsafe.has(r.local));
5041
+ if (toFold.length === 0) return null;
5042
+ let out = code;
5043
+ for (const { start, end, value } of toFold.sort((a, b) => b.start - a.start)) {
5044
+ const original = code.slice(start, end);
5045
+ const nl = original.search(/[\r\n]/);
5046
+ const head = nl === -1 ? original : original.slice(0, nl);
5047
+ const tail = nl === -1 ? "" : original.slice(nl).replace(/[^\r\n]/g, " ");
5048
+ out = out.slice(0, start) + String(value).padEnd(head.length) + tail + out.slice(end);
5049
+ }
5050
+ return out;
5051
+ };
5052
+ const getScriptKind = (fileName) => {
5053
+ if (/\.tsx$/.test(fileName)) return ts.ScriptKind.TSX;
5054
+ if (/\.[mc]?ts$/.test(fileName)) return ts.ScriptKind.TS;
5055
+ if (/\.jsx$/.test(fileName)) return ts.ScriptKind.JSX;
5056
+ return ts.ScriptKind.JS;
5057
+ };
5058
+ const isDeclarationName = (node) => {
5059
+ const p = node.parent;
5060
+ return (ts.isVariableDeclaration(p) || ts.isParameter(p) || ts.isBindingElement(p) || ts.isFunctionDeclaration(p) || ts.isFunctionExpression(p) || ts.isClassDeclaration(p) || ts.isClassExpression(p) || ts.isEnumDeclaration(p) || ts.isModuleDeclaration(p) || ts.isImportEqualsDeclaration(p) || ts.isImportClause(p) || ts.isNamespaceImport(p) || ts.isImportSpecifier(p)) && p.name === node;
5061
+ };
5062
+ const getAccessedFlag = (parent, node) => {
5063
+ if (ts.isPropertyAccessExpression(parent) && parent.expression === node) return parent.name.text;
5064
+ if (ts.isElementAccessExpression(parent) && parent.expression === node && ts.isStringLiteralLike(parent.argumentExpression)) return parent.argumentExpression.text;
5065
+ };
5066
+ const isWriteTarget = (access) => {
5067
+ const p = access.parent;
5068
+ if (ts.isBinaryExpression(p)) return p.left === access && p.operatorToken.kind >= ts.SyntaxKind.FirstAssignment && p.operatorToken.kind <= ts.SyntaxKind.LastAssignment;
5069
+ if (ts.isPrefixUnaryExpression(p) || ts.isPostfixUnaryExpression(p)) return p.operator === ts.SyntaxKind.PlusPlusToken || p.operator === ts.SyntaxKind.MinusMinusToken;
5070
+ return ts.isDeleteExpression(p);
5071
+ };
5072
+ //#endregion
4958
5073
  //#region src/compiler/bundle/constants.ts
4959
5074
  const DEV_MODULE_DIR = `~dev-module`;
4960
5075
  //#endregion
@@ -6505,6 +6620,7 @@ const getRolldownOptions = (config, compilerCtx, buildCtx, bundleOpts) => {
6505
6620
  loaderPlugin(bundleOpts.loader),
6506
6621
  userIndexPlugin(config, compilerCtx),
6507
6622
  typescriptPlugin(compilerCtx, bundleOpts, config),
6623
+ buildFlagsPlugin(bundleOpts),
6508
6624
  extFormatPlugin(config),
6509
6625
  extTransformsPlugin(config, compilerCtx, buildCtx),
6510
6626
  workerPlugin(config, compilerCtx, buildCtx, bundleOpts.platform, !!bundleOpts.inlineWorkers),
@@ -7237,31 +7353,6 @@ const createIdentifierFromStyleIdentifier = (styleIdentifier, externalStyleIds)
7237
7353
  return ts.factory.createBinaryExpression(createIdentifierFromStyleIdentifier(styleIdentifier, [id]), ts.SyntaxKind.PlusToken, createIdentifierFromStyleIdentifier(styleIdentifier, externalStyleIds.slice(1)));
7238
7354
  };
7239
7355
  //#endregion
7240
- //#region src/compiler/transformers/host-data-transform.ts
7241
- const transformHostData = (classElements, moduleFile) => {
7242
- if (classElements.some((e) => ts.isMethodDeclaration(e) && e.name.escapedText === "hostData")) {
7243
- const renderIndex = classElements.findIndex((e) => ts.isMethodDeclaration(e) && e.name.escapedText === "render");
7244
- if (renderIndex >= 0) {
7245
- const renderMethod = classElements[renderIndex];
7246
- classElements[renderIndex] = ts.factory.updateMethodDeclaration(renderMethod, retrieveModifierLike(renderMethod), renderMethod.asteriskToken, ts.factory.createIdentifier(INTERNAL_RENDER), renderMethod.questionToken, renderMethod.typeParameters, renderMethod.parameters, renderMethod.type, renderMethod.body);
7247
- }
7248
- classElements.push(syntheticRender(moduleFile, renderIndex >= 0));
7249
- }
7250
- };
7251
- const syntheticRender = (moduleFile, hasRender) => {
7252
- addCoreRuntimeApi(moduleFile, RUNTIME_APIS.Host);
7253
- addCoreRuntimeApi(moduleFile, RUNTIME_APIS.h);
7254
- const hArguments = [ts.factory.createIdentifier(HOST), ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createThis(), "hostData"), void 0, void 0)];
7255
- if (hasRender) hArguments.push(ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createThis(), INTERNAL_RENDER), void 0, void 0));
7256
- /**
7257
- * render() {
7258
- * return h(arguments);
7259
- * }
7260
- */
7261
- return ts.factory.createMethodDeclaration(void 0, void 0, "render", void 0, void 0, [], void 0, ts.factory.createBlock([ts.factory.createReturnStatement(ts.factory.createCallExpression(ts.factory.createIdentifier(H), void 0, hArguments))]));
7262
- };
7263
- const INTERNAL_RENDER = "__stencil_render";
7264
- //#endregion
7265
7356
  //#region src/compiler/transformers/reactive-handler-meta-transform.ts
7266
7357
  /**
7267
7358
  * Add a getter to a class for a static representation of the watchers
@@ -7343,7 +7434,6 @@ const updateLazyComponentMembers = (transformOpts, styleStatements, classNode, m
7343
7434
  addReactivePropHandlers(classMembers, cmp, "watchers");
7344
7435
  addReactivePropHandlers(classMembers, cmp, "serializers");
7345
7436
  addReactivePropHandlers(classMembers, cmp, "deserializers");
7346
- transformHostData(classMembers, moduleFile);
7347
7437
  if (transformOpts.style === "static") addStaticStylePropertyToClass(styleStatements, cmp, buildCtx);
7348
7438
  return classMembers;
7349
7439
  };
@@ -11157,7 +11247,6 @@ const generateEventDetailTypes = (cmp) => {
11157
11247
  //#endregion
11158
11248
  //#region src/compiler/types/types-utils.ts
11159
11249
  const COMPONENTS_DTS_HEADER = `/* eslint-disable */
11160
- /* tslint:disable */
11161
11250
  /**
11162
11251
  * This is an autogenerated file created by the Stencil compiler.
11163
11252
  * It contains typing information for all components that exist in this project.
@@ -12135,7 +12224,6 @@ const getHydrateAttrsToReflect = (cmp) => {
12135
12224
  * - Updating the constructor to be lazy (only initialize when needed in the app factory)
12136
12225
  * - Adding a static getter for the lazy element (which is used in the app factory to determine which components are needed)
12137
12226
  * - Adding reactive property handlers for watchers, serializers, and deserializers (which are used in the app factory to set up reactive properties)
12138
- * - Transforming the `hostData` method to be compatible with SSR
12139
12227
  *
12140
12228
  * @param classNode the class declaration to transform
12141
12229
  * @param moduleFile the module file containing the class declaration
@@ -12154,7 +12242,6 @@ const updateSsrHostComponentMembers = (classNode, moduleFile, cmp, buildCtx) =>
12154
12242
  addReactivePropHandlers(classMembers, cmp, "serializers");
12155
12243
  addReactivePropHandlers(classMembers, cmp, "deserializers");
12156
12244
  addHydrateRuntimeCmpMeta(classMembers, cmp, buildCtx);
12157
- transformHostData(classMembers, moduleFile);
12158
12245
  return classMembers;
12159
12246
  };
12160
12247
  //#endregion
@@ -13514,7 +13601,6 @@ const updateNativeHostComponentMembers = (transformOpts, classNode, moduleFile,
13514
13601
  addReactivePropHandlers(classMembers, cmp, "deserializers");
13515
13602
  if (cmp.isPlain) addNativeComponentMeta(classMembers, cmp);
13516
13603
  if (transformOpts.style === "static") addNativeStaticStyle(classMembers, cmp, buildCtx);
13517
- transformHostData(classMembers, moduleFile);
13518
13604
  return classMembers;
13519
13605
  };
13520
13606
  //#endregion
@@ -17700,7 +17786,6 @@ function mergeExtendedClassMetaWithResolveImport(cmpNode, staticMembers, sourceF
17700
17786
  //#region src/compiler/transformers/static-to-meta/class-methods.ts
17701
17787
  const parseClassMethods = (classMethods, cmpMeta) => {
17702
17788
  if (!classMethods?.length) return;
17703
- const hasHostData = classMethods.includes("hostData");
17704
17789
  cmpMeta.hasAttributeChangedCallbackFn = classMethods.includes("attributeChangedCallback");
17705
17790
  cmpMeta.hasConnectedCallbackFn = classMethods.includes("connectedCallback");
17706
17791
  cmpMeta.hasDisconnectedCallbackFn = classMethods.includes("disconnectedCallback");
@@ -17712,8 +17797,7 @@ const parseClassMethods = (classMethods, cmpMeta) => {
17712
17797
  cmpMeta.hasComponentShouldUpdateFn = classMethods.includes("componentShouldUpdate");
17713
17798
  cmpMeta.hasComponentDidUpdateFn = classMethods.includes("componentDidUpdate");
17714
17799
  cmpMeta.hasLifecycle = cmpMeta.hasComponentWillLoadFn || cmpMeta.hasComponentDidLoadFn || cmpMeta.hasComponentWillUpdateFn || cmpMeta.hasComponentDidUpdateFn;
17715
- cmpMeta.hasRenderFn = classMethods.includes("render") || hasHostData;
17716
- cmpMeta.hasVdomRender = cmpMeta.hasVdomRender || hasHostData;
17800
+ cmpMeta.hasRenderFn = classMethods.includes("render");
17717
17801
  };
17718
17802
  //#endregion
17719
17803
  //#region src/compiler/transformers/static-to-meta/element-ref.ts
@@ -18949,13 +19033,13 @@ const getRelativeDts = (config, srcPath, emitDtsPath) => {
18949
19033
  const previousComponentStyles = /* @__PURE__ */ new Map();
18950
19034
  /**
18951
19035
  * Generate the Hot Module Replacement (HMR) data for the current build.
18952
- * @param config a user-supplied config
19036
+ * @param config the validated Stencil config
18953
19037
  * @param compilerCtx the compiler context
18954
19038
  * @param buildCtx the build context
18955
19039
  * @returns the HMR data
18956
19040
  */
18957
19041
  const generateHmr = (config, compilerCtx, buildCtx) => {
18958
- if (config.devServer?.reloadStrategy == null) return null;
19042
+ if (config.devServer.reloadStrategy == null) return null;
18959
19043
  const hmr = {
18960
19044
  reloadStrategy: config.devServer.reloadStrategy,
18961
19045
  versionId: Date.now().toString().substring(6) + "" + Math.round(Math.random() * 89999 + 1e4)
@@ -19051,7 +19135,7 @@ const addTsFileImporters = (allModuleFiles, filesToLookForImporters, checkedFile
19051
19135
  };
19052
19136
  const getExternalStylesUpdated = (config, buildCtx) => {
19053
19137
  if (!buildCtx.isRebuild) return null;
19054
- const globalStyleFileNames = /* @__PURE__ */ new Set([...config.fsNamespace ? [getStencilCssFileName(config.fsNamespace)] : [], ...config.outputTargets.filter(isOutputTargetGlobalStyle).map((o) => o.fileName)]);
19138
+ const globalStyleFileNames = /* @__PURE__ */ new Set([getStencilCssFileName(config.fsNamespace), ...config.outputTargets.filter(isOutputTargetGlobalStyle).map((o) => o.fileName)]);
19055
19139
  const cssFiles = buildCtx.filesWritten.filter((f) => f.endsWith(".css")).map((f) => basename$1(f)).filter((fileName) => !globalStyleFileNames.has(fileName));
19056
19140
  if (cssFiles.length === 0) return null;
19057
19141
  return cssFiles.sort();
@@ -19071,7 +19155,7 @@ const getImagesUpdated = (buildCtx, outputTargetsWww) => {
19071
19155
  /**
19072
19156
  * Determine a list of files (if any) which should be excluded from HMR updates.
19073
19157
  *
19074
- * @param config a user-supplied config
19158
+ * @param config the validated Stencil config
19075
19159
  * @param excludeHmr a list of glob patterns that should be used to determine
19076
19160
  * whether to exclude a file or not (a file will be excluded if it matches one
19077
19161
  * @param filesChanged an array of files which are changed in the HMR update
@@ -19429,7 +19513,7 @@ const cleanupUpdateMsg = (logger, msg, fileNames) => {
19429
19513
  */
19430
19514
  const cleanDiagnosticsRelativePath = (config, diagnostics) => {
19431
19515
  diagnostics.forEach((diagnostic) => {
19432
- if (!diagnostic.relFilePath && diagnostic.absFilePath && !isRemoteUrl(diagnostic.absFilePath) && config.rootDir) diagnostic.relFilePath = relative$1(config.rootDir, diagnostic.absFilePath);
19516
+ if (!diagnostic.relFilePath && diagnostic.absFilePath && !isRemoteUrl(diagnostic.absFilePath)) diagnostic.relFilePath = relative$1(config.rootDir, diagnostic.absFilePath);
19433
19517
  });
19434
19518
  };
19435
19519
  //#endregion
@@ -20891,7 +20975,7 @@ var Cache = class {
20891
20975
  return typeof await this.get(key) === "string";
20892
20976
  }
20893
20977
  async createKey(domain, ...args) {
20894
- if (!this.config.enableCache || !this.sys.generateContentHash) return domain + Math.random() * 9999999;
20978
+ if (!this.config.enableCache) return domain + Math.random() * 9999999;
20895
20979
  const hash = await this.sys.generateContentHash(JSON.stringify(args), 32);
20896
20980
  return domain + "_" + hash;
20897
20981
  }
@@ -20900,35 +20984,36 @@ var Cache = class {
20900
20984
  this.skip = false;
20901
20985
  this.failed = 0;
20902
20986
  await this.cacheFs.commit();
20903
- await this.clearExpiredCache();
20987
+ await this.pruneExpired();
20904
20988
  }
20905
20989
  }
20990
+ /**
20991
+ * Remove cache files last written over a week ago. Runs at most once a day,
20992
+ * throttled by the mtime of a marker file in the cache dir.
20993
+ */
20994
+ async pruneExpired() {
20995
+ if (!this.buildCacheDir) return;
20996
+ const now = Date.now();
20997
+ const markerPath = join$2(this.buildCacheDir, PRUNE_MARKER);
20998
+ const marker = await this.sys.stat(markerPath);
20999
+ if (marker.isFile && marker.mtimeMs && now - marker.mtimeMs < ONE_DAY) return;
21000
+ const filePaths = await this.sys.readDir(this.buildCacheDir);
21001
+ let removed = 0;
21002
+ await Promise.all(filePaths.map(async (filePath) => {
21003
+ if (basename$1(filePath).startsWith("_")) return;
21004
+ const { isFile, mtimeMs } = await this.sys.stat(filePath);
21005
+ if (isFile && mtimeMs && now - mtimeMs > ONE_WEEK) {
21006
+ await this.sys.removeFile(filePath);
21007
+ this.cacheFs.clearFileCache(filePath);
21008
+ removed++;
21009
+ }
21010
+ }));
21011
+ this.logger.debug(`cache prune: removed ${removed} of ${filePaths.length} files`);
21012
+ await this.sys.writeFile(markerPath, "");
21013
+ }
20906
21014
  clear() {
20907
21015
  if (this.cacheFs != null) this.cacheFs.clearCache();
20908
21016
  }
20909
- async clearExpiredCache() {
20910
- if (this.cacheFs == null || this.sys.cacheStorage == null) return;
20911
- const now = Date.now();
20912
- const lastClear = await this.sys.cacheStorage.get(EXP_STORAGE_KEY);
20913
- if (lastClear != null) {
20914
- if (now - lastClear < ONE_DAY) return;
20915
- const fs = this.cacheFs.sys;
20916
- const cachedFileNames = await fs.readDir(this.buildCacheDir);
20917
- const cachedFilePaths = cachedFileNames.map((f) => join$2(this.buildCacheDir, f));
20918
- let totalCleared = 0;
20919
- const promises = cachedFilePaths.map(async (filePath) => {
20920
- const lastModified = (await fs.stat(filePath)).mtimeMs;
20921
- if (lastModified && now - lastModified > ONE_WEEK) {
20922
- await fs.removeFile(filePath);
20923
- totalCleared++;
20924
- }
20925
- });
20926
- await Promise.all(promises);
20927
- this.logger.debug(`clearExpiredCache, cachedFileNames: ${cachedFileNames.length}, totalCleared: ${totalCleared}`);
20928
- }
20929
- this.logger.debug(`clearExpiredCache, set last clear`);
20930
- await this.sys.cacheStorage.set(EXP_STORAGE_KEY, now);
20931
- }
20932
21017
  async clearDiskCache() {
20933
21018
  if (this.cacheFs != null) {
20934
21019
  if (await this.cacheFs.access(this.buildCacheDir)) {
@@ -20948,7 +21033,7 @@ var Cache = class {
20948
21033
  const MAX_FAILED = 100;
20949
21034
  const ONE_DAY = 864e5;
20950
21035
  const ONE_WEEK = ONE_DAY * 7;
20951
- const EXP_STORAGE_KEY = `last_clear_expired_cache`;
21036
+ const PRUNE_MARKER = "_last_prune.log";
20952
21037
  const CACHE_DIR_README = `# Stencil Cache Directory
20953
21038
 
20954
21039
  This directory contains files which the compiler has
@@ -25967,15 +26052,6 @@ const createSystem = (c) => {
25967
26052
  }
25968
26053
  return results;
25969
26054
  };
25970
- /**
25971
- * `self` is the global namespace object used within a web worker.
25972
- * `window` is the browser's global namespace object (I reorganized this to check the reference on that second)
25973
- * `global` is Node's global namespace object. https://nodejs.org/api/globals.html#globals_global
25974
- *
25975
- * loading in this order should allow workers, which are most common, then browser,
25976
- * then Node to grab the reference to fetch correctly.
25977
- */
25978
- const fetch = typeof self !== "undefined" ? self?.fetch : typeof window !== "undefined" ? window?.fetch : typeof global !== "undefined" ? global?.fetch : void 0;
25979
26055
  const writeFile = async (p, data) => writeFileSync(p, data);
25980
26056
  const tmpDirSync = () => "/.tmp";
25981
26057
  const tick = Promise.resolve();
@@ -25986,6 +26062,7 @@ const createSystem = (c) => {
25986
26062
  if (typeof hashLength === "number") hashHex = hashHex.slice(0, hashLength);
25987
26063
  return hashHex;
25988
26064
  };
26065
+ const generateFileHash = async (filePath, hashLength) => generateContentHash(readFileSync(filePath), hashLength);
25989
26066
  const copy = async (copyTasks, srcDir) => {
25990
26067
  const results = {
25991
26068
  diagnostics: [],
@@ -25995,9 +26072,6 @@ const createSystem = (c) => {
25995
26072
  logger.info("todo, copy task", copyTasks.length, srcDir);
25996
26073
  return results;
25997
26074
  };
25998
- const getEnvironmentVar = (key) => {
25999
- return process$1?.env[key];
26000
- };
26001
26075
  const getLocalModulePath = (opts) => join$2(opts.rootDir, "node_modules", opts.moduleId, opts.path);
26002
26076
  const getRemoteModuleUrl = (opts) => {
26003
26077
  const npmBaseUrl = "https://cdn.jsdelivr.net/npm/";
@@ -26013,13 +26087,14 @@ const createSystem = (c) => {
26013
26087
  access,
26014
26088
  accessSync,
26015
26089
  addDestroy,
26090
+ checkVersion: async () => noop,
26016
26091
  copyFile,
26017
26092
  createDir,
26018
26093
  createDirSync,
26019
26094
  homeDir,
26020
26095
  isTTY,
26021
- getEnvironmentVar,
26022
26096
  destroy,
26097
+ dynamicImport: (p) => import(p),
26023
26098
  encodeToBase64,
26024
26099
  exit: async (exitCode) => logger.warn(`exit ${exitCode}`),
26025
26100
  getCurrentDirectory,
@@ -26030,6 +26105,7 @@ const createSystem = (c) => {
26030
26105
  isSymbolicLink,
26031
26106
  nextTick,
26032
26107
  normalizePath: normalize,
26108
+ onProcessInterrupt: noop,
26033
26109
  platformPath: path,
26034
26110
  readDir,
26035
26111
  readDirSync,
@@ -26039,7 +26115,6 @@ const createSystem = (c) => {
26039
26115
  realpathSync,
26040
26116
  removeDestroy,
26041
26117
  rename,
26042
- fetch,
26043
26118
  resolvePath,
26044
26119
  removeDir,
26045
26120
  removeDirSync,
@@ -26054,6 +26129,7 @@ const createSystem = (c) => {
26054
26129
  writeFile,
26055
26130
  writeFileSync,
26056
26131
  generateContentHash,
26132
+ generateFileHash,
26057
26133
  createWorkerController: null,
26058
26134
  details: {
26059
26135
  cpuModel: "",
@@ -26253,6 +26329,7 @@ const transpileModule = (config, input, transformOpts) => {
26253
26329
  ...config,
26254
26330
  logger: createNodeLogger()
26255
26331
  };
26332
+ resetDeprecatedApiWarning();
26256
26333
  const compilerCtx = new CompilerContext();
26257
26334
  const buildCtx = new BuildContext(config, compilerCtx);
26258
26335
  const tsCompilerOptions = { ...config.tsCompilerOptions };
@@ -26456,4 +26533,4 @@ const shouldTranspileModule = (ext) => [
26456
26533
  "js"
26457
26534
  ].includes(ext);
26458
26535
  //#endregion
26459
- export { versions as A, replaceStencilCssComponentsImport as C, buildId as D, parseCssOnlyComponents as E, vermoji as O, hasStencilHydrateImport as S, replaceStencilHydrateImport as T, cmpMetaToDocsComponent as _, createPrerenderer as a, hasStencilCssComponentsImport as b, createWorkerContext as c, nodeRequire as d, optimizeCss as f, generateManifest as g, generateComponentTypesFile as h, createSystem as i, scopeCss as j, version as k, createWorkerMessageHandler as l, validateHydrated as m, transpile as n, loadConfig as o, validateConfig as p, transpileSync as r, createCompiler as s, ts$1 as t, optimizeJs as u, getScopeId as v, replaceStencilGlobalsImport as w, hasStencilGlobalsImport as x, buildHydrateCss as y };
26536
+ export { version as A, hasStencilHydrateImport as C, parseCssOnlyComponents as D, replaceStencilHydrateImport as E, scopeCss as M, buildId as O, hasStencilGlobalsImport as S, replaceStencilGlobalsImport as T, cmpMetaToDocsComponent as _, createPrerenderer as a, buildHydrateCss as b, createWorkerContext as c, nodeRequire as d, optimizeCss as f, generateManifest as g, generateComponentTypesFile as h, createSystem as i, versions as j, vermoji as k, createWorkerMessageHandler as l, validateHydrated as m, transpile as n, loadConfig as o, validateConfig as p, transpileSync as r, createCompiler as s, ts$1 as t, optimizeJs as u, getScopeId as v, replaceStencilCssComponentsImport as w, hasStencilCssComponentsImport as x, foldBuildFlags as y };