feature: vor und nachteile

This commit is contained in:
Hikyu
2026-05-31 13:54:31 +02:00
parent 552a947a1c
commit e3dad17446
23270 changed files with 3024794 additions and 200 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021-PRESENT Anthony Fu <https://github.com/antfu>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+15
View File
@@ -0,0 +1,15 @@
import { UserConfig, UserConfigDefaults } from '@unocss/core';
import { LoadConfigSource, LoadConfigResult } from 'unconfig';
export { LoadConfigResult, LoadConfigSource } from 'unconfig';
declare function loadConfig<U extends UserConfig>(cwd?: string, configOrPath?: string | U, extraConfigSources?: LoadConfigSource[], defaults?: UserConfigDefaults): Promise<LoadConfigResult<U>>;
/**
* Create a factory function that returns a config loader that recovers from errors.
*
* When it fails to load the config, it will return the last successfully loaded config.
*
* Mainly used for dev-time where users might have a broken config in between changes.
*/
declare function createRecoveryConfigLoader<U extends UserConfig>(): (cwd?: string, configOrPath?: string | U, extraConfigSources?: LoadConfigSource[], defaults?: UserConfigDefaults) => Promise<LoadConfigResult<U>>;
export { createRecoveryConfigLoader, loadConfig };
+15
View File
@@ -0,0 +1,15 @@
import { UserConfig, UserConfigDefaults } from '@unocss/core';
import { LoadConfigSource, LoadConfigResult } from 'unconfig';
export { LoadConfigResult, LoadConfigSource } from 'unconfig';
declare function loadConfig<U extends UserConfig>(cwd?: string, configOrPath?: string | U, extraConfigSources?: LoadConfigSource[], defaults?: UserConfigDefaults): Promise<LoadConfigResult<U>>;
/**
* Create a factory function that returns a config loader that recovers from errors.
*
* When it fails to load the config, it will return the last successfully loaded config.
*
* Mainly used for dev-time where users might have a broken config in between changes.
*/
declare function createRecoveryConfigLoader<U extends UserConfig>(): (cwd?: string, configOrPath?: string | U, extraConfigSources?: LoadConfigSource[], defaults?: UserConfigDefaults) => Promise<LoadConfigResult<U>>;
export { createRecoveryConfigLoader, loadConfig };
+70
View File
@@ -0,0 +1,70 @@
import fs from 'node:fs';
import { resolve, dirname } from 'node:path';
import process from 'node:process';
import { createConfigLoader } from 'unconfig';
async function loadConfig(cwd = process.cwd(), configOrPath = cwd, extraConfigSources = [], defaults = {}) {
let inlineConfig = {};
if (typeof configOrPath !== "string") {
inlineConfig = configOrPath;
if (inlineConfig.configFile === false) {
return {
config: inlineConfig,
sources: []
};
} else {
configOrPath = inlineConfig.configFile || process.cwd();
}
}
const resolved = resolve(configOrPath);
let isFile = false;
if (fs.existsSync(resolved) && fs.statSync(resolved).isFile()) {
isFile = true;
cwd = dirname(resolved);
}
const loader = createConfigLoader({
sources: isFile ? [
{
files: resolved,
extensions: []
}
] : [
{
files: [
"unocss.config",
"uno.config"
]
},
...extraConfigSources
],
cwd,
defaults: inlineConfig
});
const result = await loader.load();
result.config = Object.assign(defaults, result.config || inlineConfig);
if (result.config.configDeps) {
result.sources = [
...result.sources,
...result.config.configDeps.map((i) => resolve(cwd, i))
];
}
return result;
}
function createRecoveryConfigLoader() {
let lastResolved;
return async (cwd = process.cwd(), configOrPath = cwd, extraConfigSources = [], defaults = {}) => {
try {
const config = await loadConfig(cwd, configOrPath, extraConfigSources, defaults);
lastResolved = config;
return config;
} catch (e) {
if (lastResolved) {
console.error(e);
return lastResolved;
}
throw e;
}
};
}
export { createRecoveryConfigLoader, loadConfig };
+44
View File
@@ -0,0 +1,44 @@
{
"name": "@unocss/config",
"type": "module",
"version": "0.65.4",
"description": "Config loader for UnoCSS",
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
"license": "MIT",
"funding": "https://github.com/sponsors/antfu",
"homepage": "https://github.com/unocss/unocss/tree/main/packages/config#readme",
"repository": {
"type": "git",
"url": "https://github.com/unocss/unocss",
"directory": "packages/config"
},
"bugs": {
"url": "https://github.com/unocss/unocss/issues"
},
"keywords": [],
"sideEffects": false,
"exports": {
".": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
}
},
"main": "dist/index.mjs",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"engines": {
"node": ">=14"
},
"dependencies": {
"unconfig": "~0.6.0",
"@unocss/core": "0.65.4"
},
"scripts": {
"build": "unbuild",
"stub": "unbuild --stub",
"test:attw": "attw --pack --config-path ../../.attw-esm-only.json"
}
}