weapp-tailwindcss
Version:
把 tailwindcss 原子化样式思想,带给小程序开发者们! bring tailwindcss to miniprogram developers!
72 lines (59 loc) • 2.91 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/utils/index.ts
var _shared = require('@weapp-tailwindcss/shared');
// src/utils/hbuilderx.ts
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
// src/utils/uni-platform.ts
function normalizePlatform(value) {
return _optionalChain([value, 'optionalAccess', _ => _.trim, 'call', _2 => _2(), 'access', _3 => _3.toLowerCase, 'call', _4 => _4()]) || void 0;
}
function resolveUniUtsPlatform(value = _process2.default.env.UNI_UTS_PLATFORM) {
const normalized = normalizePlatform(value);
const isAppAndroid = normalized === "app-android";
const isAppIos = normalized === "app-ios";
const isAppHarmony = normalized === "app-harmony";
const isApp = _optionalChain([normalized, 'optionalAccess', _5 => _5.startsWith, 'call', _6 => _6("app-")]) === true || normalized === "app" || normalized === "app-plus";
const isMp = _optionalChain([normalized, 'optionalAccess', _7 => _7.startsWith, 'call', _8 => _8("mp-")]) === true;
const isWeb = _optionalChain([normalized, 'optionalAccess', _9 => _9.startsWith, 'call', _10 => _10("web")]) === true || normalized === "h5";
return {
raw: value,
normalized,
isApp,
isAppAndroid,
isAppHarmony,
isAppIos,
isMp,
isWeb
};
}
// src/utils/index.ts
function classifyEntry(filename, options) {
if (options.cssMatcher(filename)) {
return "css";
}
if (options.htmlMatcher(filename)) {
return "html";
}
if (options.jsMatcher(filename) || options.wxsMatcher(filename)) {
return "js";
}
return "other";
}
function createEmptyGroups() {
return {
css: [],
html: [],
js: [],
other: []
};
}
function getGroupedEntries(entries, options) {
const groups = createEmptyGroups();
for (const entry of entries) {
const [filename] = entry;
const group = classifyEntry(filename, options);
groups[group].push(entry);
}
return groups;
}
exports.resolveUniUtsPlatform = resolveUniUtsPlatform; exports.defu = _shared.defu; exports.defuOverrideArray = _shared.defuOverrideArray; exports.isMap = _shared.isMap; exports.noop = _shared.noop; exports.getGroupedEntries = getGroupedEntries;