@stencil/core 5.0.0-alpha.32 → 5.0.0-alpha.34

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 +3 -0
  3. package/dist/client-BVfiFFJ4.mjs +2368 -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-D2MlfN4O.mjs → compiler-DkOB0Joz.mjs} +479 -13
  9. package/dist/declarations/stencil-public-compiler.d.ts +24 -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-BcfVWmNG.d.mts} +44 -3
  13. package/dist/{index-D2PAsXxx.d.ts → index-BsC_D1Ve.d.ts} +4 -0
  14. package/dist/{index-VK8okIiF.d.mts → index-Cy8qbpEV.d.mts} +2 -10
  15. package/dist/index.mjs +1 -1
  16. package/dist/jsx-runtime.mjs +1 -1
  17. package/dist/{node-DRT35FuO.mjs → node-DQBayfoI.mjs} +3 -3
  18. package/dist/runtime/client/lazy.js +15 -3
  19. package/dist/runtime/client/runtime.js +15 -3
  20. package/dist/runtime/index.d.ts +1 -1
  21. package/dist/runtime/index.js +15 -3
  22. package/dist/runtime/server/index.mjs +15 -3
  23. package/dist/runtime/server/runner.mjs +21 -3
  24. package/dist/signals/index.js +3 -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 +4681 -100
  29. package/dist/testing/index.mjs +7558 -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-C3HYn-8p.mjs +0 -4850
  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-C3HYn-8p.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-DRT35FuO.mjs";
2
+ import { S as HYDRATED_CSS } from "./client-BVfiFFJ4.mjs";
3
+ import { $ as VALID_CONFIG_OUTPUT_TARGETS, A as DIST_LAZY, D as COPY, E as COLLECTION_MANIFEST_FILE_NAME, 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-DQBayfoI.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.32";
33
- const buildId = "1787268004";
34
- const vermoji = "🍦";
463
+ const version = "5.0.0-alpha.34";
464
+ const buildId = "1787347536";
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.
@@ -186,6 +617,7 @@ const getModuleLegacy = (compilerCtx, sourceFilePath) => {
186
617
  hasVdomKey: false,
187
618
  hasVdomListener: false,
188
619
  hasVdomPropOrAttr: false,
620
+ hasVdomPropOrAttrPrefix: false,
189
621
  hasVdomRef: false,
190
622
  hasVdomRender: false,
191
623
  hasVdomStyle: false,
@@ -418,6 +850,8 @@ const getBuildFeatures = (cmps) => {
418
850
  shadowDelegatesFocus: shadowDom && cmps.some((c) => c.shadowDelegatesFocus),
419
851
  shadowModeClosed: shadowDom && cmps.some((c) => c.shadowMode === "closed"),
420
852
  shadowSlotAssignmentManual: shadowDom && cmps.some((c) => c.slotAssignment === "manual"),
853
+ shadowClonable: shadowDom && cmps.some((c) => c.shadowClonable),
854
+ shadowSerializable: shadowDom && cmps.some((c) => c.shadowSerializable),
421
855
  slot,
422
856
  slotRelocation,
423
857
  state: cmps.some((c) => c.hasState),
@@ -431,6 +865,7 @@ const getBuildFeatures = (cmps) => {
431
865
  vdomKey: cmps.some((c) => c.hasVdomKey),
432
866
  vdomListener: cmps.some((c) => c.hasVdomListener),
433
867
  vdomPropOrAttr: cmps.some((c) => c.hasVdomPropOrAttr),
868
+ vdomPropOrAttrPrefix: cmps.some((c) => c.hasVdomPropOrAttrPrefix),
434
869
  vdomRef: cmps.some((c) => c.hasVdomRef),
435
870
  vdomRender: cmps.some((c) => c.hasVdomRender),
436
871
  vdomStyle: cmps.some((c) => c.hasVdomStyle),
@@ -451,6 +886,7 @@ const updateComponentBuildConditionals = (moduleMap, cmps) => {
451
886
  getModuleImports(moduleMap, cmp.sourceFilePath, []).forEach((importedModule) => {
452
887
  cmp.hasVdomAttribute = cmp.hasVdomAttribute || importedModule.hasVdomAttribute;
453
888
  cmp.hasVdomPropOrAttr = cmp.hasVdomPropOrAttr || importedModule.hasVdomPropOrAttr;
889
+ cmp.hasVdomPropOrAttrPrefix = cmp.hasVdomPropOrAttrPrefix || importedModule.hasVdomPropOrAttrPrefix;
454
890
  cmp.hasVdomXlink = cmp.hasVdomXlink || importedModule.hasVdomXlink;
455
891
  cmp.hasVdomClass = cmp.hasVdomClass || importedModule.hasVdomClass;
456
892
  cmp.hasVdomFunctional = cmp.hasVdomFunctional || importedModule.hasVdomFunctional;
@@ -4121,6 +4557,7 @@ const createModule = (staticSourceFile, staticSourceFileText, emitFilepath) => (
4121
4557
  hasVdomKey: false,
4122
4558
  hasVdomListener: false,
4123
4559
  hasVdomPropOrAttr: false,
4560
+ hasVdomPropOrAttrPrefix: false,
4124
4561
  hasVdomRef: false,
4125
4562
  hasVdomRender: false,
4126
4563
  hasVdomStyle: false,
@@ -12428,6 +12865,7 @@ const gatherVdomMeta = (m, args, typeChecker) => {
12428
12865
  m.hasVdomKey = true;
12429
12866
  m.hasVdomListener = true;
12430
12867
  m.hasVdomPropOrAttr = true;
12868
+ m.hasVdomPropOrAttrPrefix = true;
12431
12869
  m.hasVdomRef = true;
12432
12870
  m.hasVdomStyle = true;
12433
12871
  m.hasVdomXlink = true;
@@ -12441,6 +12879,7 @@ const gatherVdomMeta = (m, args, typeChecker) => {
12441
12879
  m.hasVdomKey = true;
12442
12880
  m.hasVdomListener = true;
12443
12881
  m.hasVdomPropOrAttr = true;
12882
+ m.hasVdomPropOrAttrPrefix = true;
12444
12883
  m.hasVdomRef = true;
12445
12884
  m.hasVdomStyle = true;
12446
12885
  m.hasVdomXlink = true;
@@ -12455,7 +12894,8 @@ const gatherVdomMeta = (m, args, typeChecker) => {
12455
12894
  else if (attrName.startsWith("xlink")) {
12456
12895
  m.hasVdomXlink = true;
12457
12896
  m.hasVdomPropOrAttr = true;
12458
- } else m.hasVdomPropOrAttr = true;
12897
+ } else if (attrName.startsWith("attr:") || attrName.startsWith("prop:")) m.hasVdomPropOrAttrPrefix = true;
12898
+ else m.hasVdomPropOrAttr = true;
12459
12899
  if (attrName === "part" && ts.isPropertyAssignment(prop)) {
12460
12900
  const partValue = resolveStaticStringValue(prop.initializer, typeChecker);
12461
12901
  if (partValue !== void 0) m.htmlParts.push(...partValue.split(" ").filter((part) => part.length > 0));
@@ -13046,6 +13486,8 @@ const componentDecoratorToStatic = (config, typeChecker, diagnostics, cmpNode, n
13046
13486
  if (enc.mode === "closed") newMembers.push(createStaticGetter("shadowMode", convertValueToLiteral("closed")));
13047
13487
  if (enc.delegatesFocus === true) newMembers.push(createStaticGetter("delegatesFocus", convertValueToLiteral(true)));
13048
13488
  if (enc.slotAssignment === "manual") newMembers.push(createStaticGetter("slotAssignment", convertValueToLiteral("manual")));
13489
+ if (enc.clonable === true) newMembers.push(createStaticGetter("clonable", convertValueToLiteral(true)));
13490
+ if (enc.serializable === true) newMembers.push(createStaticGetter("serializable", convertValueToLiteral(true)));
13049
13491
  } else if (enc.type === "scoped") {
13050
13492
  newMembers.push(createStaticGetter("encapsulation", convertValueToLiteral("scoped")));
13051
13493
  if (enc.patches && enc.patches.length > 0) newMembers.push(createStaticGetter("patches", convertValueToLiteral(enc.patches)));
@@ -15706,6 +16148,30 @@ const parseStaticShadowDelegatesFocus = (encapsulation, staticMembers) => {
15706
16148
  return null;
15707
16149
  };
15708
16150
  /**
16151
+ * Find and return if `clonable` is enabled for a component based on the return value of its static getter of the
16152
+ * same name.
16153
+ *
16154
+ * @param encapsulation the encapsulation mode to use for a component
16155
+ * @param staticMembers a collection of static getters to search
16156
+ * @returns `true` if encapsulation is 'shadow' and the `clonable` static getter returns true
16157
+ */
16158
+ const parseStaticShadowClonable = (encapsulation, staticMembers) => {
16159
+ if (encapsulation === "shadow") return !!getStaticValue(staticMembers, "clonable");
16160
+ return null;
16161
+ };
16162
+ /**
16163
+ * Find and return if `serializable` is enabled for a component based on the return value of its static getter of
16164
+ * the same name.
16165
+ *
16166
+ * @param encapsulation the encapsulation mode to use for a component
16167
+ * @param staticMembers a collection of static getters to search
16168
+ * @returns `true` if encapsulation is 'shadow' and the `serializable` static getter returns true
16169
+ */
16170
+ const parseStaticShadowSerializable = (encapsulation, staticMembers) => {
16171
+ if (encapsulation === "shadow") return !!getStaticValue(staticMembers, "serializable");
16172
+ return null;
16173
+ };
16174
+ /**
15709
16175
  * Find and return the `slotAssignment` mode for a component.
15710
16176
  *
15711
16177
  * @param encapsulation the encapsulation mode to use for a component
@@ -15929,6 +16395,8 @@ const parseStaticComponentMeta = (compilerCtx, typeChecker, cmpNode, moduleFile,
15929
16395
  elementRef: parseStaticElementRef(staticMembers),
15930
16396
  encapsulation,
15931
16397
  shadowDelegatesFocus: !!parseStaticShadowDelegatesFocus(encapsulation, staticMembers),
16398
+ shadowClonable: !!parseStaticShadowClonable(encapsulation, staticMembers),
16399
+ shadowSerializable: !!parseStaticShadowSerializable(encapsulation, staticMembers),
15932
16400
  shadowMode: parseStaticShadowMode(encapsulation, staticMembers),
15933
16401
  slotAssignment: parseStaticSlotAssignment(encapsulation, staticMembers),
15934
16402
  patches: parseStaticPatches(encapsulation, staticMembers),
@@ -15993,6 +16461,7 @@ const parseStaticComponentMeta = (compilerCtx, typeChecker, cmpNode, moduleFile,
15993
16461
  hasVdomKey: false,
15994
16462
  hasVdomListener: false,
15995
16463
  hasVdomPropOrAttr: false,
16464
+ hasVdomPropOrAttrPrefix: false,
15996
16465
  hasVdomRef: false,
15997
16466
  hasVdomRender: false,
15998
16467
  hasVdomStyle: false,
@@ -18945,9 +19414,6 @@ const validateDocs$1 = (config, diagnostics, userOutputs) => {
18945
19414
  userOutputs.filter(isOutputTargetDocsJson).forEach((jsonDocsOutput) => {
18946
19415
  docsOutputs.push(validateJsonDocsOutputTarget(config, diagnostics, jsonDocsOutput));
18947
19416
  });
18948
- if (!config.devMode || config._docsFlag) {
18949
- if (!userOutputs.some(isOutputTargetDocsReadme)) docsOutputs.push(validateReadmeOutputTarget(config, { type: DOCS_README }));
18950
- }
18951
19417
  userOutputs.filter(isOutputTargetDocsReadme).forEach((readmeDocsOutput) => {
18952
19418
  docsOutputs.push(validateReadmeOutputTarget(config, readmeDocsOutput));
18953
19419
  });
@@ -24165,4 +24631,4 @@ const shouldTranspileModule = (ext) => [
24165
24631
  "js"
24166
24632
  ].includes(ext);
24167
24633
  //#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 };
24634
+ 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
@@ -682,6 +684,8 @@ interface BuildFeatures {
682
684
  vdomKey: boolean;
683
685
  vdomListener: boolean;
684
686
  vdomPropOrAttr: boolean;
687
+ /** True when at least one component uses the explicit `attr:`/`prop:` JSX prefix. */
688
+ vdomPropOrAttrPrefix: boolean;
685
689
  vdomRef: boolean;
686
690
  vdomStyle: boolean;
687
691
  vdomText: boolean;
@@ -1079,6 +1083,7 @@ interface ComponentCompilerFeatures {
1079
1083
  hasVdomKey: boolean;
1080
1084
  hasVdomListener: boolean;
1081
1085
  hasVdomPropOrAttr: boolean;
1086
+ hasVdomPropOrAttrPrefix: boolean;
1082
1087
  hasVdomRef: boolean;
1083
1088
  hasVdomRender: boolean;
1084
1089
  hasVdomStyle: boolean;
@@ -1162,6 +1167,16 @@ interface ComponentCompilerMeta extends ComponentCompilerFeatures {
1162
1167
  properties: ComponentCompilerProperty[];
1163
1168
  serializers: ComponentCompilerChangeHandler[];
1164
1169
  shadowDelegatesFocus: boolean;
1170
+ /**
1171
+ * Whether the shadow root is preserved when the host element is deep-cloned via
1172
+ * `Node.cloneNode(true)`. Only applicable when encapsulation is 'shadow'.
1173
+ */
1174
+ shadowClonable: boolean;
1175
+ /**
1176
+ * Whether the shadow root is marked serializable for `Element.getHTML({ serializableShadowRoots: true })`.
1177
+ * Only applicable when encapsulation is 'shadow'.
1178
+ */
1179
+ shadowSerializable: boolean;
1165
1180
  /**
1166
1181
  * Shadow DOM mode. 'open' (default) or 'closed'.
1167
1182
  * Only applicable when encapsulation is 'shadow'.
@@ -1523,6 +1538,7 @@ interface Module {
1523
1538
  hasVdomKey: boolean;
1524
1539
  hasVdomListener: boolean;
1525
1540
  hasVdomPropOrAttr: boolean;
1541
+ hasVdomPropOrAttrPrefix: boolean;
1526
1542
  hasVdomRef: boolean;
1527
1543
  hasVdomRender: boolean;
1528
1544
  hasVdomStyle: boolean;
@@ -4270,9 +4286,11 @@ interface CompilerRequestResponse {
4270
4286
  interface TranspileOptions {
4271
4287
  /**
4272
4288
  * 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`.
4289
+ * component class can be exported by using `module`. Set to `null` to leave the
4290
+ * class's own export as-is (used with `componentMetadata: 'compilerstatic'` for
4291
+ * unit-testing preprocessors). Default is `customelement`.
4274
4292
  */
4275
- componentExport?: 'customelement' | 'module' | string | undefined;
4293
+ componentExport?: 'customelement' | 'module' | string | null | undefined;
4276
4294
  /**
4277
4295
  * Sets how and if component metadata should be assigned on the compiled
4278
4296
  * component output. The `compilerstatic` value will set the metadata to
@@ -4307,8 +4325,11 @@ interface TranspileOptions {
4307
4325
  /**
4308
4326
  * How component styles should be associated to the component. The `static`
4309
4327
  * setting will assign the styles as a static getter on the component class.
4328
+ * Set to `null` to skip the assignment entirely (and leave any `styleUrl`
4329
+ * import unresolved) - useful for unit-testing preprocessors that don't
4330
+ * need real stylesheets.
4310
4331
  */
4311
- style?: 'static' | string | undefined;
4332
+ style?: 'static' | string | null | undefined;
4312
4333
  /**
4313
4334
  * How style data should be added for imports. For example, the `queryparams` value
4314
4335
  * adds the component's tagname and encapsulation info as querystring parameter