@lwc/metadata 12.0.4 → 12.1.1-alpha.0
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/bundle-metadata.js +5 -2
- package/dist/bundle-metadata.js.map +1 -1
- package/dist/schema/typescript-types/style-metadata-types.d.ts +74 -1
- package/dist/schema/typescript-types/style-metadata-types.js.map +1 -1
- package/dist/shared/config.d.ts +3 -0
- package/dist/style-metadata/__tests__/class-references.spec.d.ts +1 -0
- package/dist/style-metadata/__tests__/custom-property-declarations.spec.d.ts +1 -0
- package/dist/style-metadata/__tests__/declaration.spec.d.ts +1 -0
- package/dist/style-metadata/class-references.d.ts +3 -0
- package/dist/style-metadata/class-references.js +38 -0
- package/dist/style-metadata/class-references.js.map +1 -0
- package/dist/style-metadata/component-references.d.ts +3 -3
- package/dist/style-metadata/component-references.js +2 -13
- package/dist/style-metadata/component-references.js.map +1 -1
- package/dist/style-metadata/custom-properties.d.ts +1 -1
- package/dist/style-metadata/custom-properties.js +5 -6
- package/dist/style-metadata/custom-properties.js.map +1 -1
- package/dist/style-metadata/custom-property-declarations.d.ts +3 -0
- package/dist/style-metadata/custom-property-declarations.js +33 -0
- package/dist/style-metadata/custom-property-declarations.js.map +1 -0
- package/dist/style-metadata/declarations.d.ts +3 -0
- package/dist/style-metadata/declarations.js +34 -0
- package/dist/style-metadata/declarations.js.map +1 -0
- package/dist/style-metadata/imports.d.ts +3 -3
- package/dist/style-metadata/imports.js.map +1 -1
- package/dist/style-metadata/index.d.ts +3 -0
- package/dist/style-metadata/index.js +17 -2
- package/dist/style-metadata/index.js.map +1 -1
- package/dist/style-metadata/utils.d.ts +4 -0
- package/dist/style-metadata/utils.js +27 -0
- package/dist/style-metadata/utils.js.map +1 -0
- package/package.json +2 -2
package/dist/bundle-metadata.js
CHANGED
|
@@ -75,10 +75,10 @@ function rollupDiagnostics(files) {
|
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
77
|
} */
|
|
78
|
-
const version = '12.0
|
|
78
|
+
const version = '12.1.1-alpha.0';
|
|
79
79
|
function collectBundleMetadata(config) {
|
|
80
80
|
// validateBundleConfig(config);
|
|
81
|
-
const { namespace, name, type, namespaceMapping, npmModuleMapping, files, enableKomaci, strictCSSTokenCollection, enableLuvio, experimentalComplexExpressions, apiVersion, } = config;
|
|
81
|
+
const { namespace, name, type, namespaceMapping, npmModuleMapping, files, enableKomaci, strictCSSTokenCollection, enableLuvio, experimentalComplexExpressions, apiVersion, enableClassReferences, enableCustomDeclarationProperty, enableDeclarationsCollection, } = config;
|
|
82
82
|
const filesResult = [];
|
|
83
83
|
files.forEach(({ fileName, source }) => {
|
|
84
84
|
const ext = path__namespace.extname(fileName);
|
|
@@ -108,6 +108,9 @@ function collectBundleMetadata(config) {
|
|
|
108
108
|
filesResult.push(index.collectCssMetadataFromSource(fileName, source, {
|
|
109
109
|
namespaceMapping,
|
|
110
110
|
strictCSSTokenCollection,
|
|
111
|
+
enableClassReferences,
|
|
112
|
+
enableCustomDeclarationProperty,
|
|
113
|
+
enableDeclarationsCollection,
|
|
111
114
|
}));
|
|
112
115
|
break;
|
|
113
116
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bundle-metadata.js","sources":["../src/bundle-metadata.ts"],"sourcesContent":[null],"names":["path","collectTemplateMetadataFromSource","collectScriptMetadataFromSource","collectCssMetadataFromSource"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAkBA,SAAS,gBAAgB,CACrB,UAAkB,EAClB,KAGG,EAAA;AAEH,IAAA,IAAI,aAAiC;AAErC,IAAA,KAAK,MAAM,EAAE,QAAQ,EAAE,IAAI,KAAK,EAAE;QAC9B,MAAM,UAAU,GAAGA,eAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;;;AAGvC,QAAA,IAAI,UAAU,CAAC,IAAI,KAAK,UAAU,EAAE;AAChC,YAAA,IAAI,UAAU,CAAC,GAAG,KAAK,MAAM,EAAE;;gBAE3B,aAAa,GAAG,QAAQ;;AACrB,iBAAA,IAAI,UAAU,CAAC,GAAG,KAAK,KAAK,IAAI,UAAU,CAAC,GAAG,KAAK,KAAK,EAAE;;AAE7D,gBAAA,OAAO,QAAQ;;;;AAI3B,IAAA,OAAO,aAAa;AACxB;AAEA,SAAS,iBAAiB,CAAC,KAAa,EAAA;AACpC,IAAA,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AAC1B,QAAA,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW;;;AAGpC,QAAA,IAAI,CAAC,WAAW,GAAG,EAAE;AACrB,QAAA,OAAO,WAAW;AACtB,KAAC,CAAC;AACN;AAEA;;;;;;;;;;;;;;;;;;AAkBI;AAEJ,MAAM,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"bundle-metadata.js","sources":["../src/bundle-metadata.ts"],"sourcesContent":[null],"names":["path","collectTemplateMetadataFromSource","collectScriptMetadataFromSource","collectCssMetadataFromSource"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAkBA,SAAS,gBAAgB,CACrB,UAAkB,EAClB,KAGG,EAAA;AAEH,IAAA,IAAI,aAAiC;AAErC,IAAA,KAAK,MAAM,EAAE,QAAQ,EAAE,IAAI,KAAK,EAAE;QAC9B,MAAM,UAAU,GAAGA,eAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;;;AAGvC,QAAA,IAAI,UAAU,CAAC,IAAI,KAAK,UAAU,EAAE;AAChC,YAAA,IAAI,UAAU,CAAC,GAAG,KAAK,MAAM,EAAE;;gBAE3B,aAAa,GAAG,QAAQ;;AACrB,iBAAA,IAAI,UAAU,CAAC,GAAG,KAAK,KAAK,IAAI,UAAU,CAAC,GAAG,KAAK,KAAK,EAAE;;AAE7D,gBAAA,OAAO,QAAQ;;;;AAI3B,IAAA,OAAO,aAAa;AACxB;AAEA,SAAS,iBAAiB,CAAC,KAAa,EAAA;AACpC,IAAA,O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CACZC,kCAA4B,CAAC,QAAQ,EAAE,MAAM,EAAE;oBAC3C,gBAAgB;oBAChB,wBAAwB;oBACxB,qBAAqB;oBACrB,+BAA+B;oBAC/B,4BAA4B;AAC/B,iBAAA,CAAC,CACL;gBACD;;AAKZ,KAAC,CAAC;IAEF,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC;IACnD,MAAM,WAAW,GAAyB,EAAE;IAQ5C,WAAW,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACnD,OAAO;QACH,OAAO;AACP,QAAA,eAAe,EAAE,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,IAAI,CAAE,CAAA;QACvC,IAAI;QACJ,SAAS;AACT,QAAA,KAAK,EAAE,WAAW;QAClB,aAAa;QACb,WAAW;KACd;AACL;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentReference, File, SourceLocation } from './common-metadata-types';
|
|
2
2
|
import { ModuleReference } from './script-metadata-types';
|
|
3
|
+
import type { Node } from 'postcss-value-parser';
|
|
3
4
|
/**
|
|
4
5
|
* Root metadata object for a css file.
|
|
5
6
|
*/
|
|
@@ -13,10 +14,22 @@ interface CSSFile extends File {
|
|
|
13
14
|
* The list of referenced component modules in CSS rules.
|
|
14
15
|
*/
|
|
15
16
|
componentReferences: ComponentReference[];
|
|
17
|
+
/**
|
|
18
|
+
* The list of CSS custom property declarations
|
|
19
|
+
*/
|
|
20
|
+
customPropertyDeclarations: CSSCustomPropertyDeclarations[];
|
|
16
21
|
/**
|
|
17
22
|
* The list of CSS custom properties.
|
|
18
23
|
*/
|
|
19
24
|
customProperties: CSSCustomProperty[];
|
|
25
|
+
/**
|
|
26
|
+
* The list of CSS class selectors
|
|
27
|
+
*/
|
|
28
|
+
classReferences: CSSClassReference[];
|
|
29
|
+
/**
|
|
30
|
+
* The list of CSS class declarations
|
|
31
|
+
*/
|
|
32
|
+
declarations: CSSDeclarations[];
|
|
20
33
|
}
|
|
21
34
|
declare function isCSSFile(file: File): file is CSSFile;
|
|
22
35
|
/**
|
|
@@ -32,4 +45,64 @@ interface CSSCustomProperty {
|
|
|
32
45
|
*/
|
|
33
46
|
location: SourceLocation;
|
|
34
47
|
}
|
|
35
|
-
|
|
48
|
+
/**
|
|
49
|
+
* The CSS class selector reference
|
|
50
|
+
*/
|
|
51
|
+
interface CSSClassReference {
|
|
52
|
+
/**
|
|
53
|
+
* Class name.
|
|
54
|
+
*/
|
|
55
|
+
name: string;
|
|
56
|
+
/**
|
|
57
|
+
* Class name location.
|
|
58
|
+
*/
|
|
59
|
+
locations: SourceLocation[];
|
|
60
|
+
}
|
|
61
|
+
interface CSSCustomPropertyDeclarations {
|
|
62
|
+
/**
|
|
63
|
+
* Property name
|
|
64
|
+
*/
|
|
65
|
+
name: string;
|
|
66
|
+
/**
|
|
67
|
+
* Property locations
|
|
68
|
+
*/
|
|
69
|
+
locations: SourceLocation[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The list of static class declarations
|
|
73
|
+
*/
|
|
74
|
+
interface CSSDeclarations {
|
|
75
|
+
/**
|
|
76
|
+
* Declaration property.
|
|
77
|
+
*/
|
|
78
|
+
prop: {
|
|
79
|
+
/**
|
|
80
|
+
* CSS property name
|
|
81
|
+
*/
|
|
82
|
+
name: string;
|
|
83
|
+
/**
|
|
84
|
+
* CSS property location
|
|
85
|
+
*/
|
|
86
|
+
location: SourceLocation;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Declaration value.
|
|
90
|
+
*/
|
|
91
|
+
value: {
|
|
92
|
+
/**
|
|
93
|
+
* CSS values
|
|
94
|
+
*
|
|
95
|
+
* Each node in nodes has a source index that can be used with the location to
|
|
96
|
+
* determine the node's absolution position.
|
|
97
|
+
*
|
|
98
|
+
* Note: The values are parsed and returned as defined here:
|
|
99
|
+
* https://www.npmjs.com/package/postcss-value-parser#nodes
|
|
100
|
+
*/
|
|
101
|
+
nodes: Node[];
|
|
102
|
+
/**
|
|
103
|
+
* CSS value location
|
|
104
|
+
*/
|
|
105
|
+
location: SourceLocation;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export { CSSFile, CSSCustomProperty, CSSCustomPropertyDeclarations, CSSClassReference, CSSDeclarations, isCSSFile, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-metadata-types.js","sources":["../../../src/schema/typescript-types/style-metadata-types.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"style-metadata-types.js","sources":["../../../src/schema/typescript-types/style-metadata-types.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;AACA;AA4CA,SAAS,SAAS,CAAC,IAAU,EAAA;AACzB,IAAA,OAAO,IAAI,CAAC,QAAQ,KAAK,KAAK;AAClC;;;;"}
|
package/dist/shared/config.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var postcssSelector = require('postcss-selector-parser');
|
|
4
|
+
var utils = require('../shared/utils.js');
|
|
5
|
+
var utils$1 = require('./utils.js');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var postcssSelector__default = /*#__PURE__*/_interopDefaultCompat(postcssSelector);
|
|
10
|
+
|
|
11
|
+
// Copyright (c) 2025, Salesforce, Inc.,
|
|
12
|
+
// All rights reserved.
|
|
13
|
+
// For full license text, see the LICENSE.txt file
|
|
14
|
+
const createClassReference = (className) => ({
|
|
15
|
+
name: className,
|
|
16
|
+
locations: [],
|
|
17
|
+
});
|
|
18
|
+
function collectClassReferences(result, root) {
|
|
19
|
+
const classMap = new Map();
|
|
20
|
+
root.walkRules((rule) => {
|
|
21
|
+
const { selector, source } = rule;
|
|
22
|
+
const processor = postcssSelector__default.default();
|
|
23
|
+
const parsedSelector = processor.astSync(selector, { lossless: true });
|
|
24
|
+
parsedSelector.walkClasses((node) => {
|
|
25
|
+
const { value: className, sourceIndex } = node;
|
|
26
|
+
let classReference = classMap.get(className);
|
|
27
|
+
if (utils.isUndefined(classReference)) {
|
|
28
|
+
classReference = createClassReference(className);
|
|
29
|
+
classMap.set(className, classReference);
|
|
30
|
+
}
|
|
31
|
+
classReference.locations.push(utils$1.getReferenceLocation(source, source.start.offset + sourceIndex, className.length));
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
result.classReferences.push(...classMap.values());
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
exports.collectClassReferences = collectClassReferences;
|
|
38
|
+
//# sourceMappingURL=class-references.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-references.js","sources":["../../src/style-metadata/class-references.ts"],"sourcesContent":[null],"names":["postcssSelector","isUndefined","getReferenceLocation"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;AAUA,MAAM,oBAAoB,GAAG,CAAC,SAAiB,MAAyB;AACpE,IAAA,IAAI,EAAE,SAAS;AACf,IAAA,SAAS,EAAE,EAAE;AAChB,CAAA,CAAC;AAEc,SAAA,sBAAsB,CAAC,MAAe,EAAE,IAAU,EAAA;AAC9D,IAAA,MAAM,QAAQ,GAAmC,IAAI,GAAG,EAAE;AAE1D,IAAA,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,KAAI;AACpB,QAAA,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI;AAEjC,QAAA,MAAM,SAAS,GAAGA,gCAAe,EAAE;AACnC,QAAA,MAAM,cAAc,GAAG,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAEtE,QAAA,cAAc,CAAC,WAAW,CAAC,CAAC,IAAI,KAAI;YAChC,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,IAAI;YAE9C,IAAI,cAAc,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC;AAC5C,YAAA,IAAIC,iBAAW,CAAC,cAAc,CAAC,EAAE;AAC7B,gBAAA,cAAc,GAAG,oBAAoB,CAAC,SAAS,CAAC;AAChD,gBAAA,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,cAAc,CAAC;;YAG3C,cAAc,CAAC,SAAS,CAAC,IAAI,CACzBC,4BAAoB,CAChB,MAAO,EACP,MAAO,CAAC,KAAM,CAAC,MAAM,GAAG,WAAW,EACnC,SAAS,CAAC,MAAM,CACnB,CACJ;AACL,SAAC,CAAC;AACN,KAAC,CAAC;IAEF,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;AACrD;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Root } from 'postcss';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { Root } from 'postcss';
|
|
2
|
+
import type { NamespaceMapping } from '../shared/config';
|
|
3
|
+
import type { CSSFile } from '../schema/typescript-types/style-metadata-types';
|
|
4
4
|
export declare function collectComponentReferences(result: CSSFile, root: Root, namespaceMapping: NamespaceMapping): void;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var sfdcCompilerUtils = require('@lwc/sfdc-compiler-utils');
|
|
4
4
|
var postcssSelector = require('postcss-selector-parser');
|
|
5
5
|
var utils = require('../shared/utils.js');
|
|
6
|
+
var utils$1 = require('./utils.js');
|
|
6
7
|
|
|
7
8
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
9
|
|
|
@@ -14,18 +15,6 @@ var postcssSelector__default = /*#__PURE__*/_interopDefaultCompat(postcssSelecto
|
|
|
14
15
|
function isCustomElementSelector(tag) {
|
|
15
16
|
return tag.includes('-');
|
|
16
17
|
}
|
|
17
|
-
function getReferenceLocation({ input }, start, length) {
|
|
18
|
-
const startLoc = input.fromOffset(start);
|
|
19
|
-
const endLoc = input.fromOffset(start + length);
|
|
20
|
-
return {
|
|
21
|
-
start,
|
|
22
|
-
end: start + length,
|
|
23
|
-
startLine: startLoc.line,
|
|
24
|
-
startColumn: startLoc.col,
|
|
25
|
-
endLine: endLoc.line,
|
|
26
|
-
endColumn: endLoc.col,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
18
|
function getSelectorReferences({ selector, source }, offset, namespaceMapping) {
|
|
30
19
|
const references = [];
|
|
31
20
|
const processor = postcssSelector__default.default();
|
|
@@ -51,7 +40,7 @@ function getSelectorReferences({ selector, source }, offset, namespaceMapping) {
|
|
|
51
40
|
name: utils.tagNameToComponentName(tagName),
|
|
52
41
|
tagName,
|
|
53
42
|
type: 'external',
|
|
54
|
-
locations: [getReferenceLocation(source, offset + node.sourceIndex, tagName.length)],
|
|
43
|
+
locations: [utils$1.getReferenceLocation(source, offset + node.sourceIndex, tagName.length)],
|
|
55
44
|
};
|
|
56
45
|
const namespacedName = sfdcCompilerUtils.getNamespacedIdForResource(moduleName, namespaceMapping);
|
|
57
46
|
if (!utils.isUndefined(namespacedName)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-references.js","sources":["../../src/style-metadata/component-references.ts"],"sourcesContent":[null],"names":["postcssSelector","tagNameToComponentName","getNamespacedIdForResource","isUndefined"],"mappings":"
|
|
1
|
+
{"version":3,"file":"component-references.js","sources":["../../src/style-metadata/component-references.ts"],"sourcesContent":[null],"names":["postcssSelector","tagNameToComponentName","getReferenceLocation","getNamespacedIdForResource","isUndefined"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AAaA,SAAS,uBAAuB,CAAC,GAAW,EAAA;AACxC,IAAA,OAAO,GAAG,CAAC,QAAQ,CAAC,GAAG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C,iBAAW,CAAC,cAAc,CAAC,EAAE;AAC9B,YAAA,GAAG,CAAC,cAAc,GAAG,cAAc;;AAGvC,QAAA,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC;AACxB,KAAC,CAAC;AAEF,IAAA,OAAO,UAAU;AACrB;SAEgB,0BAA0B,CACtC,MAAe,EACf,IAAU,EACV,gBAAkC,EAAA;AAElC,IAAA,MAAM,UAAU,GAAG,IAAI,GAAG,EAA8B;AAExD,IAAA,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,KAAI;QACpB,MAAM,cAAc,GAAG,IAAI,CAAC,MAAO,CAAC,KAAM,CAAC,MAAM;QACjD,MAAM,cAAc,GAAG,qBAAqB,CAAC,IAAI,EAAE,cAAc,EAAE,gBAAgB,CAAC;AAEpF,QAAA,KAAK,MAAM,eAAe,IAAI,cAAc,EAAE;AAC1C,YAAA,MAAM,EAAE,OAAO,EAAE,GAAG,eAAe;YACnC,IAAI,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC;AAEvC,YAAA,IAAIA,iBAAW,CAAC,SAAS,CAAC,EAAE;gBACxB,SAAS,GAAG,eAAe;AAE3B,gBAAA,UAAU,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC;;iBAC/B;gBACH,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,SAAS,CAAC;;;AAGlE,KAAC,CAAC;IAEF,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC;AAC3D;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Root } from 'postcss';
|
|
2
|
-
import { CSSFile } from '../schema/typescript-types/style-metadata-types';
|
|
2
|
+
import type { CSSFile } from '../schema/typescript-types/style-metadata-types';
|
|
3
3
|
export declare function collectCustomProperties(result: CSSFile, root: Root, strict?: boolean): void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var postcssValueParser = require('postcss-value-parser');
|
|
4
|
-
var utils = require('../shared/utils.js');
|
|
4
|
+
var utils$1 = require('../shared/utils.js');
|
|
5
|
+
var utils = require('./utils.js');
|
|
5
6
|
|
|
6
7
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
7
8
|
|
|
@@ -17,10 +18,8 @@ function collectCustomProperties(result, root, strict) {
|
|
|
17
18
|
if (!decl.value.includes('var(')) {
|
|
18
19
|
return;
|
|
19
20
|
}
|
|
20
|
-
// The value offset from the start of the declaration node
|
|
21
|
-
|
|
22
|
-
// - the space between the declaration and the value (raws.between includes the `:`)
|
|
23
|
-
const valueOffset = decl.prop.length + (decl.raws.between?.length ?? 1);
|
|
21
|
+
// The value offset from the start of the declaration node
|
|
22
|
+
const valueOffset = utils.getCssValueOffset(decl);
|
|
24
23
|
let parsedValue;
|
|
25
24
|
try {
|
|
26
25
|
parsedValue = postcssValueParser__default.default(decl.value);
|
|
@@ -50,7 +49,7 @@ function collectCustomProperties(result, root, strict) {
|
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
52
51
|
const params = node.nodes;
|
|
53
|
-
if (utils.isUndefined(params[0]) || params[0].type !== 'word') {
|
|
52
|
+
if (utils$1.isUndefined(params[0]) || params[0].type !== 'word') {
|
|
54
53
|
return;
|
|
55
54
|
}
|
|
56
55
|
const name = params[0].value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-properties.js","sources":["../../src/style-metadata/custom-properties.ts"],"sourcesContent":[null],"names":["postcssValueParser","isUndefined"],"mappings":"
|
|
1
|
+
{"version":3,"file":"custom-properties.js","sources":["../../src/style-metadata/custom-properties.ts"],"sourcesContent":[null],"names":["getCssValueOffset","postcssValueParser","isUndefined"],"mappings":";;;;;;;;;;AAAA;AACA;AACA;SAWgB,uBAAuB,CAAC,MAAe,EAAE,IAAU,EAAE,MAAgB,EAAA;AACjF,IAAA,IAAI,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,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC;AACjD,YAAA,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC;YAC7D,MAAM,WAAW,GAAG,IAAI,CAAC,MAAO,CAAC,KAAM,CAAC,MAAM,GAAG,cAAc;;AAE/D,YAAA,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC;gBACzB,IAAI;AACJ,gBAAA,QAAQ,EAAE;oBACN,SAAS,EAAE,KAAK,CAAC,IAAI;oBACrB,WAAW,EAAE,KAAK,CAAC,MAAM;oBACzB,OAAO,EAAE,GAAG,CAAC,IAAI;oBACjB,SAAS,EAAE,GAAG,CAAC,MAAM;AACrB,oBAAA,KAAK,EAAE,WAAW;AAClB,oBAAA,GAAG,EAAE,WAAW,GAAG,IAAI,CAAC,MAAM;AACjC,iBAAA;AACJ,aAAA,CAAC;AACN,SAAC,CAAC;AACN,KAAC,CAAC;AACN;;;;"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('../shared/utils.js');
|
|
4
|
+
var utils$1 = require('./utils.js');
|
|
5
|
+
|
|
6
|
+
// Copyright (c) 2025, Salesforce, Inc.,
|
|
7
|
+
// All rights reserved.
|
|
8
|
+
// For full license text, see the LICENSE.txt file
|
|
9
|
+
const createCustomProperty = (prop) => ({
|
|
10
|
+
name: prop,
|
|
11
|
+
locations: [],
|
|
12
|
+
});
|
|
13
|
+
function collectCustomPropertyDeclarations(result, root) {
|
|
14
|
+
const customPropertyMap = new Map();
|
|
15
|
+
root.walkDecls((decl) => {
|
|
16
|
+
// Early exit if the declaration property doesn't start with '--'.
|
|
17
|
+
// This avoid parsing the selector when not needed.
|
|
18
|
+
if (!decl.prop.startsWith('--')) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const { source, prop } = decl;
|
|
22
|
+
let customProperty = customPropertyMap.get(prop);
|
|
23
|
+
if (utils.isUndefined(customProperty)) {
|
|
24
|
+
customProperty = createCustomProperty(prop);
|
|
25
|
+
customPropertyMap.set(prop, customProperty);
|
|
26
|
+
}
|
|
27
|
+
customProperty.locations.push(utils$1.getReferenceLocation(source, source.start.offset, prop.length));
|
|
28
|
+
});
|
|
29
|
+
result.customPropertyDeclarations.push(...customPropertyMap.values());
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.collectCustomPropertyDeclarations = collectCustomPropertyDeclarations;
|
|
33
|
+
//# sourceMappingURL=custom-property-declarations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-property-declarations.js","sources":["../../src/style-metadata/custom-property-declarations.ts"],"sourcesContent":[null],"names":["isUndefined","getReferenceLocation"],"mappings":";;;;;AAAA;AACA;AACA;AAWA,MAAM,oBAAoB,GAAG,CAAC,IAAY,MAAqC;AAC3E,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,SAAS,EAAE,EAAE;AAChB,CAAA,CAAC;AAEc,SAAA,iCAAiC,CAAC,MAAe,EAAE,IAAU,EAAA;AACzE,IAAA,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAyC;AAE1E,IAAA,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,KAAI;;;QAGpB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;YAC7B;;AAEJ,QAAA,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI;QAE7B,IAAI,cAAc,GAAG,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC;AAChD,QAAA,IAAIA,iBAAW,CAAC,cAAc,CAAC,EAAE;AAC7B,YAAA,cAAc,GAAG,oBAAoB,CAAC,IAAI,CAAC;AAC3C,YAAA,iBAAiB,CAAC,GAAG,CAAC,IAAI,EAAE,cAAc,CAAC;;QAG/C,cAAc,CAAC,SAAS,CAAC,IAAI,CACzBC,4BAAoB,CAAC,MAAO,EAAE,MAAO,CAAC,KAAM,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CACpE;AACL,KAAC,CAAC;IAEF,MAAM,CAAC,0BAA0B,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAC;AACzE;;;;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var postcssValueParser = require('postcss-value-parser');
|
|
4
|
+
var utils = require('./utils.js');
|
|
5
|
+
|
|
6
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
7
|
+
|
|
8
|
+
var postcssValueParser__default = /*#__PURE__*/_interopDefaultCompat(postcssValueParser);
|
|
9
|
+
|
|
10
|
+
// Copyright (c) 2022, Salesforce, Inc.,
|
|
11
|
+
// All rights reserved.
|
|
12
|
+
// For full license text, see the LICENSE.txt file
|
|
13
|
+
function collectDeclarations(result, root) {
|
|
14
|
+
root.walkDecls((decl) => {
|
|
15
|
+
const { prop, value, source } = decl;
|
|
16
|
+
const parsedValue = postcssValueParser__default.default(value);
|
|
17
|
+
const startOffset = source.start.offset;
|
|
18
|
+
// The value offset from the start of the declaration node
|
|
19
|
+
const valueOffset = utils.getCssValueOffset(decl);
|
|
20
|
+
result.declarations.push({
|
|
21
|
+
prop: {
|
|
22
|
+
name: prop,
|
|
23
|
+
location: utils.getReferenceLocation(source, startOffset, prop.length),
|
|
24
|
+
},
|
|
25
|
+
value: {
|
|
26
|
+
nodes: parsedValue.nodes,
|
|
27
|
+
location: utils.getReferenceLocation(source, startOffset + valueOffset, value.length),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exports.collectDeclarations = collectDeclarations;
|
|
34
|
+
//# sourceMappingURL=declarations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"declarations.js","sources":["../../src/style-metadata/declarations.ts"],"sourcesContent":[null],"names":["postcssValueParser","getCssValueOffset","getReferenceLocation"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AASgB,SAAA,mBAAmB,CAAC,MAAe,EAAE,IAAU,EAAA;AAC3D,IAAA,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,KAAI;QACpB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;AACpC,QAAA,MAAM,WAAW,GAAGA,mCAAkB,CAAC,KAAK,CAAC;AAE7C,QAAA,MAAM,WAAW,GAAG,MAAO,CAAC,KAAM,CAAC,MAAM;;AAEzC,QAAA,MAAM,WAAW,GAAGC,uBAAiB,CAAC,IAAI,CAAC;AAE3C,QAAA,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC;AACrB,YAAA,IAAI,EAAE;AACF,gBAAA,IAAI,EAAE,IAAI;gBACV,QAAQ,EAAEC,0BAAoB,CAAC,MAAO,EAAE,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC;AACpE,aAAA;AACD,YAAA,KAAK,EAAE;gBACH,KAAK,EAAE,WAAW,CAAC,KAAK;AACxB,gBAAA,QAAQ,EAAEA,0BAAoB,CAAC,MAAO,EAAE,WAAW,GAAG,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC;AACnF,aAAA;AACJ,SAAA,CAAC;AACN,KAAC,CAAC;AACN;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Root } from 'postcss';
|
|
2
|
-
import { NamespaceMapping } from '../shared/config';
|
|
3
|
-
import { CSSFile } from '../schema/typescript-types/style-metadata-types';
|
|
1
|
+
import type { Root } from 'postcss';
|
|
2
|
+
import type { NamespaceMapping } from '../shared/config';
|
|
3
|
+
import type { CSSFile } from '../schema/typescript-types/style-metadata-types';
|
|
4
4
|
export declare function collectImports(result: CSSFile, root: Root, namespaceMapping: NamespaceMapping): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imports.js","sources":["../../src/style-metadata/imports.ts"],"sourcesContent":[null],"names":["postcssValueParser","isUndefined","QUOTE_LENGTH","generateReferenceId","getNamespacedIdForResource"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"imports.js","sources":["../../src/style-metadata/imports.ts"],"sourcesContent":[null],"names":["postcssValueParser","isUndefined","QUOTE_LENGTH","generateReferenceId","getNamespacedIdForResource"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AAoBA,SAAS,aAAa,CAAC,KAAa,EAAA;AAChC,IAAA,IAAI,IAAiB;AACrB,IAAA,IAAI;AACA,QAAA,IAAI,GAAGA,mCAAkB,CAAC,KAAK,CAAC;;AAClC,IAAA,MAAM;;QAEJ;;IAGJ,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAE1B,IAAA,IAAIC,iBAAW,CAAC,IAAI,CAAC,EAAE;QACnB;;;AAIJ,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;QACxB,OAAO;YACH,IAAI,EAAE,IAAI,CAAC,KAAK;YAChB,MAAM,EAAE,IAAI,CAAC,WAAW;SAC3B;;;;AAKL,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK,EAAE;AAClD,QAAA,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK;QAEzB,IAAIA,iBAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;YACxB;;QAGJ,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;YAC7B,OAAO;AACH,gBAAA,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK;gBACrB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC;aACpC;;QAGL,IAAI,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,EAAE;YAC3B,OAAO;AACH,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Name: string, source: string, config: {
|
|
4
4
|
namespaceMapping: NamespaceMapping;
|
|
5
5
|
strictCSSTokenCollection?: boolean;
|
|
6
|
+
enableClassReferences?: boolean;
|
|
7
|
+
enableCustomDeclarationProperty?: boolean;
|
|
8
|
+
enableDeclarationsCollection?: boolean;
|
|
6
9
|
}): CSSFile;
|
|
7
10
|
/** End internal API **/
|
|
@@ -7,6 +7,9 @@ var utils = require('../shared/utils.js');
|
|
|
7
7
|
var imports = require('./imports.js');
|
|
8
8
|
var customProperties = require('./custom-properties.js');
|
|
9
9
|
var componentReferences = require('./component-references.js');
|
|
10
|
+
var classReferences = require('./class-references.js');
|
|
11
|
+
var declarations = require('./declarations.js');
|
|
12
|
+
var customPropertyDeclarations = require('./custom-property-declarations.js');
|
|
10
13
|
|
|
11
14
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
12
15
|
|
|
@@ -21,8 +24,11 @@ function generateEmptyResult(fileName) {
|
|
|
21
24
|
fileName,
|
|
22
25
|
imports: [],
|
|
23
26
|
componentReferences: [],
|
|
27
|
+
customPropertyDeclarations: [],
|
|
24
28
|
customProperties: [],
|
|
25
29
|
diagnostics: [],
|
|
30
|
+
classReferences: [],
|
|
31
|
+
declarations: [],
|
|
26
32
|
};
|
|
27
33
|
}
|
|
28
34
|
function collectCssMetadataFromSource(fileName, source, config) {
|
|
@@ -54,14 +60,23 @@ function collectCssMetadataFromSource(fileName, source, config) {
|
|
|
54
60
|
],
|
|
55
61
|
};
|
|
56
62
|
}
|
|
57
|
-
return collectCssMetadata(fileName, root, config.namespaceMapping, config.strictCSSTokenCollection);
|
|
63
|
+
return collectCssMetadata(fileName, root, config.namespaceMapping, config.strictCSSTokenCollection, config.enableClassReferences, config.enableCustomDeclarationProperty, config.enableDeclarationsCollection);
|
|
58
64
|
}
|
|
59
65
|
/** Internal API, optimization to reuse existing ast from compilation process **/
|
|
60
|
-
function collectCssMetadata(fileName, root, namespaceMapping, strictCSSTokenCollection) {
|
|
66
|
+
function collectCssMetadata(fileName, root, namespaceMapping, strictCSSTokenCollection, enableClassReferences, enableCustomDeclarationProperty, enableDeclarationsCollection) {
|
|
61
67
|
const result = generateEmptyResult(fileName);
|
|
62
68
|
imports.collectImports(result, root, namespaceMapping);
|
|
63
69
|
customProperties.collectCustomProperties(result, root, strictCSSTokenCollection);
|
|
64
70
|
componentReferences.collectComponentReferences(result, root, namespaceMapping);
|
|
71
|
+
if (enableCustomDeclarationProperty) {
|
|
72
|
+
customPropertyDeclarations.collectCustomPropertyDeclarations(result, root);
|
|
73
|
+
}
|
|
74
|
+
if (enableClassReferences) {
|
|
75
|
+
classReferences.collectClassReferences(result, root);
|
|
76
|
+
}
|
|
77
|
+
if (enableDeclarationsCollection) {
|
|
78
|
+
declarations.collectDeclarations(result, root);
|
|
79
|
+
}
|
|
65
80
|
return result;
|
|
66
81
|
}
|
|
67
82
|
/** End internal API **/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/style-metadata/index.ts"],"sourcesContent":[null],"names":["postcss","isUndefined","generateCompilerDiagnostic","Errors","collectImports","collectCustomProperties","collectComponentReferences"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/style-metadata/index.ts"],"sourcesContent":[null],"names":["postcss","isUndefined","generateCompilerDiagnostic","Errors","collectImports","collectCustomProperties","collectComponentReferences","collectCustomPropertyDeclarations","collectClassReferences","collectDeclarations"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AAmBA,SAAS,mBAAmB,CAAC,QAAgB,EAAA;IACzC,OAAO;AACH,QAAA,QAAQ,EAAE,KAAK;QACf,QAAQ;AACR,QAAA,OAAO,EAAE,EAAE;AACX,QAAA,mBAAmB,EAAE,EAAE;AACvB,QAAA,0BAA0B,EAAE,EAAE;AAC9B,QAAA,gBAAgB,EAAE,EAAE;AACpB,QAAA,WAAW,EAAE,EAAE;AACf,QAAA,eAAe,EAAE,EAAE;AAC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B,CAAC,QAAQ,CAAC;AAE5C,IAAAC,sBAAc,CAAC,MAAM,EAAE,IAAI,EAAE,gBAAgB,CAAC;AAC9C,IAAAC,wCAAuB,CAAC,MAAM,EAAE,IAAI,EAAE,wBAAwB,CAAC;AAC/D,IAAAC,8CAA0B,CAAC,MAAM,EAAE,IAAI,EAAE,gBAAgB,CAAC;IAC1D,IAAI,+BAA+B,EAAE;AACjC,QAAAC,4DAAiC,CAAC,MAAM,EAAE,IAAI,CAAC;;IAEnD,IAAI,qBAAqB,EAAE;AACvB,QAAAC,sCAAsB,CAAC,MAAM,EAAE,IAAI,CAAC;;IAExC,IAAI,4BAA4B,EAAE;AAC9B,QAAAC,gCAAmB,CAAC,MAAM,EAAE,IAAI,CAAC;;AAErC,IAAA,OAAO,MAAM;AACjB;AACA;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Declaration, Source } from 'postcss';
|
|
2
|
+
import type { SourceLocation } from '../schema/typescript-types/common-metadata-types';
|
|
3
|
+
export declare function getReferenceLocation({ input }: Source, start: number, length: number): SourceLocation;
|
|
4
|
+
export declare function getCssValueOffset(decl: Declaration): number;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) 2025, Salesforce, Inc.,
|
|
4
|
+
// All rights reserved.
|
|
5
|
+
// For full license text, see the LICENSE.txt file
|
|
6
|
+
function getReferenceLocation({ input }, start, length) {
|
|
7
|
+
const startLoc = input.fromOffset(start);
|
|
8
|
+
const endLoc = input.fromOffset(start + length);
|
|
9
|
+
return {
|
|
10
|
+
start,
|
|
11
|
+
end: start + length,
|
|
12
|
+
startLine: startLoc.line,
|
|
13
|
+
startColumn: startLoc.col,
|
|
14
|
+
endLine: endLoc.line,
|
|
15
|
+
endColumn: endLoc.col,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function getCssValueOffset(decl) {
|
|
19
|
+
// The value offset from the start of the declaration node is:
|
|
20
|
+
// - the declaration property name length
|
|
21
|
+
// - the space between the declaration and the value (raws.between includes the `:`)
|
|
22
|
+
return decl.prop.length + (decl.raws.between?.length ?? 1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.getCssValueOffset = getCssValueOffset;
|
|
26
|
+
exports.getReferenceLocation = getReferenceLocation;
|
|
27
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../src/style-metadata/utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAA;AACA;AACA;AAKM,SAAU,oBAAoB,CAChC,EAAE,KAAK,EAAU,EACjB,KAAa,EACb,MAAc,EAAA;IAEd,MAAM,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAE;IACzC,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,GAAG,MAAM,CAAE;IAEhD,OAAO;QACH,KAAK;QACL,GAAG,EAAE,KAAK,GAAG,MAAM;QACnB,SAAS,EAAE,QAAQ,CAAC,IAAI;QACxB,WAAW,EAAE,QAAQ,CAAC,GAAG;QACzB,OAAO,EAAE,MAAM,CAAC,IAAI;QACpB,SAAS,EAAE,MAAM,CAAC,GAAG;KACxB;AACL;AAEM,SAAU,iBAAiB,CAAC,IAAiB,EAAA;;;;AAI/C,IAAA,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC,CAAC;AAC9D;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lwc/metadata",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.1-alpha.0",
|
|
4
4
|
"description": "Extract metadata about Lightning Web Components modules. This software is provided as-is with no support provided.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@babel/parser": "~7.26.2",
|
|
18
18
|
"@babel/traverse": "~7.25.9",
|
|
19
19
|
"@babel/types": "~7.26.0",
|
|
20
|
-
"@lwc/sfdc-compiler-utils": "12.0
|
|
20
|
+
"@lwc/sfdc-compiler-utils": "12.1.1-alpha.0",
|
|
21
21
|
"postcss": "~8.4.49",
|
|
22
22
|
"postcss-selector-parser": "~6.1.2",
|
|
23
23
|
"postcss-value-parser": "~4.2.0"
|