@rohal12/spindle 0.55.0 → 0.57.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/dist/pkg/format.js +1 -1
- package/dist/pkg/headless.js +84 -18
- package/dist/pkg/macro-registry.json +2 -1
- package/dist/pkg/story-variables.js +53 -11
- package/dist/pkg/tooling.js +2 -2
- package/package.json +1 -1
- package/src/code-check.ts +22 -4
- package/src/components/macros/MacroLink.tsx +30 -7
- package/src/components/macros/macro-args.ts +27 -3
- package/src/components/macros/option-utils.ts +11 -6
- package/src/define-macro.ts +22 -2
- package/src/markup/validate.ts +16 -2
- package/src/tooling.ts +12 -0
- package/src/types-drift-check.ts +2 -2
- package/types/tooling.d.ts +11 -0
package/src/tooling.ts
CHANGED
|
@@ -19,6 +19,16 @@ export { formatDiagnostic } from './markup/validate';
|
|
|
19
19
|
export type { MarkupDiagnostic, MarkupPassage } from './markup/validate';
|
|
20
20
|
|
|
21
21
|
/** What tooling knows about a macro (see MacroMetadata). */
|
|
22
|
+
/** Options for validating markup from tooling. */
|
|
23
|
+
export interface ValidateMarkupOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Whether passage names written out (links, quoted `passage` arguments)
|
|
26
|
+
* must name one of the passages given (default: true). Turn it off to
|
|
27
|
+
* validate only part of a story.
|
|
28
|
+
*/
|
|
29
|
+
checkPassageNames?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
22
32
|
export interface ToolingMacro {
|
|
23
33
|
name: string;
|
|
24
34
|
block: boolean;
|
|
@@ -36,6 +46,7 @@ export interface ToolingMacro {
|
|
|
36
46
|
export function validateStoryMarkup(
|
|
37
47
|
passages: Iterable<MarkupPassage>,
|
|
38
48
|
macros: Iterable<ToolingMacro>,
|
|
49
|
+
options: ValidateMarkupOptions = {},
|
|
39
50
|
): MarkupDiagnostic[] {
|
|
40
51
|
const list = [...passages];
|
|
41
52
|
const known = new Set<string>();
|
|
@@ -54,5 +65,6 @@ export function validateStoryMarkup(
|
|
|
54
65
|
parametersOf: (name) => parameters.get(name),
|
|
55
66
|
isBlockMacro: (name) =>
|
|
56
67
|
blocks.has(name.toLowerCase()) || isBlockMacro(name),
|
|
68
|
+
checkPassageNames: options.checkPassageNames,
|
|
57
69
|
});
|
|
58
70
|
}
|
package/src/types-drift-check.ts
CHANGED
|
@@ -115,5 +115,5 @@ const _exampleMacro: PublishedMacroDefinition = {
|
|
|
115
115
|
// metadata.
|
|
116
116
|
declare const validateStoryMarkup: typeof SourceValidateStoryMarkup;
|
|
117
117
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
118
|
-
const _validateMarkup: typeof PublishedValidateMarkup = (passages) =>
|
|
119
|
-
validateStoryMarkup(passages, []);
|
|
118
|
+
const _validateMarkup: typeof PublishedValidateMarkup = (passages, options) =>
|
|
119
|
+
validateStoryMarkup(passages, [], options);
|
package/types/tooling.d.ts
CHANGED
|
@@ -142,8 +142,19 @@ export interface MarkupDiagnostic {
|
|
|
142
142
|
*/
|
|
143
143
|
export declare function validateMarkup(
|
|
144
144
|
passages: Iterable<MarkupPassage>,
|
|
145
|
+
options?: ValidateMarkupOptions,
|
|
145
146
|
): MarkupDiagnostic[];
|
|
146
147
|
|
|
148
|
+
/** Options for {@link validateMarkup}. */
|
|
149
|
+
export interface ValidateMarkupOptions {
|
|
150
|
+
/**
|
|
151
|
+
* Whether passage names written out (links, quoted `passage` arguments)
|
|
152
|
+
* must name one of `passages` (default: true). Turn it off to validate
|
|
153
|
+
* only part of a story.
|
|
154
|
+
*/
|
|
155
|
+
checkPassageNames?: boolean;
|
|
156
|
+
}
|
|
157
|
+
|
|
147
158
|
/**
|
|
148
159
|
* A diagnostic as one line of text, as Spindle shows it:
|
|
149
160
|
* `Passage "Start", line 3, column 5 (story.twee:12): Unclosed {if}: …`.
|