@loomcli/core 0.6.0 → 0.8.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 +11 -6
- package/dist/application.js +57 -19
- package/dist/capture.d.ts +65 -0
- package/dist/capture.js +99 -0
- package/dist/chain.d.ts +28 -17
- package/dist/chain.js +11 -10
- package/dist/command-rules.d.ts +1 -1
- package/dist/command-rules.js +2 -2
- package/dist/command.d.ts +31 -47
- package/dist/command.js +204 -209
- package/dist/errors.d.ts +22 -21
- package/dist/errors.js +38 -18
- package/dist/facts.d.ts +5 -0
- package/dist/facts.js +8 -1
- package/dist/globals.d.ts +48 -22
- package/dist/globals.js +72 -29
- package/dist/glyphs.generated.js +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +3 -1
- package/dist/input-rules.d.ts +20 -2
- package/dist/input-rules.js +47 -5
- package/dist/inspect.d.ts +33 -17
- package/dist/inspect.js +74 -87
- package/dist/locate.js +52 -60
- package/dist/options.d.ts +101 -83
- package/dist/options.js +311 -267
- package/dist/parse.d.ts +162 -0
- package/dist/parse.js +601 -0
- package/dist/plain.d.ts +52 -2
- package/dist/plain.js +228 -2
- package/dist/plugin-rules.d.ts +8 -4
- package/dist/plugin-rules.js +13 -9
- package/dist/plugin-settings.d.ts +18 -0
- package/dist/plugin-settings.js +38 -0
- package/dist/plugin.d.ts +32 -27
- package/dist/plugin.js +107 -89
- package/dist/sources.d.ts +18 -9
- package/dist/sources.js +50 -20
- package/dist/style-layout.js +2 -2
- package/dist/style-width.d.ts +13 -0
- package/dist/style-width.js +170 -0
- package/dist/types.d.ts +70 -30
- package/dist/unicode.generated.d.ts +27 -0
- package/dist/unicode.generated.js +1036 -0
- package/dist/validation.d.ts +108 -34
- package/dist/validation.js +282 -125
- package/dist/view.d.ts +16 -11
- package/dist/view.js +13 -4
- 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
|
@@ -4,12 +4,12 @@ import type { LoomError } from './errors.js';
|
|
|
4
4
|
import type { AdmittedDescriptor, DescriptorRegistry, ExtensionRecords, ExtensionStore, ExtensionSubject, ExtensionValue } from './extension.js';
|
|
5
5
|
import type { BuiltGlobals, GlobalsState, GlobalTable, InputRecords } from './globals.js';
|
|
6
6
|
import type { CommandGraph, CommandNode } from './inspect.js';
|
|
7
|
-
import {
|
|
8
|
-
import type {
|
|
7
|
+
import type { OptionValues, SpellingTable } from './options.js';
|
|
8
|
+
import type { ParsedInvocation } from './parse.js';
|
|
9
9
|
import type { BuiltPlugin } from './plugin.js';
|
|
10
10
|
import type { ContextualStyle } from './style.js';
|
|
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';
|
|
12
|
-
import type { ArgumentInput,
|
|
11
|
+
import type { Action, ActionChannel, ArgumentConfig, ArgumentValue, declaredTypes, DeclaredResult, DeclaredTypes, DefaultConstraint, ImpliedConstraint, GlobalNameConstraint, Host, PerValueConstraint, NameConstraint, OpenResult, OptionConfig, OptionValue, Out, Request, ResultBinding, ResultViews, ResultViewsOf, RowViews, ValidateOmittedConstraint } from './types.js';
|
|
12
|
+
import type { ArgumentInput, InputPlaces, InputDeclaration, OptionInput, DeclaredValues, ValidatedInputs } from './validation.js';
|
|
13
13
|
/** One positional slot: the declaration it fills and whether it takes the remaining tokens. */
|
|
14
14
|
export interface ArgumentSlot {
|
|
15
15
|
input: InputDeclaration;
|
|
@@ -58,7 +58,12 @@ export interface BuiltCommand {
|
|
|
58
58
|
hidden: boolean;
|
|
59
59
|
inputs: readonly InputDeclaration[];
|
|
60
60
|
name: string | null;
|
|
61
|
-
|
|
61
|
+
/**
|
|
62
|
+
* The one table the parser reads this Command's words against, built after every lifecycle hook
|
|
63
|
+
* ran: its own options, hook-declared ones included, and every global option. Each entry names
|
|
64
|
+
* one declaration, so a group's table holds the global options alone.
|
|
65
|
+
*/
|
|
66
|
+
table: SpellingTable;
|
|
62
67
|
/** The result the Command declares, or nothing where it declares none. */
|
|
63
68
|
/** The built declaration is the shape the write site reads, so the channel carries it. */
|
|
64
69
|
result: DeclaredResult | undefined;
|
|
@@ -290,14 +295,14 @@ export interface BuiltGraph {
|
|
|
290
295
|
* The globals table compiles once per build and the whole graph shares it. The root's registry
|
|
291
296
|
* holds every descriptor the Application names, so a hook's `extend()` call meets all of them.
|
|
292
297
|
*/
|
|
293
|
-
export declare function buildGraph<Args, Options, Globals>(root: CommandState<Args, Options, Globals>, globals: GlobalsState
|
|
298
|
+
export declare function buildGraph<Args, Options, Globals>(root: CommandState<Args, Options, Globals>, globals: GlobalsState, plugins: readonly BuiltPlugin[]): BuiltGraph;
|
|
294
299
|
export declare class CommandBuilder<Args, Options, Globals, State extends CommandMethod = CommandMethod, Result = unknown> {
|
|
295
300
|
#private;
|
|
296
301
|
readonly [commandValue]: true;
|
|
297
302
|
readonly [declaredTypes]: DeclaredTypes<Args, Options, Globals, Result>;
|
|
298
303
|
constructor(name: string, state: CommandState<Args, Options, Globals>);
|
|
299
304
|
argument<const Name extends string, const Config extends ArgumentConfig>(name: Name, config: Config & NameConstraint<Name> & NoInfer<DefaultConstraint<Config>> & NoInfer<PerValueConstraint<Config>> & NoInfer<ValidateOmittedConstraint<Config>>): Command<Args & Record<Name, ArgumentValue<Config>>, Options, Globals, AfterArgument<State>, Result>;
|
|
300
|
-
option<const Name extends string, const Config extends OptionConfig>(name: Name, config: Config & NameConstraint<Name> & GlobalNameConstraint<Name, Globals> & NoInfer<DefaultConstraint<Config>> & NoInfer<PerValueConstraint<Config>> & NoInfer<ValidateOmittedConstraint<Config>>): Command<Args, Options & Record<Name, OptionValue<Config>>, Globals, State, Result>;
|
|
305
|
+
option<const Name extends string, const Config extends OptionConfig>(name: Name, config: Config & NameConstraint<Name> & GlobalNameConstraint<Name, Globals> & NoInfer<DefaultConstraint<Config>> & NoInfer<ImpliedConstraint<Config>> & NoInfer<PerValueConstraint<Config>> & NoInfer<ValidateOmittedConstraint<Config>>): Command<Args, Options & Record<Name, OptionValue<Config>>, Globals, State, Result>;
|
|
301
306
|
/**
|
|
302
307
|
* Aliases are other portable names that route to this Command. They invalidate no call, and the
|
|
303
308
|
* tuple rest parameter rejects a call that names none.
|
|
@@ -369,48 +374,20 @@ export declare const Command: CommandConstructor;
|
|
|
369
374
|
/** Every declaration in the graph, so defaults are validated before any token is read. */
|
|
370
375
|
export declare function collectInputs(command: BuiltCommand): InputDeclaration[];
|
|
371
376
|
/**
|
|
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,
|
|
377
|
+
* Where every input of one graph was declared: each global option at its `globalOption()` call or
|
|
378
|
+
* in its plugin's `options` record, and each Command's own inputs at their calls on the Command,
|
|
379
|
+
* under its path from the root.
|
|
374
380
|
*/
|
|
375
381
|
export declare function inputPlaces(graph: BuiltGraph): InputPlaces;
|
|
376
|
-
/**
|
|
377
|
-
* Whether a token names one of the Command's children: the Command has children and the token is
|
|
378
|
-
* no option token. Routing and `locate` read a bare word through this rule.
|
|
379
|
-
*/
|
|
380
|
-
export declare function readsAsChild(command: BuiltCommand, token: string): boolean;
|
|
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): {
|
|
387
|
-
command: BuiltCommand;
|
|
388
|
-
path: string[];
|
|
389
|
-
tokens: string[];
|
|
390
|
-
};
|
|
391
|
-
/**
|
|
392
|
-
* The slot the positional at one index fills: the slot at that index, else a variadic last slot,
|
|
393
|
-
* which accepts every later positional, else none. Binding and `locate` read positions through it.
|
|
394
|
-
*/
|
|
395
|
-
export declare function argumentSlot(slots: readonly ArgumentSlot[], position: number): ArgumentSlot | undefined;
|
|
396
|
-
/** One invocation after the pre-scan and routing, which the middleware chain runs on top of. */
|
|
397
|
-
export interface RoutedInvocation {
|
|
398
|
-
command: BuiltCommand;
|
|
399
|
-
path: readonly string[];
|
|
400
|
-
scan: OptionValues;
|
|
401
|
-
tokens: readonly string[];
|
|
402
|
-
}
|
|
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;
|
|
408
382
|
/** What one invocation reaches the middleware chain with. */
|
|
409
383
|
export interface DispatchInvocation {
|
|
410
384
|
/** The channel the action receives, which the results lane builds from the routed node. */
|
|
411
385
|
channel: (binding: ResultBinding) => ActionChannel;
|
|
412
|
-
defaults: DefaultValues;
|
|
413
386
|
host: Host;
|
|
387
|
+
/** Where every input of the graph was declared, which a broken validator's finding rebuilds. */
|
|
388
|
+
places: InputPlaces;
|
|
389
|
+
/** Every declared default and implied value, validated before any token was read. */
|
|
390
|
+
declaredValues: DeclaredValues;
|
|
414
391
|
/** The graph `inspect()` returns for the run, built on its first read, which a source reads. */
|
|
415
392
|
inspected: () => CommandGraph;
|
|
416
393
|
/** Offers a configuration source's foreign throw to the translators where its call settles. */
|
|
@@ -425,11 +402,14 @@ export interface DispatchInvocation {
|
|
|
425
402
|
* reads and the call that dispatches; `'held'` carries the fault this phase found, which core
|
|
426
403
|
* raises at the dispatch boundary and never before, so a takeover swallows it. `result` is what the
|
|
427
404
|
* routed Command declared, whose views a middleware selects among, on either shape. `globals` holds
|
|
428
|
-
* the globals table's values after the input-source stage, which activation and
|
|
429
|
-
*
|
|
405
|
+
* the globals table's values after the input-source stage, which activation and each plugin's
|
|
406
|
+
* spellings read on either shape. `options` is every global option's validated value, which every
|
|
407
|
+
* middleware reads, or `null` when a global option has a structural fault or was rejected, or the
|
|
408
|
+
* values could not be read.
|
|
430
409
|
*/
|
|
431
410
|
export type Prepared = {
|
|
432
411
|
globals: OptionValues;
|
|
412
|
+
options: Readonly<Record<string, unknown>> | null;
|
|
433
413
|
result: DeclaredResult | undefined;
|
|
434
414
|
} & ({
|
|
435
415
|
dispatch: (view: string | null) => Promise<void>;
|
|
@@ -443,8 +423,12 @@ export type Prepared = {
|
|
|
443
423
|
/**
|
|
444
424
|
* Prepares one dispatch ahead of the middleware chain and holds whatever fault it found, so a
|
|
445
425
|
* middleware reads the request before the action runs and a takeover never observes the fault.
|
|
446
|
-
* The phases run in order:
|
|
447
|
-
*
|
|
426
|
+
* The phases run in order: the structural fault parsing held, a group's missing subcommand, the
|
|
427
|
+
* input-source stage, and validation. Either of the first two outranks a configuration source's
|
|
428
|
+
* fault, and a source's fault takes the place of every validation problem. Validation checks the
|
|
429
|
+
* global options whatever was held, so a middleware reads them after a local fault; a structural
|
|
430
|
+
* fault on a global option, a rejected global option, a source's fault, or a validator's own fault
|
|
431
|
+
* leaves `options` `null`.
|
|
448
432
|
*/
|
|
449
|
-
export declare function prepareDispatch(graph: BuiltGraph, routed:
|
|
433
|
+
export declare function prepareDispatch(graph: BuiltGraph, routed: ParsedInvocation, invocation: DispatchInvocation): Promise<Prepared>;
|
|
450
434
|
export {};
|