@windicss/plugin-utils
Advanced tools
Comparing version 0.11.4 to 0.11.7
@@ -184,2 +184,6 @@ import * as windicss_types_interfaces from 'windicss/types/interfaces'; | ||
onConfigResolved?: (config: FullConfig, configFilePath?: string) => FullConfig | void | Promise<FullConfig | void>; | ||
/** | ||
* Callback when the utils is initialized | ||
*/ | ||
onInitialized?: (utils: WindiPluginUtils) => void; | ||
} | ||
@@ -245,2 +249,3 @@ interface WindiPluginUtilsOptions { | ||
onOptionsResolved: UserOptions['onOptionsResolved']; | ||
onInitialized: UserOptions['onInitialized']; | ||
} | ||
@@ -247,0 +252,0 @@ |
@@ -22,4 +22,12 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty; | ||
"windi.config.js", | ||
"windi.config.mjs", | ||
"windi.config.cjs", | ||
"windicss.config.ts", | ||
"windicss.config.js", | ||
"windicss.config.mjs", | ||
"windicss.config.cjs", | ||
"tailwind.config.ts", | ||
"tailwind.config.js" | ||
"tailwind.config.js", | ||
"tailwind.config.mjs", | ||
"tailwind.config.cjs" | ||
]; | ||
@@ -187,4 +195,4 @@ var defaultAlias = { | ||
var regexClassGroup = /([!\w+-][\w+:_/-]*?\w):\(([\w\s/-]*?)\)/gm; | ||
var regexClassCheck1 = /^[!a-z\d.+-](?:\([\w-.]*\)|[\w:/\\.$-])*$/; | ||
var regexClassCheck2 = /[\w)]$/; | ||
var regexClassCheck1 = /^[!a-z\d@<>.+-](?:\([\w-.]*\)|[\w:/\\.$-])*$/; | ||
var regexClassCheck2 = /[a-z].*[\w)]$/; | ||
var regexClassChecks = [ | ||
@@ -264,9 +272,9 @@ regexClassCheck1, | ||
${suffix}`; | ||
}, __assign(__assign({}, hookOptions), {exts: [extension]})); | ||
}, __assign(__assign({}, hookOptions), {exts: extension})); | ||
} | ||
function registerJS(hookOptions) { | ||
return addHook2(".js", {transforms: ["imports"]}, hookOptions); | ||
return addHook2([".js", ".cjs", ".mjs"], {transforms: ["imports"]}, hookOptions); | ||
} | ||
function registerTS(hookOptions) { | ||
return addHook2(".ts", {transforms: ["imports", "typescript"]}, hookOptions); | ||
return addHook2([".ts"], {transforms: ["imports", "typescript"]}, hookOptions); | ||
} | ||
@@ -362,2 +370,6 @@ function registerSucrase() { | ||
return options; | ||
const { | ||
name = "windicss-plugin-utils" | ||
} = utilsOptions; | ||
const debugOptions = _debug4.default.call(void 0, `${name}:options`); | ||
const {resolved: config, configFilePath} = loadConfigFile ? await loadConfiguration(options, utilsOptions) : {resolved: {}, configFilePath: {}}; | ||
@@ -425,2 +437,3 @@ const { | ||
resolvedOptions = Object.assign(resolvedOptions, modifiedOptions); | ||
debugOptions(resolveOptions); | ||
return resolvedOptions; | ||
@@ -437,2 +450,3 @@ } | ||
} = utilsOptions; | ||
const debugConfig = _debug4.default.call(void 0, `${name}:config`); | ||
const { | ||
@@ -442,3 +456,2 @@ config, | ||
} = options; | ||
const debug = _debug4.default.call(void 0, `${name}:config`); | ||
if (typeof config === "string" || !config) { | ||
@@ -464,3 +477,3 @@ if (!config) { | ||
try { | ||
debug("loading from ", configFilePath); | ||
debugConfig("loading from ", configFilePath); | ||
if (enableSucrase) | ||
@@ -488,3 +501,3 @@ revert = registerSucrase(); | ||
resolved = modifiedConfigs; | ||
debug(resolved); | ||
debugConfig(resolved); | ||
return { | ||
@@ -522,10 +535,2 @@ error, | ||
const tagsAvailable = new Set(); | ||
async function init() { | ||
options = await resolveOptions(userOptions, utilsOptions, true); | ||
regexId = new RegExp(`\\.(?:${options.scanOptions.fileExtensions.join("|")})$`, "i"); | ||
files = []; | ||
processor = new (0, _windicss2.default)(options.config); | ||
clearCache(); | ||
return processor; | ||
} | ||
async function ensureInit() { | ||
@@ -692,9 +697,9 @@ if (!processor) | ||
} else { | ||
include(classesPending, options.safelist); | ||
include(classesPending, classesGenerated); | ||
include(tagsPending, tagsGenerated); | ||
include(tagsPending, preflightTags); | ||
include(tagsPending, options.preflightOptions.safelist); | ||
include(tagsAvailable, htmlTags); | ||
} | ||
include(classesPending, options.safelist); | ||
include(tagsPending, options.preflightOptions.safelist); | ||
exclude(tagsAvailable, preflightTags); | ||
@@ -706,3 +711,3 @@ exclude(tagsAvailable, options.preflightOptions.safelist); | ||
} | ||
return { | ||
const utils = { | ||
init, | ||
@@ -756,2 +761,13 @@ ensureInit, | ||
}; | ||
async function init() { | ||
var _a; | ||
options = await resolveOptions(userOptions, utilsOptions, true); | ||
regexId = new RegExp(`\\.(?:${options.scanOptions.fileExtensions.join("|")})$`, "i"); | ||
files = []; | ||
processor = new (0, _windicss2.default)(options.config); | ||
clearCache(false); | ||
(_a = options.onInitialized) == null ? void 0 : _a.call(options, utils); | ||
return processor; | ||
} | ||
return utils; | ||
} | ||
@@ -758,0 +774,0 @@ |
{ | ||
"name": "@windicss/plugin-utils", | ||
"description": "Common utils for building integrations of Windi CSS", | ||
"version": "0.11.4", | ||
"version": "0.11.7", | ||
"main": "dist/index.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/index.mjs", |
Sorry, the diff of this file is not supported yet
59341
1825