@shell-shock/core 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/docs.d.cts +5 -5
- package/dist/components/docs.d.mts +5 -5
- package/dist/components/docs.d.mts.map +1 -1
- package/dist/components/helpers.cjs +9 -0
- package/dist/components/helpers.cjs.map +1 -1
- package/dist/components/helpers.d.cts +15 -7
- package/dist/components/helpers.d.cts.map +1 -1
- package/dist/components/helpers.d.mts +15 -7
- package/dist/components/helpers.d.mts.map +1 -1
- package/dist/components/helpers.mjs +9 -1
- package/dist/components/helpers.mjs.map +1 -1
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.mjs +2 -2
- package/dist/components/options-parser-logic.cjs +142 -62
- package/dist/components/options-parser-logic.cjs.map +1 -1
- package/dist/components/options-parser-logic.d.cts +15 -15
- package/dist/components/options-parser-logic.d.cts.map +1 -1
- package/dist/components/options-parser-logic.d.mts +15 -15
- package/dist/components/options-parser-logic.d.mts.map +1 -1
- package/dist/components/options-parser-logic.mjs +143 -63
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/usage.d.cts +2 -2
- package/dist/components/usage.d.mts +2 -2
- package/dist/components/utils-builtin.d.cts +9 -9
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts +9 -9
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/plugin-utils/description-helpers.cjs +105 -0
- package/dist/plugin-utils/description-helpers.cjs.map +1 -0
- package/dist/plugin-utils/description-helpers.d.cts +44 -0
- package/dist/plugin-utils/description-helpers.d.cts.map +1 -0
- package/dist/plugin-utils/description-helpers.d.mts +44 -0
- package/dist/plugin-utils/description-helpers.d.mts.map +1 -0
- package/dist/plugin-utils/description-helpers.mjs +101 -0
- package/dist/plugin-utils/description-helpers.mjs.map +1 -0
- package/dist/plugin-utils/index.cjs +5 -0
- package/dist/plugin-utils/index.d.cts +2 -1
- package/dist/plugin-utils/index.d.mts +2 -1
- package/dist/plugin-utils/index.mjs +2 -1
- package/dist/plugin-utils/type-checks.d.mts.map +1 -1
- package/dist/plugin.cjs +4 -6
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +4 -6
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +6 -3
- package/dist/resolver/deepkit.cjs.map +1 -1
- package/dist/resolver/deepkit.mjs +6 -3
- package/dist/resolver/deepkit.mjs.map +1 -1
- package/dist/resolver/helpers.cjs +15 -21
- package/dist/resolver/helpers.cjs.map +1 -1
- package/dist/resolver/helpers.mjs +15 -21
- package/dist/resolver/helpers.mjs.map +1 -1
- package/dist/resolver/resolve.cjs +13 -13
- package/dist/resolver/resolve.cjs.map +1 -1
- package/dist/resolver/resolve.mjs +13 -13
- package/dist/resolver/resolve.mjs.map +1 -1
- package/dist/types/config.cjs +5 -3
- package/dist/types/config.cjs.map +1 -1
- package/dist/types/config.d.cts +7 -3
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +7 -3
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +5 -3
- package/dist/types/config.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepkit.cjs","names":[],"sources":["../../src/resolver/deepkit.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeArray,\n TypeLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind,\n Context,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport { mergeCommandParameter } from \"./helpers\";\nimport type { ResolverContext } from \"./types\";\n\nfunction extractCommandParameterKind(\n type: Type | ReflectionKind\n): CommandParameterKind {\n if (type === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n type === ReflectionKind.number ||\n type === ReflectionKind.bigint ||\n ((type as Type).kind === ReflectionKind.literal &&\n (isNumber((type as TypeLiteral).literal) ||\n isBigInt((type as TypeLiteral).literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (type === ReflectionKind.boolean) {\n return CommandParameterKinds.boolean;\n } else {\n return CommandParameterKinds.string;\n }\n}\n\nfunction resolveCommandOption(\n ctx: ResolverContext,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n const existing = (ctx.output.options[reflection.getNameAsString()] ??\n {}) as Partial<CommandOption>;\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title: reflection.getTags().title?.trim(),\n description: reflection.getDescription(),\n kind: extractCommandParameterKind(type),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray()\n };\n\n if (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (option as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind((type as TypeArray).type.kind) as\n | \"string\"\n | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n option.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (option as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (option as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, option) as CommandOption;\n}\n\nfunction resolveCommandArgument(\n ctx: ResolverContext,\n index: number,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n const existing = (\n ctx.output.args.length > index ? ctx.output.args[index] : {}\n ) as Partial<CommandArgument>;\n\n if (\n !existing.kind &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName() || reflection.parameter.name,\n alias: reflection.getAlias(),\n kind: extractCommandParameterKind(type.kind),\n title: reflection.getTitle() || reflection.parameter.tags?.title,\n description: reflection.parameter.description,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue()\n };\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (argument as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind(type.type.kind) as \"string\" | \"number\";\n } else if (!existing.kind) {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, argument, {\n name: `arg${index}`\n }) as CommandArgument;\n}\n\nexport function resolveFromBytecode<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n const { input, module } = ctx;\n\n const type = reflect(module);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${\n input.command.entry.input?.file || input.command.path\n }\" does not export a valid function.`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n ctx.output.description ??= (ctx.input.command.description ||\n reflection.getDescription() ||\n type.description)!;\n\n const parameters = reflection.getParameters();\n if (parameters.length > 0 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n } else if (!ctx.module?.options) {\n throw new Error(\n `The first parameter of the command handler function in \"${\n ctx.input.command.entry.input?.file || ctx.input.command.path\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n ctx.output.args = parameters\n .slice(1)\n .map((arg, index) => resolveCommandArgument(ctx, index, arg));\n }\n}\n"],"mappings":";;;;;;;;;AAEA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AAQX,SAAS,4BAA4B,MAAM;qEAEnC,QAAO,4CAAqB;UAEvB,SAAS,gDAAe,6EAE5B,KAAG,SAAA,gDAAA,yDACS,KAAA,QAAA,iDACD,KAAA,QAAA,EACd,QAAA,4CAAA;UAEM,SAAA,gDAAA,QACJ,QAAO,4CAAsB;KAG7B,QAAO,4CAAE;;AAGjB,4BAAc,SAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AACd,SAAS,qBAAqB,KAAK,YAAK;CACpC,MAAM,OAAO,WAAW,SAAS;CACjC,MAAM,WAAY,IAAI,OAAO,QAAQ,WAAW,iBAAI,KAChD,EAAG;CACP,MAAM,SAAE;EACJ,MAAM,WAAG,iBAAA;EACT,OAAO,WAAA,SAAA,CAAA,SAAA,EAAA;EACP,OAAO,WAAO,SAAA,CAAA,OAAA,MAAA;EACd,aAAC,WAAA,gBAAA;EACD,MAAM,4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gDAAW,OACzB,OAAM,IAAI,MAAM,kCAAoB,WAAA,SAAA,CAAA,gBAAA,IAAA,MAAA,QAAA,KAAA,qIAAA,KAAA,CAChC,MAAA,CACC,WAAO,OAAA,QAAA,CAAA,GAAA;AAEhB,QAAO,sCAAsB,UAAQ,UAAA,EACjC,MAAM,MAAM,SAChB,CAAA;;AAEJ,uBAAuB,SAAS;CAAC;CAAmB;CAAO;CAAS;CAAc;CAAA;CAAA;CAAA;CAAA;AAClF,SAAgB,oBAAa,KAAA;CACzB,MAAM,EAAE,OAAO,qBAAW;CAC1B,MAAM,qDAAC,SAAA;AACP,KAAE,KAAA,SAAA,gDAAA,SACE,OAAM,IAAA,MAAA,2BAAA,MAAA,QAAA,MAAA,OAAA,QAAA,MAAA,QAAA,KAAA,qCAAA;CAEV,MAAC,aAAA,IAAA,oDAAA,KAAA;AACH,KAAA,OAAA,gBAAA,IAAA,MAAA,QAAA,8CAEM,KAAK;CACb,MAAA,aAAA,WAAA,eAAA;;AAEQ,MAAI,WAAW,GAAG,KAAK,SAAA,gDAAA,iBACnB,WAAU,GAAA,KAAA,SAAA,gDAAA,OAAA;GACV,MAAG,oBAAA,iDAAA,KAAA,WAAA,GAAA,KAAA;AACH,QAAK,MAAM,sBAAS,kBAAA,eAAA,CAChB,KAAG,OAAA,QAAA,mBAAA,iBAAA,IACC,qBAAe,KAAA,mBAAA;aAGlB,CAAC,IAAI,QAAQ;AAGtB,MAAI,OAAO,OAAC,WACP,MAAM,EAAE,CACR,IAAI,cAAc,KAAK,UAAK,uBAAA,KAAA,OAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAGzC,oBAAoB,SAAS;CAAC;CAAY;CAAA;CAAA;CAAA"}
|
|
1
|
+
{"version":3,"file":"deepkit.cjs","names":[],"sources":["../../src/resolver/deepkit.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind,\n Context,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport { mergeCommandParameter } from \"./helpers\";\nimport type { ResolverContext } from \"./types\";\n\nfunction extractCommandParameterKind(\n type: Type | ReflectionKind\n): CommandParameterKind {\n const isKind = !(isSetObject(type) && \"kind\" in type);\n const kind = !isKind ? type.kind : type;\n if (kind === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n kind === ReflectionKind.number ||\n kind === ReflectionKind.bigint ||\n (!isKind &&\n type.kind === ReflectionKind.literal &&\n (isNumber(type.literal) || isBigInt(type.literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (kind === ReflectionKind.boolean) {\n return CommandParameterKinds.boolean;\n } else {\n return CommandParameterKinds.string;\n }\n}\n\nfunction resolveCommandOption(\n ctx: ResolverContext,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n const existing = (ctx.output.options[reflection.getNameAsString()] ??\n {}) as Partial<CommandOption>;\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title: reflection.getTags().title?.trim(),\n description: reflection.getDescription(),\n kind: extractCommandParameterKind(type),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray()\n };\n\n if (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (option as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind((type as TypeArray).type.kind) as\n | \"string\"\n | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n option.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (option as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (option as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, option) as CommandOption;\n}\n\nfunction resolveCommandArgument(\n ctx: ResolverContext,\n index: number,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n const existing = (\n ctx.output.args.length > index ? ctx.output.args[index] : {}\n ) as Partial<CommandArgument>;\n\n if (\n !existing.kind &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName() || reflection.parameter.name,\n alias: reflection.getAlias(),\n kind: extractCommandParameterKind(type.kind),\n title: reflection.getTitle() || reflection.parameter.tags?.title,\n description: reflection.parameter.description,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue()\n };\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (argument as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind(type.type.kind) as \"string\" | \"number\";\n } else if (!existing.kind) {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, argument, {\n name: `arg${index}`\n }) as CommandArgument;\n}\n\nexport function resolveFromBytecode<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n const { input, module } = ctx;\n\n const type = reflect(module);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${\n input.command.entry.input?.file || input.command.path\n }\" does not export a valid function.`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n ctx.output.description ??= (ctx.input.command.description ||\n reflection.getDescription() ||\n type.description)!;\n\n const parameters = reflection.getParameters();\n if (parameters.length > 0 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n } else if (!ctx.module?.options) {\n throw new Error(\n `The first parameter of the command handler function in \"${\n ctx.input.command.entry.input?.file || ctx.input.command.path\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n ctx.output.args = parameters\n .slice(1)\n .map((arg, index) => resolveCommandArgument(ctx, index, arg));\n }\n}\n"],"mappings":";;;;;;;;;;AAEA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;CAUP,MAAM,SAAS,sDAAc,KAAG,IAAA,UAAA;;AAEhC,KAAI,SAAS,gDAAe;UAGnB,SAAQ,gDAAA,UACb,SAAS,gDAAG,UACd,CAAA,UACI,KAAA,SAAA,gDAAA,yDACY,KAAK,QAAQ,iDAAK,KAAA,QAAA,EACjC,QAAA,4CAAA;UAEM,SAAI,gDAAA,QACT,QAAO,4CAAK;KAGZ,QAAO,4CAAsB;;AAGrC,4BAA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IAAA,MAAA,QAAA,MAAA,OAAA,QAAA,IAAA,MAAA,QAAA,KAAA,6EAAA;AAEG,MAAI,OAAO,OAAO,WACb,MAAM,EAAE,CACR,IAAI,cAAc,KAAK,UAAM,uBAAA,KAAA,OAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAG1C,oBAAoB,SAAS;CAAC;CAAmB;CAAA;CAAA;CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CommandParameterKinds } from "../types/command.mjs";
|
|
2
2
|
import { mergeCommandParameter } from "./helpers.mjs";
|
|
3
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
3
4
|
import { ReflectionClass, ReflectionFunction, ReflectionKind, __ΩReflectionKind, reflect, stringifyType } from "@powerlines/deepkit/vendor/type";
|
|
4
5
|
import { isBigInt } from "@stryke/type-checks/is-bigint";
|
|
5
6
|
import { isNumber } from "@stryke/type-checks/is-number";
|
|
@@ -11,9 +12,11 @@ function __assignType(fn, args) {
|
|
|
11
12
|
return fn;
|
|
12
13
|
}
|
|
13
14
|
function extractCommandParameterKind(type) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const isKind = !(isSetObject(type) && "kind" in type);
|
|
16
|
+
const kind = !isKind ? type.kind : type;
|
|
17
|
+
if (kind === ReflectionKind.string) return CommandParameterKinds.string;
|
|
18
|
+
else if (kind === ReflectionKind.number || kind === ReflectionKind.bigint || !isKind && type.kind === ReflectionKind.literal && (isNumber(type.literal) || isBigInt(type.literal))) return CommandParameterKinds.number;
|
|
19
|
+
else if (kind === ReflectionKind.boolean) return CommandParameterKinds.boolean;
|
|
17
20
|
else return CommandParameterKinds.string;
|
|
18
21
|
}
|
|
19
22
|
extractCommandParameterKind.__type = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepkit.mjs","names":[],"sources":["../../src/resolver/deepkit.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeArray,\n TypeLiteral\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind,\n Context,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport { mergeCommandParameter } from \"./helpers\";\nimport type { ResolverContext } from \"./types\";\n\nfunction extractCommandParameterKind(\n type: Type | ReflectionKind\n): CommandParameterKind {\n if (type === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n type === ReflectionKind.number ||\n type === ReflectionKind.bigint ||\n ((type as Type).kind === ReflectionKind.literal &&\n (isNumber((type as TypeLiteral).literal) ||\n isBigInt((type as TypeLiteral).literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (type === ReflectionKind.boolean) {\n return CommandParameterKinds.boolean;\n } else {\n return CommandParameterKinds.string;\n }\n}\n\nfunction resolveCommandOption(\n ctx: ResolverContext,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n const existing = (ctx.output.options[reflection.getNameAsString()] ??\n {}) as Partial<CommandOption>;\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title: reflection.getTags().title?.trim(),\n description: reflection.getDescription(),\n kind: extractCommandParameterKind(type),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray()\n };\n\n if (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (option as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind((type as TypeArray).type.kind) as\n | \"string\"\n | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n option.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (option as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (option as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, option) as CommandOption;\n}\n\nfunction resolveCommandArgument(\n ctx: ResolverContext,\n index: number,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n const existing = (\n ctx.output.args.length > index ? ctx.output.args[index] : {}\n ) as Partial<CommandArgument>;\n\n if (\n !existing.kind &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName() || reflection.parameter.name,\n alias: reflection.getAlias(),\n kind: extractCommandParameterKind(type.kind),\n title: reflection.getTitle() || reflection.parameter.tags?.title,\n description: reflection.parameter.description,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue()\n };\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (argument as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind(type.type.kind) as \"string\" | \"number\";\n } else if (!existing.kind) {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, argument, {\n name: `arg${index}`\n }) as CommandArgument;\n}\n\nexport function resolveFromBytecode<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n const { input, module } = ctx;\n\n const type = reflect(module);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${\n input.command.entry.input?.file || input.command.path\n }\" does not export a valid function.`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n ctx.output.description ??= (ctx.input.command.description ||\n reflection.getDescription() ||\n type.description)!;\n\n const parameters = reflection.getParameters();\n if (parameters.length > 0 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n } else if (!ctx.module?.options) {\n throw new Error(\n `The first parameter of the command handler function in \"${\n ctx.input.command.entry.input?.file || ctx.input.command.path\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n ctx.output.args = parameters\n .slice(1)\n .map((arg, index) => resolveCommandArgument(ctx, index, arg));\n }\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AAQX,SAAS,4BAA4B,MAAM;oCAEnC,QAAO,sBAAqB;UAEvB,SAAS,eAAe,4CAE5B,KAAG,SAAA,eAAA,YACC,SAAQ,KAAA,QAAA,IACL,SAAI,KAAA,QAAA,EACd,QAAA,sBAAA;UAEM,SAAA,eAAA,QACJ,QAAO,sBAAsB;KAG7B,QAAO,sBAAE;;AAGjB,4BAAc,SAAA;CAAA;OAAA;CAAA;CAAA;CAAA;CAAA;CAAA;AACd,SAAS,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EAAE,CACR,IAAI,cAAc,KAAK,UAAK,uBAAA,KAAA,OAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAGzC,oBAAoB,SAAS;CAAC;CAAY;CAAA;CAAA;CAAA"}
|
|
1
|
+
{"version":3,"file":"deepkit.mjs","names":[],"sources":["../../src/resolver/deepkit.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n ReflectionParameter,\n ReflectionProperty,\n Type,\n TypeArray\n} from \"@powerlines/deepkit/vendor/type\";\nimport {\n reflect,\n ReflectionClass,\n ReflectionFunction,\n ReflectionKind,\n stringifyType\n} from \"@powerlines/deepkit/vendor/type\";\nimport { isBigInt } from \"@stryke/type-checks/is-bigint\";\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isRegExp } from \"@stryke/type-checks/is-regexp\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport type {\n CommandArgument,\n CommandOption,\n CommandParameterKind,\n Context,\n NumberCommandParameter,\n StringCommandParameter\n} from \"../types\";\nimport { CommandParameterKinds } from \"../types\";\nimport { mergeCommandParameter } from \"./helpers\";\nimport type { ResolverContext } from \"./types\";\n\nfunction extractCommandParameterKind(\n type: Type | ReflectionKind\n): CommandParameterKind {\n const isKind = !(isSetObject(type) && \"kind\" in type);\n const kind = !isKind ? type.kind : type;\n if (kind === ReflectionKind.string) {\n return CommandParameterKinds.string;\n } else if (\n kind === ReflectionKind.number ||\n kind === ReflectionKind.bigint ||\n (!isKind &&\n type.kind === ReflectionKind.literal &&\n (isNumber(type.literal) || isBigInt(type.literal)))\n ) {\n return CommandParameterKinds.number;\n } else if (kind === ReflectionKind.boolean) {\n return CommandParameterKinds.boolean;\n } else {\n return CommandParameterKinds.string;\n }\n}\n\nfunction resolveCommandOption(\n ctx: ResolverContext,\n reflection: ReflectionProperty\n): CommandOption {\n const type = reflection.getType();\n const existing = (ctx.output.options[reflection.getNameAsString()] ??\n {}) as Partial<CommandOption>;\n\n const option = {\n name: reflection.getNameAsString(),\n alias: reflection.getTags().alias ?? [],\n title: reflection.getTags().title?.trim(),\n description: reflection.getDescription(),\n kind: extractCommandParameterKind(type),\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue(),\n variadic: reflection.isArray()\n };\n\n if (reflection.isArray()) {\n if (\n (type as TypeArray).type.kind === ReflectionKind.string ||\n (type as TypeArray).type.kind === ReflectionKind.number\n ) {\n (option as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (option as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind((type as TypeArray).type.kind) as\n | \"string\"\n | \"number\";\n } else {\n throw new Error(\n `Unsupported array type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (type.kind === ReflectionKind.union) {\n option.kind = type.types.every(\n t =>\n t.kind === ReflectionKind.number ||\n (t.kind === ReflectionKind.literal &&\n (isNumber(t.literal) || isBigInt(t.literal)))\n )\n ? CommandParameterKinds.number\n : CommandParameterKinds.string;\n\n (option as StringCommandParameter | NumberCommandParameter).choices =\n type.types\n .map(t =>\n t.kind === ReflectionKind.literal\n ? isNumber(t.literal)\n ? t.literal\n : isBigInt(t.literal)\n ? Number(t.literal)\n : isRegExp(t.literal)\n ? t.literal.source\n : String(t.literal)\n : null\n )\n .filter(Boolean) as string[] | number[];\n } else if (type.kind === ReflectionKind.literal) {\n (option as StringCommandParameter | NumberCommandParameter).choices = [\n isNumber(type.literal)\n ? type.literal\n : isBigInt(type.literal)\n ? Number(type.literal)\n : isRegExp(type.literal)\n ? type.literal.source\n : String(type.literal)\n ].filter(Boolean) as string[] | number[];\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for option \"${reflection.getNameAsString()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, option) as CommandOption;\n}\n\nfunction resolveCommandArgument(\n ctx: ResolverContext,\n index: number,\n reflection: ReflectionParameter\n): CommandArgument {\n const type = reflection.getType();\n const existing = (\n ctx.output.args.length > index ? ctx.output.args[index] : {}\n ) as Partial<CommandArgument>;\n\n if (\n !existing.kind &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number &&\n type.kind !== ReflectionKind.boolean &&\n !(\n type.kind === ReflectionKind.array &&\n (type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number)\n )\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string types (or an array of strings) are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n const argument = {\n name: reflection.getName() || reflection.parameter.name,\n alias: reflection.getAlias(),\n kind: extractCommandParameterKind(type.kind),\n title: reflection.getTitle() || reflection.parameter.tags?.title,\n description: reflection.parameter.description,\n optional: reflection.isOptional(),\n default: reflection.getDefaultValue()\n };\n\n if (type.kind === ReflectionKind.array) {\n if (\n type.type.kind === ReflectionKind.string ||\n type.type.kind === ReflectionKind.number\n ) {\n (argument as StringCommandParameter | NumberCommandParameter).variadic =\n true;\n (argument as StringCommandParameter | NumberCommandParameter).kind =\n extractCommandParameterKind(type.type.kind) as \"string\" | \"number\";\n } else if (!existing.kind) {\n throw new Error(\n `Unsupported array type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n } else if (\n !existing.kind &&\n type.kind !== ReflectionKind.boolean &&\n type.kind !== ReflectionKind.string &&\n type.kind !== ReflectionKind.number\n ) {\n throw new Error(\n `Unsupported type for argument \"${reflection.getName()}\" in command \"${\n ctx.input.command.name\n }\". Only string, number, boolean, string[] and number[] are supported, received ${stringifyType(\n type\n )\n .trim()\n .replaceAll(\" | \", \", or \")}.`\n );\n }\n\n return mergeCommandParameter(existing, argument, {\n name: `arg${index}`\n }) as CommandArgument;\n}\n\nexport function resolveFromBytecode<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n const { input, module } = ctx;\n\n const type = reflect(module);\n if (type.kind !== ReflectionKind.function) {\n throw new Error(\n `The command entry file \"${\n input.command.entry.input?.file || input.command.path\n }\" does not export a valid function.`\n );\n }\n\n const reflection = new ReflectionFunction(type);\n\n ctx.output.description ??= (ctx.input.command.description ||\n reflection.getDescription() ||\n type.description)!;\n\n const parameters = reflection.getParameters();\n if (parameters.length > 0 && parameters[0]) {\n if (\n parameters[0].type.kind === ReflectionKind.objectLiteral ||\n parameters[0].type.kind === ReflectionKind.class\n ) {\n const optionsReflection = ReflectionClass.from(parameters[0].type);\n for (const propertyReflection of optionsReflection.getProperties()) {\n ctx.output.options[propertyReflection.getNameAsString()] =\n resolveCommandOption(ctx, propertyReflection);\n }\n } else if (!ctx.module?.options) {\n throw new Error(\n `The first parameter of the command handler function in \"${\n ctx.input.command.entry.input?.file || ctx.input.command.path\n }\" must be an object literal or class type representing the command options.`\n );\n }\n\n ctx.output.args = parameters\n .slice(1)\n .map((arg, index) => resolveCommandArgument(ctx, index, arg));\n }\n}\n"],"mappings":";;;;;;;;;AAEA,SA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A,mBAAA,KAAA;6DAEM,WAAW,gBAAgB,IACnC,KAAA;;AAEI,KAAI,WAAW,SAAS,KAAG,WAAA,IAAA;AACvB,MAAI,WAAU,GAAA,KAAA,SAAA,eAAA,iBACV,WAAG,GAAA,KAAA,SAAA,eAAA,OAAA;GACH,MAAM,oBAAc,gBAAA,KAAA,WAAA,GAAA,KAAA;AACpB,QAAK,MAAE,sBAAA,kBAAA,eAAA,CACH,KAAI,OAAO,QAAQ,mBAAA,iBAAA,IAChB,qBAAA,KAAA,mBAAA;kCAId,OAAA,IAAA,MAAA,2DAAA,IAAA,MAAA,QAAA,MAAA,OAAA,QAAA,IAAA,MAAA,QAAA,KAAA,6EAAA;AAEG,MAAI,OAAO,OAAO,WACb,MAAM,EAAE,CACR,IAAI,cAAc,KAAK,UAAM,uBAAA,KAAA,OAAA,IAAA,EAAA;GAAA;GAAA;GAAA;GAAA;GAAA,CAAA,CAAA;;;AAG1C,oBAAoB,SAAS;CAAC;CAAmB;CAAA;CAAA;CAAA"}
|
|
@@ -9,12 +9,6 @@ let __stryke_helpers_get_unique = require("@stryke/helpers/get-unique");
|
|
|
9
9
|
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
10
10
|
|
|
11
11
|
//#region src/resolver/helpers.ts
|
|
12
|
-
const __ΩRecord = [
|
|
13
|
-
"K",
|
|
14
|
-
"T",
|
|
15
|
-
"Record",
|
|
16
|
-
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
17
|
-
];
|
|
18
12
|
function __assignType(fn, args) {
|
|
19
13
|
fn.__type = args;
|
|
20
14
|
return fn;
|
|
@@ -69,8 +63,8 @@ resolveCommandArgumentDescription.__type = [
|
|
|
69
63
|
"resolveCommandArgumentDescription",
|
|
70
64
|
"P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/("
|
|
71
65
|
];
|
|
72
|
-
function applyOptionsDefaults(
|
|
73
|
-
return Object.fromEntries(Object.entries(options).map(__assignType(([key, option]) => {
|
|
66
|
+
function applyOptionsDefaults(ctx) {
|
|
67
|
+
return Object.fromEntries(Object.entries(ctx.output.options).map(__assignType(([key, option]) => {
|
|
74
68
|
const name = option.name || key;
|
|
75
69
|
const title = option.title || (0, __stryke_string_format_title_case.titleCase)(name);
|
|
76
70
|
return [key, {
|
|
@@ -78,7 +72,7 @@ function applyOptionsDefaults(options) {
|
|
|
78
72
|
name,
|
|
79
73
|
title,
|
|
80
74
|
description: option.description || resolveCommandOptionDescription(name, option.kind, option.optional, option.kind !== require_types_command.CommandParameterKinds.boolean && option.variadic, title, option.default),
|
|
81
|
-
env: option.env || (0, __stryke_string_format_constant_case.constantCase)(
|
|
75
|
+
env: option.env || option.env === false ? option.env : ctx.input.context.config.autoAssignEnv ? (0, __stryke_string_format_constant_case.constantCase)(name) : false
|
|
82
76
|
}];
|
|
83
77
|
}, [
|
|
84
78
|
"param0",
|
|
@@ -87,14 +81,13 @@ function applyOptionsDefaults(options) {
|
|
|
87
81
|
])));
|
|
88
82
|
}
|
|
89
83
|
applyOptionsDefaults.__type = [
|
|
90
|
-
|
|
91
|
-
"
|
|
92
|
-
"options",
|
|
84
|
+
"ResolverContext",
|
|
85
|
+
"ctx",
|
|
93
86
|
"applyOptionsDefaults",
|
|
94
|
-
"P
|
|
87
|
+
"P\"w!2\"\"/#"
|
|
95
88
|
];
|
|
96
|
-
function applyArgsDefaults(
|
|
97
|
-
return args.map(__assignType((arg, i) => {
|
|
89
|
+
function applyArgsDefaults(ctx) {
|
|
90
|
+
return ctx.output.args.map(__assignType((arg, i) => {
|
|
98
91
|
const name = arg.name || `arg${i + 1}`;
|
|
99
92
|
const title = arg.title || (0, __stryke_string_format_title_case.titleCase)(name);
|
|
100
93
|
return {
|
|
@@ -102,7 +95,7 @@ function applyArgsDefaults(args) {
|
|
|
102
95
|
name,
|
|
103
96
|
title,
|
|
104
97
|
description: arg.description || resolveCommandArgumentDescription(name, arg.kind, arg.optional, arg.kind !== require_types_command.CommandParameterKinds.boolean && arg.variadic, title, arg.default),
|
|
105
|
-
env: arg.name ? arg.env || arg.env === false ? arg.env : (0, __stryke_string_format_constant_case.constantCase)(name) : false
|
|
98
|
+
env: arg.name ? arg.env || arg.env === false ? arg.env : ctx.input.context.config.autoAssignEnv ? (0, __stryke_string_format_constant_case.constantCase)(name) : false : false
|
|
106
99
|
};
|
|
107
100
|
}, [
|
|
108
101
|
"arg",
|
|
@@ -112,17 +105,18 @@ function applyArgsDefaults(args) {
|
|
|
112
105
|
]));
|
|
113
106
|
}
|
|
114
107
|
applyArgsDefaults.__type = [
|
|
108
|
+
"ResolverContext",
|
|
109
|
+
"ctx",
|
|
115
110
|
"CommandArgument",
|
|
116
|
-
"args",
|
|
117
111
|
"applyArgsDefaults",
|
|
118
|
-
"P\"w!
|
|
112
|
+
"P\"w!2\"\"w#F/$"
|
|
119
113
|
];
|
|
120
|
-
function applyDefaults(
|
|
121
|
-
|
|
114
|
+
function applyDefaults(ctx) {
|
|
115
|
+
ctx.output.description ??= `The ${ctx.output.title.replace(/(?:c|C)ommands?$/, "").trim()} executable command-line interface.`;
|
|
122
116
|
}
|
|
123
117
|
applyDefaults.__type = [
|
|
124
118
|
"ResolverContext",
|
|
125
|
-
"
|
|
119
|
+
"ctx",
|
|
126
120
|
"applyDefaults",
|
|
127
121
|
"P\"w!2\"\"/#"
|
|
128
122
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.cjs","names":[],"sources":["../../src/resolver/helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { createDefu } from \"defu\";\nimport { getAppTitle } from \"../plugin-utils/context-helpers\";\nimport type {
|
|
1
|
+
{"version":3,"file":"helpers.cjs","names":[],"sources":["../../src/resolver/helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { createDefu } from \"defu\";\nimport { getAppTitle } from \"../plugin-utils/context-helpers\";\nimport type { CommandArgument, CommandParameterKind } from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport type { ResolverContext } from \"./types\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param name - The name of the command option.\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param variadic - Whether the command option is variadic (i.e., an array).\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n name: string,\n kind: CommandParameterKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} command-line ${\n kind === CommandParameterKinds.boolean ? \"flag\" : \"option\"\n } that allows the user to ${\n kind === CommandParameterKinds.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === CommandParameterKinds.boolean\n ? \"indicator\"\n : `${kind === CommandParameterKinds.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\n/**\n * Resolves the description for a command argument based on its reflection.\n *\n * @param name - The name of the command argument.\n * @param kind - The reflection kind of the command argument.\n * @param optional - Whether the command argument is optional.\n * @param variadic - Whether the command argument is variadic (i.e., an array).\n * @param title - The title of the command argument, if any.\n * @param defaultValue - The default value of the command argument, if any.\n * @returns The resolved description for the command argument.\n */\nexport function resolveCommandArgumentDescription(\n name: string,\n kind: CommandParameterKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `An${\n optional && !defaultValue ? \" optional\" : \"\"\n } argument that allows the user to ${\n kind === CommandParameterKinds.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === CommandParameterKinds.boolean\n ? \"indicator\"\n : `${kind === CommandParameterKinds.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\nexport function applyOptionsDefaults(ctx: ResolverContext) {\n return Object.fromEntries(\n Object.entries(ctx.output.options).map(([key, option]) => {\n const name = option.name || key;\n const title = option.title || titleCase(name);\n\n return [\n key,\n {\n ...option,\n name,\n title,\n description:\n option.description ||\n resolveCommandOptionDescription(\n name,\n option.kind,\n option.optional,\n option.kind !== CommandParameterKinds.boolean && option.variadic,\n title,\n option.default\n ),\n env:\n option.env || option.env === false\n ? option.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(name)\n : false\n }\n ];\n })\n );\n}\n\nexport function applyArgsDefaults(ctx: ResolverContext): CommandArgument[] {\n return ctx.output.args.map((arg, i) => {\n const name = arg.name || `arg${i + 1}`;\n const title = arg.title || titleCase(name);\n\n return {\n ...arg,\n name,\n title,\n description:\n arg.description ||\n resolveCommandArgumentDescription(\n name,\n arg.kind,\n arg.optional,\n arg.kind !== CommandParameterKinds.boolean && arg.variadic,\n title,\n arg.default\n ),\n env: arg.name\n ? arg.env || arg.env === false\n ? arg.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(name)\n : false\n : false\n };\n });\n}\n\nexport function applyDefaults(ctx: ResolverContext) {\n ctx.output.description ??= `The ${ctx.output.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command-line interface.`;\n}\n\nexport function resolveVirtualCommand<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n ctx.output.title ??= titleCase(ctx.input.command.name);\n ctx.output.description ??= `A collection of available ${\n ctx.output.title.replace(/(?:c|C)ommands?$/, \"\").trim() ||\n titleCase(ctx.input.command.name)\n } commands that are included in the ${getAppTitle(\n ctx.input.context\n )} command-line application.`;\n}\n\n/**\n * Merges two command parameters, giving precedence to string values in the second configuration.\n *\n * @param objA - The first command parameter object.\n * @param objB - The second command parameter object.\n * @returns The merged command parameter object.\n */\nexport const mergeCommandParameter = createDefu((obj, key, value) => {\n if (isString(obj[key]) && isString(value)) {\n if (isSetString(value)) {\n obj[key] = value;\n }\n\n return true;\n } else if (Array.isArray(obj[key]) && Array.isArray(value)) {\n if (value.length > 0) {\n obj[key] = getUniqueBy((obj[key] as unknown[]).concat(value), item =>\n isString(item) ? item : JSON.stringify(item)\n ) as (typeof obj)[typeof key];\n }\n\n return true;\n }\n\n return false;\n});\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;;;;;;AAsCX,SAAE,gCAAA,MAAA,MAAA,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AACE,QA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AI,MAAM,SAAS;;;;;AAGnB,SAAI;;AAER,QAAO;GACR;CAAC;CAAO;CAAM;CAAA;CAAA;CAAA,CAAA,CAAA"}
|
|
@@ -8,12 +8,6 @@ import { getUniqueBy } from "@stryke/helpers/get-unique";
|
|
|
8
8
|
import { isString } from "@stryke/type-checks/is-string";
|
|
9
9
|
|
|
10
10
|
//#region src/resolver/helpers.ts
|
|
11
|
-
const __ΩRecord = [
|
|
12
|
-
"K",
|
|
13
|
-
"T",
|
|
14
|
-
"Record",
|
|
15
|
-
"l'e#\"Rb!b\"Pde\"!N#!w#y"
|
|
16
|
-
];
|
|
17
11
|
function __assignType(fn, args) {
|
|
18
12
|
fn.__type = args;
|
|
19
13
|
return fn;
|
|
@@ -68,8 +62,8 @@ resolveCommandArgumentDescription.__type = [
|
|
|
68
62
|
"resolveCommandArgumentDescription",
|
|
69
63
|
"P&2!\"w\"2#\"2$\"2%&2&8\"2'8&/("
|
|
70
64
|
];
|
|
71
|
-
function applyOptionsDefaults(
|
|
72
|
-
return Object.fromEntries(Object.entries(options).map(__assignType(([key, option]) => {
|
|
65
|
+
function applyOptionsDefaults(ctx) {
|
|
66
|
+
return Object.fromEntries(Object.entries(ctx.output.options).map(__assignType(([key, option]) => {
|
|
73
67
|
const name = option.name || key;
|
|
74
68
|
const title = option.title || titleCase(name);
|
|
75
69
|
return [key, {
|
|
@@ -77,7 +71,7 @@ function applyOptionsDefaults(options) {
|
|
|
77
71
|
name,
|
|
78
72
|
title,
|
|
79
73
|
description: option.description || resolveCommandOptionDescription(name, option.kind, option.optional, option.kind !== CommandParameterKinds.boolean && option.variadic, title, option.default),
|
|
80
|
-
env: option.env || constantCase(
|
|
74
|
+
env: option.env || option.env === false ? option.env : ctx.input.context.config.autoAssignEnv ? constantCase(name) : false
|
|
81
75
|
}];
|
|
82
76
|
}, [
|
|
83
77
|
"param0",
|
|
@@ -86,14 +80,13 @@ function applyOptionsDefaults(options) {
|
|
|
86
80
|
])));
|
|
87
81
|
}
|
|
88
82
|
applyOptionsDefaults.__type = [
|
|
89
|
-
|
|
90
|
-
"
|
|
91
|
-
"options",
|
|
83
|
+
"ResolverContext",
|
|
84
|
+
"ctx",
|
|
92
85
|
"applyOptionsDefaults",
|
|
93
|
-
"P
|
|
86
|
+
"P\"w!2\"\"/#"
|
|
94
87
|
];
|
|
95
|
-
function applyArgsDefaults(
|
|
96
|
-
return args.map(__assignType((arg, i) => {
|
|
88
|
+
function applyArgsDefaults(ctx) {
|
|
89
|
+
return ctx.output.args.map(__assignType((arg, i) => {
|
|
97
90
|
const name = arg.name || `arg${i + 1}`;
|
|
98
91
|
const title = arg.title || titleCase(name);
|
|
99
92
|
return {
|
|
@@ -101,7 +94,7 @@ function applyArgsDefaults(args) {
|
|
|
101
94
|
name,
|
|
102
95
|
title,
|
|
103
96
|
description: arg.description || resolveCommandArgumentDescription(name, arg.kind, arg.optional, arg.kind !== CommandParameterKinds.boolean && arg.variadic, title, arg.default),
|
|
104
|
-
env: arg.name ? arg.env || arg.env === false ? arg.env : constantCase(name) : false
|
|
97
|
+
env: arg.name ? arg.env || arg.env === false ? arg.env : ctx.input.context.config.autoAssignEnv ? constantCase(name) : false : false
|
|
105
98
|
};
|
|
106
99
|
}, [
|
|
107
100
|
"arg",
|
|
@@ -111,17 +104,18 @@ function applyArgsDefaults(args) {
|
|
|
111
104
|
]));
|
|
112
105
|
}
|
|
113
106
|
applyArgsDefaults.__type = [
|
|
107
|
+
"ResolverContext",
|
|
108
|
+
"ctx",
|
|
114
109
|
"CommandArgument",
|
|
115
|
-
"args",
|
|
116
110
|
"applyArgsDefaults",
|
|
117
|
-
"P\"w!
|
|
111
|
+
"P\"w!2\"\"w#F/$"
|
|
118
112
|
];
|
|
119
|
-
function applyDefaults(
|
|
120
|
-
|
|
113
|
+
function applyDefaults(ctx) {
|
|
114
|
+
ctx.output.description ??= `The ${ctx.output.title.replace(/(?:c|C)ommands?$/, "").trim()} executable command-line interface.`;
|
|
121
115
|
}
|
|
122
116
|
applyDefaults.__type = [
|
|
123
117
|
"ResolverContext",
|
|
124
|
-
"
|
|
118
|
+
"ctx",
|
|
125
119
|
"applyDefaults",
|
|
126
120
|
"P\"w!2\"\"/#"
|
|
127
121
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../src/resolver/helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { createDefu } from \"defu\";\nimport { getAppTitle } from \"../plugin-utils/context-helpers\";\nimport type {
|
|
1
|
+
{"version":3,"file":"helpers.mjs","names":[],"sources":["../../src/resolver/helpers.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getUniqueBy } from \"@stryke/helpers/get-unique\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\nimport { isString } from \"@stryke/type-checks/is-string\";\nimport { createDefu } from \"defu\";\nimport { getAppTitle } from \"../plugin-utils/context-helpers\";\nimport type { CommandArgument, CommandParameterKind } from \"../types/command\";\nimport { CommandParameterKinds } from \"../types/command\";\nimport type { Context } from \"../types/context\";\nimport type { ResolverContext } from \"./types\";\n\n/**\n * Resolves the description for a command option based on its reflection.\n *\n * @param name - The name of the command option.\n * @param kind - The reflection kind of the command option.\n * @param optional - Whether the command option is optional.\n * @param variadic - Whether the command option is variadic (i.e., an array).\n * @param title - The title of the command option, if any.\n * @param defaultValue - The default value of the command option, if any.\n * @returns The resolved description for the command option.\n */\nexport function resolveCommandOptionDescription(\n name: string,\n kind: CommandParameterKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `A${optional && !defaultValue ? \"n optional\" : \"\"} command-line ${\n kind === CommandParameterKinds.boolean ? \"flag\" : \"option\"\n } that allows the user to ${\n kind === CommandParameterKinds.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === CommandParameterKinds.boolean\n ? \"indicator\"\n : `${kind === CommandParameterKinds.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\n/**\n * Resolves the description for a command argument based on its reflection.\n *\n * @param name - The name of the command argument.\n * @param kind - The reflection kind of the command argument.\n * @param optional - Whether the command argument is optional.\n * @param variadic - Whether the command argument is variadic (i.e., an array).\n * @param title - The title of the command argument, if any.\n * @param defaultValue - The default value of the command argument, if any.\n * @returns The resolved description for the command argument.\n */\nexport function resolveCommandArgumentDescription(\n name: string,\n kind: CommandParameterKind,\n optional = false,\n variadic = false,\n title?: string,\n defaultValue?: any\n): string {\n return `An${\n optional && !defaultValue ? \" optional\" : \"\"\n } argument that allows the user to ${\n kind === CommandParameterKinds.boolean\n ? \"set the\"\n : variadic\n ? \"specify custom\"\n : \"specify a custom\"\n } ${title?.trim() || titleCase(name)} ${\n kind === CommandParameterKinds.boolean\n ? \"indicator\"\n : `${kind === CommandParameterKinds.number ? \"numeric\" : \"string\"} value${\n variadic ? \"s\" : \"\"\n }`\n }.`;\n}\n\nexport function applyOptionsDefaults(ctx: ResolverContext) {\n return Object.fromEntries(\n Object.entries(ctx.output.options).map(([key, option]) => {\n const name = option.name || key;\n const title = option.title || titleCase(name);\n\n return [\n key,\n {\n ...option,\n name,\n title,\n description:\n option.description ||\n resolveCommandOptionDescription(\n name,\n option.kind,\n option.optional,\n option.kind !== CommandParameterKinds.boolean && option.variadic,\n title,\n option.default\n ),\n env:\n option.env || option.env === false\n ? option.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(name)\n : false\n }\n ];\n })\n );\n}\n\nexport function applyArgsDefaults(ctx: ResolverContext): CommandArgument[] {\n return ctx.output.args.map((arg, i) => {\n const name = arg.name || `arg${i + 1}`;\n const title = arg.title || titleCase(name);\n\n return {\n ...arg,\n name,\n title,\n description:\n arg.description ||\n resolveCommandArgumentDescription(\n name,\n arg.kind,\n arg.optional,\n arg.kind !== CommandParameterKinds.boolean && arg.variadic,\n title,\n arg.default\n ),\n env: arg.name\n ? arg.env || arg.env === false\n ? arg.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(name)\n : false\n : false\n };\n });\n}\n\nexport function applyDefaults(ctx: ResolverContext) {\n ctx.output.description ??= `The ${ctx.output.title.replace(/(?:c|C)ommands?$/, \"\").trim()} executable command-line interface.`;\n}\n\nexport function resolveVirtualCommand<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n) {\n ctx.output.title ??= titleCase(ctx.input.command.name);\n ctx.output.description ??= `A collection of available ${\n ctx.output.title.replace(/(?:c|C)ommands?$/, \"\").trim() ||\n titleCase(ctx.input.command.name)\n } commands that are included in the ${getAppTitle(\n ctx.input.context\n )} command-line application.`;\n}\n\n/**\n * Merges two command parameters, giving precedence to string values in the second configuration.\n *\n * @param objA - The first command parameter object.\n * @param objB - The second command parameter object.\n * @returns The merged command parameter object.\n */\nexport const mergeCommandParameter = createDefu((obj, key, value) => {\n if (isString(obj[key]) && isString(value)) {\n if (isSetString(value)) {\n obj[key] = value;\n }\n\n return true;\n } else if (Array.isArray(obj[key]) && Array.isArray(value)) {\n if (value.length > 0) {\n obj[key] = getUniqueBy((obj[key] as unknown[]).concat(value), item =>\n isString(item) ? item : JSON.stringify(item)\n ) as (typeof obj)[typeof key];\n }\n\n return true;\n }\n\n return false;\n});\n"],"mappings":";;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;;;;;;;;;;;;AAsCX,SAAE,gCAAA,MAAA,MAAA,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AACE,QAAO,IAAI,YAAY,CAAC,eAAe,eAAI,GAAA,gBAAA,SAAA,sBAAA,UAAA,SAAA,SAAA,2BAAA,SAAA,sBAAA,UACrC,YACA,WACI,mBACA,mBAAI,GAAA,OAAA,MAAA,IAAA,UAAA,KAAA,CAAA,GAAA,SAAA,sBAAA,UACR,cACA,GAAG,SAAM,sBAAA,SAAA,YAAA,SAAA,QAAA,WAAA,MAAA,KAAA;;AAEnB,gCAAgC,SAAS;CAAC;CAAQ;CAAwB;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;;;;;AAY1E,SAAgB,kCAAY,MAAA,MAAA,WAAA,OAAA,WAAA,OAAA,OAAA,cAAA;AACxB,QAAK,KAAA,YAAA,CAAA,eAAA,cAAA,GAAA,oCAAA,SAAA,sBAAA,UACJ,YACL,8BAEE,mBAAA,GAAA,OAAA,MAAA,IAAA,UAAA,KAAA,CAAA,GAAA,SAAA,sBAAA,UACQ,cACT,GAAA,SAAA,sBAAA,SAAA,YAAA,SAAA,QAAA,WAAA,MAAA,KAAA;;AAED,kCAAkC,SAAS;CAAC;CAAQ;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AAA,CAAA;;AAEhC,cAAc,SAAI;CAAA;CAAA;CAAA;CAAA;CAAA;AAClB,SAAgB,sBAAS,KAAA;AACrB,KAAI,OAAO,UAAU,UAAI,IAAA,MAAA,QAAA,KAAA;AACzB,KAAI,OAAO,gBAAgB,6BAA6B,IAAI,OAAO,MAAM,QAAC,oBAAA,GAAA,CAAA,MAAA,IACtE,UAAU,IAAC,MAAA,QAAA,KAAA,CAAA,qCAAA,YAAA,IAAA,MAAA,QAAA,CAAA;;AAEnB,sBAAa,SAAA;CAAA;CAAA;CAAA;CAAA;CAAA;;;;;;;;AAQb,MAAO,wBAAA,WAAA,cAAA,KAAA,KAAA,UAAA;AACH,KAAC,SAAA,IAAA,KAAA,IAAA,SAAA,MAAA,EAAA;AACF,MAAA,YAAA,MAAA,CACH,KAAA,OAAA;AAEQ,SAAO;YAEF,MAAM,QAAQ,IAAI,KAAK,IAAI,MAAE,QAAA,MAAA,EAAA;AAClC,MAAI,MAAM,SAAS;;;;;AAGnB,SAAI;;AAER,QAAO;GACR;CAAC;CAAO;CAAM;CAAA;CAAA;CAAA,CAAA,CAAA"}
|
|
@@ -51,39 +51,39 @@ initialize.__type = [
|
|
|
51
51
|
"P\"w!2\"\"w#`/$"
|
|
52
52
|
];
|
|
53
53
|
async function postprocess(ctx) {
|
|
54
|
-
ctx.output.options = require_helpers.applyOptionsDefaults(ctx
|
|
55
|
-
ctx.output.args = require_helpers.applyArgsDefaults(ctx
|
|
56
|
-
ctx.output.args.forEach(__assignType((
|
|
57
|
-
const found = ctx.output.args.findIndex(__assignType((
|
|
58
|
-
"
|
|
54
|
+
ctx.output.options = require_helpers.applyOptionsDefaults(ctx);
|
|
55
|
+
ctx.output.args = require_helpers.applyArgsDefaults(ctx);
|
|
56
|
+
ctx.output.args.forEach(__assignType((arg, index) => {
|
|
57
|
+
const found = ctx.output.args.findIndex(__assignType((a) => a.name === arg.name, [
|
|
58
|
+
"a",
|
|
59
59
|
"",
|
|
60
60
|
"P\"2!\"/\""
|
|
61
61
|
]));
|
|
62
|
-
if (found !== -1 && found !== index || ctx.output.segments.some(__assignType((segment) => require_context_helpers.isDynamicPathSegment(segment) && require_context_helpers.getDynamicPathSegmentName(segment) ===
|
|
62
|
+
if (found !== -1 && found !== index || ctx.output.segments.some(__assignType((segment) => require_context_helpers.isDynamicPathSegment(segment) && require_context_helpers.getDynamicPathSegmentName(segment) === arg.name, [
|
|
63
63
|
"segment",
|
|
64
64
|
"",
|
|
65
65
|
"P\"2!\"/\""
|
|
66
66
|
]))) {
|
|
67
|
-
|
|
67
|
+
arg.name += `_${ctx.output.segments.filter(__assignType((segment) => require_context_helpers.isDynamicPathSegment(segment) && require_context_helpers.getDynamicPathSegmentName(segment).replace(/_\d+$/, "") === arg.name, [
|
|
68
68
|
"segment",
|
|
69
69
|
"",
|
|
70
70
|
"P\"2!\"/\""
|
|
71
|
-
])).length + ctx.output.args.filter(__assignType((
|
|
72
|
-
"
|
|
71
|
+
])).length + ctx.output.args.filter(__assignType((a) => a.name.replace(/_\d+$/, "") === arg.name, [
|
|
72
|
+
"a",
|
|
73
73
|
"",
|
|
74
74
|
"P\"2!\"/\""
|
|
75
75
|
])).length}`;
|
|
76
|
-
|
|
76
|
+
arg.env = arg.name ? arg.env || arg.env === false ? arg.env : ctx.input.context.config.autoAssignEnv ? (0, __stryke_string_format_constant_case.constantCase)(arg.name) : false : false;
|
|
77
77
|
}
|
|
78
78
|
}, [
|
|
79
|
-
"
|
|
79
|
+
"arg",
|
|
80
80
|
"index",
|
|
81
81
|
"",
|
|
82
82
|
"P\"2!\"2\"\"/#"
|
|
83
83
|
]));
|
|
84
84
|
require_helpers.applyDefaults(ctx);
|
|
85
85
|
if (ctx.input.context.env) {
|
|
86
|
-
if ((0, __stryke_type_checks_is_set_object.isSetObject)(ctx.output.options)) Object.values(ctx.output.options).filter(__assignType((option) => option.env
|
|
86
|
+
if ((0, __stryke_type_checks_is_set_object.isSetObject)(ctx.output.options)) Object.values(ctx.output.options).filter(__assignType((option) => Boolean(option.env), [
|
|
87
87
|
"option",
|
|
88
88
|
"",
|
|
89
89
|
"P\"2!\"/\""
|
|
@@ -114,7 +114,7 @@ async function postprocess(ctx) {
|
|
|
114
114
|
"",
|
|
115
115
|
"P\"2!\"/\""
|
|
116
116
|
]));
|
|
117
|
-
ctx.output.args.filter(__assignType((arg) => arg.env
|
|
117
|
+
ctx.output.args.filter(__assignType((arg) => Boolean(arg.env), [
|
|
118
118
|
"arg",
|
|
119
119
|
"",
|
|
120
120
|
"P\"2!\"/\""
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.cjs","names":[],"sources":["../../src/resolver/resolve.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport { ReflectionVisibility } from \"@powerlines/deepkit/vendor/type\";\nimport { resolveModule } from \"@powerlines/plugin-esbuild/helpers/resolve\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { getDefaultOptions } from \"../helpers/utilities\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport { extractType } from \"../plugin-utils/deepkit\";\nimport type { CommandModule, CommandTree, Context } from \"../types\";\nimport { resolveFromBytecode } from \"./deepkit\";\nimport {\n applyArgsDefaults,\n applyDefaults,\n applyOptionsDefaults,\n resolveVirtualCommand\n} from \"./helpers\";\nimport { resolveFromExports } from \"./module\";\nimport type { ResolverContext, ResolverInput } from \"./types\";\n\nasync function initialize<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<ResolverContext> {\n const { context, command, parent } = input;\n\n const title =\n command.title ||\n `${\n parent?.title\n ? `${\n parent.isVirtual\n ? parent.title.replace(/(?:c|C)ommands?$/, \"\").trim()\n : parent.title\n } - `\n : \"\"\n }${titleCase(command.name)}${command.isVirtual ? \" Commands\" : \"\"}`;\n\n const output = {\n alias: [],\n icon: parent?.icon,\n ...command,\n title,\n options: getDefaultOptions(context, command),\n args: [],\n parent: parent ?? null,\n children: {}\n } as CommandTree;\n\n const result: ResolverContext = {\n input,\n output\n };\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for user-defined command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n result.module = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n }\n\n return result;\n}\n\nasync function postprocess<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n): Promise<CommandTree> {\n ctx.output.options = applyOptionsDefaults(ctx.output.options);\n ctx.output.args = applyArgsDefaults(ctx.output.args);\n\n // Ensure unique argument names by appending an index suffix to duplicates\n ctx.output.args.forEach((argument, index) => {\n const found = ctx.output.args.findIndex(arg => arg.name === argument.name);\n if (\n (found !== -1 && found !== index) ||\n ctx.output.segments.some(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment) === argument.name\n )\n ) {\n argument.name += `_${\n ctx.output.segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(/_\\d+$/, \"\") ===\n argument.name\n ).length +\n ctx.output.args.filter(\n arg => arg.name.replace(/_\\d+$/, \"\") === argument.name\n ).length\n }`;\n argument.env = constantCase(argument.name);\n }\n });\n\n applyDefaults(ctx);\n\n if (ctx.input.context.env) {\n if (isSetObject(ctx.output.options)) {\n Object.values(ctx.output.options)\n .filter(option => option.env !== false)\n .forEach(option => {\n ctx.input.context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type: extractType(option),\n default: option.default,\n tags: {\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n ctx.output.args\n .filter(arg => arg.env !== false)\n .forEach(arg =>\n ctx.input.context.env.types.env.addProperty({\n name: arg.env as string,\n optional: arg.optional ? true : undefined,\n description: arg.description,\n visibility: ReflectionVisibility.public,\n type: extractType(arg),\n default: arg.default,\n tags: {\n alias: arg.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n })\n );\n }\n\n for (const input of ctx.input.context.inputs.filter(\n input =>\n input.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n ctx.input.command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n ).length +\n 1 &&\n input.segments\n .slice(0, ctx.input.command.segments.length)\n .every((value, index) => value === ctx.input.command.segments[index])\n )) {\n ctx.output.children[input.name] = await resolve<TContext>({\n context: ctx.input.context,\n command: input,\n parent: ctx.output\n });\n }\n\n return ctx.output;\n}\n\n/**\n * Resolves a command tree from the given resolver input.\n *\n * @param input - The resolver input containing the context, command, and optional parent command tree.\n * @returns A promise that resolves to the resolved command tree.\n */\nexport async function resolve<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<CommandTree> {\n const ctx = await initialize<TContext>(input);\n\n if (!ctx.output.isVirtual) {\n await resolveFromExports(ctx);\n resolveFromBytecode(ctx);\n } else {\n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AA"}
|
|
1
|
+
{"version":3,"file":"resolve.cjs","names":[],"sources":["../../src/resolver/resolve.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { esbuildPlugin } from \"@powerlines/deepkit/esbuild-plugin\";\nimport { ReflectionVisibility } from \"@powerlines/deepkit/vendor/type\";\nimport { resolveModule } from \"@powerlines/plugin-esbuild/helpers/resolve\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { getDefaultOptions } from \"../helpers/utilities\";\nimport {\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"../plugin-utils/context-helpers\";\nimport { extractType } from \"../plugin-utils/deepkit\";\nimport type { CommandModule, CommandTree, Context } from \"../types\";\nimport { resolveFromBytecode } from \"./deepkit\";\nimport {\n applyArgsDefaults,\n applyDefaults,\n applyOptionsDefaults,\n resolveVirtualCommand\n} from \"./helpers\";\nimport { resolveFromExports } from \"./module\";\nimport type { ResolverContext, ResolverInput } from \"./types\";\n\nasync function initialize<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<ResolverContext> {\n const { context, command, parent } = input;\n\n const title =\n command.title ||\n `${\n parent?.title\n ? `${\n parent.isVirtual\n ? parent.title.replace(/(?:c|C)ommands?$/, \"\").trim()\n : parent.title\n } - `\n : \"\"\n }${titleCase(command.name)}${command.isVirtual ? \" Commands\" : \"\"}`;\n\n const output = {\n alias: [],\n icon: parent?.icon,\n ...command,\n title,\n options: getDefaultOptions(context, command),\n args: [],\n parent: parent ?? null,\n children: {}\n } as CommandTree;\n\n const result: ResolverContext = {\n input,\n output\n };\n\n if (!command.isVirtual) {\n if (\n !command.entry.input?.file ||\n !context.fs.existsSync(command.entry.input.file)\n ) {\n throw new Error(\n `${\n !command.entry.input?.file ? \"Missing\" : \"Non-existent\"\n } command entry file for \"${command.name}\"`\n );\n }\n\n context.debug(\n `Adding reflection for user-defined command: ${command.id} (file: ${\n command.entry.input.file\n })`\n );\n\n result.module = await resolveModule<CommandModule>(\n context,\n command.entry.input,\n {\n plugins: [\n esbuildPlugin(context, {\n reflection: \"default\",\n reflectionLevel: \"verbose\"\n })\n ]\n }\n );\n }\n\n return result;\n}\n\nasync function postprocess<TContext extends Context = Context>(\n ctx: ResolverContext<TContext>\n): Promise<CommandTree> {\n ctx.output.options = applyOptionsDefaults(ctx);\n ctx.output.args = applyArgsDefaults(ctx);\n\n // Ensure unique argument names by appending an index suffix to duplicates\n ctx.output.args.forEach((arg, index) => {\n const found = ctx.output.args.findIndex(a => a.name === arg.name);\n if (\n (found !== -1 && found !== index) ||\n ctx.output.segments.some(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment) === arg.name\n )\n ) {\n arg.name += `_${\n ctx.output.segments.filter(\n segment =>\n isDynamicPathSegment(segment) &&\n getDynamicPathSegmentName(segment).replace(/_\\d+$/, \"\") === arg.name\n ).length +\n ctx.output.args.filter(a => a.name.replace(/_\\d+$/, \"\") === arg.name)\n .length\n }`;\n arg.env = arg.name\n ? arg.env || arg.env === false\n ? arg.env\n : ctx.input.context.config.autoAssignEnv\n ? constantCase(arg.name)\n : false\n : false;\n }\n });\n\n applyDefaults(ctx);\n\n if (ctx.input.context.env) {\n if (isSetObject(ctx.output.options)) {\n Object.values(ctx.output.options)\n .filter(option => Boolean(option.env))\n .forEach(option => {\n ctx.input.context.env.types.env.addProperty({\n name: option.env as string,\n optional: option.optional ? true : undefined,\n description: option.description,\n visibility: ReflectionVisibility.public,\n type: extractType(option),\n default: option.default,\n tags: {\n title: option.title,\n alias: option.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n });\n });\n }\n\n ctx.output.args\n .filter(arg => Boolean(arg.env))\n .forEach(arg =>\n ctx.input.context.env.types.env.addProperty({\n name: arg.env as string,\n optional: arg.optional ? true : undefined,\n description: arg.description,\n visibility: ReflectionVisibility.public,\n type: extractType(arg),\n default: arg.default,\n tags: {\n alias: arg.alias\n .filter(alias => alias.length > 1)\n .map(alias => constantCase(alias)),\n domain: \"cli\"\n }\n })\n );\n }\n\n for (const input of ctx.input.context.inputs.filter(\n input =>\n input.segments.filter(segment => !isDynamicPathSegment(segment))\n .length ===\n ctx.input.command.segments.filter(\n segment => !isDynamicPathSegment(segment)\n ).length +\n 1 &&\n input.segments\n .slice(0, ctx.input.command.segments.length)\n .every((value, index) => value === ctx.input.command.segments[index])\n )) {\n ctx.output.children[input.name] = await resolve<TContext>({\n context: ctx.input.context,\n command: input,\n parent: ctx.output\n });\n }\n\n return ctx.output;\n}\n\n/**\n * Resolves a command tree from the given resolver input.\n *\n * @param input - The resolver input containing the context, command, and optional parent command tree.\n * @returns A promise that resolves to the resolved command tree.\n */\nexport async function resolve<TContext extends Context = Context>(\n input: ResolverInput<TContext>\n): Promise<CommandTree> {\n const ctx = await initialize<TContext>(input);\n\n if (!ctx.output.isVirtual) {\n await resolveFromExports(ctx);\n resolveFromBytecode(ctx);\n } else {\n resolveVirtualCommand(ctx);\n }\n\n return postprocess(ctx);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,SAAS,aAAa,IAAI,MAAM;;AAE5B,QAAO;;AA+BX,eAAe,WAAI,OAAA;CACf,MAAM,EAAE,SAAG,SAAA,WAAA;CACX,MAAM,QAAQ,QAAI,SACd,GAAG,QAAQ,QACL,GAAG,OAAC,YACA,OAAO,MAAM,QAAQ,oBAAM,GAAA,CAAA,MAAA,GA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