@stencil/core 5.0.0-beta.14 → 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-CAQvc3hT.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
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-Bw9pHJOq.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";
@@ -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.14";
466
- const buildId = "1790782456";
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}`,
@@ -4498,7 +4494,7 @@ const appDataPlugin = (config, compilerCtx, buildCtx, buildConditionals, platfor
4498
4494
  name: "appDataPlugin",
4499
4495
  resolveId: {
4500
4496
  filter: { id: /^@stencil\/core\/app-(data|globals)$/ },
4501
- handler(id, importer) {
4497
+ handler(id) {
4502
4498
  if (id === "@stencil/core/app-data" || id === "@stencil/core/app-globals") {
4503
4499
  if (platform === "worker") this.error("@stencil/core packages cannot be imported from a worker.");
4504
4500
  return id;
@@ -4687,19 +4683,6 @@ const appendNamespace = (config, s) => {
4687
4683
  };
4688
4684
  //#endregion
4689
4685
  //#region src/compiler/sys/fetch/fetch-utils.ts
4690
- /**
4691
- * A fetch wrapper which dispatches to `sys.fetch` if present, and otherwise
4692
- * uses `global.fetch`.
4693
- *
4694
- * @param sys a compiler system object
4695
- * @param input a `RequestInfo` object
4696
- * @param init an optional `RequestInit` object
4697
- * @returns a Promise wrapping a response
4698
- */
4699
- const httpFetch = (sys, input, init) => {
4700
- if (sys && isFunction(sys.fetch)) return sys.fetch(input, init);
4701
- return fetch(input, init);
4702
- };
4703
4686
  const packageVersions = /* @__PURE__ */ new Map();
4704
4687
  const known404Urls = /* @__PURE__ */ new Set();
4705
4688
  /**
@@ -4770,7 +4753,7 @@ const writeFetchSuccessAsync = async (sys, inMemoryFs, url, filePath, content, p
4770
4753
  const fetchModuleAsync = async (sys, inMemoryFs, pkgVersions, url, filePath) => {
4771
4754
  if (skipFilePathFetch(filePath) || known404Urls.has(url) || skipUrlFetch(url)) return;
4772
4755
  try {
4773
- const rsp = await httpFetch(sys, url);
4756
+ const rsp = await fetch(url);
4774
4757
  if (rsp) {
4775
4758
  if (rsp.ok) {
4776
4759
  const content = await rsp.clone().text();
@@ -4837,13 +4820,11 @@ const coreResolvePlugin = (config, compilerCtx, platform, externalRuntime, lazyL
4837
4820
  if (filePath && !filePath.startsWith("\0")) {
4838
4821
  filePath = normalizeFsPath(filePath);
4839
4822
  if (filePath === internalClient || filePath === internalSsr) {
4840
- if (platform === "worker") return `
4841
- export const Build = {
4842
- isDev: ${config.devMode},
4843
- isBrowser: true,
4844
- isServer: false,
4845
- isTesting: false,
4846
- };`;
4823
+ if (platform === "worker") return `export const Build = ${JSON.stringify({
4824
+ ...CLIENT_BUILD_FLAGS,
4825
+ isDev: config.devMode,
4826
+ isTesting: false
4827
+ })};`;
4847
4828
  const cached = transformedCodeCache.get(filePath);
4848
4829
  if (cached) return cached;
4849
4830
  let code = await compilerCtx.fs.readFile(filePath);
@@ -4956,6 +4937,139 @@ const buildConditionalsPlugin = (config, buildConditionals) => {
4956
4937
  };
4957
4938
  };
4958
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
4959
5073
  //#region src/compiler/bundle/constants.ts
4960
5074
  const DEV_MODULE_DIR = `~dev-module`;
4961
5075
  //#endregion
@@ -6506,6 +6620,7 @@ const getRolldownOptions = (config, compilerCtx, buildCtx, bundleOpts) => {
6506
6620
  loaderPlugin(bundleOpts.loader),
6507
6621
  userIndexPlugin(config, compilerCtx),
6508
6622
  typescriptPlugin(compilerCtx, bundleOpts, config),
6623
+ buildFlagsPlugin(bundleOpts),
6509
6624
  extFormatPlugin(config),
6510
6625
  extTransformsPlugin(config, compilerCtx, buildCtx),
6511
6626
  workerPlugin(config, compilerCtx, buildCtx, bundleOpts.platform, !!bundleOpts.inlineWorkers),
@@ -7238,31 +7353,6 @@ const createIdentifierFromStyleIdentifier = (styleIdentifier, externalStyleIds)
7238
7353
  return ts.factory.createBinaryExpression(createIdentifierFromStyleIdentifier(styleIdentifier, [id]), ts.SyntaxKind.PlusToken, createIdentifierFromStyleIdentifier(styleIdentifier, externalStyleIds.slice(1)));
7239
7354
  };
7240
7355
  //#endregion
7241
- //#region src/compiler/transformers/host-data-transform.ts
7242
- const transformHostData = (classElements, moduleFile) => {
7243
- if (classElements.some((e) => ts.isMethodDeclaration(e) && e.name.escapedText === "hostData")) {
7244
- const renderIndex = classElements.findIndex((e) => ts.isMethodDeclaration(e) && e.name.escapedText === "render");
7245
- if (renderIndex >= 0) {
7246
- const renderMethod = classElements[renderIndex];
7247
- 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);
7248
- }
7249
- classElements.push(syntheticRender(moduleFile, renderIndex >= 0));
7250
- }
7251
- };
7252
- const syntheticRender = (moduleFile, hasRender) => {
7253
- addCoreRuntimeApi(moduleFile, RUNTIME_APIS.Host);
7254
- addCoreRuntimeApi(moduleFile, RUNTIME_APIS.h);
7255
- const hArguments = [ts.factory.createIdentifier(HOST), ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createThis(), "hostData"), void 0, void 0)];
7256
- if (hasRender) hArguments.push(ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createThis(), INTERNAL_RENDER), void 0, void 0));
7257
- /**
7258
- * render() {
7259
- * return h(arguments);
7260
- * }
7261
- */
7262
- 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))]));
7263
- };
7264
- const INTERNAL_RENDER = "__stencil_render";
7265
- //#endregion
7266
7356
  //#region src/compiler/transformers/reactive-handler-meta-transform.ts
7267
7357
  /**
7268
7358
  * Add a getter to a class for a static representation of the watchers
@@ -7344,7 +7434,6 @@ const updateLazyComponentMembers = (transformOpts, styleStatements, classNode, m
7344
7434
  addReactivePropHandlers(classMembers, cmp, "watchers");
7345
7435
  addReactivePropHandlers(classMembers, cmp, "serializers");
7346
7436
  addReactivePropHandlers(classMembers, cmp, "deserializers");
7347
- transformHostData(classMembers, moduleFile);
7348
7437
  if (transformOpts.style === "static") addStaticStylePropertyToClass(styleStatements, cmp, buildCtx);
7349
7438
  return classMembers;
7350
7439
  };
@@ -11158,7 +11247,6 @@ const generateEventDetailTypes = (cmp) => {
11158
11247
  //#endregion
11159
11248
  //#region src/compiler/types/types-utils.ts
11160
11249
  const COMPONENTS_DTS_HEADER = `/* eslint-disable */
11161
- /* tslint:disable */
11162
11250
  /**
11163
11251
  * This is an autogenerated file created by the Stencil compiler.
11164
11252
  * It contains typing information for all components that exist in this project.
@@ -12136,7 +12224,6 @@ const getHydrateAttrsToReflect = (cmp) => {
12136
12224
  * - Updating the constructor to be lazy (only initialize when needed in the app factory)
12137
12225
  * - Adding a static getter for the lazy element (which is used in the app factory to determine which components are needed)
12138
12226
  * - Adding reactive property handlers for watchers, serializers, and deserializers (which are used in the app factory to set up reactive properties)
12139
- * - Transforming the `hostData` method to be compatible with SSR
12140
12227
  *
12141
12228
  * @param classNode the class declaration to transform
12142
12229
  * @param moduleFile the module file containing the class declaration
@@ -12155,7 +12242,6 @@ const updateSsrHostComponentMembers = (classNode, moduleFile, cmp, buildCtx) =>
12155
12242
  addReactivePropHandlers(classMembers, cmp, "serializers");
12156
12243
  addReactivePropHandlers(classMembers, cmp, "deserializers");
12157
12244
  addHydrateRuntimeCmpMeta(classMembers, cmp, buildCtx);
12158
- transformHostData(classMembers, moduleFile);
12159
12245
  return classMembers;
12160
12246
  };
12161
12247
  //#endregion
@@ -13515,7 +13601,6 @@ const updateNativeHostComponentMembers = (transformOpts, classNode, moduleFile,
13515
13601
  addReactivePropHandlers(classMembers, cmp, "deserializers");
13516
13602
  if (cmp.isPlain) addNativeComponentMeta(classMembers, cmp);
13517
13603
  if (transformOpts.style === "static") addNativeStaticStyle(classMembers, cmp, buildCtx);
13518
- transformHostData(classMembers, moduleFile);
13519
13604
  return classMembers;
13520
13605
  };
13521
13606
  //#endregion
@@ -17701,7 +17786,6 @@ function mergeExtendedClassMetaWithResolveImport(cmpNode, staticMembers, sourceF
17701
17786
  //#region src/compiler/transformers/static-to-meta/class-methods.ts
17702
17787
  const parseClassMethods = (classMethods, cmpMeta) => {
17703
17788
  if (!classMethods?.length) return;
17704
- const hasHostData = classMethods.includes("hostData");
17705
17789
  cmpMeta.hasAttributeChangedCallbackFn = classMethods.includes("attributeChangedCallback");
17706
17790
  cmpMeta.hasConnectedCallbackFn = classMethods.includes("connectedCallback");
17707
17791
  cmpMeta.hasDisconnectedCallbackFn = classMethods.includes("disconnectedCallback");
@@ -17713,8 +17797,7 @@ const parseClassMethods = (classMethods, cmpMeta) => {
17713
17797
  cmpMeta.hasComponentShouldUpdateFn = classMethods.includes("componentShouldUpdate");
17714
17798
  cmpMeta.hasComponentDidUpdateFn = classMethods.includes("componentDidUpdate");
17715
17799
  cmpMeta.hasLifecycle = cmpMeta.hasComponentWillLoadFn || cmpMeta.hasComponentDidLoadFn || cmpMeta.hasComponentWillUpdateFn || cmpMeta.hasComponentDidUpdateFn;
17716
- cmpMeta.hasRenderFn = classMethods.includes("render") || hasHostData;
17717
- cmpMeta.hasVdomRender = cmpMeta.hasVdomRender || hasHostData;
17800
+ cmpMeta.hasRenderFn = classMethods.includes("render");
17718
17801
  };
17719
17802
  //#endregion
17720
17803
  //#region src/compiler/transformers/static-to-meta/element-ref.ts
@@ -18950,13 +19033,13 @@ const getRelativeDts = (config, srcPath, emitDtsPath) => {
18950
19033
  const previousComponentStyles = /* @__PURE__ */ new Map();
18951
19034
  /**
18952
19035
  * Generate the Hot Module Replacement (HMR) data for the current build.
18953
- * @param config a user-supplied config
19036
+ * @param config the validated Stencil config
18954
19037
  * @param compilerCtx the compiler context
18955
19038
  * @param buildCtx the build context
18956
19039
  * @returns the HMR data
18957
19040
  */
18958
19041
  const generateHmr = (config, compilerCtx, buildCtx) => {
18959
- if (config.devServer?.reloadStrategy == null) return null;
19042
+ if (config.devServer.reloadStrategy == null) return null;
18960
19043
  const hmr = {
18961
19044
  reloadStrategy: config.devServer.reloadStrategy,
18962
19045
  versionId: Date.now().toString().substring(6) + "" + Math.round(Math.random() * 89999 + 1e4)
@@ -19052,7 +19135,7 @@ const addTsFileImporters = (allModuleFiles, filesToLookForImporters, checkedFile
19052
19135
  };
19053
19136
  const getExternalStylesUpdated = (config, buildCtx) => {
19054
19137
  if (!buildCtx.isRebuild) return null;
19055
- 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)]);
19056
19139
  const cssFiles = buildCtx.filesWritten.filter((f) => f.endsWith(".css")).map((f) => basename$1(f)).filter((fileName) => !globalStyleFileNames.has(fileName));
19057
19140
  if (cssFiles.length === 0) return null;
19058
19141
  return cssFiles.sort();
@@ -19072,7 +19155,7 @@ const getImagesUpdated = (buildCtx, outputTargetsWww) => {
19072
19155
  /**
19073
19156
  * Determine a list of files (if any) which should be excluded from HMR updates.
19074
19157
  *
19075
- * @param config a user-supplied config
19158
+ * @param config the validated Stencil config
19076
19159
  * @param excludeHmr a list of glob patterns that should be used to determine
19077
19160
  * whether to exclude a file or not (a file will be excluded if it matches one
19078
19161
  * @param filesChanged an array of files which are changed in the HMR update
@@ -19430,7 +19513,7 @@ const cleanupUpdateMsg = (logger, msg, fileNames) => {
19430
19513
  */
19431
19514
  const cleanDiagnosticsRelativePath = (config, diagnostics) => {
19432
19515
  diagnostics.forEach((diagnostic) => {
19433
- 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);
19434
19517
  });
19435
19518
  };
19436
19519
  //#endregion
@@ -20892,7 +20975,7 @@ var Cache = class {
20892
20975
  return typeof await this.get(key) === "string";
20893
20976
  }
20894
20977
  async createKey(domain, ...args) {
20895
- if (!this.config.enableCache || !this.sys.generateContentHash) return domain + Math.random() * 9999999;
20978
+ if (!this.config.enableCache) return domain + Math.random() * 9999999;
20896
20979
  const hash = await this.sys.generateContentHash(JSON.stringify(args), 32);
20897
20980
  return domain + "_" + hash;
20898
20981
  }
@@ -20901,35 +20984,36 @@ var Cache = class {
20901
20984
  this.skip = false;
20902
20985
  this.failed = 0;
20903
20986
  await this.cacheFs.commit();
20904
- await this.clearExpiredCache();
20987
+ await this.pruneExpired();
20905
20988
  }
20906
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
+ }
20907
21014
  clear() {
20908
21015
  if (this.cacheFs != null) this.cacheFs.clearCache();
20909
21016
  }
20910
- async clearExpiredCache() {
20911
- if (this.cacheFs == null || this.sys.cacheStorage == null) return;
20912
- const now = Date.now();
20913
- const lastClear = await this.sys.cacheStorage.get(EXP_STORAGE_KEY);
20914
- if (lastClear != null) {
20915
- if (now - lastClear < ONE_DAY) return;
20916
- const fs = this.cacheFs.sys;
20917
- const cachedFileNames = await fs.readDir(this.buildCacheDir);
20918
- const cachedFilePaths = cachedFileNames.map((f) => join$2(this.buildCacheDir, f));
20919
- let totalCleared = 0;
20920
- const promises = cachedFilePaths.map(async (filePath) => {
20921
- const lastModified = (await fs.stat(filePath)).mtimeMs;
20922
- if (lastModified && now - lastModified > ONE_WEEK) {
20923
- await fs.removeFile(filePath);
20924
- totalCleared++;
20925
- }
20926
- });
20927
- await Promise.all(promises);
20928
- this.logger.debug(`clearExpiredCache, cachedFileNames: ${cachedFileNames.length}, totalCleared: ${totalCleared}`);
20929
- }
20930
- this.logger.debug(`clearExpiredCache, set last clear`);
20931
- await this.sys.cacheStorage.set(EXP_STORAGE_KEY, now);
20932
- }
20933
21017
  async clearDiskCache() {
20934
21018
  if (this.cacheFs != null) {
20935
21019
  if (await this.cacheFs.access(this.buildCacheDir)) {
@@ -20949,7 +21033,7 @@ var Cache = class {
20949
21033
  const MAX_FAILED = 100;
20950
21034
  const ONE_DAY = 864e5;
20951
21035
  const ONE_WEEK = ONE_DAY * 7;
20952
- const EXP_STORAGE_KEY = `last_clear_expired_cache`;
21036
+ const PRUNE_MARKER = "_last_prune.log";
20953
21037
  const CACHE_DIR_README = `# Stencil Cache Directory
20954
21038
 
20955
21039
  This directory contains files which the compiler has
@@ -25968,15 +26052,6 @@ const createSystem = (c) => {
25968
26052
  }
25969
26053
  return results;
25970
26054
  };
25971
- /**
25972
- * `self` is the global namespace object used within a web worker.
25973
- * `window` is the browser's global namespace object (I reorganized this to check the reference on that second)
25974
- * `global` is Node's global namespace object. https://nodejs.org/api/globals.html#globals_global
25975
- *
25976
- * loading in this order should allow workers, which are most common, then browser,
25977
- * then Node to grab the reference to fetch correctly.
25978
- */
25979
- const fetch = typeof self !== "undefined" ? self?.fetch : typeof window !== "undefined" ? window?.fetch : typeof global !== "undefined" ? global?.fetch : void 0;
25980
26055
  const writeFile = async (p, data) => writeFileSync(p, data);
25981
26056
  const tmpDirSync = () => "/.tmp";
25982
26057
  const tick = Promise.resolve();
@@ -25987,6 +26062,7 @@ const createSystem = (c) => {
25987
26062
  if (typeof hashLength === "number") hashHex = hashHex.slice(0, hashLength);
25988
26063
  return hashHex;
25989
26064
  };
26065
+ const generateFileHash = async (filePath, hashLength) => generateContentHash(readFileSync(filePath), hashLength);
25990
26066
  const copy = async (copyTasks, srcDir) => {
25991
26067
  const results = {
25992
26068
  diagnostics: [],
@@ -25996,9 +26072,6 @@ const createSystem = (c) => {
25996
26072
  logger.info("todo, copy task", copyTasks.length, srcDir);
25997
26073
  return results;
25998
26074
  };
25999
- const getEnvironmentVar = (key) => {
26000
- return process$1?.env[key];
26001
- };
26002
26075
  const getLocalModulePath = (opts) => join$2(opts.rootDir, "node_modules", opts.moduleId, opts.path);
26003
26076
  const getRemoteModuleUrl = (opts) => {
26004
26077
  const npmBaseUrl = "https://cdn.jsdelivr.net/npm/";
@@ -26014,13 +26087,14 @@ const createSystem = (c) => {
26014
26087
  access,
26015
26088
  accessSync,
26016
26089
  addDestroy,
26090
+ checkVersion: async () => noop,
26017
26091
  copyFile,
26018
26092
  createDir,
26019
26093
  createDirSync,
26020
26094
  homeDir,
26021
26095
  isTTY,
26022
- getEnvironmentVar,
26023
26096
  destroy,
26097
+ dynamicImport: (p) => import(p),
26024
26098
  encodeToBase64,
26025
26099
  exit: async (exitCode) => logger.warn(`exit ${exitCode}`),
26026
26100
  getCurrentDirectory,
@@ -26031,6 +26105,7 @@ const createSystem = (c) => {
26031
26105
  isSymbolicLink,
26032
26106
  nextTick,
26033
26107
  normalizePath: normalize,
26108
+ onProcessInterrupt: noop,
26034
26109
  platformPath: path,
26035
26110
  readDir,
26036
26111
  readDirSync,
@@ -26040,7 +26115,6 @@ const createSystem = (c) => {
26040
26115
  realpathSync,
26041
26116
  removeDestroy,
26042
26117
  rename,
26043
- fetch,
26044
26118
  resolvePath,
26045
26119
  removeDir,
26046
26120
  removeDirSync,
@@ -26055,6 +26129,7 @@ const createSystem = (c) => {
26055
26129
  writeFile,
26056
26130
  writeFileSync,
26057
26131
  generateContentHash,
26132
+ generateFileHash,
26058
26133
  createWorkerController: null,
26059
26134
  details: {
26060
26135
  cpuModel: "",
@@ -26254,6 +26329,7 @@ const transpileModule = (config, input, transformOpts) => {
26254
26329
  ...config,
26255
26330
  logger: createNodeLogger()
26256
26331
  };
26332
+ resetDeprecatedApiWarning();
26257
26333
  const compilerCtx = new CompilerContext();
26258
26334
  const buildCtx = new BuildContext(config, compilerCtx);
26259
26335
  const tsCompilerOptions = { ...config.tsCompilerOptions };
@@ -26457,4 +26533,4 @@ const shouldTranspileModule = (ext) => [
26457
26533
  "js"
26458
26534
  ].includes(ext);
26459
26535
  //#endregion
26460
- 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 };