@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
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** A slot that holds a list, such as `plugins` or `commands`, holding a value of another kind. */
|
|
2
|
+
declare const notAList: import("./diagnostic-text.js").DiagnosticRule;
|
|
3
|
+
/**
|
|
4
|
+
* A declaration core reads by its keys, such as a plugin's middleware or a constructor's options,
|
|
5
|
+
* that is not an object.
|
|
6
|
+
*/
|
|
7
|
+
declare const notAnObject: import("./diagnostic-text.js").DiagnosticRule;
|
|
8
|
+
/**
|
|
9
|
+
* A declaration whose read throws while core takes its one copy, such as a getter that throws or a
|
|
10
|
+
* proxy whose trap throws: the config of an argument or option, a plugin's definition and each of
|
|
11
|
+
* its option declarations, and the options of a Command or of the Application.
|
|
12
|
+
*/
|
|
13
|
+
declare const unreadableDeclaration: import("./diagnostic-text.js").DiagnosticRule;
|
|
14
|
+
/** A list entry that its factory did not build, such as a hand-made plugin or translation. */
|
|
15
|
+
declare const foreignValue: import("./diagnostic-text.js").DiagnosticRule;
|
|
16
|
+
/** One plugin identity installed twice. */
|
|
17
|
+
declare const pluginInstalledTwice: import("./diagnostic-text.js").DiagnosticRule;
|
|
18
|
+
/** A second plugin claiming the theme, the signals, or the configuration source slot. */
|
|
19
|
+
declare const slotTaken: import("./diagnostic-text.js").DiagnosticRule;
|
|
20
|
+
/** A plugin, extension, or view identity outside the identity grammar. */
|
|
21
|
+
declare const invalidIdentity: import("./diagnostic-text.js").DiagnosticRule;
|
|
22
|
+
/** A validator or a presence rule on a plugin option. */
|
|
23
|
+
declare const pluginOptionRule: import("./diagnostic-text.js").DiagnosticRule;
|
|
24
|
+
/** A middleware activation that is missing, empty, or names an option the plugin lacks. */
|
|
25
|
+
declare const middlewareActivation: import("./diagnostic-text.js").DiagnosticRule;
|
|
26
|
+
/** A loader, a hook, or a translator that core cannot call. */
|
|
27
|
+
declare const notAFunction: import("./diagnostic-text.js").DiagnosticRule;
|
|
28
|
+
/** A claimed signal outside SIGINT and SIGTERM. */
|
|
29
|
+
declare const unknownSignal: import("./diagnostic-text.js").DiagnosticRule;
|
|
30
|
+
/** One signal claimed twice by one plugin. */
|
|
31
|
+
declare const signalClaimedTwice: import("./diagnostic-text.js").DiagnosticRule;
|
|
32
|
+
/** A configuration source binding that is not one of the plugin's option extensions. */
|
|
33
|
+
declare const sourceBinding: import("./diagnostic-text.js").DiagnosticRule;
|
|
34
|
+
/** A plugin option that carries its own plugin's source binding. */
|
|
35
|
+
declare const sourceBoundOwnOption: import("./diagnostic-text.js").DiagnosticRule;
|
|
36
|
+
/** Two distinct objects under one extension or declared-view identity. */
|
|
37
|
+
declare const twoPackageCopies: import("./diagnostic-text.js").DiagnosticRule;
|
|
38
|
+
/** A descriptor with no Standard Schema. */
|
|
39
|
+
declare const extensionWithoutSchema: import("./diagnostic-text.js").DiagnosticRule;
|
|
40
|
+
/** An extension value on a declaration its descriptor does not target. */
|
|
41
|
+
declare const extensionTarget: import("./diagnostic-text.js").DiagnosticRule;
|
|
42
|
+
/** Two values of one extension in one layer. */
|
|
43
|
+
declare const extensionValueTwice: import("./diagnostic-text.js").DiagnosticRule;
|
|
44
|
+
/** An extension value its schema rejects, by an issue or by a throw. */
|
|
45
|
+
declare const invalidExtensionValue: import("./diagnostic-text.js").DiagnosticRule;
|
|
46
|
+
/** An extension schema that answers with a promise. */
|
|
47
|
+
declare const asyncExtensionSchema: import("./diagnostic-text.js").DiagnosticRule;
|
|
48
|
+
/** An extension output that is not plain data. */
|
|
49
|
+
declare const extensionOutput: import("./diagnostic-text.js").DiagnosticRule;
|
|
50
|
+
/** An override whose key is neither a declared view nor a failure class. */
|
|
51
|
+
declare const overrideKey: import("./diagnostic-text.js").DiagnosticRule;
|
|
52
|
+
/** One key overridden twice inside one contributor. */
|
|
53
|
+
declare const overrideTwice: import("./diagnostic-text.js").DiagnosticRule;
|
|
54
|
+
/** A `translate()` key that is not a class, or that is a failure class. */
|
|
55
|
+
declare const translationKey: import("./diagnostic-text.js").DiagnosticRule;
|
|
56
|
+
/** An `onCommandAttach` hook that threw or returned a value that is not the attached Command. */
|
|
57
|
+
declare const brokenAttachHook: import("./diagnostic-text.js").DiagnosticRule;
|
|
58
|
+
/** The retired `globals` or `failures` Application option. */
|
|
59
|
+
declare const retiredApplicationOption: import("./diagnostic-text.js").DiagnosticRule;
|
|
60
|
+
/** A packet that is not an object, or whose build is neither value. */
|
|
61
|
+
declare const invalidPacket: import("./diagnostic-text.js").DiagnosticRule;
|
|
62
|
+
/** A rendering policy that is not an object, or holds a setting outside its closed set. */
|
|
63
|
+
declare const renderingPolicyRule: import("./diagnostic-text.js").DiagnosticRule;
|
|
64
|
+
/** A plugin theme that is not a mapping of names to unapplied concrete style chains. */
|
|
65
|
+
declare const themeMapping: import("./diagnostic-text.js").DiagnosticRule;
|
|
66
|
+
/** A theme name that a built-in style member already holds. */
|
|
67
|
+
declare const themeNameTaken: import("./diagnostic-text.js").DiagnosticRule;
|
|
68
|
+
export { asyncExtensionSchema, brokenAttachHook, extensionOutput, extensionTarget, extensionValueTwice, extensionWithoutSchema, foreignValue, invalidExtensionValue, invalidIdentity, invalidPacket, middlewareActivation, notAFunction, notAList, notAnObject, overrideKey, overrideTwice, pluginInstalledTwice, pluginOptionRule, renderingPolicyRule, retiredApplicationOption, signalClaimedTwice, slotTaken, sourceBinding, sourceBoundOwnOption, themeMapping, themeNameTaken, translationKey, twoPackageCopies, unknownSignal, unreadableDeclaration, };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { registerRule } from './diagnostic-text.js';
|
|
2
|
+
/*
|
|
3
|
+
* Core's rules for the declaration faults of plugins, extensions, views, translators, lifecycle
|
|
4
|
+
* hooks, and the Application options that install them. Each is declared once here and shared by
|
|
5
|
+
* every site that raises it, as a plugin's rules are.
|
|
6
|
+
*/
|
|
7
|
+
/** A slot that holds a list, such as `plugins` or `commands`, holding a value of another kind. */
|
|
8
|
+
const notAList = registerRule('@loomcli/core/not-a-list', {
|
|
9
|
+
explanation: 'Core reads plugins, commands, extensions, views, translators, and signals each as a list, in order. A value of any other kind has no entries to read.',
|
|
10
|
+
headline: 'Not a list',
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* A declaration core reads by its keys, such as a plugin's middleware or a constructor's options,
|
|
14
|
+
* that is not an object.
|
|
15
|
+
*/
|
|
16
|
+
const notAnObject = registerRule('@loomcli/core/not-an-object', {
|
|
17
|
+
explanation: "Core reads the options of a Command and of the Application, a plugin's definition, its options record, each of its option declarations, its middleware, its source, the config of an argument or option, and the settings a plugin factory takes by their keys. A value of any other kind has no keys to read.",
|
|
18
|
+
headline: 'Not an object',
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* A declaration whose read throws while core takes its one copy, such as a getter that throws or a
|
|
22
|
+
* proxy whose trap throws: the config of an argument or option, a plugin's definition and each of
|
|
23
|
+
* its option declarations, and the options of a Command or of the Application.
|
|
24
|
+
*/
|
|
25
|
+
const unreadableDeclaration = registerRule('@loomcli/core/unreadable-declaration', {
|
|
26
|
+
explanation: 'Core reads a declaration by its keys, and each list in it by index, once, at the call that declares it, and checks and records the copy it takes. A read that throws, such as a throwing getter or proxy trap, leaves core nothing to check or record.',
|
|
27
|
+
headline: 'Declaration could not be read',
|
|
28
|
+
});
|
|
29
|
+
/** A list entry that its factory did not build, such as a hand-made plugin or translation. */
|
|
30
|
+
const foreignValue = registerRule('@loomcli/core/foreign-value', {
|
|
31
|
+
explanation: 'Core reads a plugin, an extension, an extension value, a declared view, a view override, and a translation through facts its factory recorded when it built the value. Any other value carries none, even one of the same shape.',
|
|
32
|
+
headline: 'Value not from its factory',
|
|
33
|
+
});
|
|
34
|
+
/** One plugin identity installed twice. */
|
|
35
|
+
const pluginInstalledTwice = registerRule('@loomcli/core/plugin-installed-twice', {
|
|
36
|
+
explanation: 'Core keys each plugin by its identity, and a plugin contributes its options, middleware, hooks, and views once, so a second installation would contribute each of them again.',
|
|
37
|
+
headline: 'Plugin installed twice',
|
|
38
|
+
});
|
|
39
|
+
/** A second plugin claiming the theme, the signals, or the configuration source slot. */
|
|
40
|
+
const slotTaken = registerRule('@loomcli/core/slot-taken', {
|
|
41
|
+
explanation: 'A slot is a position exactly one plugin claims: the theme, the process signals, and the configuration source. A second claim would leave two plugins answering where core asks one.',
|
|
42
|
+
headline: 'Slot already claimed',
|
|
43
|
+
});
|
|
44
|
+
/** A plugin, extension, or view identity outside the identity grammar. */
|
|
45
|
+
const invalidIdentity = registerRule('@loomcli/core/invalid-identity', {
|
|
46
|
+
explanation: 'An identity keys what a plugin, an extension, or a view contributes, names it in every diagnostic, and prefixes the identities of the rules its package declares, so it is a package name as npm spells one, scoped or not, then any subpath segments, each after a / and each of lowercase letters and digits in words joined by single hyphens.',
|
|
47
|
+
headline: 'Invalid identity',
|
|
48
|
+
});
|
|
49
|
+
/** A validator or a presence rule on a plugin option. */
|
|
50
|
+
const pluginOptionRule = registerRule('@loomcli/core/plugin-option-rule', {
|
|
51
|
+
explanation: "A plugin's middleware interprets its own options' values, so a plugin option declares how it parses and nothing more: no validator and no presence rule.",
|
|
52
|
+
headline: 'Rule on a plugin option',
|
|
53
|
+
});
|
|
54
|
+
/** A middleware activation that is missing, empty, or names an option the plugin lacks. */
|
|
55
|
+
const middlewareActivation = registerRule('@loomcli/core/middleware-activation', {
|
|
56
|
+
explanation: "Activation decides when core loads a plugin's middleware: on every run with 'always', or only when an invocation supplies one of the plugin's own options the list names, so a middleware no invocation needs costs it nothing.",
|
|
57
|
+
headline: 'Invalid middleware activation',
|
|
58
|
+
});
|
|
59
|
+
/** A loader, a hook, or a translator that core cannot call. */
|
|
60
|
+
const notAFunction = registerRule('@loomcli/core/not-a-function', {
|
|
61
|
+
explanation: 'Core calls each of these values at a point of its own: load when a run first reaches a middleware or a source, onCommandAttach at graph build, onFailure when a failure renders, and a translator when a foreign throw reaches it. A value core cannot call leaves it nothing to run.',
|
|
62
|
+
headline: 'Not a function',
|
|
63
|
+
});
|
|
64
|
+
/** A claimed signal outside SIGINT and SIGTERM. */
|
|
65
|
+
const unknownSignal = registerRule('@loomcli/core/unknown-signal', {
|
|
66
|
+
explanation: 'Core installs listeners for SIGINT and SIGTERM alone, the two signals that ask a command-line program to stop, so a plugin claims one of those.',
|
|
67
|
+
headline: 'Unknown signal',
|
|
68
|
+
});
|
|
69
|
+
/** One signal claimed twice by one plugin. */
|
|
70
|
+
const signalClaimedTwice = registerRule('@loomcli/core/signal-claimed-twice', {
|
|
71
|
+
explanation: 'Core installs one listener for each signal a plugin claims, and a second listener on one signal would take the forced path on the first signal the run receives.',
|
|
72
|
+
headline: 'Signal claimed twice',
|
|
73
|
+
});
|
|
74
|
+
/** A configuration source binding that is not one of the plugin's option extensions. */
|
|
75
|
+
const sourceBinding = registerRule('@loomcli/core/source-binding', {
|
|
76
|
+
explanation: 'A configuration source answers the options that carry its binding, an extension the plugin lists under extensions that applies to options. Core asks the source about those options without knowing what the binding means.',
|
|
77
|
+
headline: 'Invalid source binding',
|
|
78
|
+
});
|
|
79
|
+
/** A plugin option that carries its own plugin's source binding. */
|
|
80
|
+
const sourceBoundOwnOption = registerRule('@loomcli/core/source-bound-own-option', {
|
|
81
|
+
explanation: "A plugin's own options resolve before its configuration source loads, because the source reads them, so none of them can take a value from that source.",
|
|
82
|
+
headline: 'Source bound to its own option',
|
|
83
|
+
});
|
|
84
|
+
/** Two distinct objects under one extension or declared-view identity. */
|
|
85
|
+
const twoPackageCopies = registerRule('@loomcli/core/two-package-copies', {
|
|
86
|
+
explanation: 'Core keys each extension and each declared view by its identity and compares it by reference. Two distinct objects under one identity mean two copies of the package that defines it are installed, and a value one copy made cannot be read through the other.',
|
|
87
|
+
headline: 'Two copies of one package',
|
|
88
|
+
});
|
|
89
|
+
/** A descriptor with no Standard Schema. */
|
|
90
|
+
const extensionWithoutSchema = registerRule('@loomcli/core/extension-without-schema', {
|
|
91
|
+
explanation: "Core validates each extension value against its descriptor's Standard Schema at the call that carries it, so a descriptor with no schema leaves the value unchecked.",
|
|
92
|
+
headline: 'Extension without a schema',
|
|
93
|
+
});
|
|
94
|
+
/** An extension value on a declaration its descriptor does not target. */
|
|
95
|
+
const extensionTarget = registerRule('@loomcli/core/extension-target', {
|
|
96
|
+
explanation: 'An extension is defined for one target, Commands, options, or arguments, and a typed read takes that kind of node alone, so a value on another kind would never be read.',
|
|
97
|
+
headline: 'Extension on the wrong target',
|
|
98
|
+
});
|
|
99
|
+
/** Two values of one extension in one layer. */
|
|
100
|
+
const extensionValueTwice = registerRule('@loomcli/core/extension-value-twice', {
|
|
101
|
+
explanation: 'One extensions list or one extend() call sets each extension once, collecting or not, so two values of one extension leave it unclear which the author meant.',
|
|
102
|
+
headline: 'Extension value twice',
|
|
103
|
+
});
|
|
104
|
+
/** An extension value its schema rejects, by an issue or by a throw. */
|
|
105
|
+
const invalidExtensionValue = registerRule('@loomcli/core/invalid-extension-value', {
|
|
106
|
+
explanation: "An extension value passes its descriptor's schema at the call that carries it, so every plugin that reads it reads a value the schema accepted.",
|
|
107
|
+
headline: 'Invalid extension value',
|
|
108
|
+
});
|
|
109
|
+
/** An extension schema that answers with a promise. */
|
|
110
|
+
const asyncExtensionSchema = registerRule('@loomcli/core/async-extension-schema', {
|
|
111
|
+
explanation: 'Core validates extension values synchronously while it builds the declaration, so a schema that answers with a promise leaves it no verdict to read.',
|
|
112
|
+
headline: 'Asynchronous extension schema',
|
|
113
|
+
});
|
|
114
|
+
/** An extension output that is not plain data. */
|
|
115
|
+
const extensionOutput = registerRule('@loomcli/core/extension-output', {
|
|
116
|
+
explanation: "Every projection, the manifest included, reads an extension's output as frozen plain data: strings, finite numbers, Booleans, null, arrays, and plain objects.",
|
|
117
|
+
headline: 'Extension output not plain data',
|
|
118
|
+
});
|
|
119
|
+
/** An override whose key is neither a declared view nor a failure class. */
|
|
120
|
+
const overrideKey = registerRule('@loomcli/core/override-key', {
|
|
121
|
+
explanation: 'An override replaces the view of a declared view or of a failure class, so its key is one of them.',
|
|
122
|
+
headline: 'Invalid override key',
|
|
123
|
+
});
|
|
124
|
+
/** One key overridden twice inside one contributor. */
|
|
125
|
+
const overrideTwice = registerRule('@loomcli/core/override-twice', {
|
|
126
|
+
explanation: 'Within one contributor, one key answers to one override, so two leave it unclear which the author meant. The same key overridden by two contributors resolves to the first installed.',
|
|
127
|
+
headline: 'Key overridden twice',
|
|
128
|
+
});
|
|
129
|
+
/** A `translate()` key that is not a class, or that is a failure class. */
|
|
130
|
+
const translationKey = registerRule('@loomcli/core/translation-key', {
|
|
131
|
+
explanation: 'A translation keys on the foreign error class it replaces. Core offers a translator only a thrown value no failure class made, so the key is a class and never a failure class.',
|
|
132
|
+
headline: 'Invalid translation key',
|
|
133
|
+
});
|
|
134
|
+
/** An `onCommandAttach` hook that threw or returned a value that is not the attached Command. */
|
|
135
|
+
const brokenAttachHook = registerRule('@loomcli/core/broken-attach-hook', {
|
|
136
|
+
explanation: "onCommandAttach receives each Command's declaration at graph build and returns it, or a value derived from it, synchronously and without throwing. Core builds the Command the hook returns, so a throw or any other value leaves it nothing to build.",
|
|
137
|
+
headline: 'Broken attach hook',
|
|
138
|
+
});
|
|
139
|
+
/** The retired `globals` or `failures` Application option. */
|
|
140
|
+
const retiredApplicationOption = registerRule('@loomcli/core/retired-application-option', {
|
|
141
|
+
explanation: 'The Application no longer reads globals or failures. A global option is declared with globalOption(), so its type reaches every action, and a failure view is an override under views.',
|
|
142
|
+
headline: 'Retired Application option',
|
|
143
|
+
});
|
|
144
|
+
/** A packet that is not an object, or whose build is neither value. */
|
|
145
|
+
const invalidPacket = registerRule('@loomcli/core/invalid-packet', {
|
|
146
|
+
explanation: 'The packet says whether the application was built for development, which decides whether a defect shows the author its Developer Diagnostic or the operator one generic message. Its build reads development or distributed.',
|
|
147
|
+
headline: 'Invalid packet',
|
|
148
|
+
});
|
|
149
|
+
/** A rendering policy that is not an object, or holds a setting outside its closed set. */
|
|
150
|
+
const renderingPolicyRule = registerRule('@loomcli/core/rendering-policy', {
|
|
151
|
+
explanation: 'The rendering policy decides whether output carries color, modifiers, hyperlinks, and terminal controls. color, modifiers, and hyperlinks each read auto, always, or never, and terminalControls reads strip or preserve.',
|
|
152
|
+
headline: 'Invalid rendering policy',
|
|
153
|
+
});
|
|
154
|
+
/** A plugin theme that is not a mapping of names to unapplied concrete style chains. */
|
|
155
|
+
const themeMapping = registerRule('@loomcli/core/theme-mapping', {
|
|
156
|
+
explanation: "A plugin's theme maps each name to an unapplied chain of concrete styles. A semantic token reads the theme itself, so a chain that holds one has no concrete style to resolve to.",
|
|
157
|
+
headline: 'Invalid theme mapping',
|
|
158
|
+
});
|
|
159
|
+
/** A theme name that a built-in style member already holds. */
|
|
160
|
+
const themeNameTaken = registerRule('@loomcli/core/theme-name-taken', {
|
|
161
|
+
explanation: 'Each theme name becomes a member of the style object beside the built-in members, so a name a built-in already holds would hide it.',
|
|
162
|
+
headline: 'Theme name taken',
|
|
163
|
+
});
|
|
164
|
+
export { asyncExtensionSchema, brokenAttachHook, extensionOutput, extensionTarget, extensionValueTwice, extensionWithoutSchema, foreignValue, invalidExtensionValue, invalidIdentity, invalidPacket, middlewareActivation, notAFunction, notAList, notAnObject, overrideKey, overrideTwice, pluginInstalledTwice, pluginOptionRule, renderingPolicyRule, retiredApplicationOption, signalClaimedTwice, slotTaken, sourceBinding, sourceBoundOwnOption, themeMapping, themeNameTaken, translationKey, twoPackageCopies, unknownSignal, unreadableDeclaration, };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The plugin factory whose settings `checkShortSetting` judges, and the option `short` spells. */
|
|
2
|
+
interface ShortSettingDeclarer {
|
|
3
|
+
/** The plugin's identity, which the sentence and each finding's note name. */
|
|
4
|
+
readonly plugin: string;
|
|
5
|
+
/** The factory's name, the call each finding quotes, such as `'format'`. */
|
|
6
|
+
readonly call: string;
|
|
7
|
+
/** The name of the option the setting gives a short spelling, such as `'format'`. */
|
|
8
|
+
readonly option: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Judges a plugin factory's settings at its call, under core's own rules: settings that are neither
|
|
12
|
+
* undefined nor a plain object are the not-an-object fault, and a `short` that is not one ASCII
|
|
13
|
+
* letter is the short-alias fault every option's short spelling answers, in the same sentence. Each
|
|
14
|
+
* finding quotes the factory's call and names the plugin, so a first-party plugin that takes a short
|
|
15
|
+
* spelling as `{ short }` reports it where the author wrote it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function checkShortSetting(settings: unknown, declarer: ShortSettingDeclarer): void;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DeclarationError, quoted } from './errors.js';
|
|
2
|
+
import { declarerNote } from './facts.js';
|
|
3
|
+
import { shortAlias } from './input-rules.js';
|
|
4
|
+
import { shortAliasText, isShortAlias } from './options.js';
|
|
5
|
+
import { isPlainObject } from './plain.js';
|
|
6
|
+
import { notAnObject } from './plugin-rules.js';
|
|
7
|
+
/**
|
|
8
|
+
* Judges a plugin factory's settings at its call, under core's own rules: settings that are neither
|
|
9
|
+
* undefined nor a plain object are the not-an-object fault, and a `short` that is not one ASCII
|
|
10
|
+
* letter is the short-alias fault every option's short spelling answers, in the same sentence. Each
|
|
11
|
+
* finding quotes the factory's call and names the plugin, so a first-party plugin that takes a short
|
|
12
|
+
* spelling as `{ short }` reports it where the author wrote it.
|
|
13
|
+
*/
|
|
14
|
+
export function checkShortSetting(settings, declarer) {
|
|
15
|
+
if (settings === undefined) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const { call, option, plugin } = declarer;
|
|
19
|
+
const finding = (mark) => ({
|
|
20
|
+
arguments: [settings],
|
|
21
|
+
call,
|
|
22
|
+
mark,
|
|
23
|
+
note: declarerNote(plugin),
|
|
24
|
+
});
|
|
25
|
+
if (!isPlainObject(settings)) {
|
|
26
|
+
throw new DeclarationError(notAnObject, {
|
|
27
|
+
correction: 'Supply a settings object, or omit the settings.',
|
|
28
|
+
findings: [finding('0')],
|
|
29
|
+
sentence: `Plugin ${quoted(plugin)} declares settings that are not an object.`,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (settings.short !== undefined && !isShortAlias(settings.short)) {
|
|
33
|
+
throw new DeclarationError(shortAlias, {
|
|
34
|
+
...shortAliasText(`Option ${quoted(option)}`),
|
|
35
|
+
findings: [finding('0.short')],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
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:
|
|
82
|
-
*
|
|
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:
|
|
111
|
-
*
|
|
112
|
-
* that
|
|
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. The definition is read once, after the identity,
|
|
118
|
+
* and every rule 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;
|
|
@@ -122,11 +130,11 @@ interface InstalledPlugins {
|
|
|
122
130
|
/**
|
|
123
131
|
* The installed list in composition order, with every rule that reads two plugins together: an
|
|
124
132
|
* identity installed twice, a second claim on the theme slot, the signals slot, or the
|
|
125
|
-
* configuration source, and two distinct descriptors under one identity. The slot is
|
|
126
|
-
*
|
|
127
|
-
* already ran at its `plugin()` call.
|
|
133
|
+
* configuration source, and two distinct descriptors under one identity. The slot is the copy the
|
|
134
|
+
* Application's constructor took, which a JavaScript author fills with any value. Each plugin's own
|
|
135
|
+
* rules 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;
|
|
157
|
-
/** The
|
|
165
|
+
/** The hook core calls for each failure `run()` renders after graph build, or nothing. */
|
|
166
|
+
onFailure: FailureHook | undefined;
|
|
167
|
+
/** The copy of the plugin's own `views` list, which the Application reads again. */
|
|
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,
|
|
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, };
|