@loomcli/core 0.5.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.
Files changed (77) hide show
  1. package/dist/application.d.ts +18 -2
  2. package/dist/application.js +266 -71
  3. package/dist/bindings.d.ts +15 -10
  4. package/dist/bindings.js +34 -15
  5. package/dist/chain.d.ts +15 -6
  6. package/dist/chain.js +40 -20
  7. package/dist/command-rules.d.ts +55 -0
  8. package/dist/command-rules.js +142 -0
  9. package/dist/command.d.ts +65 -23
  10. package/dist/command.js +695 -226
  11. package/dist/controls.d.ts +8 -0
  12. package/dist/controls.js +23 -0
  13. package/dist/defect.d.ts +18 -0
  14. package/dist/defect.js +272 -0
  15. package/dist/developer.d.ts +24 -0
  16. package/dist/developer.js +52 -0
  17. package/dist/diagnostic-text.d.ts +81 -0
  18. package/dist/diagnostic-text.js +283 -0
  19. package/dist/diagnostic.d.ts +11 -0
  20. package/dist/diagnostic.js +70 -0
  21. package/dist/errors.d.ts +108 -24
  22. package/dist/errors.js +324 -53
  23. package/dist/exit-codes.d.ts +45 -0
  24. package/dist/exit-codes.js +46 -0
  25. package/dist/extension.d.ts +41 -8
  26. package/dist/extension.js +142 -57
  27. package/dist/facts.d.ts +66 -11
  28. package/dist/facts.js +98 -22
  29. package/dist/globals.d.ts +29 -21
  30. package/dist/globals.js +115 -46
  31. package/dist/hints.d.ts +79 -0
  32. package/dist/hints.js +247 -0
  33. package/dist/host.d.ts +13 -0
  34. package/dist/host.js +43 -1
  35. package/dist/identity.d.ts +19 -0
  36. package/dist/identity.js +72 -0
  37. package/dist/index.d.ts +11 -2
  38. package/dist/index.js +5 -0
  39. package/dist/input-rules.d.ts +64 -0
  40. package/dist/input-rules.js +145 -0
  41. package/dist/inspect.d.ts +12 -4
  42. package/dist/inspect.js +88 -28
  43. package/dist/lanes.js +1 -1
  44. package/dist/locate.js +4 -4
  45. package/dist/options.d.ts +23 -2
  46. package/dist/options.js +135 -44
  47. package/dist/output.d.ts +9 -2
  48. package/dist/output.js +18 -2
  49. package/dist/plain.d.ts +6 -0
  50. package/dist/plain.js +12 -0
  51. package/dist/plugin-rules.d.ts +62 -0
  52. package/dist/plugin-rules.js +155 -0
  53. package/dist/plugin.d.ts +22 -10
  54. package/dist/plugin.js +348 -116
  55. package/dist/prototypes.d.ts +7 -0
  56. package/dist/prototypes.js +29 -0
  57. package/dist/rendering.d.ts +6 -1
  58. package/dist/rendering.js +23 -5
  59. package/dist/rules.d.ts +51 -0
  60. package/dist/rules.js +115 -0
  61. package/dist/sequence.js +6 -1
  62. package/dist/sources.d.ts +6 -4
  63. package/dist/sources.js +22 -13
  64. package/dist/style-wire.js +1 -1
  65. package/dist/style.js +1 -1
  66. package/dist/theme.d.ts +4 -0
  67. package/dist/theme.js +25 -5
  68. package/dist/thenable.d.ts +15 -0
  69. package/dist/thenable.js +29 -0
  70. package/dist/translators.d.ts +69 -0
  71. package/dist/translators.js +253 -0
  72. package/dist/types.d.ts +11 -1
  73. package/dist/validation.d.ts +44 -3
  74. package/dist/validation.js +156 -57
  75. package/dist/view.d.ts +48 -14
  76. package/dist/view.js +155 -77
  77. package/package.json +1 -1
package/dist/plugin.d.ts CHANGED
@@ -1,15 +1,17 @@
1
1
  import type { MiddlewareContext } from './chain.js';
2
2
  import type { AttachedChild, Command } from './command.js';
3
- import type { AnyExtension, DescriptorRegistry } from './extension.js';
3
+ import type { AdmittedDescriptor, AnyExtension, DescriptorRegistry } from './extension.js';
4
4
  import type { InputRecords } from './globals.js';
5
+ import type { FailureHook } from './hints.js';
5
6
  import type { CommandGraph, OptionNode } from './inspect.js';
6
7
  import type { OptionValues } from './options.js';
7
8
  import type { ProcessSignal } from './signals.js';
8
9
  import type { Palette } from './style-state.js';
9
10
  import type { ContextualStyle, ThemeConstraint, ThemeMapping } from './style.js';
11
+ import type { Translation, TranslationContributor } from './translators.js';
10
12
  import type { CommandAttachHook, Host, OptionValue, Out, PluginOptionConfig } from './types.js';
11
13
  import type { OptionInput } from './validation.js';
12
- import type { ViewContribution } from './view.js';
14
+ import type { ViewContribution, ViewSubject } from './view.js';
13
15
  /**
14
16
  * The declaration record a plugin contributes its options under: the parsing part of an option
15
17
  * config, keyed by option name. A plugin option carries no schema and no presence rule, so the
@@ -78,9 +80,10 @@ interface SourceAnswer {
78
80
  type SourceResolver<Contributor extends Plugin | ((...args: never[]) => Plugin)> = (context: SourceContext<OptionsOf<Contributor>>) => Promise<Readonly<Record<string, SourceAnswer>>>;
79
81
  /**
80
82
  * Everything a plugin declares. `plugin()` checks every rule the definition carries on its own, and
81
- * creating and installing the value runs none of its code: a hook runs at graph build, the
82
- * middleware runs inside an invocation, and the configuration source runs in the input-source
83
- * stage when an unfilled option carries its binding.
83
+ * creating and installing the value runs none of its code: `onCommandAttach` runs at graph build,
84
+ * `onFailure` runs when `run()` renders a failure, the middleware runs inside an invocation, the
85
+ * configuration source runs in the input-source stage when an unfilled option carries its binding,
86
+ * and a translator runs when a foreign throw its key matches leaves the application's work.
84
87
  */
85
88
  interface PluginDefinition<Options extends PluginOptions = PluginOptions, Theme extends ThemeMapping = ThemeMapping> {
86
89
  theme?: Theme & ThemeConstraint<Theme>;
@@ -92,8 +95,10 @@ interface PluginDefinition<Options extends PluginOptions = PluginOptions, Theme
92
95
  }>;
93
96
  };
94
97
  onCommandAttach?: CommandAttachHook;
98
+ onFailure?: FailureHook;
95
99
  extensions?: readonly AnyExtension[];
96
100
  views?: readonly ViewContribution[];
101
+ translators?: readonly Translation[];
97
102
  signals?: readonly ('SIGINT' | 'SIGTERM')[];
98
103
  source?: {
99
104
  binding: AnyExtension & {
@@ -107,13 +112,16 @@ interface PluginDefinition<Options extends PluginOptions = PluginOptions, Theme
107
112
  }
108
113
  /**
109
114
  * One plugin: an identity and the contributions it carries. Creating and installing the value runs
110
- * none of its code: a hook runs at graph build, and the middleware runs inside an invocation, so an
111
- * installed plugin an invocation never reaches costs that invocation its hooks alone. Every rule
115
+ * none of its code: `onCommandAttach` runs at graph build, `onFailure` runs when `run()` renders a
116
+ * failure, and the middleware runs inside an invocation, so an installed plugin an invocation never
117
+ * reaches costs that invocation its hooks alone. Every rule
112
118
  * that one definition carries on its own throws here, before the value exists.
113
119
  */
114
120
  declare function plugin<Options extends PluginOptions = {}, const Theme extends ThemeMapping = {}>(identity: string, definition: PluginDefinition<Options, Theme>): Plugin<NoInfer<Options>, NoInfer<Theme>>;
115
121
  /** How every plugin diagnostic names one plugin at the start of a sentence. */
116
122
  declare function pluginSentence(identity: string): string;
123
+ /** The subject a plugin's `views` list reports under, and the call that declared it. */
124
+ declare function pluginViews(identity: string): ViewSubject;
117
125
  /** What the installed list resolves to: the plugins in order, and every descriptor they define. */
118
126
  interface InstalledPlugins {
119
127
  descriptors: DescriptorRegistry;
@@ -126,7 +134,7 @@ interface InstalledPlugins {
126
134
  * defensively, because a JavaScript author reaches it with any value. Each plugin's own rules
127
135
  * already ran at its `plugin()` call.
128
136
  */
129
- declare function installPlugins(plugins: unknown): InstalledPlugins;
137
+ declare function installPlugins(application: string, plugins: unknown): InstalledPlugins;
130
138
  /**
131
139
  * The default export one plugin loader resolves to, checked by the guard its caller supplies. A
132
140
  * loader that throws where it is called and one that rejects later are one failure, and a module
@@ -154,8 +162,12 @@ interface BuiltPlugin {
154
162
  theme: Palette | undefined;
155
163
  /** The hook core calls once per Command at graph build, or nothing where none is declared. */
156
164
  onCommandAttach: CommandAttachHook | undefined;
165
+ /** The hook core calls for each failure `run()` renders after graph build, or nothing. */
166
+ onFailure: FailureHook | undefined;
157
167
  /** The plugin's own `views` slot, read once the validated theme is in place. */
158
168
  views: unknown;
169
+ /** The translations the plugin registers, which resolve after the application's. */
170
+ translators: TranslationContributor;
159
171
  identity: string;
160
172
  inputs: readonly OptionInput[];
161
173
  middleware: BuiltMiddleware | undefined;
@@ -164,7 +176,7 @@ interface BuiltPlugin {
164
176
  /** The Commands the plugin attaches to the root, in list order. */
165
177
  commands: readonly AttachedChild[];
166
178
  /** Every descriptor the plugin defines or its options' values name, by identity. */
167
- descriptors: ReadonlyMap<string, AnyExtension>;
179
+ descriptors: ReadonlyMap<string, AdmittedDescriptor>;
168
180
  /** The extension record each of the plugin's own options carries. */
169
181
  records: InputRecords;
170
182
  }
@@ -183,4 +195,4 @@ declare function pluginValues(inputs: readonly OptionInput[], values: OptionValu
183
195
  declare function pluginSpellings(inputs: readonly OptionInput[], values: OptionValues): Readonly<Record<string, string>>;
184
196
  type ThemeOf<Contributor> = [Contributor] extends [never] ? {} : Contributor extends Plugin<PluginOptions, infer Theme> ? Theme : {};
185
197
  export type { ThemeOf, BuiltPlugin, BuiltSource, PluginValues, SourceAnswer, SourceContext, SourceResolver, Middleware, OptionsOf, Plugin, PluginDefinition, PluginOptions, PluginOptionSpellings, PluginOptionValues, };
186
- export { installPlugins, loadDefault, ownedSignals, plugin, pluginSentence, pluginSpellings, pluginValues, };
198
+ export { installPlugins, loadDefault, ownedSignals, plugin, pluginSentence, pluginSpellings, pluginViews, pluginValues, };