tidewave 0.3.0 → 0.4.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.
@@ -1,112 +0,0 @@
1
- import { createRequire } from "node:module";
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __toESM = (mod, isNodeMode, target) => {
8
- target = mod != null ? __create(__getProtoOf(mod)) : {};
9
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
- for (let key of __getOwnPropNames(mod))
11
- if (!__hasOwnProp.call(to, key))
12
- __defProp(to, key, {
13
- get: () => mod[key],
14
- enumerable: true
15
- });
16
- return to;
17
- };
18
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
- var __export = (target, all) => {
20
- for (var name in all)
21
- __defProp(target, name, {
22
- get: all[name],
23
- enumerable: true,
24
- configurable: true,
25
- set: (newValue) => all[name] = () => newValue
26
- });
27
- };
28
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
29
-
30
- // src/resolution/utils.ts
31
- import ts from "typescript";
32
- import path from "node:path";
33
- function getLocation(symbol) {
34
- if (symbol.valueDeclaration) {
35
- const sourceFile = symbol.valueDeclaration.getSourceFile();
36
- const { line, character } = sourceFile.getLineAndCharacterOfPosition(symbol.valueDeclaration.getStart());
37
- let { fileName } = sourceFile;
38
- const cwd = process.cwd();
39
- if (fileName.startsWith(cwd)) {
40
- fileName = path.relative(cwd, fileName);
41
- }
42
- return `${fileName}:${line + 1}:${character + 1}`;
43
- }
44
- if (symbol.declarations && symbol.declarations.length > 0) {
45
- const [firstDeclaration] = symbol.declarations;
46
- const sourceFile = firstDeclaration?.getSourceFile();
47
- if (sourceFile === undefined || firstDeclaration === undefined)
48
- return "unknown";
49
- const { line, character } = sourceFile.getLineAndCharacterOfPosition(firstDeclaration.getStart());
50
- let fileName = sourceFile?.fileName;
51
- const cwd = process.cwd();
52
- if (fileName?.startsWith(cwd)) {
53
- fileName = path.relative(cwd, fileName);
54
- }
55
- return `${fileName}:${line + 1}:${character + 1}`;
56
- }
57
- return "unknown";
58
- }
59
- function getDocumentation(checker, symbol) {
60
- return ts.displayPartsToString(symbol.getDocumentationComment(checker));
61
- }
62
- function getJSDoc(checker, symbol) {
63
- const jsDocTags = symbol.getJsDocTags(checker);
64
- return jsDocTags.map((tag) => {
65
- const tagName = tag.name;
66
- const tagText = tag.text ? ts.displayPartsToString(tag.text) : "";
67
- return `@${tagName}${tagText ? " " + tagText : ""}`;
68
- }).join(`
69
- `);
70
- }
71
- function getSymbolKind(symbol) {
72
- const flags = symbol.getFlags();
73
- if (flags & ts.SymbolFlags.Function)
74
- return "function";
75
- if (flags & ts.SymbolFlags.Class)
76
- return "class";
77
- if (flags & ts.SymbolFlags.Interface)
78
- return "interface";
79
- if (flags & ts.SymbolFlags.TypeAlias)
80
- return "type";
81
- if (flags & ts.SymbolFlags.Variable)
82
- return "variable";
83
- if (flags & ts.SymbolFlags.Property)
84
- return "property";
85
- if (flags & ts.SymbolFlags.Method)
86
- return "method";
87
- if (flags & ts.SymbolFlags.Enum)
88
- return "enum";
89
- if (flags & ts.SymbolFlags.Module)
90
- return "module";
91
- if (symbol.valueDeclaration) {
92
- if (ts.isFunctionDeclaration(symbol.valueDeclaration)) {
93
- return "function";
94
- }
95
- if (ts.isClassDeclaration(symbol.valueDeclaration)) {
96
- return "class";
97
- }
98
- if (ts.isVariableDeclaration(symbol.valueDeclaration)) {
99
- return "variable";
100
- }
101
- if (ts.isMethodDeclaration(symbol.valueDeclaration)) {
102
- return "method";
103
- }
104
- }
105
- return "unknown";
106
- }
107
- export {
108
- getSymbolKind,
109
- getLocation,
110
- getJSDoc,
111
- getDocumentation
112
- };