@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.
- package/dist/{client-CSm3x5ke.mjs → client-Dnio47yQ.mjs} +108 -19
- package/dist/compiler/index.d.mts +2 -2
- package/dist/compiler/index.mjs +2 -2
- package/dist/compiler/utils/index.d.mts +2 -2
- package/dist/compiler/utils/index.mjs +3 -3
- package/dist/{compiler-D6iP7Bzb.mjs → compiler-Dxri2g8Z.mjs} +14994 -14303
- package/dist/declarations/stencil-public-compiler.d.ts +342 -132
- package/dist/declarations/stencil-public-compiler.js +2 -3
- package/dist/declarations/stencil-public-runtime.d.ts +2 -0
- package/dist/{index-hS-KBdAP.d.ts → index-D-XN9HW_.d.ts} +1 -1
- package/dist/{index-tUR6pD3J.d.mts → index-D5zaocDq.d.mts} +411 -189
- package/dist/{index-CyrGY82h.d.ts → index-D61XZw0f.d.ts} +2 -2
- package/dist/{index-CXHCTQNt.d.mts → index-Dat4djoo.d.mts} +5 -1
- package/dist/index.mjs +1 -1
- package/dist/{jsx-runtime-DlDkTqps.d.ts → jsx-runtime-B3vQbWIW.d.ts} +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/{node-Bg-mO5dw.mjs → node-pj6rF4Wt.mjs} +66 -69
- package/dist/{regular-expression-D5pGVpCu.mjs → regular-expression-D0_N0PGa.mjs} +44 -26
- package/dist/runtime/app-data/index.d.ts +1 -1
- package/dist/runtime/client/index.d.ts +45 -8
- package/dist/runtime/client/index.js +132 -40
- package/dist/runtime/index.d.ts +33 -5
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/server/index.d.mts +72 -28
- package/dist/runtime/server/index.mjs +146 -46
- package/dist/runtime/server/runner.d.mts +40 -26
- package/dist/runtime/server/runner.mjs +28 -22
- package/dist/{runtime-BBCnuprF.js → runtime-CKyUrF4i.js} +131 -39
- package/dist/sys/node/index.d.mts +1 -1
- package/dist/sys/node/index.mjs +1 -1
- package/dist/sys/node/worker.mjs +2 -2
- package/dist/testing/index.d.mts +2 -2
- package/dist/testing/index.mjs +17 -16
- package/dist/{validation-Byxie0Uk.mjs → validation-BA8nzXu_.mjs} +82 -58
- package/package.json +11 -12
|
@@ -147,7 +147,7 @@ interface CustomElementsDefineOptions {
|
|
|
147
147
|
}
|
|
148
148
|
//#endregion
|
|
149
149
|
//#region src/declarations/stencil-public-compiler.d.ts
|
|
150
|
-
interface
|
|
150
|
+
interface SsrDocumentOptions {
|
|
151
151
|
/**
|
|
152
152
|
* Build ID that will be added to `<html data-stencil-build="BUILD_ID">`. By default
|
|
153
153
|
* a random ID will be generated
|
|
@@ -164,7 +164,7 @@ interface HydrateDocumentOptions {
|
|
|
164
164
|
* JavaScript to read the structure of the HTML and rebuild each
|
|
165
165
|
* component. Defaults to `true`.
|
|
166
166
|
*/
|
|
167
|
-
|
|
167
|
+
clientSsrAnnotations?: boolean;
|
|
168
168
|
/**
|
|
169
169
|
* Constrain `setTimeout()` to 1ms, but still async. Also
|
|
170
170
|
* only allows `setInterval()` to fire once, also constrained to 1ms.
|
|
@@ -263,10 +263,14 @@ interface HydrateDocumentOptions {
|
|
|
263
263
|
default: 'declarative-shadow-dom' | 'scoped';
|
|
264
264
|
} | boolean;
|
|
265
265
|
}
|
|
266
|
-
interface SerializeDocumentOptions extends
|
|
266
|
+
interface SerializeDocumentOptions extends SsrDocumentOptions {
|
|
267
267
|
/**
|
|
268
268
|
* Runs after the `document` has been hydrated.
|
|
269
269
|
*/
|
|
270
|
+
afterSsr?(document: any): any | Promise<any>;
|
|
271
|
+
/**
|
|
272
|
+
* @deprecated Use `afterSsr` instead.
|
|
273
|
+
*/
|
|
270
274
|
afterHydrate?(document: any): any | Promise<any>;
|
|
271
275
|
/**
|
|
272
276
|
* Sets an approximate line width the HTML should attempt to stay within.
|
|
@@ -279,6 +283,10 @@ interface SerializeDocumentOptions extends HydrateDocumentOptions {
|
|
|
279
283
|
/**
|
|
280
284
|
* Runs before the `document` has been hydrated.
|
|
281
285
|
*/
|
|
286
|
+
beforeSsr?(document: any): any | Promise<any>;
|
|
287
|
+
/**
|
|
288
|
+
* @deprecated Use `beforeSsr` instead.
|
|
289
|
+
*/
|
|
282
290
|
beforeHydrate?(document: any): any | Promise<any>;
|
|
283
291
|
/**
|
|
284
292
|
* Format the HTML in a nicely indented format.
|
|
@@ -316,7 +324,7 @@ interface SerializeDocumentOptions extends HydrateDocumentOptions {
|
|
|
316
324
|
*/
|
|
317
325
|
modes?: ResolutionHandler[];
|
|
318
326
|
}
|
|
319
|
-
interface
|
|
327
|
+
interface SsrFactoryOptions extends SerializeDocumentOptions {
|
|
320
328
|
serializeToHtml: boolean;
|
|
321
329
|
destroyWindow: boolean;
|
|
322
330
|
destroyDocument: boolean;
|
|
@@ -466,7 +474,7 @@ interface HostElement extends HTMLElement {
|
|
|
466
474
|
['s-p']?: Promise<void>[];
|
|
467
475
|
componentOnReady?: () => Promise<this>;
|
|
468
476
|
}
|
|
469
|
-
interface
|
|
477
|
+
interface SsrResults {
|
|
470
478
|
buildId: string;
|
|
471
479
|
diagnostics: Diagnostic[];
|
|
472
480
|
url: string;
|
|
@@ -478,42 +486,42 @@ interface HydrateResults {
|
|
|
478
486
|
search: string | null;
|
|
479
487
|
hash: string | null;
|
|
480
488
|
html: string | null;
|
|
481
|
-
components:
|
|
482
|
-
anchors:
|
|
483
|
-
imgs:
|
|
484
|
-
scripts:
|
|
485
|
-
styles:
|
|
486
|
-
staticData:
|
|
489
|
+
components: SsrComponent[];
|
|
490
|
+
anchors: SsrAnchorElement[];
|
|
491
|
+
imgs: SsrImgElement[];
|
|
492
|
+
scripts: SsrScriptElement[];
|
|
493
|
+
styles: SsrStyleElement[];
|
|
494
|
+
staticData: SsrStaticData[];
|
|
487
495
|
title: string | null;
|
|
488
496
|
hydratedCount: number;
|
|
489
497
|
httpStatus: number | null;
|
|
490
498
|
}
|
|
491
|
-
interface
|
|
499
|
+
interface SsrComponent {
|
|
492
500
|
tag: string;
|
|
493
501
|
mode: string;
|
|
494
502
|
count: number;
|
|
495
503
|
depth: number;
|
|
496
504
|
}
|
|
497
|
-
interface
|
|
505
|
+
interface SsrElement {
|
|
498
506
|
[attrName: string]: string | undefined;
|
|
499
507
|
}
|
|
500
|
-
interface
|
|
508
|
+
interface SsrAnchorElement extends SsrElement {
|
|
501
509
|
href?: string;
|
|
502
510
|
target?: string;
|
|
503
511
|
}
|
|
504
|
-
interface
|
|
512
|
+
interface SsrImgElement extends SsrElement {
|
|
505
513
|
src?: string;
|
|
506
514
|
}
|
|
507
|
-
interface
|
|
515
|
+
interface SsrScriptElement extends SsrElement {
|
|
508
516
|
src?: string;
|
|
509
517
|
type?: string;
|
|
510
518
|
}
|
|
511
|
-
interface
|
|
519
|
+
interface SsrStyleElement extends SsrElement {
|
|
512
520
|
id?: string;
|
|
513
521
|
href?: string;
|
|
514
522
|
content?: string;
|
|
515
523
|
}
|
|
516
|
-
interface
|
|
524
|
+
interface SsrStaticData {
|
|
517
525
|
id: string;
|
|
518
526
|
type: string;
|
|
519
527
|
content: string;
|
|
@@ -928,19 +936,26 @@ type ChildType = VNode | number | string;
|
|
|
928
936
|
//#region src/server/platform/h-async.d.ts
|
|
929
937
|
declare const hAsync: (nodeName: any, vnodeData: any, ...children: ChildType[]) => VNode | Promise<VNode>;
|
|
930
938
|
//#endregion
|
|
931
|
-
//#region src/server/platform/
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
939
|
+
//#region src/server/platform/ssr-app.d.ts
|
|
940
|
+
/**
|
|
941
|
+
* SSR a Document by patching the DOM APIs to wait for components to be connected and hydrated
|
|
942
|
+
* before allowing them to be added to the document.
|
|
943
|
+
* Once all components are hydrated, the `afterSsr` callback is called so that the caller can serialize
|
|
944
|
+
* the document to HTML and send it back to the client.
|
|
945
|
+
* @param win The window to use for SSR. This should be a patched window created by `patchDomImplementation`.
|
|
946
|
+
* @param opts The options to use for SSR. This is used to configure which components should be hydrated, how long to wait for hydration, etc.
|
|
947
|
+
* @param results The results object to store the hydration results.
|
|
948
|
+
* @param afterSsr The callback to be called after SSR is complete.
|
|
949
|
+
* @param resolve The resolve function to be called when SSR is complete.
|
|
950
|
+
*/
|
|
951
|
+
declare function ssrApp(win: Window & typeof globalThis, opts: SsrFactoryOptions, results: SsrResults, afterSsr: (win: Window, opts: SsrFactoryOptions, results: SsrResults, resolve: (results: SsrResults) => void) => void, resolve: (results: SsrResults) => void): void;
|
|
937
952
|
//#endregion
|
|
938
|
-
//#region src/runtime/bootstrap-
|
|
953
|
+
//#region src/runtime/bootstrap-standalone.d.ts
|
|
939
954
|
declare const defineCustomElement: (Cstr: any, compactMeta: ComponentRuntimeMetaCompact) => void;
|
|
940
955
|
declare const proxyCustomElement: (Cstr: any, compactMeta: ComponentRuntimeMetaCompact) => any;
|
|
941
956
|
declare const forceModeUpdate: (elm: RenderNode) => void;
|
|
942
957
|
//#endregion
|
|
943
|
-
//#region src/runtime/bootstrap-
|
|
958
|
+
//#region src/runtime/bootstrap-loader.d.ts
|
|
944
959
|
declare const bootstrapLazy: (lazyBundles: LazyBundlesRuntimeData, options?: CustomElementsDefineOptions) => void;
|
|
945
960
|
//#endregion
|
|
946
961
|
//#region src/runtime/connected-callback.d.ts
|
|
@@ -951,6 +966,18 @@ declare const disconnectedCallback: (elm: HostElement) => Promise<void>;
|
|
|
951
966
|
//#endregion
|
|
952
967
|
//#region src/runtime/element.d.ts
|
|
953
968
|
declare const getElement: (ref: any) => HostElement;
|
|
969
|
+
/**
|
|
970
|
+
* Get the shadow root for a Stencil component's host element.
|
|
971
|
+
* This works for both open and closed shadow DOM modes.
|
|
972
|
+
*
|
|
973
|
+
* For closed shadow DOM, `element.shadowRoot` returns `null` by design,
|
|
974
|
+
* but Stencil stores the reference internally so components can still
|
|
975
|
+
* access their own shadow root.
|
|
976
|
+
*
|
|
977
|
+
* @param element The host element (from @Element() decorator)
|
|
978
|
+
* @returns The shadow root, or null if no shadow root exists
|
|
979
|
+
*/
|
|
980
|
+
declare const getShadowRoot: (element: HTMLElement) => ShadowRoot | null;
|
|
954
981
|
//#endregion
|
|
955
982
|
//#region src/runtime/event-emitter.d.ts
|
|
956
983
|
declare const createEvent: (ref: RuntimeRef, name: string, flags: number) => {
|
|
@@ -1134,11 +1161,28 @@ declare const registerHost: (elm: HostElement, cmpMeta: ComponentRuntimeMeta) =>
|
|
|
1134
1161
|
declare const Build: UserBuildConditionals;
|
|
1135
1162
|
declare const styles: StyleMap;
|
|
1136
1163
|
declare const modeResolutionChain: ResolutionHandler[];
|
|
1164
|
+
/**
|
|
1165
|
+
* Server-side implementation of getAssetPath.
|
|
1166
|
+
*
|
|
1167
|
+
* Unlike the client-side version, this doesn't use import.meta.url as a fallback
|
|
1168
|
+
* because it doesn't make sense in the bundled hydrate factory context.
|
|
1169
|
+
* The base URL must come from plt.$resourcesUrl$ (set via hydration options).
|
|
1170
|
+
* @param path - The relative path to the asset
|
|
1171
|
+
* @returns The resolved asset path, which may be an absolute URL if resourcesUrl is set to an external URL, or a relative path if resourcesUrl is a relative path or not set at all
|
|
1172
|
+
*/
|
|
1173
|
+
declare const getAssetPath: (path: string) => string;
|
|
1174
|
+
/**
|
|
1175
|
+
* Sets the base URL for resolving asset paths in the server/hydrate context.
|
|
1176
|
+
* @param path - The base URL to use for resolving asset paths. This should typically be set to the same value as the `resourcesUrl` option passed to `ssrDocument` to ensure that asset paths are resolved correctly in the server/hydrate context.
|
|
1177
|
+
* If not set, it defaults to './', which is a reasonable default for server-side rendering.
|
|
1178
|
+
* @returns void
|
|
1179
|
+
*/
|
|
1180
|
+
declare const setAssetPath: (path: string) => string;
|
|
1137
1181
|
/**
|
|
1138
1182
|
* Checks to see any components are rendered with `scoped`
|
|
1139
1183
|
* @param opts - SSR options
|
|
1140
1184
|
*/
|
|
1141
|
-
declare const
|
|
1185
|
+
declare const setScopedSsr: (opts: SsrFactoryOptions) => void;
|
|
1142
1186
|
declare const needsScopedSSR: () => boolean;
|
|
1143
1187
|
//#endregion
|
|
1144
|
-
export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getValue, hAsync as h,
|
|
1188
|
+
export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, hAsync as h, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, parsePropertyValue, plt, postUpdateComponent, proxyComponent, proxyCustomElement, readTask, registerComponents, registerHost, registerInstance, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setScopedSsr, setTagTransformer, setValue, ssrApp, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, supportsShadow, transformTag, win, writeTask };
|
|
@@ -173,14 +173,6 @@ const reWireGetterSetter = (instance, hostRef) => {
|
|
|
173
173
|
});
|
|
174
174
|
};
|
|
175
175
|
//#endregion
|
|
176
|
-
//#region src/runtime/asset-path.ts
|
|
177
|
-
const getAssetPath = (path) => {
|
|
178
|
-
const base = plt.$resourcesUrl$ || new URL(".", import.meta.url).href;
|
|
179
|
-
const assetUrl = new URL(path, base);
|
|
180
|
-
return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
|
|
181
|
-
};
|
|
182
|
-
const setAssetPath = (path) => plt.$resourcesUrl$ = path;
|
|
183
|
-
//#endregion
|
|
184
176
|
//#region src/runtime/runtime-constants.ts
|
|
185
177
|
/**
|
|
186
178
|
* Bit flags for recording various properties of VDom nodes
|
|
@@ -1102,7 +1094,8 @@ const addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
|
1102
1094
|
styleElm.textContent = style;
|
|
1103
1095
|
const nonce = plt.$nonce$ ?? queryNonceMetaTagContent(win.document);
|
|
1104
1096
|
if (nonce != null) styleElm.setAttribute("nonce", nonce);
|
|
1105
|
-
if (
|
|
1097
|
+
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);
|
|
1098
|
+
if (BUILD$1.hotModuleReplacement && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation) styleElm.setAttribute("data-slot-fb", "");
|
|
1106
1099
|
/**
|
|
1107
1100
|
* attach styles at the end of the head tag if we render scoped components
|
|
1108
1101
|
*/
|
|
@@ -2205,6 +2198,46 @@ const computeMode = (elm) => modeResolutionChain.map((h) => h(elm)).find((m) =>
|
|
|
2205
2198
|
const setMode = (handler) => modeResolutionChain.push(handler);
|
|
2206
2199
|
const getMode = (ref) => getHostRef(ref)?.$modeName$;
|
|
2207
2200
|
//#endregion
|
|
2201
|
+
//#region src/runtime/normalize-watchers.ts
|
|
2202
|
+
/**
|
|
2203
|
+
* Normalizes watcher metadata to the current `{ [methodName]: flags }[]` format.
|
|
2204
|
+
*
|
|
2205
|
+
* Prior to Stencil 4.39.x (PR #6484), the `@Watch()` compiler emitted watcher
|
|
2206
|
+
* handlers as a plain string array: `{ "min": ["minChanged"] }`. The new format
|
|
2207
|
+
* wraps each entry in an object that carries option flags (e.g. `immediate`):
|
|
2208
|
+
* `{ "min": [{ "minChanged": 0 }] }`.
|
|
2209
|
+
*
|
|
2210
|
+
* When a library (e.g. Ionic Framework) was compiled with an older Stencil compiler
|
|
2211
|
+
* but consumed by an app using a newer Stencil runtime, the runtime's
|
|
2212
|
+
* `Object.entries(watcher)` call receives a string and misinterprets its character
|
|
2213
|
+
* indices as method names, causing:
|
|
2214
|
+
* `TypeError: instance[watchMethodName] is not a function`
|
|
2215
|
+
*
|
|
2216
|
+
* This helper should be used at `$watchers$` assignment sites that need to
|
|
2217
|
+
* accept both legacy and current compiler metadata so downstream code on those
|
|
2218
|
+
* paths can safely assume the new object format.
|
|
2219
|
+
*
|
|
2220
|
+
* @param raw The raw watcher map from compiled metadata (new or legacy format).
|
|
2221
|
+
* @returns A normalized watcher map in the `{ [methodName]: flags }[]` format, or `undefined` if `raw` is `undefined` or empty.
|
|
2222
|
+
*/
|
|
2223
|
+
const normalizeWatchers = (raw) => {
|
|
2224
|
+
if (!raw) return void 0;
|
|
2225
|
+
const keys = Object.keys(raw);
|
|
2226
|
+
if (keys.length === 0) return void 0;
|
|
2227
|
+
let hasLegacy = false;
|
|
2228
|
+
for (const propName of keys) {
|
|
2229
|
+
if (hasLegacy) break;
|
|
2230
|
+
for (const h of raw[propName]) if (typeof h === "string") {
|
|
2231
|
+
hasLegacy = true;
|
|
2232
|
+
break;
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
if (!hasLegacy) return raw;
|
|
2236
|
+
const out = {};
|
|
2237
|
+
for (const propName of keys) out[propName] = raw[propName].map((h) => typeof h === "string" ? { [h]: 0 } : h);
|
|
2238
|
+
return out;
|
|
2239
|
+
};
|
|
2240
|
+
//#endregion
|
|
2208
2241
|
//#region src/runtime/parse-property-value.ts
|
|
2209
2242
|
/**
|
|
2210
2243
|
* Parse a new property value for a given property type.
|
|
@@ -3555,7 +3588,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
3555
3588
|
});
|
|
3556
3589
|
if (BUILD$1.member && cmpMeta.$members$ || BUILD$1.propChangeCallback) {
|
|
3557
3590
|
if (BUILD$1.propChangeCallback) {
|
|
3558
|
-
if (Cstr.watchers && !cmpMeta.$watchers$) cmpMeta.$watchers$ = Cstr.watchers;
|
|
3591
|
+
if (Cstr.watchers && !cmpMeta.$watchers$) cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
|
|
3559
3592
|
if (Cstr.deserializers && !cmpMeta.$deserializers$) cmpMeta.$deserializers$ = Cstr.deserializers;
|
|
3560
3593
|
if (Cstr.serializers && !cmpMeta.$serializers$) cmpMeta.$serializers$ = Cstr.serializers;
|
|
3561
3594
|
}
|
|
@@ -3660,9 +3693,11 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
3660
3693
|
return;
|
|
3661
3694
|
}
|
|
3662
3695
|
const propFlags = members.find(([m]) => m === propName);
|
|
3663
|
-
|
|
3696
|
+
const isBooleanTarget = propFlags && propFlags[1][0] & MEMBER_FLAGS.Boolean;
|
|
3697
|
+
const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
|
|
3698
|
+
if (isBooleanTarget) newValue = !(newValue === null || newValue === "false");
|
|
3664
3699
|
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
|
|
3665
|
-
if (newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
3700
|
+
if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
3666
3701
|
});
|
|
3667
3702
|
};
|
|
3668
3703
|
Cstr.observedAttributes = Array.from(new Set([...Object.keys(cmpMeta.$watchers$ ?? {}), ...members.filter(([_, m]) => m[0] & MEMBER_FLAGS.HasAttribute).map(([propName, m]) => {
|
|
@@ -3703,7 +3738,7 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
3703
3738
|
if (!Cstr) throw new Error(`Constructor for "${cmpMeta.$tagName$}#${hostRef.$modeName$}" was not found`);
|
|
3704
3739
|
if (BUILD$1.member && !Cstr.isProxied) {
|
|
3705
3740
|
if (BUILD$1.propChangeCallback) {
|
|
3706
|
-
cmpMeta.$watchers$ = Cstr.watchers;
|
|
3741
|
+
cmpMeta.$watchers$ = normalizeWatchers(Cstr.watchers);
|
|
3707
3742
|
cmpMeta.$serializers$ = Cstr.serializers;
|
|
3708
3743
|
cmpMeta.$deserializers$ = Cstr.deserializers;
|
|
3709
3744
|
}
|
|
@@ -3879,7 +3914,59 @@ const disconnectedCallback = async (elm) => {
|
|
|
3879
3914
|
if (elm.shadowRoot && rootAppliedStyles.has(elm.shadowRoot)) rootAppliedStyles.delete(elm.shadowRoot);
|
|
3880
3915
|
};
|
|
3881
3916
|
//#endregion
|
|
3882
|
-
//#region src/runtime/
|
|
3917
|
+
//#region src/runtime/hmr-component.ts
|
|
3918
|
+
/**
|
|
3919
|
+
* Kick off hot-module-replacement for a component. In order to replace the
|
|
3920
|
+
* component in-place we:
|
|
3921
|
+
*
|
|
3922
|
+
* 1. get a reference to the {@link d.HostRef} for the element
|
|
3923
|
+
* 2. reset the element's runtime flags
|
|
3924
|
+
* 3. re-run the initialization logic for the element (via
|
|
3925
|
+
* {@link initializeComponent})
|
|
3926
|
+
*
|
|
3927
|
+
* For standalone (non-lazy) builds, we instead re-import the component module
|
|
3928
|
+
* and patch the prototype of the registered constructor in-place, then
|
|
3929
|
+
* force a re-render of all existing instances in the DOM.
|
|
3930
|
+
*
|
|
3931
|
+
* @param hostElement the host element for the component which we want to start
|
|
3932
|
+
* doing HMR
|
|
3933
|
+
* @param cmpMeta runtime metadata for the component
|
|
3934
|
+
* @param hmrVersionId the current HMR version ID
|
|
3935
|
+
*/
|
|
3936
|
+
const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
|
|
3937
|
+
if (BUILD$1.lazyLoad) {
|
|
3938
|
+
const hostRef = getHostRef(hostElement);
|
|
3939
|
+
if (!hostRef) return;
|
|
3940
|
+
hostRef.$flags$ = HOST_FLAGS.hasConnected;
|
|
3941
|
+
initializeComponent(hostElement, hostRef, cmpMeta, hmrVersionId);
|
|
3942
|
+
} else hmrStandalone(hostElement, cmpMeta, hmrVersionId);
|
|
3943
|
+
};
|
|
3944
|
+
const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
3945
|
+
const modulePath = hostElement.constructor.__stencil_module__;
|
|
3946
|
+
console.log(`[Stencil HMR] hmrStandalone <${cmpMeta.$tagName$}> modulePath:`, modulePath);
|
|
3947
|
+
if (!modulePath) {
|
|
3948
|
+
console.warn(`[Stencil HMR] No __stencil_module__ on <${cmpMeta.$tagName$}> constructor — was this built with devMode?`);
|
|
3949
|
+
return;
|
|
3950
|
+
}
|
|
3951
|
+
try {
|
|
3952
|
+
const newModule = await import(
|
|
3953
|
+
/* @vite-ignore */
|
|
3954
|
+
`${modulePath}?s-hmr=${hmrVersionId}`
|
|
3955
|
+
);
|
|
3956
|
+
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
3957
|
+
if (!NewClass) return;
|
|
3958
|
+
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
3959
|
+
if (ctor) for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
3960
|
+
if (key === "constructor") continue;
|
|
3961
|
+
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
3962
|
+
}
|
|
3963
|
+
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => forceUpdate(el));
|
|
3964
|
+
} catch (e) {
|
|
3965
|
+
console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
|
|
3966
|
+
}
|
|
3967
|
+
};
|
|
3968
|
+
//#endregion
|
|
3969
|
+
//#region src/runtime/bootstrap-standalone.ts
|
|
3883
3970
|
const defineCustomElement = (Cstr, compactMeta) => {
|
|
3884
3971
|
customElements.define(transformTag(compactMeta[1]), proxyCustomElement(Cstr, compactMeta));
|
|
3885
3972
|
};
|
|
@@ -3893,12 +3980,15 @@ const proxyCustomElement = (Cstr, compactMeta) => {
|
|
|
3893
3980
|
if (BUILD$1.member) cmpMeta.$members$ = compactMeta[2];
|
|
3894
3981
|
if (BUILD$1.hostListener) cmpMeta.$listeners$ = compactMeta[3];
|
|
3895
3982
|
if (BUILD$1.propChangeCallback) {
|
|
3896
|
-
cmpMeta.$watchers$ = Cstr.$watchers
|
|
3983
|
+
cmpMeta.$watchers$ = normalizeWatchers(Cstr.$watchers$);
|
|
3897
3984
|
cmpMeta.$deserializers$ = Cstr.$deserializers$;
|
|
3898
3985
|
cmpMeta.$serializers$ = Cstr.$serializers$;
|
|
3899
3986
|
}
|
|
3900
3987
|
if (BUILD$1.reflect) cmpMeta.$attrsToReflect$ = [];
|
|
3901
3988
|
if (BUILD$1.shadowDom && !supportsShadow && cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation) cmpMeta.$flags$ |= CMP_FLAGS.needsShadowDomShim;
|
|
3989
|
+
if (BUILD$1.hotModuleReplacement) Cstr.prototype["s-hmr"] = function(hmrVersionId) {
|
|
3990
|
+
hmrStart(this, cmpMeta, hmrVersionId);
|
|
3991
|
+
};
|
|
3902
3992
|
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);
|
|
3903
3993
|
else {
|
|
3904
3994
|
if (BUILD$1.slotChildNodesFix || BUILD$1.patchChildren && cmpMeta.$flags$ & CMP_FLAGS.patchChildren) patchChildSlotNodes(Cstr.prototype);
|
|
@@ -3979,29 +4069,7 @@ const forceModeUpdate = (elm) => {
|
|
|
3979
4069
|
}
|
|
3980
4070
|
};
|
|
3981
4071
|
//#endregion
|
|
3982
|
-
//#region src/runtime/
|
|
3983
|
-
/**
|
|
3984
|
-
* Kick off hot-module-replacement for a component. In order to replace the
|
|
3985
|
-
* component in-place we:
|
|
3986
|
-
*
|
|
3987
|
-
* 1. get a reference to the {@link d.HostRef} for the element
|
|
3988
|
-
* 2. reset the element's runtime flags
|
|
3989
|
-
* 3. re-run the initialization logic for the element (via
|
|
3990
|
-
* {@link initializeComponent})
|
|
3991
|
-
*
|
|
3992
|
-
* @param hostElement the host element for the component which we want to start
|
|
3993
|
-
* doing HMR
|
|
3994
|
-
* @param cmpMeta runtime metadata for the component
|
|
3995
|
-
* @param hmrVersionId the current HMR version ID
|
|
3996
|
-
*/
|
|
3997
|
-
const hmrStart = (hostElement, cmpMeta, hmrVersionId) => {
|
|
3998
|
-
const hostRef = getHostRef(hostElement);
|
|
3999
|
-
if (!hostRef) return;
|
|
4000
|
-
hostRef.$flags$ = HOST_FLAGS.hasConnected;
|
|
4001
|
-
initializeComponent(hostElement, hostRef, cmpMeta, hmrVersionId);
|
|
4002
|
-
};
|
|
4003
|
-
//#endregion
|
|
4004
|
-
//#region src/runtime/bootstrap-lazy.ts
|
|
4072
|
+
//#region src/runtime/bootstrap-loader.ts
|
|
4005
4073
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
4006
4074
|
if (BUILD$1.profile && performance.mark) performance.mark("st:app:start");
|
|
4007
4075
|
installDevTools();
|
|
@@ -4035,7 +4103,7 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
4035
4103
|
if (BUILD$1.hostListener) cmpMeta.$listeners$ = compactMeta[3];
|
|
4036
4104
|
if (BUILD$1.reflect) cmpMeta.$attrsToReflect$ = [];
|
|
4037
4105
|
if (BUILD$1.propChangeCallback) {
|
|
4038
|
-
cmpMeta.$watchers$ = compactMeta[4]
|
|
4106
|
+
cmpMeta.$watchers$ = normalizeWatchers(compactMeta[4]);
|
|
4039
4107
|
cmpMeta.$serializers$ = compactMeta[5] ?? {};
|
|
4040
4108
|
cmpMeta.$deserializers$ = compactMeta[6] ?? {};
|
|
4041
4109
|
}
|
|
@@ -4487,15 +4555,26 @@ function componentOnReady() {
|
|
|
4487
4555
|
}
|
|
4488
4556
|
function forceUpdate$1() {}
|
|
4489
4557
|
//#endregion
|
|
4490
|
-
//#region src/server/platform/
|
|
4491
|
-
|
|
4558
|
+
//#region src/server/platform/ssr-app.ts
|
|
4559
|
+
/**
|
|
4560
|
+
* SSR a Document by patching the DOM APIs to wait for components to be connected and hydrated
|
|
4561
|
+
* before allowing them to be added to the document.
|
|
4562
|
+
* Once all components are hydrated, the `afterSsr` callback is called so that the caller can serialize
|
|
4563
|
+
* the document to HTML and send it back to the client.
|
|
4564
|
+
* @param win The window to use for SSR. This should be a patched window created by `patchDomImplementation`.
|
|
4565
|
+
* @param opts The options to use for SSR. This is used to configure which components should be hydrated, how long to wait for hydration, etc.
|
|
4566
|
+
* @param results The results object to store the hydration results.
|
|
4567
|
+
* @param afterSsr The callback to be called after SSR is complete.
|
|
4568
|
+
* @param resolve The resolve function to be called when SSR is complete.
|
|
4569
|
+
*/
|
|
4570
|
+
function ssrApp(win, opts, results, afterSsr, resolve) {
|
|
4492
4571
|
const connectedElements = /* @__PURE__ */ new Set();
|
|
4493
4572
|
const createdElements = /* @__PURE__ */ new Set();
|
|
4494
4573
|
const waitingElements = /* @__PURE__ */ new Set();
|
|
4495
4574
|
const orgDocumentCreateElement = win.document.createElement;
|
|
4496
4575
|
const orgDocumentCreateElementNS = win.document.createElementNS;
|
|
4497
4576
|
const resolved = Promise.resolve();
|
|
4498
|
-
|
|
4577
|
+
setScopedSsr(opts);
|
|
4499
4578
|
let tmrId;
|
|
4500
4579
|
let ranCompleted = false;
|
|
4501
4580
|
function hydratedComplete() {
|
|
@@ -4505,7 +4584,7 @@ function hydrateApp(win, opts, results, afterHydrate, resolve) {
|
|
|
4505
4584
|
if (!ranCompleted) {
|
|
4506
4585
|
ranCompleted = true;
|
|
4507
4586
|
try {
|
|
4508
|
-
if (opts.
|
|
4587
|
+
if (opts.clientSsrAnnotations) insertVdomAnnotations(win.document, opts.staticComponents);
|
|
4509
4588
|
win.dispatchEvent(new win.Event("DOMContentLoaded"));
|
|
4510
4589
|
win.document.createElement = orgDocumentCreateElement;
|
|
4511
4590
|
win.document.createElementNS = orgDocumentCreateElementNS;
|
|
@@ -4513,7 +4592,7 @@ function hydrateApp(win, opts, results, afterHydrate, resolve) {
|
|
|
4513
4592
|
renderCatchError(opts, results, e);
|
|
4514
4593
|
}
|
|
4515
4594
|
}
|
|
4516
|
-
|
|
4595
|
+
afterSsr(win, opts, results, resolve);
|
|
4517
4596
|
}
|
|
4518
4597
|
function hydratedError(err) {
|
|
4519
4598
|
renderCatchError(opts, results, err);
|
|
@@ -4844,13 +4923,34 @@ const Build = {
|
|
|
4844
4923
|
const styles = /* @__PURE__ */ new Map();
|
|
4845
4924
|
const modeResolutionChain = [];
|
|
4846
4925
|
/**
|
|
4926
|
+
* Server-side implementation of getAssetPath.
|
|
4927
|
+
*
|
|
4928
|
+
* Unlike the client-side version, this doesn't use import.meta.url as a fallback
|
|
4929
|
+
* because it doesn't make sense in the bundled hydrate factory context.
|
|
4930
|
+
* The base URL must come from plt.$resourcesUrl$ (set via hydration options).
|
|
4931
|
+
* @param path - The relative path to the asset
|
|
4932
|
+
* @returns The resolved asset path, which may be an absolute URL if resourcesUrl is set to an external URL, or a relative path if resourcesUrl is a relative path or not set at all
|
|
4933
|
+
*/
|
|
4934
|
+
const getAssetPath = (path) => {
|
|
4935
|
+
const base = plt.$resourcesUrl$ || "./";
|
|
4936
|
+
const assetUrl = new URL(path, base);
|
|
4937
|
+
return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
|
|
4938
|
+
};
|
|
4939
|
+
/**
|
|
4940
|
+
* Sets the base URL for resolving asset paths in the server/hydrate context.
|
|
4941
|
+
* @param path - The base URL to use for resolving asset paths. This should typically be set to the same value as the `resourcesUrl` option passed to `ssrDocument` to ensure that asset paths are resolved correctly in the server/hydrate context.
|
|
4942
|
+
* If not set, it defaults to './', which is a reasonable default for server-side rendering.
|
|
4943
|
+
* @returns void
|
|
4944
|
+
*/
|
|
4945
|
+
const setAssetPath = (path) => plt.$resourcesUrl$ = path;
|
|
4946
|
+
/**
|
|
4847
4947
|
* Checks to see any components are rendered with `scoped`
|
|
4848
4948
|
* @param opts - SSR options
|
|
4849
4949
|
*/
|
|
4850
|
-
const
|
|
4950
|
+
const setScopedSsr = (opts) => {
|
|
4851
4951
|
scopedSSR = BUILD$1.shadowDom && opts.serializeShadowRoot !== false && opts.serializeShadowRoot !== "declarative-shadow-dom";
|
|
4852
4952
|
};
|
|
4853
4953
|
const needsScopedSSR = () => scopedSSR;
|
|
4854
4954
|
let scopedSSR = false;
|
|
4855
4955
|
//#endregion
|
|
4856
|
-
export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getValue, hAsync as h,
|
|
4956
|
+
export { BUILD, Build, Env, Fragment, Host, Mixin, NAMESPACE, addHostEventListeners, bootstrapLazy, cmpModules, connectedCallback, consoleDevError, consoleDevInfo, consoleDevWarn, consoleError, createEvent, defineCustomElement, disconnectedCallback, forceModeUpdate, forceUpdate, getAssetPath, getElement, getHostRef, getMode, getRenderingRef, getShadowRoot, getValue, hAsync as h, insertVdomAnnotations, isMemberInElement, jsx, jsxs, loadModule, modeResolutionChain, needsScopedSSR, nextTick, parsePropertyValue, plt, postUpdateComponent, proxyComponent, proxyCustomElement, readTask, registerComponents, registerHost, registerInstance, renderVdom, setAssetPath, setErrorHandler, setMode, setNonce, setPlatformHelpers, setScopedSsr, setTagTransformer, setValue, ssrApp, styles, supportsConstructableStylesheets, supportsListenerOptions, supportsMutableAdoptedStyleSheets, supportsShadow, transformTag, win, writeTask };
|