tidewave 0.2.4 → 0.3.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,3 +1,3 @@
1
- import { type TidewaveConfig } from './http';
1
+ import type { TidewaveConfig } from './core';
2
2
  import type { Plugin } from 'vite';
3
3
  export default function tidewave(config?: TidewaveConfig): Plugin;
@@ -6194,7 +6194,7 @@ var require_ajv = __commonJS((exports, module) => {
6194
6194
  function noop() {}
6195
6195
  });
6196
6196
 
6197
- // node_modules/connect/node_modules/debug/node_modules/ms/index.js
6197
+ // node_modules/connect/node_modules/ms/index.js
6198
6198
  var require_ms = __commonJS((exports, module) => {
6199
6199
  var s = 1000;
6200
6200
  var m = s * 60;
@@ -30078,13 +30078,36 @@ async function extractSymbol(request, options = {}) {
30078
30078
  };
30079
30079
  }
30080
30080
  }
30081
+ // src/evaluation/eval_worker.ts
30082
+ process.on("message", async ({ code, args }) => {
30083
+ if (!process.send) {
30084
+ console.error("[Tidewave] Unable to establish communication channel with code-executor.");
30085
+ process.exit(1);
30086
+ }
30087
+ try {
30088
+ const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;
30089
+ const fn = new AsyncFunction(code);
30090
+ const result = await fn(...args);
30091
+ process.send({
30092
+ type: "result",
30093
+ success: true,
30094
+ data: (result || null) && result
30095
+ });
30096
+ } catch (error) {
30097
+ process.send({
30098
+ type: "result",
30099
+ success: false,
30100
+ data: new String(error)
30101
+ });
30102
+ }
30103
+ process.exit(0);
30104
+ });
30105
+
30081
30106
  // src/evaluation/code_executor.ts
30082
30107
  import { fork } from "child_process";
30083
- import { join } from "path";
30084
- var __dirname = "/Users/zoedsoupe/dev/dashbit/tidewave_javascript/src/evaluation";
30085
30108
  async function executeIsolated(request) {
30086
30109
  return new Promise((resolve) => {
30087
- const workerPath = join(__dirname, "eval_worker.ts");
30110
+ const workerPath = __require.resolve("./eval_worker");
30088
30111
  const child = fork(workerPath, { silent: true });
30089
30112
  const evaluation = {
30090
30113
  success: false,
@@ -33056,7 +33079,7 @@ var EMPTY_COMPLETION_RESULT = {
33056
33079
 
33057
33080
  // package.json
33058
33081
  var name = "tidewave";
33059
- var version = "0.2.3";
33082
+ var version = "0.3.0";
33060
33083
 
33061
33084
  // src/mcp.ts
33062
33085
  var {
@@ -33172,9 +33195,21 @@ async function serveMcp(transport) {
33172
33195
  }
33173
33196
 
33174
33197
  // src/http/security.ts
33198
+ function fetchRemoteIp(req) {
33199
+ const remote = req.socket.remoteAddress;
33200
+ if (remote)
33201
+ return remote;
33202
+ const ip = req.headers["x-real-ip"] && req.headers["x-forwarded-for"] || null;
33203
+ if (Array.isArray(ip)) {
33204
+ return ip.join();
33205
+ }
33206
+ return ip;
33207
+ }
33175
33208
  function checkRemoteIp(req, res, config) {
33176
- const { remoteAddress } = req.socket;
33177
- if (isLocalIp(remoteAddress))
33209
+ const ip = fetchRemoteIp(req);
33210
+ if (!ip)
33211
+ return false;
33212
+ if (isLocalIp(ip))
33178
33213
  return true;
33179
33214
  if (config.allowRemoteAccess)
33180
33215
  return true;
@@ -33730,7 +33765,6 @@ async function handleMcp(req, res, next) {
33730
33765
  methodNotAllowed(res);
33731
33766
  return;
33732
33767
  }
33733
- console.debug(`[Tidewave] Received ${req.method} message`);
33734
33768
  const transport = new StreamableHTTPServerTransport({
33735
33769
  sessionIdGenerator: undefined,
33736
33770
  enableJsonResponse: true
@@ -33888,12 +33922,17 @@ var DEFAULT_OPTIONS = {
33888
33922
  port: 5001,
33889
33923
  host: "localhost"
33890
33924
  };
33925
+ var HANDLERS = {
33926
+ mcp: handleMcp,
33927
+ shell: handleShell
33928
+ };
33891
33929
  function configureServer(server = import_connect.default(), config = DEFAULT_OPTIONS) {
33892
33930
  const securityChecker = checkSecurity(config);
33893
33931
  server.use(`${ENDPOINT}`, securityChecker);
33894
33932
  server.use(`${ENDPOINT}`, import_body_parser.default.json());
33895
- server.use(`${ENDPOINT}/mcp`, handleMcp);
33896
- server.use(`${ENDPOINT}/shell`, handleShell);
33933
+ for (const [path4, handler] of Object.entries(HANDLERS)) {
33934
+ server.use(ENDPOINT + "/" + path4, handler);
33935
+ }
33897
33936
  return server;
33898
33937
  }
33899
33938
  function serve(server, config = DEFAULT_OPTIONS) {
@@ -33916,13 +33955,18 @@ function methodNotAllowed(res) {
33916
33955
  }
33917
33956
 
33918
33957
  // src/vite-plugin.ts
33958
+ var DEFAULT_CONFIG = {
33959
+ port: 5173,
33960
+ host: "localhost",
33961
+ allowRemoteAccess: false
33962
+ };
33919
33963
  function tidewave(config = { port: 5173, host: "localhost" }) {
33920
33964
  return {
33921
33965
  name: "vite-plugin-tidewave",
33922
33966
  configureServer: (server) => tidewaveServer(server, config)
33923
33967
  };
33924
33968
  }
33925
- function tidewaveServer(server, config) {
33969
+ async function tidewaveServer(server, config = DEFAULT_CONFIG) {
33926
33970
  const { config: serverConfig } = server;
33927
33971
  const { host, port } = serverConfig.server;
33928
33972
  if (port) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tidewave",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "description": "Tidewave JavaScript CLI for documentation extraction and MCP server",
5
5
  "keywords": [
6
6
  "typescript",
@@ -26,11 +26,18 @@
26
26
  "exports": {
27
27
  ".": {
28
28
  "types": "./dist/index.d.ts",
29
- "import": "./dist/index.js"
29
+ "import": "./dist/index.js",
30
+ "require": "./dist/index.js"
30
31
  },
31
32
  "./vite-plugin": {
32
33
  "types": "./dist/vite-plugin.d.ts",
33
- "import": "./dist/vite-plugin.js"
34
+ "import": "./dist/vite-plugin.js",
35
+ "require": "./dist/vite-plugin.js"
36
+ },
37
+ "./next-js": {
38
+ "types": "./dist/next-js.d.ts",
39
+ "import": "./dist/next-js.js",
40
+ "require": "./dist/next-js.js"
34
41
  }
35
42
  },
36
43
  "files": [
@@ -73,6 +80,7 @@
73
80
  "bun-types": "latest",
74
81
  "eslint": "^9.16.0",
75
82
  "globals": "^15.14.0",
83
+ "next": "^15.5.3",
76
84
  "prettier": "^3.4.2",
77
85
  "vite": "^7.1.5",
78
86
  "vitest": "^3.2.4"