tidewave 0.6.0 → 0.7.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/CHANGELOG.md +6 -0
- package/README.md +23 -5
- package/dist/cli/index.js +231 -39
- package/dist/core.d.ts +15 -6
- package/dist/http/handlers/config.d.ts +3 -2
- package/dist/http/index.d.ts +7 -3
- package/dist/http/security.d.ts +0 -8
- package/dist/next-js/handler.d.ts +1 -0
- package/dist/next-js/handler.js +298 -188
- package/dist/next-js/instrumentation.js +20 -2
- package/dist/resolution/formatters.d.ts +2 -2
- package/dist/resolution/index.d.ts +1 -2
- package/dist/resolution/symbol-finder.d.ts +2 -2
- package/dist/resolution/utils.d.ts +1 -0
- package/dist/tanstack.js +20 -2
- package/dist/vite-plugin.js +287 -195
- package/package.json +2 -2
package/dist/next-js/handler.js
CHANGED
|
@@ -4,25 +4,43 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
function __accessProp(key) {
|
|
8
|
+
return this[key];
|
|
9
|
+
}
|
|
10
|
+
var __toESMCache_node;
|
|
11
|
+
var __toESMCache_esm;
|
|
7
12
|
var __toESM = (mod, isNodeMode, target) => {
|
|
13
|
+
var canCache = mod != null && typeof mod === "object";
|
|
14
|
+
if (canCache) {
|
|
15
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
16
|
+
var cached = cache.get(mod);
|
|
17
|
+
if (cached)
|
|
18
|
+
return cached;
|
|
19
|
+
}
|
|
8
20
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
9
21
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
10
22
|
for (let key of __getOwnPropNames(mod))
|
|
11
23
|
if (!__hasOwnProp.call(to, key))
|
|
12
24
|
__defProp(to, key, {
|
|
13
|
-
get: (
|
|
25
|
+
get: __accessProp.bind(mod, key),
|
|
14
26
|
enumerable: true
|
|
15
27
|
});
|
|
28
|
+
if (canCache)
|
|
29
|
+
cache.set(mod, to);
|
|
16
30
|
return to;
|
|
17
31
|
};
|
|
18
32
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
|
+
var __returnValue = (v) => v;
|
|
34
|
+
function __exportSetter(name, newValue) {
|
|
35
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
36
|
+
}
|
|
19
37
|
var __export = (target, all) => {
|
|
20
38
|
for (var name in all)
|
|
21
39
|
__defProp(target, name, {
|
|
22
40
|
get: all[name],
|
|
23
41
|
enumerable: true,
|
|
24
42
|
configurable: true,
|
|
25
|
-
set: (
|
|
43
|
+
set: __exportSetter.bind(all, name)
|
|
26
44
|
});
|
|
27
45
|
};
|
|
28
46
|
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
@@ -1674,65 +1692,6 @@ function isLocalIp(ip) {
|
|
|
1674
1692
|
return true;
|
|
1675
1693
|
return false;
|
|
1676
1694
|
}
|
|
1677
|
-
function checkOrigin(req, res, config) {
|
|
1678
|
-
const { origin } = req.headers;
|
|
1679
|
-
if (!origin)
|
|
1680
|
-
return true;
|
|
1681
|
-
const allowedOrigins = config.allowedOrigins || getDefaultAllowedOrigins(config);
|
|
1682
|
-
const originUrl = parseUrl(origin);
|
|
1683
|
-
if (!originUrl) {
|
|
1684
|
-
const message = `For security reasons, Tidewave only accepts requests from allowed origins.
|
|
1685
|
-
|
|
1686
|
-
Invalid origin: ${origin}`;
|
|
1687
|
-
console.warn(message);
|
|
1688
|
-
res.statusCode = 403;
|
|
1689
|
-
res.end(message);
|
|
1690
|
-
return false;
|
|
1691
|
-
}
|
|
1692
|
-
const isAllowed = allowedOrigins.some((allowed) => isOriginAllowed(originUrl, parseUrl(allowed)));
|
|
1693
|
-
if (!isAllowed) {
|
|
1694
|
-
const message = `For security reasons, Tidewave only accepts requests from the same origin your web app is running on.
|
|
1695
|
-
|
|
1696
|
-
If you really want to allow remote connections, configure the Tidewave with the \`allowedOrigins: [${JSON.stringify(origin)}]\` option.`;
|
|
1697
|
-
console.warn(message);
|
|
1698
|
-
res.statusCode = 403;
|
|
1699
|
-
res.end(message);
|
|
1700
|
-
return false;
|
|
1701
|
-
}
|
|
1702
|
-
return true;
|
|
1703
|
-
}
|
|
1704
|
-
function getDefaultAllowedOrigins(config) {
|
|
1705
|
-
const { host, port } = config;
|
|
1706
|
-
if (!(host || port))
|
|
1707
|
-
return [];
|
|
1708
|
-
return [`http://${host}:${port}`, `https://${host}:${port}`];
|
|
1709
|
-
}
|
|
1710
|
-
function parseUrl(url) {
|
|
1711
|
-
try {
|
|
1712
|
-
const isProtocolRelative = url.startsWith("//");
|
|
1713
|
-
const parsed = new URL(isProtocolRelative ? "http:" + url : url);
|
|
1714
|
-
return {
|
|
1715
|
-
scheme: isProtocolRelative ? undefined : parsed.protocol?.slice(0, -1),
|
|
1716
|
-
host: parsed.hostname,
|
|
1717
|
-
port: parsed.port ? parseInt(parsed.port) : undefined
|
|
1718
|
-
};
|
|
1719
|
-
} catch {
|
|
1720
|
-
return null;
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
function isOriginAllowed(origin, allowed) {
|
|
1724
|
-
if (!origin || !allowed)
|
|
1725
|
-
return false;
|
|
1726
|
-
if (allowed.scheme && origin.scheme !== allowed.scheme)
|
|
1727
|
-
return false;
|
|
1728
|
-
if (allowed.port && origin.port !== allowed.port)
|
|
1729
|
-
return false;
|
|
1730
|
-
if (allowed.host.startsWith("*.")) {
|
|
1731
|
-
const allowedDomain = allowed.host.slice(2);
|
|
1732
|
-
return origin.host === allowedDomain || origin.host.endsWith("." + allowedDomain);
|
|
1733
|
-
}
|
|
1734
|
-
return origin.host === allowed.host;
|
|
1735
|
-
}
|
|
1736
1695
|
|
|
1737
1696
|
// node_modules/zod/v3/helpers/util.js
|
|
1738
1697
|
var util, objectUtil, ZodParsedType, getParsedType = (data) => {
|
|
@@ -11828,10 +11787,10 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
11828
11787
|
}
|
|
11829
11788
|
return output;
|
|
11830
11789
|
}
|
|
11831
|
-
var ucs2encode = function
|
|
11790
|
+
var ucs2encode = function ucs2encode2(array) {
|
|
11832
11791
|
return String.fromCodePoint.apply(String, toConsumableArray(array));
|
|
11833
11792
|
};
|
|
11834
|
-
var basicToDigit = function
|
|
11793
|
+
var basicToDigit = function basicToDigit2(codePoint) {
|
|
11835
11794
|
if (codePoint - 48 < 10) {
|
|
11836
11795
|
return codePoint - 22;
|
|
11837
11796
|
}
|
|
@@ -11843,10 +11802,10 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
11843
11802
|
}
|
|
11844
11803
|
return base;
|
|
11845
11804
|
};
|
|
11846
|
-
var digitToBasic = function
|
|
11805
|
+
var digitToBasic = function digitToBasic2(digit, flag) {
|
|
11847
11806
|
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
11848
11807
|
};
|
|
11849
|
-
var adapt = function
|
|
11808
|
+
var adapt = function adapt2(delta, numPoints, firstTime) {
|
|
11850
11809
|
var k = 0;
|
|
11851
11810
|
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
11852
11811
|
delta += floor(delta / numPoints);
|
|
@@ -11855,7 +11814,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
11855
11814
|
}
|
|
11856
11815
|
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
11857
11816
|
};
|
|
11858
|
-
var decode = function
|
|
11817
|
+
var decode = function decode2(input) {
|
|
11859
11818
|
var output = [];
|
|
11860
11819
|
var inputLength = input.length;
|
|
11861
11820
|
var i = 0;
|
|
@@ -11903,7 +11862,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
11903
11862
|
}
|
|
11904
11863
|
return String.fromCodePoint.apply(String, output);
|
|
11905
11864
|
};
|
|
11906
|
-
var encode = function
|
|
11865
|
+
var encode = function encode2(input) {
|
|
11907
11866
|
var output = [];
|
|
11908
11867
|
input = ucs2decode(input);
|
|
11909
11868
|
var inputLength = input.length;
|
|
@@ -12017,12 +11976,12 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
12017
11976
|
}
|
|
12018
11977
|
return output.join("");
|
|
12019
11978
|
};
|
|
12020
|
-
var toUnicode = function
|
|
11979
|
+
var toUnicode = function toUnicode2(input) {
|
|
12021
11980
|
return mapDomain(input, function(string) {
|
|
12022
11981
|
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
|
|
12023
11982
|
});
|
|
12024
11983
|
};
|
|
12025
|
-
var toASCII = function
|
|
11984
|
+
var toASCII = function toASCII2(input) {
|
|
12026
11985
|
return mapDomain(input, function(string) {
|
|
12027
11986
|
return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
|
|
12028
11987
|
});
|
|
@@ -12419,13 +12378,13 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
12419
12378
|
var handler = {
|
|
12420
12379
|
scheme: "http",
|
|
12421
12380
|
domainHost: true,
|
|
12422
|
-
parse: function
|
|
12381
|
+
parse: function parse2(components, options) {
|
|
12423
12382
|
if (!components.host) {
|
|
12424
12383
|
components.error = components.error || "HTTP URIs must have a host.";
|
|
12425
12384
|
}
|
|
12426
12385
|
return components;
|
|
12427
12386
|
},
|
|
12428
|
-
serialize: function
|
|
12387
|
+
serialize: function serialize2(components, options) {
|
|
12429
12388
|
var secure = String(components.scheme).toLowerCase() === "https";
|
|
12430
12389
|
if (components.port === (secure ? 443 : 80) || components.port === "") {
|
|
12431
12390
|
components.port = undefined;
|
|
@@ -12448,7 +12407,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
12448
12407
|
var handler$2 = {
|
|
12449
12408
|
scheme: "ws",
|
|
12450
12409
|
domainHost: true,
|
|
12451
|
-
parse: function
|
|
12410
|
+
parse: function parse2(components, options) {
|
|
12452
12411
|
var wsComponents = components;
|
|
12453
12412
|
wsComponents.secure = isSecure(wsComponents);
|
|
12454
12413
|
wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
|
|
@@ -12456,7 +12415,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
12456
12415
|
wsComponents.query = undefined;
|
|
12457
12416
|
return wsComponents;
|
|
12458
12417
|
},
|
|
12459
|
-
serialize: function
|
|
12418
|
+
serialize: function serialize2(wsComponents, options) {
|
|
12460
12419
|
if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
|
|
12461
12420
|
wsComponents.port = undefined;
|
|
12462
12421
|
}
|
|
@@ -12624,7 +12583,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
12624
12583
|
var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
|
|
12625
12584
|
var handler$6 = {
|
|
12626
12585
|
scheme: "urn:uuid",
|
|
12627
|
-
parse: function
|
|
12586
|
+
parse: function parse2(urnComponents, options) {
|
|
12628
12587
|
var uuidComponents = urnComponents;
|
|
12629
12588
|
uuidComponents.uuid = uuidComponents.nss;
|
|
12630
12589
|
uuidComponents.nss = undefined;
|
|
@@ -12633,7 +12592,7 @@ var require_uri_all = __commonJS((exports, module) => {
|
|
|
12633
12592
|
}
|
|
12634
12593
|
return uuidComponents;
|
|
12635
12594
|
},
|
|
12636
|
-
serialize: function
|
|
12595
|
+
serialize: function serialize2(uuidComponents, options) {
|
|
12637
12596
|
var urnComponents = uuidComponents;
|
|
12638
12597
|
urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
|
|
12639
12598
|
return urnComponents;
|
|
@@ -14079,7 +14038,7 @@ var require_compile = __commonJS((exports, module) => {
|
|
|
14079
14038
|
|
|
14080
14039
|
// node_modules/ajv/lib/cache.js
|
|
14081
14040
|
var require_cache = __commonJS((exports, module) => {
|
|
14082
|
-
var Cache = module.exports = function
|
|
14041
|
+
var Cache = module.exports = function Cache2() {
|
|
14083
14042
|
this._cache = {};
|
|
14084
14043
|
};
|
|
14085
14044
|
Cache.prototype.put = function Cache_put(key, value) {
|
|
@@ -19374,6 +19333,7 @@ var init_zodToJsonSchema = __esm(() => {
|
|
|
19374
19333
|
|
|
19375
19334
|
// node_modules/zod-to-json-schema/dist/esm/index.js
|
|
19376
19335
|
var init_esm = __esm(() => {
|
|
19336
|
+
init_zodToJsonSchema();
|
|
19377
19337
|
init_Options();
|
|
19378
19338
|
init_Refs();
|
|
19379
19339
|
init_parseDef();
|
|
@@ -19405,7 +19365,6 @@ var init_esm = __esm(() => {
|
|
|
19405
19365
|
init_unknown();
|
|
19406
19366
|
init_selectParser();
|
|
19407
19367
|
init_zodToJsonSchema();
|
|
19408
|
-
init_zodToJsonSchema();
|
|
19409
19368
|
});
|
|
19410
19369
|
|
|
19411
19370
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
|
|
@@ -20028,9 +19987,10 @@ var init_mcp = __esm(() => {
|
|
|
20028
19987
|
});
|
|
20029
19988
|
|
|
20030
19989
|
// src/tools.ts
|
|
20031
|
-
var projectEvalDescription, projectEvalInputSchema, referenceDescription = `Module path in format 'module:symbol[#method|.method]'. Supports local files, dependencies, and Node.js builtins.
|
|
19990
|
+
var projectEvalDescription, projectEvalInputSchema, referenceDescription = `Module/file path, optionally with symbol in format 'module[:symbol[#method|.method]]'. Supports local files, dependencies, and Node.js builtins.
|
|
20032
19991
|
|
|
20033
19992
|
Module reference format:
|
|
19993
|
+
- module - List all symbols in the module (file-level documentation)
|
|
20034
19994
|
- module:symbol - Extract a top-level symbol
|
|
20035
19995
|
- module:Class#method - Extract an instance method
|
|
20036
19996
|
- module:Class.method - Extract a static method
|
|
@@ -20038,6 +19998,8 @@ Module reference format:
|
|
|
20038
19998
|
- node:Class.method - Extract a global/builtin static method
|
|
20039
19999
|
|
|
20040
20000
|
Examples:
|
|
20001
|
+
- src/types.ts (list all symbols in file)
|
|
20002
|
+
- lodash (list all symbols in dependency)
|
|
20041
20003
|
- src/types.ts:SymbolInfo (local file symbol)
|
|
20042
20004
|
- lodash:isEmpty (dependency function)
|
|
20043
20005
|
- react:Component#render (instance method)
|
|
@@ -20045,7 +20007,8 @@ Examples:
|
|
|
20045
20007
|
var init_tools = __esm(() => {
|
|
20046
20008
|
init_zod();
|
|
20047
20009
|
projectEvalDescription = `
|
|
20048
|
-
Evaluates JavaScript/TypeScript code
|
|
20010
|
+
Evaluates JavaScript/TypeScript code within your project's build tool
|
|
20011
|
+
(or server for full-stack applications).
|
|
20049
20012
|
|
|
20050
20013
|
The current NodeJS version is: ${process.version}
|
|
20051
20014
|
|
|
@@ -20054,7 +20017,7 @@ including to test the behaviour of a function or to debug
|
|
|
20054
20017
|
something. The tool also returns anything written to standard
|
|
20055
20018
|
output. DO NOT use shell tools to evaluate JavaScript/TypeScript code.
|
|
20056
20019
|
|
|
20057
|
-
Imports are allowed only as the form of dynamic imports with async/await
|
|
20020
|
+
Imports are allowed only as the form of dynamic imports with async/await:
|
|
20058
20021
|
const path = await import('node:path');
|
|
20059
20022
|
`;
|
|
20060
20023
|
projectEvalInputSchema = exports_external.object({
|
|
@@ -20080,7 +20043,26 @@ Defaults to 30000 (30 seconds).`),
|
|
|
20080
20043
|
docs: {
|
|
20081
20044
|
mcp: {
|
|
20082
20045
|
name: "get_docs",
|
|
20083
|
-
description:
|
|
20046
|
+
description: `Extract TypeScript/JavaScript documentation and type information. Works for modules in the current project, dependencies, and builtin node modules.
|
|
20047
|
+
|
|
20048
|
+
Reference format determines what is returned:
|
|
20049
|
+
|
|
20050
|
+
• "module" - Returns file overview and lists all exported symbols with their kinds, line numbers, and brief documentation. Use this to discover what's available in a module.
|
|
20051
|
+
|
|
20052
|
+
• "module:symbol" - Returns detailed documentation for a specific top-level symbol including its type signature, full documentation, JSDoc tags, and source location.
|
|
20053
|
+
|
|
20054
|
+
• "module:Class.staticMethod" - Returns detailed documentation for a static method or property of a class or object.
|
|
20055
|
+
|
|
20056
|
+
• "module:Class#instanceMethod" - Returns detailed documentation for an instance method or property of a class.
|
|
20057
|
+
|
|
20058
|
+
Examples:
|
|
20059
|
+
- "src/types.ts" → Lists all exported symbols in the file
|
|
20060
|
+
- "lodash" → Lists all symbols exported from lodash
|
|
20061
|
+
- "src/types.ts:SymbolInfo" → Full docs for SymbolInfo interface
|
|
20062
|
+
- "react:Component#render" → Docs for React Component's render method
|
|
20063
|
+
- "node:Math.max" → Docs for Math.max static method
|
|
20064
|
+
|
|
20065
|
+
Start with module-only references to explore, then drill into specific symbols for detailed information.`,
|
|
20084
20066
|
inputSchema: docsInputSchema
|
|
20085
20067
|
},
|
|
20086
20068
|
cli: {
|
|
@@ -20129,7 +20111,7 @@ Defaults to 30000 (30 seconds).`),
|
|
|
20129
20111
|
logs: {
|
|
20130
20112
|
mcp: {
|
|
20131
20113
|
name: "get_logs",
|
|
20132
|
-
description: "Retrieve application logs
|
|
20114
|
+
description: "Retrieve application logs within your project's build tool (or server for full-stack applications). Supports filtering by level, time, and pattern matching.",
|
|
20133
20115
|
inputSchema: getLogsInputSchema
|
|
20134
20116
|
}
|
|
20135
20117
|
}
|
|
@@ -20137,7 +20119,7 @@ Defaults to 30000 (30 seconds).`),
|
|
|
20137
20119
|
});
|
|
20138
20120
|
|
|
20139
20121
|
// package.json
|
|
20140
|
-
var name = "tidewave", version = "0.
|
|
20122
|
+
var name = "tidewave", version = "0.7.0", package_default;
|
|
20141
20123
|
var init_package = __esm(() => {
|
|
20142
20124
|
package_default = {
|
|
20143
20125
|
name,
|
|
@@ -20148,7 +20130,10 @@ var init_package = __esm(() => {
|
|
|
20148
20130
|
"documentation",
|
|
20149
20131
|
"mcp",
|
|
20150
20132
|
"cli",
|
|
20151
|
-
"tidewave"
|
|
20133
|
+
"tidewave",
|
|
20134
|
+
"next",
|
|
20135
|
+
"vite",
|
|
20136
|
+
"tanstack"
|
|
20152
20137
|
],
|
|
20153
20138
|
homepage: "https://tidewave.ai",
|
|
20154
20139
|
repository: {
|
|
@@ -20239,7 +20224,7 @@ var init_package = __esm(() => {
|
|
|
20239
20224
|
next: "^15.5.3",
|
|
20240
20225
|
prettier: "^3.4.2",
|
|
20241
20226
|
vite: "^7.1.5",
|
|
20242
|
-
vitest: "^
|
|
20227
|
+
vitest: "^4.1.8"
|
|
20243
20228
|
},
|
|
20244
20229
|
peerDependencies: {
|
|
20245
20230
|
typescript: "^5"
|
|
@@ -20263,6 +20248,9 @@ function isResolveError(result) {
|
|
|
20263
20248
|
function isExtractError(result) {
|
|
20264
20249
|
return result != null && "error" in result;
|
|
20265
20250
|
}
|
|
20251
|
+
function isFileInfo(result) {
|
|
20252
|
+
return result != null && "exports" in result && Array.isArray(result.exports);
|
|
20253
|
+
}
|
|
20266
20254
|
function resolveError(specifier, source) {
|
|
20267
20255
|
return {
|
|
20268
20256
|
success: false,
|
|
@@ -20461,6 +20449,8 @@ function getSymbolKind(symbol) {
|
|
|
20461
20449
|
return "property";
|
|
20462
20450
|
if (flags & ts2.SymbolFlags.Method)
|
|
20463
20451
|
return "method";
|
|
20452
|
+
if (flags & ts2.SymbolFlags.EnumMember)
|
|
20453
|
+
return "enum member";
|
|
20464
20454
|
if (flags & ts2.SymbolFlags.Enum)
|
|
20465
20455
|
return "enum";
|
|
20466
20456
|
if (flags & ts2.SymbolFlags.Module)
|
|
@@ -20481,6 +20471,27 @@ function getSymbolKind(symbol) {
|
|
|
20481
20471
|
}
|
|
20482
20472
|
return "unknown";
|
|
20483
20473
|
}
|
|
20474
|
+
function getFileOverview(sourceFile) {
|
|
20475
|
+
const leadingComments = ts2.getLeadingCommentRanges(sourceFile.text, 0);
|
|
20476
|
+
if (!leadingComments || leadingComments.length === 0) {
|
|
20477
|
+
return;
|
|
20478
|
+
}
|
|
20479
|
+
for (const comment of leadingComments) {
|
|
20480
|
+
const commentText = sourceFile.text.slice(comment.pos, comment.end);
|
|
20481
|
+
const fileoverviewMatch = commentText.match(/@fileoverview\s+([\s\S]*?)(?=@\w+|$)/);
|
|
20482
|
+
const fileMatch = commentText.match(/@file\s+([\s\S]*?)(?=@\w+|$)/);
|
|
20483
|
+
const match = fileoverviewMatch || fileMatch;
|
|
20484
|
+
if (match && match[1]) {
|
|
20485
|
+
const overviewText = match[1].split(`
|
|
20486
|
+
`).map((line) => line.replace(/^\s*\*\s?/, "").trim()).filter((line) => line.length > 0).join(`
|
|
20487
|
+
`).trim();
|
|
20488
|
+
if (overviewText) {
|
|
20489
|
+
return overviewText;
|
|
20490
|
+
}
|
|
20491
|
+
}
|
|
20492
|
+
}
|
|
20493
|
+
return;
|
|
20494
|
+
}
|
|
20484
20495
|
var init_utils = () => {};
|
|
20485
20496
|
|
|
20486
20497
|
// src/resolution/formatters.ts
|
|
@@ -20577,7 +20588,7 @@ function getTypeString(checker, symbol, type) {
|
|
|
20577
20588
|
}
|
|
20578
20589
|
return defaultTypeString;
|
|
20579
20590
|
}
|
|
20580
|
-
function
|
|
20591
|
+
function formatSymbolInfo(info) {
|
|
20581
20592
|
const output = [];
|
|
20582
20593
|
output.push(`
|
|
20583
20594
|
${info.name}`);
|
|
@@ -20604,7 +20615,36 @@ ${info.name}`);
|
|
|
20604
20615
|
return output.join(`
|
|
20605
20616
|
`);
|
|
20606
20617
|
}
|
|
20607
|
-
|
|
20618
|
+
function formatFileInfo(info) {
|
|
20619
|
+
const output = [];
|
|
20620
|
+
output.push(`
|
|
20621
|
+
File: ${info.path}`);
|
|
20622
|
+
output.push("");
|
|
20623
|
+
if (info.overview) {
|
|
20624
|
+
output.push("Overview:");
|
|
20625
|
+
output.push(info.overview);
|
|
20626
|
+
output.push("");
|
|
20627
|
+
}
|
|
20628
|
+
output.push(`Symbols (${info.exportCount} total):`);
|
|
20629
|
+
output.push("");
|
|
20630
|
+
for (const exp of info.exports) {
|
|
20631
|
+
output.push(`${exp.name} (${exp.kind}) - line ${exp.line}`);
|
|
20632
|
+
if (exp.documentation) {
|
|
20633
|
+
output.push(exp.documentation);
|
|
20634
|
+
}
|
|
20635
|
+
}
|
|
20636
|
+
return output.join(`
|
|
20637
|
+
`);
|
|
20638
|
+
}
|
|
20639
|
+
function formatOutput(info) {
|
|
20640
|
+
if (isFileInfo(info)) {
|
|
20641
|
+
return formatFileInfo(info);
|
|
20642
|
+
}
|
|
20643
|
+
return formatSymbolInfo(info);
|
|
20644
|
+
}
|
|
20645
|
+
var init_formatters = __esm(() => {
|
|
20646
|
+
init_core();
|
|
20647
|
+
});
|
|
20608
20648
|
|
|
20609
20649
|
// src/resolution/symbol-finder.ts
|
|
20610
20650
|
import ts4 from "typescript";
|
|
@@ -20681,7 +20721,12 @@ function getSymbolInfo(checker, symbol, member, isStatic) {
|
|
|
20681
20721
|
return createExtractError("TYPE_ERROR", `Symbol '${symbol.getName()}' has no declarations`);
|
|
20682
20722
|
}
|
|
20683
20723
|
const targetDeclaration = declaration || symbol.declarations[0];
|
|
20684
|
-
|
|
20724
|
+
let type;
|
|
20725
|
+
if (symbol.flags & (ts4.SymbolFlags.Interface | ts4.SymbolFlags.TypeAlias)) {
|
|
20726
|
+
type = checker.getDeclaredTypeOfSymbol(symbol);
|
|
20727
|
+
} else {
|
|
20728
|
+
type = checker.getTypeOfSymbolAtLocation(symbol, targetDeclaration);
|
|
20729
|
+
}
|
|
20685
20730
|
const symbolName = symbol.getName();
|
|
20686
20731
|
let targetSymbol = symbol;
|
|
20687
20732
|
let targetType = type;
|
|
@@ -20695,11 +20740,27 @@ function getSymbolInfo(checker, symbol, member, isStatic) {
|
|
|
20695
20740
|
targetType = checker.getTypeOfSymbolAtLocation(staticMember, staticMember.valueDeclaration);
|
|
20696
20741
|
name2 = `${symbolName}.${member}`;
|
|
20697
20742
|
} else {
|
|
20698
|
-
return createExtractError("MEMBER_NOT_FOUND", `Static member '${member}' not found on '${symbolName}'`);
|
|
20743
|
+
return createExtractError("MEMBER_NOT_FOUND", `Static member '${member}' not found on '${symbolName}'. Available: ${staticMembers.map((m) => m.getName()).join(", ")}`);
|
|
20699
20744
|
}
|
|
20700
20745
|
} else {
|
|
20701
20746
|
let instanceType;
|
|
20702
|
-
if (symbol.flags & ts4.SymbolFlags.
|
|
20747
|
+
if (symbol.flags & ts4.SymbolFlags.Interface) {
|
|
20748
|
+
instanceType = type;
|
|
20749
|
+
const instanceMembers = checker.getPropertiesOfType(instanceType);
|
|
20750
|
+
const instanceMember = instanceMembers.find((s) => s.getName() === member);
|
|
20751
|
+
if (instanceMember) {
|
|
20752
|
+
targetSymbol = instanceMember;
|
|
20753
|
+
const memberDecl = instanceMember.valueDeclaration || instanceMember.declarations?.[0];
|
|
20754
|
+
if (memberDecl) {
|
|
20755
|
+
targetType = checker.getTypeOfSymbolAtLocation(instanceMember, memberDecl);
|
|
20756
|
+
} else {
|
|
20757
|
+
targetType = checker.getTypeOfSymbol(instanceMember);
|
|
20758
|
+
}
|
|
20759
|
+
name2 = `${symbolName}#${member}`;
|
|
20760
|
+
} else {
|
|
20761
|
+
return createExtractError("MEMBER_NOT_FOUND", `Instance member '${member}' not found on interface '${symbolName}'. Available: ${instanceMembers.map((m) => m.getName()).join(", ")}`);
|
|
20762
|
+
}
|
|
20763
|
+
} else if (symbol.flags & ts4.SymbolFlags.Class) {
|
|
20703
20764
|
instanceType = checker.getTypeOfSymbolAtLocation(symbol, symbol.valueDeclaration);
|
|
20704
20765
|
const constructSignatures = instanceType.getConstructSignatures();
|
|
20705
20766
|
if (constructSignatures.length > 0) {
|
|
@@ -20783,6 +20844,9 @@ var init_symbol_finder = __esm(() => {
|
|
|
20783
20844
|
import ts5 from "typescript";
|
|
20784
20845
|
import path4 from "node:path";
|
|
20785
20846
|
function parseModulePath(modulePath) {
|
|
20847
|
+
if (!modulePath || modulePath.trim() === "") {
|
|
20848
|
+
return createExtractError("INVALID_REQUEST", "Module path is required");
|
|
20849
|
+
}
|
|
20786
20850
|
let module;
|
|
20787
20851
|
let symbolPath;
|
|
20788
20852
|
if (modulePath.startsWith("node:")) {
|
|
@@ -20791,12 +20855,22 @@ function parseModulePath(modulePath) {
|
|
|
20791
20855
|
module = `node:${baseSymbol}`;
|
|
20792
20856
|
symbolPath = nodeSymbol;
|
|
20793
20857
|
} else {
|
|
20794
|
-
const
|
|
20795
|
-
if (
|
|
20796
|
-
|
|
20858
|
+
const colonIndex = modulePath.indexOf(":");
|
|
20859
|
+
if (colonIndex === -1) {
|
|
20860
|
+
module = modulePath;
|
|
20861
|
+
symbolPath = undefined;
|
|
20862
|
+
} else if (colonIndex === 0) {
|
|
20863
|
+
return createExtractError("INVALID_REQUEST", 'Module path is required before ":"');
|
|
20864
|
+
} else {
|
|
20865
|
+
module = modulePath.substring(0, colonIndex);
|
|
20866
|
+
symbolPath = modulePath.substring(colonIndex + 1);
|
|
20867
|
+
if (!symbolPath || symbolPath.trim() === "") {
|
|
20868
|
+
return createExtractError("INVALID_REQUEST", 'Symbol name is required after ":"');
|
|
20869
|
+
}
|
|
20797
20870
|
}
|
|
20798
|
-
|
|
20799
|
-
|
|
20871
|
+
}
|
|
20872
|
+
if (!symbolPath) {
|
|
20873
|
+
return { module, symbol: undefined, member: undefined, isStatic: false };
|
|
20800
20874
|
}
|
|
20801
20875
|
if (symbolPath.includes("#")) {
|
|
20802
20876
|
const [symbol, member] = symbolPath.split("#");
|
|
@@ -20814,6 +20888,37 @@ function parseModulePath(modulePath) {
|
|
|
20814
20888
|
}
|
|
20815
20889
|
return { module, symbol: symbolPath, member: undefined, isStatic: false };
|
|
20816
20890
|
}
|
|
20891
|
+
function getExportSummaries(moduleSymbol, sourceFile, checker) {
|
|
20892
|
+
if (!moduleSymbol) {
|
|
20893
|
+
return [];
|
|
20894
|
+
}
|
|
20895
|
+
try {
|
|
20896
|
+
const exports = checker.getExportsOfModule(moduleSymbol);
|
|
20897
|
+
const summaries = [];
|
|
20898
|
+
for (const exp of exports) {
|
|
20899
|
+
const name2 = exp.getName();
|
|
20900
|
+
const kind = getSymbolKind(exp);
|
|
20901
|
+
const decl = exp.valueDeclaration ?? exp.declarations?.[0];
|
|
20902
|
+
let line = 0;
|
|
20903
|
+
if (decl) {
|
|
20904
|
+
const pos = sourceFile.getLineAndCharacterOfPosition(decl.getStart());
|
|
20905
|
+
line = pos.line + 1;
|
|
20906
|
+
}
|
|
20907
|
+
const fullDoc = ts5.displayPartsToString(exp.getDocumentationComment(checker));
|
|
20908
|
+
const briefDoc = fullDoc.split(`
|
|
20909
|
+
`)[0]?.trim();
|
|
20910
|
+
summaries.push({
|
|
20911
|
+
name: name2,
|
|
20912
|
+
kind,
|
|
20913
|
+
line,
|
|
20914
|
+
documentation: briefDoc || undefined
|
|
20915
|
+
});
|
|
20916
|
+
}
|
|
20917
|
+
return summaries.sort((a, b) => a.line - b.line);
|
|
20918
|
+
} catch {
|
|
20919
|
+
return [];
|
|
20920
|
+
}
|
|
20921
|
+
}
|
|
20817
20922
|
async function extractDocs(modulePath) {
|
|
20818
20923
|
const options = { prefix: process.cwd() };
|
|
20819
20924
|
const parseResult = parseModulePath(modulePath);
|
|
@@ -20836,6 +20941,22 @@ async function extractDocs(modulePath) {
|
|
|
20836
20941
|
}
|
|
20837
20942
|
const { sourceFile, program } = resolvedModule;
|
|
20838
20943
|
const checker = program.getTypeChecker();
|
|
20944
|
+
if (symbol === undefined) {
|
|
20945
|
+
const overview = getFileOverview(sourceFile);
|
|
20946
|
+
const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
|
|
20947
|
+
const exports = getExportSummaries(moduleSymbol, sourceFile, checker);
|
|
20948
|
+
let relativePath = sourceFile.fileName;
|
|
20949
|
+
const cwd = process.cwd();
|
|
20950
|
+
if (relativePath.startsWith(cwd)) {
|
|
20951
|
+
relativePath = path4.relative(cwd, relativePath);
|
|
20952
|
+
}
|
|
20953
|
+
return {
|
|
20954
|
+
path: relativePath,
|
|
20955
|
+
overview,
|
|
20956
|
+
exportCount: exports.length,
|
|
20957
|
+
exports
|
|
20958
|
+
};
|
|
20959
|
+
}
|
|
20839
20960
|
let targetSymbol;
|
|
20840
20961
|
if (isGlobalModule) {
|
|
20841
20962
|
const actualSymbolName = module.startsWith("node:") ? module.slice(5) : module;
|
|
@@ -20856,9 +20977,11 @@ async function extractDocs(modulePath) {
|
|
|
20856
20977
|
const exports = checker.getExportsOfModule(moduleSymbol);
|
|
20857
20978
|
const exportSymbol = exports.find((exp) => exp.getName() === symbol);
|
|
20858
20979
|
if (exportSymbol) {
|
|
20859
|
-
if (exportSymbol.
|
|
20980
|
+
if (exportSymbol.flags & ts5.SymbolFlags.Alias) {
|
|
20981
|
+
targetSymbol = checker.getAliasedSymbol(exportSymbol);
|
|
20982
|
+
} else if (exportSymbol.valueDeclaration && (ts5.isFunctionDeclaration(exportSymbol.valueDeclaration) || ts5.isClassDeclaration(exportSymbol.valueDeclaration) || ts5.isVariableDeclaration(exportSymbol.valueDeclaration) || ts5.isEnumDeclaration(exportSymbol.valueDeclaration))) {
|
|
20860
20983
|
targetSymbol = exportSymbol;
|
|
20861
|
-
} else if (exportSymbol.flags & (ts5.SymbolFlags.Interface | ts5.SymbolFlags.TypeAlias)) {
|
|
20984
|
+
} else if (exportSymbol.flags & (ts5.SymbolFlags.Interface | ts5.SymbolFlags.TypeAlias | ts5.SymbolFlags.Enum)) {
|
|
20862
20985
|
targetSymbol = exportSymbol;
|
|
20863
20986
|
} else {
|
|
20864
20987
|
targetSymbol = findSymbolInJavaScriptFile(sourceFile, checker, symbol);
|
|
@@ -20899,6 +21022,15 @@ async function getSourceLocation(reference) {
|
|
|
20899
21022
|
};
|
|
20900
21023
|
}
|
|
20901
21024
|
const { module, symbol, member, isStatic } = parseResult;
|
|
21025
|
+
if (!symbol) {
|
|
21026
|
+
return {
|
|
21027
|
+
success: false,
|
|
21028
|
+
error: {
|
|
21029
|
+
code: "INVALID_SPECIFIER",
|
|
21030
|
+
message: "Symbol reference required for source location lookup"
|
|
21031
|
+
}
|
|
21032
|
+
};
|
|
21033
|
+
}
|
|
20902
21034
|
const config2 = loadTsConfig(options.prefix);
|
|
20903
21035
|
let resolvedModule = resolveModule(module, config2.options);
|
|
20904
21036
|
let isGlobalModule = false;
|
|
@@ -21019,6 +21151,7 @@ var init_resolution = __esm(() => {
|
|
|
21019
21151
|
init_core();
|
|
21020
21152
|
init_module_resolver();
|
|
21021
21153
|
init_symbol_finder();
|
|
21154
|
+
init_utils();
|
|
21022
21155
|
init_formatters();
|
|
21023
21156
|
});
|
|
21024
21157
|
|
|
@@ -21221,7 +21354,7 @@ async function handleGetDocs({ reference }) {
|
|
|
21221
21354
|
isError: true
|
|
21222
21355
|
};
|
|
21223
21356
|
}
|
|
21224
|
-
if (!docs.documentation) {
|
|
21357
|
+
if ("documentation" in docs && !docs.documentation) {
|
|
21225
21358
|
return {
|
|
21226
21359
|
content: [
|
|
21227
21360
|
{
|
|
@@ -21326,6 +21459,10 @@ var init_mcp2 = __esm(() => {
|
|
|
21326
21459
|
// src/http/handlers/mcp.ts
|
|
21327
21460
|
async function handleMcp(req, res, next) {
|
|
21328
21461
|
try {
|
|
21462
|
+
if (req.headers.origin) {
|
|
21463
|
+
originNotAllowed(res);
|
|
21464
|
+
return;
|
|
21465
|
+
}
|
|
21329
21466
|
if (req.method !== "POST") {
|
|
21330
21467
|
methodNotAllowed(res);
|
|
21331
21468
|
return;
|
|
@@ -21377,12 +21514,6 @@ function createHandleHtml(config) {
|
|
|
21377
21514
|
}
|
|
21378
21515
|
try {
|
|
21379
21516
|
const clientUrl = config.clientUrl || "https://tidewave.ai";
|
|
21380
|
-
const tidewaveConfig = {
|
|
21381
|
-
project_name: config.projectName || "app",
|
|
21382
|
-
framework_type: config.framework || "unknown",
|
|
21383
|
-
tidewave_version: package_default.version,
|
|
21384
|
-
team: config.team || {}
|
|
21385
|
-
};
|
|
21386
21517
|
res.statusCode = 200;
|
|
21387
21518
|
res.setHeader("Content-Type", "text/html");
|
|
21388
21519
|
res.end(`
|
|
@@ -21390,7 +21521,6 @@ function createHandleHtml(config) {
|
|
|
21390
21521
|
<head>
|
|
21391
21522
|
<meta charset="UTF-8" />
|
|
21392
21523
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
21393
|
-
<meta name="tidewave:config" content="${escapeHtml(JSON.stringify(tidewaveConfig))}" />
|
|
21394
21524
|
<script type="module" src="${clientUrl}/tc/tc.js"></script>
|
|
21395
21525
|
</head>
|
|
21396
21526
|
<body></body>
|
|
@@ -21407,32 +21537,21 @@ function createHandleHtml(config) {
|
|
|
21407
21537
|
}
|
|
21408
21538
|
};
|
|
21409
21539
|
}
|
|
21410
|
-
function escapeHtml(text) {
|
|
21411
|
-
const map2 = {
|
|
21412
|
-
"&": "&",
|
|
21413
|
-
"<": "<",
|
|
21414
|
-
">": ">",
|
|
21415
|
-
'"': """,
|
|
21416
|
-
"'": "'"
|
|
21417
|
-
};
|
|
21418
|
-
return text.replace(/[&<>"']/g, (match) => map2[match]);
|
|
21419
|
-
}
|
|
21420
|
-
var init_html = __esm(() => {
|
|
21421
|
-
init_package();
|
|
21422
|
-
});
|
|
21423
21540
|
|
|
21424
21541
|
// src/http/handlers/config.ts
|
|
21425
|
-
function createHandleConfig(config) {
|
|
21426
|
-
return async function handleConfig(
|
|
21542
|
+
function createHandleConfig(config, getLocalPort) {
|
|
21543
|
+
return async function handleConfig(req, res, next) {
|
|
21427
21544
|
try {
|
|
21428
21545
|
const tidewaveConfig = {
|
|
21429
21546
|
project_name: config.projectName || "app",
|
|
21430
21547
|
framework_type: config.framework || "unknown",
|
|
21431
21548
|
tidewave_version: package_default.version,
|
|
21432
|
-
team: config.team || {}
|
|
21549
|
+
team: config.team || {},
|
|
21550
|
+
local_port: getLocalPort?.(req)
|
|
21433
21551
|
};
|
|
21434
21552
|
res.statusCode = 200;
|
|
21435
21553
|
res.setHeader("Content-Type", "application/json");
|
|
21554
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
21436
21555
|
res.end(JSON.stringify(tidewaveConfig));
|
|
21437
21556
|
} catch (err) {
|
|
21438
21557
|
console.error(`[Tidewave] Failed to serve config: ${err}`);
|
|
@@ -31772,17 +31891,6 @@ var require_db = __commonJS((exports, module) => {
|
|
|
31772
31891
|
};
|
|
31773
31892
|
});
|
|
31774
31893
|
|
|
31775
|
-
// node_modules/mime-db/index.js
|
|
31776
|
-
var require_mime_db = __commonJS((exports, module) => {
|
|
31777
|
-
/*!
|
|
31778
|
-
* mime-db
|
|
31779
|
-
* Copyright(c) 2014 Jonathan Ong
|
|
31780
|
-
* Copyright(c) 2015-2022 Douglas Christopher Wilson
|
|
31781
|
-
* MIT Licensed
|
|
31782
|
-
*/
|
|
31783
|
-
module.exports = require_db();
|
|
31784
|
-
});
|
|
31785
|
-
|
|
31786
31894
|
// node_modules/mime-types/mimeScore.js
|
|
31787
31895
|
var require_mimeScore = __commonJS((exports, module) => {
|
|
31788
31896
|
var FACET_SCORES = {
|
|
@@ -31825,7 +31933,7 @@ var require_mime_types = __commonJS((exports) => {
|
|
|
31825
31933
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
31826
31934
|
* MIT Licensed
|
|
31827
31935
|
*/
|
|
31828
|
-
var db =
|
|
31936
|
+
var db = require_db();
|
|
31829
31937
|
var extname = __require("path").extname;
|
|
31830
31938
|
var mimeScore = require_mimeScore();
|
|
31831
31939
|
var EXTRACT_TYPE_REGEXP = /^\s*([^;\s]*)(?:;|\s|$)/;
|
|
@@ -33037,7 +33145,7 @@ var require_round = __commonJS((exports, module) => {
|
|
|
33037
33145
|
|
|
33038
33146
|
// node_modules/math-intrinsics/isNaN.js
|
|
33039
33147
|
var require_isNaN = __commonJS((exports, module) => {
|
|
33040
|
-
module.exports = Number.isNaN || function
|
|
33148
|
+
module.exports = Number.isNaN || function isNaN2(a) {
|
|
33041
33149
|
return a !== a;
|
|
33042
33150
|
};
|
|
33043
33151
|
});
|
|
@@ -33171,7 +33279,7 @@ var require_implementation = __commonJS((exports, module) => {
|
|
|
33171
33279
|
var toStr = Object.prototype.toString;
|
|
33172
33280
|
var max = Math.max;
|
|
33173
33281
|
var funcType = "[object Function]";
|
|
33174
|
-
var concatty = function
|
|
33282
|
+
var concatty = function concatty2(a, b) {
|
|
33175
33283
|
var arr = [];
|
|
33176
33284
|
for (var i = 0;i < a.length; i += 1) {
|
|
33177
33285
|
arr[i] = a[i];
|
|
@@ -33181,7 +33289,7 @@ var require_implementation = __commonJS((exports, module) => {
|
|
|
33181
33289
|
}
|
|
33182
33290
|
return arr;
|
|
33183
33291
|
};
|
|
33184
|
-
var slicy = function
|
|
33292
|
+
var slicy = function slicy2(arrLike, offset) {
|
|
33185
33293
|
var arr = [];
|
|
33186
33294
|
for (var i = offset || 0, j = 0;i < arrLike.length; i += 1, j += 1) {
|
|
33187
33295
|
arr[j] = arrLike[i];
|
|
@@ -33222,7 +33330,7 @@ var require_implementation = __commonJS((exports, module) => {
|
|
|
33222
33330
|
}
|
|
33223
33331
|
bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
|
|
33224
33332
|
if (target.prototype) {
|
|
33225
|
-
var Empty = function
|
|
33333
|
+
var Empty = function Empty2() {};
|
|
33226
33334
|
Empty.prototype = target.prototype;
|
|
33227
33335
|
bound.prototype = new Empty;
|
|
33228
33336
|
Empty.prototype = null;
|
|
@@ -33461,7 +33569,7 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
33461
33569
|
}
|
|
33462
33570
|
}
|
|
33463
33571
|
var errorProto;
|
|
33464
|
-
var doEval = function
|
|
33572
|
+
var doEval = function doEval2(name2) {
|
|
33465
33573
|
var value;
|
|
33466
33574
|
if (name2 === "%AsyncFunction%") {
|
|
33467
33575
|
value = getEvalledConstructor("async function () {}");
|
|
@@ -33470,12 +33578,12 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
33470
33578
|
} else if (name2 === "%AsyncGeneratorFunction%") {
|
|
33471
33579
|
value = getEvalledConstructor("async function* () {}");
|
|
33472
33580
|
} else if (name2 === "%AsyncGenerator%") {
|
|
33473
|
-
var fn =
|
|
33581
|
+
var fn = doEval2("%AsyncGeneratorFunction%");
|
|
33474
33582
|
if (fn) {
|
|
33475
33583
|
value = fn.prototype;
|
|
33476
33584
|
}
|
|
33477
33585
|
} else if (name2 === "%AsyncIteratorPrototype%") {
|
|
33478
|
-
var gen =
|
|
33586
|
+
var gen = doEval2("%AsyncGenerator%");
|
|
33479
33587
|
if (gen && getProto) {
|
|
33480
33588
|
value = getProto(gen.prototype);
|
|
33481
33589
|
}
|
|
@@ -33546,7 +33654,7 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
33546
33654
|
var $exec = bind.call($call, RegExp.prototype.exec);
|
|
33547
33655
|
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
33548
33656
|
var reEscapeChar = /\\(\\)?/g;
|
|
33549
|
-
var stringToPath = function
|
|
33657
|
+
var stringToPath = function stringToPath2(string2) {
|
|
33550
33658
|
var first = $strSlice(string2, 0, 1);
|
|
33551
33659
|
var last = $strSlice(string2, -1);
|
|
33552
33660
|
if (first === "%" && last !== "%") {
|
|
@@ -33560,7 +33668,7 @@ var require_get_intrinsic = __commonJS((exports, module) => {
|
|
|
33560
33668
|
});
|
|
33561
33669
|
return result;
|
|
33562
33670
|
};
|
|
33563
|
-
var getBaseIntrinsic = function
|
|
33671
|
+
var getBaseIntrinsic = function getBaseIntrinsic2(name2, allowMissing) {
|
|
33564
33672
|
var intrinsicName = name2;
|
|
33565
33673
|
var alias;
|
|
33566
33674
|
if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
|
|
@@ -33850,7 +33958,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
33850
33958
|
}
|
|
33851
33959
|
return array2;
|
|
33852
33960
|
}();
|
|
33853
|
-
var compactQueue = function
|
|
33961
|
+
var compactQueue = function compactQueue2(queue) {
|
|
33854
33962
|
while (queue.length > 1) {
|
|
33855
33963
|
var item = queue.pop();
|
|
33856
33964
|
var obj = item.obj[item.prop];
|
|
@@ -33865,7 +33973,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
33865
33973
|
}
|
|
33866
33974
|
}
|
|
33867
33975
|
};
|
|
33868
|
-
var arrayToObject = function
|
|
33976
|
+
var arrayToObject = function arrayToObject2(source, options) {
|
|
33869
33977
|
var obj = options && options.plainObjects ? { __proto__: null } : {};
|
|
33870
33978
|
for (var i = 0;i < source.length; ++i) {
|
|
33871
33979
|
if (typeof source[i] !== "undefined") {
|
|
@@ -33874,7 +33982,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
33874
33982
|
}
|
|
33875
33983
|
return obj;
|
|
33876
33984
|
};
|
|
33877
|
-
var merge = function
|
|
33985
|
+
var merge = function merge2(target, source, options) {
|
|
33878
33986
|
if (!source) {
|
|
33879
33987
|
return target;
|
|
33880
33988
|
}
|
|
@@ -33902,7 +34010,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
33902
34010
|
if (has.call(target, i)) {
|
|
33903
34011
|
var targetItem = target[i];
|
|
33904
34012
|
if (targetItem && typeof targetItem === "object" && item && typeof item === "object") {
|
|
33905
|
-
target[i] =
|
|
34013
|
+
target[i] = merge2(targetItem, item, options);
|
|
33906
34014
|
} else {
|
|
33907
34015
|
target.push(item);
|
|
33908
34016
|
}
|
|
@@ -33915,7 +34023,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
33915
34023
|
return Object.keys(source).reduce(function(acc, key) {
|
|
33916
34024
|
var value = source[key];
|
|
33917
34025
|
if (has.call(acc, key)) {
|
|
33918
|
-
acc[key] =
|
|
34026
|
+
acc[key] = merge2(acc[key], value, options);
|
|
33919
34027
|
} else {
|
|
33920
34028
|
acc[key] = value;
|
|
33921
34029
|
}
|
|
@@ -33940,7 +34048,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
33940
34048
|
}
|
|
33941
34049
|
};
|
|
33942
34050
|
var limit = 1024;
|
|
33943
|
-
var encode = function
|
|
34051
|
+
var encode = function encode2(str, defaultEncoder, charset, kind, format) {
|
|
33944
34052
|
if (str.length === 0) {
|
|
33945
34053
|
return str;
|
|
33946
34054
|
}
|
|
@@ -33985,7 +34093,7 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
33985
34093
|
}
|
|
33986
34094
|
return out;
|
|
33987
34095
|
};
|
|
33988
|
-
var compact = function
|
|
34096
|
+
var compact = function compact2(value) {
|
|
33989
34097
|
var queue = [{ obj: { o: value }, prop: "o" }];
|
|
33990
34098
|
var refs = [];
|
|
33991
34099
|
for (var i = 0;i < queue.length; ++i) {
|
|
@@ -34004,19 +34112,19 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
34004
34112
|
compactQueue(queue);
|
|
34005
34113
|
return value;
|
|
34006
34114
|
};
|
|
34007
|
-
var isRegExp = function
|
|
34115
|
+
var isRegExp = function isRegExp2(obj) {
|
|
34008
34116
|
return Object.prototype.toString.call(obj) === "[object RegExp]";
|
|
34009
34117
|
};
|
|
34010
|
-
var isBuffer = function
|
|
34118
|
+
var isBuffer = function isBuffer2(obj) {
|
|
34011
34119
|
if (!obj || typeof obj !== "object") {
|
|
34012
34120
|
return false;
|
|
34013
34121
|
}
|
|
34014
34122
|
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
34015
34123
|
};
|
|
34016
|
-
var combine = function
|
|
34124
|
+
var combine = function combine2(a, b) {
|
|
34017
34125
|
return [].concat(a, b);
|
|
34018
34126
|
};
|
|
34019
|
-
var maybeMap = function
|
|
34127
|
+
var maybeMap = function maybeMap2(val, fn) {
|
|
34020
34128
|
if (isArray(val)) {
|
|
34021
34129
|
var mapped = [];
|
|
34022
34130
|
for (var i = 0;i < val.length; i += 1) {
|
|
@@ -34088,11 +34196,11 @@ var require_stringify = __commonJS((exports, module) => {
|
|
|
34088
34196
|
skipNulls: false,
|
|
34089
34197
|
strictNullHandling: false
|
|
34090
34198
|
};
|
|
34091
|
-
var isNonNullishPrimitive = function
|
|
34199
|
+
var isNonNullishPrimitive = function isNonNullishPrimitive2(v) {
|
|
34092
34200
|
return typeof v === "string" || typeof v === "number" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "bigint";
|
|
34093
34201
|
};
|
|
34094
34202
|
var sentinel = {};
|
|
34095
|
-
var stringify = function
|
|
34203
|
+
var stringify = function stringify2(object2, prefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel) {
|
|
34096
34204
|
var obj = object2;
|
|
34097
34205
|
var tmpSc = sideChannel;
|
|
34098
34206
|
var step = 0;
|
|
@@ -34168,11 +34276,11 @@ var require_stringify = __commonJS((exports, module) => {
|
|
|
34168
34276
|
sideChannel.set(object2, step);
|
|
34169
34277
|
var valueSideChannel = getSideChannel();
|
|
34170
34278
|
valueSideChannel.set(sentinel, sideChannel);
|
|
34171
|
-
pushToArray(values,
|
|
34279
|
+
pushToArray(values, stringify2(value, keyPrefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, generateArrayPrefix === "comma" && encodeValuesOnly && isArray(obj) ? null : encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, valueSideChannel));
|
|
34172
34280
|
}
|
|
34173
34281
|
return values;
|
|
34174
34282
|
};
|
|
34175
|
-
var normalizeStringifyOptions = function
|
|
34283
|
+
var normalizeStringifyOptions = function normalizeStringifyOptions2(opts) {
|
|
34176
34284
|
if (!opts) {
|
|
34177
34285
|
return defaults;
|
|
34178
34286
|
}
|
|
@@ -34449,7 +34557,7 @@ var require_parse = __commonJS((exports, module) => {
|
|
|
34449
34557
|
}
|
|
34450
34558
|
return parseObject(keys, val, options, valuesParsed);
|
|
34451
34559
|
};
|
|
34452
|
-
var normalizeParseOptions = function
|
|
34560
|
+
var normalizeParseOptions = function normalizeParseOptions2(opts) {
|
|
34453
34561
|
if (!opts) {
|
|
34454
34562
|
return defaults;
|
|
34455
34563
|
}
|
|
@@ -34682,40 +34790,34 @@ var require_body_parser = __commonJS((exports, module) => {
|
|
|
34682
34790
|
// src/http/index.ts
|
|
34683
34791
|
var exports_http = {};
|
|
34684
34792
|
__export(exports_http, {
|
|
34685
|
-
|
|
34793
|
+
originNotAllowed: () => originNotAllowed,
|
|
34686
34794
|
methodNotAllowed: () => methodNotAllowed,
|
|
34687
34795
|
getHandlers: () => getHandlers,
|
|
34688
34796
|
configureServer: () => configureServer,
|
|
34689
34797
|
checkSecurity: () => checkSecurity,
|
|
34690
34798
|
ENDPOINT: () => ENDPOINT
|
|
34691
34799
|
});
|
|
34692
|
-
|
|
34693
|
-
function getHandlers(config) {
|
|
34800
|
+
function getHandlers(config, options = {}) {
|
|
34694
34801
|
return {
|
|
34695
34802
|
"": createHandleHtml(config),
|
|
34696
|
-
config: createHandleConfig(config),
|
|
34803
|
+
config: createHandleConfig(config, options.getLocalPort),
|
|
34697
34804
|
mcp: handleMcp
|
|
34698
34805
|
};
|
|
34699
34806
|
}
|
|
34700
|
-
function configureServer(server = import_connect.default(), config = DEFAULT_OPTIONS) {
|
|
34807
|
+
function configureServer(server = import_connect.default(), config = DEFAULT_OPTIONS, options = {}) {
|
|
34701
34808
|
const securityChecker = checkSecurity(config);
|
|
34702
34809
|
server.use(`${ENDPOINT}`, securityChecker);
|
|
34703
34810
|
server.use(`${ENDPOINT}`, import_body_parser.default.json());
|
|
34704
|
-
const handlers = getHandlers(config);
|
|
34811
|
+
const handlers = getHandlers(config, options);
|
|
34705
34812
|
for (const [path6, handler] of Object.entries(handlers)) {
|
|
34706
34813
|
server.use(ENDPOINT + "/" + path6, handler);
|
|
34707
34814
|
}
|
|
34708
34815
|
return server;
|
|
34709
34816
|
}
|
|
34710
|
-
function serve(server, config = DEFAULT_OPTIONS) {
|
|
34711
|
-
http.createServer(server).listen(config.port || DEFAULT_PORT);
|
|
34712
|
-
}
|
|
34713
34817
|
function checkSecurity(config) {
|
|
34714
34818
|
return (req, res, next) => {
|
|
34715
34819
|
if (!checkRemoteIp(req, res, config))
|
|
34716
34820
|
return;
|
|
34717
|
-
if (!checkOrigin(req, res, config))
|
|
34718
|
-
return;
|
|
34719
34821
|
next();
|
|
34720
34822
|
};
|
|
34721
34823
|
}
|
|
@@ -34723,20 +34825,21 @@ function methodNotAllowed(res) {
|
|
|
34723
34825
|
res.statusCode = 405;
|
|
34724
34826
|
res.setHeader("Allow", "POST");
|
|
34725
34827
|
res.end();
|
|
34726
|
-
return;
|
|
34727
34828
|
}
|
|
34728
|
-
|
|
34829
|
+
function originNotAllowed(res) {
|
|
34830
|
+
const message = "For security reasons, Tidewave does not accept requests with an origin header for this endpoint.";
|
|
34831
|
+
console.warn(message);
|
|
34832
|
+
res.statusCode = 403;
|
|
34833
|
+
res.end(message);
|
|
34834
|
+
}
|
|
34835
|
+
var import_connect, import_body_parser, ENDPOINT = "/tidewave", DEFAULT_OPTIONS;
|
|
34729
34836
|
var init_http = __esm(() => {
|
|
34730
|
-
import_connect = __toESM(require_connect(), 1);
|
|
34731
34837
|
init_mcp3();
|
|
34732
|
-
init_html();
|
|
34733
34838
|
init_config();
|
|
34839
|
+
import_connect = __toESM(require_connect(), 1);
|
|
34734
34840
|
import_body_parser = __toESM(require_body_parser(), 1);
|
|
34735
34841
|
DEFAULT_OPTIONS = {
|
|
34736
|
-
allowRemoteAccess: false
|
|
34737
|
-
allowedOrigins: [],
|
|
34738
|
-
port: 5001,
|
|
34739
|
-
host: "localhost"
|
|
34842
|
+
allowRemoteAccess: false
|
|
34740
34843
|
};
|
|
34741
34844
|
});
|
|
34742
34845
|
|
|
@@ -34808,14 +34911,23 @@ var init_console_patch = __esm(() => {
|
|
|
34808
34911
|
|
|
34809
34912
|
// src/next-js/handler.ts
|
|
34810
34913
|
init_http();
|
|
34811
|
-
var import_body_parser2 = __toESM(require_body_parser(), 1);
|
|
34812
34914
|
init_core();
|
|
34915
|
+
var import_body_parser2 = __toESM(require_body_parser(), 1);
|
|
34813
34916
|
var DEFAULT_CONFIG = {};
|
|
34814
34917
|
function connectWrapper(fn) {
|
|
34815
34918
|
return (req, res, next) => new Promise((resolve, reject) => {
|
|
34816
34919
|
fn(req, res, (err) => err ? reject(err) : resolve());
|
|
34817
34920
|
}).then(next);
|
|
34818
34921
|
}
|
|
34922
|
+
function isAddressInfo(address) {
|
|
34923
|
+
return typeof address === "object" && address !== null && "port" in address;
|
|
34924
|
+
}
|
|
34925
|
+
function getRequestLocalPort(request) {
|
|
34926
|
+
const address = request.socket.address();
|
|
34927
|
+
if (isAddressInfo(address))
|
|
34928
|
+
return address.port;
|
|
34929
|
+
return request.socket.localPort;
|
|
34930
|
+
}
|
|
34819
34931
|
async function tidewaveHandler(config = DEFAULT_CONFIG) {
|
|
34820
34932
|
const env = process.env["NODE_ENV"];
|
|
34821
34933
|
if (!(env === "development")) {
|
|
@@ -34835,23 +34947,21 @@ async function tidewaveHandler(config = DEFAULT_CONFIG) {
|
|
|
34835
34947
|
if (!url.pathname.startsWith("/tidewave")) {
|
|
34836
34948
|
return res.status(404).json({ message: "This route only works when accessed at /tidewave" });
|
|
34837
34949
|
}
|
|
34838
|
-
if (origin) {
|
|
34839
|
-
const [hostname, port] = origin.split(":");
|
|
34840
|
-
config.host = hostname ? hostname : config.host;
|
|
34841
|
-
config.port = port ? Number(port) : config.port;
|
|
34842
|
-
}
|
|
34843
34950
|
const next = () => {};
|
|
34844
34951
|
const securityMiddleware = checkSecurity(config);
|
|
34845
34952
|
await connectWrapper(securityMiddleware)(req, res, next);
|
|
34846
34953
|
await connectWrapper(import_body_parser2.default.json())(req, res, next);
|
|
34847
34954
|
const { getHandlers: getHandlers2 } = await Promise.resolve().then(() => (init_http(), exports_http));
|
|
34848
|
-
const handlers = getHandlers2(config
|
|
34849
|
-
|
|
34850
|
-
|
|
34851
|
-
|
|
34955
|
+
const handlers = getHandlers2(config, {
|
|
34956
|
+
getLocalPort: getRequestLocalPort
|
|
34957
|
+
});
|
|
34958
|
+
const handler2 = handlers[endpoint || ""];
|
|
34959
|
+
if (handler2)
|
|
34960
|
+
return await connectWrapper(handler2)(req, res, next);
|
|
34852
34961
|
return res.status(404).json({ message: `Route not found: ${req.method} ${req.url}` });
|
|
34853
34962
|
};
|
|
34854
34963
|
}
|
|
34855
34964
|
export {
|
|
34856
|
-
tidewaveHandler
|
|
34965
|
+
tidewaveHandler,
|
|
34966
|
+
getRequestLocalPort
|
|
34857
34967
|
};
|