@rohal12/spindle-lsp 0.15.10 → 0.15.11
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/bin.js +34 -27
- package/dist/bin.js.map +2 -2
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -55,7 +55,7 @@ var VERSION;
|
|
|
55
55
|
var init_version = __esm({
|
|
56
56
|
"src/version.ts"() {
|
|
57
57
|
"use strict";
|
|
58
|
-
VERSION = false ? pkg.version : "0.15.
|
|
58
|
+
VERSION = false ? pkg.version : "0.15.11";
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
|
|
@@ -31258,7 +31258,7 @@ function parsePassageHeader(rawLine, lineNumber) {
|
|
|
31258
31258
|
const first = delimiter.exec(escaped);
|
|
31259
31259
|
const boundary = first?.index ?? line.length;
|
|
31260
31260
|
const nameEnd = escaped.slice(0, boundary).trimEnd().length;
|
|
31261
|
-
const name = line.slice(nameStart, nameEnd).replace(/\\(
|
|
31261
|
+
const name = line.slice(nameStart, nameEnd).replace(/\\(.|$)/g, "$1").trim();
|
|
31262
31262
|
if (!name) return null;
|
|
31263
31263
|
let rest = boundary;
|
|
31264
31264
|
let tags = [];
|
|
@@ -31306,7 +31306,7 @@ function isScriptOrStylesheetPassage(passage) {
|
|
|
31306
31306
|
return passage.tags?.some((t) => CODE_PASSAGE_TAGS.has(t)) ?? false;
|
|
31307
31307
|
}
|
|
31308
31308
|
function isRuntimePassage(passage) {
|
|
31309
|
-
return passage.name !== "StoryTitle" && passage.name !== "StoryData" && !isScriptOrStylesheetPassage(passage) && !passage.tags?.includes("Twine.private");
|
|
31309
|
+
return !passage.runtimeOmitted && passage.name !== "StoryTitle" && passage.name !== "StoryData" && !isScriptOrStylesheetPassage(passage) && !passage.tags?.includes("Twine.private");
|
|
31310
31310
|
}
|
|
31311
31311
|
function isMarkupPassage(passage) {
|
|
31312
31312
|
return isRuntimePassage(passage) && !(passage.name !== void 0 && NON_MARKUP_PASSAGES.has(passage.name));
|
|
@@ -31355,6 +31355,7 @@ var init_passage_parser = __esm({
|
|
|
31355
31355
|
});
|
|
31356
31356
|
|
|
31357
31357
|
// src/core/workspace/passage-index.ts
|
|
31358
|
+
import { createRequire as createSettingsRequire } from "node:module";
|
|
31358
31359
|
var PassageIndex;
|
|
31359
31360
|
var init_passage_index = __esm({
|
|
31360
31361
|
"src/core/workspace/passage-index.ts"() {
|
|
@@ -31402,6 +31403,12 @@ var init_passage_index = __esm({
|
|
|
31402
31403
|
start: passages[i2].range.start,
|
|
31403
31404
|
end: { line: nextStart, character: lines[nextStart]?.length ?? 0 }
|
|
31404
31405
|
};
|
|
31406
|
+
if (passages[i2].name === "StorySettings") {
|
|
31407
|
+
const { StoryBuilder } = createSettingsRequire(import.meta.url)("@rohal12/twee-ts");
|
|
31408
|
+
const builder = new StoryBuilder();
|
|
31409
|
+
builder.add({ name: "StorySettings", tags: [], text: lines.slice(passages[i2].headerEnd.end.line + 1, nextStart + 1).join("\n") }, []);
|
|
31410
|
+
passages[i2].runtimeOmitted = builder.build().twine1.settings.size === 0;
|
|
31411
|
+
}
|
|
31405
31412
|
}
|
|
31406
31413
|
if (passages.length > 0) {
|
|
31407
31414
|
this.byUri.set(uri, passages);
|
|
@@ -32297,6 +32304,10 @@ var init_macro_registry2 = __esm({
|
|
|
32297
32304
|
hasConfiguredParameters(name) {
|
|
32298
32305
|
return this.configEntries.get(name.toLowerCase())?.parameters !== void 0;
|
|
32299
32306
|
}
|
|
32307
|
+
/** Whether a project definition replaces the original runtime macro. */
|
|
32308
|
+
hasDiscoveredMacro(name) {
|
|
32309
|
+
return this.discovered.has(name.toLowerCase());
|
|
32310
|
+
}
|
|
32300
32311
|
/** Check if a macro is a block (container) macro. */
|
|
32301
32312
|
isBlock(name) {
|
|
32302
32313
|
return this.getMacro(name)?.block ?? false;
|
|
@@ -33363,11 +33374,10 @@ var init_macro_supplements = __esm({
|
|
|
33363
33374
|
button: {
|
|
33364
33375
|
name: "button",
|
|
33365
33376
|
container: true,
|
|
33366
|
-
description: 'Creates a button that executes its contents when clicked.\n\nUsage:\n\n```\n{button "
|
|
33367
|
-
parameters: ["text
|
|
33377
|
+
description: 'Creates a button that executes its contents when clicked. Navigate by placing {goto} in its body.\n\nUsage:\n\n```\n{button "Go"}\n {goto "Hall"}\n{/button}\n```',
|
|
33378
|
+
parameters: ["text"],
|
|
33368
33379
|
parameterDocs: [
|
|
33369
|
-
{ name: "label", documentation: "Text of the button." }
|
|
33370
|
-
{ name: "passage", documentation: "Passage to go to when clicked; omit to run the contents." }
|
|
33380
|
+
{ name: "label", documentation: "Text of the button; its body runs when clicked." }
|
|
33371
33381
|
]
|
|
33372
33382
|
},
|
|
33373
33383
|
timed: {
|
|
@@ -33448,7 +33458,7 @@ var init_macro_supplements = __esm({
|
|
|
33448
33458
|
},
|
|
33449
33459
|
meter: {
|
|
33450
33460
|
name: "meter",
|
|
33451
|
-
description:
|
|
33461
|
+
description: 'Displays the current value relative to a maximum, with an optional quoted label.\n\nUsage: `{meter 5 10 "%"}`',
|
|
33452
33462
|
parameters: ["...text"],
|
|
33453
33463
|
parameterDocs: [
|
|
33454
33464
|
{ name: "current", documentation: 'Current value expression; a maximum expression and an optional label mode (`"%"`, `"none"` or a unit) follow.' }
|
|
@@ -33595,27 +33605,19 @@ var init_macro_supplements = __esm({
|
|
|
33595
33605
|
},
|
|
33596
33606
|
watch: {
|
|
33597
33607
|
name: "watch",
|
|
33598
|
-
description:
|
|
33608
|
+
description: 'Watches a quoted condition and runs an action when it changes from false to true. Use name to allow removal with {unwatch}.\n\nUsage: `{watch "$x >= 2" run "$x = 0" name "reset-x"}`',
|
|
33599
33609
|
parameters: ["...text"],
|
|
33600
33610
|
parameterDocs: [
|
|
33601
|
-
{ name: "
|
|
33611
|
+
{ name: "condition", documentation: "Quoted expression checked when variables change or the story navigates." },
|
|
33612
|
+
{ name: "options", documentation: "Action (goto, dialog or run), optional name, priority and once flag." }
|
|
33602
33613
|
]
|
|
33603
33614
|
},
|
|
33604
33615
|
unwatch: {
|
|
33605
33616
|
name: "unwatch",
|
|
33606
|
-
description:
|
|
33617
|
+
description: 'Removes a watcher by its registered name.\n\nUsage: `{unwatch "reset-x"}`',
|
|
33607
33618
|
parameters: ["...text"],
|
|
33608
33619
|
parameterDocs: [
|
|
33609
|
-
{ name: "
|
|
33610
|
-
]
|
|
33611
|
-
},
|
|
33612
|
-
unless: {
|
|
33613
|
-
name: "unless",
|
|
33614
|
-
container: true,
|
|
33615
|
-
description: "Conditionally displays its contents when the expression is falsy. The inverse of `{if}`.\n\nUsage:\n\n```\n{unless condition}\n ...\n{/unless}\n```",
|
|
33616
|
-
parameters: ["...text"],
|
|
33617
|
-
parameterDocs: [
|
|
33618
|
-
{ name: "condition", documentation: "Expression; the contents show when it is falsy." }
|
|
33620
|
+
{ name: "name", documentation: "Name supplied to the watch macro." }
|
|
33619
33621
|
]
|
|
33620
33622
|
}
|
|
33621
33623
|
};
|
|
@@ -33641,6 +33643,7 @@ var init_workspace_model = __esm({
|
|
|
33641
33643
|
init_macro_sources();
|
|
33642
33644
|
init_story_format();
|
|
33643
33645
|
init_spindle_version();
|
|
33646
|
+
init_passage_parser();
|
|
33644
33647
|
init_macro_supplements();
|
|
33645
33648
|
WorkspaceModel = class extends EventEmitter2 {
|
|
33646
33649
|
documents;
|
|
@@ -33869,7 +33872,8 @@ var init_workspace_model = __esm({
|
|
|
33869
33872
|
}
|
|
33870
33873
|
let lines;
|
|
33871
33874
|
for (const passage of this.passages.getPassagesInDocument(uri)) {
|
|
33872
|
-
|
|
33875
|
+
if (passage.tags?.includes("Twine.private")) continue;
|
|
33876
|
+
const isStoryInit = passage.name === "StoryInit" && isRuntimePassage(passage);
|
|
33873
33877
|
const isScript = passage.tags?.includes("script") ?? false;
|
|
33874
33878
|
if (!isStoryInit && !isScript) continue;
|
|
33875
33879
|
lines ??= text3.split("\n");
|
|
@@ -33895,7 +33899,7 @@ var init_workspace_model = __esm({
|
|
|
33895
33899
|
this._target = resolveSpindleTarget(this.installedVersion, this.declaredVersion);
|
|
33896
33900
|
const declarations = (name) => {
|
|
33897
33901
|
const passage = this.passages.getPassage(name);
|
|
33898
|
-
return passage ? this.markup.get(passage.uri)?.passages.find((p) => p.passage === passage) : void 0;
|
|
33902
|
+
return passage && isRuntimePassage(passage) ? this.markup.get(passage.uri)?.passages.find((p) => p.passage === passage) : void 0;
|
|
33899
33903
|
};
|
|
33900
33904
|
const variables = declarations("StoryVariables");
|
|
33901
33905
|
if (variables) this.variables.parseStoryVariables(variables.content, variables.passage.headerEnd.end.line + 1, variables.doc.uri);
|
|
@@ -34384,7 +34388,7 @@ function buildReport(documents, workspace) {
|
|
|
34384
34388
|
}
|
|
34385
34389
|
function declarationsOf(workspace, name) {
|
|
34386
34390
|
const passage = name === "StoryVariables" ? workspace.passages.getStoryVariables() : workspace.passages.getStoryTransients();
|
|
34387
|
-
if (!passage) return void 0;
|
|
34391
|
+
if (!passage || !isRuntimePassage(passage)) return void 0;
|
|
34388
34392
|
const markup = workspace.markup.get(passage.uri)?.passages.find((candidate) => candidate.passage === passage);
|
|
34389
34393
|
if (!markup) return void 0;
|
|
34390
34394
|
return new Map(markup.declarations.declarations.map((declaration) => [declaration.name, declaration.schema]));
|
|
@@ -34694,7 +34698,8 @@ function argumentDiagnostics(passage, workspace) {
|
|
|
34694
34698
|
for (const token of passage.isMarkup ? macroTokens(passage) : []) {
|
|
34695
34699
|
if (token.type !== "macro" || token.isClose) continue;
|
|
34696
34700
|
const info = workspace.macros.getMacro(token.name);
|
|
34697
|
-
if (!info?.parameters || info.skipArgs ||
|
|
34701
|
+
if (!info?.parameters || info.skipArgs || info.parameterDefs?.length) continue;
|
|
34702
|
+
if (SPINDLE_MACROS.has(token.name.toLowerCase()) && !workspace.macros.hasDiscoveredMacro(token.name)) continue;
|
|
34698
34703
|
let params;
|
|
34699
34704
|
try {
|
|
34700
34705
|
params = new Parameters(info.parameters);
|
|
@@ -81388,7 +81393,7 @@ function declareVariable(diag, workspace, sigil) {
|
|
|
81388
81393
|
if (diag.data?.kind !== "undeclared-variable" || diag.data.sigil !== sigil) return [];
|
|
81389
81394
|
const { name } = diag.data;
|
|
81390
81395
|
const passage = sigil === "$" ? workspace.passages.getStoryVariables() : workspace.passages.getStoryTransients();
|
|
81391
|
-
if (!passage) return [];
|
|
81396
|
+
if (!passage || !isRuntimePassage(passage)) return [];
|
|
81392
81397
|
const text3 = workspace.documents.getText(passage.uri);
|
|
81393
81398
|
if (text3 === void 0) return [];
|
|
81394
81399
|
const markup = workspace.markup.get(passage.uri)?.passages.find((p) => p.passage === passage);
|
|
@@ -81404,6 +81409,7 @@ function declareVariable(diag, workspace, sigil) {
|
|
|
81404
81409
|
}];
|
|
81405
81410
|
}
|
|
81406
81411
|
function fixNoStoryVariables(workspace) {
|
|
81412
|
+
if (workspace.passages.getStoryVariables()) return null;
|
|
81407
81413
|
const targetUri = missingStoryVariablesOwner(workspace);
|
|
81408
81414
|
if (targetUri === void 0) return null;
|
|
81409
81415
|
const text3 = workspace.documents.getText(targetUri);
|
|
@@ -81454,7 +81460,7 @@ function fixBrokenLink(uri, diag, workspace) {
|
|
|
81454
81460
|
});
|
|
81455
81461
|
}
|
|
81456
81462
|
const header = `:: ${name.replace(/[\\[\]{}]/g, "\\$&")}`;
|
|
81457
|
-
if (name.trim() === name && name !== "" && !/[\r\n]/.test(name)) {
|
|
81463
|
+
if (!workspace.passages.getPassage(name) && name.trim() === name && name !== "" && !/[\r\n]/.test(name)) {
|
|
81458
81464
|
const edit = insertLinesAt(text3, text3.split("\n").length, `
|
|
81459
81465
|
${header}
|
|
81460
81466
|
`, lineEndingFor(workspace, uri));
|
|
@@ -81523,6 +81529,7 @@ var init_code_actions = __esm({
|
|
|
81523
81529
|
init_rename();
|
|
81524
81530
|
init_js_string_literal();
|
|
81525
81531
|
init_text();
|
|
81532
|
+
init_passage_parser();
|
|
81526
81533
|
DEFAULT_CONFIG_FILENAME = "spindle.config.yaml";
|
|
81527
81534
|
NEW_MACRO_ENTRY = { description: "" };
|
|
81528
81535
|
fixUndeclaredVariable = (diag, workspace) => declareVariable(diag, workspace, "$");
|