@stencil/core 5.0.0-alpha.31 → 5.0.0-alpha.33

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 (34) hide show
  1. package/dist/app-data/index.d.ts +1 -1
  2. package/dist/app-data/index.js +2 -0
  3. package/dist/client-Bqq2Agpl.mjs +2367 -0
  4. package/dist/compiler/index.d.mts +1 -1
  5. package/dist/compiler/index.mjs +2 -3
  6. package/dist/compiler/utils/index.d.mts +1 -1
  7. package/dist/compiler/utils/index.mjs +3 -3
  8. package/dist/{compiler-Cddp97Pg.mjs → compiler-DjwEWyq2.mjs} +478 -17
  9. package/dist/declarations/stencil-public-compiler.d.ts +20 -3
  10. package/dist/declarations/stencil-public-runtime.d.ts +10 -0
  11. package/dist/{regular-expression-XqU5zmPp.mjs → helpers-Cpp3qc3u.mjs} +12 -13
  12. package/dist/{index-BHj3EBl2.d.mts → index-BCm37iOm.d.mts} +40 -3
  13. package/dist/{index-D2PAsXxx.d.ts → index-BTVuF9UD.d.ts} +2 -0
  14. package/dist/{index-VK8okIiF.d.mts → index-C-fMSffa.d.mts} +2 -10
  15. package/dist/index.mjs +1 -1
  16. package/dist/jsx-runtime.mjs +1 -1
  17. package/dist/{node-BQR4L-TG.mjs → node-DugJ2Vs2.mjs} +3 -3
  18. package/dist/runtime/client/lazy.js +27 -3
  19. package/dist/runtime/client/runtime.js +27 -3
  20. package/dist/runtime/index.d.ts +1 -1
  21. package/dist/runtime/index.js +27 -3
  22. package/dist/runtime/server/index.mjs +27 -3
  23. package/dist/runtime/server/runner.mjs +21 -3
  24. package/dist/signals/index.js +2 -0
  25. package/dist/sys/node/index.d.mts +1 -1
  26. package/dist/sys/node/index.mjs +1 -1
  27. package/dist/sys/node/worker.mjs +2 -2
  28. package/dist/testing/index.d.mts +4677 -100
  29. package/dist/testing/index.mjs +7553 -780
  30. package/dist/{util-BIa-iHnt.mjs → util-IKfWWLJo.mjs} +1 -1
  31. package/dist/{validation-Dd3g77T5.mjs → validation-DAdGTrys.mjs} +16 -3
  32. package/package.json +4 -4
  33. package/dist/client-D1MsT-Rp.mjs +0 -4838
  34. package/dist/reactive-controller-BdCpSAQP.d.mts +0 -13
@@ -1,9 +1,9 @@
1
1
  import { n as __require } from "./rolldown-runtime-BhDjJH2R.mjs";
2
- import { O as HYDRATED_CSS, f as scopeCss } from "./client-D1MsT-Rp.mjs";
3
- import { $ as TYPES, B as GLOBAL_STYLE, C as ASSETS, D as COLLECTION_MANIFEST_FILE_NAME, E as COLLECTION_APP_DATA_FILE_NAME, F as DOCS_JSON, I as DOCS_README, O as COPY, R as EVENT_FLAGS, T as COLLECTION, W as LOADER_BUNDLE, X as STATS, Y as STANDALONE, Z as STYLE_EXT, _ as sortBy, a as fromEntries, b as toTitleCase, d as isNumber$1, et as VALID_CONFIG_OUTPUT_TARGETS, f as isObject, h as noop, i as flatOne, j as DIST_LAZY, l as isFunction, m as mergeIntoWith, n as dashToPascalCase, o as isBoolean$1, p as isString$1, tt as WATCH_FLAGS, u as isIterable, x as unique, y as toDashCase, z as GENERATED_DTS } from "./regular-expression-XqU5zmPp.mjs";
4
- import { S as formatComponentRuntimeMeta, T as byteSize, _ as loadRolldownDiagnostics, a as getSourceMappingUrlForEndOfFile, b as splitLineBreaks, c as err, f as augmentDiagnosticWithNode, g as isRolldownError, h as createOnWarnFn, i as getInlineSourceMappingUrlLinker, l as map, m as loadTypeScriptDiagnostics, n as validateComponentTag, p as loadTypeScriptDiagnostic, r as isRemoteUrl, s as rolldownToStencilSourceMap, t as validateComponentModes, u as ok, w as stringifyRuntimeData, x as isRootPath, y as normalizeDiagnostics } from "./validation-Dd3g77T5.mjs";
5
- import { $ as catchError, A as isOutputTargetDocsVscode, B as relativeImport, C as isOutputTargetDistLazy, D as isOutputTargetDocsCustomElementsManifest, E as isOutputTargetDocsCustom, F as isOutputTargetStandalone, G as normalizeFsPathQuery, H as join$2, I as isOutputTargetStats, J as resolve$2, K as normalizePath, L as isOutputTargetTypes, M as isOutputTargetLoaderBundle, N as isOutputTargetSsr, O as isOutputTargetDocsJson, P as isOutputTargetSsrWasm, Q as buildWarn, R as isOutputTargetWww, S as isOutputTargetCustom, T as isOutputTargetDocsAgentSkill, W as normalizeFsPath, X as buildError, Z as buildJsonFileError, a as hasDependency, b as isOutputTargetCollection, d as parsePackageJson, et as hasError, f as readOnlyArrayHasStringMember, g as getComponentsDtsSrcFilePath, h as filterExcludedComponents, i as getTextDocs, j as isOutputTargetGlobalStyle, k as isOutputTargetDocsReadme, l as isTsFile, m as filterActiveTargets, n as createJsVarName, o as isDtsFile, p as readPackageJson, q as relative$1, r as generatePreamble, rt as isGlob, t as addDocBlock, tt as hasWarning, u as isTsxFile, v as getComponentsFromModules, w as isOutputTargetDocs, x as isOutputTargetCopy, y as isOutputTargetAssets, z as isValidConfigOutputTarget } from "./util-BIa-iHnt.mjs";
6
- import { i as CustomElementsExportBehaviorOptions, o as buildEvents, r as createNodeLogger, t as createNodeSys } from "./node-BQR4L-TG.mjs";
2
+ import { S as HYDRATED_CSS } from "./client-Bqq2Agpl.mjs";
3
+ import { $ as VALID_CONFIG_OUTPUT_TARGETS, A as DIST_LAZY, D as COPY, E as COLLECTION_MANIFEST_FILE_NAME, F as DOCS_README, J as STANDALONE, L as EVENT_FLAGS, P as DOCS_JSON, Q as TYPES, R as GENERATED_DTS, S as ASSETS, T as COLLECTION_APP_DATA_FILE_NAME, U as LOADER_BUNDLE, X as STYLE_EXT, Y as STATS, a as isBoolean$1, b as unique, c as isFunction, d as isObject, et as WATCH_FLAGS, f as isString$1, g as sortBy, i as fromEntries, l as isIterable, m as noop, p as mergeIntoWith, r as flatOne, t as dashToPascalCase, u as isNumber$1, v as toDashCase, w as COLLECTION, y as toTitleCase, z as GLOBAL_STYLE } from "./helpers-Cpp3qc3u.mjs";
4
+ import { E as escapeRegExpSpecialCharacters, S as formatComponentRuntimeMeta, T as byteSize, _ as loadRolldownDiagnostics, a as getSourceMappingUrlForEndOfFile, b as splitLineBreaks, c as err, f as augmentDiagnosticWithNode, g as isRolldownError, h as createOnWarnFn, i as getInlineSourceMappingUrlLinker, l as map, m as loadTypeScriptDiagnostics, n as validateComponentTag, p as loadTypeScriptDiagnostic, r as isRemoteUrl, s as rolldownToStencilSourceMap, t as validateComponentModes, u as ok, w as stringifyRuntimeData, x as isRootPath, y as normalizeDiagnostics } from "./validation-DAdGTrys.mjs";
5
+ import { $ as catchError, A as isOutputTargetDocsVscode, B as relativeImport, C as isOutputTargetDistLazy, D as isOutputTargetDocsCustomElementsManifest, E as isOutputTargetDocsCustom, F as isOutputTargetStandalone, G as normalizeFsPathQuery, H as join$2, I as isOutputTargetStats, J as resolve$2, K as normalizePath, L as isOutputTargetTypes, M as isOutputTargetLoaderBundle, N as isOutputTargetSsr, O as isOutputTargetDocsJson, P as isOutputTargetSsrWasm, Q as buildWarn, R as isOutputTargetWww, S as isOutputTargetCustom, T as isOutputTargetDocsAgentSkill, W as normalizeFsPath, X as buildError, Z as buildJsonFileError, a as hasDependency, b as isOutputTargetCollection, d as parsePackageJson, et as hasError, f as readOnlyArrayHasStringMember, g as getComponentsDtsSrcFilePath, h as filterExcludedComponents, i as getTextDocs, j as isOutputTargetGlobalStyle, k as isOutputTargetDocsReadme, l as isTsFile, m as filterActiveTargets, n as createJsVarName, o as isDtsFile, p as readPackageJson, q as relative$1, r as generatePreamble, rt as isGlob, t as addDocBlock, tt as hasWarning, u as isTsxFile, v as getComponentsFromModules, w as isOutputTargetDocs, x as isOutputTargetCopy, y as isOutputTargetAssets, z as isValidConfigOutputTarget } from "./util-IKfWWLJo.mjs";
6
+ import { i as CustomElementsExportBehaviorOptions, o as buildEvents, r as createNodeLogger, t as createNodeSys } from "./node-DugJ2Vs2.mjs";
7
7
  import ts, { default as ts$1 } from "typescript";
8
8
  import { readFileSync } from "node:fs";
9
9
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
@@ -28,10 +28,441 @@ import { browserslistToTargets, transform } from "lightningcss";
28
28
  import { createJiti } from "jiti";
29
29
  import * as process$1 from "process";
30
30
  import { dataToEsm } from "@rollup/pluginutils";
31
+ //#region src/utils/shadow-css.ts
32
+ /**
33
+ * @license
34
+ * Copyright Google Inc. All Rights Reserved.
35
+ *
36
+ * Use of this source code is governed by an MIT-style license that can be
37
+ * found in the LICENSE file at https://angular.io/license
38
+ *
39
+ * This file is a port of shadowCSS from `webcomponents.js` to TypeScript.
40
+ * https://github.com/webcomponents/webcomponentsjs/blob/4efecd7e0e/src/ShadowCSS/ShadowCSS.js
41
+ * https://github.com/angular/angular/blob/master/packages/compiler/src/shadow_css.ts
42
+ */
43
+ const safeSelector = (selector) => {
44
+ const placeholders = [];
45
+ let index = 0;
46
+ selector = selector.replace(/(\[\s*part~=\s*("[^"]*"|'[^']*')\s*\])/g, (_, keep) => {
47
+ const replaceBy = `__part-${index}__`;
48
+ placeholders.push(keep);
49
+ index++;
50
+ return replaceBy;
51
+ });
52
+ selector = selector.replace(/(\[[^\]]*\])/g, (_, keep) => {
53
+ const replaceBy = `__ph-${index}__`;
54
+ placeholders.push(keep);
55
+ index++;
56
+ return replaceBy;
57
+ });
58
+ return {
59
+ content: selector.replace(/(:nth-[-\w]+)(\([^)]+\))/g, (_, pseudo, exp) => {
60
+ const replaceBy = `__ph-${index}__`;
61
+ placeholders.push(exp);
62
+ index++;
63
+ return pseudo + replaceBy;
64
+ }),
65
+ placeholders
66
+ };
67
+ };
68
+ const restoreSafeSelector = (placeholders, content) => {
69
+ content = content.replace(/__part-(\d+)__/g, (_, index) => placeholders[+index]);
70
+ return content.replace(/__ph-(\d+)__/g, (_, index) => placeholders[+index]);
71
+ };
72
+ const _polyfillHost = "-shadowcsshost";
73
+ const _polyfillSlotted = "-shadowcssslotted";
74
+ const _polyfillHostContext = "-shadowcsscontext";
75
+ let _cssColonHostRe;
76
+ let _cssColonHostContextRe;
77
+ let _cssColonSlottedRe;
78
+ const getCssColonHostRe = () => _cssColonHostRe ??= /* @__PURE__ */ new RegExp("(-shadowcsshost)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)", "gim");
79
+ const getCssColonHostContextRe = () => _cssColonHostContextRe ??= /* @__PURE__ */ new RegExp("(-shadowcsscontext)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)", "gim");
80
+ const getCssColonSlottedRe = () => _cssColonSlottedRe ??= /* @__PURE__ */ new RegExp("(-shadowcssslotted)(?:\\(((?:\\([^)(]*\\)|[^)(]*)+?)\\))?([^,{]*)", "gim");
81
+ const _polyfillHostNoCombinator = "-shadowcsshost-no-combinator";
82
+ const _polyfillHostNoCombinatorRe = /-shadowcsshost-no-combinator([^\s]*)/;
83
+ const _shadowDOMSelectorsRe = [/::shadow/g, /::content/g];
84
+ const _safePartRe = /__part-(\d+)__/g;
85
+ const _polyfillHostRe = /-shadowcsshost/gim;
86
+ /**
87
+ * Little helper for generating a regex that will match a specified
88
+ * CSS selector when that selector is _not_ a part of a `@supports` rule.
89
+ *
90
+ * The pattern will match the provided `selector` (i.e. ':host', ':host-context', etc.)
91
+ * when that selector is not a part of a `@supports` selector rule _or_ if the selector
92
+ * is a part of the rule's declaration.
93
+ *
94
+ * For instance, if we create the regex with the selector ':host-context':
95
+ * - '@supports selector(:host-context())' will return no matches (starts with '@supports')
96
+ * - '@supports selector(:host-context()) { :host-context() { ... }}' will match the second ':host-context' (part of declaration)
97
+ * - ':host-context() { ... }' will match ':host-context' (selector is not a '@supports' rule)
98
+ * - ':host() { ... }' will return no matches (selector doesn't match selector used to create regex)
99
+ *
100
+ * @param selector The CSS selector we want to match for replacement
101
+ * @returns A look-behind regex containing the selector
102
+ */
103
+ const createSupportsRuleRe = (selector) => {
104
+ const escapedSelector = escapeRegExpSpecialCharacters(selector);
105
+ return new RegExp(`(^|[^@]|@(?!supports\\s+selector\\s*\\([^{]*?${escapedSelector}))(${escapedSelector}\\b)`, "g");
106
+ };
107
+ const _commentRe = /\/\*\s*[\s\S]*?\*\//g;
108
+ const stripComments = (input) => {
109
+ return input.replace(_commentRe, "");
110
+ };
111
+ const _commentWithHashRe = /\/\*\s*#\s*source(Mapping)?URL=[\s\S]+?\*\//g;
112
+ const extractCommentsWithHash = (input) => {
113
+ return input.match(_commentWithHashRe) || [];
114
+ };
115
+ const _ruleRe = /(\s*)([^;{}]+?)(\s*)((?:{%BLOCK%}?\s*;?)|(?:\s*;))/g;
116
+ const _curlyRe = /([{}])/g;
117
+ const _selectorPartsRe = /(^.*?[^\\])??((:+)(.*)|$)/;
118
+ const OPEN_CURLY = "{";
119
+ const CLOSE_CURLY = "}";
120
+ const BLOCK_PLACEHOLDER = "%BLOCK%";
121
+ const processRules = (input, ruleCallback) => {
122
+ const inputWithEscapedBlocks = escapeBlocks(input);
123
+ let nextBlockIndex = 0;
124
+ return inputWithEscapedBlocks.escapedString.replace(_ruleRe, (...m) => {
125
+ const selector = m[2];
126
+ let content = "";
127
+ let suffix = m[4];
128
+ let contentPrefix = "";
129
+ if (suffix && suffix.startsWith("{%BLOCK%")) {
130
+ content = inputWithEscapedBlocks.blocks[nextBlockIndex++];
131
+ suffix = suffix.substring(8);
132
+ contentPrefix = "{";
133
+ }
134
+ const rule = ruleCallback({
135
+ selector,
136
+ content
137
+ });
138
+ return `${m[1]}${rule.selector}${m[3]}${contentPrefix}${rule.content}${suffix}`;
139
+ });
140
+ };
141
+ const escapeBlocks = (input) => {
142
+ const inputParts = input.split(_curlyRe);
143
+ const resultParts = [];
144
+ const escapedBlocks = [];
145
+ let bracketCount = 0;
146
+ let currentBlockParts = [];
147
+ for (let partIndex = 0; partIndex < inputParts.length; partIndex++) {
148
+ const part = inputParts[partIndex];
149
+ if (part === CLOSE_CURLY) bracketCount--;
150
+ if (bracketCount > 0) currentBlockParts.push(part);
151
+ else {
152
+ if (currentBlockParts.length > 0) {
153
+ escapedBlocks.push(currentBlockParts.join(""));
154
+ resultParts.push(BLOCK_PLACEHOLDER);
155
+ currentBlockParts = [];
156
+ }
157
+ resultParts.push(part);
158
+ }
159
+ if (part === OPEN_CURLY) bracketCount++;
160
+ }
161
+ if (currentBlockParts.length > 0) {
162
+ escapedBlocks.push(currentBlockParts.join(""));
163
+ resultParts.push(BLOCK_PLACEHOLDER);
164
+ }
165
+ return {
166
+ escapedString: resultParts.join(""),
167
+ blocks: escapedBlocks
168
+ };
169
+ };
170
+ /**
171
+ * Replaces certain strings within the CSS with placeholders
172
+ * that will later be replaced with class selectors appropriate
173
+ * for the level of encapsulation (shadow or scoped).
174
+ *
175
+ * When performing these replacements, we want to ignore selectors that are a
176
+ * part of an `@supports` rule. Replacing these selectors will result in invalid
177
+ * CSS that gets passed to autoprefixer/postcss once the placeholders are replaced.
178
+ * For example, a rule like:
179
+ *
180
+ * ```css
181
+ * @supports selector(:host()) {
182
+ * :host {
183
+ * color: red;
184
+ * }
185
+ * }
186
+ * ```
187
+ *
188
+ * Should be converted to:
189
+ *
190
+ * ```css
191
+ * @supports selector(:host()) {
192
+ * -shadowcsshost {
193
+ * color: red;
194
+ * }
195
+ * }
196
+ * ```
197
+ *
198
+ * The order the regex replacements happen in matters since we match
199
+ * against a whole selector word so we need to match all of `:host-context`
200
+ * before we try to replace `:host`. Otherwise the pattern for `:host` would match
201
+ * `:host-context` resulting in something like `:-shadowcsshost-context`.
202
+ *
203
+ * @param cssText A CSS string for a component
204
+ * @returns The modified CSS string
205
+ */
206
+ const insertPolyfillHostInCssText = (cssText) => {
207
+ const supportsBlocks = [];
208
+ cssText = cssText.replace(/@supports\s+selector\s*\(\s*([^)]*)\s*\)/g, (_, selectorContent) => {
209
+ const placeholder = `__supports_${supportsBlocks.length}__`;
210
+ supportsBlocks.push(selectorContent);
211
+ return `@supports selector(${placeholder})`;
212
+ });
213
+ const _colonSlottedRe = createSupportsRuleRe("::slotted");
214
+ const _colonHostRe = createSupportsRuleRe(":host");
215
+ const _colonHostContextRe = createSupportsRuleRe(":host-context");
216
+ cssText = cssText.replace(_colonHostContextRe, `$1${_polyfillHostContext}`).replace(_colonHostRe, `$1${_polyfillHost}`).replace(_colonSlottedRe, `$1${_polyfillSlotted}`);
217
+ supportsBlocks.forEach((originalSelector, index) => {
218
+ cssText = cssText.replace(`__supports_${index}__`, originalSelector);
219
+ });
220
+ return cssText;
221
+ };
222
+ const convertColonRule = (cssText, regExp, partReplacer) => {
223
+ return cssText.replace(regExp, (...m) => {
224
+ if (m[2]) {
225
+ const parts = m[2].split(",");
226
+ const r = [];
227
+ for (let i = 0; i < parts.length; i++) {
228
+ const p = parts[i].trim();
229
+ if (!p) break;
230
+ r.push(partReplacer(_polyfillHostNoCombinator, p, m[3]));
231
+ }
232
+ return r.join(",");
233
+ } else return _polyfillHostNoCombinator + m[3];
234
+ });
235
+ };
236
+ const colonHostPartReplacer = (host, part, suffix) => {
237
+ return host + part.replace(_polyfillHost, "") + suffix;
238
+ };
239
+ const convertColonHost = (cssText) => {
240
+ return convertColonRule(cssText, getCssColonHostRe(), colonHostPartReplacer);
241
+ };
242
+ const colonHostContextPartReplacer = (host, part, suffix) => {
243
+ if (part.indexOf(_polyfillHost) > -1) return colonHostPartReplacer(host, part, suffix);
244
+ else return host + part + suffix + ", " + part + " " + host + suffix;
245
+ };
246
+ const convertColonSlotted = (cssText, slotScopeId) => {
247
+ const slotClass = "." + slotScopeId + " > ";
248
+ const selectors = [];
249
+ cssText = cssText.replace(getCssColonSlottedRe(), (...m) => {
250
+ if (m[2]) {
251
+ const compound = m[2].trim();
252
+ const suffix = m[3];
253
+ const slottedSelector = slotClass + compound + suffix;
254
+ let prefixSelector = "";
255
+ for (let i = m[4] - 1; i >= 0; i--) {
256
+ const char = m[5][i];
257
+ if (char === "}" || char === ",") break;
258
+ prefixSelector = char + prefixSelector;
259
+ }
260
+ const orgSelector = (prefixSelector + slottedSelector).trim();
261
+ const addedSelector = `${prefixSelector.trimEnd()}${slottedSelector.trim()}`.trim();
262
+ if (orgSelector !== addedSelector) {
263
+ const updatedSelector = `${addedSelector}, ${orgSelector}`;
264
+ selectors.push({
265
+ orgSelector,
266
+ updatedSelector
267
+ });
268
+ }
269
+ return slottedSelector;
270
+ } else return _polyfillHostNoCombinator + m[3];
271
+ });
272
+ return {
273
+ selectors,
274
+ cssText
275
+ };
276
+ };
277
+ const convertColonHostContext = (cssText) => {
278
+ return convertColonRule(cssText, getCssColonHostContextRe(), colonHostContextPartReplacer);
279
+ };
280
+ const convertShadowDOMSelectors = (cssText) => {
281
+ return _shadowDOMSelectorsRe.reduce((result, pattern) => result.replace(pattern, " "), cssText);
282
+ };
283
+ const makeScopeMatcher = (scopeSelector) => {
284
+ scopeSelector = scopeSelector.replace(/\[/g, "\\[").replace(/\]/g, "\\]");
285
+ return new RegExp("^(" + scopeSelector + ")([>\\s~+[.,{:][\\s\\S]*)?$", "m");
286
+ };
287
+ const selectorNeedsScoping = (selector, scopeSelector) => {
288
+ return !makeScopeMatcher(scopeSelector).test(selector);
289
+ };
290
+ const injectScopingSelector = (selector, scopingSelector) => {
291
+ return selector.replace(_selectorPartsRe, (_, before = "", _colonGroup, colon = "", after = "") => {
292
+ return before + scopingSelector + colon + after;
293
+ });
294
+ };
295
+ const applySimpleSelectorScope = (selector, scopeSelector, hostSelector) => {
296
+ _polyfillHostRe.lastIndex = 0;
297
+ if (_polyfillHostRe.test(selector)) {
298
+ const replaceBy = `.${hostSelector}`;
299
+ return selector.replace(_polyfillHostNoCombinatorRe, (_, sel) => injectScopingSelector(sel, replaceBy)).replace(_polyfillHostRe, replaceBy + " ");
300
+ }
301
+ return scopeSelector + " " + selector;
302
+ };
303
+ const applyStrictSelectorScope = (selector, scopeSelector, hostSelector) => {
304
+ scopeSelector = scopeSelector.replace(/\[is=([^\]]*)\]/g, (_, ...parts) => parts[0]);
305
+ const className = "." + scopeSelector;
306
+ const _scopeSelectorPart = (p) => {
307
+ let scopedP = p.trim();
308
+ if (!scopedP) return "";
309
+ if (p.indexOf(_polyfillHostNoCombinator) > -1) scopedP = applySimpleSelectorScope(p, scopeSelector, hostSelector);
310
+ else {
311
+ const t = p.replace(_polyfillHostRe, "");
312
+ if (t.length > 0) scopedP = injectScopingSelector(t, className);
313
+ }
314
+ return scopedP;
315
+ };
316
+ const safeContent = safeSelector(selector);
317
+ selector = safeContent.content;
318
+ let scopedSelector = "";
319
+ let startIndex = 0;
320
+ let res;
321
+ const sep = /( |>|\+|~(?!=))(?=(?:[^()]*\([^()]*\))*[^()]*$)\s*/g;
322
+ let shouldScope = !(selector.indexOf(_polyfillHostNoCombinator) > -1);
323
+ while ((res = sep.exec(selector)) !== null) {
324
+ const separator = res[1];
325
+ const part = selector.slice(startIndex, res.index).trim();
326
+ shouldScope = shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1;
327
+ const scopedPart = shouldScope ? _scopeSelectorPart(part) : part;
328
+ scopedSelector += `${scopedPart} ${separator} `;
329
+ startIndex = sep.lastIndex;
330
+ }
331
+ const part = selector.substring(startIndex);
332
+ shouldScope = !part.match(_safePartRe) && (shouldScope || part.indexOf(_polyfillHostNoCombinator) > -1);
333
+ scopedSelector += shouldScope ? _scopeSelectorPart(part) : part;
334
+ return restoreSafeSelector(safeContent.placeholders, scopedSelector);
335
+ };
336
+ const scopeSelector = (selector, scopeSelectorText, hostSelector, slotSelector) => {
337
+ return selector.split(",").map((shallowPart) => {
338
+ if (slotSelector && shallowPart.indexOf("." + slotSelector) > -1) return shallowPart.trim();
339
+ if (selectorNeedsScoping(shallowPart, scopeSelectorText)) return applyStrictSelectorScope(shallowPart, scopeSelectorText, hostSelector).trim();
340
+ else return shallowPart.trim();
341
+ }).join(", ");
342
+ };
343
+ const scopeSelectors = (cssText, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector) => {
344
+ return processRules(cssText, (rule) => {
345
+ let selector = rule.selector;
346
+ let content = rule.content;
347
+ if (rule.selector[0] !== "@") selector = scopeSelector(rule.selector, scopeSelectorText, hostSelector, slotSelector);
348
+ else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) content = scopeSelectors(rule.content, scopeSelectorText, hostSelector, slotSelector, commentOriginalSelector);
349
+ return {
350
+ selector: selector.replace(/\s{2,}/g, " ").trim(),
351
+ content
352
+ };
353
+ });
354
+ };
355
+ const scopeCssText = (cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector) => {
356
+ cssText = insertPolyfillHostInCssText(cssText);
357
+ cssText = convertColonHost(cssText);
358
+ cssText = convertColonHostContext(cssText);
359
+ const slotted = convertColonSlotted(cssText, slotScopeId);
360
+ cssText = slotted.cssText;
361
+ cssText = convertShadowDOMSelectors(cssText);
362
+ if (scopeId) cssText = scopeSelectors(cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector);
363
+ cssText = replaceShadowCssHost(cssText, hostScopeId);
364
+ cssText = cssText.replace(/>\s*\*\s+([^{, ]+)/gm, " $1 ");
365
+ return {
366
+ cssText: cssText.trim(),
367
+ slottedSelectors: slotted.selectors.map((ref) => ({
368
+ orgSelector: replaceShadowCssHost(ref.orgSelector, hostScopeId),
369
+ updatedSelector: replaceShadowCssHost(ref.updatedSelector, hostScopeId)
370
+ }))
371
+ };
372
+ };
373
+ /**
374
+ * Helper function that replaces the interim string representing a `:host` selector with
375
+ * the host scope selector class for the element.
376
+ *
377
+ * @param cssText The CSS string to make the replacement in
378
+ * @param hostScopeId The scope ID that will be used as the class representing the host element
379
+ * @returns CSS with the selector replaced
380
+ */
381
+ const replaceShadowCssHost = (cssText, hostScopeId) => {
382
+ return cssText.replace(/-shadowcsshost-no-combinator/g, `.${hostScopeId}`);
383
+ };
384
+ /**
385
+ * Expands selectors with ::part(...) to also include [part~="..."] selectors.
386
+ * For example:
387
+ * ```css
388
+ * selectors-like-this::part(demo) { ... }
389
+ * .something .selectors::part(demo demo2):hover { ... }
390
+ * ```
391
+ * Becomes:
392
+ * ```
393
+ * selectors-like-this::part(demo), selectors-like-this [part~="demo"] { ... }
394
+ * .something .selectors::part(demo demo2):hover, .something .selectors [part~="demo"][part~="demo2"]:hover { ... }
395
+ * ```
396
+ *
397
+ * @param cssText The CSS text to process
398
+ * @returns The CSS text with expanded ::part(...) selectors
399
+ */
400
+ const expandPartSelectors = (cssText) => {
401
+ const partSelectorRe = /([^\s,{][^,{]*?)::part\(\s*([^)]+?)\s*\)((?:[:.][^,{]*)*)/g;
402
+ return processRules(cssText, (rule) => {
403
+ if (rule.selector[0] === "@") return rule;
404
+ rule.selector = rule.selector.split(",").map((sel) => {
405
+ const out = [sel.trim()];
406
+ let m;
407
+ while ((m = partSelectorRe.exec(sel)) !== null) {
408
+ const before = m[1].trimEnd();
409
+ const partNames = m[2].trim().split(/\s+/);
410
+ const after = m[3] || "";
411
+ const partAttr = partNames.flatMap((p) => {
412
+ if (!rule.selector.includes(`[part~="${p}"]`)) return [`[part~="${p}"]`];
413
+ return [];
414
+ }).join("");
415
+ const expanded = `${before} ${partAttr}${after}`;
416
+ if (!!partAttr && expanded !== sel.trim()) out.push(expanded);
417
+ }
418
+ return out.join(", ");
419
+ }).join(", ");
420
+ return rule;
421
+ });
422
+ };
423
+ const scopeCss = (cssText, scopeId, commentOriginalSelector) => {
424
+ const hostScopeId = scopeId + "-h";
425
+ const slotScopeId = scopeId + "-s";
426
+ const commentsWithHash = extractCommentsWithHash(cssText);
427
+ cssText = stripComments(cssText);
428
+ const orgSelectors = [];
429
+ if (commentOriginalSelector) {
430
+ const processCommentedSelector = (rule) => {
431
+ const placeholder = `/*!@___${orgSelectors.length}___*/`;
432
+ const comment = `/*!@${rule.selector}*/`;
433
+ orgSelectors.push({
434
+ placeholder,
435
+ comment
436
+ });
437
+ rule.selector = placeholder + rule.selector;
438
+ return rule;
439
+ };
440
+ cssText = processRules(cssText, (rule) => {
441
+ if (rule.selector[0] !== "@") return processCommentedSelector(rule);
442
+ else if (rule.selector.startsWith("@media") || rule.selector.startsWith("@supports") || rule.selector.startsWith("@page") || rule.selector.startsWith("@document")) {
443
+ rule.content = processRules(rule.content, processCommentedSelector);
444
+ return rule;
445
+ }
446
+ return rule;
447
+ });
448
+ }
449
+ const scoped = scopeCssText(cssText, scopeId, hostScopeId, slotScopeId, commentOriginalSelector);
450
+ cssText = [scoped.cssText, ...commentsWithHash].join("\n");
451
+ if (commentOriginalSelector) orgSelectors.forEach(({ placeholder, comment }) => {
452
+ cssText = cssText.replace(placeholder, comment);
453
+ });
454
+ scoped.slottedSelectors.forEach((slottedSelector) => {
455
+ const regex = new RegExp(escapeRegExpSpecialCharacters(slottedSelector.orgSelector) + "(?=\\s*[,{]|$)", "g");
456
+ cssText = cssText.replace(regex, slottedSelector.updatedSelector);
457
+ });
458
+ cssText = expandPartSelectors(cssText);
459
+ return cssText;
460
+ };
461
+ //#endregion
31
462
  //#region src/version.ts
32
- const version = "5.0.0-alpha.31";
33
- const buildId = "1787096835";
34
- const vermoji = "📬";
463
+ const version = "5.0.0-alpha.33";
464
+ const buildId = "1787328414";
465
+ const vermoji = "🎨";
35
466
  /**
36
467
  * Get the installed version of a tool/dependency.
37
468
  * Handles packages with exports maps that point to subdirectories.
@@ -418,6 +849,8 @@ const getBuildFeatures = (cmps) => {
418
849
  shadowDelegatesFocus: shadowDom && cmps.some((c) => c.shadowDelegatesFocus),
419
850
  shadowModeClosed: shadowDom && cmps.some((c) => c.shadowMode === "closed"),
420
851
  shadowSlotAssignmentManual: shadowDom && cmps.some((c) => c.slotAssignment === "manual"),
852
+ shadowClonable: shadowDom && cmps.some((c) => c.shadowClonable),
853
+ shadowSerializable: shadowDom && cmps.some((c) => c.shadowSerializable),
421
854
  slot,
422
855
  slotRelocation,
423
856
  state: cmps.some((c) => c.hasState),
@@ -6461,7 +6894,7 @@ const generateEsmBrowser = async (config, compilerCtx, buildCtx, rolldownBuild,
6461
6894
  if (output != null) {
6462
6895
  const es2017destinations = esmOutputs.map((o) => o.esmDir).filter((esmDir) => typeof esmDir === "string");
6463
6896
  buildCtx.esmBrowserComponentBundle = await generateLazyModules(config, compilerCtx, buildCtx, outputTargetType, es2017destinations, output, "es2017", true);
6464
- await writeEsmForwardingModule(config, compilerCtx, outputTargetType, es2017destinations);
6897
+ await writeEsmForwardingModules(config, compilerCtx, outputTargetType, es2017destinations);
6465
6898
  }
6466
6899
  }
6467
6900
  return {
@@ -6470,7 +6903,7 @@ const generateEsmBrowser = async (config, compilerCtx, buildCtx, rolldownBuild,
6470
6903
  };
6471
6904
  };
6472
6905
  /**
6473
- * Write a backwards-compatible forwarding module that re-exports from the new .js file.
6906
+ * Write backwards-compatible forwarding modules that re-export from the new .js files.
6474
6907
  * This allows existing CDN consumers with hardcoded .esm.js references to continue working.
6475
6908
  *
6476
6909
  * @param config the Stencil configuration
@@ -6478,13 +6911,13 @@ const generateEsmBrowser = async (config, compilerCtx, buildCtx, rolldownBuild,
6478
6911
  * @param outputTargetType the output target type for file writing
6479
6912
  * @param destinations the destination directories to write forwarding modules to
6480
6913
  */
6481
- const writeEsmForwardingModule = async (config, compilerCtx, outputTargetType, destinations) => {
6482
- const namespace = config.fsNamespace;
6483
- const forwardingCode = `import './${namespace}.js';\nexport * from './${namespace}.js';\n`;
6484
- await Promise.all(destinations.map((dest) => {
6485
- const filePath = join$2(dest, `${namespace}.esm.js`);
6914
+ const writeEsmForwardingModules = async (config, compilerCtx, outputTargetType, destinations) => {
6915
+ const entryNames = [config.fsNamespace, "index"];
6916
+ await Promise.all(destinations.flatMap((dest) => entryNames.map((name) => {
6917
+ const forwardingCode = `import './${name}.js';\nexport * from './${name}.js';\n`;
6918
+ const filePath = join$2(dest, `${name}.esm.js`);
6486
6919
  return compilerCtx.fs.writeFile(filePath, forwardingCode, { outputTargetType });
6487
- }));
6920
+ })));
6488
6921
  };
6489
6922
  //#endregion
6490
6923
  //#region src/compiler/output-targets/dist-lazy/generate-loader.ts
@@ -13046,6 +13479,8 @@ const componentDecoratorToStatic = (config, typeChecker, diagnostics, cmpNode, n
13046
13479
  if (enc.mode === "closed") newMembers.push(createStaticGetter("shadowMode", convertValueToLiteral("closed")));
13047
13480
  if (enc.delegatesFocus === true) newMembers.push(createStaticGetter("delegatesFocus", convertValueToLiteral(true)));
13048
13481
  if (enc.slotAssignment === "manual") newMembers.push(createStaticGetter("slotAssignment", convertValueToLiteral("manual")));
13482
+ if (enc.clonable === true) newMembers.push(createStaticGetter("clonable", convertValueToLiteral(true)));
13483
+ if (enc.serializable === true) newMembers.push(createStaticGetter("serializable", convertValueToLiteral(true)));
13049
13484
  } else if (enc.type === "scoped") {
13050
13485
  newMembers.push(createStaticGetter("encapsulation", convertValueToLiteral("scoped")));
13051
13486
  if (enc.patches && enc.patches.length > 0) newMembers.push(createStaticGetter("patches", convertValueToLiteral(enc.patches)));
@@ -15706,6 +16141,30 @@ const parseStaticShadowDelegatesFocus = (encapsulation, staticMembers) => {
15706
16141
  return null;
15707
16142
  };
15708
16143
  /**
16144
+ * Find and return if `clonable` is enabled for a component based on the return value of its static getter of the
16145
+ * same name.
16146
+ *
16147
+ * @param encapsulation the encapsulation mode to use for a component
16148
+ * @param staticMembers a collection of static getters to search
16149
+ * @returns `true` if encapsulation is 'shadow' and the `clonable` static getter returns true
16150
+ */
16151
+ const parseStaticShadowClonable = (encapsulation, staticMembers) => {
16152
+ if (encapsulation === "shadow") return !!getStaticValue(staticMembers, "clonable");
16153
+ return null;
16154
+ };
16155
+ /**
16156
+ * Find and return if `serializable` is enabled for a component based on the return value of its static getter of
16157
+ * the same name.
16158
+ *
16159
+ * @param encapsulation the encapsulation mode to use for a component
16160
+ * @param staticMembers a collection of static getters to search
16161
+ * @returns `true` if encapsulation is 'shadow' and the `serializable` static getter returns true
16162
+ */
16163
+ const parseStaticShadowSerializable = (encapsulation, staticMembers) => {
16164
+ if (encapsulation === "shadow") return !!getStaticValue(staticMembers, "serializable");
16165
+ return null;
16166
+ };
16167
+ /**
15709
16168
  * Find and return the `slotAssignment` mode for a component.
15710
16169
  *
15711
16170
  * @param encapsulation the encapsulation mode to use for a component
@@ -15929,6 +16388,8 @@ const parseStaticComponentMeta = (compilerCtx, typeChecker, cmpNode, moduleFile,
15929
16388
  elementRef: parseStaticElementRef(staticMembers),
15930
16389
  encapsulation,
15931
16390
  shadowDelegatesFocus: !!parseStaticShadowDelegatesFocus(encapsulation, staticMembers),
16391
+ shadowClonable: !!parseStaticShadowClonable(encapsulation, staticMembers),
16392
+ shadowSerializable: !!parseStaticShadowSerializable(encapsulation, staticMembers),
15932
16393
  shadowMode: parseStaticShadowMode(encapsulation, staticMembers),
15933
16394
  slotAssignment: parseStaticSlotAssignment(encapsulation, staticMembers),
15934
16395
  patches: parseStaticPatches(encapsulation, staticMembers),
@@ -24165,4 +24626,4 @@ const shouldTranspileModule = (ext) => [
24165
24626
  "js"
24166
24627
  ].includes(ext);
24167
24628
  //#endregion
24168
- export { version as C, vermoji as S, cmpMetaToDocsComponent as _, createPrerenderer as a, getBuildFeatures as b, createWorkerContext as c, nodeRequire as d, optimizeCss as f, generateManifest as g, Cache as h, createSystem as i, createWorkerMessageHandler as l, validateConfig as m, transpile as n, loadConfig as o, createInMemoryFs as p, transpileSync as r, createCompiler as s, ts$1 as t, optimizeJs as u, BuildContext as v, versions as w, buildId as x, getScopeId as y };
24629
+ export { buildId as _, createPrerenderer as a, versions as b, createWorkerContext as c, nodeRequire as d, optimizeCss as f, getScopeId as g, cmpMetaToDocsComponent as h, createSystem as i, createWorkerMessageHandler as l, generateManifest as m, transpile as n, loadConfig as o, validateConfig as p, transpileSync as r, createCompiler as s, ts$1 as t, optimizeJs as u, vermoji as v, scopeCss as x, version as y };
@@ -666,6 +666,8 @@ interface BuildFeatures {
666
666
  shadowDelegatesFocus: boolean;
667
667
  shadowModeClosed: boolean;
668
668
  shadowSlotAssignmentManual: boolean;
669
+ shadowClonable: boolean;
670
+ shadowSerializable: boolean;
669
671
  scoped: boolean;
670
672
  /**
671
673
  * Every component has a render function
@@ -1162,6 +1164,16 @@ interface ComponentCompilerMeta extends ComponentCompilerFeatures {
1162
1164
  properties: ComponentCompilerProperty[];
1163
1165
  serializers: ComponentCompilerChangeHandler[];
1164
1166
  shadowDelegatesFocus: boolean;
1167
+ /**
1168
+ * Whether the shadow root is preserved when the host element is deep-cloned via
1169
+ * `Node.cloneNode(true)`. Only applicable when encapsulation is 'shadow'.
1170
+ */
1171
+ shadowClonable: boolean;
1172
+ /**
1173
+ * Whether the shadow root is marked serializable for `Element.getHTML({ serializableShadowRoots: true })`.
1174
+ * Only applicable when encapsulation is 'shadow'.
1175
+ */
1176
+ shadowSerializable: boolean;
1165
1177
  /**
1166
1178
  * Shadow DOM mode. 'open' (default) or 'closed'.
1167
1179
  * Only applicable when encapsulation is 'shadow'.
@@ -4270,9 +4282,11 @@ interface CompilerRequestResponse {
4270
4282
  interface TranspileOptions {
4271
4283
  /**
4272
4284
  * A component can be defined as a custom element by using `customelement`, or the
4273
- * component class can be exported by using `module`. Default is `customelement`.
4285
+ * component class can be exported by using `module`. Set to `null` to leave the
4286
+ * class's own export as-is (used with `componentMetadata: 'compilerstatic'` for
4287
+ * unit-testing preprocessors). Default is `customelement`.
4274
4288
  */
4275
- componentExport?: 'customelement' | 'module' | string | undefined;
4289
+ componentExport?: 'customelement' | 'module' | string | null | undefined;
4276
4290
  /**
4277
4291
  * Sets how and if component metadata should be assigned on the compiled
4278
4292
  * component output. The `compilerstatic` value will set the metadata to
@@ -4307,8 +4321,11 @@ interface TranspileOptions {
4307
4321
  /**
4308
4322
  * How component styles should be associated to the component. The `static`
4309
4323
  * setting will assign the styles as a static getter on the component class.
4324
+ * Set to `null` to skip the assignment entirely (and leave any `styleUrl`
4325
+ * import unresolved) - useful for unit-testing preprocessors that don't
4326
+ * need real stylesheets.
4310
4327
  */
4311
- style?: 'static' | string | undefined;
4328
+ style?: 'static' | string | null | undefined;
4312
4329
  /**
4313
4330
  * How style data should be added for imports. For example, the `queryparams` value
4314
4331
  * adds the component's tagname and encapsulation info as querystring parameter
@@ -102,6 +102,16 @@ interface ShadowEncapsulation {
102
102
  * declarative slotting behavior.
103
103
  */
104
104
  slotAssignment?: 'manual' | 'named';
105
+ /**
106
+ * When set to `true`, the shadow root is preserved when the host element is deep-cloned via
107
+ * `Node.cloneNode(true)`. Without this, cloning a shadow host produces an empty shell.
108
+ */
109
+ clonable?: boolean;
110
+ /**
111
+ * When set to `true`, marks the shadow root as serializable so it is included when the host
112
+ * element is serialized via `Element.getHTML({ serializableShadowRoots: true })`.
113
+ */
114
+ serializable?: boolean;
105
115
  }
106
116
  /**
107
117
  * Patch types for non-shadow DOM components that use slots.