@master/css-compiler 2.0.0-rc.73 → 2.0.0-rc.75
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/LICENSE +21 -0
- package/dist/browser.d.ts +23 -19
- package/dist/browser.js +42 -0
- package/dist/core.d.ts +43 -41
- package/dist/core.js +1639 -0
- package/dist/css-transform.d.ts +10 -6
- package/dist/css-transform.js +17 -0
- package/dist/diagnostics.d.ts +11 -0
- package/dist/diagnostics.js +12 -0
- package/dist/index.d.ts +41 -38
- package/dist/index.js +330 -0
- package/dist/lexer/imports.d.ts +16 -12
- package/dist/lexer/imports.js +38 -0
- package/dist/lexer/source.d.ts +6 -3
- package/dist/lexer/source.js +8 -0
- package/dist/lexer/standalone-master.d.ts +23 -19
- package/dist/lexer/standalone-master.js +219 -0
- package/dist/lower-css-directives.d.ts +18 -13
- package/dist/lower-css-directives.js +753 -0
- package/dist/master-css-manifest.d.ts +18 -12
- package/dist/master-css-manifest.js +546 -0
- package/dist/native-declaration.d.ts +6 -2
- package/dist/native-declaration.js +23 -0
- package/dist/utils/selectors.d.ts +6 -3
- package/dist/utils/selectors.js +49 -0
- package/dist/utils/unquote.d.ts +4 -1
- package/dist/utils/unquote.js +9 -0
- package/dist/utils/wrap-at-rules.d.ts +4 -1
- package/dist/utils/wrap-at-rules.js +11 -0
- package/package.json +69 -1
- package/dist/browser.mjs +0 -47
- package/dist/core.mjs +0 -2146
- package/dist/css-transform.mjs +0 -18
- package/dist/index.mjs +0 -395
- package/dist/lexer/imports.mjs +0 -44
- package/dist/lexer/source.mjs +0 -9
- package/dist/lexer/standalone-master.mjs +0 -233
- package/dist/lower-css-directives.mjs +0 -969
- package/dist/master-css-manifest.mjs +0 -760
- package/dist/native-declaration.mjs +0 -25
- package/dist/utils/selectors.mjs +0 -55
- package/dist/utils/unquote.mjs +0 -10
- package/dist/utils/wrap-at-rules.mjs +0 -10
package/dist/css-transform.mjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
let transform;
|
|
2
|
-
function setCSSTransform(transformer) {
|
|
3
|
-
transform = transformer;
|
|
4
|
-
}
|
|
5
|
-
function getCSSTransform() {
|
|
6
|
-
if (!transform) {
|
|
7
|
-
throw new Error('@master/css-compiler requires a CSS transform implementation. Use the default Node entry or initialize the browser entry.');
|
|
8
|
-
}
|
|
9
|
-
return transform;
|
|
10
|
-
}
|
|
11
|
-
function encodeCSS(source) {
|
|
12
|
-
return new TextEncoder().encode(source);
|
|
13
|
-
}
|
|
14
|
-
function decodeCSS(code) {
|
|
15
|
-
return new TextDecoder().decode(code);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { decodeCSS, encodeCSS, getCSSTransform, setCSSTransform };
|
package/dist/index.mjs
DELETED
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
import { existsSync, realpathSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { createRequire } from 'node:module';
|
|
3
|
-
import { isAbsolute, resolve, extname, dirname } from 'node:path';
|
|
4
|
-
import { transform } from 'lightningcss';
|
|
5
|
-
import { stringifyMasterCSSManifestJSON } from '@master/css-schema/manifest-json';
|
|
6
|
-
import { MASTER_CSS_ENTRY_DIRECTIVE_NAME } from '@master/css-lexer';
|
|
7
|
-
import { createMasterCSSManifest } from './master-css-manifest.mjs';
|
|
8
|
-
import lowerCSSDirectives from './lower-css-directives.mjs';
|
|
9
|
-
import { compileCSS, findCSSReferenceStatements, removeCSSReferenceStatements } from './core.mjs';
|
|
10
|
-
export { maskManagedPatternEntryNames, parseDirectives } from './core.mjs';
|
|
11
|
-
import { removeCSSImportStatements, findCSSImportStatements, replaceCSSImportStatements } from './lexer/imports.mjs';
|
|
12
|
-
import { mergeCSSDirectiveExtractionPolicy, findStandaloneMasterDirectiveStatements, createCSSDirectiveExtractionPolicy } from './lexer/standalone-master.mjs';
|
|
13
|
-
export { collectStandaloneCSSDirectiveExtractionPolicy, findStandaloneCSSDirectiveStatements, removeStandaloneCSSDirectives, removeStandaloneMasterDirectives } from './lexer/standalone-master.mjs';
|
|
14
|
-
import { setCSSTransform } from './css-transform.mjs';
|
|
15
|
-
|
|
16
|
-
setCSSTransform(transform);
|
|
17
|
-
const require$1 = createRequire(import.meta.url);
|
|
18
|
-
const MASTER_CSS_PACKAGE_ID = '@master/css';
|
|
19
|
-
const MASTER_CSS_PACKAGE_IDS = new Set([
|
|
20
|
-
MASTER_CSS_PACKAGE_ID,
|
|
21
|
-
'@master/css-preset'
|
|
22
|
-
]);
|
|
23
|
-
function isExpandableImportSource(source) {
|
|
24
|
-
return (source.startsWith('./') || source.startsWith('../')) && extname(source) === '.css';
|
|
25
|
-
}
|
|
26
|
-
function readJSONFile(file) {
|
|
27
|
-
return JSON.parse(readFileSync(file, 'utf-8'));
|
|
28
|
-
}
|
|
29
|
-
function findPackageRoot(entryFile, packageName) {
|
|
30
|
-
let directory = dirname(entryFile);
|
|
31
|
-
while(true){
|
|
32
|
-
const packageJSONFile = resolve(directory, 'package.json');
|
|
33
|
-
if (existsSync(packageJSONFile)) {
|
|
34
|
-
try {
|
|
35
|
-
const packageJSON = readJSONFile(packageJSONFile);
|
|
36
|
-
if (packageJSON.name === packageName) {
|
|
37
|
-
return {
|
|
38
|
-
directory,
|
|
39
|
-
packageJSON
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
} catch {
|
|
43
|
-
// Keep walking up in case this is not the package root.
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
const parentDirectory = dirname(directory);
|
|
47
|
-
if (parentDirectory === directory) return;
|
|
48
|
-
directory = parentDirectory;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
function getPackageStyleEntry(packageJSON) {
|
|
52
|
-
if (typeof packageJSON.style === 'string') return packageJSON.style;
|
|
53
|
-
if (!packageJSON.exports || typeof packageJSON.exports !== 'object') return;
|
|
54
|
-
const rootExport = packageJSON.exports['.'];
|
|
55
|
-
if (!rootExport || typeof rootExport !== 'object') return;
|
|
56
|
-
const styleExport = rootExport.style;
|
|
57
|
-
return typeof styleExport === 'string' ? styleExport : undefined;
|
|
58
|
-
}
|
|
59
|
-
function createProjectRequire(fromFile, projectDir) {
|
|
60
|
-
return createRequire(resolve(projectDir || dirname(fromFile), 'package.json'));
|
|
61
|
-
}
|
|
62
|
-
function resolveMasterCSSPackageEntryFile(importSource, fromFile = process.cwd(), projectDir) {
|
|
63
|
-
if (!MASTER_CSS_PACKAGE_IDS.has(importSource)) return;
|
|
64
|
-
const resolver = createProjectRequire(fromFile, projectDir);
|
|
65
|
-
let packageEntryFile;
|
|
66
|
-
try {
|
|
67
|
-
packageEntryFile = resolver.resolve(importSource);
|
|
68
|
-
} catch {
|
|
69
|
-
packageEntryFile = require$1.resolve(importSource);
|
|
70
|
-
}
|
|
71
|
-
const packageRoot = findPackageRoot(packageEntryFile, importSource);
|
|
72
|
-
if (!packageRoot) return;
|
|
73
|
-
const styleEntry = getPackageStyleEntry(packageRoot.packageJSON);
|
|
74
|
-
if (!styleEntry) return;
|
|
75
|
-
const styleFile = resolve(packageRoot.directory, styleEntry);
|
|
76
|
-
if (!existsSync(styleFile)) {
|
|
77
|
-
throw new Error(`${importSource} CSS style entry was not found: ${styleFile}`);
|
|
78
|
-
}
|
|
79
|
-
return styleFile;
|
|
80
|
-
}
|
|
81
|
-
function inspectCSS(source) {
|
|
82
|
-
const hasMasterEntryDirective = findStandaloneMasterDirectiveStatements(source).some((statement)=>statement.name === MASTER_CSS_ENTRY_DIRECTIVE_NAME);
|
|
83
|
-
const hasMasterCSSImport = findCSSImportStatements(source).some((statement)=>statement.source === MASTER_CSS_PACKAGE_ID);
|
|
84
|
-
return {
|
|
85
|
-
hasMasterEntryDirective,
|
|
86
|
-
hasMasterCSSImport,
|
|
87
|
-
hasMasterEntry: hasMasterEntryDirective || hasMasterCSSImport
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function resolveCSSImportGraphFile(file, dependencies, dependencySet, stack, options = {}) {
|
|
91
|
-
const absoluteFile = resolve(file);
|
|
92
|
-
if (stack.includes(absoluteFile)) {
|
|
93
|
-
throw new Error(`Circular CSS import: ${[
|
|
94
|
-
...stack,
|
|
95
|
-
absoluteFile
|
|
96
|
-
].join(' -> ')}`);
|
|
97
|
-
}
|
|
98
|
-
if (!existsSync(absoluteFile)) {
|
|
99
|
-
throw new Error(`CSS manifest entry file not found: ${absoluteFile}`);
|
|
100
|
-
}
|
|
101
|
-
if (!dependencySet.has(absoluteFile)) {
|
|
102
|
-
dependencySet.add(absoluteFile);
|
|
103
|
-
dependencies.push(absoluteFile);
|
|
104
|
-
}
|
|
105
|
-
const source = readFileSync(absoluteFile, 'utf-8');
|
|
106
|
-
const references = findCSSReferenceStatements(source, absoluteFile);
|
|
107
|
-
for (const reference of references){
|
|
108
|
-
options.onReference?.(reference, absoluteFile);
|
|
109
|
-
}
|
|
110
|
-
const sourceWithoutReferences = removeCSSReferenceStatements(source, absoluteFile);
|
|
111
|
-
const imports = findCSSImportStatements(sourceWithoutReferences, absoluteFile);
|
|
112
|
-
if (!imports.length) return sourceWithoutReferences;
|
|
113
|
-
const preservedImports = [];
|
|
114
|
-
const resolvedSource = replaceCSSImportStatements(sourceWithoutReferences, absoluteFile, (importStatement)=>{
|
|
115
|
-
const importSource = importStatement.source;
|
|
116
|
-
const packageFile = options.expandPackageImports !== false ? resolveMasterCSSPackageEntryFile(importSource, absoluteFile, options.projectDir) : undefined;
|
|
117
|
-
if (packageFile || isExpandableImportSource(importSource)) {
|
|
118
|
-
const importedFile = packageFile || resolve(dirname(absoluteFile), importSource);
|
|
119
|
-
return resolveCSSImportGraphFile(importedFile, dependencies, dependencySet, [
|
|
120
|
-
...stack,
|
|
121
|
-
absoluteFile
|
|
122
|
-
], options);
|
|
123
|
-
}
|
|
124
|
-
preservedImports.push(importStatement.statement.trim());
|
|
125
|
-
return '';
|
|
126
|
-
});
|
|
127
|
-
if (!preservedImports.length) return resolvedSource;
|
|
128
|
-
const firstImportStart = imports[0].start;
|
|
129
|
-
const afterImports = resolvedSource.slice(firstImportStart);
|
|
130
|
-
return resolvedSource.slice(0, firstImportStart) + preservedImports.join('\n') + (afterImports ? '\n' : '') + afterImports;
|
|
131
|
-
}
|
|
132
|
-
function resolveCSSImportGraph(file, options = {}) {
|
|
133
|
-
const dependencies = [];
|
|
134
|
-
const references = [];
|
|
135
|
-
const source = resolveCSSImportGraphFile(file, dependencies, new Set(), [], {
|
|
136
|
-
...options,
|
|
137
|
-
onReference (reference, fromFile) {
|
|
138
|
-
references.push(reference);
|
|
139
|
-
options.onReference?.(reference, fromFile);
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
return {
|
|
143
|
-
source,
|
|
144
|
-
dependencies,
|
|
145
|
-
...references.length ? {
|
|
146
|
-
references
|
|
147
|
-
} : {}
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function resolveMasterCSSPackageImportGraph(projectDir) {
|
|
151
|
-
const entry = resolveMasterCSSPackageEntryFile(MASTER_CSS_PACKAGE_ID, projectDir || process.cwd(), projectDir);
|
|
152
|
-
if (!entry) {
|
|
153
|
-
throw new Error(`Cannot resolve ${MASTER_CSS_PACKAGE_ID} CSS entry.`);
|
|
154
|
-
}
|
|
155
|
-
return resolveCSSImportGraph(entry, {
|
|
156
|
-
projectDir
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
function stripRequest(id) {
|
|
160
|
-
return id.replace(/[?#].*$/, '');
|
|
161
|
-
}
|
|
162
|
-
function resolveComparablePath(file) {
|
|
163
|
-
const filename = resolve(file);
|
|
164
|
-
try {
|
|
165
|
-
return realpathSync(filename);
|
|
166
|
-
} catch {
|
|
167
|
-
return filename;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function isMasterCSSPackageStyleFile(id, projectDir) {
|
|
171
|
-
const filename = resolveComparablePath(stripRequest(id));
|
|
172
|
-
if (extname(filename) !== '.css') return false;
|
|
173
|
-
try {
|
|
174
|
-
return resolveMasterCSSPackageImportGraph(projectDir).dependencies.some((dependency)=>{
|
|
175
|
-
return resolveComparablePath(dependency) === filename;
|
|
176
|
-
});
|
|
177
|
-
} catch {
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
function compileCSSFile(file, options = {}) {
|
|
182
|
-
const { root, ...compileOptions } = options;
|
|
183
|
-
const absoluteFile = isAbsolute(file) ? file : resolve(root || '', file);
|
|
184
|
-
const graph = resolveCSSImportGraph(absoluteFile, {
|
|
185
|
-
projectDir: root
|
|
186
|
-
});
|
|
187
|
-
const source = compileOptions.preserveNativeCSS === false ? removeCSSImportStatements(graph.source, absoluteFile) : graph.source;
|
|
188
|
-
const result = compileCSS(source, {
|
|
189
|
-
...compileOptions,
|
|
190
|
-
from: absoluteFile
|
|
191
|
-
});
|
|
192
|
-
return {
|
|
193
|
-
...result,
|
|
194
|
-
dependencies: graph.dependencies,
|
|
195
|
-
...graph.references?.length ? {
|
|
196
|
-
references: graph.references
|
|
197
|
-
} : {}
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
function addUnique(target, values) {
|
|
201
|
-
if (!values) return;
|
|
202
|
-
for (const value of values){
|
|
203
|
-
if (!target.includes(value)) target.push(value);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
function resolveCSSReferenceFile(reference, options = {}) {
|
|
207
|
-
const fromFile = reference.file ? isAbsolute(reference.file) ? reference.file : resolve(options.root || '', reference.file) : resolve(options.root || process.cwd(), 'master.css');
|
|
208
|
-
const packageFile = resolveMasterCSSPackageEntryFile(reference.source, fromFile, options.root);
|
|
209
|
-
if (packageFile) return packageFile;
|
|
210
|
-
if (isExpandableImportSource(reference.source)) return resolve(dirname(fromFile), reference.source);
|
|
211
|
-
throw new Error(`@reference only supports relative CSS files or Master CSS package entries: ${reference.source}`);
|
|
212
|
-
}
|
|
213
|
-
function normalizeReferenceStack(stack) {
|
|
214
|
-
return (stack || []).map((file)=>resolveComparablePath(file));
|
|
215
|
-
}
|
|
216
|
-
function resolveCSSReferenceContext(references, options = {}) {
|
|
217
|
-
const dependencies = [];
|
|
218
|
-
const warnings = [];
|
|
219
|
-
let manifest = options.baseManifest;
|
|
220
|
-
let hasReferences = false;
|
|
221
|
-
for (const reference of references || []){
|
|
222
|
-
const referenceFile = resolveCSSReferenceFile(reference, options);
|
|
223
|
-
const comparableReferenceFile = resolveComparablePath(referenceFile);
|
|
224
|
-
const stack = normalizeReferenceStack(options.referenceStack);
|
|
225
|
-
if (stack.includes(comparableReferenceFile)) {
|
|
226
|
-
throw new Error(`Circular CSS reference: ${[
|
|
227
|
-
...options.referenceStack || [],
|
|
228
|
-
referenceFile
|
|
229
|
-
].join(' -> ')}`);
|
|
230
|
-
}
|
|
231
|
-
const result = compileCSSManifestFileInternal(referenceFile, {
|
|
232
|
-
...options,
|
|
233
|
-
baseManifest: manifest,
|
|
234
|
-
preserveNativeCSS: false,
|
|
235
|
-
referenceStack: options.referenceStack
|
|
236
|
-
});
|
|
237
|
-
hasReferences = true;
|
|
238
|
-
manifest = result.manifest;
|
|
239
|
-
addUnique(dependencies, result.dependencies);
|
|
240
|
-
addUnique(warnings, result.warnings);
|
|
241
|
-
}
|
|
242
|
-
return {
|
|
243
|
-
dependencies,
|
|
244
|
-
warnings,
|
|
245
|
-
...hasReferences ? {
|
|
246
|
-
manifest
|
|
247
|
-
} : {}
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
function toCompileCSSManifestResult(result, options = {}) {
|
|
251
|
-
const { manifestInput: _directiveManifestInput, ...directiveData } = result;
|
|
252
|
-
const referenceContext = resolveCSSReferenceContext(result.references, options);
|
|
253
|
-
const lowerResult = lowerCSSDirectives(result, {
|
|
254
|
-
baseManifest: options.baseManifest,
|
|
255
|
-
resolutionManifest: referenceContext.manifest,
|
|
256
|
-
onWarning: options.onWarning
|
|
257
|
-
});
|
|
258
|
-
const dependencies = [];
|
|
259
|
-
const warnings = [];
|
|
260
|
-
addUnique(dependencies, result.dependencies);
|
|
261
|
-
addUnique(dependencies, referenceContext.dependencies);
|
|
262
|
-
addUnique(warnings, referenceContext.warnings);
|
|
263
|
-
addUnique(warnings, lowerResult.warnings);
|
|
264
|
-
const generatedCSS = lowerResult.generatedCSS || '';
|
|
265
|
-
const css = [
|
|
266
|
-
result.nativeCSS,
|
|
267
|
-
generatedCSS
|
|
268
|
-
].filter(Boolean).join('\n');
|
|
269
|
-
return {
|
|
270
|
-
...directiveData,
|
|
271
|
-
dependencies,
|
|
272
|
-
manifest: lowerResult.manifest,
|
|
273
|
-
warnings,
|
|
274
|
-
generatedCSS,
|
|
275
|
-
css,
|
|
276
|
-
directives: result
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
function createManifestFromCSSResult(result, options = {}) {
|
|
280
|
-
return toCompileCSSManifestResult(result, options);
|
|
281
|
-
}
|
|
282
|
-
function compileCSSManifest(source, options = {}) {
|
|
283
|
-
const from = options.from ? stripRequest(options.from) : undefined;
|
|
284
|
-
const fromFile = from ? isAbsolute(from) ? from : resolve(options.root || '', from) : undefined;
|
|
285
|
-
const result = compileCSS(source, {
|
|
286
|
-
...options,
|
|
287
|
-
...fromFile ? {
|
|
288
|
-
from: fromFile
|
|
289
|
-
} : {}
|
|
290
|
-
});
|
|
291
|
-
return toCompileCSSManifestResult(result, {
|
|
292
|
-
...options,
|
|
293
|
-
...fromFile ? {
|
|
294
|
-
from: fromFile,
|
|
295
|
-
referenceStack: [
|
|
296
|
-
...options.referenceStack || [],
|
|
297
|
-
fromFile
|
|
298
|
-
]
|
|
299
|
-
} : {}
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
function compileCSSManifestFileInternal(file, options = {}) {
|
|
303
|
-
const absoluteFile = isAbsolute(file) ? file : resolve(options.root || '', file);
|
|
304
|
-
const result = compileCSSFile(file, {
|
|
305
|
-
...options,
|
|
306
|
-
preserveNativeCSS: options.preserveNativeCSS ?? false
|
|
307
|
-
});
|
|
308
|
-
return toCompileCSSManifestResult(result, {
|
|
309
|
-
...options,
|
|
310
|
-
from: absoluteFile,
|
|
311
|
-
referenceStack: [
|
|
312
|
-
...options.referenceStack || [],
|
|
313
|
-
absoluteFile
|
|
314
|
-
]
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
function compileCSSManifestFile(file, options = {}) {
|
|
318
|
-
return compileCSSManifestFileInternal(file, options);
|
|
319
|
-
}
|
|
320
|
-
function compileProjectManifest(entries, options = {}) {
|
|
321
|
-
const dependencies = [];
|
|
322
|
-
let extractionPolicy = createCSSDirectiveExtractionPolicy();
|
|
323
|
-
const classNames = [];
|
|
324
|
-
const nativeClassNames = [];
|
|
325
|
-
const nativeCSS = [];
|
|
326
|
-
const css = [];
|
|
327
|
-
const generatedCSS = [];
|
|
328
|
-
const warnings = [];
|
|
329
|
-
let directives = {
|
|
330
|
-
manifestInput: {},
|
|
331
|
-
extractionPolicy: createCSSDirectiveExtractionPolicy(),
|
|
332
|
-
classNames: [],
|
|
333
|
-
nativeClassNames: [],
|
|
334
|
-
nativeCSS: '',
|
|
335
|
-
css: '',
|
|
336
|
-
generatedCSS: '',
|
|
337
|
-
warnings: [],
|
|
338
|
-
dependencies: []
|
|
339
|
-
};
|
|
340
|
-
let manifest = options.baseManifest;
|
|
341
|
-
for (const entry of entries){
|
|
342
|
-
const result = compileCSSFile(entry, {
|
|
343
|
-
...options,
|
|
344
|
-
preserveNativeCSS: options.preserveNativeCSS ?? false
|
|
345
|
-
});
|
|
346
|
-
directives = result;
|
|
347
|
-
extractionPolicy = mergeCSSDirectiveExtractionPolicy(extractionPolicy, result.extractionPolicy);
|
|
348
|
-
addUnique(dependencies, result.dependencies);
|
|
349
|
-
addUnique(classNames, result.classNames);
|
|
350
|
-
addUnique(nativeClassNames, result.nativeClassNames);
|
|
351
|
-
addUnique(warnings, result.warnings);
|
|
352
|
-
const manifestResult = toCompileCSSManifestResult(result, {
|
|
353
|
-
...options,
|
|
354
|
-
baseManifest: manifest,
|
|
355
|
-
from: entry,
|
|
356
|
-
referenceStack: [
|
|
357
|
-
isAbsolute(entry) ? entry : resolve(options.root || '', entry)
|
|
358
|
-
]
|
|
359
|
-
});
|
|
360
|
-
manifest = manifestResult.manifest;
|
|
361
|
-
addUnique(dependencies, manifestResult.dependencies);
|
|
362
|
-
addUnique(warnings, manifestResult.warnings);
|
|
363
|
-
const entryGeneratedCSS = manifestResult.generatedCSS || '';
|
|
364
|
-
if (result.nativeCSS) nativeCSS.push(result.nativeCSS);
|
|
365
|
-
if (entryGeneratedCSS) generatedCSS.push(entryGeneratedCSS);
|
|
366
|
-
if (manifestResult.css) css.push(manifestResult.css);
|
|
367
|
-
}
|
|
368
|
-
return {
|
|
369
|
-
entries,
|
|
370
|
-
manifest: manifest || createMasterCSSManifest(),
|
|
371
|
-
dependencies,
|
|
372
|
-
extractionPolicy,
|
|
373
|
-
classNames,
|
|
374
|
-
nativeClassNames,
|
|
375
|
-
nativeCSS: nativeCSS.join('\n'),
|
|
376
|
-
css: css.join('\n'),
|
|
377
|
-
generatedCSS: generatedCSS.join('\n'),
|
|
378
|
-
warnings,
|
|
379
|
-
directives
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
function toManifestJSONResult(result) {
|
|
383
|
-
return {
|
|
384
|
-
...result,
|
|
385
|
-
json: stringifyMasterCSSManifestJSON(result.manifest)
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
function compileCSSManifestJSON(file, options = {}) {
|
|
389
|
-
return toManifestJSONResult(compileCSSManifestFile(file, options));
|
|
390
|
-
}
|
|
391
|
-
function compileProjectManifestJSON(entries, options = {}) {
|
|
392
|
-
return toManifestJSONResult(compileProjectManifest(entries, options));
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
export { compileCSS, compileCSSFile, compileCSSManifest, compileCSSManifestFile, compileCSSManifestJSON, compileProjectManifest, compileProjectManifestJSON, createCSSDirectiveExtractionPolicy, createManifestFromCSSResult, findCSSReferenceStatements, findStandaloneMasterDirectiveStatements, inspectCSS, isMasterCSSPackageStyleFile, mergeCSSDirectiveExtractionPolicy, removeCSSReferenceStatements, resolveCSSImportGraph, resolveMasterCSSPackageEntryFile, resolveMasterCSSPackageImportGraph, setCSSTransform };
|
package/dist/lexer/imports.mjs
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { getCSSTransform, encodeCSS } from '../css-transform.mjs';
|
|
2
|
-
import { maskManagedPatternEntryNames } from '../core.mjs';
|
|
3
|
-
import { findAtRuleStatementEnd } from './source.mjs';
|
|
4
|
-
import { createSourceLocationResolver, removeSourceRanges, replaceSourceRanges } from '@master/css-lexer';
|
|
5
|
-
|
|
6
|
-
function findCSSImportStatements(source, filename = 'master.css') {
|
|
7
|
-
const statements = [];
|
|
8
|
-
const maskedSource = maskManagedPatternEntryNames(source);
|
|
9
|
-
const resolveLocation = createSourceLocationResolver(maskedSource);
|
|
10
|
-
getCSSTransform()({
|
|
11
|
-
filename,
|
|
12
|
-
code: encodeCSS(maskedSource),
|
|
13
|
-
visitor: {
|
|
14
|
-
Rule: {
|
|
15
|
-
import (rule) {
|
|
16
|
-
const start = resolveLocation(rule.value.loc);
|
|
17
|
-
if (start === -1) return;
|
|
18
|
-
const end = findAtRuleStatementEnd(source, start);
|
|
19
|
-
if (end === -1) return;
|
|
20
|
-
statements.push({
|
|
21
|
-
start,
|
|
22
|
-
end,
|
|
23
|
-
source: rule.value.url,
|
|
24
|
-
statement: source.slice(start, end),
|
|
25
|
-
rule
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
return statements;
|
|
32
|
-
}
|
|
33
|
-
function removeCSSImportStatements(source, filename = 'master.css') {
|
|
34
|
-
return removeSourceRanges(source, findCSSImportStatements(source, filename));
|
|
35
|
-
}
|
|
36
|
-
function replaceCSSImportStatements(source, filename, getReplacement) {
|
|
37
|
-
const replacements = findCSSImportStatements(source, filename).map((statement)=>({
|
|
38
|
-
...statement,
|
|
39
|
-
replacement: getReplacement(statement) ?? statement.statement
|
|
40
|
-
}));
|
|
41
|
-
return replaceSourceRanges(source, replacements);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { findCSSImportStatements, removeCSSImportStatements, replaceCSSImportStatements };
|
package/dist/lexer/source.mjs
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { findCSSStatementEnd } from '@master/css-lexer';
|
|
2
|
-
export { createSourceLocationResolver, removeSourceRanges, replaceSourceRanges } from '@master/css-lexer';
|
|
3
|
-
|
|
4
|
-
function findAtRuleStatementEnd(source, start) {
|
|
5
|
-
const statementEnd = findCSSStatementEnd(source, start);
|
|
6
|
-
return statementEnd.reason === 'semicolon' ? statementEnd.end : -1;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export { findAtRuleStatementEnd };
|