@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.
@@ -104,41 +104,6 @@ const BUILD = {
104
104
  asyncQueue: false
105
105
  };
106
106
  //#endregion
107
- //#region src/client/client-build.ts
108
- const Build = {
109
- isDev: BUILD.isDev,
110
- isBrowser: true,
111
- isServer: false,
112
- isTesting: BUILD.isTesting
113
- };
114
- //#endregion
115
- //#region src/client/client-host-ref.ts
116
- /**
117
- * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
118
- *
119
- * @param ref the runtime ref of interest
120
- * @returns the Host reference (if found) or undefined
121
- */
122
- const getHostRef = (ref) => {
123
- if (ref.__s_ghr) return ref.__s_ghr();
124
- };
125
- const isMemberInElement = (elm, memberName) => memberName in elm;
126
- //#endregion
127
- //#region src/client/client-log.ts
128
- let customError;
129
- const consoleError = (e, el) => (customError || console.error)(e, el);
130
- const STENCIL_DEV_MODE = BUILD.isTesting ? ["STENCIL:"] : ["%cstencil", "color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"];
131
- const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
132
- const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
133
- const setErrorHandler = (handler) => customError = handler;
134
- //#endregion
135
- //#region src/client/client-load-module.ts
136
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
137
- //#endregion
138
- //#region src/client/client-style.ts
139
- const styles = /*@__PURE__*/ new Map();
140
- const modeResolver = [];
141
- //#endregion
142
107
  //#region src/runtime/runtime-constants.ts
143
108
  /**
144
109
  * Bit flags for recording various properties of VDom nodes
@@ -191,6 +156,54 @@ const HYDRATED_CSS = "{visibility:hidden}.hydrated{visibility:inherit}";
191
156
  */
192
157
  const SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
193
158
  const XLINK_NS = "http://www.w3.org/1999/xlink";
159
+ /**
160
+ * `Build` values fixed per platform. Shared by each runtime's `Build` export and the compiler's
161
+ * `Build.*` folding (`compiler/bundle/build-flags-plugin.ts`), so the two can't disagree.
162
+ */
163
+ const CLIENT_BUILD_FLAGS = {
164
+ isBrowser: true,
165
+ isServer: false
166
+ };
167
+ const SERVER_BUILD_FLAGS = {
168
+ isBrowser: false,
169
+ isServer: true,
170
+ isDev: false,
171
+ isTesting: false
172
+ };
173
+ //#endregion
174
+ //#region src/client/client-build.ts
175
+ const Build = {
176
+ ...CLIENT_BUILD_FLAGS,
177
+ isDev: BUILD.isDev,
178
+ isTesting: BUILD.isTesting
179
+ };
180
+ //#endregion
181
+ //#region src/client/client-host-ref.ts
182
+ /**
183
+ * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
184
+ *
185
+ * @param ref the runtime ref of interest
186
+ * @returns the Host reference (if found) or undefined
187
+ */
188
+ const getHostRef = (ref) => {
189
+ if (ref.__s_ghr) return ref.__s_ghr();
190
+ };
191
+ const isMemberInElement = (elm, memberName) => memberName in elm;
192
+ //#endregion
193
+ //#region src/client/client-log.ts
194
+ let customError;
195
+ const consoleError = (e, el) => (customError || console.error)(e, el);
196
+ const STENCIL_DEV_MODE = BUILD.isTesting ? ["STENCIL:"] : ["%cstencil", "color: white;background:#4c47ff;font-weight: bold; font-size:10px; padding:2px 6px; border-radius: 5px"];
197
+ const consoleDevError = (...m) => console.error(...STENCIL_DEV_MODE, ...m);
198
+ const consoleDevWarn = (...m) => console.warn(...STENCIL_DEV_MODE, ...m);
199
+ const setErrorHandler = (handler) => customError = handler;
200
+ //#endregion
201
+ //#region src/client/client-load-module.ts
202
+ /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
203
+ //#endregion
204
+ //#region src/client/client-style.ts
205
+ const styles = /*@__PURE__*/ new Map();
206
+ const modeResolver = [];
194
207
  //#endregion
195
208
  //#region src/client/client-window.ts
196
209
  const win = typeof window !== "undefined" ? window : {};
@@ -2122,9 +2135,7 @@ const h = (nodeName, vnodeData, ...children) => {
2122
2135
  if (classData && !(BUILD.vdomSignals && isSignalLike(classData))) vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
2123
2136
  }
2124
2137
  }
2125
- if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be the single root component. Make sure:
2126
- - You are NOT using hostData() and <Host> in the same component.
2127
- - <Host> is used once, and it's the single root component of the render() function.`);
2138
+ if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be used once, and be the single root component of the render() function.`);
2128
2139
  if (BUILD.vdomFunctional && typeof nodeName === "function") return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
2129
2140
  const vnode = newVNode(nodeName, null);
2130
2141
  vnode.$attrs$ = vnodeData;
@@ -2393,4 +2404,4 @@ function hasKeys(obj) {
2393
2404
  return false;
2394
2405
  }
2395
2406
  //#endregion
2396
- export { setErrorHandler as C, HYDRATED_CSS as S, getAssetPath as _, transformTag as a, writeTask as b, Mixin as c, Host as d, h as f, getShadowRoot as g, getElement as h, setTagTransformer as i, getMode as l, getRenderingRef as m, jsxDEV as n, render as o, forceUpdate as p, jsxs as r, ReactiveControllerHost as s, jsx as t, setMode as u, setAssetPath as v, Build as w, setPlatformHelpers as x, readTask as y };
2407
+ export { Build as C, SERVER_BUILD_FLAGS as E, setErrorHandler as S, HYDRATED_CSS as T, getAssetPath as _, transformTag as a, writeTask as b, Mixin as c, Host as d, h as f, getShadowRoot as g, getElement as h, setTagTransformer as i, getMode as l, getRenderingRef as m, jsxDEV as n, render as o, forceUpdate as p, jsxs as r, ReactiveControllerHost as s, jsx as t, setMode as u, setAssetPath as v, CLIENT_BUILD_FLAGS as w, setPlatformHelpers as x, readTask as y };
@@ -91,7 +91,7 @@ interface CompilerSystem {
91
91
  name: 'node' | 'in-memory';
92
92
  version: string;
93
93
  events?: BuildEvents;
94
- details?: SystemDetails;
94
+ details: SystemDetails;
95
95
  /**
96
96
  * Add a callback which will be ran when destroy() is called.
97
97
  */
@@ -104,14 +104,15 @@ interface CompilerSystem {
104
104
  * SYNC! Always returns a boolean, does not throw.
105
105
  */
106
106
  accessSync(p: string): boolean;
107
- applyGlobalPatch?(fromDir: string): Promise<void>;
108
107
  applyPrerenderGlobalPatch?(opts: {
109
108
  devServerHostUrl: string;
110
109
  window: any;
111
110
  }): void;
112
- cacheStorage?: CacheStorage;
113
- checkVersion?: (logger: Logger, currentVersion: string) => Promise<() => void>;
114
- copy?(copyTasks: Required<CopyTask>[], srcDir: string): Promise<CopyResults>;
111
+ /**
112
+ * Check npm for a newer Stencil version. Resolves a function that logs the result.
113
+ */
114
+ checkVersion(logger: Logger, currentVersion: string): Promise<() => void>;
115
+ copy(copyTasks: Required<CopyTask>[], srcDir: string): Promise<CopyResults>;
115
116
  /**
116
117
  * Always returns a boolean if the files were copied or not. Does not throw.
117
118
  */
@@ -136,7 +137,7 @@ interface CompilerSystem {
136
137
  /**
137
138
  * Each platform has a different way to dynamically import modules.
138
139
  */
139
- dynamicImport?(p: string): Promise<any>;
140
+ dynamicImport(p: string): Promise<any>;
140
141
  /**
141
142
  * Creates the worker controller for the current system.
142
143
  *
@@ -150,20 +151,14 @@ interface CompilerSystem {
150
151
  * process.exit()
151
152
  */
152
153
  exit(exitCode: number): Promise<void>;
153
- /**
154
- * Optionally provide a fetch() function rather than using the built-in fetch().
155
- * First arg is a url string or Request object (RequestInfo).
156
- * Second arg is the RequestInit. Returns the Response object
157
- */
158
- fetch?(input: string | any, init?: any): Promise<any>;
159
154
  /**
160
155
  * Generates a sha1 digest encoded as HEX
161
156
  */
162
- generateContentHash?(content: string | any, length?: number): Promise<string>;
157
+ generateContentHash(content: string | any, length?: number): Promise<string>;
163
158
  /**
164
159
  * Generates a sha1 digest encoded as HEX from a file path
165
160
  */
166
- generateFileHash?(filePath: string | any, length?: number): Promise<string>;
161
+ generateFileHash(filePath: string | any, length?: number): Promise<string>;
167
162
  /**
168
163
  * Get the current directory.
169
164
  */
@@ -172,7 +167,6 @@ interface CompilerSystem {
172
167
  * The compiler's executing path.
173
168
  */
174
169
  getCompilerExecutingPath(): string;
175
- getEnvironmentVar?(key: string): string;
176
170
  /**
177
171
  * Gets the absolute file path when for a dependency module.
178
172
  */
@@ -211,11 +205,7 @@ interface CompilerSystem {
211
205
  * Normalize file system path.
212
206
  */
213
207
  normalizePath(p: string): string;
214
- onProcessInterrupt?(cb: () => void): void;
215
- parseYarnLockFile?: (content: string) => {
216
- type: 'success' | 'merge' | 'conflict';
217
- object: any;
218
- };
208
+ onProcessInterrupt(cb: () => void): void;
219
209
  platformPath: PlatformPath;
220
210
  /**
221
211
  * All return paths are full normalized paths, not just the basenames. Always returns an array, does not throw.
@@ -251,6 +241,9 @@ interface CompilerSystem {
251
241
  * Rename old path to new path. Does not throw.
252
242
  */
253
243
  rename(oldPath: string, newPath: string): Promise<CompilerSystemRenameResults>;
244
+ /**
245
+ * Assigned by the compiler. Used by plugins (e.g. `@stencil/sass`) to resolve `~` imports.
246
+ */
254
247
  resolveModuleId?(opts: ResolveModuleIdOptions): Promise<ResolveModuleIdResults>;
255
248
  resolvePath(p: string): string;
256
249
  /**
@@ -775,10 +768,6 @@ interface Diagnostic {
775
768
  relFilePath?: string | undefined;
776
769
  type: string;
777
770
  }
778
- interface CacheStorage {
779
- get(key: string): Promise<any>;
780
- set(key: string, value: any): Promise<void>;
781
- }
782
771
  interface LazyRequire {
783
772
  ensure(fromDir: string, moduleIds: string[]): Promise<Diagnostic[]>;
784
773
  require(fromDir: string, moduleId: string): any;
@@ -1844,7 +1844,7 @@ const validateComponentTag = (tag) => {
1844
1844
  };
1845
1845
  //#endregion
1846
1846
  //#region src/version.ts
1847
- const version = "5.0.0-beta.14";
1847
+ const version = "5.0.0-beta.15";
1848
1848
  //#endregion
1849
1849
  //#region src/compiler/events.ts
1850
1850
  const buildEvents = () => {
@@ -2358,15 +2358,6 @@ const createSystem = (c) => {
2358
2358
  }
2359
2359
  return results;
2360
2360
  };
2361
- /**
2362
- * `self` is the global namespace object used within a web worker.
2363
- * `window` is the browser's global namespace object (I reorganized this to check the reference on that second)
2364
- * `global` is Node's global namespace object. https://nodejs.org/api/globals.html#globals_global
2365
- *
2366
- * loading in this order should allow workers, which are most common, then browser,
2367
- * then Node to grab the reference to fetch correctly.
2368
- */
2369
- const fetch = typeof self !== "undefined" ? self?.fetch : typeof window !== "undefined" ? window?.fetch : typeof global !== "undefined" ? global?.fetch : void 0;
2370
2361
  const writeFile = async (p, data) => writeFileSync(p, data);
2371
2362
  const tmpDirSync = () => "/.tmp";
2372
2363
  const tick = Promise.resolve();
@@ -2377,6 +2368,7 @@ const createSystem = (c) => {
2377
2368
  if (typeof hashLength === "number") hashHex = hashHex.slice(0, hashLength);
2378
2369
  return hashHex;
2379
2370
  };
2371
+ const generateFileHash = async (filePath, hashLength) => generateContentHash(readFileSync(filePath), hashLength);
2380
2372
  const copy = async (copyTasks, srcDir) => {
2381
2373
  const results = {
2382
2374
  diagnostics: [],
@@ -2386,9 +2378,6 @@ const createSystem = (c) => {
2386
2378
  logger.info("todo, copy task", copyTasks.length, srcDir);
2387
2379
  return results;
2388
2380
  };
2389
- const getEnvironmentVar = (key) => {
2390
- return process$1?.env[key];
2391
- };
2392
2381
  const getLocalModulePath = (opts) => join$1(opts.rootDir, "node_modules", opts.moduleId, opts.path);
2393
2382
  const getRemoteModuleUrl = (opts) => {
2394
2383
  const npmBaseUrl = "https://cdn.jsdelivr.net/npm/";
@@ -2404,13 +2393,14 @@ const createSystem = (c) => {
2404
2393
  access,
2405
2394
  accessSync,
2406
2395
  addDestroy,
2396
+ checkVersion: async () => noop,
2407
2397
  copyFile,
2408
2398
  createDir,
2409
2399
  createDirSync,
2410
2400
  homeDir,
2411
2401
  isTTY,
2412
- getEnvironmentVar,
2413
2402
  destroy,
2403
+ dynamicImport: (p) => import(p),
2414
2404
  encodeToBase64,
2415
2405
  exit: async (exitCode) => logger.warn(`exit ${exitCode}`),
2416
2406
  getCurrentDirectory,
@@ -2421,6 +2411,7 @@ const createSystem = (c) => {
2421
2411
  isSymbolicLink,
2422
2412
  nextTick,
2423
2413
  normalizePath: normalize,
2414
+ onProcessInterrupt: noop,
2424
2415
  platformPath: path,
2425
2416
  readDir,
2426
2417
  readDirSync,
@@ -2430,7 +2421,6 @@ const createSystem = (c) => {
2430
2421
  realpathSync,
2431
2422
  removeDestroy,
2432
2423
  rename,
2433
- fetch,
2434
2424
  resolvePath,
2435
2425
  removeDir,
2436
2426
  removeDirSync,
@@ -2445,6 +2435,7 @@ const createSystem = (c) => {
2445
2435
  writeFile,
2446
2436
  writeFileSync,
2447
2437
  generateContentHash,
2438
+ generateFileHash,
2448
2439
  createWorkerController: null,
2449
2440
  details: {
2450
2441
  cpuModel: "",
@@ -4928,12 +4919,10 @@ const optimizeCss = async (inputOpts) => {
4928
4919
  const CREATE_EVENT = "__stencil_createEvent";
4929
4920
  const DEFINE_CUSTOM_ELEMENT = "__stencil_defineCustomElement";
4930
4921
  const GET_ELEMENT = "__stencil_getElement";
4931
- const HOST = "__stencil_Host";
4932
4922
  const HTML_ELEMENT = "HTMLElement";
4933
4923
  const PROXY_CUSTOM_ELEMENT = "__stencil_proxyCustomElement";
4934
4924
  const REGISTER_INSTANCE = "__stencil_registerInstance";
4935
4925
  const REGISTER_HOST = "__stencil_registerHost";
4936
- const H = "__stencil_h";
4937
4926
  const TRANSFORM_TAG = "__stencil_transformTag";
4938
4927
  const GET_REGISTRY = "__stencil_getRegistry";
4939
4928
  const INJECT_SIDE_EFFECT_STYLE = "__stencil_injectSideEffectStyle";
@@ -4941,9 +4930,7 @@ const RUNTIME_APIS = {
4941
4930
  createEvent: `createEvent as ${CREATE_EVENT}`,
4942
4931
  defineCustomElement: `defineCustomElement as ${DEFINE_CUSTOM_ELEMENT}`,
4943
4932
  getElement: `getElement as ${GET_ELEMENT}`,
4944
- h: `h as ${H}`,
4945
4933
  legacyH: `h`,
4946
- Host: `Host as ${HOST}`,
4947
4934
  HTMLElement: HTML_ELEMENT,
4948
4935
  proxyCustomElement: `proxyCustomElement as ${PROXY_CUSTOM_ELEMENT}`,
4949
4936
  registerHost: `registerHost as ${REGISTER_HOST}`,
@@ -10906,31 +10893,6 @@ const createIdentifierFromStyleIdentifier = (styleIdentifier, externalStyleIds)
10906
10893
  return ts$1.factory.createBinaryExpression(createIdentifierFromStyleIdentifier(styleIdentifier, [id]), ts$1.SyntaxKind.PlusToken, createIdentifierFromStyleIdentifier(styleIdentifier, externalStyleIds.slice(1)));
10907
10894
  };
10908
10895
  //#endregion
10909
- //#region src/compiler/transformers/host-data-transform.ts
10910
- const transformHostData = (classElements, moduleFile) => {
10911
- if (classElements.some((e) => ts$1.isMethodDeclaration(e) && e.name.escapedText === "hostData")) {
10912
- const renderIndex = classElements.findIndex((e) => ts$1.isMethodDeclaration(e) && e.name.escapedText === "render");
10913
- if (renderIndex >= 0) {
10914
- const renderMethod = classElements[renderIndex];
10915
- classElements[renderIndex] = ts$1.factory.updateMethodDeclaration(renderMethod, retrieveModifierLike(renderMethod), renderMethod.asteriskToken, ts$1.factory.createIdentifier(INTERNAL_RENDER), renderMethod.questionToken, renderMethod.typeParameters, renderMethod.parameters, renderMethod.type, renderMethod.body);
10916
- }
10917
- classElements.push(syntheticRender(moduleFile, renderIndex >= 0));
10918
- }
10919
- };
10920
- const syntheticRender = (moduleFile, hasRender) => {
10921
- addCoreRuntimeApi(moduleFile, RUNTIME_APIS.Host);
10922
- addCoreRuntimeApi(moduleFile, RUNTIME_APIS.h);
10923
- const hArguments = [ts$1.factory.createIdentifier(HOST), ts$1.factory.createCallExpression(ts$1.factory.createPropertyAccessExpression(ts$1.factory.createThis(), "hostData"), void 0, void 0)];
10924
- if (hasRender) hArguments.push(ts$1.factory.createCallExpression(ts$1.factory.createPropertyAccessExpression(ts$1.factory.createThis(), INTERNAL_RENDER), void 0, void 0));
10925
- /**
10926
- * render() {
10927
- * return h(arguments);
10928
- * }
10929
- */
10930
- return ts$1.factory.createMethodDeclaration(void 0, void 0, "render", void 0, void 0, [], void 0, ts$1.factory.createBlock([ts$1.factory.createReturnStatement(ts$1.factory.createCallExpression(ts$1.factory.createIdentifier(H), void 0, hArguments))]));
10931
- };
10932
- const INTERNAL_RENDER = "__stencil_render";
10933
- //#endregion
10934
10896
  //#region src/compiler/transformers/reactive-handler-meta-transform.ts
10935
10897
  /**
10936
10898
  * Add a getter to a class for a static representation of the watchers
@@ -11012,7 +10974,6 @@ const updateLazyComponentMembers = (transformOpts, styleStatements, classNode, m
11012
10974
  addReactivePropHandlers(classMembers, cmp, "watchers");
11013
10975
  addReactivePropHandlers(classMembers, cmp, "serializers");
11014
10976
  addReactivePropHandlers(classMembers, cmp, "deserializers");
11015
- transformHostData(classMembers, moduleFile);
11016
10977
  if (transformOpts.style === "static") addStaticStylePropertyToClass(styleStatements, cmp, buildCtx);
11017
10978
  return classMembers;
11018
10979
  };
@@ -11460,7 +11421,6 @@ const updateNativeHostComponentMembers = (transformOpts, classNode, moduleFile,
11460
11421
  addReactivePropHandlers(classMembers, cmp, "deserializers");
11461
11422
  if (cmp.isPlain) addNativeComponentMeta(classMembers, cmp);
11462
11423
  if (transformOpts.style === "static") addNativeStaticStyle(classMembers, cmp, buildCtx);
11463
- transformHostData(classMembers, moduleFile);
11464
11424
  return classMembers;
11465
11425
  };
11466
11426
  //#endregion
@@ -11663,110 +11623,6 @@ const isDecoratorNamed = (propName) => {
11663
11623
  };
11664
11624
  };
11665
11625
  //#endregion
11666
- //#region src/compiler/transformers/decorators-to-static/attach-internals.ts
11667
- /**
11668
- * Convert the attach internals decorator to static, saving the name of the
11669
- * decorated property so an `ElementInternals` object can be bound to it later
11670
- * on.
11671
- *
11672
- * The `@AttachInternals` decorator is used to indicate a field on a class
11673
- * where the return value of the `HTMLElement.attachInternals` method should be
11674
- * bound. This then allows component authors to use that interface to make their
11675
- * Stencil components rich participants in whatever `HTMLFormElement` instances
11676
- * they find themselves inside of in the future.
11677
- *
11678
- * The decorator also accepts an optional `states` option to define initial
11679
- * custom states that will be set on the `ElementInternals.states` CustomStateSet.
11680
- * Each state property can have a JSDoc comment that will be extracted for documentation.
11681
- *
11682
- * **Note**: this function will mutate the `newMembers` parameter in order to
11683
- * add new members to the class.
11684
- *
11685
- * @param diagnostics for reporting errors and warnings
11686
- * @param decoratedMembers the decorated members found on the class
11687
- * @param newMembers an out param for new class members
11688
- * @param typeChecker a TypeScript typechecker, needed for resolving the prop
11689
- * declaration name
11690
- * @param decoratorName the name of the decorator to look for
11691
- */
11692
- const attachInternalsDecoratorsToStatic = (diagnostics, decoratedMembers, newMembers, typeChecker, decoratorName) => {
11693
- const attachInternalsMembers = decoratedMembers.filter(ts$1.isPropertyDeclaration).filter((prop) => {
11694
- return !!retrieveTsDecorators(prop)?.find(isDecoratorNamed(decoratorName));
11695
- });
11696
- if (attachInternalsMembers.length === 0) return;
11697
- if (attachInternalsMembers.length > 1) {
11698
- const error = buildError(diagnostics);
11699
- error.messageText = `Stencil does not support adding more than one AttachInternals() decorator to a component`;
11700
- return;
11701
- }
11702
- const [decoratedProp] = attachInternalsMembers;
11703
- const { staticName: name } = tsPropDeclName(decoratedProp, typeChecker);
11704
- const decorator = retrieveTsDecorators(decoratedProp)?.find(isDecoratorNamed(decoratorName));
11705
- const customStates = parseCustomStatesFromDecorator(decorator, typeChecker);
11706
- const formAssociated = parseFormAssociatedFromDecorator(decorator);
11707
- newMembers.push(createStaticGetter("attachInternalsMemberName", convertValueToLiteral(name)));
11708
- if (customStates.length > 0) newMembers.push(createStaticGetter("attachInternalsCustomStates", convertValueToLiteral(customStates)));
11709
- if (formAssociated) newMembers.push(createStaticGetter("formAssociated", convertValueToLiteral(true)));
11710
- };
11711
- /**
11712
- * Parse the formAssociated option from the decorator.
11713
- * Returns true (form-associated) unless explicitly set to false.
11714
- *
11715
- * @param decorator the decorator node to parse
11716
- * @returns whether the component should be form-associated
11717
- */
11718
- function parseFormAssociatedFromDecorator(decorator) {
11719
- if (!decorator || !ts$1.isCallExpression(decorator.expression)) return true;
11720
- const [firstArg] = decorator.expression.arguments;
11721
- if (!firstArg || !ts$1.isObjectLiteralExpression(firstArg)) return true;
11722
- const formAssociatedProp = firstArg.properties.find((prop) => ts$1.isPropertyAssignment(prop) && ts$1.isIdentifier(prop.name) && prop.name.text === "formAssociated");
11723
- if (!formAssociatedProp) return true;
11724
- if (formAssociatedProp.initializer.kind === ts$1.SyntaxKind.FalseKeyword) return false;
11725
- return true;
11726
- }
11727
- /**
11728
- * Parse custom states from the decorator AST, including JSDoc comments.
11729
- *
11730
- * Supports JSDoc comments on state properties:
11731
- * ```ts
11732
- * @AttachInternals({
11733
- * states: {
11734
- * hovered: false,
11735
- * /&#42;&#42; Whether is currently active &#42;/
11736
- * active: true
11737
- * }
11738
- * })
11739
- * ```
11740
- *
11741
- * @param decorator the decorator node to parse
11742
- * @param typeChecker a TypeScript typechecker for resolving symbols
11743
- * @returns array of custom state metadata with docs
11744
- */
11745
- function parseCustomStatesFromDecorator(decorator, typeChecker) {
11746
- if (!decorator || !ts$1.isCallExpression(decorator.expression)) return [];
11747
- const [firstArg] = decorator.expression.arguments;
11748
- if (!firstArg || !ts$1.isObjectLiteralExpression(firstArg)) return [];
11749
- const statesProp = firstArg.properties.find((prop) => ts$1.isPropertyAssignment(prop) && ts$1.isIdentifier(prop.name) && prop.name.text === "states");
11750
- if (!statesProp || !ts$1.isObjectLiteralExpression(statesProp.initializer)) return [];
11751
- const customStates = [];
11752
- for (const prop of statesProp.initializer.properties) {
11753
- if (!ts$1.isPropertyAssignment(prop)) continue;
11754
- const stateName = ts$1.isIdentifier(prop.name) ? prop.name.text : ts$1.isStringLiteral(prop.name) ? prop.name.text : null;
11755
- if (!stateName) continue;
11756
- let initialValue = false;
11757
- if (prop.initializer.kind === ts$1.SyntaxKind.TrueKeyword) initialValue = true;
11758
- else if (prop.initializer.kind === ts$1.SyntaxKind.FalseKeyword) initialValue = false;
11759
- const symbol = typeChecker.getSymbolAtLocation(prop.name);
11760
- const docs = symbol ? ts$1.displayPartsToString(symbol.getDocumentationComment(typeChecker)) : "";
11761
- customStates.push({
11762
- name: stateName,
11763
- initialValue,
11764
- docs
11765
- });
11766
- }
11767
- return customStates;
11768
- }
11769
- //#endregion
11770
11626
  //#region src/compiler/transformers/decorators-to-static/style-to-static.ts
11771
11627
  const styleToStatic = (newMembers, componentOptions) => {
11772
11628
  const defaultModeStyles = [];
@@ -11831,6 +11687,12 @@ const normalizeStyleUrl = (style) => {
11831
11687
  //#region src/compiler/transformers/decorators-to-static/component-decorator.ts
11832
11688
  let hasShownDeprecatedApiError = false;
11833
11689
  /**
11690
+ * Reset the deprecated API error flag. Call this at the start of each build.
11691
+ */
11692
+ const resetDeprecatedApiWarning = () => {
11693
+ hasShownDeprecatedApiError = false;
11694
+ };
11695
+ /**
11834
11696
  * Perform code generation to create new class members for a Stencil component
11835
11697
  * which will drive the runtime functionality specified by various options
11836
11698
  * passed to the `@Component` decorator.
@@ -12031,6 +11893,110 @@ const findTagNode = (propName, node) => {
12031
11893
  return out;
12032
11894
  };
12033
11895
  //#endregion
11896
+ //#region src/compiler/transformers/decorators-to-static/attach-internals.ts
11897
+ /**
11898
+ * Convert the attach internals decorator to static, saving the name of the
11899
+ * decorated property so an `ElementInternals` object can be bound to it later
11900
+ * on.
11901
+ *
11902
+ * The `@AttachInternals` decorator is used to indicate a field on a class
11903
+ * where the return value of the `HTMLElement.attachInternals` method should be
11904
+ * bound. This then allows component authors to use that interface to make their
11905
+ * Stencil components rich participants in whatever `HTMLFormElement` instances
11906
+ * they find themselves inside of in the future.
11907
+ *
11908
+ * The decorator also accepts an optional `states` option to define initial
11909
+ * custom states that will be set on the `ElementInternals.states` CustomStateSet.
11910
+ * Each state property can have a JSDoc comment that will be extracted for documentation.
11911
+ *
11912
+ * **Note**: this function will mutate the `newMembers` parameter in order to
11913
+ * add new members to the class.
11914
+ *
11915
+ * @param diagnostics for reporting errors and warnings
11916
+ * @param decoratedMembers the decorated members found on the class
11917
+ * @param newMembers an out param for new class members
11918
+ * @param typeChecker a TypeScript typechecker, needed for resolving the prop
11919
+ * declaration name
11920
+ * @param decoratorName the name of the decorator to look for
11921
+ */
11922
+ const attachInternalsDecoratorsToStatic = (diagnostics, decoratedMembers, newMembers, typeChecker, decoratorName) => {
11923
+ const attachInternalsMembers = decoratedMembers.filter(ts$1.isPropertyDeclaration).filter((prop) => {
11924
+ return !!retrieveTsDecorators(prop)?.find(isDecoratorNamed(decoratorName));
11925
+ });
11926
+ if (attachInternalsMembers.length === 0) return;
11927
+ if (attachInternalsMembers.length > 1) {
11928
+ const error = buildError(diagnostics);
11929
+ error.messageText = `Stencil does not support adding more than one AttachInternals() decorator to a component`;
11930
+ return;
11931
+ }
11932
+ const [decoratedProp] = attachInternalsMembers;
11933
+ const { staticName: name } = tsPropDeclName(decoratedProp, typeChecker);
11934
+ const decorator = retrieveTsDecorators(decoratedProp)?.find(isDecoratorNamed(decoratorName));
11935
+ const customStates = parseCustomStatesFromDecorator(decorator, typeChecker);
11936
+ const formAssociated = parseFormAssociatedFromDecorator(decorator);
11937
+ newMembers.push(createStaticGetter("attachInternalsMemberName", convertValueToLiteral(name)));
11938
+ if (customStates.length > 0) newMembers.push(createStaticGetter("attachInternalsCustomStates", convertValueToLiteral(customStates)));
11939
+ if (formAssociated) newMembers.push(createStaticGetter("formAssociated", convertValueToLiteral(true)));
11940
+ };
11941
+ /**
11942
+ * Parse the formAssociated option from the decorator.
11943
+ * Returns true (form-associated) unless explicitly set to false.
11944
+ *
11945
+ * @param decorator the decorator node to parse
11946
+ * @returns whether the component should be form-associated
11947
+ */
11948
+ function parseFormAssociatedFromDecorator(decorator) {
11949
+ if (!decorator || !ts$1.isCallExpression(decorator.expression)) return true;
11950
+ const [firstArg] = decorator.expression.arguments;
11951
+ if (!firstArg || !ts$1.isObjectLiteralExpression(firstArg)) return true;
11952
+ const formAssociatedProp = firstArg.properties.find((prop) => ts$1.isPropertyAssignment(prop) && ts$1.isIdentifier(prop.name) && prop.name.text === "formAssociated");
11953
+ if (!formAssociatedProp) return true;
11954
+ if (formAssociatedProp.initializer.kind === ts$1.SyntaxKind.FalseKeyword) return false;
11955
+ return true;
11956
+ }
11957
+ /**
11958
+ * Parse custom states from the decorator AST, including JSDoc comments.
11959
+ *
11960
+ * Supports JSDoc comments on state properties:
11961
+ * ```ts
11962
+ * @AttachInternals({
11963
+ * states: {
11964
+ * hovered: false,
11965
+ * /&#42;&#42; Whether is currently active &#42;/
11966
+ * active: true
11967
+ * }
11968
+ * })
11969
+ * ```
11970
+ *
11971
+ * @param decorator the decorator node to parse
11972
+ * @param typeChecker a TypeScript typechecker for resolving symbols
11973
+ * @returns array of custom state metadata with docs
11974
+ */
11975
+ function parseCustomStatesFromDecorator(decorator, typeChecker) {
11976
+ if (!decorator || !ts$1.isCallExpression(decorator.expression)) return [];
11977
+ const [firstArg] = decorator.expression.arguments;
11978
+ if (!firstArg || !ts$1.isObjectLiteralExpression(firstArg)) return [];
11979
+ const statesProp = firstArg.properties.find((prop) => ts$1.isPropertyAssignment(prop) && ts$1.isIdentifier(prop.name) && prop.name.text === "states");
11980
+ if (!statesProp || !ts$1.isObjectLiteralExpression(statesProp.initializer)) return [];
11981
+ const customStates = [];
11982
+ for (const prop of statesProp.initializer.properties) {
11983
+ if (!ts$1.isPropertyAssignment(prop)) continue;
11984
+ const stateName = ts$1.isIdentifier(prop.name) ? prop.name.text : ts$1.isStringLiteral(prop.name) ? prop.name.text : null;
11985
+ if (!stateName) continue;
11986
+ let initialValue = false;
11987
+ if (prop.initializer.kind === ts$1.SyntaxKind.TrueKeyword) initialValue = true;
11988
+ else if (prop.initializer.kind === ts$1.SyntaxKind.FalseKeyword) initialValue = false;
11989
+ const symbol = typeChecker.getSymbolAtLocation(prop.name);
11990
+ const docs = symbol ? ts$1.displayPartsToString(symbol.getDocumentationComment(typeChecker)) : "";
11991
+ customStates.push({
11992
+ name: stateName,
11993
+ initialValue,
11994
+ docs
11995
+ });
11996
+ }
11997
+ return customStates;
11998
+ }
11999
+ //#endregion
12034
12000
  //#region src/compiler/transformers/decorators-to-static/decorators-constants.ts
12035
12001
  /**
12036
12002
  * All the decorators supported by Stencil
@@ -15083,7 +15049,6 @@ function mergeExtendedClassMetaWithResolveImport(cmpNode, staticMembers, sourceF
15083
15049
  //#region src/compiler/transformers/static-to-meta/class-methods.ts
15084
15050
  const parseClassMethods = (classMethods, cmpMeta) => {
15085
15051
  if (!classMethods?.length) return;
15086
- const hasHostData = classMethods.includes("hostData");
15087
15052
  cmpMeta.hasAttributeChangedCallbackFn = classMethods.includes("attributeChangedCallback");
15088
15053
  cmpMeta.hasConnectedCallbackFn = classMethods.includes("connectedCallback");
15089
15054
  cmpMeta.hasDisconnectedCallbackFn = classMethods.includes("disconnectedCallback");
@@ -15095,8 +15060,7 @@ const parseClassMethods = (classMethods, cmpMeta) => {
15095
15060
  cmpMeta.hasComponentShouldUpdateFn = classMethods.includes("componentShouldUpdate");
15096
15061
  cmpMeta.hasComponentDidUpdateFn = classMethods.includes("componentDidUpdate");
15097
15062
  cmpMeta.hasLifecycle = cmpMeta.hasComponentWillLoadFn || cmpMeta.hasComponentDidLoadFn || cmpMeta.hasComponentWillUpdateFn || cmpMeta.hasComponentDidUpdateFn;
15098
- cmpMeta.hasRenderFn = classMethods.includes("render") || hasHostData;
15099
- cmpMeta.hasVdomRender = cmpMeta.hasVdomRender || hasHostData;
15063
+ cmpMeta.hasRenderFn = classMethods.includes("render");
15100
15064
  };
15101
15065
  //#endregion
15102
15066
  //#region src/compiler/transformers/static-to-meta/element-ref.ts
@@ -15995,6 +15959,7 @@ const transpileModule = (config, input, transformOpts) => {
15995
15959
  ...config,
15996
15960
  logger: createNodeLogger()
15997
15961
  };
15962
+ resetDeprecatedApiWarning();
15998
15963
  const compilerCtx = new CompilerContext();
15999
15964
  const buildCtx = new BuildContext(config, compilerCtx);
16000
15965
  const tsCompilerOptions = { ...config.tsCompilerOptions };