rolldown
Version:
Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.
1,490 lines • 152 kB
JavaScript
import { n as __toESM, t as require_binding } from "./binding-lLxFxuG-.mjs";
import { i as logInputHookInOutputPlugin, n as error } from "./logs-aMKUxRpj.mjs";
import { n as BuiltinPlugin } from "./normalize-string-or-regex-DqWsYC5b.mjs";
import { c as __decorate, d as PlainObjectLike, f as MinimalPluginContextImpl, h as LOG_LEVEL_DEBUG, i as transformModuleInfo, l as transformAssetSource, m as normalizeLog, o as transformToRollupOutput, p as normalizeHook, s as transformRenderedChunk, t as bindingifyInputOptions, u as lazyProp, v as LOG_LEVEL_WARN, x as VERSION, y as logLevelPriority } from "./bindingify-input-options-DmY7myA4.mjs";
import { i as unimplemented } from "./misc-CoQm4NHO.mjs";
import { i as unwrapBindingResult } from "./error-B8po7KiL.mjs";
import { Worker } from "node:worker_threads";
import path, { sep } from "node:path";
import { formatWithOptions, styleText } from "node:util";
import process$1 from "node:process";
import * as tty from "node:tty";
import os from "node:os";
//#region src/log/logger.ts
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
function getLogger(plugins, onLog, logLevel, watchMode) {
const minimalPriority = logLevelPriority[logLevel];
const logger = (level, log, skipped = /* @__PURE__ */ new Set()) => {
if (logLevelPriority[level] < minimalPriority) return;
for (const plugin of getSortedPlugins("onLog", plugins)) {
if (skipped.has(plugin)) continue;
const { onLog: pluginOnLog } = plugin;
if (pluginOnLog) {
const getLogHandler = (level) => {
if (logLevelPriority[level] < minimalPriority) return () => {};
return (log) => logger(level, normalizeLog(log), new Set(skipped).add(plugin));
};
if (("handler" in pluginOnLog ? pluginOnLog.handler : pluginOnLog).call({
debug: getLogHandler("debug"),
error: (log) => error(normalizeLog(log)),
info: getLogHandler("info"),
meta: {
rollupVersion: "4.23.0",
rolldownVersion: VERSION,
watchMode
},
warn: getLogHandler("warn"),
pluginName: plugin.name || "unknown"
}, level, log) === false) return;
}
}
onLog(level, log);
};
return logger;
}
const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
const { onwarn, onLog } = config;
const defaultOnLog = getDefaultOnLog(printLog, onwarn);
if (onLog) {
const minimalPriority = logLevelPriority[logLevel];
return (level, log) => onLog(level, addLogToString(log), (level, handledLog) => {
if (level === "error") return error(normalizeLog(handledLog));
if (logLevelPriority[level] >= minimalPriority) defaultOnLog(level, normalizeLog(handledLog));
});
}
return defaultOnLog;
};
const getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
if (level === "warn") onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
else printLog(level, log);
} : printLog;
const addLogToString = (log) => {
Object.defineProperty(log, "toString", {
value: () => getExtendedLogMessage(log),
writable: true
});
return log;
};
const defaultPrintLog = (level, log) => {
const message = getExtendedLogMessage(log);
switch (level) {
case LOG_LEVEL_WARN: return console.warn(message);
case LOG_LEVEL_DEBUG: return console.debug(message);
default: return console.info(message);
}
};
const getExtendedLogMessage = (log) => {
let prefix = "";
if (log.plugin) prefix += `(${log.plugin} plugin) `;
if (log.loc) prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
return prefix + log.message;
};
function relativeId(id) {
if (!path.isAbsolute(id)) return id;
return path.relative(path.resolve(), id);
}
//#endregion
//#region src/constants/plugin.ts
const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
"options",
"buildStart",
"resolveId",
"load",
"transform",
"moduleParsed",
"buildEnd",
"onLog",
"resolveDynamicImport",
"closeBundle",
"closeWatcher",
"watchChange"
];
const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES = [
"augmentChunkHash",
"outputOptions",
"renderChunk",
"renderStart",
"renderError",
"writeBundle",
"generateBundle"
];
const ENUMERATED_PLUGIN_HOOK_NAMES = [
...ENUMERATED_INPUT_PLUGIN_HOOK_NAMES,
...ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES,
"footer",
"banner",
"intro",
"outro"
];
ENUMERATED_PLUGIN_HOOK_NAMES[0], ENUMERATED_PLUGIN_HOOK_NAMES[0], ENUMERATED_PLUGIN_HOOK_NAMES[1], ENUMERATED_PLUGIN_HOOK_NAMES[1], ENUMERATED_PLUGIN_HOOK_NAMES[2], ENUMERATED_PLUGIN_HOOK_NAMES[2], ENUMERATED_PLUGIN_HOOK_NAMES[3], ENUMERATED_PLUGIN_HOOK_NAMES[3], ENUMERATED_PLUGIN_HOOK_NAMES[4], ENUMERATED_PLUGIN_HOOK_NAMES[4], ENUMERATED_PLUGIN_HOOK_NAMES[5], ENUMERATED_PLUGIN_HOOK_NAMES[5], ENUMERATED_PLUGIN_HOOK_NAMES[6], ENUMERATED_PLUGIN_HOOK_NAMES[6], ENUMERATED_PLUGIN_HOOK_NAMES[7], ENUMERATED_PLUGIN_HOOK_NAMES[7], ENUMERATED_PLUGIN_HOOK_NAMES[8], ENUMERATED_PLUGIN_HOOK_NAMES[8], ENUMERATED_PLUGIN_HOOK_NAMES[9], ENUMERATED_PLUGIN_HOOK_NAMES[9], ENUMERATED_PLUGIN_HOOK_NAMES[10], ENUMERATED_PLUGIN_HOOK_NAMES[10], ENUMERATED_PLUGIN_HOOK_NAMES[11], ENUMERATED_PLUGIN_HOOK_NAMES[11], ENUMERATED_PLUGIN_HOOK_NAMES[12], ENUMERATED_PLUGIN_HOOK_NAMES[12], ENUMERATED_PLUGIN_HOOK_NAMES[13], ENUMERATED_PLUGIN_HOOK_NAMES[13], ENUMERATED_PLUGIN_HOOK_NAMES[14], ENUMERATED_PLUGIN_HOOK_NAMES[14], ENUMERATED_PLUGIN_HOOK_NAMES[15], ENUMERATED_PLUGIN_HOOK_NAMES[15], ENUMERATED_PLUGIN_HOOK_NAMES[16], ENUMERATED_PLUGIN_HOOK_NAMES[16], ENUMERATED_PLUGIN_HOOK_NAMES[17], ENUMERATED_PLUGIN_HOOK_NAMES[17], ENUMERATED_PLUGIN_HOOK_NAMES[18], ENUMERATED_PLUGIN_HOOK_NAMES[18], ENUMERATED_PLUGIN_HOOK_NAMES[19], ENUMERATED_PLUGIN_HOOK_NAMES[19], ENUMERATED_PLUGIN_HOOK_NAMES[20], ENUMERATED_PLUGIN_HOOK_NAMES[20], ENUMERATED_PLUGIN_HOOK_NAMES[21], ENUMERATED_PLUGIN_HOOK_NAMES[21], ENUMERATED_PLUGIN_HOOK_NAMES[22], ENUMERATED_PLUGIN_HOOK_NAMES[22];
//#endregion
//#region src/utils/async-flatten.ts
async function asyncFlatten(array) {
do
array = (await Promise.all(array)).flat(Infinity);
while (array.some((v) => v?.then));
return array;
}
//#endregion
//#region src/utils/normalize-plugin-option.ts
const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
function checkOutputPluginOption(plugins, onLog) {
for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
delete plugin[hook];
onLog(LOG_LEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
}
return plugins;
}
function normalizePlugins(plugins, anonymousPrefix) {
for (const [index, plugin] of plugins.entries()) {
if ("_parallel" in plugin) continue;
if (plugin instanceof BuiltinPlugin) continue;
if (!plugin.name) plugin.name = `${anonymousPrefix}${index + 1}`;
}
return plugins;
}
const ANONYMOUS_PLUGIN_PREFIX = "at position ";
const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
//#endregion
//#region src/plugin/plugin-driver.ts
var PluginDriver = class {
static async callOptionsHook(inputOptions, watchMode = false) {
const logLevel = inputOptions.logLevel || "info";
const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel, watchMode);
for (const plugin of plugins) {
const name = plugin.name || "unknown";
const options = plugin.options;
if (options) {
const { handler } = normalizeHook(options);
const result = await handler.call(new MinimalPluginContextImpl(logger, logLevel, name, watchMode, "onLog"), inputOptions);
if (result) inputOptions = result;
}
}
return inputOptions;
}
static callOutputOptionsHook(rawPlugins, outputOptions, onLog, logLevel, watchMode) {
const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
for (const plugin of sortedPlugins) {
const name = plugin.name || "unknown";
const options = plugin.outputOptions;
if (options) {
const { handler } = normalizeHook(options);
const result = handler.call(new MinimalPluginContextImpl(onLog, logLevel, name, watchMode), outputOptions);
if (result) outputOptions = result;
}
}
return outputOptions;
}
};
function getObjectPlugins(plugins) {
return plugins.filter((plugin) => {
if (!plugin) return;
if ("_parallel" in plugin) return;
if (plugin instanceof BuiltinPlugin) return;
return plugin;
});
}
function getSortedPlugins(hookName, plugins) {
const pre = [];
const normal = [];
const post = [];
for (const plugin of plugins) {
const hook = plugin[hookName];
if (hook) {
if (typeof hook === "object") {
if (hook.order === "pre") {
pre.push(plugin);
continue;
}
if (hook.order === "post") {
post.push(plugin);
continue;
}
}
normal.push(plugin);
}
}
return [
...pre,
...normal,
...post
];
}
const DEFAULT_CONFIG = {
lang: void 0,
message: void 0,
abortEarly: void 0,
abortPipeEarly: void 0
};
/**
* Returns the global configuration.
*
* @param config The config to merge.
*
* @returns The configuration.
*/
/* @__NO_SIDE_EFFECTS__ */
function getGlobalConfig(config$1) {
if (!config$1 && true) return DEFAULT_CONFIG;
return {
lang: config$1?.lang ?? void 0,
message: config$1?.message,
abortEarly: config$1?.abortEarly ?? void 0,
abortPipeEarly: config$1?.abortPipeEarly ?? void 0
};
}
/**
* Stringifies an unknown input to a literal or type string.
*
* @param input The unknown input.
*
* @returns A literal or type string.
*
* @internal
*/
/* @__NO_SIDE_EFFECTS__ */
function _stringify(input) {
const type = typeof input;
if (type === "string") return `"${input}"`;
if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
return type;
}
/**
* Adds an issue to the dataset.
*
* @param context The issue context.
* @param label The issue label.
* @param dataset The input dataset.
* @param config The configuration.
* @param other The optional props.
*
* @internal
*/
function _addIssue(context, label, dataset, config$1, other) {
const input = other && "input" in other ? other.input : dataset.value;
const expected = other?.expected ?? context.expects ?? null;
const received = other?.received ?? /* @__PURE__ */ _stringify(input);
const issue = {
kind: context.kind,
type: context.type,
input,
expected,
received,
message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
requirement: context.requirement,
path: other?.path,
issues: other?.issues,
lang: config$1.lang,
abortEarly: config$1.abortEarly,
abortPipeEarly: config$1.abortPipeEarly
};
const isSchema = context.kind === "schema";
const message$1 = other?.message ?? context.message ?? (context.reference, issue.lang, void 0) ?? (isSchema ? (issue.lang, void 0) : null) ?? config$1.message ?? (issue.lang, void 0);
if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
if (isSchema) dataset.typed = false;
if (dataset.issues) dataset.issues.push(issue);
else dataset.issues = [issue];
}
const _standardCache = /* @__PURE__ */ new WeakMap();
/**
* Returns the Standard Schema properties.
*
* @param context The schema context.
*
* @returns The Standard Schema properties.
*/
/* @__NO_SIDE_EFFECTS__ */
function _getStandardProps(context) {
let cached = _standardCache.get(context);
if (!cached) {
cached = {
version: 1,
vendor: "valibot",
validate(value$1) {
return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig());
}
};
_standardCache.set(context, cached);
}
return cached;
}
/**
* Disallows inherited object properties and prevents object prototype
* pollution by disallowing certain keys.
*
* @param object The object to check.
* @param key The key to check.
*
* @returns Whether the key is allowed.
*
* @internal
*/
/* @__NO_SIDE_EFFECTS__ */
function _isValidObjectKey(object$1, key) {
return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
}
/**
* Joins multiple `expects` values with the given separator.
*
* @param values The `expects` values.
* @param separator The separator.
*
* @returns The joined `expects` property.
*
* @internal
*/
/* @__NO_SIDE_EFFECTS__ */
function _joinExpects(values$1, separator) {
const list = [...new Set(values$1)];
if (list.length > 1) return `(${list.join(` ${separator} `)})`;
return list[0] ?? "never";
}
/**
* A Valibot error with useful information.
*/
var ValiError = class extends Error {
/**
* Creates a Valibot error with useful information.
*
* @param issues The error issues.
*/
constructor(issues) {
super(issues[0].message);
this.name = "ValiError";
this.issues = issues;
}
};
/* @__NO_SIDE_EFFECTS__ */
function args(schema) {
return {
kind: "transformation",
type: "args",
reference: args,
async: false,
schema,
"~run"(dataset, config$1) {
const func = dataset.value;
dataset.value = (...args_) => {
const argsDataset = this.schema["~run"]({ value: args_ }, config$1);
if (argsDataset.issues) throw new ValiError(argsDataset.issues);
return func(...argsDataset.value);
};
return dataset;
}
};
}
/**
* Creates an await transformation action.
*
* @returns An await action.
*/
/* @__NO_SIDE_EFFECTS__ */
function awaitAsync() {
return {
kind: "transformation",
type: "await",
reference: awaitAsync,
async: true,
async "~run"(dataset) {
dataset.value = await dataset.value;
return dataset;
}
};
}
/**
* Creates a description metadata action.
*
* @param description_ The description text.
*
* @returns A description action.
*/
/* @__NO_SIDE_EFFECTS__ */
function description(description_) {
return {
kind: "metadata",
type: "description",
reference: description,
description: description_
};
}
/* @__NO_SIDE_EFFECTS__ */
function returns(schema) {
return {
kind: "transformation",
type: "returns",
reference: returns,
async: false,
schema,
"~run"(dataset, config$1) {
const func = dataset.value;
dataset.value = (...args_) => {
const returnsDataset = this.schema["~run"]({ value: func(...args_) }, config$1);
if (returnsDataset.issues) throw new ValiError(returnsDataset.issues);
return returnsDataset.value;
};
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function returnsAsync(schema) {
return {
kind: "transformation",
type: "returns",
reference: returnsAsync,
async: false,
schema,
"~run"(dataset, config$1) {
const func = dataset.value;
dataset.value = async (...args_) => {
const returnsDataset = await this.schema["~run"]({ value: await func(...args_) }, config$1);
if (returnsDataset.issues) throw new ValiError(returnsDataset.issues);
return returnsDataset.value;
};
return dataset;
}
};
}
const ABORT_EARLY_CONFIG = { abortEarly: true };
/**
* Returns the fallback value of the schema.
*
* @param schema The schema to get it from.
* @param dataset The output dataset if available.
* @param config The config if available.
*
* @returns The fallback value.
*/
/* @__NO_SIDE_EFFECTS__ */
function getFallback(schema, dataset, config$1) {
return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
}
/**
* Returns the default value of the schema.
*
* @param schema The schema to get it from.
* @param dataset The input dataset if available.
* @param config The config if available.
*
* @returns The default value.
*/
/* @__NO_SIDE_EFFECTS__ */
function getDefault(schema, dataset, config$1) {
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
}
/**
* Checks if the input matches the schema. By using a type predicate, this
* function can be used as a type guard.
*
* @param schema The schema to be used.
* @param input The input to be tested.
*
* @returns Whether the input matches the schema.
*/
/* @__NO_SIDE_EFFECTS__ */
function is(schema, input) {
return !schema["~run"]({ value: input }, ABORT_EARLY_CONFIG).issues;
}
/**
* Creates an any schema.
*
* Hint: This schema function exists only for completeness and is not
* recommended in practice. Instead, `unknown` should be used to accept
* unknown data.
*
* @returns An any schema.
*/
/* @__NO_SIDE_EFFECTS__ */
function any() {
return {
kind: "schema",
type: "any",
reference: any,
expects: "any",
async: false,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset) {
dataset.typed = true;
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function array(item, message$1) {
return {
kind: "schema",
type: "array",
reference: array,
expects: "Array",
async: false,
item,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
const input = dataset.value;
if (Array.isArray(input)) {
dataset.typed = true;
dataset.value = [];
for (let key = 0; key < input.length; key++) {
const value$1 = input[key];
const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
if (itemDataset.issues) {
const pathItem = {
type: "array",
origin: "value",
input,
key,
value: value$1
};
for (const issue of itemDataset.issues) {
if (issue.path) issue.path.unshift(pathItem);
else issue.path = [pathItem];
dataset.issues?.push(issue);
}
if (!dataset.issues) dataset.issues = itemDataset.issues;
if (config$1.abortEarly) {
dataset.typed = false;
break;
}
}
if (!itemDataset.typed) dataset.typed = false;
dataset.value.push(itemDataset.value);
}
} else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function boolean(message$1) {
return {
kind: "schema",
type: "boolean",
reference: boolean,
expects: "boolean",
async: false,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
if (typeof dataset.value === "boolean") dataset.typed = true;
else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function custom(check$1, message$1) {
return {
kind: "schema",
type: "custom",
reference: custom,
expects: "unknown",
async: false,
check: check$1,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
if (this.check(dataset.value)) dataset.typed = true;
else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function function_(message$1) {
return {
kind: "schema",
type: "function",
reference: function_,
expects: "Function",
async: false,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
if (typeof dataset.value === "function") dataset.typed = true;
else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function instance(class_, message$1) {
return {
kind: "schema",
type: "instance",
reference: instance,
expects: class_.name,
async: false,
class: class_,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
if (dataset.value instanceof this.class) dataset.typed = true;
else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function literal(literal_, message$1) {
return {
kind: "schema",
type: "literal",
reference: literal,
expects: /* @__PURE__ */ _stringify(literal_),
async: false,
literal: literal_,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
if (dataset.value === this.literal) dataset.typed = true;
else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function never(message$1) {
return {
kind: "schema",
type: "never",
reference: never,
expects: "never",
async: false,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
_addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function nullish(wrapped, default_) {
return {
kind: "schema",
type: "nullish",
reference: nullish,
expects: `(${wrapped.expects} | null | undefined)`,
async: false,
wrapped,
default: default_,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
if (dataset.value === null || dataset.value === void 0) {
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
if (dataset.value === null || dataset.value === void 0) {
dataset.typed = true;
return dataset;
}
}
return this.wrapped["~run"](dataset, config$1);
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function number(message$1) {
return {
kind: "schema",
type: "number",
reference: number,
expects: "number",
async: false,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function object(entries$1, message$1) {
return {
kind: "schema",
type: "object",
reference: object,
expects: "Object",
async: false,
entries: entries$1,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
const input = dataset.value;
if (input && typeof input === "object") {
dataset.typed = true;
dataset.value = {};
for (const key in this.entries) {
const valueSchema = this.entries[key];
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
if (valueDataset.issues) {
const pathItem = {
type: "object",
origin: "value",
input,
key,
value: value$1
};
for (const issue of valueDataset.issues) {
if (issue.path) issue.path.unshift(pathItem);
else issue.path = [pathItem];
dataset.issues?.push(issue);
}
if (!dataset.issues) dataset.issues = valueDataset.issues;
if (config$1.abortEarly) {
dataset.typed = false;
break;
}
}
if (!valueDataset.typed) dataset.typed = false;
dataset.value[key] = valueDataset.value;
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
_addIssue(this, "key", dataset, config$1, {
input: void 0,
expected: `"${key}"`,
path: [{
type: "object",
origin: "key",
input,
key,
value: input[key]
}]
});
if (config$1.abortEarly) break;
}
}
} else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function optional(wrapped, default_) {
return {
kind: "schema",
type: "optional",
reference: optional,
expects: `(${wrapped.expects} | undefined)`,
async: false,
wrapped,
default: default_,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
if (dataset.value === void 0) {
if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
if (dataset.value === void 0) {
dataset.typed = true;
return dataset;
}
}
return this.wrapped["~run"](dataset, config$1);
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function picklist(options, message$1) {
return {
kind: "schema",
type: "picklist",
reference: picklist,
expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
async: false,
options,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
if (this.options.includes(dataset.value)) dataset.typed = true;
else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function promise(message$1) {
return {
kind: "schema",
type: "promise",
reference: promise,
expects: "Promise",
async: false,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
if (dataset.value instanceof Promise) dataset.typed = true;
else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function record(key, value$1, message$1) {
return {
kind: "schema",
type: "record",
reference: record,
expects: "Object",
async: false,
key,
value: value$1,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
const input = dataset.value;
if (input && typeof input === "object") {
dataset.typed = true;
dataset.value = {};
for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
const entryValue = input[entryKey];
const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
if (keyDataset.issues) {
const pathItem = {
type: "object",
origin: "key",
input,
key: entryKey,
value: entryValue
};
for (const issue of keyDataset.issues) {
issue.path = [pathItem];
dataset.issues?.push(issue);
}
if (!dataset.issues) dataset.issues = keyDataset.issues;
if (config$1.abortEarly) {
dataset.typed = false;
break;
}
}
const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
if (valueDataset.issues) {
const pathItem = {
type: "object",
origin: "value",
input,
key: entryKey,
value: entryValue
};
for (const issue of valueDataset.issues) {
if (issue.path) issue.path.unshift(pathItem);
else issue.path = [pathItem];
dataset.issues?.push(issue);
}
if (!dataset.issues) dataset.issues = valueDataset.issues;
if (config$1.abortEarly) {
dataset.typed = false;
break;
}
}
if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
}
} else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function strictObject(entries$1, message$1) {
return {
kind: "schema",
type: "strict_object",
reference: strictObject,
expects: "Object",
async: false,
entries: entries$1,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
const input = dataset.value;
if (input && typeof input === "object") {
dataset.typed = true;
dataset.value = {};
for (const key in this.entries) {
const valueSchema = this.entries[key];
if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
if (valueDataset.issues) {
const pathItem = {
type: "object",
origin: "value",
input,
key,
value: value$1
};
for (const issue of valueDataset.issues) {
if (issue.path) issue.path.unshift(pathItem);
else issue.path = [pathItem];
dataset.issues?.push(issue);
}
if (!dataset.issues) dataset.issues = valueDataset.issues;
if (config$1.abortEarly) {
dataset.typed = false;
break;
}
}
if (!valueDataset.typed) dataset.typed = false;
dataset.value[key] = valueDataset.value;
} else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
_addIssue(this, "key", dataset, config$1, {
input: void 0,
expected: `"${key}"`,
path: [{
type: "object",
origin: "key",
input,
key,
value: input[key]
}]
});
if (config$1.abortEarly) break;
}
}
if (!dataset.issues || !config$1.abortEarly) {
for (const key in input) if (!(key in this.entries)) {
_addIssue(this, "key", dataset, config$1, {
input: key,
expected: "never",
path: [{
type: "object",
origin: "key",
input,
key,
value: input[key]
}]
});
break;
}
}
} else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function string(message$1) {
return {
kind: "schema",
type: "string",
reference: string,
expects: "string",
async: false,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
if (typeof dataset.value === "string") dataset.typed = true;
else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function tuple(items, message$1) {
return {
kind: "schema",
type: "tuple",
reference: tuple,
expects: "Array",
async: false,
items,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
const input = dataset.value;
if (Array.isArray(input)) {
dataset.typed = true;
dataset.value = [];
for (let key = 0; key < this.items.length; key++) {
const value$1 = input[key];
const itemDataset = this.items[key]["~run"]({ value: value$1 }, config$1);
if (itemDataset.issues) {
const pathItem = {
type: "array",
origin: "value",
input,
key,
value: value$1
};
for (const issue of itemDataset.issues) {
if (issue.path) issue.path.unshift(pathItem);
else issue.path = [pathItem];
dataset.issues?.push(issue);
}
if (!dataset.issues) dataset.issues = itemDataset.issues;
if (config$1.abortEarly) {
dataset.typed = false;
break;
}
}
if (!itemDataset.typed) dataset.typed = false;
dataset.value.push(itemDataset.value);
}
} else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function undefined_(message$1) {
return {
kind: "schema",
type: "undefined",
reference: undefined_,
expects: "undefined",
async: false,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
if (dataset.value === void 0) dataset.typed = true;
else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/**
* Returns the sub issues of the provided datasets for the union issue.
*
* @param datasets The datasets.
*
* @returns The sub issues.
*
* @internal
*/
/* @__NO_SIDE_EFFECTS__ */
function _subIssues(datasets) {
let issues;
if (datasets) for (const dataset of datasets) if (issues) for (const issue of dataset.issues) issues.push(issue);
else issues = dataset.issues;
return issues;
}
/* @__NO_SIDE_EFFECTS__ */
function union(options, message$1) {
return {
kind: "schema",
type: "union",
reference: union,
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
async: false,
options,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
let validDataset;
let typedDatasets;
let untypedDatasets;
for (const schema of this.options) {
const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
else typedDatasets = [optionDataset];
else {
validDataset = optionDataset;
break;
}
else if (untypedDatasets) untypedDatasets.push(optionDataset);
else untypedDatasets = [optionDataset];
}
if (validDataset) return validDataset;
if (typedDatasets) {
if (typedDatasets.length === 1) return typedDatasets[0];
_addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
dataset.typed = true;
} else if (untypedDatasets?.length === 1) return untypedDatasets[0];
else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function unionAsync(options, message$1) {
return {
kind: "schema",
type: "union",
reference: unionAsync,
expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
async: true,
options,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
async "~run"(dataset, config$1) {
let validDataset;
let typedDatasets;
let untypedDatasets;
for (const schema of this.options) {
const optionDataset = await schema["~run"]({ value: dataset.value }, config$1);
if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
else typedDatasets = [optionDataset];
else {
validDataset = optionDataset;
break;
}
else if (untypedDatasets) untypedDatasets.push(optionDataset);
else untypedDatasets = [optionDataset];
}
if (validDataset) return validDataset;
if (typedDatasets) {
if (typedDatasets.length === 1) return typedDatasets[0];
_addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
dataset.typed = true;
} else if (untypedDatasets?.length === 1) return untypedDatasets[0];
else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function void_(message$1) {
return {
kind: "schema",
type: "void",
reference: void_,
expects: "void",
async: false,
message: message$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
if (dataset.value === void 0) dataset.typed = true;
else _addIssue(this, "type", dataset, config$1);
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function keyof(schema, message$1) {
return /* @__PURE__ */ picklist(Object.keys(schema.entries), message$1);
}
/**
* Creates a modified copy of an object schema that does not contain the
* selected entries.
*
* @param schema The schema to omit from.
* @param keys The selected entries.
*
* @returns An object schema.
*/
/* @__NO_SIDE_EFFECTS__ */
function omit(schema, keys) {
const entries$1 = { ...schema.entries };
for (const key of keys) delete entries$1[key];
return {
...schema,
entries: entries$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function partial(schema, keys) {
const entries$1 = {};
for (const key in schema.entries) entries$1[key] = !keys || keys.includes(key) ? /* @__PURE__ */ optional(schema.entries[key]) : schema.entries[key];
return {
...schema,
entries: entries$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function pipe(...pipe$1) {
return {
...pipe$1[0],
pipe: pipe$1,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
"~run"(dataset, config$1) {
for (const item of pipe$1) if (item.kind !== "metadata") {
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
dataset.typed = false;
break;
}
if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
}
return dataset;
}
};
}
/* @__NO_SIDE_EFFECTS__ */
function pipeAsync(...pipe$1) {
return {
...pipe$1[0],
pipe: pipe$1,
async: true,
get "~standard"() {
return /* @__PURE__ */ _getStandardProps(this);
},
async "~run"(dataset, config$1) {
for (const item of pipe$1) if (item.kind !== "metadata") {
if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
dataset.typed = false;
break;
}
if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = await item["~run"](dataset, config$1);
}
return dataset;
}
};
}
/**
* Parses an unknown input based on a schema.
*
* @param schema The schema to be used.
* @param input The input to be parsed.
* @param config The parse configuration.
*
* @returns The parse result.
*/
/* @__NO_SIDE_EFFECTS__ */
function safeParse(schema, input, config$1) {
const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
return {
typed: dataset.typed,
success: !dataset.issues,
output: dataset.value,
issues: dataset.issues
};
}
//#endregion
//#region src/utils/flatten-valibot-schema.ts
function unwrapSchema(schema) {
if (!schema) return schema;
if (schema.type === "optional" && schema.wrapped) return unwrapSchema(schema.wrapped);
if (schema.type === "nullable" && schema.wrapped) return unwrapSchema(schema.wrapped);
if (schema.type === "nullish" && schema.wrapped) return unwrapSchema(schema.wrapped);
return schema;
}
function getValibotSchemaType(schema) {
if (!schema) return "any";
if (schema.type) switch (schema.type) {
case "string": return "string";
case "number": return "number";
case "boolean": return "boolean";
case "array": return "array";
case "object":
case "strict_object":
case "loose_object": return "object";
case "union": return "union";
case "literal": return typeof schema.literal;
case "record": return "object";
case "optional": return getValibotSchemaType(schema.wrapped);
case "nullable": return getValibotSchemaType(schema.wrapped);
case "nullish": return getValibotSchemaType(schema.wrapped);
case "never": return "never";
case "any": return "any";
case "custom": return "any";
case "function": return "never";
case "instance": return "object";
default: return "any";
}
return "any";
}
function getValibotDescription(schema) {
if (!schema) return void 0;
if (schema.pipe && Array.isArray(schema.pipe)) {
for (const action of schema.pipe) if (action.type === "description" && action.description) return action.description;
}
if (schema.type === "optional" && schema.wrapped) return getValibotDescription(schema.wrapped);
}
function flattenValibotSchema(schema, result = {}, prefix = "") {
if (!schema || typeof schema !== "object") return result;
if (schema.type === "strict_object" || schema.type === "object" || schema.type === "loose_object") {
if (schema.entries && typeof schema.entries === "object") for (const [key, value] of Object.entries(schema.entries)) {
const fullKey = prefix ? `${prefix}.${key}` : key;
const valueSchema = value;
const type = getValibotSchemaType(valueSchema);
const description = getValibotDescription(valueSchema);
if (type === "object") {
const unwrappedSchema = unwrapSchema(valueSchema);
if (unwrappedSchema && unwrappedSchema.entries) flattenValibotSchema(unwrappedSchema, result, fullKey);
else result[fullKey] = {
type,
description
};
} else result[fullKey] = {
type,
description
};
}
}
return result;
}
//#endregion
//#region src/utils/style-text.ts
/**
* Cross-platform styleText utility that works in both Node.js and browser environments
* In Node.js, it uses the native `styleText` from `node:util`
* In browser, it provides empty styling functions for compatibility
*/
function styleText$1(...args) {
return styleText(...args);
}
//#endregion
//#region src/utils/validator.ts
const StringOrRegExpSchema = /* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ instance(RegExp)]);
function vFunction() {
return /* @__PURE__ */ function_();
}
const LogLevelSchema = /* @__PURE__ */ union([
/* @__PURE__ */ literal("debug"),
/* @__PURE__ */ literal("info"),
/* @__PURE__ */ literal("warn")
]);
const LogLevelOptionSchema = /* @__PURE__ */ union([LogLevelSchema, /* @__PURE__ */ literal("silent")]);
const LogLevelWithErrorSchema = /* @__PURE__ */ union([LogLevelSchema, /* @__PURE__ */ literal("error")]);
const RollupLogSchema = /* @__PURE__ */ any();
const RollupLogWithStringSchema = /* @__PURE__ */ union([RollupLogSchema, /* @__PURE__ */ string()]);
const InputOptionSchema = /* @__PURE__ */ union([
/* @__PURE__ */ string(),
/* @__PURE__ */ array(/* @__PURE__ */ string()),
/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ string())
]);
const ExternalOptionFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([
/* @__PURE__ */ string(),
/* @__PURE__ */ optional(/* @__PURE__ */ string()),
/* @__PURE__ */ boolean()
])), /* @__PURE__ */ returns(/* @__PURE__ */ nullish(/* @__PURE__ */ boolean())));
const ExternalOptionSchema = /* @__PURE__ */ union([
StringOrRegExpSchema,
/* @__PURE__ */ array(StringOrRegExpSchema),
ExternalOptionFunctionSchema
]);
const ModuleTypesSchema = /* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ union([
/* @__PURE__ */ literal("asset"),
/* @__PURE__ */ literal("base64"),
/* @__PURE__ */ literal("binary"),
/* @__PURE__ */ literal("copy"),
/* @__PURE__ */ literal("css"),
/* @__PURE__ */ literal("dataurl"),
/* @__PURE__ */ literal("empty"),
/* @__PURE__ */ literal("js"),
/* @__PURE__ */ literal("json"),
/* @__PURE__ */ literal("jsx"),
/* @__PURE__ */ literal("text"),
/* @__PURE__ */ literal("ts"),
/* @__PURE__ */ literal("tsx")
]));
const TransformOptionsSchema = /* @__PURE__ */ object({
assumptions: /* @__PURE__ */ optional(/* @__PURE__ */ object({
ignoreFunctionLength: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
noDocumentAll: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
objectRestNoSymbols: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
pureGetters: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
setPublicClassFields: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
})),
typescript: /* @__PURE__ */ optional(/* @__PURE__ */ object({
jsxPragma: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
jsxPragmaFrag: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
onlyRemoveTypeImports: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
allowNamespaces: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
allowDeclareFields: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
removeClassFieldsWithoutInitializer: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
optimizeConstEnums: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
optimizeEnums: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
declaration: /* @__PURE__ */ optional(/* @__PURE__ */ object({
stripInternal: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
sourcemap: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
})),
rewriteImportExtensions: /* @__PURE__ */ optional(/* @__PURE__ */ union([
/* @__PURE__ */ literal("rewrite"),
/* @__PURE__ */ literal("remove"),
/* @__PURE__ */ boolean()
]))
})),
helpers: /* @__PURE__ */ optional(/* @__PURE__ */ object({ mode: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("Runtime"), /* @__PURE__ */ literal("External")])) })),
decorator: /* @__PURE__ */ optional(/* @__PURE__ */ object({
legacy: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
emitDecoratorMetadata: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
})),
jsx: /* @__PURE__ */ optional(/* @__PURE__ */ union([
/* @__PURE__ */ literal(false),
/* @__PURE__ */ literal("preserve"),
/* @__PURE__ */ literal("react"),
/* @__PURE__ */ literal("react-jsx"),
/* @__PURE__ */ strictObject({
runtime: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("classic"), /* @__PURE__ */ literal("automatic")])), /* @__PURE__ */ description("Which runtime to use")),
development: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Development specific information")),
throwIfNamespace: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Toggles whether to throw an error when a tag name uses an XML namespace")),
pure: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Mark JSX elements and top-level React method calls as pure for tree shaking.")),
importSource: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Import the factory of element and fragment if mode is classic")),
pragma: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Jsx element transformation")),
pragmaFrag: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Jsx fragment transformation")),
refresh: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ any()])), /* @__PURE__ */ description("Enable react fast refresh"))
})
])),
target: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ array(/* @__PURE__ */ string())])), /* @__PURE__ */ description("The JavaScript target environment")),
define: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ string())), /* @__PURE__ */ description("Define global variables (syntax: key:value,key2:value2)")),
inject: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ tuple([/* @__PURE__ */ string(), /* @__PURE__ */ string()])]))), /* @__PURE__ */ description("Inject import statements on demand")),
dropLabels: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())), /* @__PURE__ */ description("Remove labeled statements with these label names")),
plugins: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ object({
styledComponents: /* @__PURE__ */ optional(/* @__PURE__ */ any()),
taggedTemplateEscape: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
})), /* @__PURE__ */ description("Third-party plugins to use"))
});
const WatcherFileWatcherOptionsSchema = /* @__PURE__ */ strictObject({
usePolling: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Use polling-based file watching instead of native OS events")),
pollInterval: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Poll interval in milliseconds (only used when usePolling is true)")),
compareContentsForPolling: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Compare file contents for poll-based watchers (only used when usePolling is true)")),
useDebounce: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Use debounced event delivery at the filesystem level")),
debounceDelay: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Debounce delay in milliseconds (only used when useDebounce is true)")),
debounceTickRate: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Tick rate in milliseconds for debouncer (only used when useDebounce is true)"))
});
const WatcherOptionsSchema = /* @__PURE__ */ strictObject({
chokidar: /* @__PURE__ */ optional(/* @__PURE__ */ never(`The "watch.chokidar" option is deprecated, please use "watch.watcher" instead of it`)),
exclude: /* @__PURE__ */ optional(/* @__PURE__ */ union([StringOrRegExpSchema, /* @__PURE__ */ array(StringOrRegExpSchema)])),
include: /* @__PURE__ */ optional(/* @__PURE__ */ union([StringOrRegExpSchema, /* @__PURE__ */ array(StringOrRegExpSchema)])),
watcher: /* @__PURE__ */ optional(WatcherFileWatcherOptionsSchema),
notify: /* @__PURE__ */ optional(WatcherFileWatcherOptionsSchema),
skipWrite: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Skip the bundle.write() step")),
buildDelay: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Throttle watch rebuilds")),
clearScreen: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()),