@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.
Files changed (52) hide show
  1. package/NOTICE +34 -0
  2. package/dist/application.d.ts +11 -6
  3. package/dist/application.js +57 -19
  4. package/dist/capture.d.ts +65 -0
  5. package/dist/capture.js +99 -0
  6. package/dist/chain.d.ts +28 -17
  7. package/dist/chain.js +11 -10
  8. package/dist/command-rules.d.ts +1 -1
  9. package/dist/command-rules.js +2 -2
  10. package/dist/command.d.ts +31 -47
  11. package/dist/command.js +204 -209
  12. package/dist/errors.d.ts +22 -21
  13. package/dist/errors.js +38 -18
  14. package/dist/facts.d.ts +5 -0
  15. package/dist/facts.js +8 -1
  16. package/dist/globals.d.ts +48 -22
  17. package/dist/globals.js +72 -29
  18. package/dist/glyphs.generated.js +1 -1
  19. package/dist/index.d.ts +5 -3
  20. package/dist/index.js +3 -1
  21. package/dist/input-rules.d.ts +20 -2
  22. package/dist/input-rules.js +47 -5
  23. package/dist/inspect.d.ts +33 -17
  24. package/dist/inspect.js +74 -87
  25. package/dist/locate.js +52 -60
  26. package/dist/options.d.ts +101 -83
  27. package/dist/options.js +311 -267
  28. package/dist/parse.d.ts +162 -0
  29. package/dist/parse.js +601 -0
  30. package/dist/plain.d.ts +52 -2
  31. package/dist/plain.js +228 -2
  32. package/dist/plugin-rules.d.ts +8 -4
  33. package/dist/plugin-rules.js +13 -9
  34. package/dist/plugin-settings.d.ts +18 -0
  35. package/dist/plugin-settings.js +38 -0
  36. package/dist/plugin.d.ts +32 -27
  37. package/dist/plugin.js +107 -89
  38. package/dist/sources.d.ts +18 -9
  39. package/dist/sources.js +50 -20
  40. package/dist/style-layout.js +2 -2
  41. package/dist/style-width.d.ts +13 -0
  42. package/dist/style-width.js +170 -0
  43. package/dist/types.d.ts +70 -30
  44. package/dist/unicode.generated.d.ts +27 -0
  45. package/dist/unicode.generated.js +1036 -0
  46. package/dist/validation.d.ts +108 -34
  47. package/dist/validation.js +282 -125
  48. package/dist/view.d.ts +16 -11
  49. package/dist/view.js +13 -4
  50. package/licenses/unicode-LICENSE.txt +41 -0
  51. package/licenses/uucode-LICENSE.md +35 -0
  52. package/package.json +9 -5
package/dist/options.d.ts CHANGED
@@ -8,33 +8,123 @@ export interface OptionValues {
8
8
  strings: Map<string, string>;
9
9
  lists: Map<string, string[]>;
10
10
  booleans: Map<string, boolean>;
11
+ /** How many times each counted option was supplied, or the count an input source filled. */
12
+ counts: Map<string, number>;
11
13
  /** The spelling of the token that supplied each parsed option, which no input source writes. */
12
14
  spellings: Map<string, string>;
15
+ /**
16
+ * For each string option a bare spelling supplied, the positions that held its implied value: `0`
17
+ * for a scalar, and each such occurrence's index in a multiple option's list. Validation supplies
18
+ * the implied value's prepared output there, and no input source writes it.
19
+ */
20
+ implied: Map<string, number[]>;
13
21
  }
14
- /** Every parsed value lands in one of these maps; `lists` holds the repeated string options. */
22
+ /**
23
+ * Every parsed value lands in one of these maps; `lists` holds the repeated string options and
24
+ * `counts` the counted ones.
25
+ */
15
26
  export declare function emptyValues(): OptionValues;
16
- /** Which accepted form a table entry is. The table owns the convention, so readers never re-derive it. */
17
- export type SpellingRole = 'long' | 'negative' | 'short';
27
+ /**
28
+ * Which accepted form a table entry is, and for an alias's spelling, positive or negative, its place
29
+ * in `aliases`. The table owns the convention, so readers never re-derive it.
30
+ */
31
+ export type SpellingOrigin = {
32
+ role: 'long' | 'negative' | 'short';
33
+ } | {
34
+ role: 'alias';
35
+ index: number;
36
+ };
37
+ /**
38
+ * How one option reads words: its kind, and its value class, of which there are four: a Boolean
39
+ * option, a counted option, a string option with an implied value, which never takes the next word
40
+ * and supplies `implied` when its spelling is bare, and a string option that takes the next word as
41
+ * its value when nothing is attached. Compiling the table derives the class once, and the parser, a
42
+ * rebound occurrence, and `locate` read that one fact.
43
+ */
18
44
  type OptionForm = {
19
45
  type: 'string';
46
+ valueClass: 'separate';
47
+ name: string;
48
+ multiple: boolean;
49
+ } | {
50
+ type: 'string';
51
+ valueClass: 'implied';
20
52
  name: string;
21
53
  multiple: boolean;
54
+ implied: string;
22
55
  } | {
23
56
  type: 'boolean';
57
+ valueClass: 'boolean';
24
58
  name: string;
25
59
  value: boolean;
60
+ } | {
61
+ type: 'count';
62
+ valueClass: 'count';
63
+ name: string;
26
64
  };
27
- type OptionSpelling = OptionForm & {
28
- role: SpellingRole;
65
+ export type OptionSpelling = OptionForm & SpellingOrigin;
66
+ /**
67
+ * One entry of a Command's spelling table: a spelling of one declaration, and whether that
68
+ * declaration is a global option, whose value every action reads, or the Command's own.
69
+ */
70
+ export type TableSpelling = OptionSpelling & {
71
+ readonly global: boolean;
29
72
  };
73
+ /** The one table the parser reads a Command's words against, keyed by spelling. */
74
+ export type SpellingTable = ReadonlyMap<string, TableSpelling>;
75
+ /** One scope's compiled spellings as table entries, each marked with whether the scope is global. */
76
+ export declare function tableEntries(spellings: ReadonlyMap<string, OptionSpelling>, global: boolean): [string, TableSpelling][];
77
+ /** The accepted spellings of one option, `null` where the declaration publishes none. */
78
+ export interface Spellings {
79
+ long: string | null;
80
+ negative: string | null;
81
+ short: string | null;
82
+ }
30
83
  /**
31
- * The part of one declaration that yields a spelling of the given role, which a spelling fault
32
- * marks: the declared name for the long form, `short` for the short alias, and the `polarity` that
33
- * generates a negative form.
84
+ * Reads one option's spellings out of a compiled table, so a reader cannot report a form the parser
85
+ * does not accept. Each entry carries its own role, so the naming convention has one owner: the
86
+ * table that writes it.
34
87
  */
35
- export declare function spellingMark(site: InputSite, role: SpellingRole): string;
88
+ export declare function spellingsOf(table: ReadonlyMap<string, OptionSpelling>, name: string): Spellings;
89
+ /**
90
+ * The spelling every reported problem names an option by: its long form, a negative-only Boolean
91
+ * option's negative form, and otherwise its short form, which a short-only option alone publishes.
92
+ * The problem belongs to the option, so an alias or the spelling the operator typed is never it.
93
+ */
94
+ export declare function reportedOf({ long, negative, short }: Spellings, name: string): string;
95
+ /**
96
+ * The part of one declaration that yields a spelling of the given origin, which a spelling fault
97
+ * marks: the declared name for the long form, `short` for the short alias, the `polarity` that
98
+ * generates a negative form, and the alias in `aliases` for either form of an alias.
99
+ */
100
+ export declare function spellingMark(site: InputSite, origin: SpellingOrigin): string;
36
101
  /** The declared name answers the declared-name rule an argument's name answers. */
37
102
  export declare function checkOptionName(name: unknown, site: InputSite): void;
103
+ /**
104
+ * The one name rule for an argument, option, alias of an option, or view name: a bare token the
105
+ * parser can read, nonempty, with no leading hyphen, whitespace, or `=`, which it reads apart.
106
+ */
107
+ export declare function isDeclaredName(name: unknown): name is string;
108
+ /** The one correction every declared-name diagnostic for a string ends with. */
109
+ export declare const declaredNameCorrection = "Use a nonempty name without a leading hyphen, whitespace, or \"=\".";
110
+ /** The sentence and correction of each repeated-alias fault, for the Command or option `subject` names. */
111
+ export declare function repeatedAliasText(subject: string, alias: string): {
112
+ own: {
113
+ correction: string;
114
+ sentence: string;
115
+ };
116
+ twice: {
117
+ correction: string;
118
+ sentence: string;
119
+ };
120
+ };
121
+ /** Whether a declared short alias is one ASCII letter, the rule every short spelling answers. */
122
+ export declare function isShortAlias(short: unknown): boolean;
123
+ /** The sentence and correction of the short-alias fault for the option `subject` names. */
124
+ export declare function shortAliasText(subject: string): {
125
+ sentence: string;
126
+ correction: string;
127
+ };
38
128
  /**
39
129
  * The scope one table compiles: the phrase a repeated name names it by, and where each of its
40
130
  * options was declared, which every fault's findings rebuild.
@@ -46,8 +136,8 @@ export interface CompileScope<Declaration extends OptionDeclaration> {
46
136
  /**
47
137
  * One Boolean option's value for one invocation: the value the parser consumed, or the value its
48
138
  * declared polarity gives an absent option. A negative-only option is absent as `true`, because its
49
- * one spelling turns the value off. Every scope reads it here, so a plugin option and a validated
50
- * declaration answer the same rule.
139
+ * one spelling turns the value off. Validation reads every Boolean option's value here, whichever
140
+ * scope declared it.
51
141
  */
52
142
  export declare function booleanValue(values: OptionValues, name: string, config: OptionConfig): boolean;
53
143
  /**
@@ -55,58 +145,6 @@ export declare function booleanValue(values: OptionValues, name: string, config:
55
145
  * declaration answers alone and every rule two of them answer together.
56
146
  */
57
147
  export declare function compileOptions<Declaration extends OptionDeclaration>(declarations: readonly Declaration[], scope: CompileScope<Declaration>): Map<string, OptionSpelling>;
58
- /**
59
- * Whether a token reads as an option: it starts with a hyphen. Routing stops at one, and a
60
- * separate value is never one. The parser and `locate` read each token through this rule.
61
- */
62
- export declare function isOptionToken(token: string): boolean;
63
- /** A long option token and the inline value it carries after its first `=`, if any. */
64
- export interface LongToken {
65
- spelling: string;
66
- inline: string | undefined;
67
- }
68
- /**
69
- * A token that starts with `--` split at its first `=` into the spelling and the inline value, or
70
- * `undefined` for any other token. The parser and `locate` split long tokens through this rule.
71
- */
72
- export declare function longToken(token: string): LongToken | undefined;
73
- /**
74
- * The name of the string option one long spelling names in a table, which takes its value after
75
- * `=`, or `undefined` for a Boolean, negative, short, or unknown spelling.
76
- */
77
- export declare function longStringOption(spellings: ReadonlyMap<string, OptionSpelling>, spelling: string): string | undefined;
78
- /**
79
- * A string option whose value the next token supplies, where the tokens ended first. A complete
80
- * invocation reports it as a missing value; a partial one reads the next word as that value.
81
- */
82
- export interface AwaitingValue {
83
- name: string;
84
- spelling: string;
85
- }
86
- /** One option name a token newly supplied, with the index of that token in the list read. */
87
- export interface SuppliedOption {
88
- name: string;
89
- token: number;
90
- }
91
- /**
92
- * The pre-scan's reading of a token list that may stop short. `positions` holds the index in
93
- * `tokens` of each `rest` token, and `awaiting` is the global option the last token left without
94
- * its value.
95
- */
96
- export interface GlobalScan {
97
- awaiting: AwaitingValue | undefined;
98
- positions: number[];
99
- rest: string[];
100
- supplied: SuppliedOption[];
101
- values: OptionValues;
102
- }
103
- /** Consumes global options anywhere before the passthrough delimiter and leaves the rest routable. */
104
- export declare function scanGlobals(spellings: ReadonlyMap<string, OptionSpelling>, tokens: readonly string[]): GlobalScan;
105
- /** The pre-scan of a complete invocation, where a global still waiting for its value is a fault. */
106
- export declare function extractGlobals(spellings: ReadonlyMap<string, OptionSpelling>, tokens: readonly string[]): {
107
- rest: string[];
108
- values: OptionValues;
109
- };
110
148
  /**
111
149
  * Whether one option holds a value a tier supplied: a token in any spelling it accepts, or a fill
112
150
  * from an input source. A declared default is never in these maps, so it never counts.
@@ -116,24 +154,4 @@ export declare function isSupplied(values: OptionValues, name: string): boolean;
116
154
  export declare function copyValues(values: OptionValues): OptionValues;
117
155
  /** Global and local keys never overlap, so one merged view feeds a single validation pass. */
118
156
  export declare function mergeValues(globals: OptionValues, locals: OptionValues): OptionValues;
119
- /**
120
- * One Command's reading of its own tokens, which may stop short. `delimited` says a bare `--` was
121
- * read, and `awaiting` is the option the last token left without its value.
122
- */
123
- export interface InputScan {
124
- awaiting: AwaitingValue | undefined;
125
- delimited: boolean;
126
- options: OptionValues;
127
- passthrough: string[];
128
- positionals: string[];
129
- supplied: SuppliedOption[];
130
- }
131
- /** Reads one Command's tokens into options, positionals, and the passthrough tail. */
132
- export declare function scanInputs(spellings: ReadonlyMap<string, OptionSpelling>, tokens: readonly string[]): InputScan;
133
- /** Parses a complete invocation's local tokens, where a waiting option is a missing value. */
134
- export declare function parseInputs(spellings: ReadonlyMap<string, OptionSpelling>, tokens: readonly string[]): {
135
- options: OptionValues;
136
- passthrough: string[];
137
- positionals: string[];
138
- };
139
157
  export {};