From 6656ceb9658511a0860e7b395f8bf9fd0999e9a7 Mon Sep 17 00:00:00 2001 From: Active <56242467+doubleactii@users.noreply.github.com> Date: Wed, 1 Jan 2025 01:49:08 -0600 Subject: [PATCH] fix: stop tracking lib --- .gitignore | 1 + lib/bundle/cli/cli.js | 2680 ------------------------------- lib/event-system.d.ts | 13 - lib/event-system.d.ts.map | 1 - lib/event-system.js | 26 - lib/index.d.ts | 2 - lib/index.d.ts.map | 1 - lib/index.js | 1 - lib/kit.d.ts | 65 - lib/kit.d.ts.map | 1 - lib/kit.js | 152 -- lib/types/shared-types.d.ts | 25 - lib/types/shared-types.d.ts.map | 1 - lib/types/shared-types.js | 1 - package.json | 5 +- 15 files changed, 5 insertions(+), 2970 deletions(-) delete mode 100755 lib/bundle/cli/cli.js delete mode 100644 lib/event-system.d.ts delete mode 100644 lib/event-system.d.ts.map delete mode 100644 lib/event-system.js delete mode 100644 lib/index.d.ts delete mode 100644 lib/index.d.ts.map delete mode 100644 lib/index.js delete mode 100644 lib/kit.d.ts delete mode 100644 lib/kit.d.ts.map delete mode 100644 lib/kit.js delete mode 100644 lib/types/shared-types.d.ts delete mode 100644 lib/types/shared-types.d.ts.map delete mode 100644 lib/types/shared-types.js diff --git a/.gitignore b/.gitignore index b79f931..9964ecf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ dist/ +lib/ tests/temp/ # Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore diff --git a/lib/bundle/cli/cli.js b/lib/bundle/cli/cli.js deleted file mode 100755 index d7cdca6..0000000 --- a/lib/bundle/cli/cli.js +++ /dev/null @@ -1,2680 +0,0 @@ -#!/usr/bin/env node - -/*! - * @evitcastudio/kit@1.1.2 git+https://github.com/EvitcaStudio/Kit.git - * Compiled Wed, 01 Jan 2025 07:32:50 UTC - * Copyright (c) 2025 Jared Bates, Evitca Studio, "doubleactii" - * - * @evitcastudio/kit is licensed under the MIT License. - * http://www.opensource.org/licenses/mit-license - */ -import { createRequire } from "node:module"; -var __create = Object.create; -var __getProtoOf = Object.getPrototypeOf; -var __defProp = Object.defineProperty; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __toESM = (mod, isNodeMode, target) => { - target = mod != null ? __create(__getProtoOf(mod)) : {}; - const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target; - for (let key of __getOwnPropNames(mod)) - if (!__hasOwnProp.call(to, key)) - __defProp(to, key, { - get: () => mod[key], - enumerable: true - }); - return to; -}; -var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports); -var __require = /* @__PURE__ */ createRequire(import.meta.url); - -// node_modules/commander/lib/error.js -var require_error = __commonJS((exports) => { - class CommanderError extends Error { - constructor(exitCode, code, message) { - super(message); - Error.captureStackTrace(this, this.constructor); - this.name = this.constructor.name; - this.code = code; - this.exitCode = exitCode; - this.nestedError = undefined; - } - } - - class InvalidArgumentError extends CommanderError { - constructor(message) { - super(1, "commander.invalidArgument", message); - Error.captureStackTrace(this, this.constructor); - this.name = this.constructor.name; - } - } - exports.CommanderError = CommanderError; - exports.InvalidArgumentError = InvalidArgumentError; -}); - -// node_modules/commander/lib/argument.js -var require_argument = __commonJS((exports) => { - var { InvalidArgumentError } = require_error(); - - class Argument { - constructor(name, description) { - this.description = description || ""; - this.variadic = false; - this.parseArg = undefined; - this.defaultValue = undefined; - this.defaultValueDescription = undefined; - this.argChoices = undefined; - switch (name[0]) { - case "<": - this.required = true; - this._name = name.slice(1, -1); - break; - case "[": - this.required = false; - this._name = name.slice(1, -1); - break; - default: - this.required = true; - this._name = name; - break; - } - if (this._name.length > 3 && this._name.slice(-3) === "...") { - this.variadic = true; - this._name = this._name.slice(0, -3); - } - } - name() { - return this._name; - } - _concatValue(value, previous) { - if (previous === this.defaultValue || !Array.isArray(previous)) { - return [value]; - } - return previous.concat(value); - } - default(value, description) { - this.defaultValue = value; - this.defaultValueDescription = description; - return this; - } - argParser(fn) { - this.parseArg = fn; - return this; - } - choices(values) { - this.argChoices = values.slice(); - this.parseArg = (arg, previous) => { - if (!this.argChoices.includes(arg)) { - throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`); - } - if (this.variadic) { - return this._concatValue(arg, previous); - } - return arg; - }; - return this; - } - argRequired() { - this.required = true; - return this; - } - argOptional() { - this.required = false; - return this; - } - } - function humanReadableArgName(arg) { - const nameOutput = arg.name() + (arg.variadic === true ? "..." : ""); - return arg.required ? "<" + nameOutput + ">" : "[" + nameOutput + "]"; - } - exports.Argument = Argument; - exports.humanReadableArgName = humanReadableArgName; -}); - -// node_modules/commander/lib/help.js -var require_help = __commonJS((exports) => { - var { humanReadableArgName } = require_argument(); - - class Help { - constructor() { - this.helpWidth = undefined; - this.sortSubcommands = false; - this.sortOptions = false; - this.showGlobalOptions = false; - } - visibleCommands(cmd) { - const visibleCommands = cmd.commands.filter((cmd2) => !cmd2._hidden); - const helpCommand = cmd._getHelpCommand(); - if (helpCommand && !helpCommand._hidden) { - visibleCommands.push(helpCommand); - } - if (this.sortSubcommands) { - visibleCommands.sort((a, b) => { - return a.name().localeCompare(b.name()); - }); - } - return visibleCommands; - } - compareOptions(a, b) { - const getSortKey = (option) => { - return option.short ? option.short.replace(/^-/, "") : option.long.replace(/^--/, ""); - }; - return getSortKey(a).localeCompare(getSortKey(b)); - } - visibleOptions(cmd) { - const visibleOptions = cmd.options.filter((option) => !option.hidden); - const helpOption = cmd._getHelpOption(); - if (helpOption && !helpOption.hidden) { - const removeShort = helpOption.short && cmd._findOption(helpOption.short); - const removeLong = helpOption.long && cmd._findOption(helpOption.long); - if (!removeShort && !removeLong) { - visibleOptions.push(helpOption); - } else if (helpOption.long && !removeLong) { - visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description)); - } else if (helpOption.short && !removeShort) { - visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description)); - } - } - if (this.sortOptions) { - visibleOptions.sort(this.compareOptions); - } - return visibleOptions; - } - visibleGlobalOptions(cmd) { - if (!this.showGlobalOptions) - return []; - const globalOptions = []; - for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) { - const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden); - globalOptions.push(...visibleOptions); - } - if (this.sortOptions) { - globalOptions.sort(this.compareOptions); - } - return globalOptions; - } - visibleArguments(cmd) { - if (cmd._argsDescription) { - cmd.registeredArguments.forEach((argument) => { - argument.description = argument.description || cmd._argsDescription[argument.name()] || ""; - }); - } - if (cmd.registeredArguments.find((argument) => argument.description)) { - return cmd.registeredArguments; - } - return []; - } - subcommandTerm(cmd) { - const args = cmd.registeredArguments.map((arg) => humanReadableArgName(arg)).join(" "); - return cmd._name + (cmd._aliases[0] ? "|" + cmd._aliases[0] : "") + (cmd.options.length ? " [options]" : "") + (args ? " " + args : ""); - } - optionTerm(option) { - return option.flags; - } - argumentTerm(argument) { - return argument.name(); - } - longestSubcommandTermLength(cmd, helper) { - return helper.visibleCommands(cmd).reduce((max, command) => { - return Math.max(max, helper.subcommandTerm(command).length); - }, 0); - } - longestOptionTermLength(cmd, helper) { - return helper.visibleOptions(cmd).reduce((max, option) => { - return Math.max(max, helper.optionTerm(option).length); - }, 0); - } - longestGlobalOptionTermLength(cmd, helper) { - return helper.visibleGlobalOptions(cmd).reduce((max, option) => { - return Math.max(max, helper.optionTerm(option).length); - }, 0); - } - longestArgumentTermLength(cmd, helper) { - return helper.visibleArguments(cmd).reduce((max, argument) => { - return Math.max(max, helper.argumentTerm(argument).length); - }, 0); - } - commandUsage(cmd) { - let cmdName = cmd._name; - if (cmd._aliases[0]) { - cmdName = cmdName + "|" + cmd._aliases[0]; - } - let ancestorCmdNames = ""; - for (let ancestorCmd = cmd.parent;ancestorCmd; ancestorCmd = ancestorCmd.parent) { - ancestorCmdNames = ancestorCmd.name() + " " + ancestorCmdNames; - } - return ancestorCmdNames + cmdName + " " + cmd.usage(); - } - commandDescription(cmd) { - return cmd.description(); - } - subcommandDescription(cmd) { - return cmd.summary() || cmd.description(); - } - optionDescription(option) { - const extraInfo = []; - if (option.argChoices) { - extraInfo.push(`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`); - } - if (option.defaultValue !== undefined) { - const showDefault = option.required || option.optional || option.isBoolean() && typeof option.defaultValue === "boolean"; - if (showDefault) { - extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`); - } - } - if (option.presetArg !== undefined && option.optional) { - extraInfo.push(`preset: ${JSON.stringify(option.presetArg)}`); - } - if (option.envVar !== undefined) { - extraInfo.push(`env: ${option.envVar}`); - } - if (extraInfo.length > 0) { - return `${option.description} (${extraInfo.join(", ")})`; - } - return option.description; - } - argumentDescription(argument) { - const extraInfo = []; - if (argument.argChoices) { - extraInfo.push(`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(", ")}`); - } - if (argument.defaultValue !== undefined) { - extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`); - } - if (extraInfo.length > 0) { - const extraDescripton = `(${extraInfo.join(", ")})`; - if (argument.description) { - return `${argument.description} ${extraDescripton}`; - } - return extraDescripton; - } - return argument.description; - } - formatHelp(cmd, helper) { - const termWidth = helper.padWidth(cmd, helper); - const helpWidth = helper.helpWidth || 80; - const itemIndentWidth = 2; - const itemSeparatorWidth = 2; - function formatItem(term, description) { - if (description) { - const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`; - return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth); - } - return term; - } - function formatList(textArray) { - return textArray.join(` -`).replace(/^/gm, " ".repeat(itemIndentWidth)); - } - let output = [`Usage: ${helper.commandUsage(cmd)}`, ""]; - const commandDescription = helper.commandDescription(cmd); - if (commandDescription.length > 0) { - output = output.concat([ - helper.wrap(commandDescription, helpWidth, 0), - "" - ]); - } - const argumentList = helper.visibleArguments(cmd).map((argument) => { - return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument)); - }); - if (argumentList.length > 0) { - output = output.concat(["Arguments:", formatList(argumentList), ""]); - } - const optionList = helper.visibleOptions(cmd).map((option) => { - return formatItem(helper.optionTerm(option), helper.optionDescription(option)); - }); - if (optionList.length > 0) { - output = output.concat(["Options:", formatList(optionList), ""]); - } - if (this.showGlobalOptions) { - const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => { - return formatItem(helper.optionTerm(option), helper.optionDescription(option)); - }); - if (globalOptionList.length > 0) { - output = output.concat([ - "Global Options:", - formatList(globalOptionList), - "" - ]); - } - } - const commandList = helper.visibleCommands(cmd).map((cmd2) => { - return formatItem(helper.subcommandTerm(cmd2), helper.subcommandDescription(cmd2)); - }); - if (commandList.length > 0) { - output = output.concat(["Commands:", formatList(commandList), ""]); - } - return output.join(` -`); - } - padWidth(cmd, helper) { - return Math.max(helper.longestOptionTermLength(cmd, helper), helper.longestGlobalOptionTermLength(cmd, helper), helper.longestSubcommandTermLength(cmd, helper), helper.longestArgumentTermLength(cmd, helper)); - } - wrap(str, width, indent, minColumnWidth = 40) { - const indents = " \\f\\t\\v   -    \uFEFF"; - const manualIndent = new RegExp(`[\\n][${indents}]+`); - if (str.match(manualIndent)) - return str; - const columnWidth = width - indent; - if (columnWidth < minColumnWidth) - return str; - const leadingStr = str.slice(0, indent); - const columnText = str.slice(indent).replace(`\r -`, ` -`); - const indentString = " ".repeat(indent); - const zeroWidthSpace = "​"; - const breaks = `\\s${zeroWidthSpace}`; - const regex = new RegExp(` -|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, "g"); - const lines = columnText.match(regex) || []; - return leadingStr + lines.map((line, i) => { - if (line === ` -`) - return ""; - return (i > 0 ? indentString : "") + line.trimEnd(); - }).join(` -`); - } - } - exports.Help = Help; -}); - -// node_modules/commander/lib/option.js -var require_option = __commonJS((exports) => { - var { InvalidArgumentError } = require_error(); - - class Option { - constructor(flags, description) { - this.flags = flags; - this.description = description || ""; - this.required = flags.includes("<"); - this.optional = flags.includes("["); - this.variadic = /\w\.\.\.[>\]]$/.test(flags); - this.mandatory = false; - const optionFlags = splitOptionFlags(flags); - this.short = optionFlags.shortFlag; - this.long = optionFlags.longFlag; - this.negate = false; - if (this.long) { - this.negate = this.long.startsWith("--no-"); - } - this.defaultValue = undefined; - this.defaultValueDescription = undefined; - this.presetArg = undefined; - this.envVar = undefined; - this.parseArg = undefined; - this.hidden = false; - this.argChoices = undefined; - this.conflictsWith = []; - this.implied = undefined; - } - default(value, description) { - this.defaultValue = value; - this.defaultValueDescription = description; - return this; - } - preset(arg) { - this.presetArg = arg; - return this; - } - conflicts(names) { - this.conflictsWith = this.conflictsWith.concat(names); - return this; - } - implies(impliedOptionValues) { - let newImplied = impliedOptionValues; - if (typeof impliedOptionValues === "string") { - newImplied = { [impliedOptionValues]: true }; - } - this.implied = Object.assign(this.implied || {}, newImplied); - return this; - } - env(name) { - this.envVar = name; - return this; - } - argParser(fn) { - this.parseArg = fn; - return this; - } - makeOptionMandatory(mandatory = true) { - this.mandatory = !!mandatory; - return this; - } - hideHelp(hide = true) { - this.hidden = !!hide; - return this; - } - _concatValue(value, previous) { - if (previous === this.defaultValue || !Array.isArray(previous)) { - return [value]; - } - return previous.concat(value); - } - choices(values) { - this.argChoices = values.slice(); - this.parseArg = (arg, previous) => { - if (!this.argChoices.includes(arg)) { - throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(", ")}.`); - } - if (this.variadic) { - return this._concatValue(arg, previous); - } - return arg; - }; - return this; - } - name() { - if (this.long) { - return this.long.replace(/^--/, ""); - } - return this.short.replace(/^-/, ""); - } - attributeName() { - return camelcase(this.name().replace(/^no-/, "")); - } - is(arg) { - return this.short === arg || this.long === arg; - } - isBoolean() { - return !this.required && !this.optional && !this.negate; - } - } - - class DualOptions { - constructor(options) { - this.positiveOptions = new Map; - this.negativeOptions = new Map; - this.dualOptions = new Set; - options.forEach((option) => { - if (option.negate) { - this.negativeOptions.set(option.attributeName(), option); - } else { - this.positiveOptions.set(option.attributeName(), option); - } - }); - this.negativeOptions.forEach((value, key) => { - if (this.positiveOptions.has(key)) { - this.dualOptions.add(key); - } - }); - } - valueFromOption(value, option) { - const optionKey = option.attributeName(); - if (!this.dualOptions.has(optionKey)) - return true; - const preset = this.negativeOptions.get(optionKey).presetArg; - const negativeValue = preset !== undefined ? preset : false; - return option.negate === (negativeValue === value); - } - } - function camelcase(str) { - return str.split("-").reduce((str2, word) => { - return str2 + word[0].toUpperCase() + word.slice(1); - }); - } - function splitOptionFlags(flags) { - let shortFlag; - let longFlag; - const flagParts = flags.split(/[ |,]+/); - if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1])) - shortFlag = flagParts.shift(); - longFlag = flagParts.shift(); - if (!shortFlag && /^-[^-]$/.test(longFlag)) { - shortFlag = longFlag; - longFlag = undefined; - } - return { shortFlag, longFlag }; - } - exports.Option = Option; - exports.DualOptions = DualOptions; -}); - -// node_modules/commander/lib/suggestSimilar.js -var require_suggestSimilar = __commonJS((exports) => { - var maxDistance = 3; - function editDistance(a, b) { - if (Math.abs(a.length - b.length) > maxDistance) - return Math.max(a.length, b.length); - const d = []; - for (let i = 0;i <= a.length; i++) { - d[i] = [i]; - } - for (let j = 0;j <= b.length; j++) { - d[0][j] = j; - } - for (let j = 1;j <= b.length; j++) { - for (let i = 1;i <= a.length; i++) { - let cost = 1; - if (a[i - 1] === b[j - 1]) { - cost = 0; - } else { - cost = 1; - } - d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost); - if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) { - d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + 1); - } - } - } - return d[a.length][b.length]; - } - function suggestSimilar(word, candidates) { - if (!candidates || candidates.length === 0) - return ""; - candidates = Array.from(new Set(candidates)); - const searchingOptions = word.startsWith("--"); - if (searchingOptions) { - word = word.slice(2); - candidates = candidates.map((candidate) => candidate.slice(2)); - } - let similar = []; - let bestDistance = maxDistance; - const minSimilarity = 0.4; - candidates.forEach((candidate) => { - if (candidate.length <= 1) - return; - const distance = editDistance(word, candidate); - const length = Math.max(word.length, candidate.length); - const similarity = (length - distance) / length; - if (similarity > minSimilarity) { - if (distance < bestDistance) { - bestDistance = distance; - similar = [candidate]; - } else if (distance === bestDistance) { - similar.push(candidate); - } - } - }); - similar.sort((a, b) => a.localeCompare(b)); - if (searchingOptions) { - similar = similar.map((candidate) => `--${candidate}`); - } - if (similar.length > 1) { - return ` -(Did you mean one of ${similar.join(", ")}?)`; - } - if (similar.length === 1) { - return ` -(Did you mean ${similar[0]}?)`; - } - return ""; - } - exports.suggestSimilar = suggestSimilar; -}); - -// node_modules/commander/lib/command.js -var require_command = __commonJS((exports) => { - var EventEmitter = __require("node:events").EventEmitter; - var childProcess = __require("node:child_process"); - var path = __require("node:path"); - var fs = __require("node:fs"); - var process2 = __require("node:process"); - var { Argument, humanReadableArgName } = require_argument(); - var { CommanderError } = require_error(); - var { Help } = require_help(); - var { Option, DualOptions } = require_option(); - var { suggestSimilar } = require_suggestSimilar(); - - class Command extends EventEmitter { - constructor(name) { - super(); - this.commands = []; - this.options = []; - this.parent = null; - this._allowUnknownOption = false; - this._allowExcessArguments = true; - this.registeredArguments = []; - this._args = this.registeredArguments; - this.args = []; - this.rawArgs = []; - this.processedArgs = []; - this._scriptPath = null; - this._name = name || ""; - this._optionValues = {}; - this._optionValueSources = {}; - this._storeOptionsAsProperties = false; - this._actionHandler = null; - this._executableHandler = false; - this._executableFile = null; - this._executableDir = null; - this._defaultCommandName = null; - this._exitCallback = null; - this._aliases = []; - this._combineFlagAndOptionalValue = true; - this._description = ""; - this._summary = ""; - this._argsDescription = undefined; - this._enablePositionalOptions = false; - this._passThroughOptions = false; - this._lifeCycleHooks = {}; - this._showHelpAfterError = false; - this._showSuggestionAfterError = true; - this._outputConfiguration = { - writeOut: (str) => process2.stdout.write(str), - writeErr: (str) => process2.stderr.write(str), - getOutHelpWidth: () => process2.stdout.isTTY ? process2.stdout.columns : undefined, - getErrHelpWidth: () => process2.stderr.isTTY ? process2.stderr.columns : undefined, - outputError: (str, write) => write(str) - }; - this._hidden = false; - this._helpOption = undefined; - this._addImplicitHelpCommand = undefined; - this._helpCommand = undefined; - this._helpConfiguration = {}; - } - copyInheritedSettings(sourceCommand) { - this._outputConfiguration = sourceCommand._outputConfiguration; - this._helpOption = sourceCommand._helpOption; - this._helpCommand = sourceCommand._helpCommand; - this._helpConfiguration = sourceCommand._helpConfiguration; - this._exitCallback = sourceCommand._exitCallback; - this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties; - this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue; - this._allowExcessArguments = sourceCommand._allowExcessArguments; - this._enablePositionalOptions = sourceCommand._enablePositionalOptions; - this._showHelpAfterError = sourceCommand._showHelpAfterError; - this._showSuggestionAfterError = sourceCommand._showSuggestionAfterError; - return this; - } - _getCommandAndAncestors() { - const result = []; - for (let command = this;command; command = command.parent) { - result.push(command); - } - return result; - } - command(nameAndArgs, actionOptsOrExecDesc, execOpts) { - let desc = actionOptsOrExecDesc; - let opts = execOpts; - if (typeof desc === "object" && desc !== null) { - opts = desc; - desc = null; - } - opts = opts || {}; - const [, name, args] = nameAndArgs.match(/([^ ]+) *(.*)/); - const cmd = this.createCommand(name); - if (desc) { - cmd.description(desc); - cmd._executableHandler = true; - } - if (opts.isDefault) - this._defaultCommandName = cmd._name; - cmd._hidden = !!(opts.noHelp || opts.hidden); - cmd._executableFile = opts.executableFile || null; - if (args) - cmd.arguments(args); - this._registerCommand(cmd); - cmd.parent = this; - cmd.copyInheritedSettings(this); - if (desc) - return this; - return cmd; - } - createCommand(name) { - return new Command(name); - } - createHelp() { - return Object.assign(new Help, this.configureHelp()); - } - configureHelp(configuration) { - if (configuration === undefined) - return this._helpConfiguration; - this._helpConfiguration = configuration; - return this; - } - configureOutput(configuration) { - if (configuration === undefined) - return this._outputConfiguration; - Object.assign(this._outputConfiguration, configuration); - return this; - } - showHelpAfterError(displayHelp = true) { - if (typeof displayHelp !== "string") - displayHelp = !!displayHelp; - this._showHelpAfterError = displayHelp; - return this; - } - showSuggestionAfterError(displaySuggestion = true) { - this._showSuggestionAfterError = !!displaySuggestion; - return this; - } - addCommand(cmd, opts) { - if (!cmd._name) { - throw new Error(`Command passed to .addCommand() must have a name -- specify the name in Command constructor or using .name()`); - } - opts = opts || {}; - if (opts.isDefault) - this._defaultCommandName = cmd._name; - if (opts.noHelp || opts.hidden) - cmd._hidden = true; - this._registerCommand(cmd); - cmd.parent = this; - cmd._checkForBrokenPassThrough(); - return this; - } - createArgument(name, description) { - return new Argument(name, description); - } - argument(name, description, fn, defaultValue) { - const argument = this.createArgument(name, description); - if (typeof fn === "function") { - argument.default(defaultValue).argParser(fn); - } else { - argument.default(fn); - } - this.addArgument(argument); - return this; - } - arguments(names) { - names.trim().split(/ +/).forEach((detail) => { - this.argument(detail); - }); - return this; - } - addArgument(argument) { - const previousArgument = this.registeredArguments.slice(-1)[0]; - if (previousArgument && previousArgument.variadic) { - throw new Error(`only the last argument can be variadic '${previousArgument.name()}'`); - } - if (argument.required && argument.defaultValue !== undefined && argument.parseArg === undefined) { - throw new Error(`a default value for a required argument is never used: '${argument.name()}'`); - } - this.registeredArguments.push(argument); - return this; - } - helpCommand(enableOrNameAndArgs, description) { - if (typeof enableOrNameAndArgs === "boolean") { - this._addImplicitHelpCommand = enableOrNameAndArgs; - return this; - } - enableOrNameAndArgs = enableOrNameAndArgs ?? "help [command]"; - const [, helpName, helpArgs] = enableOrNameAndArgs.match(/([^ ]+) *(.*)/); - const helpDescription = description ?? "display help for command"; - const helpCommand = this.createCommand(helpName); - helpCommand.helpOption(false); - if (helpArgs) - helpCommand.arguments(helpArgs); - if (helpDescription) - helpCommand.description(helpDescription); - this._addImplicitHelpCommand = true; - this._helpCommand = helpCommand; - return this; - } - addHelpCommand(helpCommand, deprecatedDescription) { - if (typeof helpCommand !== "object") { - this.helpCommand(helpCommand, deprecatedDescription); - return this; - } - this._addImplicitHelpCommand = true; - this._helpCommand = helpCommand; - return this; - } - _getHelpCommand() { - const hasImplicitHelpCommand = this._addImplicitHelpCommand ?? (this.commands.length && !this._actionHandler && !this._findCommand("help")); - if (hasImplicitHelpCommand) { - if (this._helpCommand === undefined) { - this.helpCommand(undefined, undefined); - } - return this._helpCommand; - } - return null; - } - hook(event, listener) { - const allowedValues = ["preSubcommand", "preAction", "postAction"]; - if (!allowedValues.includes(event)) { - throw new Error(`Unexpected value for event passed to hook : '${event}'. -Expecting one of '${allowedValues.join("', '")}'`); - } - if (this._lifeCycleHooks[event]) { - this._lifeCycleHooks[event].push(listener); - } else { - this._lifeCycleHooks[event] = [listener]; - } - return this; - } - exitOverride(fn) { - if (fn) { - this._exitCallback = fn; - } else { - this._exitCallback = (err) => { - if (err.code !== "commander.executeSubCommandAsync") { - throw err; - } else { - } - }; - } - return this; - } - _exit(exitCode, code, message) { - if (this._exitCallback) { - this._exitCallback(new CommanderError(exitCode, code, message)); - } - process2.exit(exitCode); - } - action(fn) { - const listener = (args) => { - const expectedArgsCount = this.registeredArguments.length; - const actionArgs = args.slice(0, expectedArgsCount); - if (this._storeOptionsAsProperties) { - actionArgs[expectedArgsCount] = this; - } else { - actionArgs[expectedArgsCount] = this.opts(); - } - actionArgs.push(this); - return fn.apply(this, actionArgs); - }; - this._actionHandler = listener; - return this; - } - createOption(flags, description) { - return new Option(flags, description); - } - _callParseArg(target, value, previous, invalidArgumentMessage) { - try { - return target.parseArg(value, previous); - } catch (err) { - if (err.code === "commander.invalidArgument") { - const message = `${invalidArgumentMessage} ${err.message}`; - this.error(message, { exitCode: err.exitCode, code: err.code }); - } - throw err; - } - } - _registerOption(option) { - const matchingOption = option.short && this._findOption(option.short) || option.long && this._findOption(option.long); - if (matchingOption) { - const matchingFlag = option.long && this._findOption(option.long) ? option.long : option.short; - throw new Error(`Cannot add option '${option.flags}'${this._name && ` to command '${this._name}'`} due to conflicting flag '${matchingFlag}' -- already used by option '${matchingOption.flags}'`); - } - this.options.push(option); - } - _registerCommand(command) { - const knownBy = (cmd) => { - return [cmd.name()].concat(cmd.aliases()); - }; - const alreadyUsed = knownBy(command).find((name) => this._findCommand(name)); - if (alreadyUsed) { - const existingCmd = knownBy(this._findCommand(alreadyUsed)).join("|"); - const newCmd = knownBy(command).join("|"); - throw new Error(`cannot add command '${newCmd}' as already have command '${existingCmd}'`); - } - this.commands.push(command); - } - addOption(option) { - this._registerOption(option); - const oname = option.name(); - const name = option.attributeName(); - if (option.negate) { - const positiveLongFlag = option.long.replace(/^--no-/, "--"); - if (!this._findOption(positiveLongFlag)) { - this.setOptionValueWithSource(name, option.defaultValue === undefined ? true : option.defaultValue, "default"); - } - } else if (option.defaultValue !== undefined) { - this.setOptionValueWithSource(name, option.defaultValue, "default"); - } - const handleOptionValue = (val, invalidValueMessage, valueSource) => { - if (val == null && option.presetArg !== undefined) { - val = option.presetArg; - } - const oldValue = this.getOptionValue(name); - if (val !== null && option.parseArg) { - val = this._callParseArg(option, val, oldValue, invalidValueMessage); - } else if (val !== null && option.variadic) { - val = option._concatValue(val, oldValue); - } - if (val == null) { - if (option.negate) { - val = false; - } else if (option.isBoolean() || option.optional) { - val = true; - } else { - val = ""; - } - } - this.setOptionValueWithSource(name, val, valueSource); - }; - this.on("option:" + oname, (val) => { - const invalidValueMessage = `error: option '${option.flags}' argument '${val}' is invalid.`; - handleOptionValue(val, invalidValueMessage, "cli"); - }); - if (option.envVar) { - this.on("optionEnv:" + oname, (val) => { - const invalidValueMessage = `error: option '${option.flags}' value '${val}' from env '${option.envVar}' is invalid.`; - handleOptionValue(val, invalidValueMessage, "env"); - }); - } - return this; - } - _optionEx(config, flags, description, fn, defaultValue) { - if (typeof flags === "object" && flags instanceof Option) { - throw new Error("To add an Option object use addOption() instead of option() or requiredOption()"); - } - const option = this.createOption(flags, description); - option.makeOptionMandatory(!!config.mandatory); - if (typeof fn === "function") { - option.default(defaultValue).argParser(fn); - } else if (fn instanceof RegExp) { - const regex = fn; - fn = (val, def) => { - const m = regex.exec(val); - return m ? m[0] : def; - }; - option.default(defaultValue).argParser(fn); - } else { - option.default(fn); - } - return this.addOption(option); - } - option(flags, description, parseArg, defaultValue) { - return this._optionEx({}, flags, description, parseArg, defaultValue); - } - requiredOption(flags, description, parseArg, defaultValue) { - return this._optionEx({ mandatory: true }, flags, description, parseArg, defaultValue); - } - combineFlagAndOptionalValue(combine = true) { - this._combineFlagAndOptionalValue = !!combine; - return this; - } - allowUnknownOption(allowUnknown = true) { - this._allowUnknownOption = !!allowUnknown; - return this; - } - allowExcessArguments(allowExcess = true) { - this._allowExcessArguments = !!allowExcess; - return this; - } - enablePositionalOptions(positional = true) { - this._enablePositionalOptions = !!positional; - return this; - } - passThroughOptions(passThrough = true) { - this._passThroughOptions = !!passThrough; - this._checkForBrokenPassThrough(); - return this; - } - _checkForBrokenPassThrough() { - if (this.parent && this._passThroughOptions && !this.parent._enablePositionalOptions) { - throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`); - } - } - storeOptionsAsProperties(storeAsProperties = true) { - if (this.options.length) { - throw new Error("call .storeOptionsAsProperties() before adding options"); - } - if (Object.keys(this._optionValues).length) { - throw new Error("call .storeOptionsAsProperties() before setting option values"); - } - this._storeOptionsAsProperties = !!storeAsProperties; - return this; - } - getOptionValue(key) { - if (this._storeOptionsAsProperties) { - return this[key]; - } - return this._optionValues[key]; - } - setOptionValue(key, value) { - return this.setOptionValueWithSource(key, value, undefined); - } - setOptionValueWithSource(key, value, source) { - if (this._storeOptionsAsProperties) { - this[key] = value; - } else { - this._optionValues[key] = value; - } - this._optionValueSources[key] = source; - return this; - } - getOptionValueSource(key) { - return this._optionValueSources[key]; - } - getOptionValueSourceWithGlobals(key) { - let source; - this._getCommandAndAncestors().forEach((cmd) => { - if (cmd.getOptionValueSource(key) !== undefined) { - source = cmd.getOptionValueSource(key); - } - }); - return source; - } - _prepareUserArgs(argv, parseOptions) { - if (argv !== undefined && !Array.isArray(argv)) { - throw new Error("first parameter to parse must be array or undefined"); - } - parseOptions = parseOptions || {}; - if (argv === undefined && parseOptions.from === undefined) { - if (process2.versions?.electron) { - parseOptions.from = "electron"; - } - const execArgv = process2.execArgv ?? []; - if (execArgv.includes("-e") || execArgv.includes("--eval") || execArgv.includes("-p") || execArgv.includes("--print")) { - parseOptions.from = "eval"; - } - } - if (argv === undefined) { - argv = process2.argv; - } - this.rawArgs = argv.slice(); - let userArgs; - switch (parseOptions.from) { - case undefined: - case "node": - this._scriptPath = argv[1]; - userArgs = argv.slice(2); - break; - case "electron": - if (process2.defaultApp) { - this._scriptPath = argv[1]; - userArgs = argv.slice(2); - } else { - userArgs = argv.slice(1); - } - break; - case "user": - userArgs = argv.slice(0); - break; - case "eval": - userArgs = argv.slice(1); - break; - default: - throw new Error(`unexpected parse option { from: '${parseOptions.from}' }`); - } - if (!this._name && this._scriptPath) - this.nameFromFilename(this._scriptPath); - this._name = this._name || "program"; - return userArgs; - } - parse(argv, parseOptions) { - const userArgs = this._prepareUserArgs(argv, parseOptions); - this._parseCommand([], userArgs); - return this; - } - async parseAsync(argv, parseOptions) { - const userArgs = this._prepareUserArgs(argv, parseOptions); - await this._parseCommand([], userArgs); - return this; - } - _executeSubCommand(subcommand, args) { - args = args.slice(); - let launchWithNode = false; - const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"]; - function findFile(baseDir, baseName) { - const localBin = path.resolve(baseDir, baseName); - if (fs.existsSync(localBin)) - return localBin; - if (sourceExt.includes(path.extname(baseName))) - return; - const foundExt = sourceExt.find((ext) => fs.existsSync(`${localBin}${ext}`)); - if (foundExt) - return `${localBin}${foundExt}`; - return; - } - this._checkForMissingMandatoryOptions(); - this._checkForConflictingOptions(); - let executableFile = subcommand._executableFile || `${this._name}-${subcommand._name}`; - let executableDir = this._executableDir || ""; - if (this._scriptPath) { - let resolvedScriptPath; - try { - resolvedScriptPath = fs.realpathSync(this._scriptPath); - } catch (err) { - resolvedScriptPath = this._scriptPath; - } - executableDir = path.resolve(path.dirname(resolvedScriptPath), executableDir); - } - if (executableDir) { - let localFile = findFile(executableDir, executableFile); - if (!localFile && !subcommand._executableFile && this._scriptPath) { - const legacyName = path.basename(this._scriptPath, path.extname(this._scriptPath)); - if (legacyName !== this._name) { - localFile = findFile(executableDir, `${legacyName}-${subcommand._name}`); - } - } - executableFile = localFile || executableFile; - } - launchWithNode = sourceExt.includes(path.extname(executableFile)); - let proc; - if (process2.platform !== "win32") { - if (launchWithNode) { - args.unshift(executableFile); - args = incrementNodeInspectorPort(process2.execArgv).concat(args); - proc = childProcess.spawn(process2.argv[0], args, { stdio: "inherit" }); - } else { - proc = childProcess.spawn(executableFile, args, { stdio: "inherit" }); - } - } else { - args.unshift(executableFile); - args = incrementNodeInspectorPort(process2.execArgv).concat(args); - proc = childProcess.spawn(process2.execPath, args, { stdio: "inherit" }); - } - if (!proc.killed) { - const signals = ["SIGUSR1", "SIGUSR2", "SIGTERM", "SIGINT", "SIGHUP"]; - signals.forEach((signal) => { - process2.on(signal, () => { - if (proc.killed === false && proc.exitCode === null) { - proc.kill(signal); - } - }); - }); - } - const exitCallback = this._exitCallback; - proc.on("close", (code) => { - code = code ?? 1; - if (!exitCallback) { - process2.exit(code); - } else { - exitCallback(new CommanderError(code, "commander.executeSubCommandAsync", "(close)")); - } - }); - proc.on("error", (err) => { - if (err.code === "ENOENT") { - const executableDirMessage = executableDir ? `searched for local subcommand relative to directory '${executableDir}'` : "no directory for search for local subcommand, use .executableDir() to supply a custom directory"; - const executableMissing = `'${executableFile}' does not exist - - if '${subcommand._name}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead - - if the default executable name is not suitable, use the executableFile option to supply a custom name or path - - ${executableDirMessage}`; - throw new Error(executableMissing); - } else if (err.code === "EACCES") { - throw new Error(`'${executableFile}' not executable`); - } - if (!exitCallback) { - process2.exit(1); - } else { - const wrappedError = new CommanderError(1, "commander.executeSubCommandAsync", "(error)"); - wrappedError.nestedError = err; - exitCallback(wrappedError); - } - }); - this.runningCommand = proc; - } - _dispatchSubcommand(commandName, operands, unknown) { - const subCommand = this._findCommand(commandName); - if (!subCommand) - this.help({ error: true }); - let promiseChain; - promiseChain = this._chainOrCallSubCommandHook(promiseChain, subCommand, "preSubcommand"); - promiseChain = this._chainOrCall(promiseChain, () => { - if (subCommand._executableHandler) { - this._executeSubCommand(subCommand, operands.concat(unknown)); - } else { - return subCommand._parseCommand(operands, unknown); - } - }); - return promiseChain; - } - _dispatchHelpCommand(subcommandName) { - if (!subcommandName) { - this.help(); - } - const subCommand = this._findCommand(subcommandName); - if (subCommand && !subCommand._executableHandler) { - subCommand.help(); - } - return this._dispatchSubcommand(subcommandName, [], [this._getHelpOption()?.long ?? this._getHelpOption()?.short ?? "--help"]); - } - _checkNumberOfArguments() { - this.registeredArguments.forEach((arg, i) => { - if (arg.required && this.args[i] == null) { - this.missingArgument(arg.name()); - } - }); - if (this.registeredArguments.length > 0 && this.registeredArguments[this.registeredArguments.length - 1].variadic) { - return; - } - if (this.args.length > this.registeredArguments.length) { - this._excessArguments(this.args); - } - } - _processArguments() { - const myParseArg = (argument, value, previous) => { - let parsedValue = value; - if (value !== null && argument.parseArg) { - const invalidValueMessage = `error: command-argument value '${value}' is invalid for argument '${argument.name()}'.`; - parsedValue = this._callParseArg(argument, value, previous, invalidValueMessage); - } - return parsedValue; - }; - this._checkNumberOfArguments(); - const processedArgs = []; - this.registeredArguments.forEach((declaredArg, index) => { - let value = declaredArg.defaultValue; - if (declaredArg.variadic) { - if (index < this.args.length) { - value = this.args.slice(index); - if (declaredArg.parseArg) { - value = value.reduce((processed, v) => { - return myParseArg(declaredArg, v, processed); - }, declaredArg.defaultValue); - } - } else if (value === undefined) { - value = []; - } - } else if (index < this.args.length) { - value = this.args[index]; - if (declaredArg.parseArg) { - value = myParseArg(declaredArg, value, declaredArg.defaultValue); - } - } - processedArgs[index] = value; - }); - this.processedArgs = processedArgs; - } - _chainOrCall(promise, fn) { - if (promise && promise.then && typeof promise.then === "function") { - return promise.then(() => fn()); - } - return fn(); - } - _chainOrCallHooks(promise, event) { - let result = promise; - const hooks = []; - this._getCommandAndAncestors().reverse().filter((cmd) => cmd._lifeCycleHooks[event] !== undefined).forEach((hookedCommand) => { - hookedCommand._lifeCycleHooks[event].forEach((callback) => { - hooks.push({ hookedCommand, callback }); - }); - }); - if (event === "postAction") { - hooks.reverse(); - } - hooks.forEach((hookDetail) => { - result = this._chainOrCall(result, () => { - return hookDetail.callback(hookDetail.hookedCommand, this); - }); - }); - return result; - } - _chainOrCallSubCommandHook(promise, subCommand, event) { - let result = promise; - if (this._lifeCycleHooks[event] !== undefined) { - this._lifeCycleHooks[event].forEach((hook) => { - result = this._chainOrCall(result, () => { - return hook(this, subCommand); - }); - }); - } - return result; - } - _parseCommand(operands, unknown) { - const parsed = this.parseOptions(unknown); - this._parseOptionsEnv(); - this._parseOptionsImplied(); - operands = operands.concat(parsed.operands); - unknown = parsed.unknown; - this.args = operands.concat(unknown); - if (operands && this._findCommand(operands[0])) { - return this._dispatchSubcommand(operands[0], operands.slice(1), unknown); - } - if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) { - return this._dispatchHelpCommand(operands[1]); - } - if (this._defaultCommandName) { - this._outputHelpIfRequested(unknown); - return this._dispatchSubcommand(this._defaultCommandName, operands, unknown); - } - if (this.commands.length && this.args.length === 0 && !this._actionHandler && !this._defaultCommandName) { - this.help({ error: true }); - } - this._outputHelpIfRequested(parsed.unknown); - this._checkForMissingMandatoryOptions(); - this._checkForConflictingOptions(); - const checkForUnknownOptions = () => { - if (parsed.unknown.length > 0) { - this.unknownOption(parsed.unknown[0]); - } - }; - const commandEvent = `command:${this.name()}`; - if (this._actionHandler) { - checkForUnknownOptions(); - this._processArguments(); - let promiseChain; - promiseChain = this._chainOrCallHooks(promiseChain, "preAction"); - promiseChain = this._chainOrCall(promiseChain, () => this._actionHandler(this.processedArgs)); - if (this.parent) { - promiseChain = this._chainOrCall(promiseChain, () => { - this.parent.emit(commandEvent, operands, unknown); - }); - } - promiseChain = this._chainOrCallHooks(promiseChain, "postAction"); - return promiseChain; - } - if (this.parent && this.parent.listenerCount(commandEvent)) { - checkForUnknownOptions(); - this._processArguments(); - this.parent.emit(commandEvent, operands, unknown); - } else if (operands.length) { - if (this._findCommand("*")) { - return this._dispatchSubcommand("*", operands, unknown); - } - if (this.listenerCount("command:*")) { - this.emit("command:*", operands, unknown); - } else if (this.commands.length) { - this.unknownCommand(); - } else { - checkForUnknownOptions(); - this._processArguments(); - } - } else if (this.commands.length) { - checkForUnknownOptions(); - this.help({ error: true }); - } else { - checkForUnknownOptions(); - this._processArguments(); - } - } - _findCommand(name) { - if (!name) - return; - return this.commands.find((cmd) => cmd._name === name || cmd._aliases.includes(name)); - } - _findOption(arg) { - return this.options.find((option) => option.is(arg)); - } - _checkForMissingMandatoryOptions() { - this._getCommandAndAncestors().forEach((cmd) => { - cmd.options.forEach((anOption) => { - if (anOption.mandatory && cmd.getOptionValue(anOption.attributeName()) === undefined) { - cmd.missingMandatoryOptionValue(anOption); - } - }); - }); - } - _checkForConflictingLocalOptions() { - const definedNonDefaultOptions = this.options.filter((option) => { - const optionKey = option.attributeName(); - if (this.getOptionValue(optionKey) === undefined) { - return false; - } - return this.getOptionValueSource(optionKey) !== "default"; - }); - const optionsWithConflicting = definedNonDefaultOptions.filter((option) => option.conflictsWith.length > 0); - optionsWithConflicting.forEach((option) => { - const conflictingAndDefined = definedNonDefaultOptions.find((defined) => option.conflictsWith.includes(defined.attributeName())); - if (conflictingAndDefined) { - this._conflictingOption(option, conflictingAndDefined); - } - }); - } - _checkForConflictingOptions() { - this._getCommandAndAncestors().forEach((cmd) => { - cmd._checkForConflictingLocalOptions(); - }); - } - parseOptions(argv) { - const operands = []; - const unknown = []; - let dest = operands; - const args = argv.slice(); - function maybeOption(arg) { - return arg.length > 1 && arg[0] === "-"; - } - let activeVariadicOption = null; - while (args.length) { - const arg = args.shift(); - if (arg === "--") { - if (dest === unknown) - dest.push(arg); - dest.push(...args); - break; - } - if (activeVariadicOption && !maybeOption(arg)) { - this.emit(`option:${activeVariadicOption.name()}`, arg); - continue; - } - activeVariadicOption = null; - if (maybeOption(arg)) { - const option = this._findOption(arg); - if (option) { - if (option.required) { - const value = args.shift(); - if (value === undefined) - this.optionMissingArgument(option); - this.emit(`option:${option.name()}`, value); - } else if (option.optional) { - let value = null; - if (args.length > 0 && !maybeOption(args[0])) { - value = args.shift(); - } - this.emit(`option:${option.name()}`, value); - } else { - this.emit(`option:${option.name()}`); - } - activeVariadicOption = option.variadic ? option : null; - continue; - } - } - if (arg.length > 2 && arg[0] === "-" && arg[1] !== "-") { - const option = this._findOption(`-${arg[1]}`); - if (option) { - if (option.required || option.optional && this._combineFlagAndOptionalValue) { - this.emit(`option:${option.name()}`, arg.slice(2)); - } else { - this.emit(`option:${option.name()}`); - args.unshift(`-${arg.slice(2)}`); - } - continue; - } - } - if (/^--[^=]+=/.test(arg)) { - const index = arg.indexOf("="); - const option = this._findOption(arg.slice(0, index)); - if (option && (option.required || option.optional)) { - this.emit(`option:${option.name()}`, arg.slice(index + 1)); - continue; - } - } - if (maybeOption(arg)) { - dest = unknown; - } - if ((this._enablePositionalOptions || this._passThroughOptions) && operands.length === 0 && unknown.length === 0) { - if (this._findCommand(arg)) { - operands.push(arg); - if (args.length > 0) - unknown.push(...args); - break; - } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) { - operands.push(arg); - if (args.length > 0) - operands.push(...args); - break; - } else if (this._defaultCommandName) { - unknown.push(arg); - if (args.length > 0) - unknown.push(...args); - break; - } - } - if (this._passThroughOptions) { - dest.push(arg); - if (args.length > 0) - dest.push(...args); - break; - } - dest.push(arg); - } - return { operands, unknown }; - } - opts() { - if (this._storeOptionsAsProperties) { - const result = {}; - const len = this.options.length; - for (let i = 0;i < len; i++) { - const key = this.options[i].attributeName(); - result[key] = key === this._versionOptionName ? this._version : this[key]; - } - return result; - } - return this._optionValues; - } - optsWithGlobals() { - return this._getCommandAndAncestors().reduce((combinedOptions, cmd) => Object.assign(combinedOptions, cmd.opts()), {}); - } - error(message, errorOptions) { - this._outputConfiguration.outputError(`${message} -`, this._outputConfiguration.writeErr); - if (typeof this._showHelpAfterError === "string") { - this._outputConfiguration.writeErr(`${this._showHelpAfterError} -`); - } else if (this._showHelpAfterError) { - this._outputConfiguration.writeErr(` -`); - this.outputHelp({ error: true }); - } - const config = errorOptions || {}; - const exitCode = config.exitCode || 1; - const code = config.code || "commander.error"; - this._exit(exitCode, code, message); - } - _parseOptionsEnv() { - this.options.forEach((option) => { - if (option.envVar && option.envVar in process2.env) { - const optionKey = option.attributeName(); - if (this.getOptionValue(optionKey) === undefined || ["default", "config", "env"].includes(this.getOptionValueSource(optionKey))) { - if (option.required || option.optional) { - this.emit(`optionEnv:${option.name()}`, process2.env[option.envVar]); - } else { - this.emit(`optionEnv:${option.name()}`); - } - } - } - }); - } - _parseOptionsImplied() { - const dualHelper = new DualOptions(this.options); - const hasCustomOptionValue = (optionKey) => { - return this.getOptionValue(optionKey) !== undefined && !["default", "implied"].includes(this.getOptionValueSource(optionKey)); - }; - this.options.filter((option) => option.implied !== undefined && hasCustomOptionValue(option.attributeName()) && dualHelper.valueFromOption(this.getOptionValue(option.attributeName()), option)).forEach((option) => { - Object.keys(option.implied).filter((impliedKey) => !hasCustomOptionValue(impliedKey)).forEach((impliedKey) => { - this.setOptionValueWithSource(impliedKey, option.implied[impliedKey], "implied"); - }); - }); - } - missingArgument(name) { - const message = `error: missing required argument '${name}'`; - this.error(message, { code: "commander.missingArgument" }); - } - optionMissingArgument(option) { - const message = `error: option '${option.flags}' argument missing`; - this.error(message, { code: "commander.optionMissingArgument" }); - } - missingMandatoryOptionValue(option) { - const message = `error: required option '${option.flags}' not specified`; - this.error(message, { code: "commander.missingMandatoryOptionValue" }); - } - _conflictingOption(option, conflictingOption) { - const findBestOptionFromValue = (option2) => { - const optionKey = option2.attributeName(); - const optionValue = this.getOptionValue(optionKey); - const negativeOption = this.options.find((target) => target.negate && optionKey === target.attributeName()); - const positiveOption = this.options.find((target) => !target.negate && optionKey === target.attributeName()); - if (negativeOption && (negativeOption.presetArg === undefined && optionValue === false || negativeOption.presetArg !== undefined && optionValue === negativeOption.presetArg)) { - return negativeOption; - } - return positiveOption || option2; - }; - const getErrorMessage = (option2) => { - const bestOption = findBestOptionFromValue(option2); - const optionKey = bestOption.attributeName(); - const source = this.getOptionValueSource(optionKey); - if (source === "env") { - return `environment variable '${bestOption.envVar}'`; - } - return `option '${bestOption.flags}'`; - }; - const message = `error: ${getErrorMessage(option)} cannot be used with ${getErrorMessage(conflictingOption)}`; - this.error(message, { code: "commander.conflictingOption" }); - } - unknownOption(flag) { - if (this._allowUnknownOption) - return; - let suggestion = ""; - if (flag.startsWith("--") && this._showSuggestionAfterError) { - let candidateFlags = []; - let command = this; - do { - const moreFlags = command.createHelp().visibleOptions(command).filter((option) => option.long).map((option) => option.long); - candidateFlags = candidateFlags.concat(moreFlags); - command = command.parent; - } while (command && !command._enablePositionalOptions); - suggestion = suggestSimilar(flag, candidateFlags); - } - const message = `error: unknown option '${flag}'${suggestion}`; - this.error(message, { code: "commander.unknownOption" }); - } - _excessArguments(receivedArgs) { - if (this._allowExcessArguments) - return; - const expected = this.registeredArguments.length; - const s = expected === 1 ? "" : "s"; - const forSubcommand = this.parent ? ` for '${this.name()}'` : ""; - const message = `error: too many arguments${forSubcommand}. Expected ${expected} argument${s} but got ${receivedArgs.length}.`; - this.error(message, { code: "commander.excessArguments" }); - } - unknownCommand() { - const unknownName = this.args[0]; - let suggestion = ""; - if (this._showSuggestionAfterError) { - const candidateNames = []; - this.createHelp().visibleCommands(this).forEach((command) => { - candidateNames.push(command.name()); - if (command.alias()) - candidateNames.push(command.alias()); - }); - suggestion = suggestSimilar(unknownName, candidateNames); - } - const message = `error: unknown command '${unknownName}'${suggestion}`; - this.error(message, { code: "commander.unknownCommand" }); - } - version(str, flags, description) { - if (str === undefined) - return this._version; - this._version = str; - flags = flags || "-V, --version"; - description = description || "output the version number"; - const versionOption = this.createOption(flags, description); - this._versionOptionName = versionOption.attributeName(); - this._registerOption(versionOption); - this.on("option:" + versionOption.name(), () => { - this._outputConfiguration.writeOut(`${str} -`); - this._exit(0, "commander.version", str); - }); - return this; - } - description(str, argsDescription) { - if (str === undefined && argsDescription === undefined) - return this._description; - this._description = str; - if (argsDescription) { - this._argsDescription = argsDescription; - } - return this; - } - summary(str) { - if (str === undefined) - return this._summary; - this._summary = str; - return this; - } - alias(alias) { - if (alias === undefined) - return this._aliases[0]; - let command = this; - if (this.commands.length !== 0 && this.commands[this.commands.length - 1]._executableHandler) { - command = this.commands[this.commands.length - 1]; - } - if (alias === command._name) - throw new Error("Command alias can't be the same as its name"); - const matchingCommand = this.parent?._findCommand(alias); - if (matchingCommand) { - const existingCmd = [matchingCommand.name()].concat(matchingCommand.aliases()).join("|"); - throw new Error(`cannot add alias '${alias}' to command '${this.name()}' as already have command '${existingCmd}'`); - } - command._aliases.push(alias); - return this; - } - aliases(aliases) { - if (aliases === undefined) - return this._aliases; - aliases.forEach((alias) => this.alias(alias)); - return this; - } - usage(str) { - if (str === undefined) { - if (this._usage) - return this._usage; - const args = this.registeredArguments.map((arg) => { - return humanReadableArgName(arg); - }); - return [].concat(this.options.length || this._helpOption !== null ? "[options]" : [], this.commands.length ? "[command]" : [], this.registeredArguments.length ? args : []).join(" "); - } - this._usage = str; - return this; - } - name(str) { - if (str === undefined) - return this._name; - this._name = str; - return this; - } - nameFromFilename(filename) { - this._name = path.basename(filename, path.extname(filename)); - return this; - } - executableDir(path2) { - if (path2 === undefined) - return this._executableDir; - this._executableDir = path2; - return this; - } - helpInformation(contextOptions) { - const helper = this.createHelp(); - if (helper.helpWidth === undefined) { - helper.helpWidth = contextOptions && contextOptions.error ? this._outputConfiguration.getErrHelpWidth() : this._outputConfiguration.getOutHelpWidth(); - } - return helper.formatHelp(this, helper); - } - _getHelpContext(contextOptions) { - contextOptions = contextOptions || {}; - const context = { error: !!contextOptions.error }; - let write; - if (context.error) { - write = (arg) => this._outputConfiguration.writeErr(arg); - } else { - write = (arg) => this._outputConfiguration.writeOut(arg); - } - context.write = contextOptions.write || write; - context.command = this; - return context; - } - outputHelp(contextOptions) { - let deprecatedCallback; - if (typeof contextOptions === "function") { - deprecatedCallback = contextOptions; - contextOptions = undefined; - } - const context = this._getHelpContext(contextOptions); - this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", context)); - this.emit("beforeHelp", context); - let helpInformation = this.helpInformation(context); - if (deprecatedCallback) { - helpInformation = deprecatedCallback(helpInformation); - if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) { - throw new Error("outputHelp callback must return a string or a Buffer"); - } - } - context.write(helpInformation); - if (this._getHelpOption()?.long) { - this.emit(this._getHelpOption().long); - } - this.emit("afterHelp", context); - this._getCommandAndAncestors().forEach((command) => command.emit("afterAllHelp", context)); - } - helpOption(flags, description) { - if (typeof flags === "boolean") { - if (flags) { - this._helpOption = this._helpOption ?? undefined; - } else { - this._helpOption = null; - } - return this; - } - flags = flags ?? "-h, --help"; - description = description ?? "display help for command"; - this._helpOption = this.createOption(flags, description); - return this; - } - _getHelpOption() { - if (this._helpOption === undefined) { - this.helpOption(undefined, undefined); - } - return this._helpOption; - } - addHelpOption(option) { - this._helpOption = option; - return this; - } - help(contextOptions) { - this.outputHelp(contextOptions); - let exitCode = process2.exitCode || 0; - if (exitCode === 0 && contextOptions && typeof contextOptions !== "function" && contextOptions.error) { - exitCode = 1; - } - this._exit(exitCode, "commander.help", "(outputHelp)"); - } - addHelpText(position, text) { - const allowedValues = ["beforeAll", "before", "after", "afterAll"]; - if (!allowedValues.includes(position)) { - throw new Error(`Unexpected value for position to addHelpText. -Expecting one of '${allowedValues.join("', '")}'`); - } - const helpEvent = `${position}Help`; - this.on(helpEvent, (context) => { - let helpStr; - if (typeof text === "function") { - helpStr = text({ error: context.error, command: context.command }); - } else { - helpStr = text; - } - if (helpStr) { - context.write(`${helpStr} -`); - } - }); - return this; - } - _outputHelpIfRequested(args) { - const helpOption = this._getHelpOption(); - const helpRequested = helpOption && args.find((arg) => helpOption.is(arg)); - if (helpRequested) { - this.outputHelp(); - this._exit(0, "commander.helpDisplayed", "(outputHelp)"); - } - } - } - function incrementNodeInspectorPort(args) { - return args.map((arg) => { - if (!arg.startsWith("--inspect")) { - return arg; - } - let debugOption; - let debugHost = "127.0.0.1"; - let debugPort = "9229"; - let match; - if ((match = arg.match(/^(--inspect(-brk)?)$/)) !== null) { - debugOption = match[1]; - } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+)$/)) !== null) { - debugOption = match[1]; - if (/^\d+$/.test(match[3])) { - debugPort = match[3]; - } else { - debugHost = match[3]; - } - } else if ((match = arg.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/)) !== null) { - debugOption = match[1]; - debugHost = match[3]; - debugPort = match[4]; - } - if (debugOption && debugPort !== "0") { - return `${debugOption}=${debugHost}:${parseInt(debugPort) + 1}`; - } - return arg; - }); - } - exports.Command = Command; -}); - -// node_modules/commander/index.js -var require_commander = __commonJS((exports) => { - var { Argument } = require_argument(); - var { Command } = require_command(); - var { CommanderError, InvalidArgumentError } = require_error(); - var { Help } = require_help(); - var { Option } = require_option(); - exports.program = new Command; - exports.createCommand = (name) => new Command(name); - exports.createOption = (flags, description) => new Option(flags, description); - exports.createArgument = (name, description) => new Argument(name, description); - exports.Command = Command; - exports.Option = Option; - exports.Argument = Argument; - exports.Help = Help; - exports.CommanderError = CommanderError; - exports.InvalidArgumentError = InvalidArgumentError; - exports.InvalidOptionArgumentError = InvalidArgumentError; -}); - -// node_modules/commander/esm.mjs -var import__ = __toESM(require_commander(), 1); -var { - program, - createCommand, - createArgument, - createOption, - CommanderError, - InvalidArgumentError, - InvalidOptionArgumentError, - Command, - Argument, - Option, - Help -} = import__.default; - -// bin/resource-builder.ts -import { promises as fs } from "fs"; -import { join, extname, basename } from "path"; - -// node_modules/chalk/source/vendor/ansi-styles/index.js -var ANSI_BACKGROUND_OFFSET = 10; -var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`; -var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`; -var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`; -var styles = { - modifier: { - reset: [0, 0], - bold: [1, 22], - dim: [2, 22], - italic: [3, 23], - underline: [4, 24], - overline: [53, 55], - inverse: [7, 27], - hidden: [8, 28], - strikethrough: [9, 29] - }, - color: { - black: [30, 39], - red: [31, 39], - green: [32, 39], - yellow: [33, 39], - blue: [34, 39], - magenta: [35, 39], - cyan: [36, 39], - white: [37, 39], - blackBright: [90, 39], - gray: [90, 39], - grey: [90, 39], - redBright: [91, 39], - greenBright: [92, 39], - yellowBright: [93, 39], - blueBright: [94, 39], - magentaBright: [95, 39], - cyanBright: [96, 39], - whiteBright: [97, 39] - }, - bgColor: { - bgBlack: [40, 49], - bgRed: [41, 49], - bgGreen: [42, 49], - bgYellow: [43, 49], - bgBlue: [44, 49], - bgMagenta: [45, 49], - bgCyan: [46, 49], - bgWhite: [47, 49], - bgBlackBright: [100, 49], - bgGray: [100, 49], - bgGrey: [100, 49], - bgRedBright: [101, 49], - bgGreenBright: [102, 49], - bgYellowBright: [103, 49], - bgBlueBright: [104, 49], - bgMagentaBright: [105, 49], - bgCyanBright: [106, 49], - bgWhiteBright: [107, 49] - } -}; -var modifierNames = Object.keys(styles.modifier); -var foregroundColorNames = Object.keys(styles.color); -var backgroundColorNames = Object.keys(styles.bgColor); -var colorNames = [...foregroundColorNames, ...backgroundColorNames]; -function assembleStyles() { - const codes = new Map; - for (const [groupName, group] of Object.entries(styles)) { - for (const [styleName, style] of Object.entries(group)) { - styles[styleName] = { - open: `\x1B[${style[0]}m`, - close: `\x1B[${style[1]}m` - }; - group[styleName] = styles[styleName]; - codes.set(style[0], style[1]); - } - Object.defineProperty(styles, groupName, { - value: group, - enumerable: false - }); - } - Object.defineProperty(styles, "codes", { - value: codes, - enumerable: false - }); - styles.color.close = "\x1B[39m"; - styles.bgColor.close = "\x1B[49m"; - styles.color.ansi = wrapAnsi16(); - styles.color.ansi256 = wrapAnsi256(); - styles.color.ansi16m = wrapAnsi16m(); - styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET); - styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET); - styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET); - Object.defineProperties(styles, { - rgbToAnsi256: { - value(red, green, blue) { - if (red === green && green === blue) { - if (red < 8) { - return 16; - } - if (red > 248) { - return 231; - } - return Math.round((red - 8) / 247 * 24) + 232; - } - return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5); - }, - enumerable: false - }, - hexToRgb: { - value(hex) { - const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16)); - if (!matches) { - return [0, 0, 0]; - } - let [colorString] = matches; - if (colorString.length === 3) { - colorString = [...colorString].map((character) => character + character).join(""); - } - const integer = Number.parseInt(colorString, 16); - return [ - integer >> 16 & 255, - integer >> 8 & 255, - integer & 255 - ]; - }, - enumerable: false - }, - hexToAnsi256: { - value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)), - enumerable: false - }, - ansi256ToAnsi: { - value(code) { - if (code < 8) { - return 30 + code; - } - if (code < 16) { - return 90 + (code - 8); - } - let red; - let green; - let blue; - if (code >= 232) { - red = ((code - 232) * 10 + 8) / 255; - green = red; - blue = red; - } else { - code -= 16; - const remainder = code % 36; - red = Math.floor(code / 36) / 5; - green = Math.floor(remainder / 6) / 5; - blue = remainder % 6 / 5; - } - const value = Math.max(red, green, blue) * 2; - if (value === 0) { - return 30; - } - let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red)); - if (value === 2) { - result += 60; - } - return result; - }, - enumerable: false - }, - rgbToAnsi: { - value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)), - enumerable: false - }, - hexToAnsi: { - value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)), - enumerable: false - } - }); - return styles; -} -var ansiStyles = assembleStyles(); -var ansi_styles_default = ansiStyles; - -// node_modules/chalk/source/vendor/supports-color/index.js -import process2 from "node:process"; -import os from "node:os"; -import tty from "node:tty"; -function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process2.argv) { - const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--"; - const position = argv.indexOf(prefix + flag); - const terminatorPosition = argv.indexOf("--"); - return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); -} -var { env } = process2; -var flagForceColor; -if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) { - flagForceColor = 0; -} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) { - flagForceColor = 1; -} -function envForceColor() { - if ("FORCE_COLOR" in env) { - if (env.FORCE_COLOR === "true") { - return 1; - } - if (env.FORCE_COLOR === "false") { - return 0; - } - return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3); - } -} -function translateLevel(level) { - if (level === 0) { - return false; - } - return { - level, - hasBasic: true, - has256: level >= 2, - has16m: level >= 3 - }; -} -function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) { - const noFlagForceColor = envForceColor(); - if (noFlagForceColor !== undefined) { - flagForceColor = noFlagForceColor; - } - const forceColor = sniffFlags ? flagForceColor : noFlagForceColor; - if (forceColor === 0) { - return 0; - } - if (sniffFlags) { - if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) { - return 3; - } - if (hasFlag("color=256")) { - return 2; - } - } - if ("TF_BUILD" in env && "AGENT_NAME" in env) { - return 1; - } - if (haveStream && !streamIsTTY && forceColor === undefined) { - return 0; - } - const min = forceColor || 0; - if (env.TERM === "dumb") { - return min; - } - if (process2.platform === "win32") { - const osRelease = os.release().split("."); - if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) { - return Number(osRelease[2]) >= 14931 ? 3 : 2; - } - return 1; - } - if ("CI" in env) { - if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => (key in env))) { - return 3; - } - if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => (sign in env)) || env.CI_NAME === "codeship") { - return 1; - } - return min; - } - if ("TEAMCITY_VERSION" in env) { - return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0; - } - if (env.COLORTERM === "truecolor") { - return 3; - } - if (env.TERM === "xterm-kitty") { - return 3; - } - if ("TERM_PROGRAM" in env) { - const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10); - switch (env.TERM_PROGRAM) { - case "iTerm.app": { - return version >= 3 ? 3 : 2; - } - case "Apple_Terminal": { - return 2; - } - } - } - if (/-256(color)?$/i.test(env.TERM)) { - return 2; - } - if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { - return 1; - } - if ("COLORTERM" in env) { - return 1; - } - return min; -} -function createSupportsColor(stream, options = {}) { - const level = _supportsColor(stream, { - streamIsTTY: stream && stream.isTTY, - ...options - }); - return translateLevel(level); -} -var supportsColor = { - stdout: createSupportsColor({ isTTY: tty.isatty(1) }), - stderr: createSupportsColor({ isTTY: tty.isatty(2) }) -}; -var supports_color_default = supportsColor; - -// node_modules/chalk/source/utilities.js -function stringReplaceAll(string, substring, replacer) { - let index = string.indexOf(substring); - if (index === -1) { - return string; - } - const substringLength = substring.length; - let endIndex = 0; - let returnValue = ""; - do { - returnValue += string.slice(endIndex, index) + substring + replacer; - endIndex = index + substringLength; - index = string.indexOf(substring, endIndex); - } while (index !== -1); - returnValue += string.slice(endIndex); - return returnValue; -} -function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) { - let endIndex = 0; - let returnValue = ""; - do { - const gotCR = string[index - 1] === "\r"; - returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? `\r -` : ` -`) + postfix; - endIndex = index + 1; - index = string.indexOf(` -`, endIndex); - } while (index !== -1); - returnValue += string.slice(endIndex); - return returnValue; -} - -// node_modules/chalk/source/index.js -var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default; -var GENERATOR = Symbol("GENERATOR"); -var STYLER = Symbol("STYLER"); -var IS_EMPTY = Symbol("IS_EMPTY"); -var levelMapping = [ - "ansi", - "ansi", - "ansi256", - "ansi16m" -]; -var styles2 = Object.create(null); -var applyOptions = (object, options = {}) => { - if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) { - throw new Error("The `level` option should be an integer from 0 to 3"); - } - const colorLevel = stdoutColor ? stdoutColor.level : 0; - object.level = options.level === undefined ? colorLevel : options.level; -}; -var chalkFactory = (options) => { - const chalk = (...strings) => strings.join(" "); - applyOptions(chalk, options); - Object.setPrototypeOf(chalk, createChalk.prototype); - return chalk; -}; -function createChalk(options) { - return chalkFactory(options); -} -Object.setPrototypeOf(createChalk.prototype, Function.prototype); -for (const [styleName, style] of Object.entries(ansi_styles_default)) { - styles2[styleName] = { - get() { - const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]); - Object.defineProperty(this, styleName, { value: builder }); - return builder; - } - }; -} -styles2.visible = { - get() { - const builder = createBuilder(this, this[STYLER], true); - Object.defineProperty(this, "visible", { value: builder }); - return builder; - } -}; -var getModelAnsi = (model, level, type, ...arguments_) => { - if (model === "rgb") { - if (level === "ansi16m") { - return ansi_styles_default[type].ansi16m(...arguments_); - } - if (level === "ansi256") { - return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_)); - } - return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_)); - } - if (model === "hex") { - return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_)); - } - return ansi_styles_default[type][model](...arguments_); -}; -var usedModels = ["rgb", "hex", "ansi256"]; -for (const model of usedModels) { - styles2[model] = { - get() { - const { level } = this; - return function(...arguments_) { - const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]); - return createBuilder(this, styler, this[IS_EMPTY]); - }; - } - }; - const bgModel = "bg" + model[0].toUpperCase() + model.slice(1); - styles2[bgModel] = { - get() { - const { level } = this; - return function(...arguments_) { - const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]); - return createBuilder(this, styler, this[IS_EMPTY]); - }; - } - }; -} -var proto = Object.defineProperties(() => { -}, { - ...styles2, - level: { - enumerable: true, - get() { - return this[GENERATOR].level; - }, - set(level) { - this[GENERATOR].level = level; - } - } -}); -var createStyler = (open, close, parent) => { - let openAll; - let closeAll; - if (parent === undefined) { - openAll = open; - closeAll = close; - } else { - openAll = parent.openAll + open; - closeAll = close + parent.closeAll; - } - return { - open, - close, - openAll, - closeAll, - parent - }; -}; -var createBuilder = (self, _styler, _isEmpty) => { - const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" ")); - Object.setPrototypeOf(builder, proto); - builder[GENERATOR] = self; - builder[STYLER] = _styler; - builder[IS_EMPTY] = _isEmpty; - return builder; -}; -var applyStyle = (self, string) => { - if (self.level <= 0 || !string) { - return self[IS_EMPTY] ? "" : string; - } - let styler = self[STYLER]; - if (styler === undefined) { - return string; - } - const { openAll, closeAll } = styler; - if (string.includes("\x1B")) { - while (styler !== undefined) { - string = stringReplaceAll(string, styler.close, styler.open); - styler = styler.parent; - } - } - const lfIndex = string.indexOf(` -`); - if (lfIndex !== -1) { - string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex); - } - return openAll + string + closeAll; -}; -Object.defineProperties(createChalk.prototype, styles2); -var chalk = createChalk(); -var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 }); -var source_default = chalk; - -// node_modules/uuid/dist/esm/stringify.js -var byteToHex = []; -for (let i = 0;i < 256; ++i) { - byteToHex.push((i + 256).toString(16).slice(1)); -} -function unsafeStringify(arr, offset = 0) { - return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); -} - -// node_modules/uuid/dist/esm/rng.js -import { randomFillSync } from "crypto"; -var rnds8Pool = new Uint8Array(256); -var poolPtr = rnds8Pool.length; -function rng() { - if (poolPtr > rnds8Pool.length - 16) { - randomFillSync(rnds8Pool); - poolPtr = 0; - } - return rnds8Pool.slice(poolPtr, poolPtr += 16); -} - -// node_modules/uuid/dist/esm/native.js -import { randomUUID } from "crypto"; -var native_default = { randomUUID }; - -// node_modules/uuid/dist/esm/v4.js -function v4(options, buf, offset) { - if (native_default.randomUUID && !buf && !options) { - return native_default.randomUUID(); - } - options = options || {}; - const rnds = options.random || (options.rng || rng)(); - rnds[6] = rnds[6] & 15 | 64; - rnds[8] = rnds[8] & 63 | 128; - if (buf) { - offset = offset || 0; - for (let i = 0;i < 16; ++i) { - buf[offset + i] = rnds[i]; - } - return buf; - } - return unsafeStringify(rnds); -} -var v4_default = v4; -// bin/resource-builder.ts -var log = console.log; -var info = source_default.hex("#ffa552"); -var error = source_default.hex("#c42847"); -var alert = source_default.hex("#EFF2C0"); -var RESOURCE_TYPES = ["interface", "icon", "map", "sound", "macros"]; -var VALID_EXTENSIONS = ["vyint", "vyi", "vym", "vymac", "mp3", "aac", "wav", "m4a", "ogg", "flac"]; -var resourceJSON = initializeResourceJSON(); -var isVerbose = false; -var ignoringSound = false; -var resourceInDirectory = ""; -var resourceOutDirectory = ""; -var resourcesToProcess = []; -function initializeResourceJSON() { - return RESOURCE_TYPES.reduce((acc, type) => { - acc[type] = []; - return acc; - }, {}); -} -function prepareFileForProcessing(filePath) { - const extension = extname(filePath).slice(1); - const fileName = filePath.replace(/^.*[\\\/]/, ""); - const resourceIdentifier = `${v4_default()}.${extension}`; - const type = getResourceType(extension); - if (!type) - return; - if (type === "sound" && ignoringSound) { - logVerbose(`[Ignored File] ${filePath} (ignoreSound flag enabled)`); - return; - } - resourcesToProcess.push({ filePath, type }); - resourceJSON[type].push({ resourceIdentifier, fileName }); -} -function getResourceType(pExtension) { - switch (pExtension) { - case "vyint": - return "interface"; - case "vyi": - return "icon"; - case "vym": - return "map"; - case "vymac": - return "macros"; - case "mp3": - case "aac": - case "wav": - case "m4a": - case "ogg": - case "flac": - return "sound"; - default: - return null; - } -} -async function processDirectory(pDirectoryPath) { - try { - const contents = await fs.readdir(pDirectoryPath); - for (const item of contents) { - const itemPath = join(pDirectoryPath, item); - const stats = await fs.stat(itemPath); - if (stats.isDirectory()) { - await processDirectory(itemPath); - } else if (isValidExtension(extname(itemPath).slice(1))) { - prepareFileForProcessing(itemPath); - } - } - } catch (pError) { - logError(`[Error] Processing directory: ${pError}`); - } -} -function isValidExtension(pExtension) { - return VALID_EXTENSIONS.includes(pExtension); -} -async function processAllFiles() { - try { - await clearResourceTypeDirectories(`${resourceOutDirectory}/resources`, RESOURCE_TYPES); - const copyOperations = resourcesToProcess.map(({ filePath, type }) => { - const fileName = basename(filePath); - const resource = resourceJSON[type].find((res) => res.fileName === fileName); - if (!resource) { - throw new Error(`Resource not found for file: ${fileName}`); - } - const destination = join(resourceOutDirectory, "resources", type); - return copyFile(filePath, destination, resource.resourceIdentifier); - }); - await Promise.all(copyOperations); - logVerbose(`[Kit CLI] All resources have been processed.`); - await saveResourceJSON(); - } catch (pError) { - logError(`[Error] Processing files in batch: ${pError.message}`); - } -} -async function clearResourceTypeDirectories(pBaseDirectory, pDirectoriesToRemove) { - try { - for (const directory of pDirectoriesToRemove) { - const directoryPath = join(pBaseDirectory, directory); - const directoryExists = await fs.stat(directoryPath).then((stat) => stat.isDirectory()).catch(() => false); - if (directoryExists) { - await fs.rm(directoryPath, { recursive: true }); - } - } - } catch (pError) { - log(`${error(`[Error]`)} clearing directories: ${pError}`); - } -} -async function copyFile(pSource, pDestinationDir, pNewName) { - try { - await fs.mkdir(pDestinationDir, { recursive: true }); - await fs.copyFile(pSource, join(pDestinationDir, pNewName)); - } catch (pError) { - logError(`[Error] Copying file ${pSource}: ${pError}`); - } -} -async function saveResourceJSON() { - const filePath = join(resourceOutDirectory, "resource.json"); - try { - await fs.writeFile(filePath, JSON.stringify(resourceJSON, null, 2)); - } catch (pError) { - logError(`[Error] Saving resource JSON: ${pError}`); - } -} -async function processResources({ inDirectory, outDirectory, verbose, ignoreSound }) { - resourceInDirectory = inDirectory; - resourceOutDirectory = outDirectory; - isVerbose = verbose; - ignoringSound = ignoreSound; - resourceJSON = initializeResourceJSON(); - if (!resourceInDirectory || !resourceOutDirectory) { - logError("[Error] Input and output directories must be specified"); - return; - } - await processDirectory(resourceInDirectory); - if (resourcesToProcess.length > 0) { - await processAllFiles(); - } else { - logAlert("No resources found!"); - await saveResourceJSON(); - } -} -function logVerbose(pMessage) { - if (isVerbose) - log(info(pMessage)); -} -function logError(pMessage) { - log(error(pMessage)); -} -function logAlert(pMessage) { - log(alert(pMessage)); -} - -// bin/index.ts -class KitCLI { - static async processResources(pProcessOptions) { - await processResources(pProcessOptions); - } -} -// package.json -var package_default = { - name: "@evitcastudio/kit", - version: "1.1.2", - author: "doubleactii 56242467+doubleactii@users.noreply.github.com (https://evitcastudio.com)", - main: "./lib/index.js", - types: "./lib/index.d.ts", - module: "lib/index.js", - type: "module", - description: "A single-player/multiplayer framework for the Vylocity Game Engine.", - "cli-description": "CLI for handling building resources and running | testing | publishing games.", - keywords: [ - "framework", - "multiplayer", - "single-player", - "toolkit", - "kit" - ], - repository: { - type: "git", - url: "git+https://github.com/EvitcaStudio/Kit.git" - }, - bugs: { - url: "https://github.com/EvitcaStudio/Kit/issues" - }, - homepage: "https://github.com/EvitcaStudio/Kit", - license: "MIT", - scripts: { - prepublishOnly: "bun run build-all", - test: "bun test ./tests", - lint: "bun eslint ./src", - "build-types": "bun tsc", - "build-dist": "bun bun-build.ts", - "build-docs": "bun typedoc ./src/index.ts ./src/types/shared-types.ts", - "build-all": "bun run build-types && bun run build-dist && bun run build-docs" - }, - bin: { - kit: "./lib/bundle/cli/cli.js" - }, - devDependencies: { - "@eslint/create-config": "1.4.0", - "@eslint/js": "^9.17.0", - "@evitcastudio/kit-plugin": "^1.0.7", - "@types/bun": "latest", - "@types/node": "^22.10.2", - bun: "^1.1.42", - eslint: "^9.17.0", - globals: "^15.14.0", - typedoc: "^0.27.5", - typescript: "^5.7.2", - "typescript-eslint": "^8.19.0" - }, - dependencies: { - chalk: "^5.4.0", - commander: "^12.1.0", - uuid: "^11.0.3" - }, - directories: { - test: "tests" - } -}; - -// bin/cli.ts -var program2 = new Command; -program2.version(`${package_default.version}`).description(`Kit - ${package_default["cli-description"]}`); -program2.option("-i, --in ", "Input directory").option("-o, --out ", "Output directory").option("-is, --ignore-sound", "Ignore sound files", false).option("-v, --verbose", "Enable verbose mode", false); -program2.helpInformation = () => { - return ` -Kit CLI - ${package_default["cli-description"]} -Version: ${package_default.version} - -Usage: kit [options] - -Commands: -build Build resources from the specified directory ---help Display this help message - -Options: --i, --in Input directory (required) --o, --out Output directory (required) --is, --ignore-sound Ignore sound files (optional) --v, --verbose Enable verbose mode for debugging - -Examples: -kit build --in ./src --out ./dist --verbose -kit build --in ./resources --out ./dist --ignore-sound -`; -}; -if (!process.argv.slice(2).length) { - program2.help(); -} -program2.command("build").description("Build resources from the specified directory").action(() => { - const flags = program2.opts(); - if (!flags.in || !flags.out) { - console.error("Error: --in and --out are required flags for the build command."); - process.exit(1); - } - const ProcessOptions = { - inDirectory: flags.in, - outDirectory: flags.out, - ignoreSound: flags.ignoreSound || false, - verbose: flags.verbose || false - }; - KitCLI.processResources(ProcessOptions); -}); -program2.parse(process.argv); diff --git a/lib/event-system.d.ts b/lib/event-system.d.ts deleted file mode 100644 index f1fd475..0000000 --- a/lib/event-system.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import './types/shared-types'; -import type { KitPlugin } from '@evitcastudio/kit-plugin'; -export declare class EventEmitter { - private listener; - private plugin; - constructor(pListener: Listener, pPlugin: KitPlugin); - /** - * Emit an event to all listeners. - * @param pEvent - The event to emit. - */ - emit(pEvent: EmitterEvent): void; -} -//# sourceMappingURL=event-system.d.ts.map \ No newline at end of file diff --git a/lib/event-system.d.ts.map b/lib/event-system.d.ts.map deleted file mode 100644 index 0e0522d..0000000 --- a/lib/event-system.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"event-system.d.ts","sourceRoot":"","sources":["../src/event-system.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,qBAAa,YAAY;IACrB,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,MAAM,CAAY;gBAEd,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS;IAKnD;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI;CAcnC"} \ No newline at end of file diff --git a/lib/event-system.js b/lib/event-system.js deleted file mode 100644 index eebf9c1..0000000 --- a/lib/event-system.js +++ /dev/null @@ -1,26 +0,0 @@ -import './types/shared-types'; -export class EventEmitter { - listener; - plugin; - constructor(pListener, pPlugin) { - this.listener = pListener; - this.plugin = pPlugin; - } - /** - * Emit an event to all listeners. - * @param pEvent - The event to emit. - */ - emit(pEvent) { - if (pEvent.plugin && pEvent.plugin !== this.plugin.name) { - throw new Error(`Event mismatch: ${this.plugin.name} tried to emit an event from the ${pEvent.plugin} namespace.`); - } - const event = { - plugin: this.plugin.name, - event: pEvent.event, - data: pEvent?.data, - timestamp: Date.now() - }; - Object.freeze(event); - this.listener(event); - } -} diff --git a/lib/index.d.ts b/lib/index.d.ts deleted file mode 100644 index 3753d87..0000000 --- a/lib/index.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { Kit } from './kit'; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/lib/index.d.ts.map b/lib/index.d.ts.map deleted file mode 100644 index 7d24964..0000000 --- a/lib/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 041f69f..0000000 --- a/lib/index.js +++ /dev/null @@ -1 +0,0 @@ -export { Kit } from './kit'; diff --git a/lib/kit.d.ts b/lib/kit.d.ts deleted file mode 100644 index 5b87850..0000000 --- a/lib/kit.d.ts +++ /dev/null @@ -1,65 +0,0 @@ -import type { KitPlugin } from '@evitcastudio/kit-plugin'; -import './types/shared-types'; -export declare class Kit { - /** - * A record of all plugins registered with the Kit class. - */ - private static plugins; - /** - * A set of all plugin emitters. - */ - private static emitters; - /** - * A record of all event listeners. - */ - private static events; - private constructor(); - /** - * Initialize the Kit class with plugins. - * @param pPlugins - An array of plugins to initialize. - */ - static init(pPlugins: KitPluginConstructor[]): void; - /** - * Register a plugin with the Kit class. - * @param pPlugin - The plugin to register. - */ - static registerPlugin(pPlugin: KitPluginConstructor): void; - /** - * Gets a plugin by name. - * @param pName - String name of the plugin to retrieve. - */ - static getPlugin(pName: string): T | undefined; - /** - * Lists all registered plugins. - */ - static getPlugins(): string[]; - /** - * Emit an event to all listeners. - * @param pEvent - The event to emit. - */ - private static emit; - /** - * Listen for an event. - * @param pPluginName - The plugin namespace. - * @param pEventName - The event name. - * @param pListener - The listener to call when the event is emitted. - */ - static on(pPluginName: string, pEventName: string, pListener: Listener): void; - /** - * Removes an event listener. - * @param pPluginName - The plugin namespace. - * @param pEventName - The event name. - * @param pListener - The listener to remove. - */ - static off(pPluginName: string, pEventName: string, pListener: (pData: EmitterEvent) => void): void; - /** - * Sets the resource locator for the engine to reference the files we have in the resources folder. interface | map | icon | macro | sound are checked for. - * @param pData - An array of each file that was found in the resources folder - */ - private static setResource; - /** - * Sets the resources found in resources and preloads all interfaces found. - */ - static setResources(): Promise; -} -//# sourceMappingURL=kit.d.ts.map \ No newline at end of file diff --git a/lib/kit.d.ts.map b/lib/kit.d.ts.map deleted file mode 100644 index 9d23d77..0000000 --- a/lib/kit.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"kit.d.ts","sourceRoot":"","sources":["../src/kit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,sBAAsB,CAAC;AAe9B,qBAAa,GAAG;IACZ;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,OAAO,CAAiC;IACvD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAmC;IAC1D;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,MAAM,CAAuC;IAE5D,OAAO;IAIP;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,SAAS,EAAE,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI;IAM3E;;;OAGG;IACH,MAAM,CAAC,cAAc,CAAC,CAAC,SAAS,SAAS,EAAE,OAAO,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,IAAI;IAkBlF;;;OAGG;IACH,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAInE;;OAEG;IACH,MAAM,CAAC,UAAU,IAAI,MAAM,EAAE;IAI7B;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,IAAI;IAWlB;;;;;MAKE;IACH,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,GAAG,IAAI;IAQ7E;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,IAAI;IAOnG;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAiB1B;;OAEG;WACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CA0B7C"} \ No newline at end of file diff --git a/lib/kit.js b/lib/kit.js deleted file mode 100644 index 4167e61..0000000 --- a/lib/kit.js +++ /dev/null @@ -1,152 +0,0 @@ -import { EventEmitter } from './event-system'; -import './types/shared-types'; -const extensionToPath = { - '.vyint': 'interface', - '.vym': 'map', - '.vyi': 'icon', - '.vymac': 'macros', - '.aac': 'sound', - '.mp3': 'sound', - '.wav': 'sound', - '.m4a': 'sound', - '.ogg': 'sound', - '.flac': 'sound' -}; -export class Kit { - /** - * A record of all plugins registered with the Kit class. - */ - static plugins = {}; - /** - * A set of all plugin emitters. - */ - static emitters = new Map(); - /** - * A record of all event listeners. - */ - static events = {}; - constructor() { - throw new Error('[Kit] is not to be instantiated.'); - } - /** - * Initialize the Kit class with plugins. - * @param pPlugins - An array of plugins to initialize. - */ - static init(pPlugins) { - pPlugins.forEach(pPlugin => { - this.registerPlugin(pPlugin); - }); - } - /** - * Register a plugin with the Kit class. - * @param pPlugin - The plugin to register. - */ - static registerPlugin(pPlugin) { - const plugin = new pPlugin(); - if (Kit.plugins[plugin.name]) { - throw new Error(`[Kit] plugin with name '${plugin.name}' is already registered.`); - } - const listener = (pEvent) => { - Kit.emit(pEvent); - }; - const emitter = new EventEmitter(listener, plugin); - Kit.emitters.set(plugin.name, emitter); - Kit.plugins[plugin.name] = plugin; - plugin._register(emitter); - } - /** - * Gets a plugin by name. - * @param pName - String name of the plugin to retrieve. - */ - static getPlugin(pName) { - return Kit.plugins[pName]; - } - /** - * Lists all registered plugins. - */ - static getPlugins() { - return Object.keys(Kit.plugins); - } - /** - * Emit an event to all listeners. - * @param pEvent - The event to emit. - */ - static emit(pEvent) { - const { plugin, event } = pEvent; - const eventScope = `${plugin}-${event}`; - if (!Kit.events[eventScope]) { - return; - } - Kit.events[eventScope].forEach(pListener => pListener(pEvent)); - } - /** - * Listen for an event. - * @param pPluginName - The plugin namespace. - * @param pEventName - The event name. - * @param pListener - The listener to call when the event is emitted. - */ - static on(pPluginName, pEventName, pListener) { - const eventScope = `${pPluginName}-${pEventName}`; - if (!Kit.events[eventScope]) { - Kit.events[eventScope] = []; - } - Kit.events[eventScope].push(pListener); - } - /** - * Removes an event listener. - * @param pPluginName - The plugin namespace. - * @param pEventName - The event name. - * @param pListener - The listener to remove. - */ - static off(pPluginName, pEventName, pListener) { - const eventScope = `${pPluginName}-${pEventName}`; - if (Kit.events[eventScope].includes(pListener)) { - Kit.events[eventScope].splice(Kit.events[eventScope].indexOf(pListener), 1); - } - } - /** - * Sets the resource locator for the engine to reference the files we have in the resources folder. interface | map | icon | macro | sound are checked for. - * @param pData - An array of each file that was found in the resources folder - */ - static setResource(pData) { - pData.forEach((pResource) => { - const extensionMatch = pResource.fileName.match(/\.[^.]+$/); - const fileNameWithoutExtensionMatch = pResource.fileName.match(/(.+?)(?=\.[^.]+$|$)/); - if (extensionMatch && fileNameWithoutExtensionMatch) { - const extension = extensionMatch[0]; - const fileNameWithoutExtension = fileNameWithoutExtensionMatch[0]; - const resourceType = extensionToPath[extension]; - if (resourceType) { - globalThis.VYLO.Resource.setResource(resourceType, fileNameWithoutExtension, `resources/${resourceType}/${pResource.resourceIdentifier}`, true); - } - } - }); - } - /** - * Sets the resources found in resources and preloads all interfaces found. - */ - static async setResources() { - if (!globalThis.VYLO) { - throw new Error('[Kit] VYLO is not defined. Please ensure the VYLO variable is available in the global namespace.'); - } - const resourcePath = './resource.json'; - // Load the resource json and set the resources found - try { - const response = await fetch(resourcePath); - if (!response.ok) { - throw new Error(`[Kit] HTTP error! Status: ${response.status}`); - } - const resourceJSON = await response.json(); - if (resourceJSON) { - const resources = Object.values(resourceJSON); - // Group all data from separate arrays in object to one unified array of all resource data - const consolidatedData = resources.flat(); - // Set all the resources - this.setResource(consolidatedData); - } - } - catch (pError) { - console.error(`[Kit] error reading ${resourcePath}`, pError); - } - } -} diff --git a/lib/types/shared-types.d.ts b/lib/types/shared-types.d.ts deleted file mode 100644 index 715949c..0000000 --- a/lib/types/shared-types.d.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { KitPlugin } from '@evitcastudio/kit-plugin'; -declare global { - /** - * The EmitterEvent type is used to define the shape of the data that is passed to the event listeners. - */ - type EmitterEvent = { - /** - * The event name, e.g., "draw-frame". - */ - event: string; - /** - * The data associated with the event. - */ - data?: Record; - } & Record; - type ResourceData = { - resourceIdentifier: string; - fileName: string; - }; - type Listener = (pData: EmitterEvent) => void; - type KitPluginConstructor = new () => T; - var VYLO: VyloType; -} -export type {}; -//# sourceMappingURL=shared-types.d.ts.map \ No newline at end of file diff --git a/lib/types/shared-types.d.ts.map b/lib/types/shared-types.d.ts.map deleted file mode 100644 index 928813b..0000000 --- a/lib/types/shared-types.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"shared-types.d.ts","sourceRoot":"","sources":["../../src/types/shared-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,CAAC,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,YAAY,GAAG;QAChB;;WAEG;QACH,KAAK,EAAE,MAAM,CAAC;QACd;;WAEG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE5B,KAAK,YAAY,GAAG;QAChB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,QAAQ,EAAE,MAAM,CAAA;KACnB,CAAC;IAEF,KAAK,QAAQ,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAE9C,KAAK,oBAAoB,CAAC,CAAC,SAAS,SAAS,IAAI,UAAU,CAAC,CAAC;IAE7D,IAAI,IAAI,EAAE,QAAQ,CAAC;CACtB;AAED,YAAY,EAAE,CAAC"} \ No newline at end of file diff --git a/lib/types/shared-types.js b/lib/types/shared-types.js deleted file mode 100644 index cb0ff5c..0000000 --- a/lib/types/shared-types.js +++ /dev/null @@ -1 +0,0 @@ -export {}; diff --git a/package.json b/package.json index 648906d..40101a1 100644 --- a/package.json +++ b/package.json @@ -56,5 +56,8 @@ }, "directories": { "test": "tests" - } + }, + "files": [ + "/lib" + ] }