Skip to content

Commit 10d1d42

Browse files
committed
Move middleware typing to middleware package
1 parent 6e33a6e commit 10d1d42

12 files changed

Lines changed: 36 additions & 15 deletions

packages/api/src/hooks/Composer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import {
3232
type OneOrMany,
3333
type WebChatActivity
3434
} from 'botframework-webchat-core';
35+
import { type ActivityMiddleware, type AttachmentMiddleware } from 'botframework-webchat-middleware/legacy';
36+
import { ReduxStoreComposer } from 'botframework-webchat-redux-store';
3537
import PropTypes from 'prop-types';
3638
import React, { useCallback, useEffect, useMemo, useRef, useState, type ComponentType, type ReactNode } from 'react';
3739
import { Provider } from 'react-redux';
@@ -54,10 +56,8 @@ import ActivitySendStatusComposer from '../providers/ActivitySendStatus/Activity
5456
import ActivitySendStatusTelemetryComposer from '../providers/ActivitySendStatusTelemetry/ActivitySendStatusTelemetryComposer';
5557
import ActivityTypingComposer from '../providers/ActivityTyping/ActivityTypingComposer';
5658
import PonyfillComposer from '../providers/Ponyfill/PonyfillComposer';
57-
import ActivityMiddleware from '../types/ActivityMiddleware';
5859
import { type ActivityStatusMiddleware, type RenderActivityStatus } from '../types/ActivityStatusMiddleware';
5960
import AttachmentForScreenReaderMiddleware from '../types/AttachmentForScreenReaderMiddleware';
60-
import AttachmentMiddleware from '../types/AttachmentMiddleware';
6161
import AvatarMiddleware from '../types/AvatarMiddleware';
6262
import CardActionMiddleware from '../types/CardActionMiddleware';
6363
import { type ContextOf } from '../types/ContextOf';

packages/api/src/hooks/internal/WebChatAPIContext.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import {
66
type sendMessage,
77
type setSendBoxAttachments
88
} from 'botframework-webchat-core';
9+
import { type LegacyActivityRenderer, type RenderAttachment } from 'botframework-webchat-middleware/legacy';
910
import { createContext, type ComponentType } from 'react';
1011

1112
import { StrictStyleOptions } from '../../StyleOptions';
12-
import { LegacyActivityRenderer } from '../../types/ActivityMiddleware';
1313
import { RenderActivityStatus } from '../../types/ActivityStatusMiddleware';
1414
import { AttachmentForScreenReaderComponentFactory } from '../../types/AttachmentForScreenReaderMiddleware';
15-
import { RenderAttachment } from '../../types/AttachmentMiddleware';
1615
import { AvatarComponentFactory } from '../../types/AvatarMiddleware';
1716
import { PerformCardAction } from '../../types/CardActionMiddleware';
1817
import { GroupActivities } from '../../types/GroupActivitiesMiddleware';

packages/api/src/hooks/internal/useCreateActivityRendererInternal.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { isValidElement, useMemo } from 'react';
2+
import { type ActivityComponentFactory, type RenderAttachment } from 'botframework-webchat-middleware/legacy';
23

3-
import { ActivityComponentFactory } from '../../types/ActivityMiddleware';
4-
import { RenderAttachment } from '../../types/AttachmentMiddleware';
54
import useRenderAttachment from '../useRenderAttachment';
65
import useWebChatAPIContext from './useWebChatAPIContext';
76

packages/api/src/hooks/useCreateActivityRenderer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ActivityComponentFactory } from '../types/ActivityMiddleware';
1+
import { type ActivityComponentFactory } from 'botframework-webchat-middleware/legacy';
22
import useCreateActivityRendererInternal from './internal/useCreateActivityRendererInternal';
33

44
// The newer useCreateActivityRenderer() hook does not support override renderAttachment().

packages/api/src/hooks/useRenderAttachment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type RenderAttachment } from '../types/AttachmentMiddleware';
1+
import { type RenderAttachment } from 'botframework-webchat-middleware/legacy';
22
import useWebChatAPIContext from './internal/useWebChatAPIContext';
33

44
export default function useRenderAttachment(): RenderAttachment | undefined {

packages/api/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
// TODO: Move the pattern to re-export.
2+
import {
3+
type ActivityComponentFactory,
4+
type ActivityMiddleware,
5+
type AttachmentMiddleware,
6+
type RenderAttachment
7+
} from 'botframework-webchat-middleware/legacy';
28
import StyleOptions, { StrictStyleOptions } from './StyleOptions';
39
import defaultStyleOptions from './defaultStyleOptions';
410
import Composer, { ComposerProps } from './hooks/Composer';
@@ -9,12 +15,10 @@ import { type DebouncedNotification, type DebouncedNotifications } from './hooks
915
import { type PostActivityFile } from './hooks/useSendFiles';
1016
import { localize } from './localization/Localize';
1117
import normalizeStyleOptions from './normalizeStyleOptions';
12-
import ActivityMiddleware, { type ActivityComponentFactory } from './types/ActivityMiddleware';
1318
import { type ActivityStatusMiddleware, type RenderActivityStatus } from './types/ActivityStatusMiddleware';
1419
import AttachmentForScreenReaderMiddleware, {
1520
AttachmentForScreenReaderComponentFactory
1621
} from './types/AttachmentForScreenReaderMiddleware';
17-
import AttachmentMiddleware, { type RenderAttachment } from './types/AttachmentMiddleware';
1822
import AvatarMiddleware, { type AvatarComponentFactory } from './types/AvatarMiddleware';
1923
import CardActionMiddleware, { type PerformCardAction } from './types/CardActionMiddleware';
2024
import { type ContextOf } from './types/ContextOf';

packages/middleware/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
"main": "./dist/botframework-webchat-middleware.js",
66
"types": "./dist/botframework-webchat-middleware.d.ts",
77
"exports": {
8+
"./legacy": {
9+
"import": {
10+
"types": "./dist/botframework-webchat-middleware.legacy.d.mts",
11+
"default": "./dist/botframework-webchat-middleware.legacy.mjs"
12+
},
13+
"require": {
14+
"types": "./dist/botframework-webchat-middleware.legacy.d.ts",
15+
"default": "./dist/botframework-webchat-middleware.legacy.js"
16+
}
17+
},
818
".": {
919
"import": {
1020
"types": "./dist/botframework-webchat-middleware.d.mts",

packages/middleware/src/internal/createActivityPolyMiddlewareFromLegacy.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import { type ActivityMiddleware, type RenderAttachment } from 'botframework-webchat-api';
21
import { type WebChatActivity } from 'botframework-webchat-core';
32
import { composeEnhancer } from 'handler-chain';
43
import React, { type ComponentType, type ReactNode } from 'react';
4+
import type ActivityMiddleware from '../legacy/activityMiddleware';
5+
import { type RenderAttachment } from '../legacy/attachmentMiddleware';
56

67
import { custom, function_, never, object, optional, pipe, readonly, safeParse, type InferInput } from 'valibot';
78
import {

packages/middleware/src/legacy.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export {
2+
type ActivityComponentFactory,
3+
type default as ActivityMiddleware,
4+
type LegacyActivityRenderer
5+
} from './legacy/activityMiddleware';
6+
export { type default as AttachmentMiddleware, type RenderAttachment } from './legacy/attachmentMiddleware';

packages/api/src/types/ActivityMiddleware.ts renamed to packages/middleware/src/legacy/activityMiddleware.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
// TODO: Move this to botframework-webchat-middleware.
1+
// TODO: This is moved from /api, need to revisit/rewrite everything in this file.
22
import { type WebChatActivity } from 'botframework-webchat-core';
33
import { type ReactNode } from 'react';
44

5-
import { type RenderAttachment } from './AttachmentMiddleware';
5+
import { type RenderAttachment } from './attachmentMiddleware';
66

77
type ActivityProps = {
88
hideTimestamp: boolean;

0 commit comments

Comments
 (0)