tailwindcss-patch 9.3.3 → 9.3.5
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/cli.js +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/commands/cli-runtime.d.mts +1 -1
- package/dist/commands/cli-runtime.d.ts +1 -1
- package/dist/commands/cli-runtime.js +1 -1
- package/dist/commands/cli-runtime.mjs +1 -1
- package/dist/{index.bundle-C39laqrA.mjs → index.bundle-BXhvZOy8.mjs} +1 -1
- package/dist/{index.bundle-BdxyJef9.js → index.bundle-Cz6ZOOFG.js} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -2
- package/dist/index.mjs +3 -3
- package/dist/{validate-DABvQ44V.js → validate-5TFH6ktk.js} +186 -1
- package/dist/{validate-DDJnolx2.d.mts → validate-Bd5gnHL1.d.mts} +6 -3
- package/dist/{validate-cMWKFUKS.mjs → validate-SJIkeBUb.mjs} +175 -2
- package/dist/{validate-rPPCy1cl.d.ts → validate-ZwyABmFW.d.ts} +6 -3
- package/package.json +1 -1
- package/src/extraction/candidate-extractor.ts +246 -1
- package/src/index.bundle.ts +4 -0
- package/src/index.ts +3 -0
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_validate = require("./validate-
|
|
3
|
-
const require_index_bundle = require("./index.bundle-
|
|
2
|
+
const require_validate = require("./validate-5TFH6ktk.js");
|
|
3
|
+
const require_index_bundle = require("./index.bundle-Cz6ZOOFG.js");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process);
|
|
6
6
|
//#region src/cli.bundle.ts
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as createTailwindcssPatchCli } from "./index.bundle-
|
|
1
|
+
import { N as logger, r as ValidateCommandError } from "./validate-SJIkeBUb.mjs";
|
|
2
|
+
import { t as createTailwindcssPatchCli } from "./index.bundle-BXhvZOy8.mjs";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
//#region src/cli.bundle.ts
|
|
5
5
|
async function main() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ValidateFailureSummary, c as TailwindcssPatchCliMountOptions, d as TailwindcssPatchCommandContext, f as TailwindcssPatchCommandHandler, g as tailwindcssPatchCommands, h as TailwindcssPatchCommandOptions, i as ValidateFailureReason, l as TailwindcssPatchCliOptions, m as TailwindcssPatchCommandOptionDefinition, n as VALIDATE_FAILURE_REASONS, o as ValidateJsonFailurePayload, p as TailwindcssPatchCommandHandlerMap, r as ValidateCommandError, s as ValidateJsonSuccessPayload, t as VALIDATE_EXIT_CODES, u as TailwindcssPatchCommand } from "../validate-
|
|
1
|
+
import { a as ValidateFailureSummary, c as TailwindcssPatchCliMountOptions, d as TailwindcssPatchCommandContext, f as TailwindcssPatchCommandHandler, g as tailwindcssPatchCommands, h as TailwindcssPatchCommandOptions, i as ValidateFailureReason, l as TailwindcssPatchCliOptions, m as TailwindcssPatchCommandOptionDefinition, n as VALIDATE_FAILURE_REASONS, o as ValidateJsonFailurePayload, p as TailwindcssPatchCommandHandlerMap, r as ValidateCommandError, s as ValidateJsonSuccessPayload, t as VALIDATE_EXIT_CODES, u as TailwindcssPatchCommand } from "../validate-Bd5gnHL1.mjs";
|
|
2
2
|
import { CAC } from "cac";
|
|
3
3
|
|
|
4
4
|
//#region src/commands/cli.d.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as ValidateFailureSummary, c as TailwindcssPatchCliMountOptions, d as TailwindcssPatchCommandContext, f as TailwindcssPatchCommandHandler, g as tailwindcssPatchCommands, h as TailwindcssPatchCommandOptions, i as ValidateFailureReason, l as TailwindcssPatchCliOptions, m as TailwindcssPatchCommandOptionDefinition, n as VALIDATE_FAILURE_REASONS, o as ValidateJsonFailurePayload, p as TailwindcssPatchCommandHandlerMap, r as ValidateCommandError, s as ValidateJsonSuccessPayload, t as VALIDATE_EXIT_CODES, u as TailwindcssPatchCommand } from "../validate-
|
|
1
|
+
import { a as ValidateFailureSummary, c as TailwindcssPatchCliMountOptions, d as TailwindcssPatchCommandContext, f as TailwindcssPatchCommandHandler, g as tailwindcssPatchCommands, h as TailwindcssPatchCommandOptions, i as ValidateFailureReason, l as TailwindcssPatchCliOptions, m as TailwindcssPatchCommandOptionDefinition, n as VALIDATE_FAILURE_REASONS, o as ValidateJsonFailurePayload, p as TailwindcssPatchCommandHandlerMap, r as ValidateCommandError, s as ValidateJsonSuccessPayload, t as VALIDATE_EXIT_CODES, u as TailwindcssPatchCommand } from "../validate-ZwyABmFW.js";
|
|
2
2
|
import { CAC } from "cac";
|
|
3
3
|
|
|
4
4
|
//#region src/commands/cli.d.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_chunk = require("../chunk-8l464Juk.js");
|
|
3
|
-
const require_validate = require("../validate-
|
|
3
|
+
const require_validate = require("../validate-5TFH6ktk.js");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process);
|
|
6
6
|
let fs_extra = require("fs-extra");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as loadWorkspaceConfigModule, N as logger, S as groupTokensByFile, a as tailwindcssPatchCommands, i as classifyValidateError, k as loadPatchOptionsForWorkspace, n as VALIDATE_FAILURE_REASONS, o as migrateConfigFiles, r as ValidateCommandError, s as restoreConfigFiles, t as VALIDATE_EXIT_CODES, u as TailwindcssPatcher } from "../validate-SJIkeBUb.mjs";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import fs from "fs-extra";
|
|
4
4
|
import path from "pathe";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { C as compileTailwindV4Source, D as replaceBareArbitraryValueSelectors, E as extractTailwindV4InlineSourceCandidates, O as resolveValidTailwindV4Candidates, T as canonicalizeBareArbitraryValueCandidates, _ as extractRawCandidates, j as normalizeOptions, v as extractRawCandidatesWithPositions, w as loadTailwindV4DesignSystem } from "./validate-SJIkeBUb.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import path from "pathe";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require("./chunk-8l464Juk.js");
|
|
2
|
-
const require_validate = require("./validate-
|
|
2
|
+
const require_validate = require("./validate-5TFH6ktk.js");
|
|
3
3
|
let node_module = require("node:module");
|
|
4
4
|
let node_process = require("node:process");
|
|
5
5
|
node_process = require_chunk.__toESM(node_process);
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as TailwindV4GenerateResult, A as extractSourceCandidatesWithPositions, B as ExtractOptions, C as MIGRATION_REPORT_SCHEMA_VERSION, D as extractRawCandidates, E as extractProjectCandidatesWithPositions, F as ApplyOptions, G as TailwindV2Options, H as NormalizedTailwindCssPatchOptions, I as CacheOptions, J as TailwindV4CandidateSource, K as TailwindV3Options, L as CacheStrategy, M as groupTokensByFile, N as BareArbitraryValueOptions, O as extractRawCandidatesWithPositions, P as normalizeOptions, Q as TailwindV4GenerateOptions, R as ExposeContextOptions, S as MIGRATION_REPORT_KIND, St as CacheReadResult, T as TailwindcssPatcher, U as TailwindCssOptions, V as NormalizedCacheOptions, W as TailwindCssPatchOptions, X as TailwindV4DesignSystem, Y as TailwindV4CssSource, Z as TailwindV4Engine, _ as ConfigFileMigrationEntry, _t as CacheClearScope, a as ValidateFailureSummary, at as PatchName, b as RestoreConfigFilesOptions, bt as CacheIndexFileV2, c as TailwindcssPatchCliMountOptions, ct as TailwindPatchRuntime, d as TailwindcssPatchCommandContext, dt as TailwindTokenLocation, et as TailwindV4ResolvedSource, f as TailwindcssPatchCommandHandler, ft as TailwindTokenReport, g as tailwindcssPatchCommands, gt as CacheClearResult, h as TailwindcssPatchCommandOptions, ht as CacheClearOptions, i as ValidateFailureReason, it as PatchCheckStatus, j as extractValidCandidates, k as extractSourceCandidates, l as TailwindcssPatchCliOptions, lt as TailwindTokenByFileMap, m as TailwindcssPatchCommandOptionDefinition, mt as TailwindcssRuntimeContext, n as VALIDATE_FAILURE_REASONS, nt as ExtractResult, o as ValidateJsonFailurePayload, ot as PatchStatusEntry, p as TailwindcssPatchCommandHandlerMap, pt as TailwindcssClassCache, q as TailwindV4Options, r as ValidateCommandError, rt as ILengthUnitsPatchOptions, s as ValidateJsonSuccessPayload, st as PatchStatusReport, t as VALIDATE_EXIT_CODES, tt as TailwindV4SourceOptions, u as TailwindcssPatchCommand, ut as TailwindTokenFileKey, v as ConfigFileMigrationReport, vt as CacheContextDescriptor, w as logger, x as RestoreConfigFilesResult, xt as CacheReadMeta, y as MigrateConfigFilesOptions, yt as CacheContextMetadata, z as ExtendLengthUnitsOptions } from "./validate-Bd5gnHL1.mjs";
|
|
2
2
|
import { PackageInfo } from "local-pkg";
|
|
3
3
|
import postcss from "postcss";
|
|
4
4
|
import { CAC } from "cac";
|
|
@@ -97,4 +97,4 @@ declare function mountTailwindcssPatchCommands(cli: CAC, options?: TailwindcssPa
|
|
|
97
97
|
declare function createTailwindcssPatchCli(options?: TailwindcssPatchCliOptions): CAC;
|
|
98
98
|
declare function defineConfig<T extends TailwindcssMangleConfig>(config: T): T;
|
|
99
99
|
//#endregion
|
|
100
|
-
export { ApplyOptions, CacheClearOptions, CacheClearResult, CacheClearScope, CacheContextMetadata, CacheOptions, CacheReadMeta, CacheStore, CacheStrategy, type ConfigFileMigrationEntry, type ConfigFileMigrationReport, ExposeContextOptions, ExtendLengthUnitsOptions, ExtractOptions, ExtractResult, ILengthUnitsPatchOptions, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, type MigrateConfigFilesOptions, NormalizedTailwindCssPatchOptions, PatchCheckStatus, PatchName, PatchStatusEntry, PatchStatusReport, type RestoreConfigFilesOptions, type RestoreConfigFilesResult, TailwindCssOptions, type TailwindCssPatchOptions, TailwindPatchRuntime, TailwindTokenByFileMap, TailwindTokenFileKey, TailwindTokenLocation, TailwindTokenReport, TailwindV2Options, TailwindV3Options, type TailwindV4CandidateSource, type TailwindV4CssSource, type TailwindV4DesignSystem, type TailwindV4Engine, type TailwindV4GenerateOptions, type TailwindV4GenerateResult, TailwindV4Options, type TailwindV4ResolvedSource, type TailwindV4SourceOptions, TailwindcssClassCache, type TailwindcssPatchCliMountOptions, type TailwindcssPatchCliOptions, type TailwindcssPatchCommand, type TailwindcssPatchCommandContext, type TailwindcssPatchCommandHandler, type TailwindcssPatchCommandHandlerMap, type TailwindcssPatchCommandOptionDefinition, type TailwindcssPatchCommandOptions, TailwindcssPatcher, TailwindcssRuntimeContext, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, type ValidateFailureReason, type ValidateFailureSummary, type ValidateJsonFailurePayload, type ValidateJsonSuccessPayload, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindV4Engine, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
|
100
|
+
export { ApplyOptions, CacheClearOptions, CacheClearResult, CacheClearScope, CacheContextMetadata, CacheOptions, CacheReadMeta, CacheStore, CacheStrategy, type ConfigFileMigrationEntry, type ConfigFileMigrationReport, ExposeContextOptions, ExtendLengthUnitsOptions, ExtractOptions, ExtractResult, ILengthUnitsPatchOptions, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, type MigrateConfigFilesOptions, NormalizedTailwindCssPatchOptions, PatchCheckStatus, PatchName, PatchStatusEntry, PatchStatusReport, type RestoreConfigFilesOptions, type RestoreConfigFilesResult, TailwindCssOptions, type TailwindCssPatchOptions, TailwindPatchRuntime, TailwindTokenByFileMap, TailwindTokenFileKey, TailwindTokenLocation, TailwindTokenReport, TailwindV2Options, TailwindV3Options, type TailwindV4CandidateSource, type TailwindV4CssSource, type TailwindV4DesignSystem, type TailwindV4Engine, type TailwindV4GenerateOptions, type TailwindV4GenerateResult, TailwindV4Options, type TailwindV4ResolvedSource, type TailwindV4SourceOptions, TailwindcssClassCache, type TailwindcssPatchCliMountOptions, type TailwindcssPatchCliOptions, type TailwindcssPatchCommand, type TailwindcssPatchCommandContext, type TailwindcssPatchCommandHandler, type TailwindcssPatchCommandHandlerMap, type TailwindcssPatchCommandOptionDefinition, type TailwindcssPatchCommandOptions, TailwindcssPatcher, TailwindcssRuntimeContext, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, type ValidateFailureReason, type ValidateFailureSummary, type ValidateJsonFailurePayload, type ValidateJsonSuccessPayload, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindV4Engine, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractSourceCandidates, extractSourceCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as TailwindV4GenerateResult, A as extractSourceCandidatesWithPositions, B as ExtractOptions, C as MIGRATION_REPORT_SCHEMA_VERSION, D as extractRawCandidates, E as extractProjectCandidatesWithPositions, F as ApplyOptions, G as TailwindV2Options, H as NormalizedTailwindCssPatchOptions, I as CacheOptions, J as TailwindV4CandidateSource, K as TailwindV3Options, L as CacheStrategy, M as groupTokensByFile, N as BareArbitraryValueOptions, O as extractRawCandidatesWithPositions, P as normalizeOptions, Q as TailwindV4GenerateOptions, R as ExposeContextOptions, S as MIGRATION_REPORT_KIND, St as CacheReadResult, T as TailwindcssPatcher, U as TailwindCssOptions, V as NormalizedCacheOptions, W as TailwindCssPatchOptions, X as TailwindV4DesignSystem, Y as TailwindV4CssSource, Z as TailwindV4Engine, _ as ConfigFileMigrationEntry, _t as CacheClearScope, a as ValidateFailureSummary, at as PatchName, b as RestoreConfigFilesOptions, bt as CacheIndexFileV2, c as TailwindcssPatchCliMountOptions, ct as TailwindPatchRuntime, d as TailwindcssPatchCommandContext, dt as TailwindTokenLocation, et as TailwindV4ResolvedSource, f as TailwindcssPatchCommandHandler, ft as TailwindTokenReport, g as tailwindcssPatchCommands, gt as CacheClearResult, h as TailwindcssPatchCommandOptions, ht as CacheClearOptions, i as ValidateFailureReason, it as PatchCheckStatus, j as extractValidCandidates, k as extractSourceCandidates, l as TailwindcssPatchCliOptions, lt as TailwindTokenByFileMap, m as TailwindcssPatchCommandOptionDefinition, mt as TailwindcssRuntimeContext, n as VALIDATE_FAILURE_REASONS, nt as ExtractResult, o as ValidateJsonFailurePayload, ot as PatchStatusEntry, p as TailwindcssPatchCommandHandlerMap, pt as TailwindcssClassCache, q as TailwindV4Options, r as ValidateCommandError, rt as ILengthUnitsPatchOptions, s as ValidateJsonSuccessPayload, st as PatchStatusReport, t as VALIDATE_EXIT_CODES, tt as TailwindV4SourceOptions, u as TailwindcssPatchCommand, ut as TailwindTokenFileKey, v as ConfigFileMigrationReport, vt as CacheContextDescriptor, w as logger, x as RestoreConfigFilesResult, xt as CacheReadMeta, y as MigrateConfigFilesOptions, yt as CacheContextMetadata, z as ExtendLengthUnitsOptions } from "./validate-ZwyABmFW.js";
|
|
2
2
|
import { CAC } from "cac";
|
|
3
3
|
import { PackageInfo } from "local-pkg";
|
|
4
4
|
import postcss from "postcss";
|
|
@@ -97,4 +97,4 @@ declare function mountTailwindcssPatchCommands(cli: CAC, options?: TailwindcssPa
|
|
|
97
97
|
declare function createTailwindcssPatchCli(options?: TailwindcssPatchCliOptions): CAC;
|
|
98
98
|
declare function defineConfig<T extends TailwindcssMangleConfig>(config: T): T;
|
|
99
99
|
//#endregion
|
|
100
|
-
export { ApplyOptions, CacheClearOptions, CacheClearResult, CacheClearScope, CacheContextMetadata, CacheOptions, CacheReadMeta, CacheStore, CacheStrategy, type ConfigFileMigrationEntry, type ConfigFileMigrationReport, ExposeContextOptions, ExtendLengthUnitsOptions, ExtractOptions, ExtractResult, ILengthUnitsPatchOptions, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, type MigrateConfigFilesOptions, NormalizedTailwindCssPatchOptions, PatchCheckStatus, PatchName, PatchStatusEntry, PatchStatusReport, type RestoreConfigFilesOptions, type RestoreConfigFilesResult, TailwindCssOptions, type TailwindCssPatchOptions, TailwindPatchRuntime, TailwindTokenByFileMap, TailwindTokenFileKey, TailwindTokenLocation, TailwindTokenReport, TailwindV2Options, TailwindV3Options, type TailwindV4CandidateSource, type TailwindV4CssSource, type TailwindV4DesignSystem, type TailwindV4Engine, type TailwindV4GenerateOptions, type TailwindV4GenerateResult, TailwindV4Options, type TailwindV4ResolvedSource, type TailwindV4SourceOptions, TailwindcssClassCache, type TailwindcssPatchCliMountOptions, type TailwindcssPatchCliOptions, type TailwindcssPatchCommand, type TailwindcssPatchCommandContext, type TailwindcssPatchCommandHandler, type TailwindcssPatchCommandHandlerMap, type TailwindcssPatchCommandOptionDefinition, type TailwindcssPatchCommandOptions, TailwindcssPatcher, TailwindcssRuntimeContext, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, type ValidateFailureReason, type ValidateFailureSummary, type ValidateJsonFailurePayload, type ValidateJsonSuccessPayload, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindV4Engine, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
|
100
|
+
export { ApplyOptions, CacheClearOptions, CacheClearResult, CacheClearScope, CacheContextMetadata, CacheOptions, CacheReadMeta, CacheStore, CacheStrategy, type ConfigFileMigrationEntry, type ConfigFileMigrationReport, ExposeContextOptions, ExtendLengthUnitsOptions, ExtractOptions, ExtractResult, ILengthUnitsPatchOptions, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, type MigrateConfigFilesOptions, NormalizedTailwindCssPatchOptions, PatchCheckStatus, PatchName, PatchStatusEntry, PatchStatusReport, type RestoreConfigFilesOptions, type RestoreConfigFilesResult, TailwindCssOptions, type TailwindCssPatchOptions, TailwindPatchRuntime, TailwindTokenByFileMap, TailwindTokenFileKey, TailwindTokenLocation, TailwindTokenReport, TailwindV2Options, TailwindV3Options, type TailwindV4CandidateSource, type TailwindV4CssSource, type TailwindV4DesignSystem, type TailwindV4Engine, type TailwindV4GenerateOptions, type TailwindV4GenerateResult, TailwindV4Options, type TailwindV4ResolvedSource, type TailwindV4SourceOptions, TailwindcssClassCache, type TailwindcssPatchCliMountOptions, type TailwindcssPatchCliOptions, type TailwindcssPatchCommand, type TailwindcssPatchCommandContext, type TailwindcssPatchCommandHandler, type TailwindcssPatchCommandHandlerMap, type TailwindcssPatchCommandOptionDefinition, type TailwindcssPatchCommandOptions, TailwindcssPatcher, TailwindcssRuntimeContext, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, type ValidateFailureReason, type ValidateFailureSummary, type ValidateJsonFailurePayload, type ValidateJsonSuccessPayload, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindV4Engine, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractSourceCandidates, extractSourceCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_validate = require("./validate-
|
|
3
|
-
const require_index_bundle = require("./index.bundle-
|
|
2
|
+
const require_validate = require("./validate-5TFH6ktk.js");
|
|
3
|
+
const require_index_bundle = require("./index.bundle-Cz6ZOOFG.js");
|
|
4
4
|
exports.CacheStore = require_validate.CacheStore;
|
|
5
5
|
exports.MIGRATION_REPORT_KIND = require_validate.MIGRATION_REPORT_KIND;
|
|
6
6
|
exports.MIGRATION_REPORT_SCHEMA_VERSION = require_validate.MIGRATION_REPORT_SCHEMA_VERSION;
|
|
@@ -16,6 +16,8 @@ exports.defineConfig = require_index_bundle.defineConfig;
|
|
|
16
16
|
exports.extractProjectCandidatesWithPositions = require_validate.extractProjectCandidatesWithPositions;
|
|
17
17
|
exports.extractRawCandidates = require_validate.extractRawCandidates;
|
|
18
18
|
exports.extractRawCandidatesWithPositions = require_validate.extractRawCandidatesWithPositions;
|
|
19
|
+
exports.extractSourceCandidates = require_validate.extractSourceCandidates;
|
|
20
|
+
exports.extractSourceCandidatesWithPositions = require_validate.extractSourceCandidatesWithPositions;
|
|
19
21
|
exports.extractValidCandidates = require_validate.extractValidCandidates;
|
|
20
22
|
exports.getPatchStatusReport = require_validate.getPatchStatusReport;
|
|
21
23
|
exports.groupTokensByFile = require_validate.groupTokensByFile;
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as resolveTailwindV4SourceFromPatchOptions, i as resolveTailwindV4Source, n as defineConfig, o as createTailwindV4Engine, r as mountTailwindcssPatchCommands, t as createTailwindcssPatchCli } from "./index.bundle-
|
|
3
|
-
export { CacheStore, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, TailwindcssPatcher, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindV4Engine, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
|
1
|
+
import { M as CacheStore, N as logger, O as resolveValidTailwindV4Candidates, S as groupTokensByFile, _ as extractRawCandidates, a as tailwindcssPatchCommands, b as extractSourceCandidatesWithPositions, c as MIGRATION_REPORT_KIND, d as getPatchStatusReport, f as runTailwindBuild, g as extractProjectCandidatesWithPositions, h as collectClassesFromTailwindV4, j as normalizeOptions, l as MIGRATION_REPORT_SCHEMA_VERSION, m as collectClassesFromContexts, n as VALIDATE_FAILURE_REASONS, o as migrateConfigFiles, p as loadRuntimeContexts, r as ValidateCommandError, s as restoreConfigFiles, t as VALIDATE_EXIT_CODES, u as TailwindcssPatcher, v as extractRawCandidatesWithPositions, w as loadTailwindV4DesignSystem, x as extractValidCandidates, y as extractSourceCandidates } from "./validate-SJIkeBUb.mjs";
|
|
2
|
+
import { a as resolveTailwindV4SourceFromPatchOptions, i as resolveTailwindV4Source, n as defineConfig, o as createTailwindV4Engine, r as mountTailwindcssPatchCommands, t as createTailwindcssPatchCli } from "./index.bundle-BXhvZOy8.mjs";
|
|
3
|
+
export { CacheStore, MIGRATION_REPORT_KIND, MIGRATION_REPORT_SCHEMA_VERSION, TailwindcssPatcher, VALIDATE_EXIT_CODES, VALIDATE_FAILURE_REASONS, ValidateCommandError, collectClassesFromContexts, collectClassesFromTailwindV4, createTailwindV4Engine, createTailwindcssPatchCli, defineConfig, extractProjectCandidatesWithPositions, extractRawCandidates, extractRawCandidatesWithPositions, extractSourceCandidates, extractSourceCandidatesWithPositions, extractValidCandidates, getPatchStatusReport, groupTokensByFile, loadRuntimeContexts, loadTailwindV4DesignSystem, logger, migrateConfigFiles, mountTailwindcssPatchCommands, normalizeOptions, resolveTailwindV4Source, resolveTailwindV4SourceFromPatchOptions, resolveValidTailwindV4Candidates, restoreConfigFiles, runTailwindBuild, tailwindcssPatchCommands };
|
|
@@ -23,7 +23,7 @@ _babel_traverse = require_chunk.__toESM(_babel_traverse);
|
|
|
23
23
|
let _babel_parser = require("@babel/parser");
|
|
24
24
|
let tailwindcss_config = require("tailwindcss-config");
|
|
25
25
|
//#region package.json
|
|
26
|
-
var version = "9.3.
|
|
26
|
+
var version = "9.3.5";
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/constants.ts
|
|
29
29
|
const pkgName = "tailwindcss-patch";
|
|
@@ -2066,6 +2066,153 @@ function getOxideModule() {
|
|
|
2066
2066
|
});
|
|
2067
2067
|
return oxideImportPromise;
|
|
2068
2068
|
}
|
|
2069
|
+
const HTML_ATTRIBUTE_NAME_CANDIDATE_RE = /^(?:class|className|hover-class|hoverClass)$/;
|
|
2070
|
+
const CSS_DIRECTIVE_CANDIDATE_RE = /^@(?:apply|tailwind|source|config|plugin|theme|utility|custom-variant|variant)$/;
|
|
2071
|
+
const CSS_APPLY_IMPORTANT = "!important";
|
|
2072
|
+
const CSS_APPLY_RE = /@apply\s+([^;{}]+)/g;
|
|
2073
|
+
const JS_LIKE_SOURCE_EXTENSION_RE = /^(?:[cm]?[jt]sx?)$/;
|
|
2074
|
+
const MIXED_TEMPLATE_SOURCE_EXTENSION_RE = /^(?:vue|uvue|nvue|svelte|mpx)$/;
|
|
2075
|
+
const CSS_LIKE_SOURCE_EXTENSION_RE = /^(?:css|wxss|acss|jxss|ttss|qss|tyss|scss|sass|less|styl|stylus)$/;
|
|
2076
|
+
const SFC_SCRIPT_BLOCK_RE = /<script\b[^>]*>([\s\S]*?)<\/script>/gi;
|
|
2077
|
+
function isWhitespace(value) {
|
|
2078
|
+
return value === " " || value === "\n" || value === "\r" || value === " " || value === "\f";
|
|
2079
|
+
}
|
|
2080
|
+
function isHtmlAttributeNameCandidate(content, candidate) {
|
|
2081
|
+
if (!HTML_ATTRIBUTE_NAME_CANDIDATE_RE.test(candidate.rawCandidate)) return false;
|
|
2082
|
+
let index = candidate.end;
|
|
2083
|
+
while (isWhitespace(content[index])) index++;
|
|
2084
|
+
return content[index] === "=";
|
|
2085
|
+
}
|
|
2086
|
+
function isInsideHtmlTagText(content, candidate) {
|
|
2087
|
+
if (content.lastIndexOf("<", candidate.start) > content.lastIndexOf(">", candidate.start)) return false;
|
|
2088
|
+
const nextOpen = content.indexOf("<", candidate.end);
|
|
2089
|
+
return nextOpen !== -1 && (nextOpen < content.indexOf(">", candidate.end) || content.indexOf(">", candidate.end) === -1);
|
|
2090
|
+
}
|
|
2091
|
+
function isCssDirectiveCandidate(candidate) {
|
|
2092
|
+
return candidate === CSS_APPLY_IMPORTANT || CSS_DIRECTIVE_CANDIDATE_RE.test(candidate);
|
|
2093
|
+
}
|
|
2094
|
+
function isCandidateInCssApplyParams(content, candidate) {
|
|
2095
|
+
const apply = content.lastIndexOf("@apply", candidate.start);
|
|
2096
|
+
if (apply === -1) return false;
|
|
2097
|
+
const boundary = content.slice(apply + 6, candidate.start);
|
|
2098
|
+
return !/[;{}]/.test(boundary);
|
|
2099
|
+
}
|
|
2100
|
+
function isCandidateInsideJsStringStaticContent(content, start) {
|
|
2101
|
+
let quote;
|
|
2102
|
+
let templateExpressionDepth = 0;
|
|
2103
|
+
for (let index = 0; index < start; index++) {
|
|
2104
|
+
const char = content[index];
|
|
2105
|
+
const next = content[index + 1];
|
|
2106
|
+
if (quote && char === "\\") {
|
|
2107
|
+
index++;
|
|
2108
|
+
continue;
|
|
2109
|
+
}
|
|
2110
|
+
if (quote === "`" && templateExpressionDepth > 0) {
|
|
2111
|
+
if (char === "\"" || char === "'") {
|
|
2112
|
+
const nestedQuote = char;
|
|
2113
|
+
index++;
|
|
2114
|
+
while (index < start) {
|
|
2115
|
+
const nestedChar = content[index];
|
|
2116
|
+
if (nestedChar === "\\") {
|
|
2117
|
+
index += 2;
|
|
2118
|
+
continue;
|
|
2119
|
+
}
|
|
2120
|
+
if (nestedChar === nestedQuote) break;
|
|
2121
|
+
index++;
|
|
2122
|
+
}
|
|
2123
|
+
continue;
|
|
2124
|
+
}
|
|
2125
|
+
if (char === "`") {
|
|
2126
|
+
index++;
|
|
2127
|
+
while (index < start) {
|
|
2128
|
+
const nestedChar = content[index];
|
|
2129
|
+
if (nestedChar === "\\") {
|
|
2130
|
+
index += 2;
|
|
2131
|
+
continue;
|
|
2132
|
+
}
|
|
2133
|
+
if (nestedChar === "`") break;
|
|
2134
|
+
index++;
|
|
2135
|
+
}
|
|
2136
|
+
continue;
|
|
2137
|
+
}
|
|
2138
|
+
if (char === "{") {
|
|
2139
|
+
templateExpressionDepth++;
|
|
2140
|
+
continue;
|
|
2141
|
+
}
|
|
2142
|
+
if (char === "}") {
|
|
2143
|
+
templateExpressionDepth--;
|
|
2144
|
+
continue;
|
|
2145
|
+
}
|
|
2146
|
+
continue;
|
|
2147
|
+
}
|
|
2148
|
+
if (quote) {
|
|
2149
|
+
if (quote === "`" && char === "$" && next === "{") {
|
|
2150
|
+
templateExpressionDepth = 1;
|
|
2151
|
+
index++;
|
|
2152
|
+
continue;
|
|
2153
|
+
}
|
|
2154
|
+
if (char === quote) quote = void 0;
|
|
2155
|
+
continue;
|
|
2156
|
+
}
|
|
2157
|
+
if (char === "\"" || char === "'" || char === "`") quote = char;
|
|
2158
|
+
}
|
|
2159
|
+
return quote !== void 0 && templateExpressionDepth === 0;
|
|
2160
|
+
}
|
|
2161
|
+
function shouldKeepSourceCandidate(content, extension, candidate) {
|
|
2162
|
+
if (!candidate.rawCandidate || isCssDirectiveCandidate(candidate.rawCandidate)) return false;
|
|
2163
|
+
if (CSS_LIKE_SOURCE_EXTENSION_RE.test(extension) && !isCandidateInCssApplyParams(content, candidate)) return false;
|
|
2164
|
+
if (isHtmlAttributeNameCandidate(content, candidate)) return false;
|
|
2165
|
+
if (isInsideHtmlTagText(content, candidate)) return false;
|
|
2166
|
+
if (JS_LIKE_SOURCE_EXTENSION_RE.test(extension) && !isCandidateInsideJsStringStaticContent(content, candidate.start)) return false;
|
|
2167
|
+
return true;
|
|
2168
|
+
}
|
|
2169
|
+
function createLocalCandidate(candidate) {
|
|
2170
|
+
return {
|
|
2171
|
+
rawCandidate: candidate.rawCandidate,
|
|
2172
|
+
start: candidate.localStart,
|
|
2173
|
+
end: candidate.localStart + candidate.rawCandidate.length
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
async function extractCssApplyCandidates(content, extension) {
|
|
2177
|
+
const candidates = [];
|
|
2178
|
+
CSS_APPLY_RE.lastIndex = 0;
|
|
2179
|
+
let match = CSS_APPLY_RE.exec(content);
|
|
2180
|
+
while (match !== null) {
|
|
2181
|
+
const applyParams = match[1] ?? "";
|
|
2182
|
+
const applyParamsStart = match.index + match[0].indexOf(applyParams);
|
|
2183
|
+
const applyCandidates = await extractRawCandidatesWithPositions(applyParams, extension);
|
|
2184
|
+
candidates.push(...applyCandidates.map((candidate) => ({
|
|
2185
|
+
content: applyParams,
|
|
2186
|
+
extension: "html",
|
|
2187
|
+
localStart: candidate.start,
|
|
2188
|
+
rawCandidate: candidate.rawCandidate,
|
|
2189
|
+
start: candidate.start + applyParamsStart,
|
|
2190
|
+
end: candidate.end + applyParamsStart
|
|
2191
|
+
})));
|
|
2192
|
+
match = CSS_APPLY_RE.exec(content);
|
|
2193
|
+
}
|
|
2194
|
+
return candidates;
|
|
2195
|
+
}
|
|
2196
|
+
async function extractMixedSourceScriptCandidates(content) {
|
|
2197
|
+
const candidates = [];
|
|
2198
|
+
SFC_SCRIPT_BLOCK_RE.lastIndex = 0;
|
|
2199
|
+
let match = SFC_SCRIPT_BLOCK_RE.exec(content);
|
|
2200
|
+
while (match !== null) {
|
|
2201
|
+
const scriptContent = match[1] ?? "";
|
|
2202
|
+
const scriptStart = match.index + match[0].indexOf(scriptContent);
|
|
2203
|
+
const scriptCandidates = await extractRawCandidatesWithPositions(scriptContent, "js");
|
|
2204
|
+
candidates.push(...scriptCandidates.map((candidate) => ({
|
|
2205
|
+
content: scriptContent,
|
|
2206
|
+
extension: "js",
|
|
2207
|
+
localStart: candidate.start,
|
|
2208
|
+
rawCandidate: candidate.rawCandidate,
|
|
2209
|
+
start: candidate.start + scriptStart,
|
|
2210
|
+
end: candidate.end + scriptStart
|
|
2211
|
+
})));
|
|
2212
|
+
match = SFC_SCRIPT_BLOCK_RE.exec(content);
|
|
2213
|
+
}
|
|
2214
|
+
return candidates;
|
|
2215
|
+
}
|
|
2069
2216
|
function createCandidateCacheKey(designSystemKey, options) {
|
|
2070
2217
|
if (options.bareArbitraryValues == null || options.bareArbitraryValues === false) return designSystemKey;
|
|
2071
2218
|
return `${designSystemKey}:bare-arbitrary:${JSON.stringify(options.bareArbitraryValues)}`;
|
|
@@ -2081,6 +2228,32 @@ async function extractRawCandidatesWithPositions(content, extension = "html") {
|
|
|
2081
2228
|
end: position + candidate.length
|
|
2082
2229
|
}));
|
|
2083
2230
|
}
|
|
2231
|
+
async function extractSourceCandidatesWithPositions(content, extension = "html") {
|
|
2232
|
+
const normalizedExtension = extension.replace(/^\./, "");
|
|
2233
|
+
const candidates = CSS_LIKE_SOURCE_EXTENSION_RE.test(normalizedExtension) ? await extractCssApplyCandidates(content, normalizedExtension) : (await extractRawCandidatesWithPositions(content, normalizedExtension)).map((candidate) => ({
|
|
2234
|
+
...candidate,
|
|
2235
|
+
content,
|
|
2236
|
+
extension: normalizedExtension,
|
|
2237
|
+
localStart: candidate.start
|
|
2238
|
+
}));
|
|
2239
|
+
if (MIXED_TEMPLATE_SOURCE_EXTENSION_RE.test(normalizedExtension)) candidates.push(...await extractMixedSourceScriptCandidates(content));
|
|
2240
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2241
|
+
return candidates.filter((candidate) => {
|
|
2242
|
+
if (!shouldKeepSourceCandidate(candidate.content, candidate.extension, createLocalCandidate(candidate))) return false;
|
|
2243
|
+
const key = `${candidate.start}:${candidate.end}:${candidate.rawCandidate}`;
|
|
2244
|
+
if (seen.has(key)) return false;
|
|
2245
|
+
seen.add(key);
|
|
2246
|
+
return true;
|
|
2247
|
+
}).map(({ rawCandidate, start, end }) => ({
|
|
2248
|
+
rawCandidate,
|
|
2249
|
+
start,
|
|
2250
|
+
end
|
|
2251
|
+
}));
|
|
2252
|
+
}
|
|
2253
|
+
async function extractSourceCandidates(content, extension = "html") {
|
|
2254
|
+
const candidates = await extractSourceCandidatesWithPositions(content, extension);
|
|
2255
|
+
return [...new Set(candidates.map((candidate) => candidate.rawCandidate))];
|
|
2256
|
+
}
|
|
2084
2257
|
async function extractRawCandidates(sources) {
|
|
2085
2258
|
const { Scanner } = await getOxideModule();
|
|
2086
2259
|
return new Scanner(sources === void 0 ? {} : { sources }).scan();
|
|
@@ -4026,6 +4199,18 @@ Object.defineProperty(exports, "extractRawCandidatesWithPositions", {
|
|
|
4026
4199
|
return extractRawCandidatesWithPositions;
|
|
4027
4200
|
}
|
|
4028
4201
|
});
|
|
4202
|
+
Object.defineProperty(exports, "extractSourceCandidates", {
|
|
4203
|
+
enumerable: true,
|
|
4204
|
+
get: function() {
|
|
4205
|
+
return extractSourceCandidates;
|
|
4206
|
+
}
|
|
4207
|
+
});
|
|
4208
|
+
Object.defineProperty(exports, "extractSourceCandidatesWithPositions", {
|
|
4209
|
+
enumerable: true,
|
|
4210
|
+
get: function() {
|
|
4211
|
+
return extractSourceCandidatesWithPositions;
|
|
4212
|
+
}
|
|
4213
|
+
});
|
|
4029
4214
|
Object.defineProperty(exports, "extractTailwindV4InlineSourceCandidates", {
|
|
4030
4215
|
enumerable: true,
|
|
4031
4216
|
get: function() {
|
|
@@ -512,11 +512,14 @@ interface ExtractValidCandidatesOption {
|
|
|
512
512
|
cwd?: string;
|
|
513
513
|
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
514
514
|
}
|
|
515
|
-
|
|
515
|
+
interface ExtractSourceCandidate {
|
|
516
516
|
rawCandidate: string;
|
|
517
517
|
start: number;
|
|
518
518
|
end: number;
|
|
519
|
-
}
|
|
519
|
+
}
|
|
520
|
+
declare function extractRawCandidatesWithPositions(content: string, extension?: string): Promise<ExtractSourceCandidate[]>;
|
|
521
|
+
declare function extractSourceCandidatesWithPositions(content: string, extension?: string): Promise<ExtractSourceCandidate[]>;
|
|
522
|
+
declare function extractSourceCandidates(content: string, extension?: string): Promise<string[]>;
|
|
520
523
|
declare function extractRawCandidates(sources?: SourceEntry[]): Promise<string[]>;
|
|
521
524
|
declare function extractValidCandidates(options?: ExtractValidCandidatesOption): Promise<string[]>;
|
|
522
525
|
interface ExtractProjectCandidatesOptions {
|
|
@@ -773,4 +776,4 @@ declare class ValidateCommandError extends Error {
|
|
|
773
776
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
774
777
|
}
|
|
775
778
|
//#endregion
|
|
776
|
-
export {
|
|
779
|
+
export { TailwindV4GenerateResult as $, extractSourceCandidatesWithPositions as A, ExtractOptions as B, MIGRATION_REPORT_SCHEMA_VERSION as C, extractRawCandidates as D, extractProjectCandidatesWithPositions as E, ApplyOptions as F, TailwindV2Options as G, NormalizedTailwindCssPatchOptions as H, CacheOptions as I, TailwindV4CandidateSource as J, TailwindV3Options as K, CacheStrategy as L, groupTokensByFile as M, BareArbitraryValueOptions as N, extractRawCandidatesWithPositions as O, normalizeOptions as P, TailwindV4GenerateOptions as Q, ExposeContextOptions as R, MIGRATION_REPORT_KIND as S, CacheReadResult as St, TailwindcssPatcher as T, TailwindCssOptions as U, NormalizedCacheOptions as V, TailwindCssPatchOptions as W, TailwindV4DesignSystem as X, TailwindV4CssSource as Y, TailwindV4Engine as Z, ConfigFileMigrationEntry as _, CacheClearScope as _t, ValidateFailureSummary as a, PatchName as at, RestoreConfigFilesOptions as b, CacheIndexFileV2 as bt, TailwindcssPatchCliMountOptions as c, TailwindPatchRuntime as ct, TailwindcssPatchCommandContext as d, TailwindTokenLocation as dt, TailwindV4ResolvedSource as et, TailwindcssPatchCommandHandler as f, TailwindTokenReport as ft, tailwindcssPatchCommands as g, CacheClearResult as gt, TailwindcssPatchCommandOptions as h, CacheClearOptions as ht, ValidateFailureReason as i, PatchCheckStatus as it, extractValidCandidates as j, extractSourceCandidates as k, TailwindcssPatchCliOptions as l, TailwindTokenByFileMap as lt, TailwindcssPatchCommandOptionDefinition as m, TailwindcssRuntimeContext as mt, VALIDATE_FAILURE_REASONS as n, ExtractResult as nt, ValidateJsonFailurePayload as o, PatchStatusEntry as ot, TailwindcssPatchCommandHandlerMap as p, TailwindcssClassCache as pt, TailwindV4Options as q, ValidateCommandError as r, ILengthUnitsPatchOptions as rt, ValidateJsonSuccessPayload as s, PatchStatusReport as st, VALIDATE_EXIT_CODES as t, TailwindV4SourceOptions as tt, TailwindcssPatchCommand as u, TailwindTokenFileKey as ut, ConfigFileMigrationReport as v, CacheContextDescriptor as vt, logger as w, RestoreConfigFilesResult as x, CacheReadMeta as xt, MigrateConfigFilesOptions as y, CacheContextMetadata as yt, ExtendLengthUnitsOptions as z };
|
|
@@ -16,7 +16,7 @@ import _babelTraverse from "@babel/traverse";
|
|
|
16
16
|
import { parse, parse as parse$1 } from "@babel/parser";
|
|
17
17
|
import { loadConfig } from "tailwindcss-config";
|
|
18
18
|
//#region package.json
|
|
19
|
-
var version = "9.3.
|
|
19
|
+
var version = "9.3.5";
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/constants.ts
|
|
22
22
|
const pkgName = "tailwindcss-patch";
|
|
@@ -2064,6 +2064,153 @@ function getOxideModule() {
|
|
|
2064
2064
|
});
|
|
2065
2065
|
return oxideImportPromise;
|
|
2066
2066
|
}
|
|
2067
|
+
const HTML_ATTRIBUTE_NAME_CANDIDATE_RE = /^(?:class|className|hover-class|hoverClass)$/;
|
|
2068
|
+
const CSS_DIRECTIVE_CANDIDATE_RE = /^@(?:apply|tailwind|source|config|plugin|theme|utility|custom-variant|variant)$/;
|
|
2069
|
+
const CSS_APPLY_IMPORTANT = "!important";
|
|
2070
|
+
const CSS_APPLY_RE = /@apply\s+([^;{}]+)/g;
|
|
2071
|
+
const JS_LIKE_SOURCE_EXTENSION_RE = /^(?:[cm]?[jt]sx?)$/;
|
|
2072
|
+
const MIXED_TEMPLATE_SOURCE_EXTENSION_RE = /^(?:vue|uvue|nvue|svelte|mpx)$/;
|
|
2073
|
+
const CSS_LIKE_SOURCE_EXTENSION_RE = /^(?:css|wxss|acss|jxss|ttss|qss|tyss|scss|sass|less|styl|stylus)$/;
|
|
2074
|
+
const SFC_SCRIPT_BLOCK_RE = /<script\b[^>]*>([\s\S]*?)<\/script>/gi;
|
|
2075
|
+
function isWhitespace(value) {
|
|
2076
|
+
return value === " " || value === "\n" || value === "\r" || value === " " || value === "\f";
|
|
2077
|
+
}
|
|
2078
|
+
function isHtmlAttributeNameCandidate(content, candidate) {
|
|
2079
|
+
if (!HTML_ATTRIBUTE_NAME_CANDIDATE_RE.test(candidate.rawCandidate)) return false;
|
|
2080
|
+
let index = candidate.end;
|
|
2081
|
+
while (isWhitespace(content[index])) index++;
|
|
2082
|
+
return content[index] === "=";
|
|
2083
|
+
}
|
|
2084
|
+
function isInsideHtmlTagText(content, candidate) {
|
|
2085
|
+
if (content.lastIndexOf("<", candidate.start) > content.lastIndexOf(">", candidate.start)) return false;
|
|
2086
|
+
const nextOpen = content.indexOf("<", candidate.end);
|
|
2087
|
+
return nextOpen !== -1 && (nextOpen < content.indexOf(">", candidate.end) || content.indexOf(">", candidate.end) === -1);
|
|
2088
|
+
}
|
|
2089
|
+
function isCssDirectiveCandidate(candidate) {
|
|
2090
|
+
return candidate === CSS_APPLY_IMPORTANT || CSS_DIRECTIVE_CANDIDATE_RE.test(candidate);
|
|
2091
|
+
}
|
|
2092
|
+
function isCandidateInCssApplyParams(content, candidate) {
|
|
2093
|
+
const apply = content.lastIndexOf("@apply", candidate.start);
|
|
2094
|
+
if (apply === -1) return false;
|
|
2095
|
+
const boundary = content.slice(apply + 6, candidate.start);
|
|
2096
|
+
return !/[;{}]/.test(boundary);
|
|
2097
|
+
}
|
|
2098
|
+
function isCandidateInsideJsStringStaticContent(content, start) {
|
|
2099
|
+
let quote;
|
|
2100
|
+
let templateExpressionDepth = 0;
|
|
2101
|
+
for (let index = 0; index < start; index++) {
|
|
2102
|
+
const char = content[index];
|
|
2103
|
+
const next = content[index + 1];
|
|
2104
|
+
if (quote && char === "\\") {
|
|
2105
|
+
index++;
|
|
2106
|
+
continue;
|
|
2107
|
+
}
|
|
2108
|
+
if (quote === "`" && templateExpressionDepth > 0) {
|
|
2109
|
+
if (char === "\"" || char === "'") {
|
|
2110
|
+
const nestedQuote = char;
|
|
2111
|
+
index++;
|
|
2112
|
+
while (index < start) {
|
|
2113
|
+
const nestedChar = content[index];
|
|
2114
|
+
if (nestedChar === "\\") {
|
|
2115
|
+
index += 2;
|
|
2116
|
+
continue;
|
|
2117
|
+
}
|
|
2118
|
+
if (nestedChar === nestedQuote) break;
|
|
2119
|
+
index++;
|
|
2120
|
+
}
|
|
2121
|
+
continue;
|
|
2122
|
+
}
|
|
2123
|
+
if (char === "`") {
|
|
2124
|
+
index++;
|
|
2125
|
+
while (index < start) {
|
|
2126
|
+
const nestedChar = content[index];
|
|
2127
|
+
if (nestedChar === "\\") {
|
|
2128
|
+
index += 2;
|
|
2129
|
+
continue;
|
|
2130
|
+
}
|
|
2131
|
+
if (nestedChar === "`") break;
|
|
2132
|
+
index++;
|
|
2133
|
+
}
|
|
2134
|
+
continue;
|
|
2135
|
+
}
|
|
2136
|
+
if (char === "{") {
|
|
2137
|
+
templateExpressionDepth++;
|
|
2138
|
+
continue;
|
|
2139
|
+
}
|
|
2140
|
+
if (char === "}") {
|
|
2141
|
+
templateExpressionDepth--;
|
|
2142
|
+
continue;
|
|
2143
|
+
}
|
|
2144
|
+
continue;
|
|
2145
|
+
}
|
|
2146
|
+
if (quote) {
|
|
2147
|
+
if (quote === "`" && char === "$" && next === "{") {
|
|
2148
|
+
templateExpressionDepth = 1;
|
|
2149
|
+
index++;
|
|
2150
|
+
continue;
|
|
2151
|
+
}
|
|
2152
|
+
if (char === quote) quote = void 0;
|
|
2153
|
+
continue;
|
|
2154
|
+
}
|
|
2155
|
+
if (char === "\"" || char === "'" || char === "`") quote = char;
|
|
2156
|
+
}
|
|
2157
|
+
return quote !== void 0 && templateExpressionDepth === 0;
|
|
2158
|
+
}
|
|
2159
|
+
function shouldKeepSourceCandidate(content, extension, candidate) {
|
|
2160
|
+
if (!candidate.rawCandidate || isCssDirectiveCandidate(candidate.rawCandidate)) return false;
|
|
2161
|
+
if (CSS_LIKE_SOURCE_EXTENSION_RE.test(extension) && !isCandidateInCssApplyParams(content, candidate)) return false;
|
|
2162
|
+
if (isHtmlAttributeNameCandidate(content, candidate)) return false;
|
|
2163
|
+
if (isInsideHtmlTagText(content, candidate)) return false;
|
|
2164
|
+
if (JS_LIKE_SOURCE_EXTENSION_RE.test(extension) && !isCandidateInsideJsStringStaticContent(content, candidate.start)) return false;
|
|
2165
|
+
return true;
|
|
2166
|
+
}
|
|
2167
|
+
function createLocalCandidate(candidate) {
|
|
2168
|
+
return {
|
|
2169
|
+
rawCandidate: candidate.rawCandidate,
|
|
2170
|
+
start: candidate.localStart,
|
|
2171
|
+
end: candidate.localStart + candidate.rawCandidate.length
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
async function extractCssApplyCandidates(content, extension) {
|
|
2175
|
+
const candidates = [];
|
|
2176
|
+
CSS_APPLY_RE.lastIndex = 0;
|
|
2177
|
+
let match = CSS_APPLY_RE.exec(content);
|
|
2178
|
+
while (match !== null) {
|
|
2179
|
+
const applyParams = match[1] ?? "";
|
|
2180
|
+
const applyParamsStart = match.index + match[0].indexOf(applyParams);
|
|
2181
|
+
const applyCandidates = await extractRawCandidatesWithPositions(applyParams, extension);
|
|
2182
|
+
candidates.push(...applyCandidates.map((candidate) => ({
|
|
2183
|
+
content: applyParams,
|
|
2184
|
+
extension: "html",
|
|
2185
|
+
localStart: candidate.start,
|
|
2186
|
+
rawCandidate: candidate.rawCandidate,
|
|
2187
|
+
start: candidate.start + applyParamsStart,
|
|
2188
|
+
end: candidate.end + applyParamsStart
|
|
2189
|
+
})));
|
|
2190
|
+
match = CSS_APPLY_RE.exec(content);
|
|
2191
|
+
}
|
|
2192
|
+
return candidates;
|
|
2193
|
+
}
|
|
2194
|
+
async function extractMixedSourceScriptCandidates(content) {
|
|
2195
|
+
const candidates = [];
|
|
2196
|
+
SFC_SCRIPT_BLOCK_RE.lastIndex = 0;
|
|
2197
|
+
let match = SFC_SCRIPT_BLOCK_RE.exec(content);
|
|
2198
|
+
while (match !== null) {
|
|
2199
|
+
const scriptContent = match[1] ?? "";
|
|
2200
|
+
const scriptStart = match.index + match[0].indexOf(scriptContent);
|
|
2201
|
+
const scriptCandidates = await extractRawCandidatesWithPositions(scriptContent, "js");
|
|
2202
|
+
candidates.push(...scriptCandidates.map((candidate) => ({
|
|
2203
|
+
content: scriptContent,
|
|
2204
|
+
extension: "js",
|
|
2205
|
+
localStart: candidate.start,
|
|
2206
|
+
rawCandidate: candidate.rawCandidate,
|
|
2207
|
+
start: candidate.start + scriptStart,
|
|
2208
|
+
end: candidate.end + scriptStart
|
|
2209
|
+
})));
|
|
2210
|
+
match = SFC_SCRIPT_BLOCK_RE.exec(content);
|
|
2211
|
+
}
|
|
2212
|
+
return candidates;
|
|
2213
|
+
}
|
|
2067
2214
|
function createCandidateCacheKey(designSystemKey, options) {
|
|
2068
2215
|
if (options.bareArbitraryValues == null || options.bareArbitraryValues === false) return designSystemKey;
|
|
2069
2216
|
return `${designSystemKey}:bare-arbitrary:${JSON.stringify(options.bareArbitraryValues)}`;
|
|
@@ -2079,6 +2226,32 @@ async function extractRawCandidatesWithPositions(content, extension = "html") {
|
|
|
2079
2226
|
end: position + candidate.length
|
|
2080
2227
|
}));
|
|
2081
2228
|
}
|
|
2229
|
+
async function extractSourceCandidatesWithPositions(content, extension = "html") {
|
|
2230
|
+
const normalizedExtension = extension.replace(/^\./, "");
|
|
2231
|
+
const candidates = CSS_LIKE_SOURCE_EXTENSION_RE.test(normalizedExtension) ? await extractCssApplyCandidates(content, normalizedExtension) : (await extractRawCandidatesWithPositions(content, normalizedExtension)).map((candidate) => ({
|
|
2232
|
+
...candidate,
|
|
2233
|
+
content,
|
|
2234
|
+
extension: normalizedExtension,
|
|
2235
|
+
localStart: candidate.start
|
|
2236
|
+
}));
|
|
2237
|
+
if (MIXED_TEMPLATE_SOURCE_EXTENSION_RE.test(normalizedExtension)) candidates.push(...await extractMixedSourceScriptCandidates(content));
|
|
2238
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2239
|
+
return candidates.filter((candidate) => {
|
|
2240
|
+
if (!shouldKeepSourceCandidate(candidate.content, candidate.extension, createLocalCandidate(candidate))) return false;
|
|
2241
|
+
const key = `${candidate.start}:${candidate.end}:${candidate.rawCandidate}`;
|
|
2242
|
+
if (seen.has(key)) return false;
|
|
2243
|
+
seen.add(key);
|
|
2244
|
+
return true;
|
|
2245
|
+
}).map(({ rawCandidate, start, end }) => ({
|
|
2246
|
+
rawCandidate,
|
|
2247
|
+
start,
|
|
2248
|
+
end
|
|
2249
|
+
}));
|
|
2250
|
+
}
|
|
2251
|
+
async function extractSourceCandidates(content, extension = "html") {
|
|
2252
|
+
const candidates = await extractSourceCandidatesWithPositions(content, extension);
|
|
2253
|
+
return [...new Set(candidates.map((candidate) => candidate.rawCandidate))];
|
|
2254
|
+
}
|
|
2082
2255
|
async function extractRawCandidates(sources) {
|
|
2083
2256
|
const { Scanner } = await getOxideModule();
|
|
2084
2257
|
return new Scanner(sources === void 0 ? {} : { sources }).scan();
|
|
@@ -3934,4 +4107,4 @@ var ValidateCommandError = class extends Error {
|
|
|
3934
4107
|
}
|
|
3935
4108
|
};
|
|
3936
4109
|
//#endregion
|
|
3937
|
-
export {
|
|
4110
|
+
export { loadWorkspaceConfigModule as A, compileTailwindV4Source as C, replaceBareArbitraryValueSelectors as D, extractTailwindV4InlineSourceCandidates as E, CacheStore as M, logger as N, resolveValidTailwindV4Candidates as O, groupTokensByFile as S, canonicalizeBareArbitraryValueCandidates as T, extractRawCandidates as _, tailwindcssPatchCommands as a, extractSourceCandidatesWithPositions as b, MIGRATION_REPORT_KIND as c, getPatchStatusReport as d, runTailwindBuild as f, extractProjectCandidatesWithPositions as g, collectClassesFromTailwindV4 as h, classifyValidateError as i, normalizeOptions as j, loadPatchOptionsForWorkspace as k, MIGRATION_REPORT_SCHEMA_VERSION as l, collectClassesFromContexts as m, VALIDATE_FAILURE_REASONS as n, migrateConfigFiles as o, loadRuntimeContexts as p, ValidateCommandError as r, restoreConfigFiles as s, VALIDATE_EXIT_CODES as t, TailwindcssPatcher as u, extractRawCandidatesWithPositions as v, loadTailwindV4DesignSystem as w, extractValidCandidates as x, extractSourceCandidates as y };
|
|
@@ -513,11 +513,14 @@ interface ExtractValidCandidatesOption {
|
|
|
513
513
|
cwd?: string;
|
|
514
514
|
bareArbitraryValues?: boolean | BareArbitraryValueOptions;
|
|
515
515
|
}
|
|
516
|
-
|
|
516
|
+
interface ExtractSourceCandidate {
|
|
517
517
|
rawCandidate: string;
|
|
518
518
|
start: number;
|
|
519
519
|
end: number;
|
|
520
|
-
}
|
|
520
|
+
}
|
|
521
|
+
declare function extractRawCandidatesWithPositions(content: string, extension?: string): Promise<ExtractSourceCandidate[]>;
|
|
522
|
+
declare function extractSourceCandidatesWithPositions(content: string, extension?: string): Promise<ExtractSourceCandidate[]>;
|
|
523
|
+
declare function extractSourceCandidates(content: string, extension?: string): Promise<string[]>;
|
|
521
524
|
declare function extractRawCandidates(sources?: SourceEntry[]): Promise<string[]>;
|
|
522
525
|
declare function extractValidCandidates(options?: ExtractValidCandidatesOption): Promise<string[]>;
|
|
523
526
|
interface ExtractProjectCandidatesOptions {
|
|
@@ -774,4 +777,4 @@ declare class ValidateCommandError extends Error {
|
|
|
774
777
|
constructor(summary: ValidateFailureSummary, options?: ErrorOptions);
|
|
775
778
|
}
|
|
776
779
|
//#endregion
|
|
777
|
-
export {
|
|
780
|
+
export { TailwindV4GenerateResult as $, extractSourceCandidatesWithPositions as A, ExtractOptions as B, MIGRATION_REPORT_SCHEMA_VERSION as C, extractRawCandidates as D, extractProjectCandidatesWithPositions as E, ApplyOptions as F, TailwindV2Options as G, NormalizedTailwindCssPatchOptions as H, CacheOptions as I, TailwindV4CandidateSource as J, TailwindV3Options as K, CacheStrategy as L, groupTokensByFile as M, BareArbitraryValueOptions as N, extractRawCandidatesWithPositions as O, normalizeOptions as P, TailwindV4GenerateOptions as Q, ExposeContextOptions as R, MIGRATION_REPORT_KIND as S, CacheReadResult as St, TailwindcssPatcher as T, TailwindCssOptions as U, NormalizedCacheOptions as V, TailwindCssPatchOptions as W, TailwindV4DesignSystem as X, TailwindV4CssSource as Y, TailwindV4Engine as Z, ConfigFileMigrationEntry as _, CacheClearScope as _t, ValidateFailureSummary as a, PatchName as at, RestoreConfigFilesOptions as b, CacheIndexFileV2 as bt, TailwindcssPatchCliMountOptions as c, TailwindPatchRuntime as ct, TailwindcssPatchCommandContext as d, TailwindTokenLocation as dt, TailwindV4ResolvedSource as et, TailwindcssPatchCommandHandler as f, TailwindTokenReport as ft, tailwindcssPatchCommands as g, CacheClearResult as gt, TailwindcssPatchCommandOptions as h, CacheClearOptions as ht, ValidateFailureReason as i, PatchCheckStatus as it, extractValidCandidates as j, extractSourceCandidates as k, TailwindcssPatchCliOptions as l, TailwindTokenByFileMap as lt, TailwindcssPatchCommandOptionDefinition as m, TailwindcssRuntimeContext as mt, VALIDATE_FAILURE_REASONS as n, ExtractResult as nt, ValidateJsonFailurePayload as o, PatchStatusEntry as ot, TailwindcssPatchCommandHandlerMap as p, TailwindcssClassCache as pt, TailwindV4Options as q, ValidateCommandError as r, ILengthUnitsPatchOptions as rt, ValidateJsonSuccessPayload as s, PatchStatusReport as st, VALIDATE_EXIT_CODES as t, TailwindV4SourceOptions as tt, TailwindcssPatchCommand as u, TailwindTokenFileKey as ut, ConfigFileMigrationReport as v, CacheContextDescriptor as vt, logger as w, RestoreConfigFilesResult as x, CacheReadMeta as xt, MigrateConfigFilesOptions as y, CacheContextMetadata as yt, ExtendLengthUnitsOptions as z };
|
package/package.json
CHANGED
|
@@ -55,6 +55,212 @@ export interface ExtractValidCandidatesOption {
|
|
|
55
55
|
bareArbitraryValues?: boolean | BareArbitraryValueOptions
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
export interface ExtractSourceCandidate {
|
|
59
|
+
rawCandidate: string
|
|
60
|
+
start: number
|
|
61
|
+
end: number
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface ExtractSourceCandidateWithContext extends ExtractSourceCandidate {
|
|
65
|
+
content: string
|
|
66
|
+
extension: string
|
|
67
|
+
localStart: number
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const HTML_ATTRIBUTE_NAME_CANDIDATE_RE = /^(?:class|className|hover-class|hoverClass)$/
|
|
71
|
+
const CSS_DIRECTIVE_CANDIDATE_RE = /^@(?:apply|tailwind|source|config|plugin|theme|utility|custom-variant|variant)$/
|
|
72
|
+
const CSS_APPLY_IMPORTANT = '!important'
|
|
73
|
+
const CSS_APPLY_RE = /@apply\s+([^;{}]+)/g
|
|
74
|
+
const JS_LIKE_SOURCE_EXTENSION_RE = /^(?:[cm]?[jt]sx?)$/
|
|
75
|
+
const MIXED_TEMPLATE_SOURCE_EXTENSION_RE = /^(?:vue|uvue|nvue|svelte|mpx)$/
|
|
76
|
+
const CSS_LIKE_SOURCE_EXTENSION_RE = /^(?:css|wxss|acss|jxss|ttss|qss|tyss|scss|sass|less|styl|stylus)$/
|
|
77
|
+
const SFC_SCRIPT_BLOCK_RE = /<script\b[^>]*>([\s\S]*?)<\/script>/gi
|
|
78
|
+
|
|
79
|
+
function isWhitespace(value: string | undefined) {
|
|
80
|
+
return value === ' ' || value === '\n' || value === '\r' || value === '\t' || value === '\f'
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function isHtmlAttributeNameCandidate(content: string, candidate: ExtractSourceCandidate) {
|
|
84
|
+
if (!HTML_ATTRIBUTE_NAME_CANDIDATE_RE.test(candidate.rawCandidate)) {
|
|
85
|
+
return false
|
|
86
|
+
}
|
|
87
|
+
let index = candidate.end
|
|
88
|
+
while (isWhitespace(content[index])) {
|
|
89
|
+
index++
|
|
90
|
+
}
|
|
91
|
+
return content[index] === '='
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function isInsideHtmlTagText(content: string, candidate: ExtractSourceCandidate) {
|
|
95
|
+
const open = content.lastIndexOf('<', candidate.start)
|
|
96
|
+
const close = content.lastIndexOf('>', candidate.start)
|
|
97
|
+
if (open > close) {
|
|
98
|
+
return false
|
|
99
|
+
}
|
|
100
|
+
const nextOpen = content.indexOf('<', candidate.end)
|
|
101
|
+
return nextOpen !== -1 && (nextOpen < content.indexOf('>', candidate.end) || content.indexOf('>', candidate.end) === -1)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function isCssDirectiveCandidate(candidate: string) {
|
|
105
|
+
return candidate === CSS_APPLY_IMPORTANT || CSS_DIRECTIVE_CANDIDATE_RE.test(candidate)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function isCandidateInCssApplyParams(content: string, candidate: ExtractSourceCandidate) {
|
|
109
|
+
const apply = content.lastIndexOf('@apply', candidate.start)
|
|
110
|
+
if (apply === -1) {
|
|
111
|
+
return false
|
|
112
|
+
}
|
|
113
|
+
const boundary = content.slice(apply + '@apply'.length, candidate.start)
|
|
114
|
+
return !/[;{}]/.test(boundary)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function isCandidateInsideJsStringStaticContent(content: string, start: number) {
|
|
118
|
+
let quote: '"' | '\'' | '`' | undefined
|
|
119
|
+
let templateExpressionDepth = 0
|
|
120
|
+
for (let index = 0; index < start; index++) {
|
|
121
|
+
const char = content[index]
|
|
122
|
+
const next = content[index + 1]
|
|
123
|
+
|
|
124
|
+
if (quote && char === '\\') {
|
|
125
|
+
index++
|
|
126
|
+
continue
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (quote === '`' && templateExpressionDepth > 0) {
|
|
130
|
+
if (char === '"' || char === '\'') {
|
|
131
|
+
const nestedQuote = char
|
|
132
|
+
index++
|
|
133
|
+
while (index < start) {
|
|
134
|
+
const nestedChar = content[index]
|
|
135
|
+
if (nestedChar === '\\') {
|
|
136
|
+
index += 2
|
|
137
|
+
continue
|
|
138
|
+
}
|
|
139
|
+
if (nestedChar === nestedQuote) {
|
|
140
|
+
break
|
|
141
|
+
}
|
|
142
|
+
index++
|
|
143
|
+
}
|
|
144
|
+
continue
|
|
145
|
+
}
|
|
146
|
+
if (char === '`') {
|
|
147
|
+
index++
|
|
148
|
+
while (index < start) {
|
|
149
|
+
const nestedChar = content[index]
|
|
150
|
+
if (nestedChar === '\\') {
|
|
151
|
+
index += 2
|
|
152
|
+
continue
|
|
153
|
+
}
|
|
154
|
+
if (nestedChar === '`') {
|
|
155
|
+
break
|
|
156
|
+
}
|
|
157
|
+
index++
|
|
158
|
+
}
|
|
159
|
+
continue
|
|
160
|
+
}
|
|
161
|
+
if (char === '{') {
|
|
162
|
+
templateExpressionDepth++
|
|
163
|
+
continue
|
|
164
|
+
}
|
|
165
|
+
if (char === '}') {
|
|
166
|
+
templateExpressionDepth--
|
|
167
|
+
continue
|
|
168
|
+
}
|
|
169
|
+
continue
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (quote) {
|
|
173
|
+
if (quote === '`' && char === '$' && next === '{') {
|
|
174
|
+
templateExpressionDepth = 1
|
|
175
|
+
index++
|
|
176
|
+
continue
|
|
177
|
+
}
|
|
178
|
+
if (char === quote) {
|
|
179
|
+
quote = undefined
|
|
180
|
+
}
|
|
181
|
+
continue
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (char === '"' || char === '\'' || char === '`') {
|
|
185
|
+
quote = char
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return quote !== undefined && templateExpressionDepth === 0
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function shouldKeepSourceCandidate(content: string, extension: string, candidate: ExtractSourceCandidate) {
|
|
193
|
+
if (!candidate.rawCandidate || isCssDirectiveCandidate(candidate.rawCandidate)) {
|
|
194
|
+
return false
|
|
195
|
+
}
|
|
196
|
+
if (CSS_LIKE_SOURCE_EXTENSION_RE.test(extension) && !isCandidateInCssApplyParams(content, candidate)) {
|
|
197
|
+
return false
|
|
198
|
+
}
|
|
199
|
+
if (isHtmlAttributeNameCandidate(content, candidate)) {
|
|
200
|
+
return false
|
|
201
|
+
}
|
|
202
|
+
if (isInsideHtmlTagText(content, candidate)) {
|
|
203
|
+
return false
|
|
204
|
+
}
|
|
205
|
+
if (
|
|
206
|
+
JS_LIKE_SOURCE_EXTENSION_RE.test(extension)
|
|
207
|
+
&& !isCandidateInsideJsStringStaticContent(content, candidate.start)
|
|
208
|
+
) {
|
|
209
|
+
return false
|
|
210
|
+
}
|
|
211
|
+
return true
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function createLocalCandidate(candidate: ExtractSourceCandidateWithContext): ExtractSourceCandidate {
|
|
215
|
+
return {
|
|
216
|
+
rawCandidate: candidate.rawCandidate,
|
|
217
|
+
start: candidate.localStart,
|
|
218
|
+
end: candidate.localStart + candidate.rawCandidate.length,
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async function extractCssApplyCandidates(content: string, extension: string) {
|
|
223
|
+
const candidates: ExtractSourceCandidateWithContext[] = []
|
|
224
|
+
CSS_APPLY_RE.lastIndex = 0
|
|
225
|
+
let match = CSS_APPLY_RE.exec(content)
|
|
226
|
+
while (match !== null) {
|
|
227
|
+
const applyParams = match[1] ?? ''
|
|
228
|
+
const applyParamsStart = match.index + match[0].indexOf(applyParams)
|
|
229
|
+
const applyCandidates = await extractRawCandidatesWithPositions(applyParams, extension)
|
|
230
|
+
candidates.push(...applyCandidates.map(candidate => ({
|
|
231
|
+
content: applyParams,
|
|
232
|
+
extension: 'html',
|
|
233
|
+
localStart: candidate.start,
|
|
234
|
+
rawCandidate: candidate.rawCandidate,
|
|
235
|
+
start: candidate.start + applyParamsStart,
|
|
236
|
+
end: candidate.end + applyParamsStart,
|
|
237
|
+
})))
|
|
238
|
+
match = CSS_APPLY_RE.exec(content)
|
|
239
|
+
}
|
|
240
|
+
return candidates
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
async function extractMixedSourceScriptCandidates(content: string) {
|
|
244
|
+
const candidates: ExtractSourceCandidateWithContext[] = []
|
|
245
|
+
SFC_SCRIPT_BLOCK_RE.lastIndex = 0
|
|
246
|
+
let match = SFC_SCRIPT_BLOCK_RE.exec(content)
|
|
247
|
+
while (match !== null) {
|
|
248
|
+
const scriptContent = match[1] ?? ''
|
|
249
|
+
const scriptStart = match.index + match[0].indexOf(scriptContent)
|
|
250
|
+
const scriptCandidates = await extractRawCandidatesWithPositions(scriptContent, 'js')
|
|
251
|
+
candidates.push(...scriptCandidates.map(candidate => ({
|
|
252
|
+
content: scriptContent,
|
|
253
|
+
extension: 'js',
|
|
254
|
+
localStart: candidate.start,
|
|
255
|
+
rawCandidate: candidate.rawCandidate,
|
|
256
|
+
start: candidate.start + scriptStart,
|
|
257
|
+
end: candidate.end + scriptStart,
|
|
258
|
+
})))
|
|
259
|
+
match = SFC_SCRIPT_BLOCK_RE.exec(content)
|
|
260
|
+
}
|
|
261
|
+
return candidates
|
|
262
|
+
}
|
|
263
|
+
|
|
58
264
|
function createCandidateCacheKey(
|
|
59
265
|
designSystemKey: string,
|
|
60
266
|
options: Pick<ExtractValidCandidatesOption, 'bareArbitraryValues'>,
|
|
@@ -68,7 +274,7 @@ function createCandidateCacheKey(
|
|
|
68
274
|
export async function extractRawCandidatesWithPositions(
|
|
69
275
|
content: string,
|
|
70
276
|
extension: string = 'html',
|
|
71
|
-
): Promise<
|
|
277
|
+
): Promise<ExtractSourceCandidate[]> {
|
|
72
278
|
const { Scanner } = await getOxideModule()
|
|
73
279
|
const scanner = new Scanner({})
|
|
74
280
|
const result = scanner.getCandidatesWithPositions({ content, extension })
|
|
@@ -80,6 +286,45 @@ export async function extractRawCandidatesWithPositions(
|
|
|
80
286
|
}))
|
|
81
287
|
}
|
|
82
288
|
|
|
289
|
+
export async function extractSourceCandidatesWithPositions(
|
|
290
|
+
content: string,
|
|
291
|
+
extension: string = 'html',
|
|
292
|
+
): Promise<ExtractSourceCandidate[]> {
|
|
293
|
+
const normalizedExtension = extension.replace(/^\./, '')
|
|
294
|
+
const candidates: ExtractSourceCandidateWithContext[] = CSS_LIKE_SOURCE_EXTENSION_RE.test(normalizedExtension)
|
|
295
|
+
? await extractCssApplyCandidates(content, normalizedExtension)
|
|
296
|
+
: (await extractRawCandidatesWithPositions(content, normalizedExtension))
|
|
297
|
+
.map(candidate => ({
|
|
298
|
+
...candidate,
|
|
299
|
+
content,
|
|
300
|
+
extension: normalizedExtension,
|
|
301
|
+
localStart: candidate.start,
|
|
302
|
+
}))
|
|
303
|
+
if (MIXED_TEMPLATE_SOURCE_EXTENSION_RE.test(normalizedExtension)) {
|
|
304
|
+
candidates.push(...await extractMixedSourceScriptCandidates(content))
|
|
305
|
+
}
|
|
306
|
+
const seen = new Set<string>()
|
|
307
|
+
return candidates.filter((candidate) => {
|
|
308
|
+
if (!shouldKeepSourceCandidate(candidate.content, candidate.extension, createLocalCandidate(candidate))) {
|
|
309
|
+
return false
|
|
310
|
+
}
|
|
311
|
+
const key = `${candidate.start}:${candidate.end}:${candidate.rawCandidate}`
|
|
312
|
+
if (seen.has(key)) {
|
|
313
|
+
return false
|
|
314
|
+
}
|
|
315
|
+
seen.add(key)
|
|
316
|
+
return true
|
|
317
|
+
}).map(({ rawCandidate, start, end }) => ({ rawCandidate, start, end }))
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export async function extractSourceCandidates(
|
|
321
|
+
content: string,
|
|
322
|
+
extension: string = 'html',
|
|
323
|
+
): Promise<string[]> {
|
|
324
|
+
const candidates = await extractSourceCandidatesWithPositions(content, extension)
|
|
325
|
+
return [...new Set(candidates.map(candidate => candidate.rawCandidate))]
|
|
326
|
+
}
|
|
327
|
+
|
|
83
328
|
export async function extractRawCandidates(
|
|
84
329
|
sources?: SourceEntry[],
|
|
85
330
|
): Promise<string[]> {
|
package/src/index.bundle.ts
CHANGED
|
@@ -22,6 +22,8 @@ import {
|
|
|
22
22
|
extractProjectCandidatesWithPositions,
|
|
23
23
|
extractRawCandidates,
|
|
24
24
|
extractRawCandidatesWithPositions,
|
|
25
|
+
extractSourceCandidates,
|
|
26
|
+
extractSourceCandidatesWithPositions,
|
|
25
27
|
extractValidCandidates,
|
|
26
28
|
groupTokensByFile,
|
|
27
29
|
} from './extraction/candidate-extractor'
|
|
@@ -57,6 +59,8 @@ export {
|
|
|
57
59
|
extractProjectCandidatesWithPositions,
|
|
58
60
|
extractRawCandidates,
|
|
59
61
|
extractRawCandidatesWithPositions,
|
|
62
|
+
extractSourceCandidates,
|
|
63
|
+
extractSourceCandidatesWithPositions,
|
|
60
64
|
extractValidCandidates,
|
|
61
65
|
getPatchStatusReport,
|
|
62
66
|
groupTokensByFile,
|
package/src/index.ts
CHANGED
|
@@ -39,8 +39,11 @@ export {
|
|
|
39
39
|
extractProjectCandidatesWithPositions,
|
|
40
40
|
extractRawCandidates,
|
|
41
41
|
extractRawCandidatesWithPositions,
|
|
42
|
+
extractSourceCandidates,
|
|
43
|
+
extractSourceCandidatesWithPositions,
|
|
42
44
|
extractValidCandidates,
|
|
43
45
|
groupTokensByFile,
|
|
46
|
+
type ExtractSourceCandidate,
|
|
44
47
|
} from './extraction/candidate-extractor'
|
|
45
48
|
export {
|
|
46
49
|
collectClassesFromContexts,
|