feat(editor): complete the apis block and drop the removed snippets

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-20 12:31:23 +05:30
co-authored by Claude Opus 5
parent 990a8128a7
commit 2bb52487eb
5 changed files with 62 additions and 6 deletions
+48
View File
@@ -306,6 +306,54 @@ const BLOCK_COMPLETIONS = [
"}", "}",
].join("\n"), ].join("\n"),
}, },
{
label: "apis",
detail: "Page-level API call declarations block",
documentation:
"Declare the API calls available to this page as named entries, each callable via api.<name>() from functions and the `api=` view binding.",
snippet: [
"apis {",
" ${1:searchUsers} ${2|GET,POST,PUT,PATCH,DELETE|} ${3:/api/users} {",
" request {",
" body {",
" ${4:name}?: ${5:string}",
" }",
" }",
"",
" response {",
" return ${6:data}",
" }",
"",
" error {",
" return ${7:null}",
" }",
" }",
"}",
].join("\n"),
},
{
label: "apis entry",
detail: "Single API call declaration",
documentation:
"Declare a single named API call inside an apis { } block: <name> <METHOD> <path> { request/response/error }.",
snippet: [
"${1:searchUsers} ${2|GET,POST,PUT,PATCH,DELETE|} ${3:/api/users} {",
" request {",
" body {",
" ${4:name}?: ${5:string}",
" }",
" }",
"",
" response {",
" return ${6:data}",
" }",
"",
" error {",
" return ${7:null}",
" }",
"}",
].join("\n"),
},
{ {
label: "persist", label: "persist",
detail: "Include-only store persistence", detail: "Include-only store persistence",
+1 -1
View File
@@ -1,4 +1,4 @@
// WRN editor extension source hash: 01c5b97824df25422267667a6083adbdc0a5dc14ae7fbec5345084a214d40523 // WRN editor extension source hash: d0ca0feee6516ae43e902e6aea0424bc5c3d05790708eb8a8c68c98162eb99bb
// WRN editor extension generator hash: 456d1d614e44e5fb1f19b784176c09cf2ade9b64ef73a17934c2698150b62728 // WRN editor extension generator hash: 456d1d614e44e5fb1f19b784176c09cf2ade9b64ef73a17934c2698150b62728
"use strict"; "use strict";
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports); var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
+4 -3
View File
@@ -1,5 +1,5 @@
#!/usr/bin/env node #!/usr/bin/env node
// WRN editor language server source hash: 92a9c7cd3babafdbc518a6f20c0c8f0025e49e92a28a2fa5598c8bb7a858e800 // WRN editor language server source hash: f75d793688bdb42225d2314660c87852a108b76311974be9307d11e42ecfbb41
// WRN editor language server generator hash: f593a44aaf05495b789ce7a3086bee1eebb951b884d41c0e017bbcfe5f547e72 // WRN editor language server generator hash: f593a44aaf05495b789ce7a3086bee1eebb951b884d41c0e017bbcfe5f547e72
// @bun @bun-cjs // @bun @bun-cjs
(function(exports, require, module, __filename, __dirname) {var __create = Object.create; (function(exports, require, module, __filename, __dirname) {var __create = Object.create;
@@ -173590,7 +173590,7 @@ function htmlToWrn(html, name = "ImportedPage") {
} }
// packages/language-server/src/index.ts // packages/language-server/src/index.ts
var WRN_COMPLETIONS = [ var WRN_KEYWORDS = [
"page", "page",
"component", "component",
"layout", "layout",
@@ -173604,6 +173604,7 @@ var WRN_COMPLETIONS = [
"load", "load",
"action", "action",
"api", "api",
"apis",
"realtime", "realtime",
"view", "view",
"style", "style",
@@ -173766,7 +173767,7 @@ ${declaration[0]}
}; };
} }
function completionItems() { function completionItems() {
return WRN_COMPLETIONS.map((label) => ({ label, kind: 14, detail: "WRNexus language keyword" })); return WRN_KEYWORDS.map((label) => ({ label, kind: 14, detail: "WRNexus language keyword" }));
} }
var semanticTokenTypes = ["variable"]; var semanticTokenTypes = ["variable"];
var semanticTokenModifiers = ["declaration", "modification"]; var semanticTokenModifiers = ["declaration", "modification"];
+3 -2
View File
@@ -15,7 +15,7 @@ export interface TextDocument {
version?: number; version?: number;
} }
export const WRN_COMPLETIONS = [ export const WRN_KEYWORDS = [
"page", "page",
"component", "component",
"layout", "layout",
@@ -29,6 +29,7 @@ export const WRN_COMPLETIONS = [
"load", "load",
"action", "action",
"api", "api",
"apis",
"realtime", "realtime",
"view", "view",
"style", "style",
@@ -237,7 +238,7 @@ export function hover(document: TextDocument, position: Position) {
} }
export function completionItems() { export function completionItems() {
return WRN_COMPLETIONS.map((label) => ({ label, kind: 14, detail: "WRNexus language keyword" })); return WRN_KEYWORDS.map((label) => ({ label, kind: 14, detail: "WRNexus language keyword" }));
} }
const semanticTokenTypes = ["variable"] as const; const semanticTokenTypes = ["variable"] as const;
@@ -0,0 +1,6 @@
import { expect, test } from "bun:test";
import { WRN_KEYWORDS } from "../src/index.ts";
test("apis is a known page-level keyword", () => {
expect(WRN_KEYWORDS).toContain("apis");
});