@stencil/core 5.0.0-beta.3 → 5.0.0-beta.30
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/app-data/index.d.ts +1 -1
- package/dist/{client-BRu0GtRn.mjs → client-BYvfR_Hx.mjs} +127 -68
- package/dist/compiler/browser.d.ts +114 -81
- package/dist/compiler/browser.js +733 -336
- package/dist/compiler/index.d.mts +110 -2
- package/dist/compiler/index.mjs +3 -3
- package/dist/compiler/utils/index.d.mts +1 -1
- package/dist/{compiler-BPgV6bA4.mjs → compiler-6RhuOkQ0.mjs} +4829 -2895
- package/dist/declarations/stencil-public-compiler.d.ts +152 -129
- package/dist/declarations/stencil-public-docs.d.ts +23 -0
- package/dist/declarations/stencil-public-runtime.d.ts +60 -58
- package/dist/{index-DmHmu3y0.d.mts → index-BGUOG9Wc.d.mts} +6 -2
- package/dist/{index-BXAcVN2j.d.ts → index-BHciXst1.d.ts} +57 -55
- package/dist/{index-BopBfjPu.d.mts → index-BogZpjP2.d.mts} +150 -127
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.d.mts +6 -0
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/{node-75gQKkFz.mjs → node-CvPPhnWO.mjs} +41 -47
- package/dist/runtime/client/lazy.js +252 -189
- package/dist/runtime/client/runtime.d.ts +71 -66
- package/dist/runtime/client/runtime.js +252 -189
- package/dist/runtime/index.d.ts +4 -5
- package/dist/runtime/index.js +250 -187
- package/dist/runtime/server/index.d.mts +11 -11
- package/dist/runtime/server/index.mjs +302 -228
- package/dist/runtime/server/runner.d.mts +4 -4
- package/dist/runtime/server/runner.mjs +82 -54
- package/dist/signals/index.d.ts +11 -2
- package/dist/signals/index.js +14 -35
- 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 +136 -120
- package/dist/testing/index.mjs +259 -201
- package/package.json +8 -4
package/dist/testing/index.mjs
CHANGED
|
@@ -3,14 +3,15 @@ import { MockWindow, setupGlobal } from "@stencil/mock-doc";
|
|
|
3
3
|
import "typescript";
|
|
4
4
|
import fs from "node:fs";
|
|
5
5
|
import "picomatch";
|
|
6
|
-
import
|
|
6
|
+
import * as SignalsCore from "@preact/signals-core";
|
|
7
7
|
import path, { basename, dirname } from "path";
|
|
8
|
+
import resolve from "resolve";
|
|
8
9
|
import "postcss";
|
|
9
|
-
import "postcss-
|
|
10
|
+
import "postcss-nesting";
|
|
10
11
|
import "postcss-selector-parser";
|
|
12
|
+
import "postcss-safe-parser";
|
|
11
13
|
import "magic-string";
|
|
12
14
|
import "rolldown";
|
|
13
|
-
import resolve from "resolve";
|
|
14
15
|
import "rolldown/utils";
|
|
15
16
|
import "terser";
|
|
16
17
|
import "css-what";
|
|
@@ -32,7 +33,7 @@ import "@rollup/pluginutils";
|
|
|
32
33
|
import { createHash } from "crypto";
|
|
33
34
|
import { afterAll, vi } from "vitest";
|
|
34
35
|
//#region src/version.ts
|
|
35
|
-
const version = "5.0.0-beta.
|
|
36
|
+
const version = "5.0.0-beta.30";
|
|
36
37
|
const MEMBER_FLAGS = {
|
|
37
38
|
String: 1,
|
|
38
39
|
Number: 2,
|
|
@@ -379,6 +380,10 @@ const trimFalsy = (data) => {
|
|
|
379
380
|
*/
|
|
380
381
|
const isDef = (v) => v != null && v !== void 0;
|
|
381
382
|
/**
|
|
383
|
+
* This is just a no-op, don't expect it to do anything.
|
|
384
|
+
*/
|
|
385
|
+
const noop = () => {};
|
|
386
|
+
/**
|
|
382
387
|
* Check whether a value is a 'complex type', defined here as an object or a
|
|
383
388
|
* function.
|
|
384
389
|
*
|
|
@@ -640,7 +645,7 @@ const Env = {};
|
|
|
640
645
|
//#endregion
|
|
641
646
|
//#region src/testing/platform/testing-constants.ts
|
|
642
647
|
const styles = /* @__PURE__ */ new Map();
|
|
643
|
-
const
|
|
648
|
+
const modeResolver = [];
|
|
644
649
|
/**
|
|
645
650
|
* A mapping of custom element tags (e.g. `my-component`) to their constructor
|
|
646
651
|
*/
|
|
@@ -2110,7 +2115,19 @@ const hydrateScopedToShadow = () => {
|
|
|
2110
2115
|
registerStyle(scopeId, convertScopedToShadow(styleElements[i].innerHTML), allowCS);
|
|
2111
2116
|
}
|
|
2112
2117
|
};
|
|
2118
|
+
//#endregion
|
|
2119
|
+
//#region src/runtime/signals-core.ts
|
|
2120
|
+
const getCore = () => globalThis[Symbol.for("stencil.preact-signals-core")] ??= SignalsCore;
|
|
2121
|
+
const effect = (fn, options) => getCore().effect(fn, options);
|
|
2122
|
+
function signal(value, options) {
|
|
2123
|
+
return getCore().signal(value, options);
|
|
2124
|
+
}
|
|
2113
2125
|
const getRegistry = () => customElements;
|
|
2126
|
+
/**
|
|
2127
|
+
* @param elm a defined component host
|
|
2128
|
+
* @returns the registry the host's class was defined in, else the active registry
|
|
2129
|
+
*/
|
|
2130
|
+
const getHostRegistry = (elm) => elm.constructor._registry ?? getRegistry();
|
|
2114
2131
|
//#endregion
|
|
2115
2132
|
//#region src/runtime/vdom/set-accessor.ts
|
|
2116
2133
|
/**
|
|
@@ -2154,7 +2171,7 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
2154
2171
|
attrMap.get(memberName)?.();
|
|
2155
2172
|
if (!signalAttrDisposers.has(elm)) signalAttrDisposers.set(elm, attrMap);
|
|
2156
2173
|
let prevVal = oldValue;
|
|
2157
|
-
attrMap.set(memberName, effect
|
|
2174
|
+
attrMap.set(memberName, effect(() => {
|
|
2158
2175
|
const curVal = newValue.value;
|
|
2159
2176
|
setAccessor(elm, memberName, prevVal, curVal, isSvg, flags);
|
|
2160
2177
|
prevVal = curVal;
|
|
@@ -2234,10 +2251,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
2234
2251
|
const isComplex = isComplexType(newValue);
|
|
2235
2252
|
if (!BUILD.lazyLoad) {
|
|
2236
2253
|
const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
|
|
2237
|
-
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" &&
|
|
2254
|
+
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
|
|
2238
2255
|
if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
|
|
2239
2256
|
elm["s-pp"].set(memberName, newValue);
|
|
2240
|
-
return;
|
|
2257
|
+
if (isComplex || /[A-Z]/.test(memberName)) return;
|
|
2241
2258
|
}
|
|
2242
2259
|
}
|
|
2243
2260
|
if ((isProp || isComplex && newValue !== null) && !isSvg) try {
|
|
@@ -2355,6 +2372,7 @@ function sortedAttrNames(attrNames) {
|
|
|
2355
2372
|
let scopeId;
|
|
2356
2373
|
let contentRef;
|
|
2357
2374
|
let hostTagName;
|
|
2375
|
+
let hostRegistry;
|
|
2358
2376
|
let useNativeShadowDom = false;
|
|
2359
2377
|
let checkSlotFallbackVisibility = false;
|
|
2360
2378
|
let checkSlotRelocate = false;
|
|
@@ -2371,16 +2389,33 @@ const signalNodeDisposers = /* @__PURE__ */ new WeakMap();
|
|
|
2371
2389
|
const disposeSignalVNode = (vnode) => {
|
|
2372
2390
|
const elm = vnode.$elm$;
|
|
2373
2391
|
if (elm) {
|
|
2374
|
-
|
|
2375
|
-
if (dispose) {
|
|
2376
|
-
dispose();
|
|
2377
|
-
signalNodeDisposers.delete(elm);
|
|
2378
|
-
}
|
|
2392
|
+
disposeTextSignal(elm);
|
|
2379
2393
|
disposeAllSignalAttrs(elm);
|
|
2380
2394
|
}
|
|
2381
2395
|
vnode.$children$?.forEach(disposeSignalVNode);
|
|
2382
2396
|
};
|
|
2383
2397
|
/**
|
|
2398
|
+
* Tear down a text node's signal subscription, if it has one.
|
|
2399
|
+
* @param textNode the text node to unsubscribe
|
|
2400
|
+
*/
|
|
2401
|
+
const disposeTextSignal = (textNode) => {
|
|
2402
|
+
const dispose = signalNodeDisposers.get(textNode);
|
|
2403
|
+
if (dispose) {
|
|
2404
|
+
dispose();
|
|
2405
|
+
signalNodeDisposers.delete(textNode);
|
|
2406
|
+
}
|
|
2407
|
+
};
|
|
2408
|
+
/**
|
|
2409
|
+
* Subscribe a text node to a signal, keeping its `data` in sync on every change.
|
|
2410
|
+
* @param textNode the text node to keep in sync
|
|
2411
|
+
* @param textSig the signal to subscribe to
|
|
2412
|
+
*/
|
|
2413
|
+
const wireTextSignal = (textNode, textSig) => {
|
|
2414
|
+
signalNodeDisposers.set(textNode, effect(() => {
|
|
2415
|
+
textNode.data = String(textSig.value);
|
|
2416
|
+
}));
|
|
2417
|
+
};
|
|
2418
|
+
/**
|
|
2384
2419
|
* Create a DOM Node corresponding to one of the children of a given VNode.
|
|
2385
2420
|
*
|
|
2386
2421
|
* @param oldParentVNode the parent VNode from the previous render
|
|
@@ -2402,13 +2437,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
2402
2437
|
if (BUILD.isDev && newVNode.$elm$) consoleDevError(`The JSX ${newVNode.$text$ !== null ? `"${newVNode.$text$}" text` : `"${String(newVNode.$tag$)}" element`} node should not be shared within the same renderer. The renderer caches element lookups in order to improve performance. However, a side effect from this is that the exact same JSX node should not be reused. For more information please see https://stenciljs.com/docs/templating-jsx#avoid-shared-jsx-nodes`);
|
|
2403
2438
|
if (BUILD.vdomText && newVNode.$text$ != null) {
|
|
2404
2439
|
elm = newVNode.$elm$ = win.document.createTextNode(newVNode.$text$);
|
|
2405
|
-
if (BUILD.vdomSignals && newVNode.$signal$)
|
|
2406
|
-
const textSig = newVNode.$signal$;
|
|
2407
|
-
const textNode = elm;
|
|
2408
|
-
signalNodeDisposers.set(textNode, effect$1(() => {
|
|
2409
|
-
textNode.data = String(textSig.value);
|
|
2410
|
-
}));
|
|
2411
|
-
}
|
|
2440
|
+
if (BUILD.vdomSignals && newVNode.$signal$) wireTextSignal(elm, newVNode.$signal$);
|
|
2412
2441
|
} else if (BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotReference) {
|
|
2413
2442
|
elm = newVNode.$elm$ = BUILD.isDebug || BUILD.hydrateServerSide ? slotReferenceDebugNode(newVNode) : win.document.createTextNode("");
|
|
2414
2443
|
if (typeof newVNode.$attrs$?.slot === "string") elm["s-sa"] = newVNode.$attrs$.slot;
|
|
@@ -2417,8 +2446,7 @@ const createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
|
2417
2446
|
if (BUILD.svg && !isSvgMode) isSvgMode = newVNode.$tag$ === "svg";
|
|
2418
2447
|
if (!win.document) throw new Error("No DOM environment available for rendering.");
|
|
2419
2448
|
const tag = !useNativeShadowDom && BUILD.slotRelocation && newVNode.$flags$ & VNODE_FLAGS.isSlotFallback ? "slot-fb" : newVNode.$tag$;
|
|
2420
|
-
const
|
|
2421
|
-
const registryOpts = _reg !== win.customElements && tag.includes("-") ? { customElementRegistry: _reg } : void 0;
|
|
2449
|
+
const registryOpts = hostRegistry !== win.customElements && tag.includes("-") ? { customElementRegistry: hostRegistry } : void 0;
|
|
2422
2450
|
elm = newVNode.$elm$ = BUILD.svg && isSvgMode ? win.document.createElementNS(SVG_NS, tag) : win.document.createElement(tag, registryOpts);
|
|
2423
2451
|
if (BUILD.svg && isSvgMode && newVNode.$tag$ === "foreignObject") isSvgMode = false;
|
|
2424
2452
|
if (BUILD.vdomAttribute) updateElement(null, newVNode, isSvgMode);
|
|
@@ -2676,7 +2704,7 @@ const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = fal
|
|
|
2676
2704
|
}
|
|
2677
2705
|
if (BUILD.vdomKey && idxInOld >= 0) {
|
|
2678
2706
|
elmToMove = oldCh[idxInOld];
|
|
2679
|
-
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode,
|
|
2707
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx);
|
|
2680
2708
|
else {
|
|
2681
2709
|
patch(elmToMove, newStartVnode, isInitialRender);
|
|
2682
2710
|
oldCh[idxInOld] = void 0;
|
|
@@ -2769,7 +2797,17 @@ const patch = (oldVNode, newVNode, isInitialRender = false) => {
|
|
|
2769
2797
|
else if (BUILD.hydrateClientSide && isInitialRender && BUILD.updatable && oldChildren !== null && newChildren === null) newVNode.$children$ = oldChildren;
|
|
2770
2798
|
if (BUILD.svg && isSvgMode && tag === "svg") isSvgMode = false;
|
|
2771
2799
|
} else if (BUILD.vdomText && BUILD.slotRelocation && (defaultHolder = elm["s-cr"])) defaultHolder.parentNode.textContent = text;
|
|
2772
|
-
else if (BUILD.vdomText
|
|
2800
|
+
else if (BUILD.vdomText) {
|
|
2801
|
+
if (BUILD.vdomSignals && newVNode.$signal$) {
|
|
2802
|
+
if (newVNode.$signal$ !== oldVNode.$signal$) {
|
|
2803
|
+
disposeTextSignal(elm);
|
|
2804
|
+
wireTextSignal(elm, newVNode.$signal$);
|
|
2805
|
+
}
|
|
2806
|
+
} else {
|
|
2807
|
+
if (BUILD.vdomSignals && oldVNode.$signal$) disposeTextSignal(elm);
|
|
2808
|
+
if (oldVNode.$text$ !== text) elm.data = text;
|
|
2809
|
+
}
|
|
2810
|
+
}
|
|
2773
2811
|
};
|
|
2774
2812
|
/**
|
|
2775
2813
|
* Component-global information about nodes which are either currently being
|
|
@@ -2957,6 +2995,7 @@ const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
|
2957
2995
|
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
2958
2996
|
const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
|
|
2959
2997
|
hostTagName = hostElm.tagName;
|
|
2998
|
+
hostRegistry = getHostRegistry(hostElm);
|
|
2960
2999
|
if (BUILD.isDev && Array.isArray(renderFnResults) && renderFnResults.some(isHost)) throw new Error(`The <Host> must be the single root component.
|
|
2961
3000
|
Looks like the render() function of "${hostTagName.toLowerCase()}" is returning an array that contains the <Host>.
|
|
2962
3001
|
|
|
@@ -3109,11 +3148,12 @@ const markFirstConnected = (hostRef) => {
|
|
|
3109
3148
|
* autoloader, where the ancestor tag may not be defined yet.
|
|
3110
3149
|
*
|
|
3111
3150
|
* @param ancestorElm the nearest Stencil ancestor element
|
|
3151
|
+
* @param registry the registry the waiting component is defined in
|
|
3112
3152
|
*/
|
|
3113
|
-
const awaitAncestorConnected = async (ancestorElm) => {
|
|
3153
|
+
const awaitAncestorConnected = async (ancestorElm, registry) => {
|
|
3114
3154
|
let ancestorHostRef = getHostRef(ancestorElm);
|
|
3115
3155
|
if (!BUILD.lazyLoad && !ancestorHostRef) {
|
|
3116
|
-
await
|
|
3156
|
+
await registry.whenDefined(ancestorElm.tagName.toLowerCase());
|
|
3117
3157
|
ancestorHostRef = getHostRef(ancestorElm);
|
|
3118
3158
|
}
|
|
3119
3159
|
if (ancestorHostRef && !(ancestorHostRef.$flags$ & HOST_FLAGS.hasFiredConnected)) await ensureFirstConnectPromise(ancestorHostRef);
|
|
@@ -3469,8 +3509,7 @@ const initializeSignals = (elm, hostRef, cmpMeta) => {
|
|
|
3469
3509
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
3470
3510
|
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) {
|
|
3471
3511
|
if (!(memberFlags & MEMBER_FLAGS.PropLike)) continue;
|
|
3472
|
-
const
|
|
3473
|
-
const sig = signal(initialVal);
|
|
3512
|
+
const sig = signal(hostRef.$instanceValues$.get(memberName));
|
|
3474
3513
|
hostRef.$signalValues$.set(memberName, sig);
|
|
3475
3514
|
let prevScheduleVal = sig.peek();
|
|
3476
3515
|
disposers.push(effect(() => {
|
|
@@ -3598,9 +3637,7 @@ const h = (nodeName, vnodeData, ...children) => {
|
|
|
3598
3637
|
if (classData && !(BUILD.vdomSignals && isSignalLike(classData))) vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
|
|
3599
3638
|
}
|
|
3600
3639
|
}
|
|
3601
|
-
if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be the single root component
|
|
3602
|
-
- You are NOT using hostData() and <Host> in the same component.
|
|
3603
|
-
- <Host> is used once, and it's the single root component of the render() function.`);
|
|
3640
|
+
if (BUILD.isDev && vNodeChildren.some(isHost)) consoleDevError(`The <Host> must be used once, and be the single root component of the render() function.`);
|
|
3604
3641
|
if (BUILD.vdomFunctional && typeof nodeName === "function") return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
|
|
3605
3642
|
const vnode = newVNode(nodeName, null);
|
|
3606
3643
|
vnode.$attrs$ = vnodeData;
|
|
@@ -3653,17 +3690,23 @@ const vdomFnUtils = {
|
|
|
3653
3690
|
* Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
|
|
3654
3691
|
* friendlier public interface (hence, 'convertToPublic').
|
|
3655
3692
|
*
|
|
3656
|
-
*
|
|
3693
|
+
* Functional components receive primitive children unwrapped, so those
|
|
3694
|
+
* become text-only child nodes.
|
|
3695
|
+
*
|
|
3696
|
+
* @param node the virtual DOM node (or primitive child) to convert
|
|
3657
3697
|
* @returns a converted child node
|
|
3658
3698
|
*/
|
|
3659
|
-
const convertToPublic = (node) =>
|
|
3699
|
+
const convertToPublic = (node) => typeof node !== "object" ? {
|
|
3700
|
+
vtag: null,
|
|
3701
|
+
vtext: String(node)
|
|
3702
|
+
} : {
|
|
3660
3703
|
vattrs: node.$attrs$,
|
|
3661
3704
|
vchildren: node.$children$,
|
|
3662
3705
|
vkey: node.$key$,
|
|
3663
3706
|
vname: node.$name$,
|
|
3664
3707
|
vtag: node.$tag$,
|
|
3665
3708
|
vtext: node.$text$
|
|
3666
|
-
}
|
|
3709
|
+
};
|
|
3667
3710
|
/**
|
|
3668
3711
|
* Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
|
|
3669
3712
|
* order to use the resulting object in the virtual DOM. The initial object was
|
|
@@ -3680,11 +3723,11 @@ const convertToPrivate = (node) => {
|
|
|
3680
3723
|
if (node.vname) vnodeData.name = node.vname;
|
|
3681
3724
|
return h(node.vtag, vnodeData, ...node.vchildren || []);
|
|
3682
3725
|
}
|
|
3683
|
-
const vnode = newVNode(node.vtag, node.vtext);
|
|
3684
|
-
vnode.$attrs$ = node.vattrs;
|
|
3685
|
-
vnode.$children$ = node.vchildren;
|
|
3686
|
-
vnode.$key$ = node.vkey;
|
|
3687
|
-
vnode.$name$ = node.vname;
|
|
3726
|
+
const vnode = newVNode(node.vtag ?? null, node.vtext);
|
|
3727
|
+
vnode.$attrs$ = node.vattrs ?? null;
|
|
3728
|
+
vnode.$children$ = node.vchildren ?? null;
|
|
3729
|
+
vnode.$key$ = node.vkey ?? null;
|
|
3730
|
+
vnode.$name$ = node.vname ?? null;
|
|
3688
3731
|
return vnode;
|
|
3689
3732
|
};
|
|
3690
3733
|
/**
|
|
@@ -3982,6 +4025,7 @@ const initializeDocumentHydrate = (node, orgLocNodes) => {
|
|
|
3982
4025
|
const createSimpleVNode = (vnode) => ({
|
|
3983
4026
|
$flags$: 0,
|
|
3984
4027
|
$index$: "0",
|
|
4028
|
+
$children$: null,
|
|
3985
4029
|
...vnode
|
|
3986
4030
|
});
|
|
3987
4031
|
function addSlot(slotName, slotId, childVNode, node, parentVNode, childRenderNodes, slotNodes, shadowRootNodes, slottedNodes) {
|
|
@@ -4365,7 +4409,7 @@ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector)
|
|
|
4365
4409
|
else return shallowPart.trim();
|
|
4366
4410
|
}).join(", ");
|
|
4367
4411
|
};
|
|
4368
|
-
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer");
|
|
4412
|
+
const isScopableAtRule = (selector) => selector.startsWith("@media") || selector.startsWith("@supports") || selector.startsWith("@page") || selector.startsWith("@document") || selector.startsWith("@layer") || selector.startsWith("@container");
|
|
4369
4413
|
const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
|
|
4370
4414
|
return processRules(cssText, (rule) => {
|
|
4371
4415
|
let selector = rule.selector;
|
|
@@ -4484,7 +4528,7 @@ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
|
|
|
4484
4528
|
};
|
|
4485
4529
|
//#endregion
|
|
4486
4530
|
//#region src/runtime/mode.ts
|
|
4487
|
-
const computeMode = (elm) =>
|
|
4531
|
+
const computeMode = (elm) => modeResolver.map((h) => h(elm)).find((m) => !!m);
|
|
4488
4532
|
const getMode = (ref) => getHostRef(ref)?.$modeName$;
|
|
4489
4533
|
//#endregion
|
|
4490
4534
|
//#region src/runtime/normalize-watchers.ts
|
|
@@ -4549,23 +4593,14 @@ const normalizeWatchers = (raw) => {
|
|
|
4549
4593
|
*
|
|
4550
4594
|
* @param propValue the new value to coerce to some type
|
|
4551
4595
|
* @param propType the type of the prop, expressed as a binary number
|
|
4552
|
-
* @param isFormAssociated whether the component is form-associated (optional)
|
|
4553
4596
|
* @returns the parsed/coerced value
|
|
4554
4597
|
*/
|
|
4555
|
-
const parsePropertyValue = (propValue, propType
|
|
4598
|
+
const parsePropertyValue = (propValue, propType) => {
|
|
4556
4599
|
if (propValue != null && !isComplexType(propValue)) {
|
|
4557
4600
|
/**
|
|
4558
4601
|
* ensure this value is of the correct prop type
|
|
4559
4602
|
*/
|
|
4560
|
-
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean)
|
|
4561
|
-
/**
|
|
4562
|
-
* For form-associated components, according to HTML spec, the presence of any boolean attribute
|
|
4563
|
-
* (regardless of its value, even "false") should make the property true.
|
|
4564
|
-
* For non-form-associated components, we maintain the legacy behavior where "false" becomes false.
|
|
4565
|
-
*/
|
|
4566
|
-
if (BUILD.formAssociated && isFormAssociated && typeof propValue === "string") return propValue === "" || !!propValue;
|
|
4567
|
-
else return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
4568
|
-
}
|
|
4603
|
+
if (BUILD.propBoolean && propType & MEMBER_FLAGS.Boolean) return propValue === "" || !!propValue;
|
|
4569
4604
|
/**
|
|
4570
4605
|
* force it to be a number
|
|
4571
4606
|
*/
|
|
@@ -4607,7 +4642,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4607
4642
|
if (BUILD.signalBacking) {
|
|
4608
4643
|
const sig = hostRef?.$signalValues$?.get(propName);
|
|
4609
4644
|
if (sig !== void 0) {
|
|
4610
|
-
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4645
|
+
const parsed = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4611
4646
|
if (BUILD.serializer && BUILD.reflect && cmpMeta.$attrsToReflect$ && cmpMeta.$serializers$?.[propName]) {
|
|
4612
4647
|
const elm = BUILD.lazyLoad ? hostRef.$hostElement$ : ref;
|
|
4613
4648
|
applySerializers(hostRef, cmpMeta, propName, parsed, BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm);
|
|
@@ -4625,7 +4660,7 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4625
4660
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
4626
4661
|
const flags = hostRef.$flags$;
|
|
4627
4662
|
const instance = BUILD.lazyLoad ? hostRef.$lazyInstance$ : elm;
|
|
4628
|
-
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]
|
|
4663
|
+
newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
|
|
4629
4664
|
const didValueChange = newVal !== oldVal && !(Number.isNaN(oldVal) && Number.isNaN(newVal));
|
|
4630
4665
|
if ((!BUILD.lazyLoad || !(flags & HOST_FLAGS.isConstructingInstance) || oldVal === void 0) && didValueChange) {
|
|
4631
4666
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
@@ -4674,6 +4709,22 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
4674
4709
|
*/
|
|
4675
4710
|
const reflectedAttrValue = (propValue) => propValue == null || propValue === false ? null : propValue === true ? "" : String(propValue);
|
|
4676
4711
|
/**
|
|
4712
|
+
* Hand values written to a lazy component's element before its instance existed to the
|
|
4713
|
+
* instance's own `@Prop` setters. Must run as soon as the instance is constructed, so that
|
|
4714
|
+
* whenever `$lazyInstance$` is set, reads through it agree with the element's last write.
|
|
4715
|
+
*
|
|
4716
|
+
* @param hostRef the runtime bookkeeping object of a freshly constructed lazy instance
|
|
4717
|
+
* @param cmpMeta runtime metadata for the component (with any run-time only setters flagged)
|
|
4718
|
+
*/
|
|
4719
|
+
const replayPendingSetterValues = (hostRef, cmpMeta) => {
|
|
4720
|
+
const instance = hostRef.$lazyInstance$;
|
|
4721
|
+
if (!instance) return;
|
|
4722
|
+
for (const [memberName, [memberFlags]] of Object.entries(cmpMeta.$members$ ?? {})) if (memberFlags & MEMBER_FLAGS.Setter && hostRef.$instanceValues$.has(memberName)) {
|
|
4723
|
+
const pendingValue = hostRef.$instanceValues$.get(memberName);
|
|
4724
|
+
if (instance[memberName] !== pendingValue) instance[memberName] = pendingValue;
|
|
4725
|
+
}
|
|
4726
|
+
};
|
|
4727
|
+
/**
|
|
4677
4728
|
* Attach a series of runtime constructs to a compiled Stencil component
|
|
4678
4729
|
* constructor, including getters and setters for the `@Prop` and `@State`
|
|
4679
4730
|
* decorators, callbacks for when attributes change, and so on.
|
|
@@ -4730,9 +4781,8 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4730
4781
|
if (BUILD.lazyLoad) {
|
|
4731
4782
|
if ((cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Getter) === 0) return getValue(this, memberName);
|
|
4732
4783
|
const ref = getHostRef(this);
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
return instance[memberName];
|
|
4784
|
+
if (!ref) return prototype[memberName];
|
|
4785
|
+
return ref.$lazyInstance$ ? ref.$lazyInstance$[memberName] : getValue(this, memberName);
|
|
4736
4786
|
}
|
|
4737
4787
|
if (!BUILD.lazyLoad) return origGetter ? origGetter.apply(this) : getValue(this, memberName);
|
|
4738
4788
|
},
|
|
@@ -4747,7 +4797,7 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4747
4797
|
}
|
|
4748
4798
|
if (origSetter) {
|
|
4749
4799
|
if (typeof (memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName]) === "undefined" && ref.$instanceValues$.get(memberName)) newValue = ref.$instanceValues$.get(memberName);
|
|
4750
|
-
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags
|
|
4800
|
+
origSetter.apply(this, [parsePropertyValue(newValue, memberFlags)]);
|
|
4751
4801
|
newValue = memberFlags & MEMBER_FLAGS.State ? this[memberName] : ref.$hostElement$[memberName];
|
|
4752
4802
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4753
4803
|
return;
|
|
@@ -4759,21 +4809,15 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4759
4809
|
if (BUILD.lazyLoad) {
|
|
4760
4810
|
if ((flags & PROXY_FLAGS.isElementConstructor) === 0 || (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter) === 0) {
|
|
4761
4811
|
setValue(this, memberName, newValue, cmpMeta);
|
|
4762
|
-
if (flags & PROXY_FLAGS.isElementConstructor && !ref.$lazyInstance$) ref.$fetchedCbList$.push(() => {
|
|
4763
|
-
if (cmpMeta.$members$[memberName][0] & MEMBER_FLAGS.Setter && ref.$lazyInstance$[memberName] !== ref.$instanceValues$.get(memberName)) ref.$lazyInstance$[memberName] = newValue;
|
|
4764
|
-
});
|
|
4765
4812
|
return;
|
|
4766
4813
|
}
|
|
4767
|
-
const
|
|
4814
|
+
const parsedValue = parsePropertyValue(newValue, memberFlags);
|
|
4815
|
+
if (ref.$lazyInstance$) {
|
|
4768
4816
|
const currentValue = ref.$lazyInstance$[memberName];
|
|
4769
4817
|
if (!ref.$instanceValues$.get(memberName) && currentValue) ref.$instanceValues$.set(memberName, currentValue);
|
|
4770
|
-
ref.$lazyInstance$[memberName] =
|
|
4818
|
+
ref.$lazyInstance$[memberName] = parsedValue;
|
|
4771
4819
|
setValue(this, memberName, ref.$lazyInstance$[memberName], cmpMeta);
|
|
4772
|
-
};
|
|
4773
|
-
if (ref.$lazyInstance$) setterSetVal();
|
|
4774
|
-
else ref.$fetchedCbList$.push(() => {
|
|
4775
|
-
setterSetVal();
|
|
4776
|
-
});
|
|
4820
|
+
} else ref.$instanceValues$.set(memberName, parsedValue);
|
|
4777
4821
|
}
|
|
4778
4822
|
} });
|
|
4779
4823
|
} else if (BUILD.lazyLoad && BUILD.method && flags & PROXY_FLAGS.isElementConstructor && memberFlags & MEMBER_FLAGS.Method) Object.defineProperty(prototype, memberName, { value(...args) {
|
|
@@ -4825,7 +4869,10 @@ const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
|
4825
4869
|
const isBooleanTarget = propMemberFlags & MEMBER_FLAGS.Boolean;
|
|
4826
4870
|
if (BUILD.reflect && propMemberFlags & MEMBER_FLAGS.ReflectAttr && propMemberFlags & MEMBER_FLAGS.Any && !isComplexType(this[propName]) && reflectedAttrValue(this[propName]) === newValue) return;
|
|
4827
4871
|
const isSpuriousBooleanRemoval = isBooleanTarget && newValue === null && this[propName] === void 0;
|
|
4828
|
-
if (isBooleanTarget)
|
|
4872
|
+
if (isBooleanTarget) {
|
|
4873
|
+
if (BUILD.isDev && newValue === "false") consoleDevWarn(`<${cmpMeta.$tagName$} ${attrName}="false">: boolean attributes are true when present, regardless of value. Remove the attribute or set the "${propName}" property to false instead.`);
|
|
4874
|
+
newValue = newValue !== null;
|
|
4875
|
+
}
|
|
4829
4876
|
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
|
|
4830
4877
|
if (!isSpuriousBooleanRemoval && newValue != this[propName] && (!propDesc.get || !!propDesc.set)) this[propName] = newValue;
|
|
4831
4878
|
});
|
|
@@ -4888,9 +4935,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
|
4888
4935
|
} catch (e) {
|
|
4889
4936
|
consoleError(e, elm);
|
|
4890
4937
|
}
|
|
4891
|
-
if (BUILD.member)
|
|
4938
|
+
if (BUILD.member) {
|
|
4939
|
+
hostRef.$flags$ &= ~HOST_FLAGS.isConstructingInstance;
|
|
4940
|
+
replayPendingSetterValues(hostRef, cmpMeta);
|
|
4941
|
+
}
|
|
4892
4942
|
endNewInstance();
|
|
4893
|
-
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent
|
|
4943
|
+
if (BUILD.asyncLoading && hostRef.$ancestorComponent$) await awaitAncestorConnected(hostRef.$ancestorComponent$, getHostRegistry(elm));
|
|
4894
4944
|
if (!(BUILD.slotRelocation && cmpMeta.$flags$ & CMP_FLAGS.hasSlotRelocation)) {
|
|
4895
4945
|
fireConnectedCallback(hostRef.$lazyInstance$, elm);
|
|
4896
4946
|
if (BUILD.asyncLoading) markFirstConnected(hostRef);
|
|
@@ -4990,9 +5040,16 @@ const connectedCallback = (elm) => {
|
|
|
4990
5040
|
}
|
|
4991
5041
|
if (BUILD.asyncLoading) {
|
|
4992
5042
|
let ancestorComponent = elm;
|
|
4993
|
-
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)
|
|
4994
|
-
|
|
4995
|
-
|
|
5043
|
+
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
|
|
5044
|
+
if (BUILD.hydrateClientSide && !ancestorComponent["s-p"] && ancestorComponent.nodeType === NODE_TYPE.ElementNode && ancestorComponent.hasAttribute("s-id")) {
|
|
5045
|
+
ancestorComponent["s-p"] = [];
|
|
5046
|
+
ancestorComponent["s-rc"] = [];
|
|
5047
|
+
ancestorComponent["s-pc"] = [];
|
|
5048
|
+
}
|
|
5049
|
+
if (ancestorComponent["s-p"]) {
|
|
5050
|
+
attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
|
|
5051
|
+
break;
|
|
5052
|
+
}
|
|
4996
5053
|
}
|
|
4997
5054
|
}
|
|
4998
5055
|
if (BUILD.prop && !BUILD.hydrateServerSide && cmpMeta.$members$) Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
@@ -5108,48 +5165,45 @@ const hmrStandalone = async (hostElement, cmpMeta, hmrVersionId) => {
|
|
|
5108
5165
|
`${modulePath}?s-hmr=${hmrVersionId}`
|
|
5109
5166
|
);
|
|
5110
5167
|
const NewClass = Object.values(newModule).find((v) => typeof v === "function" && v.is === cmpMeta.$tagName$) ?? newModule.default;
|
|
5111
|
-
if (
|
|
5112
|
-
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
5113
|
-
if (ctor) {
|
|
5114
|
-
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
5115
|
-
if (key === "constructor") continue;
|
|
5116
|
-
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
5117
|
-
}
|
|
5118
|
-
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
5119
|
-
if (styleDesc) {
|
|
5120
|
-
Object.defineProperty(ctor, "style", styleDesc);
|
|
5121
|
-
const newStyle = NewClass.style;
|
|
5122
|
-
if (newStyle) {
|
|
5123
|
-
const scopeId = getScopeId(cmpMeta);
|
|
5124
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
5125
|
-
console.log("[stencil-hmr] registerStyle", {
|
|
5126
|
-
tag: cmpMeta.$tagName$,
|
|
5127
|
-
scopeId,
|
|
5128
|
-
isShadow,
|
|
5129
|
-
cssLen: newStyle.length
|
|
5130
|
-
});
|
|
5131
|
-
registerStyle(scopeId, newStyle, isShadow);
|
|
5132
|
-
}
|
|
5133
|
-
}
|
|
5134
|
-
}
|
|
5135
|
-
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
5136
|
-
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
5137
|
-
const hostRef = getHostRef(el);
|
|
5138
|
-
if (BUILD.hostListener && hostRef?.$rmListeners$) {
|
|
5139
|
-
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
5140
|
-
hostRef.$rmListeners$ = void 0;
|
|
5141
|
-
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
5142
|
-
}
|
|
5143
|
-
if (!isShadow && hostRef) {
|
|
5144
|
-
console.log("[stencil-hmr] calling attachStyles for", cmpMeta.$tagName$);
|
|
5145
|
-
attachStyles(hostRef);
|
|
5146
|
-
}
|
|
5147
|
-
forceUpdate(el);
|
|
5148
|
-
});
|
|
5168
|
+
if (NewClass) hmrApplyClass(cmpMeta, NewClass);
|
|
5149
5169
|
} catch (e) {
|
|
5150
5170
|
console.error(`[Stencil HMR] Failed to reload <${cmpMeta.$tagName$}>`, e);
|
|
5151
5171
|
}
|
|
5152
5172
|
};
|
|
5173
|
+
/**
|
|
5174
|
+
* Patch a re-executed component class onto the registered one and re-render every live instance.
|
|
5175
|
+
* Shared by the standalone re-import above and bundlers that re-execute the module themselves
|
|
5176
|
+
* (webpack/rspack `module.hot`), which reach it via the constructor's `s-hmr-apply` hook.
|
|
5177
|
+
*
|
|
5178
|
+
* @param cmpMeta runtime metadata for the component
|
|
5179
|
+
* @param NewClass the component's newly executed class
|
|
5180
|
+
*/
|
|
5181
|
+
const hmrApplyClass = (cmpMeta, NewClass) => {
|
|
5182
|
+
const ctor = customElements.get(cmpMeta.$tagName$);
|
|
5183
|
+
const isShadow = !!(cmpMeta.$flags$ & CMP_FLAGS.shadowDomEncapsulation);
|
|
5184
|
+
if (ctor && ctor !== NewClass) {
|
|
5185
|
+
for (const key of Object.getOwnPropertyNames(NewClass.prototype)) {
|
|
5186
|
+
if (key === "constructor") continue;
|
|
5187
|
+
Object.defineProperty(ctor.prototype, key, Object.getOwnPropertyDescriptor(NewClass.prototype, key));
|
|
5188
|
+
}
|
|
5189
|
+
const styleDesc = Object.getOwnPropertyDescriptor(NewClass, "style");
|
|
5190
|
+
if (styleDesc) {
|
|
5191
|
+
Object.defineProperty(ctor, "style", styleDesc);
|
|
5192
|
+
const newStyle = NewClass.style;
|
|
5193
|
+
if (newStyle) registerStyle(getScopeId(cmpMeta), newStyle, isShadow);
|
|
5194
|
+
}
|
|
5195
|
+
}
|
|
5196
|
+
document.querySelectorAll(cmpMeta.$tagName$).forEach((el) => {
|
|
5197
|
+
const hostRef = getHostRef(el);
|
|
5198
|
+
if (BUILD.hostListener && hostRef?.$rmListeners$) {
|
|
5199
|
+
hostRef.$rmListeners$.map((rmListener) => rmListener());
|
|
5200
|
+
hostRef.$rmListeners$ = void 0;
|
|
5201
|
+
addHostEventListeners(el, hostRef, cmpMeta.$listeners$);
|
|
5202
|
+
}
|
|
5203
|
+
if (!isShadow && hostRef) attachStyles(hostRef);
|
|
5204
|
+
forceUpdate(el);
|
|
5205
|
+
});
|
|
5206
|
+
};
|
|
5153
5207
|
//#endregion
|
|
5154
5208
|
//#region src/runtime/bootstrap-loader.ts
|
|
5155
5209
|
const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
@@ -5567,8 +5621,8 @@ const insertChildVNodeAnnotations = (doc, vnodeChild, cmpData, hostId, depth, in
|
|
|
5567
5621
|
//#endregion
|
|
5568
5622
|
//#region src/testing/platform/index.ts
|
|
5569
5623
|
const setMode = (handler) => {
|
|
5570
|
-
|
|
5571
|
-
|
|
5624
|
+
modeResolver.length = 0;
|
|
5625
|
+
modeResolver.push(handler);
|
|
5572
5626
|
};
|
|
5573
5627
|
const needsScopedSSR = () => scopedSSR;
|
|
5574
5628
|
let scopedSSR = false;
|
|
@@ -5647,79 +5701,6 @@ const buildEvents = () => {
|
|
|
5647
5701
|
};
|
|
5648
5702
|
};
|
|
5649
5703
|
//#endregion
|
|
5650
|
-
//#region src/compiler/app-core/app-data.ts
|
|
5651
|
-
/**
|
|
5652
|
-
* Generate a {@link BuildFeatures} entity, based on the provided component metadata
|
|
5653
|
-
* @param cmps a collection of component compiler metadata, used to set values on the generated build features object
|
|
5654
|
-
* @returns the generated build features entity
|
|
5655
|
-
*/
|
|
5656
|
-
const getBuildFeatures = (cmps) => {
|
|
5657
|
-
const slot = cmps.some((c) => c.htmlTagNames.includes("slot"));
|
|
5658
|
-
const shadowDom = cmps.some((c) => c.encapsulation === "shadow");
|
|
5659
|
-
const slotRelocation = cmps.some((c) => c.encapsulation !== "shadow" && c.htmlTagNames.includes("slot"));
|
|
5660
|
-
const f = {
|
|
5661
|
-
allRenderFn: cmps.every((c) => c.hasRenderFn),
|
|
5662
|
-
formAssociated: cmps.some((c) => c.formAssociated),
|
|
5663
|
-
deserializer: cmps.some((c) => c.hasDeserializer),
|
|
5664
|
-
element: cmps.some((c) => c.hasElement),
|
|
5665
|
-
event: cmps.some((c) => c.hasEvent),
|
|
5666
|
-
hasRenderFn: cmps.some((c) => c.hasRenderFn),
|
|
5667
|
-
lifecycle: cmps.some((c) => c.hasLifecycle),
|
|
5668
|
-
asyncLoading: true,
|
|
5669
|
-
hostListener: cmps.some((c) => c.hasListener),
|
|
5670
|
-
hostListenerTargetWindow: cmps.some((c) => c.hasListenerTargetWindow),
|
|
5671
|
-
hostListenerTargetDocument: cmps.some((c) => c.hasListenerTargetDocument),
|
|
5672
|
-
hostListenerTargetBody: cmps.some((c) => c.hasListenerTargetBody),
|
|
5673
|
-
hostListenerTarget: cmps.some((c) => c.hasListenerTarget),
|
|
5674
|
-
member: cmps.some((c) => c.hasMember),
|
|
5675
|
-
method: cmps.some((c) => c.hasMethod),
|
|
5676
|
-
mode: cmps.some((c) => c.hasMode),
|
|
5677
|
-
observeAttribute: cmps.some((c) => c.hasAttribute || c.hasWatchCallback || c.hasDeserializer),
|
|
5678
|
-
prop: cmps.some((c) => c.hasProp),
|
|
5679
|
-
propBoolean: cmps.some((c) => c.hasPropBoolean),
|
|
5680
|
-
propChangeCallback: cmps.some((c) => c.hasWatchCallback || c.hasDeserializer || c.hasSerializer),
|
|
5681
|
-
propNumber: cmps.some((c) => c.hasPropNumber),
|
|
5682
|
-
propString: cmps.some((c) => c.hasPropString),
|
|
5683
|
-
propMutable: cmps.some((c) => c.hasPropMutable),
|
|
5684
|
-
reflect: cmps.some((c) => c.hasReflect || c.hasSerializer),
|
|
5685
|
-
scoped: cmps.some((c) => c.encapsulation === "scoped"),
|
|
5686
|
-
serializer: cmps.some((c) => c.hasSerializer),
|
|
5687
|
-
shadowDom,
|
|
5688
|
-
shadowDelegatesFocus: shadowDom && cmps.some((c) => c.shadowDelegatesFocus),
|
|
5689
|
-
shadowModeClosed: shadowDom && cmps.some((c) => c.shadowMode === "closed"),
|
|
5690
|
-
shadowSlotAssignmentManual: shadowDom && cmps.some((c) => c.slotAssignment === "manual"),
|
|
5691
|
-
shadowClonable: shadowDom && cmps.some((c) => c.shadowClonable),
|
|
5692
|
-
shadowSerializable: shadowDom && cmps.some((c) => c.shadowSerializable),
|
|
5693
|
-
slot,
|
|
5694
|
-
slotRelocation,
|
|
5695
|
-
state: cmps.some((c) => c.hasState),
|
|
5696
|
-
style: cmps.some((c) => c.hasStyle),
|
|
5697
|
-
svg: cmps.some((c) => c.htmlTagNames.includes("svg")),
|
|
5698
|
-
updatable: cmps.some((c) => c.isUpdateable),
|
|
5699
|
-
vdomAttribute: cmps.some((c) => c.hasVdomAttribute),
|
|
5700
|
-
vdomXlink: cmps.some((c) => c.hasVdomXlink),
|
|
5701
|
-
vdomClass: cmps.some((c) => c.hasVdomClass),
|
|
5702
|
-
vdomFunctional: cmps.some((c) => c.hasVdomFunctional),
|
|
5703
|
-
vdomKey: cmps.some((c) => c.hasVdomKey),
|
|
5704
|
-
vdomListener: cmps.some((c) => c.hasVdomListener),
|
|
5705
|
-
vdomPropOrAttr: cmps.some((c) => c.hasVdomPropOrAttr),
|
|
5706
|
-
vdomPropOrAttrPrefix: cmps.some((c) => c.hasVdomPropOrAttrPrefix),
|
|
5707
|
-
vdomRef: cmps.some((c) => c.hasVdomRef),
|
|
5708
|
-
vdomRender: cmps.some((c) => c.hasVdomRender),
|
|
5709
|
-
vdomStyle: cmps.some((c) => c.hasVdomStyle),
|
|
5710
|
-
vdomText: cmps.some((c) => c.hasVdomText),
|
|
5711
|
-
vdomSignals: cmps.some((c) => c.hasSignalsImport),
|
|
5712
|
-
taskQueue: true,
|
|
5713
|
-
patchAll: cmps.some((c) => c.hasPatchAll),
|
|
5714
|
-
patchChildren: cmps.some((c) => c.hasPatchChildren),
|
|
5715
|
-
patchClone: cmps.some((c) => c.hasPatchClone),
|
|
5716
|
-
patchInsert: cmps.some((c) => c.hasPatchInsert)
|
|
5717
|
-
};
|
|
5718
|
-
f.vdomAttribute = f.vdomAttribute || f.reflect;
|
|
5719
|
-
f.vdomPropOrAttr = f.vdomPropOrAttr || f.reflect;
|
|
5720
|
-
return f;
|
|
5721
|
-
};
|
|
5722
|
-
//#endregion
|
|
5723
5704
|
//#region src/compiler/sys/resolve/resolve-utils.ts
|
|
5724
5705
|
const getModuleId = (orgImport) => {
|
|
5725
5706
|
if (orgImport.startsWith("~")) orgImport = orgImport.substring(1);
|
|
@@ -5809,6 +5790,92 @@ const createCustomResolverAsync = (sys, inMemoryFs, exts) => {
|
|
|
5809
5790
|
extensions: exts
|
|
5810
5791
|
};
|
|
5811
5792
|
};
|
|
5793
|
+
//#endregion
|
|
5794
|
+
//#region src/compiler/app-core/app-data.ts
|
|
5795
|
+
/**
|
|
5796
|
+
* Generate a {@link BuildFeatures} entity, based on the provided component metadata
|
|
5797
|
+
* @param cmps a collection of component compiler metadata, used to set values on the generated build features object
|
|
5798
|
+
* @returns the generated build features entity
|
|
5799
|
+
*/
|
|
5800
|
+
const getBuildFeatures = (cmps) => {
|
|
5801
|
+
const slot = cmps.some((c) => c.htmlTagNames.includes("slot"));
|
|
5802
|
+
const shadowDom = cmps.some((c) => c.encapsulation === "shadow");
|
|
5803
|
+
const slotRelocation = cmps.some((c) => c.encapsulation !== "shadow" && c.htmlTagNames.includes("slot"));
|
|
5804
|
+
const f = {
|
|
5805
|
+
allRenderFn: cmps.every((c) => c.hasRenderFn),
|
|
5806
|
+
formAssociated: cmps.some((c) => c.formAssociated),
|
|
5807
|
+
deserializer: cmps.some((c) => c.hasDeserializer),
|
|
5808
|
+
element: cmps.some((c) => c.hasElement),
|
|
5809
|
+
event: cmps.some((c) => c.hasEvent),
|
|
5810
|
+
hasRenderFn: cmps.some((c) => c.hasRenderFn),
|
|
5811
|
+
lifecycle: cmps.some((c) => c.hasLifecycle),
|
|
5812
|
+
asyncLoading: true,
|
|
5813
|
+
hostListener: cmps.some((c) => c.hasListener),
|
|
5814
|
+
hostListenerTargetWindow: cmps.some((c) => c.hasListenerTargetWindow),
|
|
5815
|
+
hostListenerTargetDocument: cmps.some((c) => c.hasListenerTargetDocument),
|
|
5816
|
+
hostListenerTargetBody: cmps.some((c) => c.hasListenerTargetBody),
|
|
5817
|
+
hostListenerTarget: cmps.some((c) => c.hasListenerTarget),
|
|
5818
|
+
member: cmps.some((c) => c.hasMember),
|
|
5819
|
+
method: cmps.some((c) => c.hasMethod),
|
|
5820
|
+
mode: cmps.some((c) => c.hasMode),
|
|
5821
|
+
observeAttribute: cmps.some((c) => c.hasAttribute || c.hasWatchCallback || c.hasDeserializer),
|
|
5822
|
+
prop: cmps.some((c) => c.hasProp),
|
|
5823
|
+
propBoolean: cmps.some((c) => c.hasPropBoolean),
|
|
5824
|
+
propChangeCallback: cmps.some((c) => c.hasWatchCallback || c.hasDeserializer || c.hasSerializer),
|
|
5825
|
+
propNumber: cmps.some((c) => c.hasPropNumber),
|
|
5826
|
+
propString: cmps.some((c) => c.hasPropString),
|
|
5827
|
+
propMutable: cmps.some((c) => c.hasPropMutable),
|
|
5828
|
+
reflect: cmps.some((c) => c.hasReflect || c.hasSerializer),
|
|
5829
|
+
scoped: cmps.some((c) => c.encapsulation === "scoped"),
|
|
5830
|
+
serializer: cmps.some((c) => c.hasSerializer),
|
|
5831
|
+
shadowDom,
|
|
5832
|
+
shadowDelegatesFocus: shadowDom && cmps.some((c) => c.shadowDelegatesFocus),
|
|
5833
|
+
shadowModeClosed: shadowDom && cmps.some((c) => c.shadowMode === "closed"),
|
|
5834
|
+
shadowSlotAssignmentManual: shadowDom && cmps.some((c) => c.slotAssignment === "manual"),
|
|
5835
|
+
shadowClonable: shadowDom && cmps.some((c) => c.shadowClonable),
|
|
5836
|
+
shadowSerializable: shadowDom && cmps.some((c) => c.shadowSerializable),
|
|
5837
|
+
slot,
|
|
5838
|
+
slotRelocation,
|
|
5839
|
+
state: cmps.some((c) => c.hasState),
|
|
5840
|
+
style: cmps.some((c) => c.hasStyle),
|
|
5841
|
+
svg: cmps.some((c) => c.htmlTagNames.includes("svg")),
|
|
5842
|
+
updatable: cmps.some((c) => c.isUpdateable),
|
|
5843
|
+
vdomAttribute: cmps.some((c) => c.hasVdomAttribute),
|
|
5844
|
+
vdomXlink: cmps.some((c) => c.hasVdomXlink),
|
|
5845
|
+
vdomClass: cmps.some((c) => c.hasVdomClass),
|
|
5846
|
+
vdomFunctional: cmps.some((c) => c.hasVdomFunctional),
|
|
5847
|
+
vdomKey: cmps.some((c) => c.hasVdomKey),
|
|
5848
|
+
vdomListener: cmps.some((c) => c.hasVdomListener),
|
|
5849
|
+
vdomPropOrAttr: cmps.some((c) => c.hasVdomPropOrAttr),
|
|
5850
|
+
vdomPropOrAttrPrefix: cmps.some((c) => c.hasVdomPropOrAttrPrefix),
|
|
5851
|
+
vdomRef: cmps.some((c) => c.hasVdomRef),
|
|
5852
|
+
vdomRender: cmps.some((c) => c.hasVdomRender),
|
|
5853
|
+
vdomStyle: cmps.some((c) => c.hasVdomStyle),
|
|
5854
|
+
vdomText: cmps.some((c) => c.hasVdomText),
|
|
5855
|
+
vdomSignals: cmps.some((c) => c.hasSignalsImport),
|
|
5856
|
+
taskQueue: true,
|
|
5857
|
+
patchAll: cmps.some((c) => c.hasPatchAll),
|
|
5858
|
+
patchChildren: cmps.some((c) => c.hasPatchChildren),
|
|
5859
|
+
patchClone: cmps.some((c) => c.hasPatchClone),
|
|
5860
|
+
patchInsert: cmps.some((c) => c.hasPatchInsert)
|
|
5861
|
+
};
|
|
5862
|
+
f.vdomAttribute = f.vdomAttribute || f.reflect;
|
|
5863
|
+
f.vdomPropOrAttr = f.vdomPropOrAttr || f.reflect;
|
|
5864
|
+
return f;
|
|
5865
|
+
};
|
|
5866
|
+
//#endregion
|
|
5867
|
+
//#region src/compiler/style/component-global-styles.ts
|
|
5868
|
+
/**
|
|
5869
|
+
* Match `@import` of a `stencil-*` virtual import in any form CSS allows or a preprocessor emits:
|
|
5870
|
+
* quoted or not, bare or `url()`-wrapped, and with or without whitespace after `@import` (Sass's
|
|
5871
|
+
* compressed output drops it). Capture group 2 holds any trailing modifiers, e.g. `layer(name)`.
|
|
5872
|
+
* @param name the virtual import to match
|
|
5873
|
+
* @returns a global regex
|
|
5874
|
+
*/
|
|
5875
|
+
const stencilVirtualImportRe = (name) => new RegExp(`@import(?:\\s+|(?=['"]|url\\())(?:url\\(\\s*)?(['"]?)${name}(?![\\w-])\\1\\s*\\)?([^;]*);?`, "g");
|
|
5876
|
+
stencilVirtualImportRe("stencil-component-globals");
|
|
5877
|
+
stencilVirtualImportRe("stencil-hydrate");
|
|
5878
|
+
stencilVirtualImportRe("stencil-css-components");
|
|
5812
5879
|
new RegExp(`^(${[.../* @__PURE__ */ new Set([
|
|
5813
5880
|
"child_process",
|
|
5814
5881
|
"cluster",
|
|
@@ -7357,15 +7424,6 @@ const createSystem = (c) => {
|
|
|
7357
7424
|
}
|
|
7358
7425
|
return results;
|
|
7359
7426
|
};
|
|
7360
|
-
/**
|
|
7361
|
-
* `self` is the global namespace object used within a web worker.
|
|
7362
|
-
* `window` is the browser's global namespace object (I reorganized this to check the reference on that second)
|
|
7363
|
-
* `global` is Node's global namespace object. https://nodejs.org/api/globals.html#globals_global
|
|
7364
|
-
*
|
|
7365
|
-
* loading in this order should allow workers, which are most common, then browser,
|
|
7366
|
-
* then Node to grab the reference to fetch correctly.
|
|
7367
|
-
*/
|
|
7368
|
-
const fetch = typeof self !== "undefined" ? self?.fetch : typeof window !== "undefined" ? window?.fetch : typeof global !== "undefined" ? global?.fetch : void 0;
|
|
7369
7427
|
const writeFile = async (p, data) => writeFileSync(p, data);
|
|
7370
7428
|
const tmpDirSync = () => "/.tmp";
|
|
7371
7429
|
const tick = Promise.resolve();
|
|
@@ -7376,6 +7434,7 @@ const createSystem = (c) => {
|
|
|
7376
7434
|
if (typeof hashLength === "number") hashHex = hashHex.slice(0, hashLength);
|
|
7377
7435
|
return hashHex;
|
|
7378
7436
|
};
|
|
7437
|
+
const generateFileHash = async (filePath, hashLength) => generateContentHash(readFileSync(filePath), hashLength);
|
|
7379
7438
|
const copy = async (copyTasks, srcDir) => {
|
|
7380
7439
|
const results = {
|
|
7381
7440
|
diagnostics: [],
|
|
@@ -7385,9 +7444,6 @@ const createSystem = (c) => {
|
|
|
7385
7444
|
logger.info("todo, copy task", copyTasks.length, srcDir);
|
|
7386
7445
|
return results;
|
|
7387
7446
|
};
|
|
7388
|
-
const getEnvironmentVar = (key) => {
|
|
7389
|
-
return process$1?.env[key];
|
|
7390
|
-
};
|
|
7391
7447
|
const getLocalModulePath = (opts) => join(opts.rootDir, "node_modules", opts.moduleId, opts.path);
|
|
7392
7448
|
const getRemoteModuleUrl = (opts) => {
|
|
7393
7449
|
const npmBaseUrl = "https://cdn.jsdelivr.net/npm/";
|
|
@@ -7403,13 +7459,14 @@ const createSystem = (c) => {
|
|
|
7403
7459
|
access,
|
|
7404
7460
|
accessSync,
|
|
7405
7461
|
addDestroy,
|
|
7462
|
+
checkVersion: async () => noop,
|
|
7406
7463
|
copyFile,
|
|
7407
7464
|
createDir,
|
|
7408
7465
|
createDirSync,
|
|
7409
7466
|
homeDir,
|
|
7410
7467
|
isTTY,
|
|
7411
|
-
getEnvironmentVar,
|
|
7412
7468
|
destroy,
|
|
7469
|
+
dynamicImport: (p) => import(p),
|
|
7413
7470
|
encodeToBase64,
|
|
7414
7471
|
exit: async (exitCode) => logger.warn(`exit ${exitCode}`),
|
|
7415
7472
|
getCurrentDirectory,
|
|
@@ -7420,6 +7477,7 @@ const createSystem = (c) => {
|
|
|
7420
7477
|
isSymbolicLink,
|
|
7421
7478
|
nextTick,
|
|
7422
7479
|
normalizePath: normalize,
|
|
7480
|
+
onProcessInterrupt: noop,
|
|
7423
7481
|
platformPath: path,
|
|
7424
7482
|
readDir,
|
|
7425
7483
|
readDirSync,
|
|
@@ -7429,7 +7487,6 @@ const createSystem = (c) => {
|
|
|
7429
7487
|
realpathSync,
|
|
7430
7488
|
removeDestroy,
|
|
7431
7489
|
rename,
|
|
7432
|
-
fetch,
|
|
7433
7490
|
resolvePath,
|
|
7434
7491
|
removeDir,
|
|
7435
7492
|
removeDirSync,
|
|
@@ -7444,6 +7501,7 @@ const createSystem = (c) => {
|
|
|
7444
7501
|
writeFile,
|
|
7445
7502
|
writeFileSync,
|
|
7446
7503
|
generateContentHash,
|
|
7504
|
+
generateFileHash,
|
|
7447
7505
|
createWorkerController: null,
|
|
7448
7506
|
details: {
|
|
7449
7507
|
cpuModel: "",
|