fix: add explicit .js extensions to relative imports so declarations resolve under NodeNext/Node16
The emitted .d.ts copy relative specifiers verbatim, and the extensionless form (e.g. `from "./events"`) doesn't resolve under Node16/NodeNext, hiding inherited members such as `addEventListener` (TS2339). Appending `.js` matches the existing SDK-import style and works with both bundler-mode type-checking and Bun.build. Types-only; runtime is unaffected. Fixes #704
This commit is contained in:
parent
1a713173cc
commit
264d9cae44
12 changed files with 35 additions and 35 deletions
|
|
@ -3,8 +3,8 @@ import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
|
||||||
import { Server, type ServerCapabilities } from "@modelcontextprotocol/server";
|
import { Server, type ServerCapabilities } from "@modelcontextprotocol/server";
|
||||||
import { z } from "zod/v4";
|
import { z } from "zod/v4";
|
||||||
|
|
||||||
import { App } from "./app";
|
import { App } from "./app.js";
|
||||||
import { LATEST_PROTOCOL_VERSION } from "./types";
|
import { LATEST_PROTOCOL_VERSION } from "./types.js";
|
||||||
import {
|
import {
|
||||||
AppBridge,
|
AppBridge,
|
||||||
buildAllowAttribute,
|
buildAllowAttribute,
|
||||||
|
|
@ -13,7 +13,7 @@ import {
|
||||||
isToolVisibilityAppOnly,
|
isToolVisibilityAppOnly,
|
||||||
McpUiOpenLinkResultSchema,
|
McpUiOpenLinkResultSchema,
|
||||||
type McpUiHostCapabilities,
|
type McpUiHostCapabilities,
|
||||||
} from "./app-bridge";
|
} from "./app-bridge.js";
|
||||||
|
|
||||||
/** Wait for pending microtasks to complete */
|
/** Wait for pending microtasks to complete */
|
||||||
const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
|
const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ import {
|
||||||
EmptyResultSchema,
|
EmptyResultSchema,
|
||||||
LoggingMessageNotificationSchema,
|
LoggingMessageNotificationSchema,
|
||||||
} from "@modelcontextprotocol/core";
|
} from "@modelcontextprotocol/core";
|
||||||
import { EventDispatcher } from "./events";
|
import { EventDispatcher } from "./events.js";
|
||||||
import type { ZodLiteral, ZodObject, ZodType } from "zod/v4";
|
import type { ZodLiteral, ZodObject, ZodType } from "zod/v4";
|
||||||
|
|
||||||
type MethodSchema = ZodObject<{
|
type MethodSchema = ZodObject<{
|
||||||
|
|
@ -87,11 +87,11 @@ import {
|
||||||
McpUiRequestDisplayModeResultSchema,
|
McpUiRequestDisplayModeResultSchema,
|
||||||
McpUiResourcePermissions,
|
McpUiResourcePermissions,
|
||||||
McpUiToolMeta,
|
McpUiToolMeta,
|
||||||
} from "./types";
|
} from "./types.js";
|
||||||
export * from "./types";
|
export * from "./types.js";
|
||||||
export { RESOURCE_URI_META_KEY, RESOURCE_MIME_TYPE } from "./constants";
|
export { RESOURCE_URI_META_KEY, RESOURCE_MIME_TYPE } from "./constants.js";
|
||||||
import { RESOURCE_URI_META_KEY } from "./constants";
|
import { RESOURCE_URI_META_KEY } from "./constants.js";
|
||||||
export { PostMessageTransport } from "./message-transport";
|
export { PostMessageTransport } from "./message-transport.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract UI resource URI from tool metadata.
|
* Extract UI resource URI from tool metadata.
|
||||||
|
|
|
||||||
20
src/app.ts
20
src/app.ts
|
|
@ -22,10 +22,10 @@ import {
|
||||||
type Transport,
|
type Transport,
|
||||||
} from "@modelcontextprotocol/client";
|
} from "@modelcontextprotocol/client";
|
||||||
import { EmptyResultSchema } from "@modelcontextprotocol/core";
|
import { EmptyResultSchema } from "@modelcontextprotocol/core";
|
||||||
export { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "./constants";
|
export { RESOURCE_MIME_TYPE, RESOURCE_URI_META_KEY } from "./constants.js";
|
||||||
import { EventDispatcher } from "./events";
|
import { EventDispatcher } from "./events.js";
|
||||||
export { EventDispatcher } from "./events";
|
export { EventDispatcher } from "./events.js";
|
||||||
import { PostMessageTransport } from "./message-transport";
|
import { PostMessageTransport } from "./message-transport.js";
|
||||||
import {
|
import {
|
||||||
LATEST_PROTOCOL_VERSION,
|
LATEST_PROTOCOL_VERSION,
|
||||||
McpUiAppCapabilities,
|
McpUiAppCapabilities,
|
||||||
|
|
@ -59,12 +59,12 @@ import {
|
||||||
McpUiToolResultNotificationSchema,
|
McpUiToolResultNotificationSchema,
|
||||||
McpUiRequestDisplayModeRequest,
|
McpUiRequestDisplayModeRequest,
|
||||||
McpUiRequestDisplayModeResultSchema,
|
McpUiRequestDisplayModeResultSchema,
|
||||||
} from "./types";
|
} from "./types.js";
|
||||||
import {
|
import {
|
||||||
StandardSchemaV1,
|
StandardSchemaV1,
|
||||||
standardSchemaToJsonSchema,
|
standardSchemaToJsonSchema,
|
||||||
validateStandardSchema,
|
validateStandardSchema,
|
||||||
} from "./standard-schema";
|
} from "./standard-schema.js";
|
||||||
import { z, type ZodLiteral, type ZodObject, type ZodType } from "zod/v4";
|
import { z, type ZodLiteral, type ZodObject, type ZodType } from "zod/v4";
|
||||||
|
|
||||||
type MethodSchema = ZodObject<{
|
type MethodSchema = ZodObject<{
|
||||||
|
|
@ -92,16 +92,16 @@ function mergeAppCapabilities(
|
||||||
export type {
|
export type {
|
||||||
StandardSchemaV1,
|
StandardSchemaV1,
|
||||||
StandardSchemaWithJSON,
|
StandardSchemaWithJSON,
|
||||||
} from "./standard-schema";
|
} from "./standard-schema.js";
|
||||||
|
|
||||||
export { PostMessageTransport } from "./message-transport";
|
export { PostMessageTransport } from "./message-transport.js";
|
||||||
export * from "./types";
|
export * from "./types.js";
|
||||||
export {
|
export {
|
||||||
applyHostStyleVariables,
|
applyHostStyleVariables,
|
||||||
applyHostFonts,
|
applyHostFonts,
|
||||||
getDocumentTheme,
|
getDocumentTheme,
|
||||||
applyDocumentTheme,
|
applyDocumentTheme,
|
||||||
} from "./styles";
|
} from "./styles.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata key for associating a UI resource URI with a tool.
|
* Metadata key for associating a UI resource URI with a tool.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { describe, it, expect, beforeEach, afterEach, mock } from "bun:test";
|
import { describe, it, expect, beforeEach, afterEach, mock } from "bun:test";
|
||||||
import type { JSONRPCMessage } from "@modelcontextprotocol/client";
|
import type { JSONRPCMessage } from "@modelcontextprotocol/client";
|
||||||
|
|
||||||
import { PostMessageTransport } from "./message-transport";
|
import { PostMessageTransport } from "./message-transport.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimal `window` stub for bun's DOM-less test environment.
|
* Minimal `window` stub for bun's DOM-less test environment.
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import type {
|
||||||
Transport,
|
Transport,
|
||||||
TransportSendOptions,
|
TransportSendOptions,
|
||||||
} from "@modelcontextprotocol/client";
|
} from "@modelcontextprotocol/client";
|
||||||
import { TOOL_INPUT_PARTIAL_METHOD } from "./spec.types";
|
import { TOOL_INPUT_PARTIAL_METHOD } from "./spec.types.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSON-RPC transport using `window.postMessage` for iframe↔parent communication.
|
* JSON-RPC transport using `window.postMessage` for iframe↔parent communication.
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export * from "./useApp";
|
export * from "./useApp.js";
|
||||||
export * from "./useAutoResize";
|
export * from "./useAutoResize.js";
|
||||||
export * from "./useDocumentTheme";
|
export * from "./useDocumentTheme.js";
|
||||||
export * from "./useHostStyles";
|
export * from "./useHostStyles.js";
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import {
|
||||||
AppOptions,
|
AppOptions,
|
||||||
McpUiAppCapabilities,
|
McpUiAppCapabilities,
|
||||||
PostMessageTransport,
|
PostMessageTransport,
|
||||||
} from "../app";
|
} from "../app.js";
|
||||||
export * from "../app";
|
export * from "../app.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options for configuring the {@link useApp `useApp`} hook.
|
* Options for configuring the {@link useApp `useApp`} hook.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { useEffect, RefObject } from "react";
|
import { useEffect, RefObject } from "react";
|
||||||
import { App } from "../app";
|
import { App } from "../app.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* React hook that automatically reports UI size changes to the host.
|
* React hook that automatically reports UI size changes to the host.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { getDocumentTheme } from "../styles";
|
import { getDocumentTheme } from "../styles.js";
|
||||||
import { McpUiTheme } from "../types";
|
import { McpUiTheme } from "../types.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* React hook that provides the current document theme reactively.
|
* React hook that provides the current document theme reactively.
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import { App } from "../app";
|
import { App } from "../app.js";
|
||||||
import {
|
import {
|
||||||
applyDocumentTheme,
|
applyDocumentTheme,
|
||||||
applyHostFonts,
|
applyHostFonts,
|
||||||
applyHostStyleVariables,
|
applyHostStyleVariables,
|
||||||
} from "../styles";
|
} from "../styles.js";
|
||||||
import { McpUiHostContext } from "../types";
|
import { McpUiHostContext } from "../types.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* React hook that applies host style variables and theme as CSS custom properties.
|
* React hook that applies host style variables and theme as CSS custom properties.
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import {
|
||||||
RESOURCE_MIME_TYPE,
|
RESOURCE_MIME_TYPE,
|
||||||
getUiCapability,
|
getUiCapability,
|
||||||
EXTENSION_ID,
|
EXTENSION_ID,
|
||||||
} from "./index";
|
} from "./index.js";
|
||||||
import type { McpServer } from "@modelcontextprotocol/server";
|
import type { McpServer } from "@modelcontextprotocol/server";
|
||||||
|
|
||||||
describe("registerAppTool", () => {
|
describe("registerAppTool", () => {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { McpUiStyles, McpUiTheme } from "./types";
|
import { McpUiStyles, McpUiTheme } from "./types.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current document theme from the root HTML element.
|
* Get the current document theme from the root HTML element.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue