weapp-tailwindcss
Version:
把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!
776 lines (775 loc) • 27.7 kB
JavaScript
const require_rolldown_runtime = require("./rolldown-runtime-CVvi-lCc.cjs");
const require_generator = require("./generator-BE34PYSC.cjs");
let node_fs = require("node:fs");
let node_path = require("node:path");
node_path = require_rolldown_runtime.__toESM(node_path, 1);
let node_process = require("node:process");
node_process = require_rolldown_runtime.__toESM(node_process, 1);
let _weapp_tailwindcss_postcss = require("@weapp-tailwindcss/postcss");
let node_fs_promises = require("node:fs/promises");
let fast_glob = require("fast-glob");
fast_glob = require_rolldown_runtime.__toESM(fast_glob, 1);
let tailwindcss_config = require("tailwindcss-config");
//#region src/tailwindcss/source-scan/inline-source.ts
const NUMERICAL_RANGE_RE = /^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/;
function segmentTopLevel(input, separator, options = {}) {
const parts = [];
const stack = [];
let lastPos = 0;
let quote;
for (let index = 0; index < input.length; index++) {
const char = input[index];
if (char === "\\") {
index += 1;
continue;
}
if (quote) {
if (char === quote) quote = void 0;
continue;
}
if (char === "\"" || char === "'") {
quote = char;
continue;
}
if (char === "(") {
stack.push(")");
continue;
}
if (char === "[") {
stack.push("]");
continue;
}
if (char === "{") {
stack.push("}");
continue;
}
if (stack.length > 0 && char === stack[stack.length - 1]) {
stack.pop();
continue;
}
if (stack.length === 0 && char === separator) {
const part = input.slice(lastPos, index);
if (part || options.keepEmpty) parts.push(part);
lastPos = index + 1;
}
}
const part = input.slice(lastPos);
if (part || options.keepEmpty) parts.push(part);
return parts;
}
function isSequence(value) {
return NUMERICAL_RANGE_RE.test(value);
}
function expandSequence(value) {
const match = value.match(NUMERICAL_RANGE_RE);
if (!match) return [value];
const [, start, end, stepValue] = match;
if (start === void 0 || end === void 0) return [value];
let step = stepValue ? Number.parseInt(stepValue, 10) : void 0;
const startNumber = Number.parseInt(start, 10);
const endNumber = Number.parseInt(end, 10);
const increasing = startNumber < endNumber;
if (step === void 0) step = increasing ? 1 : -1;
if (step === 0) return [];
if (increasing && step < 0) step = -step;
if (!increasing && step > 0) step = -step;
const result = [];
for (let value = startNumber; increasing ? value <= endNumber : value >= endNumber; value += step) result.push(String(value));
return result;
}
function expandInlineSourceCandidatePattern(pattern) {
const index = pattern.indexOf("{");
if (index === -1) return [pattern];
const prefix = pattern.slice(0, index);
const rest = pattern.slice(index);
let depth = 0;
let endIndex = -1;
for (let index = 0; index < rest.length; index++) {
const char = rest[index];
if (char === "{") depth += 1;
else if (char === "}") {
depth -= 1;
if (depth === 0) {
endIndex = index;
break;
}
}
}
if (endIndex === -1) return [pattern];
const inner = rest.slice(1, endIndex);
const suffix = rest.slice(endIndex + 1);
const parts = (isSequence(inner) ? expandSequence(inner) : segmentTopLevel(inner, ",", { keepEmpty: true })).flatMap((part) => expandInlineSourceCandidatePattern(part));
return expandInlineSourceCandidatePattern(suffix).flatMap((suffix) => parts.map((part) => `${prefix}${part}${suffix}`));
}
function parseSourceInlineParam(params) {
let value = params.trim();
const negated = value.startsWith("not ");
if (negated) value = value.slice(4).trim();
if (!value.startsWith("inline(") || !value.endsWith(")")) return;
const inlineValue = value.slice(7, -1).trim();
const match = /^(['"])([\s\S]*)\1$/.exec(inlineValue);
if (!match) return;
const source = match[2];
if (source === void 0) return;
return {
negated,
source
};
}
function collectCssInlineSourceCandidates(root) {
const included = /* @__PURE__ */ new Set();
const excluded = /* @__PURE__ */ new Set();
root.walkAtRules("source", (rule) => {
const parsed = parseSourceInlineParam(rule.params);
if (!parsed) return;
const target = parsed.negated ? excluded : included;
for (const source of segmentTopLevel(parsed.source, " ")) {
const trimmed = source.trim();
if (!trimmed) continue;
for (const candidate of expandInlineSourceCandidatePattern(trimmed)) {
const normalized = candidate.trim();
if (normalized) target.add(normalized);
}
}
});
for (const candidate of excluded) included.delete(candidate);
return {
included,
excluded
};
}
//#endregion
//#region src/tailwindcss/v4/preflight.ts
function parseCssImportSpecifier(params) {
const value = params.trim();
const quoted = /^(['"])(.*?)\1/.exec(value);
if (quoted) return quoted[2];
const url = /^url\(\s*(?:(['"])(.*?)\1|([^'")\s]+))\s*\)/.exec(value);
return url?.[2] ?? url?.[3];
}
function normalizeTailwindImportSpecifier(params) {
return parseCssImportSpecifier(params)?.replaceAll("\\", "/");
}
function isTailwindV4CssImportParam(params) {
const specifier = normalizeTailwindImportSpecifier(params);
return specifier === "tailwindcss" || specifier === "tailwindcss4" || specifier?.startsWith("tailwindcss/") === true || specifier?.startsWith("tailwindcss4/") === true || specifier?.endsWith("/tailwindcss/index.css") === true;
}
function isTailwindV4PreflightImportParam(params) {
const specifier = normalizeTailwindImportSpecifier(params);
return specifier === "tailwindcss" || specifier === "tailwindcss4" || specifier === "tailwindcss/preflight" || specifier === "tailwindcss/preflight.css" || specifier === "tailwindcss4/preflight" || specifier === "tailwindcss4/preflight.css" || specifier?.endsWith("/tailwindcss/index.css") === true || specifier?.endsWith("/tailwindcss/preflight.css") === true;
}
function includesTailwindV4PreflightDirective(css) {
try {
const root = _weapp_tailwindcss_postcss.postcss.parse(css);
let includesPreflight = false;
root.walkAtRules("import", (rule) => {
includesPreflight || (includesPreflight = isTailwindV4PreflightImportParam(rule.params));
});
root.walkAtRules("tailwind", (rule) => {
includesPreflight || (includesPreflight = rule.params.trim() === "base");
});
return includesPreflight;
} catch {
return /@import\s+(?:url\(\s*)?["']?tailwindcss4?(?:\/(?:preflight(?:\.css)?|index\.css))?["')\s;]/.test(css) || /@tailwind\s+base\b/.test(css);
}
}
//#endregion
//#region src/bundlers/shared/static-config-content.ts
function skipWhitespaceAndComments(source, start) {
let index = start;
while (index < source.length) {
const char = source[index];
if (/\s/.test(char ?? "")) {
index += 1;
continue;
}
if (char === "/" && source[index + 1] === "/") {
index += 2;
while (index < source.length && source[index] !== "\n") index += 1;
continue;
}
if (char === "/" && source[index + 1] === "*") {
index += 2;
while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) index += 1;
index = Math.min(index + 2, source.length);
continue;
}
break;
}
return index;
}
function readQuotedString(source, start) {
const quote = source[start];
if (quote !== "\"" && quote !== "'") return;
let value = "";
for (let index = start + 1; index < source.length; index++) {
const char = source[index];
if (char === "\\") {
const next = source[index + 1];
if (next === void 0) return;
value += next;
index += 1;
continue;
}
if (char === quote) return {
end: index + 1,
value
};
value += char;
}
}
function readIdentifier(source, start) {
return /^[A-Z_$][\w$]*/i.exec(source.slice(start))?.[0];
}
function findMatchingBracket(source, start, open, close) {
let depth = 0;
let quote;
for (let index = start; index < source.length; index++) {
const char = source[index];
if (char === "\\") {
index += 1;
continue;
}
if (quote) {
if (char === quote) quote = void 0;
continue;
}
if (char === "\"" || char === "'") {
quote = char;
continue;
}
if (char === "`") return;
if (char === open) {
depth += 1;
continue;
}
if (char === close) {
depth -= 1;
if (depth === 0) return index;
}
}
}
function findContentPropertyValue(source) {
let index = 0;
while (index < source.length) {
const nextIndex = source.indexOf("content", index);
if (nextIndex === -1) return;
const previous = source[nextIndex - 1];
const next = source[nextIndex + 7];
if (previous && /[\w$]/.test(previous) || next && /[\w$]/.test(next)) {
index = nextIndex + 7;
continue;
}
let colonIndex = skipWhitespaceAndComments(source, nextIndex + 7);
if (source[colonIndex] !== ":") {
index = nextIndex + 7;
continue;
}
colonIndex = skipWhitespaceAndComments(source, colonIndex + 1);
return { start: colonIndex };
}
}
function parseStaticContentArray(source, start) {
if (source[start] !== "[") return;
const value = [];
let index = skipWhitespaceAndComments(source, start + 1);
while (index < source.length) {
if (source[index] === "]") return {
end: index + 1,
value
};
const parsed = parseStaticContentValue(source, index);
if (!parsed) return;
value.push(parsed.value);
index = skipWhitespaceAndComments(source, parsed.end);
if (source[index] === ",") {
index = skipWhitespaceAndComments(source, index + 1);
continue;
}
if (source[index] === "]") continue;
return;
}
}
function parseStaticContentObject(source, start) {
if (source[start] !== "{") return;
const end = findMatchingBracket(source, start, "{", "}");
if (end === void 0) return;
let index = skipWhitespaceAndComments(source, start + 1);
let files;
while (index < end) {
let key;
const quotedKey = readQuotedString(source, index);
if (quotedKey) {
key = quotedKey.value;
index = quotedKey.end;
} else {
key = readIdentifier(source, index);
if (!key) return;
index += key.length;
}
index = skipWhitespaceAndComments(source, index);
if (source[index] !== ":") return;
index = skipWhitespaceAndComments(source, index + 1);
const parsedValue = parseStaticContentValue(source, index);
if (!parsedValue) return;
if (key === "files") files = parsedValue.value;
index = skipWhitespaceAndComments(source, parsedValue.end);
if (source[index] === ",") {
index = skipWhitespaceAndComments(source, index + 1);
continue;
}
if (index < end) return;
}
return files === void 0 ? void 0 : {
end: end + 1,
value: { files }
};
}
function parseStaticContentValue(source, start) {
const index = skipWhitespaceAndComments(source, start);
const quoted = readQuotedString(source, index);
if (quoted) return quoted;
if (source[index] === "[") return parseStaticContentArray(source, index);
if (source[index] === "{") return parseStaticContentObject(source, index);
}
function readStaticConfigContent(configPath) {
let source;
try {
source = (0, node_fs.readFileSync)(configPath, "utf8");
} catch {
return;
}
const contentProperty = findContentPropertyValue(source);
if (!contentProperty) return;
return parseStaticContentValue(source, contentProperty.start)?.value;
}
//#endregion
//#region src/bundlers/shared/source-scan/css-entries.ts
const SOURCE_CANDIDATE_PATTERN = require_generator.FULL_SOURCE_SCAN_PATTERN;
const TAILWIND_CSS_ENTRY_PATTERN = "**/*.css";
const tailwindV4CssEntriesCache = /* @__PURE__ */ new Map();
function parseImportSourceParam(params) {
const match = /\bsource\(\s*(none|(['"])(.*?)\2)\s*\)/.exec(params);
if (!match) return;
return {
none: match[1] === "none",
sourcePath: match[3]
};
}
function resolveSourceBase(base, sourcePath) {
return node_path.default.isAbsolute(sourcePath) ? sourcePath : node_path.default.resolve(base, sourcePath);
}
function resolveConfigPath(base, configPath) {
if (node_path.default.isAbsolute(configPath)) return node_path.default.resolve(configPath);
return node_path.default.resolve(base, configPath);
}
function createCssEntriesCacheKey(css, base, dependencies) {
return JSON.stringify({
base: node_path.default.resolve(base),
css,
dependencies
});
}
async function statConfigDependency(file) {
try {
const stats = await (0, node_fs_promises.stat)(file);
return {
file,
mtimeMs: stats.mtimeMs,
size: stats.size
};
} catch {
return {
file,
mtimeMs: -1,
size: -1
};
}
}
async function collectConfigDependencySignatures(root, base) {
const configPaths = /* @__PURE__ */ new Set();
root.walkAtRules("config", (rule) => {
const configPath = require_generator.parseConfigParam(rule.params);
if (configPath) configPaths.add(resolveConfigPath(base, configPath));
});
return Promise.all([...configPaths].sort().map(statConfigDependency));
}
function mergeTailwindInlineSourceCandidates(allInlineCandidates) {
const merged = {
included: /* @__PURE__ */ new Set(),
excluded: /* @__PURE__ */ new Set()
};
for (const inlineCandidates of allInlineCandidates) {
if (!inlineCandidates) continue;
for (const candidate of inlineCandidates.included) if (!merged.excluded.has(candidate)) merged.included.add(candidate);
for (const candidate of inlineCandidates.excluded) {
merged.excluded.add(candidate);
merged.included.delete(candidate);
}
}
return merged.included.size > 0 || merged.excluded.size > 0 ? merged : void 0;
}
async function resolveConfigContentEntries(root, base) {
const configPaths = /* @__PURE__ */ new Set();
root.walkAtRules("config", (rule) => {
const configPath = require_generator.parseConfigParam(rule.params);
if (configPath) configPaths.add(resolveConfigPath(base, configPath));
});
const entries = [];
for (const configPath of configPaths) {
const staticContent = readStaticConfigContent(configPath);
if (staticContent !== void 0) {
entries.push(...require_generator.normalizeLegacyContentEntries(staticContent, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
continue;
}
try {
const loaded = await (0, tailwindcss_config.loadConfig)({
config: configPath,
cwd: node_path.default.dirname(configPath)
});
entries.push(...require_generator.normalizeLegacyContentEntries(loaded?.config.content, node_path.default.dirname(configPath), { relativeBase: node_path.default.dirname(configPath) }));
} catch {}
}
return {
dependencies: [...configPaths],
entries
};
}
async function resolveTailwindV4EntriesFromCss(css, base) {
let root;
try {
root = _weapp_tailwindcss_postcss.postcss.parse(css);
} catch {
return;
}
let importSourceBase;
let hasSourceNone = false;
let hasTailwindCssImport = false;
let includesPreflight = false;
const [sourceEntries, configEntries] = await Promise.all([require_generator.resolveCssSourceEntries(root, base, SOURCE_CANDIDATE_PATTERN), resolveConfigContentEntries(root, base)]);
const entries = [...configEntries.entries, ...sourceEntries];
const hasPositiveEntries = entries.some((entry) => !entry.negated);
const inlineCandidates = collectCssInlineSourceCandidates(root);
root.walkAtRules("import", (rule) => {
if (!isTailwindV4CssImportParam(rule.params)) return;
hasTailwindCssImport = true;
includesPreflight || (includesPreflight = isTailwindV4PreflightImportParam(rule.params));
const sourceParam = parseImportSourceParam(rule.params);
if (sourceParam?.none) hasSourceNone = true;
if (sourceParam?.sourcePath) importSourceBase = resolveSourceBase(base, sourceParam.sourcePath);
});
root.walkAtRules("tailwind", (rule) => {
includesPreflight || (includesPreflight = rule.params.trim() === "base");
});
if (importSourceBase) return {
entries: [{
base: importSourceBase,
negated: false,
pattern: SOURCE_CANDIDATE_PATTERN
}, ...entries],
explicit: true,
includesPreflight,
inlineCandidates,
dependencies: configEntries.dependencies
};
if (hasSourceNone) return {
entries,
explicit: true,
includesPreflight,
inlineCandidates,
dependencies: configEntries.dependencies
};
if (hasPositiveEntries) return {
entries,
explicit: true,
includesPreflight,
inlineCandidates,
dependencies: configEntries.dependencies
};
if (inlineCandidates.included.size > 0 || inlineCandidates.excluded.size > 0) return {
entries: [],
explicit: true,
includesPreflight,
inlineCandidates,
dependencies: configEntries.dependencies
};
return hasTailwindCssImport ? {
entries,
explicit: false,
includesPreflight,
inlineCandidates,
dependencies: configEntries.dependencies
} : void 0;
}
async function resolveTailwindV4CssDependencies(css, base) {
return (await resolveTailwindV4EntriesFromCss(css, base))?.dependencies ?? [];
}
function collectExistingCssEntries(options) {
return [
...options.cssEntries ?? [],
...options.tailwindcss?.v4?.cssEntries ?? [],
...options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssEntries ?? []
].filter((item) => typeof item === "string" && item.length > 0).filter(require_generator.isTailwindV4CssEntry).map((item) => node_path.default.resolve(item)).filter((item) => (0, node_fs.existsSync)(item));
}
async function pathExistsAsFile(file) {
try {
return (await (0, node_fs_promises.stat)(file)).isFile();
} catch {
return false;
}
}
async function resolveTailwindV4EntriesFromCssCached(css, base) {
let root;
try {
root = _weapp_tailwindcss_postcss.postcss.parse(css);
} catch {
return;
}
const cacheKey = createCssEntriesCacheKey(css, base, await collectConfigDependencySignatures(root, base));
const cached = tailwindV4CssEntriesCache.get(cacheKey);
if (cached) return cached;
const task = resolveTailwindV4EntriesFromCss(css, base).catch((error) => {
tailwindV4CssEntriesCache.delete(cacheKey);
throw error;
});
tailwindV4CssEntriesCache.set(cacheKey, task);
return task;
}
async function discoverTailwindV4CssEntries(root, outDir) {
const resolvedRoot = node_path.default.resolve(root);
const ignore = ["**/node_modules/**", "**/.git/**"];
const resolvedOutDir = outDir ? node_path.default.resolve(resolvedRoot, outDir) : void 0;
if (resolvedOutDir) {
const relativeOutDir = node_path.default.relative(resolvedRoot, resolvedOutDir);
if (relativeOutDir && !relativeOutDir.startsWith("..") && !node_path.default.isAbsolute(relativeOutDir)) ignore.push(`${relativeOutDir.split(node_path.default.sep).join("/")}/**`);
}
const candidates = await (0, fast_glob.default)(TAILWIND_CSS_ENTRY_PATTERN, {
absolute: true,
cwd: resolvedRoot,
ignore,
onlyFiles: true,
unique: true
});
const entries = [];
for (const file of candidates) {
if (!await pathExistsAsFile(file)) continue;
try {
const css = (0, node_fs.readFileSync)(file, "utf8");
if (css.includes("tailwindcss") || css.includes("@source") || css.includes("@config")) {
if (await resolveTailwindV4EntriesFromCssCached(css, node_path.default.dirname(file))) entries.push(file);
}
} catch {}
}
return entries;
}
function collectConfiguredCssSources(options) {
return require_generator.filterTailwindV4CssSourceRoots([...options.tailwindcss?.v4?.cssSources ?? [], ...options.tailwindcssRuntimeOptions?.tailwindcss?.v4?.cssSources ?? []]) ?? [];
}
//#endregion
//#region src/bundlers/shared/source-scan/dependencies.ts
function addSourceScanDependency(dependencies, file) {
if (typeof file === "string" && file.length > 0) dependencies.add(node_path.default.resolve(file));
}
function addSourceScanDependencies(dependencies, files) {
for (const file of files ?? []) addSourceScanDependency(dependencies, file);
}
//#endregion
//#region src/bundlers/shared/source-scan.ts
function createResolvedSourceScan(input, dependencies) {
return {
...input,
...dependencies.size > 0 ? { dependencies: [...dependencies].sort() } : {}
};
}
function createMergedCssEntrySourceScanEntries(entries, options) {
if (options.sourceCount <= 1) return entries;
const positiveEntries = entries.filter((entry) => !entry.negated);
return positiveEntries.length > 0 ? positiveEntries : entries;
}
function resolveExplicitSourceScanEntries(entries, explicit) {
if (!explicit) return entries.length > 0 ? entries : void 0;
return entries.some((entry) => !entry.negated) ? entries : [];
}
function createResolvedV4CssScanInput(entries, inlineCandidates, explicit) {
return {
entries: resolveExplicitSourceScanEntries(entries, explicit),
explicit,
inlineCandidates
};
}
async function resolveSourceScanEntries(options, runtime, scanOptions = {}) {
const sourceOptions = require_generator.resolveTailwindV4SourceOptionsFromRuntime(runtime);
const cssEntries = collectExistingCssEntries(options);
if (cssEntries.length === 0 && !sourceOptions.css && !sourceOptions.cssSources?.length) {
const scanRoot = scanOptions.root;
const sourceProjectRoot = sourceOptions.projectRoot;
if (scanRoot && sourceProjectRoot && node_path.default.resolve(scanRoot) === node_path.default.resolve(sourceProjectRoot)) {
const discoveredCssEntries = await discoverTailwindV4CssEntries(scanRoot, scanOptions.outDir);
cssEntries.push(...discoveredCssEntries);
}
}
const entries = [];
const cssInlineCandidates = [];
const dependencies = /* @__PURE__ */ new Set();
let explicit = false;
let readableCssEntryCount = 0;
for (const cssEntry of cssEntries) {
addSourceScanDependency(dependencies, cssEntry);
let css;
try {
css = (0, node_fs.readFileSync)(cssEntry, "utf8");
} catch {
continue;
}
readableCssEntryCount++;
const resolved = await resolveTailwindV4EntriesFromCssCached(css, node_path.default.dirname(cssEntry));
if (resolved) {
entries.push(...resolved.entries);
cssInlineCandidates.push(resolved.inlineCandidates);
addSourceScanDependencies(dependencies, resolved.dependencies);
explicit || (explicit = resolved.explicit);
}
}
const inlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
const scanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: readableCssEntryCount });
if (scanEntries.length > 0 || inlineCandidates || explicit || readableCssEntryCount > 0) return createResolvedSourceScan({
entries: resolveExplicitSourceScanEntries(scanEntries, explicit),
explicit,
inlineCandidates
}, dependencies);
if (typeof sourceOptions.css === "string" && sourceOptions.css.length > 0) {
const resolved = await resolveTailwindV4EntriesFromCssCached(sourceOptions.css, sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd());
return resolved ? createResolvedSourceScan(createResolvedV4CssScanInput(resolved.entries, resolved.inlineCandidates, resolved.explicit), new Set(resolved.dependencies)) : void 0;
}
const sourceOptionBase = sourceOptions.base ?? sourceOptions.projectRoot ?? node_process.default.cwd();
const configuredCssSources = collectConfiguredCssSources(options);
for (const cssSource of [...configuredCssSources, ...sourceOptions.cssSources ?? []]) {
if (typeof cssSource.css !== "string" || cssSource.css.length === 0) continue;
addSourceScanDependency(dependencies, cssSource.file);
addSourceScanDependencies(dependencies, cssSource.dependencies);
const resolved = await resolveTailwindV4EntriesFromCssCached(cssSource.css, require_generator.resolveTailwindV4CssSourceBase(cssSource, sourceOptionBase));
if (resolved) {
entries.push(...resolved.entries);
cssInlineCandidates.push(resolved.inlineCandidates);
addSourceScanDependencies(dependencies, resolved.dependencies);
explicit || (explicit = resolved.explicit);
}
}
const cssSourceInlineCandidates = mergeTailwindInlineSourceCandidates(cssInlineCandidates);
const cssSourceCount = (sourceOptions.cssSources?.length ?? 0) + configuredCssSources.length;
const cssSourceScanEntries = createMergedCssEntrySourceScanEntries(entries, { sourceCount: cssSourceCount });
if (cssSourceScanEntries.length > 0 || cssSourceInlineCandidates || explicit) return createResolvedSourceScan({
entries: resolveExplicitSourceScanEntries(cssSourceScanEntries, explicit),
explicit,
inlineCandidates: cssSourceInlineCandidates
}, dependencies);
if (cssSourceCount > 0) return;
const source = await require_generator.resolveTailwindV4SourceFromRuntime(runtime);
addSourceScanDependency(dependencies, source.file);
addSourceScanDependencies(dependencies, source.dependencies);
const resolved = await resolveTailwindV4EntriesFromCssCached(source.css, source.base);
return resolved ? createResolvedSourceScan(createResolvedV4CssScanInput(resolved.entries.length > 0 ? resolved.entries : [], resolved.inlineCandidates, resolved.entries.length > 0 ? resolved.explicit : false), /* @__PURE__ */ new Set([...dependencies, ...resolved.dependencies])) : void 0;
}
function createSourceScanMatcher(entries) {
if (entries?.length === 0) return () => false;
return require_generator.createTailwindSourceEntryMatcher(entries);
}
//#endregion
//#region src/uni-app-x/options.ts
const DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS = {
enabled: true,
onlyWhenStyleIsolationVersion2: true
};
const DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS = {
enabled: false,
onlyWhenStyleIsolationVersion2: true
};
function isBooleanUniAppXShortcut(option) {
return option === true || option === false || option === void 0;
}
function resolveComponentLocalStyles(option) {
if (isBooleanUniAppXShortcut(option)) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
const componentLocalStyles = option.componentLocalStyles;
if (componentLocalStyles === false) return DISABLED_COMPONENT_LOCAL_STYLES_OPTIONS;
if (componentLocalStyles === true || componentLocalStyles === void 0) return DEFAULT_COMPONENT_LOCAL_STYLES_OPTIONS;
return {
enabled: componentLocalStyles.enabled !== false,
onlyWhenStyleIsolationVersion2: componentLocalStyles.onlyWhenStyleIsolationVersion2 !== false
};
}
function resolveUniAppXOptions(option) {
if (typeof option === "object" && option) return {
enabled: option.enabled !== false,
componentLocalStyles: resolveComponentLocalStyles(option),
uvueUnsupported: option.uvueUnsupported ?? "warn"
};
return {
enabled: Boolean(option),
componentLocalStyles: resolveComponentLocalStyles(option),
uvueUnsupported: "warn"
};
}
function isUniAppXEnabled(option) {
return resolveUniAppXOptions(option).enabled;
}
//#endregion
Object.defineProperty(exports, "collectCssInlineSourceCandidates", {
enumerable: true,
get: function() {
return collectCssInlineSourceCandidates;
}
});
Object.defineProperty(exports, "createSourceScanMatcher", {
enumerable: true,
get: function() {
return createSourceScanMatcher;
}
});
Object.defineProperty(exports, "discoverTailwindV4CssEntries", {
enumerable: true,
get: function() {
return discoverTailwindV4CssEntries;
}
});
Object.defineProperty(exports, "includesTailwindV4PreflightDirective", {
enumerable: true,
get: function() {
return includesTailwindV4PreflightDirective;
}
});
Object.defineProperty(exports, "isUniAppXEnabled", {
enumerable: true,
get: function() {
return isUniAppXEnabled;
}
});
Object.defineProperty(exports, "resolveSourceScanEntries", {
enumerable: true,
get: function() {
return resolveSourceScanEntries;
}
});
Object.defineProperty(exports, "resolveTailwindV4CssDependencies", {
enumerable: true,
get: function() {
return resolveTailwindV4CssDependencies;
}
});
Object.defineProperty(exports, "resolveTailwindV4EntriesFromCss", {
enumerable: true,
get: function() {
return resolveTailwindV4EntriesFromCss;
}
});
Object.defineProperty(exports, "resolveTailwindV4EntriesFromCssCached", {
enumerable: true,
get: function() {
return resolveTailwindV4EntriesFromCssCached;
}
});
Object.defineProperty(exports, "resolveUniAppXOptions", {
enumerable: true,
get: function() {
return resolveUniAppXOptions;
}
});