@loomcli/core 0.4.0 → 0.6.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/LICENSE +21 -0
- package/dist/application.d.ts +60 -31
- package/dist/application.js +356 -149
- package/dist/bindings.d.ts +31 -0
- package/dist/bindings.js +64 -0
- package/dist/chain.d.ts +26 -12
- package/dist/chain.js +59 -92
- package/dist/command-rules.d.ts +55 -0
- package/dist/command-rules.js +142 -0
- package/dist/command.d.ts +212 -93
- package/dist/command.js +1224 -454
- 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 +115 -26
- package/dist/errors.js +333 -54
- package/dist/exit-codes.d.ts +45 -0
- package/dist/exit-codes.js +46 -0
- package/dist/extension.d.ts +44 -9
- package/dist/extension.js +147 -65
- package/dist/facts.d.ts +71 -11
- package/dist/facts.js +108 -25
- package/dist/globals.d.ts +63 -22
- package/dist/globals.js +164 -39
- 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 +15 -4
- package/dist/index.js +6 -0
- package/dist/input-rules.d.ts +64 -0
- package/dist/input-rules.js +145 -0
- package/dist/inspect.d.ts +36 -5
- package/dist/inspect.js +125 -27
- package/dist/lanes.js +1 -1
- package/dist/locate.d.ts +41 -0
- package/dist/locate.js +121 -0
- package/dist/options.d.ts +96 -2
- package/dist/options.js +259 -71
- package/dist/output.d.ts +11 -2
- package/dist/output.js +23 -3
- package/dist/plain.d.ts +6 -0
- package/dist/plain.js +12 -0
- package/dist/plugin-rules.d.ts +62 -0
- package/dist/plugin-rules.js +155 -0
- package/dist/plugin.d.ts +121 -55
- package/dist/plugin.js +496 -126
- 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 +58 -0
- package/dist/sources.js +258 -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 +76 -21
- package/dist/validation.d.ts +65 -10
- package/dist/validation.js +314 -108
- package/dist/view.d.ts +49 -15
- package/dist/view.js +157 -79
- package/package.json +3 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Drew Butler
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/application.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import type { AfterAction, AttachmentConstraint, AfterArgument, AfterCommand, AfterResult, Command, CommandMethod, CommandState, ResultMethod } from './command.js';
|
|
1
|
+
import type { AfterAction, AttachmentConstraint, AfterArgument, AfterCommand, AfterResult, ChildOwner, Command, CommandMethod, CommandNodeHandle, CommandState, ResultMethod } from './command.js';
|
|
2
2
|
import type { ApplicationEnvironment, applicationEnvironment } from './environment.js';
|
|
3
3
|
import type { ExtensionValue } from './extension.js';
|
|
4
4
|
import type { GlobalsState } from './globals.js';
|
|
5
5
|
import type { CommandGraph } from './inspect.js';
|
|
6
|
-
import type { Plugin } from './plugin.js';
|
|
6
|
+
import type { BuiltPlugin, Plugin } from './plugin.js';
|
|
7
7
|
import type { RenderingPolicy } from './rendering.js';
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
8
|
+
import type { Translation, TranslatorRegistry } from './translators.js';
|
|
9
|
+
import type { Action, ArgumentConfig, ArgumentValue, declaredTypes, DeclaredTypes, DefaultConstraint, GlobalNameConstraint, GlobalOmissionConstraint, PerValueConstraint, NameConstraint, ExitCode, OptionConfig, OptionValue, ResultViews, ResultViewsOf, RowViews, RunOptions, ValidateOmittedConstraint } from './types.js';
|
|
10
|
+
import type { ViewContributions, ViewOverride } from './view.js';
|
|
10
11
|
/**
|
|
11
12
|
* Every authoring call an Application can publish, beside `run()` and `name`, which always remain.
|
|
12
13
|
* An Application's type state is a subset of these, and each call removes the names it invalidates.
|
|
@@ -14,14 +15,46 @@ import type { ViewOverride } from './view.js';
|
|
|
14
15
|
* to no bare token, so it has no name to alias.
|
|
15
16
|
*/
|
|
16
17
|
export type ApplicationMethod = Exclude<CommandMethod, 'alias'> | 'globalOption';
|
|
18
|
+
/**
|
|
19
|
+
* The build fact file, `loom.packet.json`, that the entry imports and hands to the Application.
|
|
20
|
+
* `build` is typed `string`, because a JSON module types its members that way, and the Application
|
|
21
|
+
* constructor accepts `development` or `distributed` alone. Core ignores every other member.
|
|
22
|
+
*/
|
|
23
|
+
export interface Packet {
|
|
24
|
+
readonly build: string;
|
|
25
|
+
}
|
|
17
26
|
export interface ApplicationOptions<Plugins extends readonly Plugin[] = readonly Plugin[]> {
|
|
18
27
|
rendering?: RenderingPolicy;
|
|
28
|
+
/** The packet that says whether this is a development build. With none, it is distributed. */
|
|
29
|
+
packet?: Packet;
|
|
19
30
|
views?: readonly ViewOverride[];
|
|
31
|
+
translators?: readonly Translation[];
|
|
20
32
|
plugins?: Plugins;
|
|
21
33
|
extensions?: readonly ExtensionValue<'command'>[];
|
|
22
34
|
description?: string;
|
|
23
35
|
version?: string;
|
|
24
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Everything an Application holds beside its root declaration and its globals, each part checked by
|
|
39
|
+
* the constructor or the call that set it.
|
|
40
|
+
*/
|
|
41
|
+
interface ApplicationConfig {
|
|
42
|
+
/** Whether the application's own `command()` or `action()` has run, which closes `globalOption()`. */
|
|
43
|
+
composed: boolean;
|
|
44
|
+
/** Whether the packet reads `development`, read once at construction. */
|
|
45
|
+
development: boolean;
|
|
46
|
+
/** Each installed plugin's view contributions, in installation order. */
|
|
47
|
+
contributors: readonly ViewContributions[];
|
|
48
|
+
facts: ApplicationFacts;
|
|
49
|
+
/** The parent that claimed each node the graph holds, so one value attaches at one point. */
|
|
50
|
+
owners: ReadonlyMap<CommandNodeHandle, ChildOwner>;
|
|
51
|
+
plugins: readonly BuiltPlugin[];
|
|
52
|
+
rendering: RenderingPolicy;
|
|
53
|
+
/** The application's translations, then each installed plugin's, in resolution order. */
|
|
54
|
+
translators: TranslatorRegistry;
|
|
55
|
+
/** The application's own view overrides. */
|
|
56
|
+
views: ViewContributions;
|
|
57
|
+
}
|
|
25
58
|
/**
|
|
26
59
|
* The Application holds the unnamed root's declaration state and applies the same transitions a
|
|
27
60
|
* Command does, so each declaration call has one typed implementation and no builder to recover.
|
|
@@ -30,19 +63,17 @@ declare class ApplicationBuilder<Args, Options, Globals, State extends Applicati
|
|
|
30
63
|
#private;
|
|
31
64
|
readonly [applicationEnvironment]: ApplicationEnvironment<Globals, Plugins>;
|
|
32
65
|
readonly [declaredTypes]: DeclaredTypes<Args, Options, Globals, Result>;
|
|
33
|
-
constructor(name: string,
|
|
34
|
-
|
|
35
|
-
views: unknown;
|
|
36
|
-
options?: unknown;
|
|
37
|
-
plugins: Plugins | undefined;
|
|
66
|
+
constructor(name: string, declared: {
|
|
67
|
+
config: ApplicationConfig;
|
|
38
68
|
globals: GlobalsState<Globals>;
|
|
69
|
+
root: CommandState<Args, Options, Globals>;
|
|
39
70
|
});
|
|
40
71
|
get name(): string;
|
|
41
|
-
argument<const Name extends string, const Config extends ArgumentConfig>(name: Name, config: Config & NameConstraint<Name> & NoInfer<DefaultConstraint<Config>> & NoInfer<ValidateOmittedConstraint<Config>>): Application<Args & Record<Name, ArgumentValue<Config>>, Options, Globals, AfterArgument<State>, Plugins, Result>;
|
|
42
|
-
option<const Name extends string, const Config extends OptionConfig>(name: Name, config: Config & NameConstraint<Name> & GlobalNameConstraint<Name, Globals> & NoInfer<DefaultConstraint<Config>> & NoInfer<
|
|
72
|
+
argument<const Name extends string, const Config extends ArgumentConfig>(name: Name, config: Config & NameConstraint<Name> & NoInfer<DefaultConstraint<Config>> & NoInfer<PerValueConstraint<Config>> & NoInfer<ValidateOmittedConstraint<Config>>): Application<Args & Record<Name, ArgumentValue<Config>>, Options, Globals, AfterArgument<State>, Plugins, Result>;
|
|
73
|
+
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>>): Application<Args, Options & Record<Name, OptionValue<Config>>, Globals, State, Plugins, Result>;
|
|
43
74
|
globalOption<const Name extends string, const Config extends OptionConfig>(name: Name, config: Config & NameConstraint<Name> & (Name extends keyof Options ? {
|
|
44
75
|
'This option name is already declared as a local option': Name;
|
|
45
|
-
} : unknown) & NoInfer<DefaultConstraint<Config>> & NoInfer<
|
|
76
|
+
} : unknown) & NoInfer<DefaultConstraint<Config>> & NoInfer<PerValueConstraint<Config>> & NoInfer<ValidateOmittedConstraint<Config>> & NoInfer<GlobalOmissionConstraint<Config>>): Application<Args, Options, Globals & Record<Name, OptionValue<Config>>, State, Plugins, Result>;
|
|
46
77
|
/** Registering the action closes input authoring; extension configuration remains available. */
|
|
47
78
|
action(handler: Action<Args, Globals & Options, Result>): Application<Args, Options, Globals, AfterAction, Plugins, Result>;
|
|
48
79
|
/** A child arrives in any type state, because its own action is the call that finished it. */
|
|
@@ -69,27 +100,26 @@ declare class ApplicationBuilder<Args, Options, Globals, State extends Applicati
|
|
|
69
100
|
default?: string;
|
|
70
101
|
}): Application<Args, Options, Globals, State, Plugins, Result>;
|
|
71
102
|
extend(...values: readonly ExtensionValue<'command'>[]): Application<Args, Options, Globals, State, Plugins, Result>;
|
|
103
|
+
/** The globals table the root's options and every joining subtree meet. */
|
|
104
|
+
private table;
|
|
72
105
|
/**
|
|
73
|
-
* Root declaration calls preserve the Application configuration
|
|
74
|
-
* travels through this call: each method names its transition in its return type,
|
|
75
|
-
* wrapper publishes the same runtime value in exactly that state.
|
|
106
|
+
* Root declaration calls preserve the Application configuration, with the parts a call changed.
|
|
107
|
+
* The next state travels through this call: each method names its transition in its return type,
|
|
108
|
+
* and the wrapper publishes the same runtime value in exactly that state.
|
|
76
109
|
*/
|
|
77
110
|
private derive;
|
|
78
111
|
/**
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* reaches them, while a fault in that list itself reports through core's own text. The merged
|
|
84
|
-
* registry is published once the whole build has succeeded, so a build-time fault never resolves
|
|
85
|
-
* through a plugin's overrides, which build has not yet validated.
|
|
112
|
+
* The graph build, which applies the rules no earlier moment could know: the root's
|
|
113
|
+
* finished-Command rules and every lifecycle hook's contribution. The application's own overrides
|
|
114
|
+
* are published first, so a build fault reports through them. The merged registry is published
|
|
115
|
+
* once the build has succeeded, so a build fault never resolves through a plugin's overrides.
|
|
86
116
|
*/
|
|
87
117
|
private prepare;
|
|
88
118
|
/**
|
|
89
|
-
* The built graph as plain, frozen data. It
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
119
|
+
* The built graph as plain, frozen data. It builds the graph as `run()` does and throws
|
|
120
|
+
* `DeclarationError` for the same build faults. Validating a declared default through its schema
|
|
121
|
+
* can be asynchronous, so that one rule stays in `run()`. Nothing is cached: each call builds the
|
|
122
|
+
* graph anew.
|
|
93
123
|
*/
|
|
94
124
|
inspect(): CommandGraph;
|
|
95
125
|
run(options?: RunOptions): Promise<ExitCode>;
|
|
@@ -107,11 +137,10 @@ interface ApplicationConstructor {
|
|
|
107
137
|
new (name: string): Application<{}, {}, {}, ApplicationMethod, readonly []>;
|
|
108
138
|
new <const Plugins extends readonly Plugin[] = readonly []>(name: string, options: ApplicationOptions<Plugins>): Application<{}, {}, {}, ApplicationMethod, Plugins>;
|
|
109
139
|
}
|
|
110
|
-
/** The
|
|
111
|
-
interface
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
version: unknown;
|
|
140
|
+
/** The core facts one Application declares, validated at construction and reported by `inspect()`. */
|
|
141
|
+
interface ApplicationFacts {
|
|
142
|
+
description: string | undefined;
|
|
143
|
+
version: string;
|
|
115
144
|
}
|
|
116
145
|
export declare const Application: ApplicationConstructor;
|
|
117
146
|
export {};
|