@stencil/core 5.0.0-beta.12 → 5.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{client-CdFmjaQa.mjs → client-NHI55T4R.mjs} +7 -4
- package/dist/compiler/browser.d.ts +96 -54
- package/dist/compiler/browser.js +140 -18
- package/dist/compiler/index.d.mts +87 -2
- package/dist/compiler/index.mjs +3 -3
- package/dist/compiler/utils/index.d.mts +1 -1
- package/dist/{compiler-BjKDj129.mjs → compiler-Dr9JHtLp.mjs} +3571 -2384
- package/dist/declarations/stencil-public-compiler.d.ts +85 -59
- package/dist/declarations/stencil-public-docs.d.ts +23 -0
- package/dist/declarations/stencil-public-runtime.d.ts +2 -2
- package/dist/{index-CKnzMkZC.d.mts → index-BBJVAnzJ.d.mts} +2 -2
- package/dist/{index-Cw1NW9FW.d.mts → index-BilaSOF5.d.mts} +87 -61
- package/dist/index.mjs +1 -1
- package/dist/jsx-runtime.mjs +1 -1
- package/dist/{node-HKfDhPR3.mjs → node-DrwzfDH1.mjs} +1 -1
- package/dist/runtime/client/lazy.js +87 -84
- package/dist/runtime/client/runtime.d.ts +5 -6
- package/dist/runtime/client/runtime.js +87 -84
- package/dist/runtime/index.d.ts +2 -3
- package/dist/runtime/index.js +85 -82
- package/dist/runtime/server/index.d.mts +4 -5
- package/dist/runtime/server/index.mjs +97 -84
- package/dist/runtime/server/runner.mjs +27 -41
- 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 +77 -58
- package/dist/testing/index.mjs +167 -156
- package/package.json +5 -4
|
@@ -137,7 +137,7 @@ const setErrorHandler = (handler) => customError = handler;
|
|
|
137
137
|
//#endregion
|
|
138
138
|
//#region src/client/client-style.ts
|
|
139
139
|
const styles = /*@__PURE__*/ new Map();
|
|
140
|
-
const
|
|
140
|
+
const modeResolver = [];
|
|
141
141
|
//#endregion
|
|
142
142
|
//#region src/runtime/runtime-constants.ts
|
|
143
143
|
/**
|
|
@@ -863,10 +863,10 @@ const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialR
|
|
|
863
863
|
const isComplex = isComplexType(newValue);
|
|
864
864
|
if (!BUILD.lazyLoad) {
|
|
865
865
|
const isStandardAttr = ln.startsWith("aria-") || ln.startsWith("data-");
|
|
866
|
-
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" &&
|
|
866
|
+
if (!isProp && !isStandardAttr && elm.tagName?.includes("-") && elm.tagName !== "SLOT-FB" && !customElements.get(elm.tagName.toLowerCase())) {
|
|
867
867
|
if (!elm["s-pp"]) elm["s-pp"] = /* @__PURE__ */ new Map();
|
|
868
868
|
elm["s-pp"].set(memberName, newValue);
|
|
869
|
-
return;
|
|
869
|
+
if (isComplex || /[A-Z]/.test(memberName)) return;
|
|
870
870
|
}
|
|
871
871
|
}
|
|
872
872
|
if ((isProp || isComplex && newValue !== null) && !isSvg) try {
|
|
@@ -2228,7 +2228,10 @@ const validateInputProperties = (inputElm) => {
|
|
|
2228
2228
|
};
|
|
2229
2229
|
//#endregion
|
|
2230
2230
|
//#region src/runtime/mode.ts
|
|
2231
|
-
const setMode = (handler) =>
|
|
2231
|
+
const setMode = (handler) => {
|
|
2232
|
+
modeResolver.length = 0;
|
|
2233
|
+
modeResolver.push(handler);
|
|
2234
|
+
};
|
|
2232
2235
|
const getMode = (ref) => getHostRef(ref)?.$modeName$;
|
|
2233
2236
|
//#endregion
|
|
2234
2237
|
//#region src/runtime/mixin.ts
|
|
@@ -1,11 +1,77 @@
|
|
|
1
1
|
import ts from "typescript";
|
|
2
2
|
import "rolldown";
|
|
3
3
|
//#region src/declarations/stencil-public-docs.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A descriptor for a single JSDoc tag found in a block comment
|
|
6
|
+
*/
|
|
7
|
+
interface JsonDocsTag {
|
|
8
|
+
/**
|
|
9
|
+
* The tag name (immediately following the '@')
|
|
10
|
+
*/
|
|
11
|
+
name: string;
|
|
12
|
+
/**
|
|
13
|
+
* The description that immediately follows the tag name
|
|
14
|
+
*/
|
|
15
|
+
text?: string;
|
|
16
|
+
}
|
|
4
17
|
interface JsonDocMethodParameter {
|
|
5
18
|
name: string;
|
|
6
19
|
type: string;
|
|
7
20
|
docs: string;
|
|
8
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* A descriptor for a Custom State defined via @AttachInternals({ states: {...} })
|
|
24
|
+
*
|
|
25
|
+
* Custom states are exposed via the ElementInternals.states CustomStateSet
|
|
26
|
+
* and can be targeted with the CSS `:state()` pseudo-class.
|
|
27
|
+
*
|
|
28
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet
|
|
29
|
+
*/
|
|
30
|
+
interface JsonDocsCustomState {
|
|
31
|
+
/**
|
|
32
|
+
* The name of the custom state (without dashes)
|
|
33
|
+
*/
|
|
34
|
+
name: string;
|
|
35
|
+
/**
|
|
36
|
+
* The initial/default value of the state
|
|
37
|
+
*/
|
|
38
|
+
initialValue: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* A textual description of the custom state
|
|
41
|
+
*/
|
|
42
|
+
docs: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Represents a parsed block comment in a CSS, Sass, etc. file for a custom property.
|
|
46
|
+
*/
|
|
47
|
+
interface StyleDoc {
|
|
48
|
+
/**
|
|
49
|
+
* The name of the CSS property
|
|
50
|
+
*/
|
|
51
|
+
name: string;
|
|
52
|
+
/**
|
|
53
|
+
* The user-defined description of the CSS property
|
|
54
|
+
*/
|
|
55
|
+
docs: string;
|
|
56
|
+
/**
|
|
57
|
+
* The JSDoc-style annotation (e.g. `@prop`) that was used in the block comment to detect the comment.
|
|
58
|
+
* Used to inform Stencil where the start of a new property's description starts (and where the previous description
|
|
59
|
+
* ends).
|
|
60
|
+
*/
|
|
61
|
+
annotation: 'prop';
|
|
62
|
+
/**
|
|
63
|
+
* The Stencil style-mode that is associated with this property.
|
|
64
|
+
*/
|
|
65
|
+
mode: string | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* The CSS `syntax` descriptor, if this property was registered via a native `@property` at-rule.
|
|
68
|
+
*/
|
|
69
|
+
syntax?: string;
|
|
70
|
+
/**
|
|
71
|
+
* The `initial-value` descriptor, if this property was registered via a native `@property` at-rule.
|
|
72
|
+
*/
|
|
73
|
+
default?: string;
|
|
74
|
+
}
|
|
9
75
|
//#endregion
|
|
10
76
|
//#region src/declarations/stencil-public-runtime.d.ts
|
|
11
77
|
type ListenTargetOptions = 'body' | 'document' | 'window';
|
|
@@ -367,6 +433,7 @@ interface CompilerBuildResults {
|
|
|
367
433
|
buildId: number;
|
|
368
434
|
componentGraph?: BuildResultsComponentGraph;
|
|
369
435
|
components: ComponentCompilerMeta[];
|
|
436
|
+
cssOnlyComponents: ComponentCompilerMeta[];
|
|
370
437
|
diagnostics: Diagnostic[];
|
|
371
438
|
dirsAdded: string[];
|
|
372
439
|
dirsDeleted: string[];
|
|
@@ -383,6 +450,15 @@ interface CompilerBuildResults {
|
|
|
383
450
|
namespace: string;
|
|
384
451
|
fsNamespace: string;
|
|
385
452
|
outputs: BuildOutput[];
|
|
453
|
+
/**
|
|
454
|
+
* Absolute paths to every global stylesheet, in cascade order: each `global-style` output
|
|
455
|
+
* target's compiled CSS in the order those targets are declared in `config.outputTargets` - or,
|
|
456
|
+
* with none configured, the generated `{fsNamespace}.css` holding Stencil's auto-placed CSS (when
|
|
457
|
+
* emitted). Unlike `outputs`, which groups files by type and sorts them alphabetically, this
|
|
458
|
+
* preserves author-intended order for consumers like the dev-server's auto-generated component
|
|
459
|
+
* preview.
|
|
460
|
+
*/
|
|
461
|
+
globalStyleFiles: string[];
|
|
386
462
|
rootDir: string;
|
|
387
463
|
srcDir: string;
|
|
388
464
|
timestamp: string;
|
|
@@ -398,6 +474,7 @@ interface HotModuleReplacement {
|
|
|
398
474
|
componentsUpdated?: string[];
|
|
399
475
|
excludeHmr?: string[];
|
|
400
476
|
externalStylesUpdated?: string[];
|
|
477
|
+
globalStylesUpdated?: HmrGlobalStyleUpdate[];
|
|
401
478
|
imagesUpdated?: string[];
|
|
402
479
|
indexHtmlUpdated?: boolean;
|
|
403
480
|
inlineStylesUpdated?: HmrStyleUpdate[];
|
|
@@ -412,6 +489,15 @@ interface HmrStyleUpdate {
|
|
|
412
489
|
styleTag: string;
|
|
413
490
|
styleText: string;
|
|
414
491
|
}
|
|
492
|
+
/**
|
|
493
|
+
* A live-reload update for a `global-style` output target's CSS. Applied on
|
|
494
|
+
* the client by matching `fileName` against the `<link>` that loads it and
|
|
495
|
+
* inserting/updating an adjacent `<style>` override
|
|
496
|
+
*/
|
|
497
|
+
interface HmrGlobalStyleUpdate {
|
|
498
|
+
fileName: string;
|
|
499
|
+
styleText: string;
|
|
500
|
+
}
|
|
415
501
|
type BuildOnEventRemove = () => boolean;
|
|
416
502
|
interface BuildEvents extends BuildOnEvents, BuildEmitEvents {
|
|
417
503
|
unsubscribeAll(): void;
|
|
@@ -839,6 +925,12 @@ interface TranspileOptions {
|
|
|
839
925
|
* that the specified flags take effect for this component at runtime.
|
|
840
926
|
*/
|
|
841
927
|
buildOverrides?: BuildOverrides;
|
|
928
|
+
/**
|
|
929
|
+
* When `true`, a `.css`/`.scss` transpile also collects CSS custom-property docs
|
|
930
|
+
* onto {@link TranspileResults.styleDocs}. Off by default, since it costs an extra parse
|
|
931
|
+
* of the style text.
|
|
932
|
+
*/
|
|
933
|
+
docs?: boolean;
|
|
842
934
|
}
|
|
843
935
|
/**
|
|
844
936
|
* Keys of {@link BuildConditionals} that can be meaningfully overridden at
|
|
@@ -864,6 +956,7 @@ interface TranspileResults {
|
|
|
864
956
|
inputFilePath: string;
|
|
865
957
|
map: any;
|
|
866
958
|
outputFilePath: string;
|
|
959
|
+
styleDocs?: StyleDoc[];
|
|
867
960
|
}
|
|
868
961
|
//#endregion
|
|
869
962
|
//#region src/declarations/stencil-private.d.ts
|
|
@@ -1070,7 +1163,7 @@ interface ComponentCompilerMeta extends ComponentCompilerFeatures {
|
|
|
1070
1163
|
* Custom states to initialize on the ElementInternals.states CustomStateSet.
|
|
1071
1164
|
* These are defined via @AttachInternals({ states: {...} }).
|
|
1072
1165
|
*/
|
|
1073
|
-
attachInternalsCustomStates:
|
|
1166
|
+
attachInternalsCustomStates: JsonDocsCustomState[];
|
|
1074
1167
|
componentClassName: string;
|
|
1075
1168
|
/**
|
|
1076
1169
|
* A list of web component tag names that are either:
|
|
@@ -1140,7 +1233,7 @@ interface ComponentCompilerMeta extends ComponentCompilerFeatures {
|
|
|
1140
1233
|
sourceFilePath: string;
|
|
1141
1234
|
sourceMapPath: string;
|
|
1142
1235
|
states: ComponentCompilerState[];
|
|
1143
|
-
styleDocs:
|
|
1236
|
+
styleDocs: StyleDoc[];
|
|
1144
1237
|
styles: StyleCompiler[];
|
|
1145
1238
|
globalStyles: ComponentGlobalStyle[];
|
|
1146
1239
|
tagName: string;
|
|
@@ -1324,20 +1417,6 @@ interface ComponentCompilerState {
|
|
|
1324
1417
|
* Custom states are exposed via the ElementInternals.states CustomStateSet
|
|
1325
1418
|
* and can be targeted with the CSS :state() pseudo-class.
|
|
1326
1419
|
*/
|
|
1327
|
-
interface ComponentCompilerCustomState {
|
|
1328
|
-
/**
|
|
1329
|
-
* The name of the custom state (without dashes)
|
|
1330
|
-
*/
|
|
1331
|
-
name: string;
|
|
1332
|
-
/**
|
|
1333
|
-
* The initial value of the state
|
|
1334
|
-
*/
|
|
1335
|
-
initialValue: boolean;
|
|
1336
|
-
/**
|
|
1337
|
-
* Optional JSDoc description for the state
|
|
1338
|
-
*/
|
|
1339
|
-
docs: string;
|
|
1340
|
-
}
|
|
1341
1420
|
/**
|
|
1342
1421
|
* Representation of JSDoc that is pulled off a node in the AST
|
|
1343
1422
|
*/
|
|
@@ -1349,44 +1428,7 @@ interface CompilerJsDoc {
|
|
|
1349
1428
|
/**
|
|
1350
1429
|
* Tags included in the JSDoc
|
|
1351
1430
|
*/
|
|
1352
|
-
tags:
|
|
1353
|
-
}
|
|
1354
|
-
/**
|
|
1355
|
-
* Representation of a tag that exists in a JSDoc
|
|
1356
|
-
*/
|
|
1357
|
-
interface CompilerJsDocTagInfo {
|
|
1358
|
-
/**
|
|
1359
|
-
* The name of the tag - e.g. `@deprecated`
|
|
1360
|
-
*/
|
|
1361
|
-
name: string;
|
|
1362
|
-
/**
|
|
1363
|
-
* Additional text that is associated with the tag - e.g. `@deprecated use v2 of this API`
|
|
1364
|
-
*/
|
|
1365
|
-
text?: string;
|
|
1366
|
-
}
|
|
1367
|
-
/**
|
|
1368
|
-
* The (internal) representation of a CSS block comment in a CSS, Sass, etc. file. This data structure is used during
|
|
1369
|
-
* the initial compilation phases of Stencil, as a piece of {@link ComponentCompilerMeta}.
|
|
1370
|
-
*/
|
|
1371
|
-
interface CompilerStyleDoc {
|
|
1372
|
-
/**
|
|
1373
|
-
* The name of the CSS property
|
|
1374
|
-
*/
|
|
1375
|
-
name: string;
|
|
1376
|
-
/**
|
|
1377
|
-
* The user-defined description of the CSS property
|
|
1378
|
-
*/
|
|
1379
|
-
docs: string;
|
|
1380
|
-
/**
|
|
1381
|
-
* The JSDoc-style annotation (e.g. `@prop`) that was used in the block comment to detect the comment.
|
|
1382
|
-
* Used to inform Stencil where the start of a new property's description starts (and where the previous description
|
|
1383
|
-
* ends).
|
|
1384
|
-
*/
|
|
1385
|
-
annotation: 'prop';
|
|
1386
|
-
/**
|
|
1387
|
-
* The Stencil style-mode that is associated with this property.
|
|
1388
|
-
*/
|
|
1389
|
-
mode: string;
|
|
1431
|
+
tags: JsonDocsTag[];
|
|
1390
1432
|
}
|
|
1391
1433
|
interface CompilerAssetDir {
|
|
1392
1434
|
absolutePath?: string;
|
package/dist/compiler/browser.js
CHANGED
|
@@ -1844,7 +1844,7 @@ const validateComponentTag = (tag) => {
|
|
|
1844
1844
|
};
|
|
1845
1845
|
//#endregion
|
|
1846
1846
|
//#region src/version.ts
|
|
1847
|
-
const version = "5.0.0-beta.
|
|
1847
|
+
const version = "5.0.0-beta.13";
|
|
1848
1848
|
//#endregion
|
|
1849
1849
|
//#region src/compiler/events.ts
|
|
1850
1850
|
const buildEvents = () => {
|
|
@@ -2646,7 +2646,8 @@ const getTranspileCssConfig = (compileOpts, importData, results) => {
|
|
|
2646
2646
|
minify: false,
|
|
2647
2647
|
autoprefixer: false,
|
|
2648
2648
|
module: compileOpts.module,
|
|
2649
|
-
styleImportData: compileOpts.styleImportData
|
|
2649
|
+
styleImportData: compileOpts.styleImportData,
|
|
2650
|
+
docs: compileOpts.docs === true
|
|
2650
2651
|
};
|
|
2651
2652
|
};
|
|
2652
2653
|
const getTranspileConfigOpt = (value, validValues, defaultValue) => {
|
|
@@ -3827,6 +3828,7 @@ const validateConfig = (userConfig = {}, bootstrapConfig) => {
|
|
|
3827
3828
|
devMode,
|
|
3828
3829
|
compat: config.compat || {},
|
|
3829
3830
|
generateExportMaps: isBoolean$1(config.generateExportMaps) ? config.generateExportMaps : !isString$1(config.configPath),
|
|
3831
|
+
enableCssOnlyComponents: config.enableCssOnlyComponents ?? true,
|
|
3830
3832
|
hydratedFlag: validateHydrated(config),
|
|
3831
3833
|
logLevel,
|
|
3832
3834
|
logger,
|
|
@@ -3884,29 +3886,137 @@ const validateConfig = (userConfig = {}, bootstrapConfig) => {
|
|
|
3884
3886
|
};
|
|
3885
3887
|
};
|
|
3886
3888
|
//#endregion
|
|
3889
|
+
//#region src/compiler/docs/css-doc-comments.ts
|
|
3890
|
+
/**
|
|
3891
|
+
* A JSDoc-style comment is `/** ... *\/` or `/*! ... *\/` - postcss's `Comment.text` already
|
|
3892
|
+
* strips the `/*`/`*\/` delimiters, so this checks the leading `*` or `!` that remains.
|
|
3893
|
+
* @param commentText a postcss `Comment` node's `.text`
|
|
3894
|
+
* @returns `true` if the comment is JSDoc-style
|
|
3895
|
+
*/
|
|
3896
|
+
const isJsDocComment = (commentText) => commentText.startsWith("*") || commentText.startsWith("!");
|
|
3897
|
+
/**
|
|
3898
|
+
* Strip the leading `*`/`!` marker and per-line `*` prefixes, returning trimmed lines.
|
|
3899
|
+
* @param commentText a postcss `Comment` node's `.text`
|
|
3900
|
+
* @returns the comment's lines, delimiters and leading `*`s stripped
|
|
3901
|
+
*/
|
|
3902
|
+
const normalizeJsDocLines = (commentText) => {
|
|
3903
|
+
return commentText.replace(/^[*!]/, "").split(/\r?\n/).map((line) => line.trim().replace(/^\*/, "").trim()).filter((line, i, arr) => !(line === "" && (i === 0 || i === arr.length - 1)));
|
|
3904
|
+
};
|
|
3905
|
+
/**
|
|
3906
|
+
* @param commentText a postcss `Comment` node's `.text`
|
|
3907
|
+
* @returns the comment's lines joined into a single trimmed line of text
|
|
3908
|
+
*/
|
|
3909
|
+
const normalizeJsDocText = (commentText) => normalizeJsDocLines(commentText).filter(Boolean).join(" ").trim();
|
|
3910
|
+
/**
|
|
3911
|
+
* @param value a CSS descriptor value, possibly quoted (e.g. a `syntax` descriptor's `"<length>"`)
|
|
3912
|
+
* @returns the value with any surrounding quotes removed
|
|
3913
|
+
*/
|
|
3914
|
+
const stripQuotes = (value) => value.replace(/^['"]|['"]$/g, "");
|
|
3915
|
+
/**
|
|
3916
|
+
* Extract the `syntax`/`initial-value` descriptors from a native `@property` at-rule's body.
|
|
3917
|
+
* @param node a postcss `AtRule` node whose `name` is `property`
|
|
3918
|
+
* @returns the extracted descriptors, if present
|
|
3919
|
+
*/
|
|
3920
|
+
const parsePropertyAtRuleDescriptors = (node) => {
|
|
3921
|
+
let syntax;
|
|
3922
|
+
let initialValue;
|
|
3923
|
+
node.each((child) => {
|
|
3924
|
+
if (child.type !== "decl") return;
|
|
3925
|
+
if (child.prop === "syntax") syntax = stripQuotes(child.value);
|
|
3926
|
+
else if (child.prop === "initial-value") initialValue = child.value;
|
|
3927
|
+
});
|
|
3928
|
+
return {
|
|
3929
|
+
syntax,
|
|
3930
|
+
initialValue
|
|
3931
|
+
};
|
|
3932
|
+
};
|
|
3933
|
+
//#endregion
|
|
3887
3934
|
//#region src/compiler/docs/style-docs.ts
|
|
3888
3935
|
/**
|
|
3889
3936
|
* Parse CSS docstrings that Stencil supports, as documented here:
|
|
3890
3937
|
* https://stenciljs.com/docs/docs-json#css-variables
|
|
3891
3938
|
*
|
|
3892
|
-
* Docstrings found in the supplied style text will be added to the
|
|
3893
|
-
*
|
|
3939
|
+
* Docstrings found in the supplied style text will be added to the `styleDocs` param, via three
|
|
3940
|
+
* mechanisms, in order of precedence (an earlier mechanism always wins over a later one for the
|
|
3941
|
+
* same custom property name):
|
|
3942
|
+
* 1. An explicit `@prop`/`@cssprop`/`@cssproperty` annotation in a block comment, anywhere in the file.
|
|
3943
|
+
* 2. A doc-commented `--foo: value;` declaration inside the component's "root" rule - `:host`
|
|
3944
|
+
* for `shadow`/`scoped` encapsulation, or the component's own tag selector for `none`.
|
|
3945
|
+
* 3. A native `@property --foo { ... }` at-rule, with the `syntax`/`initial-value` descriptors
|
|
3946
|
+
* surfaced as `syntax`/`default`. Not scoped - `@property` is a global registration.
|
|
3894
3947
|
*
|
|
3895
3948
|
* @param styleDocs the array to hold formatted CSS docstrings
|
|
3896
3949
|
* @param styleText the CSS text we're working with
|
|
3897
3950
|
* @param mode a mode associated with the parsed style, if applicable (e.g. this is not applicable for global styles)
|
|
3951
|
+
* @param tag the component's tag name, used to scope auto-detection for `none` encapsulation
|
|
3952
|
+
* @param encapsulation the component's encapsulation, used to pick the "root" scope for auto-detection
|
|
3898
3953
|
*/
|
|
3899
|
-
function parseStyleDocs(styleDocs, styleText, mode) {
|
|
3954
|
+
function parseStyleDocs(styleDocs, styleText, mode, tag, encapsulation) {
|
|
3900
3955
|
if (typeof styleText !== "string") return;
|
|
3901
|
-
let
|
|
3956
|
+
let remainingText = styleText;
|
|
3957
|
+
let match = remainingText.match(CSS_DOC_START);
|
|
3902
3958
|
while (match !== null) {
|
|
3903
|
-
|
|
3904
|
-
const endIndex =
|
|
3959
|
+
remainingText = remainingText.substring(match.index + match[0].length);
|
|
3960
|
+
const endIndex = remainingText.indexOf(CSS_DOC_END);
|
|
3905
3961
|
if (endIndex === -1) break;
|
|
3906
|
-
parseCssComment(styleDocs,
|
|
3907
|
-
|
|
3908
|
-
match =
|
|
3962
|
+
parseCssComment(styleDocs, remainingText.substring(0, endIndex), mode);
|
|
3963
|
+
remainingText = remainingText.substring(endIndex + CSS_DOC_END.length);
|
|
3964
|
+
match = remainingText.match(CSS_DOC_START);
|
|
3909
3965
|
}
|
|
3966
|
+
if (styleText.includes("--")) parseScopedAndNativeStyleDocs(styleDocs, styleText, mode, tag, encapsulation);
|
|
3967
|
+
}
|
|
3968
|
+
/**
|
|
3969
|
+
* Auto-detect doc-commented custom-property declarations within the component's "root" rule,
|
|
3970
|
+
* and native `@property` at-rule registrations, merging them into `styleDocs`. Mirrors the
|
|
3971
|
+
* equivalent detection for CSS-only components in `css-components/parse-css-component.ts`.
|
|
3972
|
+
*
|
|
3973
|
+
* @param styleDocs the array to hold formatted CSS docstrings - also consulted so an explicit
|
|
3974
|
+
* `@prop`/`@cssprop` annotation always wins over an auto-detected entry for the same name
|
|
3975
|
+
* @param styleText the CSS text we're working with
|
|
3976
|
+
* @param mode a mode associated with the parsed style, if applicable
|
|
3977
|
+
* @param tag the component's tag name
|
|
3978
|
+
* @param encapsulation the component's encapsulation
|
|
3979
|
+
*/
|
|
3980
|
+
function parseScopedAndNativeStyleDocs(styleDocs, styleText, mode, tag, encapsulation) {
|
|
3981
|
+
let root;
|
|
3982
|
+
try {
|
|
3983
|
+
root = postcss().process(styleText, { from: void 0 }).root;
|
|
3984
|
+
} catch {
|
|
3985
|
+
return;
|
|
3986
|
+
}
|
|
3987
|
+
const hasName = (name) => styleDocs.some((styleDoc) => styleDoc.name === name);
|
|
3988
|
+
const rootSelector = encapsulation === "shadow" || encapsulation === "scoped" ? ":host" : tag;
|
|
3989
|
+
if (rootSelector) root.walkRules((rule) => {
|
|
3990
|
+
if (!rule.selectors.some((selector) => selector.trim() === rootSelector)) return;
|
|
3991
|
+
const children = rule.nodes;
|
|
3992
|
+
for (let i = 0; i < children.length; i++) {
|
|
3993
|
+
const child = children[i];
|
|
3994
|
+
if (child.type !== "decl" || !child.prop.startsWith("--") || hasName(child.prop)) continue;
|
|
3995
|
+
const prev = children[i - 1];
|
|
3996
|
+
if (!prev || prev.type !== "comment" || !isJsDocComment(prev.text)) continue;
|
|
3997
|
+
styleDocs.push({
|
|
3998
|
+
name: child.prop,
|
|
3999
|
+
docs: normalizeJsDocText(prev.text),
|
|
4000
|
+
annotation: "prop",
|
|
4001
|
+
mode
|
|
4002
|
+
});
|
|
4003
|
+
}
|
|
4004
|
+
});
|
|
4005
|
+
root.walkAtRules("property", (node) => {
|
|
4006
|
+
const propName = node.params.trim();
|
|
4007
|
+
if (!propName.startsWith("--") || hasName(propName)) return;
|
|
4008
|
+
const { syntax, initialValue } = parsePropertyAtRuleDescriptors(node);
|
|
4009
|
+
const prev = node.prev();
|
|
4010
|
+
const docs = prev && prev.type === "comment" && isJsDocComment(prev.text) ? normalizeJsDocText(prev.text) : "";
|
|
4011
|
+
styleDocs.push({
|
|
4012
|
+
name: propName,
|
|
4013
|
+
docs,
|
|
4014
|
+
annotation: "prop",
|
|
4015
|
+
mode,
|
|
4016
|
+
...syntax && { syntax },
|
|
4017
|
+
...initialValue && { default: initialValue }
|
|
4018
|
+
});
|
|
4019
|
+
});
|
|
3910
4020
|
}
|
|
3911
4021
|
/**
|
|
3912
4022
|
* Parse a CSS comment string and insert it into the provided array of
|
|
@@ -3923,7 +4033,7 @@ function parseCssComment(styleDocs, comment, mode) {
|
|
|
3923
4033
|
return line;
|
|
3924
4034
|
}).join(" ").replace(/\t/g, " ").trim();
|
|
3925
4035
|
while (comment.includes(" ")) comment = comment.replace(" ", " ");
|
|
3926
|
-
comment.split(
|
|
4036
|
+
comment.split(CSS_PROP_ANNOTATION_RE).forEach((d) => {
|
|
3927
4037
|
const cssDocument = d.trim();
|
|
3928
4038
|
if (!cssDocument.startsWith(`--`)) return;
|
|
3929
4039
|
const splt = cssDocument.split(`:`);
|
|
@@ -3946,9 +4056,11 @@ const CSS_DOC_START = /\/\*(\*|!)/;
|
|
|
3946
4056
|
*/
|
|
3947
4057
|
const CSS_DOC_END = "*/";
|
|
3948
4058
|
/**
|
|
3949
|
-
* The `@prop` annotation we support within CSS docstrings
|
|
4059
|
+
* The `@prop` annotation we support within CSS docstrings. `@cssprop`/`@cssproperty` are also
|
|
4060
|
+
* recognized as synonyms (the more common names in other web-component-analyzer/docgen
|
|
4061
|
+
* ecosystems).
|
|
3950
4062
|
*/
|
|
3951
|
-
const
|
|
4063
|
+
const CSS_PROP_ANNOTATION_RE = /@(?:cssproperty|cssprop|prop)\b/;
|
|
3952
4064
|
//#endregion
|
|
3953
4065
|
//#region src/compiler/sys/browser-stubs/browserslist.ts
|
|
3954
4066
|
const browserslist = (_query) => [];
|
|
@@ -9230,9 +9342,9 @@ const serializeSymbol = (checker, symbol) => {
|
|
|
9230
9342
|
};
|
|
9231
9343
|
};
|
|
9232
9344
|
/**
|
|
9233
|
-
* Maps a TypeScript 4.3+ JSDocTagInfo to a flattened Stencil
|
|
9345
|
+
* Maps a TypeScript 4.3+ JSDocTagInfo to a flattened Stencil JsonDocsTag.
|
|
9234
9346
|
* @param tags A readonly array of JSDocTagInfo objects.
|
|
9235
|
-
* @returns An array of
|
|
9347
|
+
* @returns An array of JsonDocsTag objects.
|
|
9236
9348
|
*/
|
|
9237
9349
|
const mapJSDocTagInfo = (tags) => {
|
|
9238
9350
|
return tags.map((tag) => ({
|
|
@@ -9643,7 +9755,7 @@ const transformCssToEsmModule = (input) => {
|
|
|
9643
9755
|
defaultVarName: createCssVarName(input.file, input.mode),
|
|
9644
9756
|
styleDocs: []
|
|
9645
9757
|
};
|
|
9646
|
-
if (input.docs) parseStyleDocs(results.styleDocs, input.input, input.mode);
|
|
9758
|
+
if (input.docs) parseStyleDocs(results.styleDocs, input.input, input.mode, input.tag, input.encapsulation);
|
|
9647
9759
|
try {
|
|
9648
9760
|
const varNames = /* @__PURE__ */ new Set([results.defaultVarName]);
|
|
9649
9761
|
if (isString$1(input.tag) && input.encapsulation === "scoped") {
|
|
@@ -9740,7 +9852,7 @@ const getCssToEsmImports = (varNames, cssText, filePath, modeName) => {
|
|
|
9740
9852
|
isNodeModule: false
|
|
9741
9853
|
};
|
|
9742
9854
|
if (!isLocalCssImport(cssImportData.srcImportText)) continue;
|
|
9743
|
-
else if (cssImportData.url === "stencil-globals" || cssImportData.url === "stencil-hydrate") continue;
|
|
9855
|
+
else if (cssImportData.url === "stencil-component-globals" || cssImportData.url === "stencil-hydrate" || cssImportData.url === "stencil-css-components") continue;
|
|
9744
9856
|
else if (isCssNodeModule(cssImportData.url)) {
|
|
9745
9857
|
cssImportData.filePath = cssImportData.url.substring(1);
|
|
9746
9858
|
cssImportData.isNodeModule = true;
|
|
@@ -9955,6 +10067,7 @@ var BuildContext = class {
|
|
|
9955
10067
|
completedTasks = [];
|
|
9956
10068
|
compilerCtx;
|
|
9957
10069
|
components = [];
|
|
10070
|
+
cssOnlyComponents = [];
|
|
9958
10071
|
componentGraph = /* @__PURE__ */ new Map();
|
|
9959
10072
|
config;
|
|
9960
10073
|
data = {};
|
|
@@ -9996,6 +10109,7 @@ var BuildContext = class {
|
|
|
9996
10109
|
styleBuildCount = 0;
|
|
9997
10110
|
stylesPromise = null;
|
|
9998
10111
|
stylesUpdated = [];
|
|
10112
|
+
globalStylesUpdated = [];
|
|
9999
10113
|
timeSpan = null;
|
|
10000
10114
|
timestamp;
|
|
10001
10115
|
transpileBuildCount = 0;
|
|
@@ -10176,12 +10290,18 @@ var CompilerContext = class {
|
|
|
10176
10290
|
*/
|
|
10177
10291
|
prevStylesMap = /* @__PURE__ */ new Map();
|
|
10178
10292
|
globalStyleCache = /* @__PURE__ */ new Map();
|
|
10293
|
+
cssOnlyComponentsCache = /* @__PURE__ */ new Map();
|
|
10294
|
+
stencilCss;
|
|
10295
|
+
globalStyleVirtualImports = /* @__PURE__ */ new Map();
|
|
10179
10296
|
styleModeNames = /* @__PURE__ */ new Set();
|
|
10180
10297
|
worker = null;
|
|
10181
10298
|
reset() {
|
|
10182
10299
|
this.cache.clear();
|
|
10183
10300
|
this.cssModuleImports.clear();
|
|
10184
10301
|
this.globalStyleCache.clear();
|
|
10302
|
+
this.cssOnlyComponentsCache.clear();
|
|
10303
|
+
this.stencilCss = void 0;
|
|
10304
|
+
this.globalStyleVirtualImports.clear();
|
|
10185
10305
|
this.collections.length = 0;
|
|
10186
10306
|
this.compilerOptions = null;
|
|
10187
10307
|
this.hasSuccessfulBuild = false;
|
|
@@ -16052,6 +16172,7 @@ const transpileCss = async (transformInput, results) => {
|
|
|
16052
16172
|
results.map = cssResults.map;
|
|
16053
16173
|
results.imports = cssResults.imports.map((p) => ({ path: p.importPath }));
|
|
16054
16174
|
results.diagnostics.push(...cssResults.diagnostics);
|
|
16175
|
+
if (transformInput.docs) results.styleDocs = cssResults.styleDocs;
|
|
16055
16176
|
};
|
|
16056
16177
|
const transpileCssSync = (transformInput, results) => {
|
|
16057
16178
|
const cssResults = transformCssToEsmSync(transformInput);
|
|
@@ -16059,6 +16180,7 @@ const transpileCssSync = (transformInput, results) => {
|
|
|
16059
16180
|
results.map = cssResults.map;
|
|
16060
16181
|
results.imports = cssResults.imports.map((p) => ({ path: p.importPath }));
|
|
16061
16182
|
results.diagnostics.push(...cssResults.diagnostics);
|
|
16183
|
+
if (transformInput.docs) results.styleDocs = cssResults.styleDocs;
|
|
16062
16184
|
};
|
|
16063
16185
|
const transpileJson = (results) => {
|
|
16064
16186
|
results.code = dataToEsm(JSON.parse(results.code), {
|