@shell-shock/core 0.17.7 → 0.17.8
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/_virtual/_rolldown/runtime.cjs +1 -29
- package/dist/api.cjs +1 -95
- package/dist/api.d.cts +52 -4
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts +52 -4
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +1 -92
- package/dist/api.mjs.map +1 -1
- package/dist/components/command-validation-logic.cjs +1 -292
- package/dist/components/command-validation-logic.mjs +1 -289
- package/dist/components/command-validation-logic.mjs.map +1 -1
- package/dist/components/docs.cjs +1 -265
- package/dist/components/docs.d.cts.map +1 -1
- package/dist/components/docs.d.mts.map +1 -1
- package/dist/components/docs.mjs +1 -256
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/exec-builtin.cjs +13 -429
- package/dist/components/exec-builtin.mjs +13 -425
- package/dist/components/exec-builtin.mjs.map +1 -1
- package/dist/components/helpers.cjs +1 -120
- package/dist/components/helpers.mjs +1 -112
- package/dist/components/helpers.mjs.map +1 -1
- package/dist/components/index.cjs +1 -58
- package/dist/components/index.mjs +1 -10
- package/dist/components/options-parser-logic.cjs +5 -960
- package/dist/components/options-parser-logic.d.cts +1 -1
- package/dist/components/options-parser-logic.mjs +5 -945
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/state-builtin.cjs +8 -629
- package/dist/components/state-builtin.d.cts.map +1 -1
- package/dist/components/state-builtin.d.mts.map +1 -1
- package/dist/components/state-builtin.mjs +8 -622
- package/dist/components/state-builtin.mjs.map +1 -1
- package/dist/components/usage.cjs +1 -117
- package/dist/components/usage.mjs +1 -114
- package/dist/components/usage.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +33 -838
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/components/utils-builtin.mjs +33 -828
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/config.cjs +1 -31
- package/dist/config.mjs +1 -29
- package/dist/config.mjs.map +1 -1
- package/dist/contexts/command.cjs +1 -26
- package/dist/contexts/command.mjs +1 -23
- package/dist/contexts/command.mjs.map +1 -1
- package/dist/contexts/index.cjs +1 -9
- package/dist/contexts/index.mjs +1 -4
- package/dist/contexts/options.cjs +1 -63
- package/dist/contexts/options.mjs +1 -58
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/automd.cjs +1 -71
- package/dist/helpers/automd.mjs +1 -70
- package/dist/helpers/automd.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +1 -23
- package/dist/helpers/docs-helpers.mjs +1 -22
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/paths.cjs +1 -137
- package/dist/helpers/paths.mjs +1 -133
- package/dist/helpers/paths.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +1 -113
- package/dist/helpers/persistence.mjs +1 -110
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +1 -59
- package/dist/helpers/update-package-json.mjs +1 -57
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.cjs +1 -95
- package/dist/helpers/utilities.mjs +1 -93
- package/dist/helpers/utilities.mjs.map +1 -1
- package/dist/helpers/validations.cjs +1 -71
- package/dist/helpers/validations.mjs +1 -71
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +1 -52
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -7
- package/dist/plugin-utils/compute-bin.cjs +1 -50
- package/dist/plugin-utils/compute-bin.mjs +1 -49
- package/dist/plugin-utils/compute-bin.mjs.map +1 -1
- package/dist/plugin-utils/context-helpers.cjs +1 -231
- package/dist/plugin-utils/context-helpers.mjs +1 -221
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +1 -71
- package/dist/plugin-utils/deepkit.mjs +1 -69
- package/dist/plugin-utils/deepkit.mjs.map +1 -1
- package/dist/plugin-utils/description-helpers.cjs +2 -111
- package/dist/plugin-utils/description-helpers.mjs +2 -107
- package/dist/plugin-utils/description-helpers.mjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.cjs +1 -117
- package/dist/plugin-utils/get-command-tree.mjs +1 -114
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/index.cjs +1 -39
- package/dist/plugin-utils/index.mjs +1 -10
- package/dist/plugin-utils/reflect.cjs +1 -52
- package/dist/plugin-utils/reflect.mjs +1 -52
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.cjs +1 -64
- package/dist/plugin-utils/traverse-command-tree.mjs +1 -62
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.cjs +1 -93
- package/dist/plugin-utils/type-checks.mjs +1 -88
- package/dist/plugin-utils/type-checks.mjs.map +1 -1
- package/dist/plugin.cjs +4 -429
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +4 -423
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +1 -135
- package/dist/resolver/deepkit.mjs +1 -134
- package/dist/resolver/deepkit.mjs.map +1 -1
- package/dist/resolver/helpers.cjs +1 -173
- package/dist/resolver/helpers.mjs +1 -168
- package/dist/resolver/helpers.mjs.map +1 -1
- package/dist/resolver/module.cjs +1 -145
- package/dist/resolver/module.mjs +1 -144
- package/dist/resolver/module.mjs.map +1 -1
- package/dist/resolver/resolve.cjs +1 -222
- package/dist/resolver/resolve.mjs +1 -221
- package/dist/resolver/resolve.mjs.map +1 -1
- package/dist/types/command.cjs +1 -441
- package/dist/types/command.mjs +1 -405
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +1 -144
- package/dist/types/config.d.cts +3 -2
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +3 -2
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +1 -138
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +1 -37
- package/dist/types/context.d.cts +3 -2
- package/dist/types/context.d.cts.map +1 -1
- package/dist/types/context.d.mts +3 -2
- package/dist/types/context.d.mts.map +1 -1
- package/dist/types/context.mjs +1 -34
- package/dist/types/context.mjs.map +1 -1
- package/dist/types/env.cjs +1 -52
- package/dist/types/env.mjs +1 -50
- package/dist/types/env.mjs.map +1 -1
- package/dist/types/index.cjs +1 -49
- package/dist/types/index.mjs +1 -6
- package/dist/types/options.cjs +1 -12
- package/dist/types/options.mjs +1 -10
- package/package.json +23 -23
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-builtin.d.cts","names":[],"sources":["../../src/components/state-builtin.tsx"],"mappings":";;;;iBA6CgB,qBAAA,CAAA,GAAqB,iBAAA,CAAA,QAAA;;;AAArC;iBA2FgB,aAAA,CAAA,GAAa,iBAAA,CAAA,QAAA;AAAA,iBAqBb,gBAAA,CAAA,GAAgB,iBAAA,CAAA,QAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"state-builtin.d.cts","names":[],"sources":["../../src/components/state-builtin.tsx"],"mappings":";;;;iBA6CgB,qBAAA,CAAA,GAAqB,iBAAA,CAAA,QAAA;;;AAArC;iBA2FgB,aAAA,CAAA,GAAa,iBAAA,CAAA,QAAA;AAAA,iBAqBb,gBAAA,CAAA,GAAgB,iBAAA,CAAA,QAAA;AAAA,UAiUf,iBAAA,SAA0B,IAAA,CACzC,gBAAA;AAvVF;;;AAAA,iBA8VgB,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAiB,iBAAA,CAAA,QAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state-builtin.d.mts","names":[],"sources":["../../src/components/state-builtin.tsx"],"mappings":";;;;iBA6CgB,qBAAA,CAAA,GAAqB,iBAAA,CAAA,QAAA;;;AAArC;iBA2FgB,aAAA,CAAA,GAAa,iBAAA,CAAA,QAAA;AAAA,iBAqBb,gBAAA,CAAA,GAAgB,iBAAA,CAAA,QAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"state-builtin.d.mts","names":[],"sources":["../../src/components/state-builtin.tsx"],"mappings":";;;;iBA6CgB,qBAAA,CAAA,GAAqB,iBAAA,CAAA,QAAA;;;AAArC;iBA2FgB,aAAA,CAAA,GAAa,iBAAA,CAAA,QAAA;AAAA,iBAqBb,gBAAA,CAAA,GAAgB,iBAAA,CAAA,QAAA;AAAA,UAiUf,iBAAA,SAA0B,IAAA,CACzC,gBAAA;AAvVF;;;AAAA,iBA8VgB,YAAA,CAAa,KAAA,EAAO,iBAAA,GAAiB,iBAAA,CAAA,QAAA"}
|
|
@@ -1,578 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { computedOptions } from "../contexts/options.mjs";
|
|
3
|
-
import "../plugin-utils/index.mjs";
|
|
4
|
-
import { OptionsMember, OptionsParserLogic } from "./options-parser-logic.mjs";
|
|
5
|
-
import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
6
|
-
import defu$1 from "defu";
|
|
7
|
-
import { For, Show, code, computed, splitProps } from "@alloy-js/core";
|
|
8
|
-
import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
|
|
9
|
-
import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
|
|
10
|
-
import { FunctionDeclaration, InterfaceDeclaration, InterfaceMember, TypeDeclaration, VarDeclaration } from "@alloy-js/typescript";
|
|
11
|
-
import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
12
|
-
import { TSDoc, TSDocInternal, TSDocLink, TSDocParam, TSDocRemarks, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
13
|
-
|
|
14
|
-
//#region src/components/state-builtin.tsx
|
|
15
|
-
const __ΩOmit = [
|
|
16
|
-
"T",
|
|
17
|
-
"K",
|
|
18
|
-
() => __ΩPick,
|
|
19
|
-
() => __ΩExclude,
|
|
20
|
-
"Omit",
|
|
21
|
-
"b!b\"e!!e!!ge!\"o$#o##w%y"
|
|
22
|
-
];
|
|
23
|
-
const __ΩPick = [
|
|
24
|
-
"T",
|
|
25
|
-
"K",
|
|
26
|
-
"Pick",
|
|
27
|
-
"l+e#!e\"!fRb!b\"Pde\"\"N#!w#y"
|
|
28
|
-
];
|
|
29
|
-
const __ΩExclude = [
|
|
30
|
-
"T",
|
|
31
|
-
"U",
|
|
32
|
-
"Exclude",
|
|
33
|
-
"l6!Re$!RPe#!e$\"qk#%QRb!b\"Pde\"!p)w#y"
|
|
34
|
-
];
|
|
35
|
-
function __assignType(fn, args) {
|
|
36
|
-
fn.__type = args;
|
|
37
|
-
return fn;
|
|
38
|
-
}
|
|
39
|
-
function GlobalTypeDefinitions() {
|
|
40
|
-
const context = (usePowerlines.Ω = [["Context", "\"w!"]], usePowerlines());
|
|
41
|
-
const options = computed(() => computedOptions(context.options));
|
|
42
|
-
return [
|
|
43
|
-
createComponent(TSDoc, { get heading() {
|
|
44
|
-
return `An object representing the global options available for every command in the ${getAppTitle(context, true)} command-line application.`;
|
|
45
|
-
} }),
|
|
46
|
-
createComponent(InterfaceDeclaration, {
|
|
47
|
-
"export": true,
|
|
48
|
-
name: "GlobalOptions",
|
|
49
|
-
get children() {
|
|
50
|
-
return createComponent(For, {
|
|
51
|
-
get each() {
|
|
52
|
-
return Object.values(options.value);
|
|
53
|
-
},
|
|
54
|
-
hardline: true,
|
|
55
|
-
get children() {
|
|
56
|
-
return __assignType((option) => createComponent(OptionsMember, { option }), [
|
|
57
|
-
"option",
|
|
58
|
-
"",
|
|
59
|
-
"P\"2!\"/\""
|
|
60
|
-
]);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}),
|
|
65
|
-
createComponent(Spacing, {}),
|
|
66
|
-
createComponent(TSDoc, { heading: "The context object for the current command execution, containing the command path and segments." }),
|
|
67
|
-
createComponent(InterfaceDeclaration, {
|
|
68
|
-
"export": true,
|
|
69
|
-
name: "CommandContext",
|
|
70
|
-
typeParameters: [{
|
|
71
|
-
name: "THandler",
|
|
72
|
-
extends: "(...params: any[]) => any",
|
|
73
|
-
default: "any"
|
|
74
|
-
}],
|
|
75
|
-
get children() {
|
|
76
|
-
return [
|
|
77
|
-
createComponent(TSDoc, { get heading() {
|
|
78
|
-
return `The full command path as a string. For example, if the user runs \`${getAppBin(context)} foo bar\`, this would be \`foo bar\`. This is useful for commands that need to know their full invocation path, such as for help text or for commands that have dynamic behavior based on their position in the command hierarchy.`;
|
|
79
|
-
} }),
|
|
80
|
-
createComponent(InterfaceMember, {
|
|
81
|
-
name: "path",
|
|
82
|
-
type: "string"
|
|
83
|
-
}),
|
|
84
|
-
createComponent(Spacing, {}),
|
|
85
|
-
createComponent(TSDoc, { get heading() {
|
|
86
|
-
return `An array of command path segments. For example, if the user runs \`${getAppBin(context)} foo bar\`, this would be \`["foo", "bar"]\`. This is useful for commands that need to know their individual path segments, such as for dynamic routing or for commands that have behavior based on specific segments in the command hierarchy.`;
|
|
87
|
-
} }),
|
|
88
|
-
createComponent(InterfaceMember, {
|
|
89
|
-
name: "segments",
|
|
90
|
-
type: "string[]"
|
|
91
|
-
}),
|
|
92
|
-
createComponent(Spacing, {}),
|
|
93
|
-
createComponent(TSDoc, { heading: `The parameters for the current command's handler function.` }),
|
|
94
|
-
createComponent(InterfaceMember, {
|
|
95
|
-
name: "params",
|
|
96
|
-
type: "Parameters<THandler>"
|
|
97
|
-
})
|
|
98
|
-
];
|
|
99
|
-
}
|
|
100
|
-
}),
|
|
101
|
-
createComponent(Spacing, {}),
|
|
102
|
-
createComponent(TypeDeclaration, {
|
|
103
|
-
"export": true,
|
|
104
|
-
name: "GlobalContextStatus",
|
|
105
|
-
children: code`"initializing" | "preparing" | "executing" | "completed"`
|
|
106
|
-
}),
|
|
107
|
-
createComponent(Spacing, {}),
|
|
108
|
-
createComponent(TSDoc, { get heading() {
|
|
109
|
-
return `The state object for the ${getAppTitle(context)} application context.`;
|
|
110
|
-
} }),
|
|
111
|
-
createComponent(InterfaceDeclaration, {
|
|
112
|
-
"export": true,
|
|
113
|
-
name: "GlobalContextState",
|
|
114
|
-
get children() {
|
|
115
|
-
return [
|
|
116
|
-
createComponent(TSDoc, { heading: "The unique identifier for the current execution context." }),
|
|
117
|
-
createComponent(InterfaceMember, {
|
|
118
|
-
name: "executionId",
|
|
119
|
-
type: "string"
|
|
120
|
-
}),
|
|
121
|
-
createComponent(Spacing, {}),
|
|
122
|
-
createComponent(TSDoc, { heading: "The status of the current execution context." }),
|
|
123
|
-
createComponent(InterfaceMember, {
|
|
124
|
-
name: "status",
|
|
125
|
-
type: "GlobalContextStatus"
|
|
126
|
-
}),
|
|
127
|
-
createComponent(Spacing, {}),
|
|
128
|
-
createComponent(TSDoc, { heading: "Indicates whether the current execution context has encountered an error." }),
|
|
129
|
-
createComponent(InterfaceMember, {
|
|
130
|
-
name: "isError",
|
|
131
|
-
type: "boolean"
|
|
132
|
-
}),
|
|
133
|
-
createComponent(Spacing, {}),
|
|
134
|
-
createComponent(TSDoc, { heading: "A map containing arbitrary data associated with the current execution context." }),
|
|
135
|
-
createComponent(InterfaceMember, {
|
|
136
|
-
name: "meta",
|
|
137
|
-
type: "Map<string, unknown>"
|
|
138
|
-
})
|
|
139
|
-
];
|
|
140
|
-
}
|
|
141
|
-
}),
|
|
142
|
-
createComponent(Spacing, {}),
|
|
143
|
-
createComponent(TSDoc, { get heading() {
|
|
144
|
-
return `The context object for the ${getAppTitle(context)} application.`;
|
|
145
|
-
} }),
|
|
146
|
-
createComponent(InterfaceDeclaration, {
|
|
147
|
-
"export": true,
|
|
148
|
-
name: "GlobalContext",
|
|
149
|
-
get children() {
|
|
150
|
-
return [
|
|
151
|
-
createComponent(TSDoc, { heading: "The global options shared across all commands in the application." }),
|
|
152
|
-
createComponent(InterfaceMember, {
|
|
153
|
-
name: "options",
|
|
154
|
-
type: "GlobalOptions"
|
|
155
|
-
}),
|
|
156
|
-
createComponent(Spacing, {}),
|
|
157
|
-
createComponent(TSDoc, { heading: "The raw command-line arguments passed to the application." }),
|
|
158
|
-
createComponent(InterfaceMember, {
|
|
159
|
-
name: "inputArgs",
|
|
160
|
-
type: "string[]"
|
|
161
|
-
}),
|
|
162
|
-
createComponent(Spacing, {}),
|
|
163
|
-
createComponent(TSDoc, { heading: "The state of the current execution context." }),
|
|
164
|
-
createComponent(InterfaceMember, {
|
|
165
|
-
name: "state",
|
|
166
|
-
type: "GlobalContextState"
|
|
167
|
-
})
|
|
168
|
-
];
|
|
169
|
-
}
|
|
170
|
-
})
|
|
171
|
-
];
|
|
172
|
-
}
|
|
173
|
-
GlobalTypeDefinitions.__type = ["GlobalTypeDefinitions", "P\"/!"];
|
|
174
|
-
/**
|
|
175
|
-
* Generates utilities for detecting terminal color support.
|
|
176
|
-
*/
|
|
177
|
-
function ArgsUtilities() {
|
|
178
|
-
return [createComponent(TSDoc, {
|
|
179
|
-
heading: "Retrieves the command-line arguments from Deno or Node.js environments.",
|
|
180
|
-
get children() {
|
|
181
|
-
return [
|
|
182
|
-
createComponent(TSDocRemarks, { children: `This function is only intended for internal use. Please use \`useArgs()\` instead.` }),
|
|
183
|
-
createComponent(Spacing, {}),
|
|
184
|
-
createComponent(TSDocInternal, {}),
|
|
185
|
-
createComponent(Spacing, {}),
|
|
186
|
-
createComponent(TSDocReturns, { children: `An array of command-line arguments from Deno or Node.js environments.` })
|
|
187
|
-
];
|
|
188
|
-
}
|
|
189
|
-
}), createComponent(FunctionDeclaration, {
|
|
190
|
-
name: "getInputArgs",
|
|
191
|
-
returnType: "string[]",
|
|
192
|
-
children: code`return ((globalThis as { Deno?: { args: string[] } })?.Deno?.args ?? process.argv ?? []) as string[];`
|
|
193
|
-
})];
|
|
194
|
-
}
|
|
195
|
-
ArgsUtilities.__type = [
|
|
196
|
-
"ArgsUtilities",
|
|
197
|
-
"Generates utilities for detecting terminal color support.",
|
|
198
|
-
"P\"/!?\""
|
|
199
|
-
];
|
|
200
|
-
function ContextUtilities() {
|
|
201
|
-
const context = (usePowerlines.Ω = [["Context", "\"w!"]], usePowerlines());
|
|
202
|
-
const options = computed(() => Object.fromEntries(context.options.map(__assignType((option) => [option.name, option], [
|
|
203
|
-
"option",
|
|
204
|
-
"",
|
|
205
|
-
"P\"2!\"/\""
|
|
206
|
-
]))));
|
|
207
|
-
return [
|
|
208
|
-
createComponent(Spacing, {}),
|
|
209
|
-
createComponent(TSDoc, {
|
|
210
|
-
get heading() {
|
|
211
|
-
return `The global ${getAppTitle(context)} application context store instance.`;
|
|
212
|
-
},
|
|
213
|
-
get children() {
|
|
214
|
-
return createComponent(TSDocInternal, {});
|
|
215
|
-
}
|
|
216
|
-
}),
|
|
217
|
-
createComponent(VarDeclaration, {
|
|
218
|
-
"export": true,
|
|
219
|
-
"const": true,
|
|
220
|
-
name: "unstable_globalStore",
|
|
221
|
-
children: code` new AsyncLocalStorage<GlobalContext>({ name: "globalStore" }); `
|
|
222
|
-
}),
|
|
223
|
-
createComponent(Spacing, {}),
|
|
224
|
-
createComponent(TSDoc, {
|
|
225
|
-
get heading() {
|
|
226
|
-
return `Get the ${getAppTitle(context)} application context for the current application.`;
|
|
227
|
-
},
|
|
228
|
-
get children() {
|
|
229
|
-
return createComponent(TSDocReturns, { get children() {
|
|
230
|
-
return `The ${getAppTitle(context)} application context for the current application or undefined if the context is not available.`;
|
|
231
|
-
} });
|
|
232
|
-
}
|
|
233
|
-
}),
|
|
234
|
-
createComponent(FunctionDeclaration, {
|
|
235
|
-
"export": true,
|
|
236
|
-
name: "useGlobal",
|
|
237
|
-
returnType: "GlobalContext",
|
|
238
|
-
children: code`return unstable_globalStore.getStore() as GlobalContext;`
|
|
239
|
-
}),
|
|
240
|
-
createComponent(Spacing, {}),
|
|
241
|
-
createComponent(TSDoc, {
|
|
242
|
-
get heading() {
|
|
243
|
-
return `A utility hook function to get the command-line arguments from the ${getAppTitle(context)} application context.`;
|
|
244
|
-
},
|
|
245
|
-
get children() {
|
|
246
|
-
return createComponent(TSDocReturns, { children: "An array of command-line arguments from the application context." });
|
|
247
|
-
}
|
|
248
|
-
}),
|
|
249
|
-
createComponent(FunctionDeclaration, {
|
|
250
|
-
"export": true,
|
|
251
|
-
name: "useArgs",
|
|
252
|
-
returnType: "string[]",
|
|
253
|
-
children: code`return useGlobal()?.inputArgs ?? getInputArgs();`
|
|
254
|
-
}),
|
|
255
|
-
createComponent(Spacing, {}),
|
|
256
|
-
createComponent(TSDoc, {
|
|
257
|
-
get heading() {
|
|
258
|
-
return `A utility hook function to get the command-line global options from the ${getAppTitle(context)} application context.`;
|
|
259
|
-
},
|
|
260
|
-
get children() {
|
|
261
|
-
return createComponent(TSDocReturns, { children: "An object containing the global options from the application context." });
|
|
262
|
-
}
|
|
263
|
-
}),
|
|
264
|
-
createComponent(FunctionDeclaration, {
|
|
265
|
-
"export": true,
|
|
266
|
-
name: "useGlobalOptions",
|
|
267
|
-
returnType: "GlobalOptions",
|
|
268
|
-
children: code`return useGlobal()?.options ?? {};`
|
|
269
|
-
}),
|
|
270
|
-
createComponent(Spacing, {}),
|
|
271
|
-
createComponent(TSDoc, {
|
|
272
|
-
get heading() {
|
|
273
|
-
return `A utility hook function to get the state of the ${getAppTitle(context)} application context.`;
|
|
274
|
-
},
|
|
275
|
-
get children() {
|
|
276
|
-
return createComponent(TSDocReturns, { children: "The state of the application context." });
|
|
277
|
-
}
|
|
278
|
-
}),
|
|
279
|
-
createComponent(FunctionDeclaration, {
|
|
280
|
-
"export": true,
|
|
281
|
-
name: "useState",
|
|
282
|
-
returnType: "GlobalContextState",
|
|
283
|
-
children: code`return useGlobal()?.state;`
|
|
284
|
-
}),
|
|
285
|
-
createComponent(Spacing, {}),
|
|
286
|
-
createComponent(TSDoc, {
|
|
287
|
-
get heading() {
|
|
288
|
-
return `A utility function to update the state of the ${getAppTitle(context)} application context.`;
|
|
289
|
-
},
|
|
290
|
-
get children() {
|
|
291
|
-
return [
|
|
292
|
-
createComponent(TSDocRemarks, { children: `This function will throw an error if the global context is not available, so it should only be used within a valid context scope, such as within a command handler or within the \`withGlobal()\` function.` }),
|
|
293
|
-
createComponent(Spacing, {}),
|
|
294
|
-
createComponent(TSDocParam, {
|
|
295
|
-
name: "update",
|
|
296
|
-
children: `The new state or a function that receives the previous state and returns the new state. This allows for both direct state updates and functional updates based on the previous state.`
|
|
297
|
-
})
|
|
298
|
-
];
|
|
299
|
-
}
|
|
300
|
-
}),
|
|
301
|
-
createComponent(FunctionDeclaration, {
|
|
302
|
-
"export": true,
|
|
303
|
-
name: "setState",
|
|
304
|
-
parameters: [{
|
|
305
|
-
name: "update",
|
|
306
|
-
type: "Partial<GlobalContextState> | ((prev: GlobalContextState) => GlobalContextState)"
|
|
307
|
-
}],
|
|
308
|
-
get children() {
|
|
309
|
-
return code`const prev = useGlobal()?.state;
|
|
1
|
+
import{getAppBin as e,getAppTitle as t}from"../plugin-utils/context-helpers.mjs";import{computedOptions as n}from"../contexts/options.mjs";import"../plugin-utils/index.mjs";import{OptionsMember as r,OptionsParserLogic as i}from"./options-parser-logic.mjs";import{createComponent as a,createIntrinsic as o,mergeProps as s}from"@alloy-js/core/jsx-runtime";import c from"defu";import{For as l,Show as u,code as d,computed as f,splitProps as p}from"@alloy-js/core";import{Spacing as m}from"@powerlines/plugin-alloy/core/components/spacing";import{usePowerlines as h}from"@powerlines/plugin-alloy/core/contexts/context";import{FunctionDeclaration as g,InterfaceDeclaration as _,InterfaceMember as v,TypeDeclaration as y,VarDeclaration as b}from"@alloy-js/typescript";import{BuiltinFile as x}from"@powerlines/plugin-alloy/typescript/components/builtin-file";import{TSDoc as S,TSDocInternal as C,TSDocLink as w,TSDocParam as T,TSDocRemarks as E,TSDocReturns as D}from"@powerlines/plugin-alloy/typescript/components/tsdoc";const O=[`T`,`K`,()=>k,()=>A,`Omit`,`b!b"e!!e!!ge!"o$#o##w%y`],k=[`T`,`K`,`Pick`,`l+e#!e"!fRb!b"Pde""N#!w#y`],A=[`T`,`U`,`Exclude`,`l6!Re$!RPe#!e$"qk#%QRb!b"Pde"!p)w#y`];function j(e,t){return e.__type=t,e}function M(){let i=(h.Ω=[[`Context`,`"w!`]],h()),o=f(()=>n(i.globalOptions));return[a(S,{get heading(){return`An object representing the global options available for every command in the ${t(i,!0)} command-line application.`}}),a(_,{export:!0,name:`GlobalOptions`,get children(){return a(l,{get each(){return Object.values(o.value)},hardline:!0,get children(){return j(e=>a(r,{option:e}),[`option`,``,`P"2!"/"`])}})}}),a(m,{}),a(S,{heading:`The context object for the current command execution, containing the command path and segments.`}),a(_,{export:!0,name:`CommandContext`,typeParameters:[{name:`THandler`,extends:`(...params: any[]) => any`,default:`any`}],get children(){return[a(S,{get heading(){return`The full command path as a string. For example, if the user runs \`${e(i)} foo bar\`, this would be \`foo bar\`. This is useful for commands that need to know their full invocation path, such as for help text or for commands that have dynamic behavior based on their position in the command hierarchy.`}}),a(v,{name:`path`,type:`string`}),a(m,{}),a(S,{get heading(){return`An array of command path segments. For example, if the user runs \`${e(i)} foo bar\`, this would be \`["foo", "bar"]\`. This is useful for commands that need to know their individual path segments, such as for dynamic routing or for commands that have behavior based on specific segments in the command hierarchy.`}}),a(v,{name:`segments`,type:`string[]`}),a(m,{}),a(S,{heading:`The parameters for the current command's handler function.`}),a(v,{name:`params`,type:`Parameters<THandler>`})]}}),a(m,{}),a(y,{export:!0,name:`GlobalContextStatus`,children:d`"initializing" | "preparing" | "executing" | "completed"`}),a(m,{}),a(S,{get heading(){return`The state object for the ${t(i)} application context.`}}),a(_,{export:!0,name:`GlobalContextState`,get children(){return[a(S,{heading:`The unique identifier for the current execution context.`}),a(v,{name:`executionId`,type:`string`}),a(m,{}),a(S,{heading:`The status of the current execution context.`}),a(v,{name:`status`,type:`GlobalContextStatus`}),a(m,{}),a(S,{heading:`Indicates whether the current execution context has encountered an error.`}),a(v,{name:`isError`,type:`boolean`}),a(m,{}),a(S,{heading:`A map containing arbitrary data associated with the current execution context.`}),a(v,{name:`meta`,type:`Map<string, unknown>`})]}}),a(m,{}),a(S,{get heading(){return`The context object for the ${t(i)} application.`}}),a(_,{export:!0,name:`GlobalContext`,get children(){return[a(S,{heading:`The global options shared across all commands in the application.`}),a(v,{name:`options`,type:`GlobalOptions`}),a(m,{}),a(S,{heading:`The raw command-line arguments passed to the application.`}),a(v,{name:`inputArgs`,type:`string[]`}),a(m,{}),a(S,{heading:`The state of the current execution context.`}),a(v,{name:`state`,type:`GlobalContextState`})]}})]}M.__type=[`GlobalTypeDefinitions`,`P"/!`];function N(){return[a(S,{heading:`Retrieves the command-line arguments from Deno or Node.js environments.`,get children(){return[a(E,{children:"This function is only intended for internal use. Please use `useArgs()` instead."}),a(m,{}),a(C,{}),a(m,{}),a(D,{children:`An array of command-line arguments from Deno or Node.js environments.`})]}}),a(g,{name:`getInputArgs`,returnType:`string[]`,children:d`return ((globalThis as { Deno?: { args: string[] } })?.Deno?.args ?? process.argv ?? []) as string[];`})]}N.__type=[`ArgsUtilities`,`Generates utilities for detecting terminal color support.`,`P"/!?"`];function P(){let n=(h.Ω=[[`Context`,`"w!`]],h()),r=f(()=>Object.fromEntries(n.globalOptions.map(j(e=>[e.name,e],[`option`,``,`P"2!"/"`]))));return[a(m,{}),a(S,{get heading(){return`The global ${t(n)} application context store instance.`},get children(){return a(C,{})}}),a(b,{export:!0,const:!0,name:`unstable_globalStore`,children:d` new AsyncLocalStorage<GlobalContext>({ name: "globalStore" }); `}),a(m,{}),a(S,{get heading(){return`Get the ${t(n)} application context for the current application.`},get children(){return a(D,{get children(){return`The ${t(n)} application context for the current application or undefined if the context is not available.`}})}}),a(g,{export:!0,name:`useGlobal`,returnType:`GlobalContext`,children:d`return unstable_globalStore.getStore() as GlobalContext;`}),a(m,{}),a(S,{get heading(){return`A utility hook function to get the command-line arguments from the ${t(n)} application context.`},get children(){return a(D,{children:`An array of command-line arguments from the application context.`})}}),a(g,{export:!0,name:`useArgs`,returnType:`string[]`,children:d`return useGlobal()?.inputArgs ?? getInputArgs();`}),a(m,{}),a(S,{get heading(){return`A utility hook function to get the command-line global options from the ${t(n)} application context.`},get children(){return a(D,{children:`An object containing the global options from the application context.`})}}),a(g,{export:!0,name:`useGlobalOptions`,returnType:`GlobalOptions`,children:d`return useGlobal()?.options ?? {};`}),a(m,{}),a(S,{get heading(){return`A utility hook function to get the state of the ${t(n)} application context.`},get children(){return a(D,{children:`The state of the application context.`})}}),a(g,{export:!0,name:`useState`,returnType:`GlobalContextState`,children:d`return useGlobal()?.state;`}),a(m,{}),a(S,{get heading(){return`A utility function to update the state of the ${t(n)} application context.`},get children(){return[a(E,{children:"This function will throw an error if the global context is not available, so it should only be used within a valid context scope, such as within a command handler or within the `withGlobal()` function."}),a(m,{}),a(T,{name:`update`,children:`The new state or a function that receives the previous state and returns the new state. This allows for both direct state updates and functional updates based on the previous state.`})]}}),a(g,{export:!0,name:`setState`,parameters:[{name:`update`,type:`Partial<GlobalContextState> | ((prev: GlobalContextState) => GlobalContextState)`}],get children(){return d`const prev = useGlobal()?.state;
|
|
310
2
|
if (!prev) {
|
|
311
3
|
throw new Error(
|
|
312
|
-
\`The ${
|
|
4
|
+
\`The ${t(n)} application context is not available. Make sure to call setState() within a valid context scope.\`
|
|
313
5
|
);
|
|
314
6
|
}
|
|
315
7
|
|
|
316
|
-
useGlobal().state = typeof update === "function" ? update(prev) : { ...prev, ...update };
|
|
317
|
-
}
|
|
318
|
-
}),
|
|
319
|
-
createComponent(Spacing, {}),
|
|
320
|
-
createComponent(TSDoc, {
|
|
321
|
-
get heading() {
|
|
322
|
-
return `A utility hook function to get the execution ID of the ${getAppTitle(context)} application context.`;
|
|
323
|
-
},
|
|
324
|
-
get children() {
|
|
325
|
-
return createComponent(TSDocReturns, { children: "The execution ID of the application context." });
|
|
326
|
-
}
|
|
327
|
-
}),
|
|
328
|
-
createComponent(FunctionDeclaration, {
|
|
329
|
-
"export": true,
|
|
330
|
-
name: "useExecutionId",
|
|
331
|
-
returnType: "string",
|
|
332
|
-
children: code`return useState().executionId;`
|
|
333
|
-
}),
|
|
334
|
-
createComponent(Spacing, {}),
|
|
335
|
-
createComponent(TSDoc, {
|
|
336
|
-
get heading() {
|
|
337
|
-
return `A utility hook function to get the metadata of the ${getAppTitle(context)} application context.`;
|
|
338
|
-
},
|
|
339
|
-
get children() {
|
|
340
|
-
return createComponent(TSDocReturns, { children: "The metadata of the application context." });
|
|
341
|
-
}
|
|
342
|
-
}),
|
|
343
|
-
createComponent(FunctionDeclaration, {
|
|
344
|
-
"export": true,
|
|
345
|
-
name: "useMeta",
|
|
346
|
-
returnType: "Map<string, unknown>",
|
|
347
|
-
children: code`return useState().meta;`
|
|
348
|
-
}),
|
|
349
|
-
createComponent(Spacing, {}),
|
|
350
|
-
createComponent(TSDoc, {
|
|
351
|
-
get heading() {
|
|
352
|
-
return `A utility hook function to get the current status of the ${getAppTitle(context)} application.`;
|
|
353
|
-
},
|
|
354
|
-
get children() {
|
|
355
|
-
return createComponent(TSDocReturns, { children: "The current status of the application." });
|
|
356
|
-
}
|
|
357
|
-
}),
|
|
358
|
-
createComponent(FunctionDeclaration, {
|
|
359
|
-
"export": true,
|
|
360
|
-
name: "useStatus",
|
|
361
|
-
returnType: "GlobalContextStatus",
|
|
362
|
-
children: code`return useState().status;`
|
|
363
|
-
}),
|
|
364
|
-
createComponent(Spacing, {}),
|
|
365
|
-
createComponent(TSDoc, {
|
|
366
|
-
get heading() {
|
|
367
|
-
return `The global ${getAppTitle(context)} - command context store instance.`;
|
|
368
|
-
},
|
|
369
|
-
get children() {
|
|
370
|
-
return createComponent(TSDocInternal, {});
|
|
371
|
-
}
|
|
372
|
-
}),
|
|
373
|
-
createComponent(VarDeclaration, {
|
|
374
|
-
"export": true,
|
|
375
|
-
name: "unstable_commandStore",
|
|
376
|
-
children: code`new AsyncLocalStorage<CommandContext>({ name: "commandStore" });`
|
|
377
|
-
}),
|
|
378
|
-
createComponent(Spacing, {}),
|
|
379
|
-
createComponent(TSDoc, {
|
|
380
|
-
get heading() {
|
|
381
|
-
return `Get the ${getAppTitle(context)} - command context for the current application.`;
|
|
382
|
-
},
|
|
383
|
-
get children() {
|
|
384
|
-
return createComponent(TSDocReturns, { get children() {
|
|
385
|
-
return `The ${getAppTitle(context)} - command context for the current application.`;
|
|
386
|
-
} });
|
|
387
|
-
}
|
|
388
|
-
}),
|
|
389
|
-
createComponent(FunctionDeclaration, {
|
|
390
|
-
"export": true,
|
|
391
|
-
name: "useCommand",
|
|
392
|
-
returnType: "CommandContext",
|
|
393
|
-
get children() {
|
|
394
|
-
return code`const result = unstable_commandStore.getStore();
|
|
8
|
+
useGlobal().state = typeof update === "function" ? update(prev) : { ...prev, ...update }; `}}),a(m,{}),a(S,{get heading(){return`A utility hook function to get the execution ID of the ${t(n)} application context.`},get children(){return a(D,{children:`The execution ID of the application context.`})}}),a(g,{export:!0,name:`useExecutionId`,returnType:`string`,children:d`return useState().executionId;`}),a(m,{}),a(S,{get heading(){return`A utility hook function to get the metadata of the ${t(n)} application context.`},get children(){return a(D,{children:`The metadata of the application context.`})}}),a(g,{export:!0,name:`useMeta`,returnType:`Map<string, unknown>`,children:d`return useState().meta;`}),a(m,{}),a(S,{get heading(){return`A utility hook function to get the current status of the ${t(n)} application.`},get children(){return a(D,{children:`The current status of the application.`})}}),a(g,{export:!0,name:`useStatus`,returnType:`GlobalContextStatus`,children:d`return useState().status;`}),a(m,{}),a(S,{get heading(){return`The global ${t(n)} - command context store instance.`},get children(){return a(C,{})}}),a(b,{export:!0,name:`unstable_commandStore`,children:d`new AsyncLocalStorage<CommandContext>({ name: "commandStore" });`}),a(m,{}),a(S,{get heading(){return`Get the ${t(n)} - command context for the current application.`},get children(){return a(D,{get children(){return`The ${t(n)} - command context for the current application.`}})}}),a(g,{export:!0,name:`useCommand`,returnType:`CommandContext`,get children(){return d`const result = unstable_commandStore.getStore();
|
|
395
9
|
if (!result) {
|
|
396
10
|
throw new Error(
|
|
397
|
-
\`The ${
|
|
11
|
+
\`The ${t(n)} - command context is not available. Make sure to call useCommand() within a valid context scope.\`
|
|
398
12
|
);
|
|
399
13
|
}
|
|
400
|
-
return result
|
|
401
|
-
}
|
|
402
|
-
}),
|
|
403
|
-
createComponent(Spacing, {}),
|
|
404
|
-
createComponent(TSDoc, {
|
|
405
|
-
heading: "A utility hook function to get the individual segments of the current command path.",
|
|
406
|
-
get children() {
|
|
407
|
-
return createComponent(TSDocReturns, { children: "An array of command path segments." });
|
|
408
|
-
}
|
|
409
|
-
}),
|
|
410
|
-
createComponent(FunctionDeclaration, {
|
|
411
|
-
"export": true,
|
|
412
|
-
name: "useSegments",
|
|
413
|
-
returnType: "string[]",
|
|
414
|
-
children: code`return useCommand().segments;`
|
|
415
|
-
}),
|
|
416
|
-
createComponent(Spacing, {}),
|
|
417
|
-
createComponent(TSDoc, {
|
|
418
|
-
heading: "A utility hook function to get the full command path as a string.",
|
|
419
|
-
get children() {
|
|
420
|
-
return createComponent(TSDocReturns, { get children() {
|
|
421
|
-
return `The full command path as a string. For example, if the user runs \`${getAppBin(context)} foo bar\`, this would return \`"foo bar"\`. This is useful for commands that need to know their full invocation path, such as for help text or for commands that have dynamic behavior based on their position in the command hierarchy.`;
|
|
422
|
-
} });
|
|
423
|
-
}
|
|
424
|
-
}),
|
|
425
|
-
createComponent(FunctionDeclaration, {
|
|
426
|
-
"export": true,
|
|
427
|
-
name: "usePath",
|
|
428
|
-
returnType: "string",
|
|
429
|
-
children: code`return useCommand().path;`
|
|
430
|
-
}),
|
|
431
|
-
createComponent(Spacing, {}),
|
|
432
|
-
createComponent(TSDoc, {
|
|
433
|
-
heading: "Checks if a specific flag is present in the command-line arguments.",
|
|
434
|
-
get children() {
|
|
435
|
-
return [
|
|
436
|
-
createComponent(TSDocLink, { children: "https://github.com/sindresorhus/has-flag/blob/main/index.js" }),
|
|
437
|
-
createComponent(TSDocParam, {
|
|
438
|
-
name: "flag",
|
|
439
|
-
children: "The flag (or an array of flags/aliases) to check for, e.g., \"color\", \"no-color\"."
|
|
440
|
-
}),
|
|
441
|
-
createComponent(TSDocParam, {
|
|
442
|
-
name: "argv",
|
|
443
|
-
children: "The command-line arguments to check against. Defaults to global Deno args or process args."
|
|
444
|
-
}),
|
|
445
|
-
createComponent(TSDocReturns, { children: "True if the flag is present, false otherwise." })
|
|
446
|
-
];
|
|
447
|
-
}
|
|
448
|
-
}),
|
|
449
|
-
createComponent(FunctionDeclaration, {
|
|
450
|
-
"export": true,
|
|
451
|
-
name: "hasFlag",
|
|
452
|
-
parameters: [{
|
|
453
|
-
name: "flag",
|
|
454
|
-
type: "string | string[]"
|
|
455
|
-
}, {
|
|
456
|
-
name: "argv",
|
|
457
|
-
type: "string[]",
|
|
458
|
-
default: "useArgs()"
|
|
459
|
-
}],
|
|
460
|
-
get children() {
|
|
461
|
-
return [
|
|
462
|
-
createComponent(VarDeclaration, {
|
|
463
|
-
"const": true,
|
|
464
|
-
name: "position",
|
|
465
|
-
type: "number",
|
|
466
|
-
initializer: code`(Array.isArray(flag) ? flag : [flag]).reduce((ret, f) => {
|
|
14
|
+
return result;`}}),a(m,{}),a(S,{heading:`A utility hook function to get the individual segments of the current command path.`,get children(){return a(D,{children:`An array of command path segments.`})}}),a(g,{export:!0,name:`useSegments`,returnType:`string[]`,children:d`return useCommand().segments;`}),a(m,{}),a(S,{heading:`A utility hook function to get the full command path as a string.`,get children(){return a(D,{get children(){return`The full command path as a string. For example, if the user runs \`${e(n)} foo bar\`, this would return \`"foo bar"\`. This is useful for commands that need to know their full invocation path, such as for help text or for commands that have dynamic behavior based on their position in the command hierarchy.`}})}}),a(g,{export:!0,name:`usePath`,returnType:`string`,children:d`return useCommand().path;`}),a(m,{}),a(S,{heading:`Checks if a specific flag is present in the command-line arguments.`,get children(){return[a(w,{children:`https://github.com/sindresorhus/has-flag/blob/main/index.js`}),a(T,{name:`flag`,children:`The flag (or an array of flags/aliases) to check for, e.g., "color", "no-color".`}),a(T,{name:`argv`,children:`The command-line arguments to check against. Defaults to global Deno args or process args.`}),a(D,{children:`True if the flag is present, false otherwise.`})]}}),a(g,{export:!0,name:`hasFlag`,parameters:[{name:`flag`,type:`string | string[]`},{name:`argv`,type:`string[]`,default:`useArgs()`}],get children(){return[a(b,{const:!0,name:`position`,type:`number`,initializer:d`(Array.isArray(flag) ? flag : [flag]).reduce((ret, f) => {
|
|
467
15
|
const pos = argv.findIndex(arg => (f.startsWith("-") ? "" : (f.length === 1 ? "-" : "--") + f)?.toLowerCase() === arg?.toLowerCase() || arg?.toLowerCase().startsWith((f.length === 1 ? "-" : "--") + f + "="));
|
|
468
16
|
return pos !== -1 ? pos : ret;
|
|
469
|
-
}, -1);`
|
|
470
|
-
|
|
471
|
-
createIntrinsic("hbr", {}),
|
|
472
|
-
code`return position !== -1 && argv.indexOf("--") === -1 || position < argv.indexOf("--");`
|
|
473
|
-
];
|
|
474
|
-
}
|
|
475
|
-
}),
|
|
476
|
-
createComponent(Spacing, {}),
|
|
477
|
-
createComponent(TSDoc, {
|
|
478
|
-
heading: "A utility function to determine if the help flag is present or if the command is in an error state during preparation.",
|
|
479
|
-
get children() {
|
|
480
|
-
return createComponent(TSDocReturns, { children: `True if the help flag is present or if the command is in an error state during preparation, false otherwise. This can be used to conditionally display help text or to alter command behavior when the user is likely seeking help.` });
|
|
481
|
-
}
|
|
482
|
-
}),
|
|
483
|
-
createComponent(FunctionDeclaration, {
|
|
484
|
-
"export": true,
|
|
485
|
-
name: "isHelp",
|
|
486
|
-
returnType: "boolean",
|
|
487
|
-
children: code`return !isCI && (hasFlag(["help", "h", "?"]) || (useStatus() === "preparing" && useState().isError)); `
|
|
488
|
-
}),
|
|
489
|
-
createComponent(Spacing, {}),
|
|
490
|
-
createComponent(TSDoc, {
|
|
491
|
-
get heading() {
|
|
492
|
-
return `A utility function to wrap the ${getAppTitle(context)} application within the global context scope.`;
|
|
493
|
-
},
|
|
494
|
-
get children() {
|
|
495
|
-
return [createComponent(TSDocParam, {
|
|
496
|
-
name: "handler",
|
|
497
|
-
children: `The callback function to run within the global context scope. This function will receive the global context as its argument, allowing it to access any properties or utilities defined on the context. The callback function can be asynchronous and can return a value or a promise.`
|
|
498
|
-
}), createComponent(TSDocReturns, { children: `The result of the callback function, which can be a value or a promise that resolves to a value.` })];
|
|
499
|
-
}
|
|
500
|
-
}),
|
|
501
|
-
createComponent(FunctionDeclaration, {
|
|
502
|
-
"export": true,
|
|
503
|
-
async: true,
|
|
504
|
-
name: "withGlobal",
|
|
505
|
-
parameters: [{
|
|
506
|
-
name: "handler",
|
|
507
|
-
type: "() => any"
|
|
508
|
-
}],
|
|
509
|
-
returnType: "Promise<void>",
|
|
510
|
-
get children() {
|
|
511
|
-
return [
|
|
512
|
-
createComponent(VarDeclaration, {
|
|
513
|
-
"const": true,
|
|
514
|
-
name: "args",
|
|
515
|
-
initializer: code`getInputArgs(); `
|
|
516
|
-
}),
|
|
517
|
-
createComponent(Spacing, {}),
|
|
518
|
-
createComponent(OptionsParserLogic, {
|
|
519
|
-
get options() {
|
|
520
|
-
return options.value;
|
|
521
|
-
},
|
|
522
|
-
get appSpecificEnvPrefix() {
|
|
523
|
-
return context.config.appSpecificEnvPrefix;
|
|
524
|
-
},
|
|
525
|
-
get isCaseSensitive() {
|
|
526
|
-
return context.config.isCaseSensitive;
|
|
527
|
-
}
|
|
528
|
-
}),
|
|
529
|
-
createComponent(Spacing, {}),
|
|
530
|
-
code`
|
|
531
|
-
return unstable_globalStore.run({ options, inputArgs: args, state: { executionId: randomUUID(), status: "initializing", isError: false, meta: new Map() } as GlobalContextState }, handler);`
|
|
532
|
-
];
|
|
533
|
-
}
|
|
534
|
-
}),
|
|
535
|
-
createComponent(Spacing, {}),
|
|
536
|
-
createComponent(TSDoc, {
|
|
537
|
-
get heading() {
|
|
538
|
-
return `A utility function to wrap a ${getAppTitle(context)} application command handler within the command context scope.`;
|
|
539
|
-
},
|
|
540
|
-
get children() {
|
|
541
|
-
return [createComponent(TSDocParam, {
|
|
542
|
-
name: "handler",
|
|
543
|
-
children: `The callback function to run within the command context scope. This function will receive the command context as its argument, allowing it to access any properties or utilities defined on the context. The callback function can be asynchronous and can return a value or a promise.`
|
|
544
|
-
}), createComponent(TSDocReturns, { children: `The result of the callback function, which can be a value or a promise that resolves to a value.` })];
|
|
545
|
-
}
|
|
546
|
-
}),
|
|
547
|
-
createComponent(FunctionDeclaration, {
|
|
548
|
-
"export": true,
|
|
549
|
-
async: true,
|
|
550
|
-
name: "withCommand",
|
|
551
|
-
typeParameters: [{
|
|
552
|
-
name: "THandler",
|
|
553
|
-
extends: "(this: CommandContext, ...params: any[]) => any",
|
|
554
|
-
default: "(this: CommandContext, ...params: any[]) => any"
|
|
555
|
-
}],
|
|
556
|
-
parameters: [
|
|
557
|
-
{
|
|
558
|
-
name: "path",
|
|
559
|
-
type: "string"
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
name: "segments",
|
|
563
|
-
type: "string[]"
|
|
564
|
-
},
|
|
565
|
-
{
|
|
566
|
-
name: "params",
|
|
567
|
-
type: "Parameters<THandler>"
|
|
568
|
-
},
|
|
569
|
-
{
|
|
570
|
-
name: "handler",
|
|
571
|
-
type: "THandler"
|
|
572
|
-
}
|
|
573
|
-
],
|
|
574
|
-
returnType: "Promise<{ error: string | Error | null }>",
|
|
575
|
-
children: code`setState({ status: "preparing", isError: false });
|
|
17
|
+
}, -1);`}),o(`hbr`,{}),d`return position !== -1 && argv.indexOf("--") === -1 || position < argv.indexOf("--");`]}}),a(m,{}),a(S,{heading:`A utility function to determine if the help flag is present or if the command is in an error state during preparation.`,get children(){return a(D,{children:`True if the help flag is present or if the command is in an error state during preparation, false otherwise. This can be used to conditionally display help text or to alter command behavior when the user is likely seeking help.`})}}),a(g,{export:!0,name:`isHelp`,returnType:`boolean`,children:d`return !isCI && (hasFlag(["help", "h", "?"]) || (useStatus() === "preparing" && useState().isError)); `}),a(m,{}),a(S,{get heading(){return`A utility function to wrap the ${t(n)} application within the global context scope.`},get children(){return[a(T,{name:`handler`,children:`The callback function to run within the global context scope. This function will receive the global context as its argument, allowing it to access any properties or utilities defined on the context. The callback function can be asynchronous and can return a value or a promise.`}),a(D,{children:`The result of the callback function, which can be a value or a promise that resolves to a value.`})]}}),a(g,{export:!0,async:!0,name:`withGlobal`,parameters:[{name:`handler`,type:`() => any`}],returnType:`Promise<void>`,get children(){return[a(b,{const:!0,name:`args`,initializer:d`getInputArgs(); `}),a(m,{}),a(i,{get options(){return r.value},get appSpecificEnvPrefix(){return n.config.appSpecificEnvPrefix},get isCaseSensitive(){return n.config.isCaseSensitive}}),a(m,{}),d`
|
|
18
|
+
return unstable_globalStore.run({ options, inputArgs: args, state: { executionId: randomUUID(), status: "initializing", isError: false, meta: new Map() } as GlobalContextState }, handler);`]}}),a(m,{}),a(S,{get heading(){return`A utility function to wrap a ${t(n)} application command handler within the command context scope.`},get children(){return[a(T,{name:`handler`,children:`The callback function to run within the command context scope. This function will receive the command context as its argument, allowing it to access any properties or utilities defined on the context. The callback function can be asynchronous and can return a value or a promise.`}),a(D,{children:`The result of the callback function, which can be a value or a promise that resolves to a value.`})]}}),a(g,{export:!0,async:!0,name:`withCommand`,typeParameters:[{name:`THandler`,extends:`(this: CommandContext, ...params: any[]) => any`,default:`(this: CommandContext, ...params: any[]) => any`}],parameters:[{name:`path`,type:`string`},{name:`segments`,type:`string[]`},{name:`params`,type:`Parameters<THandler>`},{name:`handler`,type:`THandler`}],returnType:`Promise<{ error: string | Error | null }>`,children:d`setState({ status: "preparing", isError: false });
|
|
576
19
|
|
|
577
20
|
const ctx = { path, segments, params } as CommandContext<THandler>;
|
|
578
21
|
const result = await Promise.resolve(unstable_commandStore.run(ctx, () => Reflect.apply(handler, ctx, params)));
|
|
@@ -582,62 +25,5 @@ return result;`;
|
|
|
582
25
|
}
|
|
583
26
|
|
|
584
27
|
setState({ status: "completed", isError: false });
|
|
585
|
-
return { error: null }; `
|
|
586
|
-
})
|
|
587
|
-
];
|
|
588
|
-
}
|
|
589
|
-
ContextUtilities.__type = ["ContextUtilities", "P\"/!"];
|
|
590
|
-
const __ΩStateBuiltinProps = [
|
|
591
|
-
() => __ΩOmit,
|
|
592
|
-
"id",
|
|
593
|
-
"description",
|
|
594
|
-
"StateBuiltinProps",
|
|
595
|
-
"P!P.\".#Jo!#Mw$y"
|
|
596
|
-
];
|
|
597
|
-
/**
|
|
598
|
-
* A built-in module for handling application state utilities in Shell Shock.
|
|
599
|
-
*/
|
|
600
|
-
function StateBuiltin(props) {
|
|
601
|
-
const [{ children }, rest] = splitProps(props, ["children"]);
|
|
602
|
-
return createComponent(BuiltinFile, mergeProps({
|
|
603
|
-
id: "state",
|
|
604
|
-
description: "A module that provides context hooks and utilities for accessing the application state."
|
|
605
|
-
}, rest, {
|
|
606
|
-
get imports() {
|
|
607
|
-
return defu$1(rest.imports ?? {}, {
|
|
608
|
-
"node:async_hooks": ["AsyncLocalStorage"],
|
|
609
|
-
"node:crypto": ["randomUUID"]
|
|
610
|
-
});
|
|
611
|
-
},
|
|
612
|
-
get builtinImports() {
|
|
613
|
-
return defu$1(rest.builtinImports ?? {}, { env: ["isCI", "env"] });
|
|
614
|
-
},
|
|
615
|
-
get children() {
|
|
616
|
-
return [
|
|
617
|
-
createComponent(GlobalTypeDefinitions, {}),
|
|
618
|
-
createComponent(Spacing, {}),
|
|
619
|
-
createComponent(ArgsUtilities, {}),
|
|
620
|
-
createComponent(Spacing, {}),
|
|
621
|
-
createComponent(ContextUtilities, {}),
|
|
622
|
-
createComponent(Spacing, {}),
|
|
623
|
-
createComponent(Show, {
|
|
624
|
-
get when() {
|
|
625
|
-
return Boolean(children);
|
|
626
|
-
},
|
|
627
|
-
children
|
|
628
|
-
})
|
|
629
|
-
];
|
|
630
|
-
}
|
|
631
|
-
}));
|
|
632
|
-
}
|
|
633
|
-
StateBuiltin.__type = [
|
|
634
|
-
() => __ΩStateBuiltinProps,
|
|
635
|
-
"props",
|
|
636
|
-
"StateBuiltin",
|
|
637
|
-
"A built-in module for handling application state utilities in Shell Shock.",
|
|
638
|
-
"Pn!2\"\"/#?$"
|
|
639
|
-
];
|
|
640
|
-
|
|
641
|
-
//#endregion
|
|
642
|
-
export { ArgsUtilities, ContextUtilities, GlobalTypeDefinitions, StateBuiltin, __ΩStateBuiltinProps };
|
|
28
|
+
return { error: null }; `})]}P.__type=[`ContextUtilities`,`P"/!`];const F=[()=>O,`id`,`description`,`StateBuiltinProps`,`P!P.".#Jo!#Mw$y`];function I(e){let[{children:t},n]=p(e,[`children`]);return a(x,s({id:`state`,description:`A module that provides context hooks and utilities for accessing the application state.`},n,{get imports(){return c(n.imports??{},{"node:async_hooks":[`AsyncLocalStorage`],"node:crypto":[`randomUUID`]})},get builtinImports(){return c(n.builtinImports??{},{env:[`isCI`,`env`]})},get children(){return[a(M,{}),a(m,{}),a(N,{}),a(m,{}),a(P,{}),a(m,{}),a(u,{get when(){return!!t},children:t})]}}))}I.__type=[()=>F,`props`,`StateBuiltin`,`A built-in module for handling application state utilities in Shell Shock.`,`Pn!2""/#?$`];export{N as ArgsUtilities,P as ContextUtilities,M as GlobalTypeDefinitions,I as StateBuiltin,F as __ΩStateBuiltinProps};
|
|
643
29
|
//# sourceMappingURL=state-builtin.mjs.map
|