@bascik/language-server 0.1.0-rc.4 → 0.1.0-rc.6

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.
Files changed (119) hide show
  1. package/README.md +72 -30
  2. package/dist/analyzer.d.ts +70 -1
  3. package/dist/analyzer.d.ts.map +1 -1
  4. package/dist/analyzer.js +657 -77
  5. package/dist/analyzer.js.map +1 -1
  6. package/dist/api-rules.d.ts +7 -0
  7. package/dist/api-rules.d.ts.map +1 -1
  8. package/dist/api-rules.js +235 -16
  9. package/dist/api-rules.js.map +1 -1
  10. package/dist/bin.js +4 -1
  11. package/dist/bin.js.map +1 -1
  12. package/dist/check.d.ts +14 -1
  13. package/dist/check.d.ts.map +1 -1
  14. package/dist/check.js +116 -10
  15. package/dist/check.js.map +1 -1
  16. package/dist/cli.d.ts.map +1 -1
  17. package/dist/cli.js +27 -8
  18. package/dist/cli.js.map +1 -1
  19. package/dist/compatibility-rules.json +21 -3
  20. package/dist/component-metadata.d.ts.map +1 -1
  21. package/dist/component-metadata.js +3 -1
  22. package/dist/component-metadata.js.map +1 -1
  23. package/dist/component-usages.d.ts +47 -0
  24. package/dist/component-usages.d.ts.map +1 -0
  25. package/dist/component-usages.js +495 -0
  26. package/dist/component-usages.js.map +1 -0
  27. package/dist/config-reader.d.ts +41 -0
  28. package/dist/config-reader.d.ts.map +1 -0
  29. package/dist/config-reader.js +461 -0
  30. package/dist/config-reader.js.map +1 -0
  31. package/dist/config.d.ts +10 -0
  32. package/dist/config.d.ts.map +1 -1
  33. package/dist/config.js +25 -30
  34. package/dist/config.js.map +1 -1
  35. package/dist/directive-rules.d.ts +3 -3
  36. package/dist/directive-rules.d.ts.map +1 -1
  37. package/dist/directive-rules.js +6 -6
  38. package/dist/directive-rules.js.map +1 -1
  39. package/dist/hand-written-escaper.d.ts +35 -0
  40. package/dist/hand-written-escaper.d.ts.map +1 -0
  41. package/dist/hand-written-escaper.js +739 -0
  42. package/dist/hand-written-escaper.js.map +1 -0
  43. package/dist/module-specifiers.d.ts +25 -0
  44. package/dist/module-specifiers.d.ts.map +1 -1
  45. package/dist/module-specifiers.js +234 -165
  46. package/dist/module-specifiers.js.map +1 -1
  47. package/dist/name-groups.d.ts +36 -0
  48. package/dist/name-groups.d.ts.map +1 -0
  49. package/dist/name-groups.js +198 -0
  50. package/dist/name-groups.js.map +1 -0
  51. package/dist/plain-holes.d.ts +116 -0
  52. package/dist/plain-holes.d.ts.map +1 -0
  53. package/dist/plain-holes.js +1970 -0
  54. package/dist/plain-holes.js.map +1 -0
  55. package/dist/project.d.ts +58 -1
  56. package/dist/project.d.ts.map +1 -1
  57. package/dist/project.js +146 -8
  58. package/dist/project.js.map +1 -1
  59. package/dist/references.d.ts +47 -0
  60. package/dist/references.d.ts.map +1 -0
  61. package/dist/references.js +241 -0
  62. package/dist/references.js.map +1 -0
  63. package/dist/script-modules.d.ts +60 -0
  64. package/dist/script-modules.d.ts.map +1 -0
  65. package/dist/script-modules.js +382 -0
  66. package/dist/script-modules.js.map +1 -0
  67. package/dist/server-script-rules.d.ts +94 -1
  68. package/dist/server-script-rules.d.ts.map +1 -1
  69. package/dist/server-script-rules.js +2572 -230
  70. package/dist/server-script-rules.js.map +1 -1
  71. package/dist/server-script-templates.d.ts +250 -0
  72. package/dist/server-script-templates.d.ts.map +1 -0
  73. package/dist/server-script-templates.js +1685 -0
  74. package/dist/server-script-templates.js.map +1 -0
  75. package/dist/server.d.ts +191 -3
  76. package/dist/server.d.ts.map +1 -1
  77. package/dist/server.js +822 -50
  78. package/dist/server.js.map +1 -1
  79. package/dist/start.d.ts +10 -1
  80. package/dist/start.d.ts.map +1 -1
  81. package/dist/start.js +14 -2
  82. package/dist/start.js.map +1 -1
  83. package/dist/string-typed-flow.d.ts +26 -0
  84. package/dist/string-typed-flow.d.ts.map +1 -0
  85. package/dist/string-typed-flow.js +496 -0
  86. package/dist/string-typed-flow.js.map +1 -0
  87. package/dist/typescript-blocks.d.ts +205 -0
  88. package/dist/typescript-blocks.d.ts.map +1 -0
  89. package/dist/typescript-blocks.js +464 -0
  90. package/dist/typescript-blocks.js.map +1 -0
  91. package/dist/typescript-editor-mode.d.ts +28 -0
  92. package/dist/typescript-editor-mode.d.ts.map +1 -0
  93. package/dist/typescript-editor-mode.js +161 -0
  94. package/dist/typescript-editor-mode.js.map +1 -0
  95. package/dist/typescript-engine.d.ts +115 -0
  96. package/dist/typescript-engine.d.ts.map +1 -0
  97. package/dist/typescript-engine.js +286 -0
  98. package/dist/typescript-engine.js.map +1 -0
  99. package/dist/typescript-features.d.ts +136 -0
  100. package/dist/typescript-features.d.ts.map +1 -0
  101. package/dist/typescript-features.js +374 -0
  102. package/dist/typescript-features.js.map +1 -0
  103. package/dist/typescript-loader.d.ts +55 -0
  104. package/dist/typescript-loader.d.ts.map +1 -0
  105. package/dist/typescript-loader.js +202 -0
  106. package/dist/typescript-loader.js.map +1 -0
  107. package/dist/typescript-lsp.d.ts +8 -0
  108. package/dist/typescript-lsp.d.ts.map +1 -0
  109. package/dist/typescript-lsp.js +115 -0
  110. package/dist/typescript-lsp.js.map +1 -0
  111. package/dist/typescript-service.d.ts +350 -0
  112. package/dist/typescript-service.d.ts.map +1 -0
  113. package/dist/typescript-service.js +1465 -0
  114. package/dist/typescript-service.js.map +1 -0
  115. package/dist/typescript-worker.d.ts +11 -0
  116. package/dist/typescript-worker.d.ts.map +1 -0
  117. package/dist/typescript-worker.js +107 -0
  118. package/dist/typescript-worker.js.map +1 -0
  119. package/package.json +20 -7
@@ -0,0 +1,382 @@
1
+ /**
2
+ * The project's .ts and .js files that run in Node, so the markup rules and
3
+ * hand-written-html-escaper apply to them as they do to inline directive
4
+ * scripts.
5
+ *
6
+ * A file runs in Node when it is:
7
+ * - the `src=` file of a directive script (`data-bascik-build`,
8
+ * `data-bascik-build-once`, `data-bascik-routes`, `data-bascik-server`,
9
+ * `data-bascik-stream`) in a page or component;
10
+ * - a module that a directive script, an API route, or another such module
11
+ * imports with a `./`, `../` or `@/` specifier (followed transitively);
12
+ * - an API route itself.
13
+ *
14
+ * Browser code is left out: a component's plain `<script src>` companion,
15
+ * and anything only it imports, is scoped for the browser, where these rules
16
+ * do not apply. Bare specifiers (packages) are not followed.
17
+ */
18
+ import * as fs from "node:fs";
19
+ import * as path from "node:path";
20
+ import { findModuleSpecifiers } from "./module-specifiers.js";
21
+ /** A directive attribute in a script's open tag; group 1 is the directive. */
22
+ const DIRECTIVE_RE = /(?:^|[\s"'])data-bascik-(build-once|build|routes|server|stream)(?=[\s=/>]|$)/i;
23
+ const SCRIPT_EXTENSIONS = [".ts", ".mts", ".js", ".mjs"];
24
+ const API_ROUTE_EXTENSIONS = new Set([".ts", ".mts", ".js", ".mjs"]);
25
+ /** A bound on the files followed, so a huge or cyclic graph cannot stall the editor. */
26
+ const MAX_MODULES = 5_000;
27
+ const SCRIPT_OPEN_RE = /<script(?=[\t\n\f\r />])/gi;
28
+ const SCRIPT_CLOSE_RE = /<\/script(?=[\t\n\f\r />])/gi;
29
+ const SRC_RE = /(?:^|\s)src\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/i;
30
+ /**
31
+ * The closed <script> elements of an HTML text, in one linear pass. An open
32
+ * tag ends at the first `>` outside quotes; its body at the next
33
+ * `</script`. Whatever follows an opener with no `>` or no close (a page
34
+ * being typed) is not read, since nothing after it can end the script.
35
+ */
36
+ function scriptTags(text) {
37
+ const out = [];
38
+ let pos = 0;
39
+ while (pos < text.length) {
40
+ SCRIPT_OPEN_RE.lastIndex = pos;
41
+ const open = SCRIPT_OPEN_RE.exec(text);
42
+ if (!open)
43
+ break;
44
+ let i = open.index + 7;
45
+ let tagEnd = -1;
46
+ while (i < text.length) {
47
+ const c = text[i];
48
+ if (c === '"' || c === "'") {
49
+ const quote = text.indexOf(c, i + 1);
50
+ if (quote === -1)
51
+ return out;
52
+ i = quote + 1;
53
+ }
54
+ else if (c === ">") {
55
+ tagEnd = i;
56
+ break;
57
+ }
58
+ else
59
+ i++;
60
+ }
61
+ if (tagEnd === -1)
62
+ break;
63
+ SCRIPT_CLOSE_RE.lastIndex = tagEnd + 1;
64
+ const close = SCRIPT_CLOSE_RE.exec(text);
65
+ if (!close)
66
+ break;
67
+ out.push({
68
+ attrs: text.slice(open.index + 7, tagEnd),
69
+ body: text.slice(tagEnd + 1, close.index),
70
+ });
71
+ const closeEnd = text.indexOf(">", close.index);
72
+ pos = closeEnd === -1 ? text.length : closeEnd + 1;
73
+ }
74
+ return out;
75
+ }
76
+ /**
77
+ * A script's import specifiers, or none when the script cannot be read (a
78
+ * template nested thousands deep overflows the scanner's stack).
79
+ */
80
+ function specifiersOf(text) {
81
+ const known = specifierMemo.get(text);
82
+ if (known !== undefined)
83
+ return known;
84
+ let found;
85
+ try {
86
+ found = findModuleSpecifiers(text).map((s) => s.value);
87
+ }
88
+ catch {
89
+ found = [];
90
+ }
91
+ if (specifierMemo.size >= SPECIFIER_MEMO_ENTRIES ||
92
+ specifierMemoChars + text.length > SPECIFIER_MEMO_CHARS) {
93
+ specifierMemo.clear();
94
+ specifierMemoChars = 0;
95
+ }
96
+ specifierMemo.set(text, found);
97
+ specifierMemoChars += text.length;
98
+ return found;
99
+ }
100
+ /**
101
+ * Import specifiers by script text. A walk reads a module once per reach
102
+ * (build, request, browser), `bascik --check` walks twice (the checked
103
+ * files and the whole project), and the language server walks again after
104
+ * every module write, so the same texts are scanned many times; keyed by
105
+ * text, an edited file is simply scanned anew. Bounded by entries and by
106
+ * characters held, and cleared whole when full.
107
+ */
108
+ const SPECIFIER_MEMO_ENTRIES = 8192;
109
+ const SPECIFIER_MEMO_CHARS = 32 * 1024 * 1024;
110
+ const specifierMemo = new Map();
111
+ let specifierMemoChars = 0;
112
+ /** Forward slashes, so Windows and POSIX paths compare the same. */
113
+ export const normalizeModulePath = (fsPath) => path.resolve(fsPath).replace(/\\/g, "/");
114
+ const isTestFile = (file) => /\.(test|spec)\.[a-z0-9]+$/i.test(file) || /\.d\.[cm]?ts$/i.test(file);
115
+ /** The file a specifier names, trying TypeScript for `.js` and adding an extension or `/index`. */
116
+ function resolveFile(target) {
117
+ const candidates = [target];
118
+ const ext = path.extname(target).toLowerCase();
119
+ if (ext === ".js")
120
+ candidates.push(target.slice(0, -3) + ".ts");
121
+ else if (ext === ".mjs")
122
+ candidates.push(target.slice(0, -4) + ".mts");
123
+ else if (!SCRIPT_EXTENSIONS.includes(ext))
124
+ for (const e of SCRIPT_EXTENSIONS)
125
+ candidates.push(target + e, path.join(target, `index${e}`));
126
+ for (const candidate of candidates) {
127
+ if (!SCRIPT_EXTENSIONS.includes(path.extname(candidate).toLowerCase()))
128
+ continue;
129
+ try {
130
+ if (fs.statSync(candidate).isFile())
131
+ return candidate;
132
+ }
133
+ catch {
134
+ // Not there; try the next spelling.
135
+ }
136
+ }
137
+ return undefined;
138
+ }
139
+ function resolveSpecifier(value, fromDir, importRoot) {
140
+ if (value.startsWith("./") || value.startsWith("../"))
141
+ return resolveFile(path.resolve(fromDir, value));
142
+ if (value.startsWith("@/"))
143
+ return resolveFile(path.resolve(importRoot, value.slice(2)));
144
+ return undefined;
145
+ }
146
+ /** A script's src= value as a local file, or undefined for none, a URL or a root-absolute path. */
147
+ function resolveSrc(attrs, dir, importRoot) {
148
+ const src = SRC_RE.exec(attrs);
149
+ if (!src)
150
+ return null;
151
+ const value = (src[1] ?? src[2] ?? src[3] ?? "").trim();
152
+ if (value.startsWith("@/"))
153
+ return resolveFile(path.resolve(importRoot, value.slice(2)));
154
+ if (value && !value.startsWith("/") && !/^[a-z][a-z\d+.-]*:/i.test(value))
155
+ return resolveFile(path.resolve(dir, value));
156
+ return undefined;
157
+ }
158
+ /**
159
+ * The files that run in Node (normalized paths). `requestTime` holds the
160
+ * ones that run per request: API routes and what server scripts, stream
161
+ * scripts and API routes reach. `browser` holds what browser code reaches
162
+ * (a plain `<script src>` companion and what browser scripts import); a
163
+ * file can be in both sets, when browser and Node code share it.
164
+ */
165
+ export class ScriptModules extends Set {
166
+ requestTime = new Set();
167
+ browser = new Set();
168
+ /** Every module of both, request-time or browser in either. */
169
+ static union(a, b) {
170
+ const out = new ScriptModules([...a, ...b]);
171
+ for (const m of [...a.requestTime, ...b.requestTime])
172
+ out.requestTime.add(m);
173
+ for (const m of [...a.browser, ...b.browser])
174
+ out.browser.add(m);
175
+ return out;
176
+ }
177
+ }
178
+ /** Every file that runs in Node, from the given pages, components and API routes. */
179
+ export function findScriptModules(sources) {
180
+ const { projectRoot, importRoot } = sources;
181
+ const roots = [projectRoot, ...(sources.extraRoots ?? [])];
182
+ const found = new ScriptModules();
183
+ /** Files visited, per reach. */
184
+ const visited = {
185
+ build: new Set(),
186
+ request: new Set(),
187
+ browser: new Set(),
188
+ };
189
+ let visits = 0;
190
+ const queue = [];
191
+ const inProject = (file) => !file.split(/[\\/]/).includes("node_modules") &&
192
+ roots.some((r) => {
193
+ const rel = path.relative(r, file);
194
+ return rel !== "" && !rel.startsWith("..") && !path.isAbsolute(rel);
195
+ });
196
+ const add = (file, reach) => {
197
+ if (!file || !inProject(file) || isTestFile(file))
198
+ return;
199
+ const key = normalizeModulePath(file);
200
+ if (visited[reach].has(key) || visits >= MAX_MODULES * 3)
201
+ return;
202
+ visited[reach].add(key);
203
+ visits++;
204
+ if (reach === "browser")
205
+ found.browser.add(key);
206
+ else {
207
+ if (!found.has(key) && found.size >= MAX_MODULES)
208
+ return;
209
+ found.add(key);
210
+ if (reach === "request")
211
+ found.requestTime.add(key);
212
+ }
213
+ queue.push([file, reach]);
214
+ };
215
+ const addImports = (text, fromDir, reach) => {
216
+ for (const value of specifiersOf(text))
217
+ add(resolveSpecifier(value, fromDir, importRoot), reach);
218
+ };
219
+ for (const [htmlPath, text] of sources.html) {
220
+ const dir = path.dirname(htmlPath);
221
+ for (const { attrs, body } of scriptTags(text)) {
222
+ const directive = DIRECTIVE_RE.exec(attrs)?.[1]?.toLowerCase();
223
+ const reach = directive === undefined
224
+ ? "browser"
225
+ : directive === "server" || directive === "stream"
226
+ ? "request"
227
+ : "build";
228
+ const src = resolveSrc(attrs, dir, importRoot);
229
+ if (src === null)
230
+ addImports(body, dir, reach);
231
+ else
232
+ add(src, reach);
233
+ }
234
+ }
235
+ for (const route of sources.apiRoutes ?? [])
236
+ add(route, "request");
237
+ const texts = new Map();
238
+ while (queue.length > 0) {
239
+ const [file, reach] = queue.pop();
240
+ let text = texts.get(file);
241
+ if (text === undefined && !texts.has(file)) {
242
+ text = sources.readText?.(file);
243
+ if (text === undefined) {
244
+ try {
245
+ text = fs.readFileSync(file, "utf8");
246
+ }
247
+ catch {
248
+ text = undefined;
249
+ }
250
+ }
251
+ texts.set(file, text);
252
+ }
253
+ if (text !== undefined)
254
+ addImports(text, path.dirname(file), reach);
255
+ }
256
+ return found;
257
+ }
258
+ /** The API route files under `apiRoot`, skipping tests and folders that start with a dot. */
259
+ export function listApiRoutes(apiRoot) {
260
+ if (!apiRoot)
261
+ return [];
262
+ const out = [];
263
+ const stack = [apiRoot];
264
+ while (stack.length > 0) {
265
+ const dir = stack.pop();
266
+ let entries;
267
+ try {
268
+ entries = fs.readdirSync(dir, { withFileTypes: true });
269
+ }
270
+ catch {
271
+ continue;
272
+ }
273
+ for (const entry of entries) {
274
+ if (entry.name.startsWith(".") || entry.name === "node_modules")
275
+ continue;
276
+ const full = path.join(dir, entry.name);
277
+ if (entry.isDirectory())
278
+ stack.push(full);
279
+ else if (API_ROUTE_EXTENSIONS.has(path.extname(entry.name).toLowerCase()) &&
280
+ !isTestFile(entry.name))
281
+ out.push(full);
282
+ }
283
+ }
284
+ return out;
285
+ }
286
+ /** What an open buffer contributes to the module graph: its scripts' kinds, src= values and imports. */
287
+ function importSignature(fsPath, text) {
288
+ const lower = fsPath.toLowerCase();
289
+ if (lower.endsWith(".html"))
290
+ return scriptTags(text)
291
+ .map(({ attrs, body }) => `${DIRECTIVE_RE.exec(attrs)?.[1]?.toLowerCase() ?? ""}|${SRC_RE.exec(attrs)?.[0] ?? specifiersOf(body).join("\u0000")}`)
292
+ .join("\n");
293
+ if (SCRIPT_EXTENSIONS.includes(path.extname(lower)))
294
+ return specifiersOf(text).join("\u0000");
295
+ return undefined;
296
+ }
297
+ /** The last signature computed for each open buffer, reused while its text is the same string. */
298
+ const signatureMemo = new Map();
299
+ const signaturesOf = (openDocumentTexts) => {
300
+ const out = new Map();
301
+ for (const { fsPath, text } of openDocumentTexts) {
302
+ const key = normalizeModulePath(fsPath);
303
+ const memo = signatureMemo.get(key);
304
+ let signature;
305
+ if (memo && memo.text === text)
306
+ signature = memo.signature;
307
+ else {
308
+ signature = importSignature(fsPath, text);
309
+ if (signature !== undefined)
310
+ signatureMemo.set(key, { text, signature });
311
+ }
312
+ if (signature !== undefined)
313
+ out.set(key, signature);
314
+ }
315
+ if (signatureMemo.size > 4 * out.size + 64)
316
+ signatureMemo.clear();
317
+ return out;
318
+ };
319
+ const sameSignatures = (a, b) => {
320
+ if (a.size !== b.size)
321
+ return false;
322
+ for (const [key, value] of a)
323
+ if (b.get(key) !== value)
324
+ return false;
325
+ return true;
326
+ };
327
+ const cache = new WeakMap();
328
+ /** Bumped when a module changes on disk, which no snapshot or open buffer shows. */
329
+ let generation = 0;
330
+ /**
331
+ * Forgets every cached module set. The language server calls it when a
332
+ * .ts or .js file changes on disk (a checkout, a formatter, an agent's
333
+ * edit), since a closed module's imports decide which files run in Node.
334
+ */
335
+ export function invalidateScriptModules() {
336
+ generation++;
337
+ }
338
+ /**
339
+ * The Node modules of a project snapshot: its pages' and components' HTML
340
+ * (open HTML buffers in place of the disk) and its API routes. Cached per
341
+ * snapshot, and reused while the open buffers' scripts and imports stay the
342
+ * same, so typing in a module or in a page's markup does not walk the
343
+ * project again; an edit that adds, removes or changes an import does, and
344
+ * so does invalidateScriptModules().
345
+ */
346
+ export function scriptModulesOf(snapshot, openDocumentTexts = []) {
347
+ const signatures = signaturesOf(openDocumentTexts);
348
+ const cached = cache.get(snapshot);
349
+ if (cached &&
350
+ cached.generation === generation &&
351
+ sameSignatures(cached.signatures, signatures))
352
+ return cached.modules;
353
+ const open = new Map(openDocumentTexts.map((d) => [normalizeModulePath(d.fsPath), d.text]));
354
+ const html = new Map();
355
+ for (const [file, text] of snapshot.htmlUsageByFile)
356
+ html.set(file, text);
357
+ for (const [file, text] of snapshot.componentSourceByFile ?? [])
358
+ html.set(file, text);
359
+ for (const { fsPath, text } of openDocumentTexts)
360
+ if (fsPath.toLowerCase().endsWith(".html"))
361
+ html.set(fsPath, text);
362
+ const modules = findScriptModules({
363
+ projectRoot: snapshot.projectRoot,
364
+ importRoot: snapshot.importRoot,
365
+ html,
366
+ apiRoutes: listApiRoutes(snapshot.apiRoot),
367
+ extraRoots: snapshotRoots(snapshot),
368
+ readText: (file) => open.get(normalizeModulePath(file)),
369
+ });
370
+ cache.set(snapshot, { signatures, modules, generation });
371
+ return modules;
372
+ }
373
+ /**
374
+ * A snapshot's component roots, API root and `scripts.importRoot`, which
375
+ * may lie outside the project (a monorepo's shared folder).
376
+ */
377
+ export const snapshotRoots = (snapshot) => [
378
+ ...snapshot.componentRoots,
379
+ ...(snapshot.apiRoot ? [snapshot.apiRoot] : []),
380
+ snapshot.importRoot,
381
+ ];
382
+ //# sourceMappingURL=script-modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"script-modules.js","sourceRoot":"","sources":["../src/script-modules.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,8EAA8E;AAC9E,MAAM,YAAY,GAChB,+EAA+E,CAAC;AAClF,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AACzD,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC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AAU;CACpB,CAAC"}
@@ -1,13 +1,106 @@
1
+ import { type Token } from "./module-specifiers.js";
1
2
  export interface ServerScriptDiagnostic {
2
3
  code: string;
3
4
  message: string;
4
5
  severity: "error" | "warning" | "info";
5
6
  start: number;
6
7
  end: number;
8
+ /**
9
+ * server-script-unescaped-markup only: the offset of the template's
10
+ * opening backtick, and whether wrapping it in html`...` is a safe fix
11
+ * (no hole sits where html would throw).
12
+ */
13
+ template?: {
14
+ start: number;
15
+ fixable: boolean;
16
+ };
17
+ /**
18
+ * hand-written-html-escaper only, when the escaper is one `return` (or an
19
+ * arrow's expression) with one plain parameter: the body to replace with
20
+ * a call to esc(), and that parameter.
21
+ */
22
+ escaper?: {
23
+ start: number;
24
+ end: number;
25
+ param: string;
26
+ block: boolean;
27
+ };
7
28
  }
8
29
  export interface AnalyzeOptions {
9
30
  hasSrcAttribute: boolean;
10
- directive: "server" | "stream" | "build" | "routes";
31
+ /**
32
+ * The script's directive, or "module" for a .ts or .js file that runs in
33
+ * Node: a directive script's src= file, a module one imports, or an API
34
+ * route. server and stream run per request; the rest run at build time
35
+ * (or are imported by code that does).
36
+ */
37
+ directive: "server" | "stream" | "build" | "routes" | "module";
38
+ /**
39
+ * "module" only: the module runs per request (an API route, or a module a
40
+ * server script, stream script or API route imports), so every sink rule
41
+ * applies as in a server script.
42
+ */
43
+ requestTime?: boolean;
44
+ /** A project's own escapers, trusted like esc() (bascik.ext.json diagnostics.escapeFunctions). */
45
+ escapeFunctions?: readonly string[];
46
+ /** Added to body line numbers so messages name the file line (the body's first line is line 1 + lineOffset). */
47
+ lineOffset?: number;
11
48
  }
49
+ export declare const UNESCAPED_MARKUP_RULE = "server-script-unescaped-markup";
50
+ /** A server or stream script whose default export returns a Response. */
51
+ export declare const RETURNS_RESPONSE_RULE = "server-script-returns-response";
12
52
  export declare function analyzeServerScriptSource(body: string, opts: AnalyzeOptions): ServerScriptDiagnostic[];
53
+ /**
54
+ * A function whose parameter list starts at `at` (a source offset), as a
55
+ * message names it. `exported`: other modules can call it; `unseen`: a
56
+ * callback, a method, or a function passed on or returned as a value, whose
57
+ * callers this file cannot all see; `this` and `arguments`: what those
58
+ * read, which callers fill.
59
+ */
60
+ interface ReachableOwner {
61
+ at: number;
62
+ label: string;
63
+ kind: "exported" | "unseen" | "this" | "arguments";
64
+ }
65
+ /**
66
+ * The parameters of everything this module lets other modules call, each
67
+ * with the functions it belongs to and how a message names them: exported functions (named, or a
68
+ * default export named or anonymous), every method and constructor of an
69
+ * exported class, the methods and function members of an exported object
70
+ * (nested objects too), local functions exported by name or named in an
71
+ * exported object, and the same through module.exports and exports.x.
72
+ * Another module may pass any of them markup, so they count as possibly
73
+ * markup, except a parameter whose declared type is number, bigint or
74
+ * boolean (or a union of those). Each declaration is read once, so the
75
+ * pass stays linear in the tokens.
76
+ */
77
+ export declare function exportReachableParameters(body: string, tokens?: readonly Token[]): Map<string, ReachableOwner[]>;
78
+ /**
79
+ * The parameters in a module whose callers this file cannot all see, with
80
+ * the functions they belong to: every callback and function expression,
81
+ * every method and constructor, generators, and named functions that are
82
+ * exported or used as a value (returned, passed, stored, wrapped) rather
83
+ * than only called by name. A local function declared with `function` or
84
+ * bound to a `const`, `let` or `var`, and only ever called by name, is left
85
+ * out: its parameters hold what those calls pass, which markupProducers
86
+ * follows. Types count as for exported functions: a number, bigint or
87
+ * boolean parameter is plain data. `this` and `arguments` are included as
88
+ * well, since callers fill them. One pass over the tokens, each lookback
89
+ * bounded, so the pass stays linear.
90
+ */
91
+ export declare function unseenCallerParameters(body: string, tokens?: readonly Token[]): Map<string, ReachableOwner[]>;
92
+ /** A .join() of html values inside html: the joined string is escaped. */
93
+ export declare const JOINED_RULE = "html-joined-string";
94
+ /**
95
+ * Each `new Response(...)` or `Response.json(...)` (`.redirect`, `.error`)
96
+ * the default export returns, as offsets into `body`. Comments and strings are
97
+ * masked first, so the words in either never count, and a `return` inside a
98
+ * nested function (a helper, a callback, a method) belongs to that function.
99
+ * One pass over the default export's body.
100
+ */
101
+ export declare function findReturnedResponses(body: string): {
102
+ start: number;
103
+ end: number;
104
+ }[];
105
+ export {};
13
106
  //# sourceMappingURL=server-script-rules.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server-script-rules.d.ts","sourceRoot":"","sources":["../src/server-script-rules.ts"],"names":[],"mappings":"AAsGA,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,cAAc;IAC7B,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,CAAC;CACrD;AAiED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,cAAc,GACnB,sBAAsB,EAAE,CA+M1B"}
1
+ {"version":3,"file":"server-script-rules.d.ts","sourceRoot":"","sources":["../src/server-script-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,KAAK,EACX,MAAM,wBAAwB,CAAC;AAqChC,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,QAAQ,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAC/C;;;;OAIG;IACH,OAAO,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,O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