@stencil/core 5.0.0-alpha.3 → 5.0.0-alpha.5

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.
Files changed (36) hide show
  1. package/dist/{client-CSm3x5ke.mjs → client-Dnio47yQ.mjs} +108 -19
  2. package/dist/compiler/index.d.mts +2 -2
  3. package/dist/compiler/index.mjs +2 -2
  4. package/dist/compiler/utils/index.d.mts +2 -2
  5. package/dist/compiler/utils/index.mjs +3 -3
  6. package/dist/{compiler-D6iP7Bzb.mjs → compiler-Dxri2g8Z.mjs} +14994 -14303
  7. package/dist/declarations/stencil-public-compiler.d.ts +342 -132
  8. package/dist/declarations/stencil-public-compiler.js +2 -3
  9. package/dist/declarations/stencil-public-runtime.d.ts +2 -0
  10. package/dist/{index-hS-KBdAP.d.ts → index-D-XN9HW_.d.ts} +1 -1
  11. package/dist/{index-tUR6pD3J.d.mts → index-D5zaocDq.d.mts} +411 -189
  12. package/dist/{index-CyrGY82h.d.ts → index-D61XZw0f.d.ts} +2 -2
  13. package/dist/{index-CXHCTQNt.d.mts → index-Dat4djoo.d.mts} +5 -1
  14. package/dist/index.mjs +1 -1
  15. package/dist/{jsx-runtime-DlDkTqps.d.ts → jsx-runtime-B3vQbWIW.d.ts} +1 -1
  16. package/dist/jsx-runtime.d.ts +1 -1
  17. package/dist/jsx-runtime.js +1 -1
  18. package/dist/{node-Bg-mO5dw.mjs → node-pj6rF4Wt.mjs} +66 -69
  19. package/dist/{regular-expression-D5pGVpCu.mjs → regular-expression-D0_N0PGa.mjs} +44 -26
  20. package/dist/runtime/app-data/index.d.ts +1 -1
  21. package/dist/runtime/client/index.d.ts +45 -8
  22. package/dist/runtime/client/index.js +132 -40
  23. package/dist/runtime/index.d.ts +33 -5
  24. package/dist/runtime/index.js +2 -2
  25. package/dist/runtime/server/index.d.mts +72 -28
  26. package/dist/runtime/server/index.mjs +146 -46
  27. package/dist/runtime/server/runner.d.mts +40 -26
  28. package/dist/runtime/server/runner.mjs +28 -22
  29. package/dist/{runtime-BBCnuprF.js → runtime-CKyUrF4i.js} +131 -39
  30. package/dist/sys/node/index.d.mts +1 -1
  31. package/dist/sys/node/index.mjs +1 -1
  32. package/dist/sys/node/worker.mjs +2 -2
  33. package/dist/testing/index.d.mts +2 -2
  34. package/dist/testing/index.mjs +17 -16
  35. package/dist/{validation-Byxie0Uk.mjs → validation-BA8nzXu_.mjs} +82 -58
  36. package/package.json +11 -12
@@ -497,6 +497,7 @@ declare namespace JSXBase {
497
497
  importance?: 'low' | 'auto' | 'high';
498
498
  height?: number | string;
499
499
  loading?: 'lazy' | 'auto' | 'eager';
500
+ referrerPolicy?: ReferrerPolicy;
500
501
  sizes?: string;
501
502
  src?: string;
502
503
  srcSet?: string;
@@ -1284,7 +1285,7 @@ interface CustomElementsDefineOptions {
1284
1285
  }
1285
1286
  //#endregion
1286
1287
  //#region src/declarations/stencil-public-compiler.d.ts
1287
- interface HydrateDocumentOptions {
1288
+ interface SsrDocumentOptions {
1288
1289
  /**
1289
1290
  * Build ID that will be added to `<html data-stencil-build="BUILD_ID">`. By default
1290
1291
  * a random ID will be generated
@@ -1301,7 +1302,7 @@ interface HydrateDocumentOptions {
1301
1302
  * JavaScript to read the structure of the HTML and rebuild each
1302
1303
  * component. Defaults to `true`.
1303
1304
  */
1304
- clientHydrateAnnotations?: boolean;
1305
+ clientSsrAnnotations?: boolean;
1305
1306
  /**
1306
1307
  * Constrain `setTimeout()` to 1ms, but still async. Also
1307
1308
  * only allows `setInterval()` to fire once, also constrained to 1ms.
@@ -1400,10 +1401,14 @@ interface HydrateDocumentOptions {
1400
1401
  default: 'declarative-shadow-dom' | 'scoped';
1401
1402
  } | boolean;
1402
1403
  }
1403
- interface SerializeDocumentOptions extends HydrateDocumentOptions {
1404
+ interface SerializeDocumentOptions extends SsrDocumentOptions {
1404
1405
  /**
1405
1406
  * Runs after the `document` has been hydrated.
1406
1407
  */
1408
+ afterSsr?(document: any): any | Promise<any>;
1409
+ /**
1410
+ * @deprecated Use `afterSsr` instead.
1411
+ */
1407
1412
  afterHydrate?(document: any): any | Promise<any>;
1408
1413
  /**
1409
1414
  * Sets an approximate line width the HTML should attempt to stay within.
@@ -1416,6 +1421,10 @@ interface SerializeDocumentOptions extends HydrateDocumentOptions {
1416
1421
  /**
1417
1422
  * Runs before the `document` has been hydrated.
1418
1423
  */
1424
+ beforeSsr?(document: any): any | Promise<any>;
1425
+ /**
1426
+ * @deprecated Use `beforeSsr` instead.
1427
+ */
1419
1428
  beforeHydrate?(document: any): any | Promise<any>;
1420
1429
  /**
1421
1430
  * Format the HTML in a nicely indented format.
@@ -1453,7 +1462,7 @@ interface SerializeDocumentOptions extends HydrateDocumentOptions {
1453
1462
  */
1454
1463
  modes?: ResolutionHandler[];
1455
1464
  }
1456
- interface HydrateFactoryOptions extends SerializeDocumentOptions {
1465
+ interface SsrFactoryOptions extends SerializeDocumentOptions {
1457
1466
  serializeToHtml: boolean;
1458
1467
  destroyWindow: boolean;
1459
1468
  destroyDocument: boolean;
@@ -2122,7 +2131,7 @@ declare const setErrorHandler: (handler: ErrorHandler) => ErrorHandler;
2122
2131
  //#region src/client/client-style.d.ts
2123
2132
  declare const styles: StyleMap;
2124
2133
  declare const modeResolutionChain: ResolutionHandler[];
2125
- declare const setScopedSSR: (_opts: HydrateFactoryOptions) => void;
2134
+ declare const setScopedSsr: (_opts: SsrFactoryOptions) => void;
2126
2135
  declare const needsScopedSSR: () => boolean;
2127
2136
  //#endregion
2128
2137
  //#region src/client/client-task-queue.d.ts
@@ -2154,12 +2163,12 @@ declare const supportsMutableAdoptedStyleSheets: boolean;
2154
2163
  declare const getAssetPath: (path: string) => string;
2155
2164
  declare const setAssetPath: (path: string) => string;
2156
2165
  //#endregion
2157
- //#region src/runtime/bootstrap-custom-element.d.ts
2166
+ //#region src/runtime/bootstrap-standalone.d.ts
2158
2167
  declare const defineCustomElement: (Cstr: any, compactMeta: ComponentRuntimeMetaCompact) => void;
2159
2168
  declare const proxyCustomElement: (Cstr: any, compactMeta: ComponentRuntimeMetaCompact) => any;
2160
2169
  declare const forceModeUpdate: (elm: RenderNode) => void;
2161
2170
  //#endregion
2162
- //#region src/runtime/bootstrap-lazy.d.ts
2171
+ //#region src/runtime/bootstrap-loader.d.ts
2163
2172
  declare const bootstrapLazy: (lazyBundles: LazyBundlesRuntimeData, options?: CustomElementsDefineOptions) => void;
2164
2173
  //#endregion
2165
2174
  //#region src/runtime/connected-callback.d.ts
@@ -2211,6 +2220,30 @@ declare const getMode: (ref: RuntimeRef) => string;
2211
2220
  */
2212
2221
  declare const setNonce: (nonce: string) => string;
2213
2222
  //#endregion
2223
+ //#region src/runtime/normalize-watchers.d.ts
2224
+ /**
2225
+ * Normalizes watcher metadata to the current `{ [methodName]: flags }[]` format.
2226
+ *
2227
+ * Prior to Stencil 4.39.x (PR #6484), the `@Watch()` compiler emitted watcher
2228
+ * handlers as a plain string array: `{ "min": ["minChanged"] }`. The new format
2229
+ * wraps each entry in an object that carries option flags (e.g. `immediate`):
2230
+ * `{ "min": [{ "minChanged": 0 }] }`.
2231
+ *
2232
+ * When a library (e.g. Ionic Framework) was compiled with an older Stencil compiler
2233
+ * but consumed by an app using a newer Stencil runtime, the runtime's
2234
+ * `Object.entries(watcher)` call receives a string and misinterprets its character
2235
+ * indices as method names, causing:
2236
+ * `TypeError: instance[watchMethodName] is not a function`
2237
+ *
2238
+ * This helper should be used at `$watchers$` assignment sites that need to
2239
+ * accept both legacy and current compiler metadata so downstream code on those
2240
+ * paths can safely assume the new object format.
2241
+ *
2242
+ * @param raw The raw watcher map from compiled metadata (new or legacy format).
2243
+ * @returns A normalized watcher map in the `{ [methodName]: flags }[]` format, or `undefined` if `raw` is `undefined` or empty.
2244
+ */
2245
+ declare const normalizeWatchers: (raw: ComponentConstructorChangeHandlers | undefined) => ComponentConstructorChangeHandlers | undefined;
2246
+ //#endregion
2214
2247
  //#region src/runtime/parse-property-value.d.ts
2215
2248
  /**
2216
2249
  * Parse a new property value for a given property type.
@@ -2269,6 +2302,10 @@ declare const proxyComponent: (Cstr: ComponentConstructor, cmpMeta: ComponentRun
2269
2302
  /**
2270
2303
  * Method to render a virtual DOM tree to a container element.
2271
2304
  *
2305
+ * Supports efficient re-renders: calling `render()` again on the same container
2306
+ * will diff the new VNode tree against the previous one and only update what changed,
2307
+ * preserving existing DOM elements and their state.
2308
+ *
2272
2309
  * @example
2273
2310
  * ```tsx
2274
2311
  * import { render } from '@stencil/core';
@@ -2365,4 +2402,4 @@ declare const insertVdomAnnotations: (doc: Document, staticComponents: string[])
2365
2402
  */
2366
2403
  declare const renderVdom: (hostRef: HostRef, renderFnResults: VNode | VNode[], isInitialLoad?: boolean) => void;
2367
2404
  //#endregion
2368
- export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, type HTMLStencilElement, HYDRATED_STYLE_ID, Host, type JSXBase, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, h, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, render, renderVdom, resolveVar, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setScopedSSR, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, supportsShadow, transformTag, win, writeTask };
2405
+ export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, type HTMLStencilElement, HYDRATED_STYLE_ID, Host, type JSXBase, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, h, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, render, renderVdom, resolveVar, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setScopedSsr, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, supportsShadow, transformTag, win, writeTask };
@@ -379,7 +379,7 @@ const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
379
379
  //#region src/client/client-style.ts
380
380
  const styles = /* @__PURE__ */ new Map();
381
381
  const modeResolutionChain = [];
382
- const setScopedSSR = (_opts) => {};
382
+ const setScopedSsr = (_opts) => {};
383
383
  const needsScopedSSR = () => false;
384
384
  //#endregion
385
385
  //#region src/runtime/runtime-constants.ts
@@ -1427,7 +1427,8 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
1427
1427
  styleElm.textContent = style;
1428
1428
  const nonce = plt.$nonce$ ?? queryNonceMetaTagContent(win.document);
1429
1429
  if (nonce != null) styleElm.setAttribute("nonce", nonce);
1430
- if ((BUILD$1.hydrateServerSide || BUILD$1.hotModuleReplacement) && (cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation || cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss || cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation)) styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
1430
+ if (BUILD$1.hydrateServerSide && (cmpMeta.$flags$ & CMP_FLAGS.scopedCssEncapsulation || cmpMeta.$flags$ & CMP_FLAGS.shadowNeedsScopedCss || cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) || BUILD$1.hotModuleReplacement) styleElm.setAttribute(HYDRATED_STYLE_ID, scopeId);
1431
+ if (BUILD$1.hotModuleReplacement && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation) styleElm.setAttribute("data-slot-fb", "");
1431
1432
  /**
1432
1433
  * attach styles at the end of the head tag if we render scoped components
1433
1434
  */
@@ -2538,6 +2539,46 @@ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) =>
2538
2539
  const setMode = (handler) => modeResolutionChain.push(handler);
2539
2540
  const getMode = (ref) => getHostRef(ref)?.$modeName$;
2540
2541
  //#endregion
2542
+ //#region src/runtime/normalize-watchers.ts
2543
+ /**
2544
+ * Normalizes watcher metadata to the current `{ [methodName]: flags }[]` format.
2545
+ *
2546
+ * Prior to Stencil 4.39.x (PR #6484), the `@Watch()` compiler emitted watcher
2547
+ * handlers as a plain string array: `{ "min": ["minChanged"] }`. The new format
2548
+ * wraps each entry in an object that carries option flags (e.g. `immediate`):
2549
+ * `{ "min": [{ "minChanged": 0 }] }`.
2550
+ *
2551
+ * When a library (e.g. Ionic Framework) was compiled with an older Stencil compiler
2552
+ * but consumed by an app using a newer Stencil runtime, the runtime's
2553
+ * `Object.entries(watcher)` call receives a string and misinterprets its character
2554
+ * indices as method names, causing:
2555
+ * `TypeError: instance[watchMethodName] is not a function`
2556
+ *
2557
+ * This helper should be used at `$watchers$` assignment sites that need to
2558
+ * accept both legacy and current compiler metadata so downstream code on those
2559
+ * paths can safely assume the new object format.
2560
+ *
2561
+ * @param raw The raw watcher map from compiled metadata (new or legacy format).
2562
+ * @returns A normalized watcher map in the `{ [methodName]: flags }[]` format, or `undefined` if `raw` is `undefined` or empty.
2563
+ */
2564
+ const normalizeWatchers = (raw) => {
2565
+ if (!raw) return void 0;
2566
+ const keys = Object.keys(raw);
2567
+ if (keys.length === 0) return void 0;
2568
+ let hasLegacy = false;
2569
+ for (const propName of keys) {
2570
+ if (hasLegacy) break;
2571
+ for (const h of raw[propName]) if (typeof h === "string") {
2572
+ hasLegacy = true;
2573
+ break;
2574
+ }
2575
+ }
2576
+ if (!hasLegacy) return raw;
2577
+ const out = {};
2578
+ for (const propName of keys) out[propName] = raw[propName].map((h) => typeof h === "string" ? { [h]: 0 } : h);
2579
+ return out;
2580
+ };
2581
+ //#endregion
2541
2582
  //#region src/runtime/parse-property-value.ts
2542
2583
  /**
2543
2584
  * Parse a new property value for a given property type.
@@ -3888,7 +3929,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
3888
3929
  });
3889
3930
  if (BUILD$1.member && cmpMeta.$members$ || BUILD$1.propChangeCallback) {
3890
3931
  if (BUILD$1.propChangeCallback) {
3891
- if (Cstr.watchers && !cmpMeta.$watchers$) cmpMeta.$watchers$ = Cstr.watchers;
3932
+ if (Cstr.watchers && !cmpMeta.$watchers$) cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
3892
3933
  if (Cstr.deserializers && !cmpMeta.$deserializers$) cmpMeta.$deserializers$ = Cstr.deserializers;
3893
3934
  if (Cstr.serializers && !cmpMeta.$serializers$) cmpMeta.$serializers$ = Cstr.serializers;
3894
3935
  }
@@ -3993,9 +4034,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
3993
4034
  return;
3994
4035
  }
3995
4036
  const propFlags = members.find(([m]) => m === propName);
3996
- if (propFlags && propFlags[1][0] & MEMBER_FLAGS.Boolean) newValue = newValue !== null && newValue !== "false";
4037
+ const isBooleanTarget = propFlags && propFlags[1][0] & MEMBER_FLAGS.Boolean;
4038
+ const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
4039
+ if (isBooleanTarget) newValue = !(newValue === null || newValue === "false");
3997
4040
  const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
3998
- if (newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
4041
+ if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
3999
4042
  });
4000
4043
  };
4001
4044
  Cstr.observedAttributes = Array.from(new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
@@ -4036,7 +4079,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
4036
4079
  if (!Cstr) throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
4037
4080
  if (BUILD$1.member && !Cstr.isProxied) {
4038
4081
  if (BUILD$1.propChangeCallback) {
4039
- cmpMeta.$watchers$ = Cstr.watchers;
4082
+ cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
4040
4083
  cmpMeta.$serializers$ = Cstr.serializers;
4041
4084
  cmpMeta.$deserializers$ = Cstr.deserializers;
4042
4085
  }
@@ -4212,7 +4255,59 @@ const disconnectedCallback = async (elm) => {
4212
4255
  if (elm.shadowRoot && rootAppliedStyles.has(elm.shadowRoot)) rootAppliedStyles.delete(elm.shadowRoot);
4213
4256
  };
4214
4257
  //#endregion
4215
- //#region src/runtime/bootstrap-custom-element.ts
4258
+ //#region src/runtime/hmr-component.ts
4259
+ /**
4260
+ * Kick off hot-module-replacement for a component. In order to replace the
4261
+ * component in-place we:
4262
+ *
4263
+ * 1. get a reference to the {@link d.HostRef} for the element
4264
+ * 2. reset the element's runtime flags
4265
+ * 3. re-run the initialization logic for the element (via
4266
+ * {@link initializeComponent})
4267
+ *
4268
+ * For standalone (non-lazy) builds, we instead re-import the component module
4269
+ * and patch the prototype of the registered constructor in-place, then
4270
+ * force a re-render of all existing instances in the DOM.
4271
+ *
4272
+ * @param hostElement the host element for the component which we want to start
4273
+ * doing HMR
4274
+ * @param cmpMeta runtime metadata for the component
4275
+ * @param hmrVersionId the current HMR version ID
4276
+ */
4277
+ const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
4278
+ if (BUILD$1.lazyLoad) {
4279
+ const hostRef = getHostRef(hostElement);
4280
+ if (!hostRef) return;
4281
+ hostRef.$flags$ = HOST_FLAGS.hasConnected;
4282
+ initializeComponent(hostElement, hostRef, cmpMeta, hmrVersionId);
4283
+ } else hmrStandalone(hostElement, cmpMeta, hmrVersionId);
4284
+ };
4285
+ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
4286
+ const modulePath = hostElement.constructor.__stencil_module__;
4287
+ console.log(`[Stencil HMR] hmrStandalone <${cmpMeta.$tagName$}> modulePath:`, modulePath);
4288
+ if (!modulePath) {
4289
+ console.warn(`[Stencil HMR] No __stencil_module__ on <${cmpMeta.$tagName$}> constructor — was this built with devMode?`);
4290
+ return;
4291
+ }
4292
+ try {
4293
+ const newModule = await import(
4294
+ /* @vite-ignore */
4295
+ `${modulePath}?s-hmr=${hmrVersionId}`
4296
+ );
4297
+ const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
4298
+ if (!NewClass) return;
4299
+ const ctor = customElements.get(cmpMeta.$tagName$);
4300
+ if (ctor) for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
4301
+ if (key === "constructor") continue;
4302
+ Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
4303
+ }
4304
+ document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => forceUpdate(el));
4305
+ } catch (e) {
4306
+ console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
4307
+ }
4308
+ };
4309
+ //#endregion
4310
+ //#region src/runtime/bootstrap-standalone.ts
4216
4311
  const defineCustomElement = (Cstr, compactMeta) => {
4217
4312
  customElements.define(transformTag(compactMeta[1]), proxyCustomElement(Cstr, compactMeta));
4218
4313
  };
@@ -4226,12 +4321,15 @@ const proxyCustomElement = (Cstr, compactMeta) => {
4226
4321
  if (BUILD$1.member) cmpMeta.$members$ = compactMeta[2];
4227
4322
  if (BUILD$1.hostListener) cmpMeta.$listeners$ = compactMeta[3];
4228
4323
  if (BUILD$1.propChangeCallback) {
4229
- cmpMeta.$watchers$ = Cstr.$watchers$;
4324
+ cmpMeta.$watchers$ = normalizeWatchers(Cstr.$watchers$);
4230
4325
  cmpMeta.$deserializers$ = Cstr.$deserializers$;
4231
4326
  cmpMeta.$serializers$ = Cstr.$serializers$;
4232
4327
  }
4233
4328
  if (BUILD$1.reflect) cmpMeta.$attrsToReflect$ = [];
4234
4329
  if (BUILD$1.shadowDom && !supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
4330
+ if (BUILD$1.hotModuleReplacement) Cstr.prototype["s-hmr"] = function(hmrVersionId) {
4331
+ hmrStart(this, cmpMeta, hmrVersionId);
4332
+ };
4235
4333
  if (!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) && cmpMeta.$flags$ & CMP_FLAGS.hasSlot) if (BUILD$1.experimentalSlotFixes || BUILD$1.patchAll && cmpMeta.$flags$ & CMP_FLAGS.patchAll) patchPseudoShadowDom(Cstr.prototype);
4236
4334
  else {
4237
4335
  if (BUILD$1.slotChildNodesFix || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
@@ -4312,29 +4410,7 @@ const forceModeUpdate = (elm) => {
4312
4410
  }
4313
4411
  };
4314
4412
  //#endregion
4315
- //#region src/runtime/hmr-component.ts
4316
- /**
4317
- * Kick off hot-module-replacement for a component. In order to replace the
4318
- * component in-place we:
4319
- *
4320
- * 1. get a reference to the {@link d.HostRef} for the element
4321
- * 2. reset the element's runtime flags
4322
- * 3. re-run the initialization logic for the element (via
4323
- * {@link initializeComponent})
4324
- *
4325
- * @param hostElement the host element for the component which we want to start
4326
- * doing HMR
4327
- * @param cmpMeta runtime metadata for the component
4328
- * @param hmrVersionId the current HMR version ID
4329
- */
4330
- const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
4331
- const hostRef = getHostRef(hostElement);
4332
- if (!hostRef) return;
4333
- hostRef.$flags$ = HOST_FLAGS.hasConnected;
4334
- initializeComponent(hostElement, hostRef, cmpMeta, hmrVersionId);
4335
- };
4336
- //#endregion
4337
- //#region src/runtime/bootstrap-lazy.ts
4413
+ //#region src/runtime/bootstrap-loader.ts
4338
4414
  const bootstrapLazy = (lazyBundles, options = {}) => {
4339
4415
  if (BUILD$1.profile && performance.mark) performance.mark("st:app:start");
4340
4416
  installDevTools();
@@ -4368,7 +4444,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
4368
4444
  if (BUILD$1.hostListener) cmpMeta.$listeners$ = compactMeta[3];
4369
4445
  if (BUILD$1.reflect) cmpMeta.$attrsToReflect$ = [];
4370
4446
  if (BUILD$1.propChangeCallback) {
4371
- cmpMeta.$watchers$ = compactMeta[4] ?? {};
4447
+ cmpMeta.$watchers$ = normalizeWatchers(compactMeta[4]);
4372
4448
  cmpMeta.$serializers$ = compactMeta[5] ?? {};
4373
4449
  cmpMeta.$deserializers$ = compactMeta[6] ?? {};
4374
4450
  }
@@ -4524,8 +4600,19 @@ const setPlatformOptions = (opts) => Object.assign(plt, opts);
4524
4600
  //#endregion
4525
4601
  //#region src/runtime/render.ts
4526
4602
  /**
4603
+ * A WeakMap to persist HostRef objects across multiple render() calls to the
4604
+ * same container. This enables VNode diffing on re-renders — without it, each
4605
+ * call creates a fresh HostRef with no previous VNode, causing renderVdom to
4606
+ * replace the entire DOM subtree instead of patching only what changed.
4607
+ */
4608
+ const hostRefCache = /* @__PURE__ */ new WeakMap();
4609
+ /**
4527
4610
  * Method to render a virtual DOM tree to a container element.
4528
4611
  *
4612
+ * Supports efficient re-renders: calling `render()` again on the same container
4613
+ * will diff the new VNode tree against the previous one and only update what changed,
4614
+ * preserving existing DOM elements and their state.
4615
+ *
4529
4616
  * @example
4530
4617
  * ```tsx
4531
4618
  * import { render } from '@stencil/core';
@@ -4542,14 +4629,19 @@ const setPlatformOptions = (opts) => Object.assign(plt, opts);
4542
4629
  * @param container - The container element to render the virtual DOM tree to
4543
4630
  */
4544
4631
  function render(vnode, container) {
4545
- renderVdom({
4546
- $flags$: 0,
4547
- $cmpMeta$: {
4632
+ let ref = hostRefCache.get(container);
4633
+ if (!ref) {
4634
+ ref = {
4548
4635
  $flags$: 0,
4549
- $tagName$: container.tagName
4550
- },
4551
- $hostElement$: container
4552
- }, vnode);
4636
+ $cmpMeta$: {
4637
+ $flags$: 0,
4638
+ $tagName$: container.tagName
4639
+ },
4640
+ $hostElement$: container
4641
+ };
4642
+ hostRefCache.set(container, ref);
4643
+ }
4644
+ renderVdom(ref, vnode);
4553
4645
  }
4554
4646
  //#endregion
4555
4647
  //#region src/runtime/tag-transform.ts
@@ -4774,4 +4866,4 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
4774
4866
  }
4775
4867
  };
4776
4868
  //#endregion
4777
- export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, h, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, render, renderVdom, resolveVar, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setScopedSSR, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, supportsShadow, transformTag, win, writeTask };
4869
+ export { AttachInternals, AttrDeserialize, BUILD, Build, Component, Element$1 as Element, Env, Event, Fragment, H, H as HTMLElement, HYDRATED_STYLE_ID, Host, Listen, Method, Mixin, NAMESPACE, Prop, PropSerialize, STENCIL_DEV_MODE, State, Watch, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, h, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, normalizeWatchers, parsePropertyValue, plt, postUpdateComponent, promiseResolve, proxyComponent, proxyCustomElement, readTask, registerHost, registerInstance, render, renderVdom, resolveVar, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setPlatformOptions, setScopedSsr, setTagTransformer, setValue, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, supportsShadow, transformTag, win, writeTask };
@@ -1,16 +1,16 @@
1
- import { _ as ResolutionHandler, a as ComponentRuntimeMeta, c as HostRef, d as RenderNode, f as RuntimeRef, g as JSXBase, h as HTMLStencilElement, i as ComponentRuntimeHostListener, l as LazyBundlesRuntimeData, n as ChildType, o as ComponentRuntimeMetaCompact, p as CustomElementsDefineOptions, r as ComponentConstructor, s as HostElement, u as PlatformRuntime, v as TagTransformer, y as VNode } from "../index-CyrGY82h.js";
2
- import { n as jsxs, r as Fragment, t as jsx } from "../jsx-runtime-DlDkTqps.js";
1
+ import { _ as JSXBase, a as ComponentRuntimeHostListener, b as VNode, c as HostElement, d as PlatformRuntime, f as RenderNode, g as HTMLStencilElement, i as ComponentConstructorChangeHandlers, l as HostRef, m as CustomElementsDefineOptions, n as ChildType, o as ComponentRuntimeMeta, p as RuntimeRef, r as ComponentConstructor, s as ComponentRuntimeMetaCompact, u as LazyBundlesRuntimeData, v as ResolutionHandler, y as TagTransformer } from "../index-D61XZw0f.js";
2
+ import { n as jsxs, r as Fragment, t as jsx } from "../jsx-runtime-B3vQbWIW.js";
3
3
 
4
4
  //#region src/runtime/asset-path.d.ts
5
5
  declare const getAssetPath: (path: string) => string;
6
6
  declare const setAssetPath: (path: string) => string;
7
7
  //#endregion
8
- //#region src/runtime/bootstrap-custom-element.d.ts
8
+ //#region src/runtime/bootstrap-standalone.d.ts
9
9
  declare const defineCustomElement: (Cstr: any, compactMeta: ComponentRuntimeMetaCompact) => void;
10
10
  declare const proxyCustomElement: (Cstr: any, compactMeta: ComponentRuntimeMetaCompact) => any;
11
11
  declare const forceModeUpdate: (elm: RenderNode) => void;
12
12
  //#endregion
13
- //#region src/runtime/bootstrap-lazy.d.ts
13
+ //#region src/runtime/bootstrap-loader.d.ts
14
14
  declare const bootstrapLazy: (lazyBundles: LazyBundlesRuntimeData, options?: CustomElementsDefineOptions) => void;
15
15
  //#endregion
16
16
  //#region src/runtime/connected-callback.d.ts
@@ -59,6 +59,30 @@ declare const getMode: (ref: RuntimeRef) => string;
59
59
  */
60
60
  declare const setNonce: (nonce: string) => string;
61
61
  //#endregion
62
+ //#region src/runtime/normalize-watchers.d.ts
63
+ /**
64
+ * Normalizes watcher metadata to the current `{ [methodName]: flags }[]` format.
65
+ *
66
+ * Prior to Stencil 4.39.x (PR #6484), the `@Watch()` compiler emitted watcher
67
+ * handlers as a plain string array: `{ "min": ["minChanged"] }`. The new format
68
+ * wraps each entry in an object that carries option flags (e.g. `immediate`):
69
+ * `{ "min": [{ "minChanged": 0 }] }`.
70
+ *
71
+ * When a library (e.g. Ionic Framework) was compiled with an older Stencil compiler
72
+ * but consumed by an app using a newer Stencil runtime, the runtime's
73
+ * `Object.entries(watcher)` call receives a string and misinterprets its character
74
+ * indices as method names, causing:
75
+ * `TypeError: instance[watchMethodName] is not a function`
76
+ *
77
+ * This helper should be used at `$watchers$` assignment sites that need to
78
+ * accept both legacy and current compiler metadata so downstream code on those
79
+ * paths can safely assume the new object format.
80
+ *
81
+ * @param raw The raw watcher map from compiled metadata (new or legacy format).
82
+ * @returns A normalized watcher map in the `{ [methodName]: flags }[]` format, or `undefined` if `raw` is `undefined` or empty.
83
+ */
84
+ declare const normalizeWatchers: (raw: ComponentConstructorChangeHandlers | undefined) => ComponentConstructorChangeHandlers | undefined;
85
+ //#endregion
62
86
  //#region src/runtime/parse-property-value.d.ts
63
87
  /**
64
88
  * Parse a new property value for a given property type.
@@ -117,6 +141,10 @@ declare const proxyComponent: (Cstr: ComponentConstructor, cmpMeta: ComponentRun
117
141
  /**
118
142
  * Method to render a virtual DOM tree to a container element.
119
143
  *
144
+ * Supports efficient re-renders: calling `render()` again on the same container
145
+ * will diff the new VNode tree against the previous one and only update what changed,
146
+ * preserving existing DOM elements and their state.
147
+ *
120
148
  * @example
121
149
  * ```tsx
122
150
  * import { render } from '@stencil/core';
@@ -191,4 +219,4 @@ declare const insertVdomAnnotations: (doc: Document, staticComponents: string[])
191
219
  */
192
220
  declare const renderVdom: (hostRef: HostRef, renderFnResults: VNode | VNode[], isInitialLoad?: boolean) => void;
193
221
  //#endregion
194
- export { Fragment, type HTMLStencilElement, HYDRATED_STYLE_ID, Host, type JSXBase, Mixin, addHostEventListeners, bootstrapLazy, connectedCallback, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getMode, getRenderingRef, getShadowRoot, getValue, h, insertVdomAnnotations, jsx, jsxs, parsePropertyValue, postUpdateComponent, proxyComponent, proxyCustomElement, render, renderVdom, setAssetPath, setMode, setNonce, setPlatformOptions, setTagTransformer, setValue, transformTag };
222
+ export { Fragment, type HTMLStencilElement, HYDRATED_STYLE_ID, Host, type JSXBase, Mixin, addHostEventListeners, bootstrapLazy, connectedCallback, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getMode, getRenderingRef, getShadowRoot, getValue, h, insertVdomAnnotations, jsx, jsxs, normalizeWatchers, parsePropertyValue, postUpdateComponent, proxyComponent, proxyCustomElement, render, renderVdom, setAssetPath, setMode, setNonce, setPlatformOptions, setTagTransformer, setValue, transformTag };
@@ -1,2 +1,2 @@
1
- import { A as h, C as postUpdateComponent, D as getMode, E as parsePropertyValue, F as HYDRATED_STYLE_ID, M as getShadowRoot, N as getAssetPath, O as setMode, P as setAssetPath, S as getRenderingRef, T as createEvent, _ as connectedCallback, a as transformTag, b as setValue, c as setNonce, d as Fragment, f as bootstrapLazy, g as disconnectedCallback, h as proxyCustomElement, i as setTagTransformer, j as getElement, k as Host, l as Mixin, m as forceModeUpdate, n as jsx, o as render, p as defineCustomElement, r as jsxs, s as setPlatformOptions, t as insertVdomAnnotations, u as addHostEventListeners, v as proxyComponent, w as renderVdom, x as forceUpdate, y as getValue } from "../runtime-BBCnuprF.js";
2
- export { Fragment, HYDRATED_STYLE_ID, Host, Mixin, addHostEventListeners, bootstrapLazy, connectedCallback, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getMode, getRenderingRef, getShadowRoot, getValue, h, insertVdomAnnotations, jsx, jsxs, parsePropertyValue, postUpdateComponent, proxyComponent, proxyCustomElement, render, renderVdom, setAssetPath, setMode, setNonce, setPlatformOptions, setTagTransformer, setValue, transformTag };
1
+ import { A as Host, C as postUpdateComponent, D as normalizeWatchers, E as parsePropertyValue, F as setAssetPath, I as HYDRATED_STYLE_ID, M as getElement, N as getShadowRoot, O as getMode, P as getAssetPath, S as getRenderingRef, T as createEvent, _ as connectedCallback, a as transformTag, b as setValue, c as setNonce, d as Fragment, f as bootstrapLazy, g as disconnectedCallback, h as proxyCustomElement, i as setTagTransformer, j as h, k as setMode, l as Mixin, m as forceModeUpdate, n as jsx, o as render, p as defineCustomElement, r as jsxs, s as setPlatformOptions, t as insertVdomAnnotations, u as addHostEventListeners, v as proxyComponent, w as renderVdom, x as forceUpdate, y as getValue } from "../runtime-CKyUrF4i.js";
2
+ export { Fragment, HYDRATED_STYLE_ID, Host, Mixin, addHostEventListeners, bootstrapLazy, connectedCallback, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getMode, getRenderingRef, getShadowRoot, getValue, h, insertVdomAnnotations, jsx, jsxs, normalizeWatchers, parsePropertyValue, postUpdateComponent, proxyComponent, proxyCustomElement, render, renderVdom, setAssetPath, setMode, setNonce, setPlatformOptions, setTagTransformer, setValue, transformTag };