@rohal12/spindle 0.55.0 → 0.56.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 +1 -1
- package/dist/pkg/story-variables.js +4 -3
- package/dist/pkg/tooling.js +2 -2
- package/package.json +1 -1
- package/src/markup/validate.ts +9 -1
- package/src/tooling.ts +12 -0
- package/src/types-drift-check.ts +2 -2
- package/types/tooling.d.ts +11 -0
package/dist/pkg/headless.js
CHANGED
|
@@ -17735,7 +17735,7 @@ function validateMarkup(passages, options) {
|
|
|
17735
17735
|
for (const piece of codeAndText(src, tokens, parametersOf)) {
|
|
17736
17736
|
const at = base + piece.offset;
|
|
17737
17737
|
if (piece.kind === "passage") {
|
|
17738
|
-
if (!passageNames.has(piece.name)) {
|
|
17738
|
+
if (options.checkPassageNames !== false && !passageNames.has(piece.name)) {
|
|
17739
17739
|
const hint = didYouMean(piece.name, passageNames, JSON.stringify);
|
|
17740
17740
|
report(passage, at, `${where}No passage named ${JSON.stringify(piece.name)} in ${piece.label}.${hint}`);
|
|
17741
17741
|
}
|
|
@@ -10285,7 +10285,7 @@ function validateMarkup(passages, options) {
|
|
|
10285
10285
|
for (const piece of codeAndText(src, tokens, parametersOf)) {
|
|
10286
10286
|
const at = base + piece.offset;
|
|
10287
10287
|
if (piece.kind === "passage") {
|
|
10288
|
-
if (!passageNames.has(piece.name)) {
|
|
10288
|
+
if (options.checkPassageNames !== false && !passageNames.has(piece.name)) {
|
|
10289
10289
|
const hint = didYouMean(piece.name, passageNames, JSON.stringify);
|
|
10290
10290
|
report(passage, at, `${where}No passage named ${JSON.stringify(piece.name)} in ${piece.label}.${hint}`);
|
|
10291
10291
|
}
|
|
@@ -10473,7 +10473,7 @@ new NameMap();
|
|
|
10473
10473
|
* markup, unknown macros and syntax errors in code, with their passage, line
|
|
10474
10474
|
* and column.
|
|
10475
10475
|
*/
|
|
10476
|
-
function validateStoryMarkup(passages, macros) {
|
|
10476
|
+
function validateStoryMarkup(passages, macros, options = {}) {
|
|
10477
10477
|
const list = [...passages];
|
|
10478
10478
|
const known = /* @__PURE__ */ new Set();
|
|
10479
10479
|
const parameters = /* @__PURE__ */ new Map();
|
|
@@ -10489,7 +10489,8 @@ function validateStoryMarkup(passages, macros) {
|
|
|
10489
10489
|
isKnownMacro: (name) => known.has(name),
|
|
10490
10490
|
macroNames: known,
|
|
10491
10491
|
parametersOf: (name) => parameters.get(name),
|
|
10492
|
-
isBlockMacro: (name) => blocks.has(name.toLowerCase()) || isBlockMacro(name)
|
|
10492
|
+
isBlockMacro: (name) => blocks.has(name.toLowerCase()) || isBlockMacro(name),
|
|
10493
|
+
checkPassageNames: options.checkPassageNames
|
|
10493
10494
|
});
|
|
10494
10495
|
}
|
|
10495
10496
|
//#endregion
|
package/dist/pkg/tooling.js
CHANGED
|
@@ -55,6 +55,6 @@ export function getMacroRegistry() {
|
|
|
55
55
|
* macros and those registered with defineMacro), with passage, line and
|
|
56
56
|
* column.
|
|
57
57
|
*/
|
|
58
|
-
export function validateMarkup(passages) {
|
|
59
|
-
return validateStoryMarkup(passages, metadata.values());
|
|
58
|
+
export function validateMarkup(passages, options) {
|
|
59
|
+
return validateStoryMarkup(passages, metadata.values(), options);
|
|
60
60
|
}
|
package/package.json
CHANGED
package/src/markup/validate.ts
CHANGED
|
@@ -52,6 +52,11 @@ export interface MarkupValidationOptions {
|
|
|
52
52
|
* others are still read for the widgets they define.
|
|
53
53
|
*/
|
|
54
54
|
only?(passage: MarkupPassage): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether passage names written out must name one of the passages
|
|
57
|
+
* (default: true). Off when only part of a story is validated.
|
|
58
|
+
*/
|
|
59
|
+
checkPassageNames?: boolean;
|
|
55
60
|
/**
|
|
56
61
|
* The declared parameters of a macro, whose `expression` and `statements`
|
|
57
62
|
* arguments are checked as code and whose `text` and `string` arguments
|
|
@@ -232,7 +237,10 @@ export function validateMarkup(
|
|
|
232
237
|
for (const piece of codeAndText(src, tokens, parametersOf)) {
|
|
233
238
|
const at = base + piece.offset;
|
|
234
239
|
if (piece.kind === 'passage') {
|
|
235
|
-
if (
|
|
240
|
+
if (
|
|
241
|
+
options.checkPassageNames !== false &&
|
|
242
|
+
!passageNames.has(piece.name)
|
|
243
|
+
) {
|
|
236
244
|
const hint = didYouMean(piece.name, passageNames, JSON.stringify);
|
|
237
245
|
report(
|
|
238
246
|
passage,
|
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}: …`.
|