@loomcli/core 0.5.0 → 0.7.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/NOTICE +34 -0
- package/dist/application.d.ts +18 -2
- package/dist/application.js +302 -75
- package/dist/bindings.d.ts +15 -10
- package/dist/bindings.js +34 -15
- package/dist/capture.d.ts +65 -0
- package/dist/capture.js +99 -0
- package/dist/chain.d.ts +15 -6
- package/dist/chain.js +40 -20
- package/dist/command-rules.d.ts +55 -0
- package/dist/command-rules.js +142 -0
- package/dist/command.d.ts +65 -23
- package/dist/command.js +734 -236
- package/dist/controls.d.ts +8 -0
- package/dist/controls.js +23 -0
- package/dist/defect.d.ts +18 -0
- package/dist/defect.js +272 -0
- package/dist/developer.d.ts +24 -0
- package/dist/developer.js +52 -0
- package/dist/diagnostic-text.d.ts +81 -0
- package/dist/diagnostic-text.js +283 -0
- package/dist/diagnostic.d.ts +11 -0
- package/dist/diagnostic.js +70 -0
- package/dist/errors.d.ts +108 -24
- package/dist/errors.js +324 -53
- package/dist/exit-codes.d.ts +45 -0
- package/dist/exit-codes.js +46 -0
- package/dist/extension.d.ts +41 -8
- package/dist/extension.js +142 -57
- package/dist/facts.d.ts +71 -11
- package/dist/facts.js +106 -23
- package/dist/globals.d.ts +29 -21
- package/dist/globals.js +117 -46
- package/dist/glyphs.generated.js +1 -1
- package/dist/hints.d.ts +79 -0
- package/dist/hints.js +247 -0
- package/dist/host.d.ts +13 -0
- package/dist/host.js +43 -1
- package/dist/identity.d.ts +19 -0
- package/dist/identity.js +72 -0
- package/dist/index.d.ts +12 -2
- package/dist/index.js +6 -0
- package/dist/input-rules.d.ts +68 -0
- package/dist/input-rules.js +152 -0
- package/dist/inspect.d.ts +12 -12
- package/dist/inspect.js +92 -48
- package/dist/lanes.js +1 -1
- package/dist/locate.js +4 -4
- package/dist/options.d.ts +30 -2
- package/dist/options.js +143 -46
- package/dist/output.d.ts +9 -2
- package/dist/output.js +18 -2
- package/dist/plain.d.ts +56 -0
- package/dist/plain.js +238 -0
- package/dist/plugin-rules.d.ts +68 -0
- package/dist/plugin-rules.js +164 -0
- package/dist/plugin-settings.d.ts +18 -0
- package/dist/plugin-settings.js +38 -0
- package/dist/plugin.d.ts +27 -15
- package/dist/plugin.js +429 -144
- package/dist/prototypes.d.ts +7 -0
- package/dist/prototypes.js +29 -0
- package/dist/rendering.d.ts +6 -1
- package/dist/rendering.js +23 -5
- package/dist/rules.d.ts +51 -0
- package/dist/rules.js +115 -0
- package/dist/sequence.js +6 -1
- package/dist/sources.d.ts +6 -4
- package/dist/sources.js +25 -16
- package/dist/style-layout.js +2 -2
- package/dist/style-width.d.ts +13 -0
- package/dist/style-width.js +170 -0
- package/dist/style-wire.js +1 -1
- package/dist/style.js +1 -1
- package/dist/theme.d.ts +4 -0
- package/dist/theme.js +25 -5
- package/dist/thenable.d.ts +15 -0
- package/dist/thenable.js +29 -0
- package/dist/translators.d.ts +69 -0
- package/dist/translators.js +253 -0
- package/dist/types.d.ts +13 -3
- package/dist/unicode.generated.d.ts +27 -0
- package/dist/unicode.generated.js +1036 -0
- package/dist/validation.d.ts +69 -7
- package/dist/validation.js +211 -67
- package/dist/view.d.ts +61 -22
- package/dist/view.js +168 -81
- package/licenses/unicode-LICENSE.txt +41 -0
- package/licenses/uucode-LICENSE.md +35 -0
- package/package.json +9 -5
package/dist/command.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { Finding } from './diagnostic-text.js';
|
|
1
2
|
import type { RegisteredGlobals } from './environment.js';
|
|
2
|
-
import type {
|
|
3
|
+
import type { LoomError } from './errors.js';
|
|
4
|
+
import type { AdmittedDescriptor, DescriptorRegistry, ExtensionRecords, ExtensionStore, ExtensionSubject, ExtensionValue } from './extension.js';
|
|
3
5
|
import type { BuiltGlobals, GlobalsState, GlobalTable, InputRecords } from './globals.js';
|
|
4
6
|
import type { CommandGraph, CommandNode } from './inspect.js';
|
|
5
7
|
import { compileOptions } from './options.js';
|
|
@@ -7,7 +9,7 @@ import type { OptionValues } from './options.js';
|
|
|
7
9
|
import type { BuiltPlugin } from './plugin.js';
|
|
8
10
|
import type { ContextualStyle } from './style.js';
|
|
9
11
|
import type { Action, ActionChannel, ArgumentConfig, ArgumentValue, declaredTypes, DeclaredResult, DeclaredTypes, DefaultConstraint, GlobalNameConstraint, Host, PerValueConstraint, NameConstraint, OpenResult, OptionConfig, OptionValue, Out, Request, ResultBinding, ResultViews, ResultViewsOf, RowViews, ValidateOmittedConstraint } from './types.js';
|
|
10
|
-
import type { ArgumentInput, DefaultValues, InputDeclaration, OptionInput, ValidatedInputs } from './validation.js';
|
|
12
|
+
import type { ArgumentInput, DefaultValues, InputPlaces, InputDeclaration, OptionInput, ValidatedInputs } from './validation.js';
|
|
11
13
|
/** One positional slot: the declaration it fills and whether it takes the remaining tokens. */
|
|
12
14
|
export interface ArgumentSlot {
|
|
13
15
|
input: InputDeclaration;
|
|
@@ -88,10 +90,14 @@ export interface CommandNodeHandle {
|
|
|
88
90
|
readonly name: string;
|
|
89
91
|
build(context: BuildContext): BuiltCommand;
|
|
90
92
|
}
|
|
91
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* One attached child, under the canonical name its parent's namespace holds it by, with the call
|
|
95
|
+
* that attached it, which a diagnostic about the child as a whole marks.
|
|
96
|
+
*/
|
|
92
97
|
export interface AttachedChild {
|
|
93
98
|
readonly name: string;
|
|
94
99
|
readonly node: CommandNodeHandle;
|
|
100
|
+
readonly placement: Finding;
|
|
95
101
|
}
|
|
96
102
|
/**
|
|
97
103
|
* One graph build's shared state. `globals` compiles once and every Command reads it. The build is
|
|
@@ -108,6 +114,12 @@ interface BuildContext {
|
|
|
108
114
|
}
|
|
109
115
|
/** The handle behind a value an author built as a Command, or nothing for any other value. */
|
|
110
116
|
export declare function commandNode(value: unknown): CommandNodeHandle | undefined;
|
|
117
|
+
/** A call's arguments as its author wrote them: the trailing ones left undefined are dropped. */
|
|
118
|
+
export declare function callArguments(...values: readonly unknown[]): readonly unknown[];
|
|
119
|
+
/** A Command value as a finding prints it, which it would otherwise print as an ellipsis. */
|
|
120
|
+
export declare function commandCode(name: string): object;
|
|
121
|
+
/** The finding for one `command()` call that attached a child under the Command at `path`. */
|
|
122
|
+
export declare function commandPlacement(path: readonly string[], child: string): Finding;
|
|
111
123
|
/**
|
|
112
124
|
* The portable name rule, for every name an operator types as a command at a shell prompt: the
|
|
113
125
|
* application name, every Command name, and every alias. The characters are the POSIX portable
|
|
@@ -118,17 +130,20 @@ export declare function isPortableName(name: unknown): name is string;
|
|
|
118
130
|
/** The one correction every portable name diagnostic ends with. */
|
|
119
131
|
export declare const portableNameCorrection = "Use a nonempty name of A-Z, a-z, 0-9, \".\", \"_\", and \"-\" that does not start with \"-\" or \".\".";
|
|
120
132
|
/**
|
|
121
|
-
* One call of the results lane, in the order it was made
|
|
122
|
-
* the unit, and a `views()` call reshapes the views of
|
|
133
|
+
* One call of the results lane, in the order it was made, with the arguments a finding rebuilds it
|
|
134
|
+
* from. A `result()` or `rows()` call declares the unit, and a `views()` call reshapes the views of
|
|
135
|
+
* whichever declaration it follows.
|
|
123
136
|
*/
|
|
124
137
|
export type ResultCall = {
|
|
138
|
+
arguments: readonly unknown[];
|
|
139
|
+
} & ({
|
|
125
140
|
kind: 'value' | 'rows';
|
|
126
141
|
views: unknown;
|
|
127
142
|
} | {
|
|
128
143
|
default: unknown;
|
|
129
144
|
kind: 'views';
|
|
130
145
|
views: unknown;
|
|
131
|
-
};
|
|
146
|
+
});
|
|
132
147
|
/** The core facts a named Command declares, which its constructor checked. The root carries none. */
|
|
133
148
|
export interface CommandFacts {
|
|
134
149
|
deprecated: string | undefined;
|
|
@@ -157,7 +172,7 @@ export interface CommandState<Args, Options, Globals> {
|
|
|
157
172
|
* Every descriptor this declaration's extension values name, by identity. The root's holds the
|
|
158
173
|
* whole Application's: its plugins', its global options', and every attached subtree's.
|
|
159
174
|
*/
|
|
160
|
-
descriptors: ReadonlyMap<string,
|
|
175
|
+
descriptors: ReadonlyMap<string, AdmittedDescriptor>;
|
|
161
176
|
/** The extension values of every layer, validated at the call that carried each one. */
|
|
162
177
|
extensions: ExtensionStore;
|
|
163
178
|
facts: CommandFacts;
|
|
@@ -176,19 +191,19 @@ export declare function layerOf(name: string | null): ExtensionSubject;
|
|
|
176
191
|
* declaration values arrive checked, because the constructor that read them threw for any fault.
|
|
177
192
|
*/
|
|
178
193
|
export declare function freshState<Globals>(declaration: {
|
|
179
|
-
descriptors: ReadonlyMap<string,
|
|
194
|
+
descriptors: ReadonlyMap<string, AdmittedDescriptor>;
|
|
180
195
|
extensions: ExtensionStore;
|
|
181
196
|
facts: CommandFacts;
|
|
182
197
|
name: string | null;
|
|
183
198
|
}): CommandState<{}, {}, Globals>;
|
|
184
199
|
/** The declared value joins `args` under its literal name, typed by its own config. */
|
|
185
|
-
export declare function declareArgument<Args, Options, Globals, Name extends string, Config extends ArgumentConfig>(state: CommandState<Args, Options, Globals>,
|
|
200
|
+
export declare function declareArgument<Args, Options, Globals, Name extends string, Config extends ArgumentConfig>(state: CommandState<Args, Options, Globals>, declared: ArgumentInput<Name, Config>): CommandState<Args & Record<Name, ArgumentValue<Config>>, Options, Globals>;
|
|
186
201
|
/**
|
|
187
202
|
* The declared value joins `options` under its literal name, typed by its own config. The root's
|
|
188
203
|
* options also meet the Application's globals table, which a named Command meets when its subtree
|
|
189
204
|
* joins an Application.
|
|
190
205
|
*/
|
|
191
|
-
export declare function declareOption<Args, Options, Globals, Name extends string, Config extends OptionConfig>(state: CommandState<Args, Options, Globals>,
|
|
206
|
+
export declare function declareOption<Args, Options, Globals, Name extends string, Config extends OptionConfig>(state: CommandState<Args, Options, Globals>, declared: OptionInput<Name, Config>, table?: GlobalTable): CommandState<Args, Options & Record<Name, OptionValue<Config>>, Globals>;
|
|
192
207
|
/**
|
|
193
208
|
* One call's names join the Command's aliases. A call that names none, which the types reject and
|
|
194
209
|
* a JavaScript author can still write, reports as the call it is.
|
|
@@ -211,35 +226,48 @@ export declare function declareAction<Args, Options, Globals, Result>(state: Com
|
|
|
211
226
|
export declare function declareResult<Args, Options, Globals>(state: CommandState<Args, Options, Globals>, kind: 'value' | 'rows', declaration: unknown): CommandState<Args, Options, Globals>;
|
|
212
227
|
/** A `views()` call reshapes views and closes nothing, so it is never a late declaration. */
|
|
213
228
|
export declare function declareResultViews<Args, Options, Globals>(state: CommandState<Args, Options, Globals>, replacements: unknown, options: unknown): CommandState<Args, Options, Globals>;
|
|
214
|
-
/**
|
|
215
|
-
interface
|
|
229
|
+
/** One Command a rule judges: the name its sentence reads, and the path its findings open with. */
|
|
230
|
+
interface CommandPlace {
|
|
231
|
+
name: string | null;
|
|
232
|
+
path: readonly string[];
|
|
233
|
+
}
|
|
234
|
+
/** The parent one attach reads: its place, the children it holds, and the calls that close it. */
|
|
235
|
+
interface AttachParent extends CommandPlace {
|
|
216
236
|
/** The first argument the parent declares, which no child may sit beside. */
|
|
217
|
-
argument:
|
|
237
|
+
argument: InputDeclaration | undefined;
|
|
218
238
|
children: readonly AttachedChild[];
|
|
219
239
|
hasAction: boolean;
|
|
220
|
-
name: string | null;
|
|
221
240
|
}
|
|
222
241
|
/**
|
|
223
242
|
* The one attach operation `Command.command()`, `Application.command()`, and a plugin's
|
|
224
243
|
* `commands` list share. A Command is an immutable value, so the child is final here: it is checked
|
|
225
244
|
* as a finished Command, against the parent's current children, and against the nesting cap from
|
|
226
|
-
* the shallowest level the parent can sit at.
|
|
245
|
+
* the shallowest level the parent can sit at. The placement is the call that attached it, which a
|
|
246
|
+
* finding about the child as a whole marks.
|
|
227
247
|
*/
|
|
228
|
-
export declare function attach(parent: AttachParent, node: CommandNodeHandle): AttachedChild;
|
|
248
|
+
export declare function attach(parent: AttachParent, node: CommandNodeHandle, placement: Finding): AttachedChild;
|
|
229
249
|
/** The handle behind the value one `command()` call received; anything else is a declaration error. */
|
|
230
250
|
export declare function childNode(parent: string | null, child: unknown): CommandNodeHandle;
|
|
251
|
+
/** The first place an Application holds one Command value: its parent's name and the attach call. */
|
|
252
|
+
export interface ChildOwner {
|
|
253
|
+
name: string | null;
|
|
254
|
+
placement: Finding;
|
|
255
|
+
}
|
|
231
256
|
/** What an Application holds while a subtree joins it, each register a copy the caller commits. */
|
|
232
257
|
interface JoinScope {
|
|
233
258
|
descriptors: DescriptorRegistry;
|
|
234
|
-
/** The
|
|
235
|
-
owners: Map<CommandNodeHandle,
|
|
259
|
+
/** The first place that claimed each node the Application holds. */
|
|
260
|
+
owners: Map<CommandNodeHandle, ChildOwner>;
|
|
236
261
|
table: GlobalTable;
|
|
237
262
|
}
|
|
238
263
|
/**
|
|
239
264
|
* Attaches one child to an Application's root and walks the subtree it brings, once. The scope's
|
|
240
265
|
* registers are copies: the caller commits the owners, and the returned root holds the descriptors.
|
|
241
266
|
*/
|
|
242
|
-
export declare function attachToRoot<Args, Options, Globals>(state: CommandState<Args, Options, Globals>,
|
|
267
|
+
export declare function attachToRoot<Args, Options, Globals>(state: CommandState<Args, Options, Globals>, child: {
|
|
268
|
+
node: CommandNodeHandle;
|
|
269
|
+
placement: Finding;
|
|
270
|
+
}, scope: JoinScope): CommandState<Args, Options, Globals>;
|
|
243
271
|
/**
|
|
244
272
|
* A declaration's own options and every attached Command's, against a globals table that has just
|
|
245
273
|
* grown. The table's new option reads as the other side of any collision.
|
|
@@ -340,13 +368,22 @@ type CommandConstructor = new (name: string, options?: CommandOptions) => Comman
|
|
|
340
368
|
export declare const Command: CommandConstructor;
|
|
341
369
|
/** Every declaration in the graph, so defaults are validated before any token is read. */
|
|
342
370
|
export declare function collectInputs(command: BuiltCommand): InputDeclaration[];
|
|
371
|
+
/**
|
|
372
|
+
* Where every input of one graph was declared: each global option at its `globalOption()` call,
|
|
373
|
+
* and each Command's own inputs at their calls on the Command, under its path from the root.
|
|
374
|
+
*/
|
|
375
|
+
export declare function inputPlaces(graph: BuiltGraph): InputPlaces;
|
|
343
376
|
/**
|
|
344
377
|
* Whether a token names one of the Command's children: the Command has children and the token is
|
|
345
378
|
* no option token. Routing and `locate` read a bare word through this rule.
|
|
346
379
|
*/
|
|
347
380
|
export declare function readsAsChild(command: BuiltCommand, token: string): boolean;
|
|
348
|
-
/**
|
|
349
|
-
|
|
381
|
+
/**
|
|
382
|
+
* Bare tokens, names or aliases, select children until a Command has none; a hyphen commits.
|
|
383
|
+
* `walked` receives the path after each name routes, so an unknown Command leaves its caller
|
|
384
|
+
* holding the partial path walked before it.
|
|
385
|
+
*/
|
|
386
|
+
export declare function route(root: BuiltCommand, tokens: readonly string[], walked?: (path: readonly string[]) => void): {
|
|
350
387
|
command: BuiltCommand;
|
|
351
388
|
path: string[];
|
|
352
389
|
tokens: string[];
|
|
@@ -363,8 +400,11 @@ export interface RoutedInvocation {
|
|
|
363
400
|
scan: OptionValues;
|
|
364
401
|
tokens: readonly string[];
|
|
365
402
|
}
|
|
366
|
-
/**
|
|
367
|
-
|
|
403
|
+
/**
|
|
404
|
+
* Consumes the globals table, then routes the remaining bare tokens to a Command. `walked`
|
|
405
|
+
* receives the path as routing extends it, the partial path of an unknown Command included.
|
|
406
|
+
*/
|
|
407
|
+
export declare function routeInvocation(graph: BuiltGraph, argv: readonly string[], walked: (path: readonly string[]) => void): RoutedInvocation;
|
|
368
408
|
/** What one invocation reaches the middleware chain with. */
|
|
369
409
|
export interface DispatchInvocation {
|
|
370
410
|
/** The channel the action receives, which the results lane builds from the routed node. */
|
|
@@ -373,6 +413,8 @@ export interface DispatchInvocation {
|
|
|
373
413
|
host: Host;
|
|
374
414
|
/** The graph `inspect()` returns for the run, built on its first read, which a source reads. */
|
|
375
415
|
inspected: () => CommandGraph;
|
|
416
|
+
/** Offers a configuration source's foreign throw to the translators where its call settles. */
|
|
417
|
+
offer: (thrown: unknown) => LoomError | undefined;
|
|
376
418
|
signal: AbortSignal;
|
|
377
419
|
/** The channel a configuration source writes through, whose results call names the source. */
|
|
378
420
|
sourceOut: Out<OpenResult>;
|