Skip to content

Commit 21a4ec1

Browse files
OEvgenycompulim
andauthored
Add base package (#5176)
* Add base package * Self review * fix wording Co-authored-by: William Wong <[email protected]> * Remove babel * Self-review * Tweak api package * Tweak component package * Tweak more packages * Fix lock file * Valid core dts * Do not emit unused * Make base a bit useful ⚡️ * Cleanup --------- Co-authored-by: William Wong <[email protected]>
1 parent 0eed4fb commit 21a4ec1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+231
-113
lines changed

.github/workflows/pull-request-validation.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -183,15 +183,15 @@ jobs:
183183
- run: npm run build --if-present
184184

185185
- name: Run tsd under packages/bundle (CJS)
186-
run: ../../node_modules/.bin/tsd -t ./lib/index.d.ts
186+
run: ../../node_modules/.bin/tsd -t ./dist/botframework-webchat.d.ts
187187
working-directory: ./packages/bundle
188188

189189
- name: Run tsd under packages/bundle (ESM)
190190
run: ../../node_modules/.bin/tsd -t ./dist/botframework-webchat.d.mts
191191
working-directory: ./packages/bundle
192192

193193
- name: Run tsd under packages/core (CJS)
194-
run: ../../node_modules/.bin/tsd -t ./lib/index.d.ts
194+
run: ../../node_modules/.bin/tsd -t ./dist/botframework-webchat-core.d.ts
195195
working-directory: ./packages/core
196196

197197
- name: Run tsd under packages/core (ESM)

package-lock.json

+36-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"keywords": [],
1616
"cldr-data-coverage": "full",
1717
"workspaces": [
18+
"./packages/base",
1819
"./packages/test/dev-server",
1920
"./packages/test/harness",
2021
"./packages/test/web-server",

packages/README.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22

33
Web Chat consists of the following packages:
44

5+
- [`base`](#base)
56
- [`core`](#core)
67
- [`component`](#component)
78
- [`bundle`](#bundle)
89
- [`directlinespeech`](#directlinespeech)
910
- [`embed`](#embed)
1011
- [`isomorphic-*`](#isomorphic-*)
1112

13+
## `base`
14+
15+
Essentials and utilities used in the project.
16+
1217
## `core`
1318

1419
Stateful data layer as Redux store.
@@ -69,9 +74,9 @@ We offer 3 build flavors:
6974

7075
| | Instrumented | Minified | Source maps |
7176
| ----------- | ------------ | -------- | ----------- |
72-
| Production || ||
73-
| Test | | ||
74-
| Development ||| |
77+
| Production ||||
78+
| Test ||||
79+
| Development ||||
7580

7681
> Instrumentation code is added by Istanbul via Babel.
7782
> Minification is carried out by Terser via Webpack.

packages/api/.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/*.tgz
22
/dist/
3-
/lib/
43
/node_modules/
54
/src/external/

packages/api/decorator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This is required for Webpack 4 which does not support named exports.
22
// eslint-disable-next-line no-undef
3-
module.exports = require('./lib/decorator/index');
3+
module.exports = require('./dist/botframework-webchat-api.decorator');

packages/api/internal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This is required for Webpack 4 which does not support named exports.
22
// eslint-disable-next-line no-undef
3-
module.exports = require('./lib/internal');
3+
module.exports = require('./dist/botframework-webchat-api.internal');

packages/api/package.json

+10-15
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
"name": "botframework-webchat-api",
33
"version": "0.0.0-0",
44
"description": "React DOM component of botframework-webchat",
5-
"main": "./lib/index.js",
6-
"types": "./lib/index.d.ts",
5+
"main": "./dist/botframework-webchat-api.js",
6+
"types": "./dist/botframework-webchat-api.d.ts",
77
"exports": {
88
".": {
99
"import": {
1010
"types": "./dist/botframework-webchat-api.d.mts",
1111
"default": "./dist/botframework-webchat-api.mjs"
1212
},
1313
"require": {
14-
"types": "./lib/index.d.ts",
15-
"default": "./lib/index.js"
14+
"types": "./dist/botframework-webchat-api.d.ts",
15+
"default": "./dist/botframework-webchat-api.js"
1616
}
1717
},
1818
"./internal": {
@@ -21,8 +21,8 @@
2121
"default": "./dist/botframework-webchat-api.internal.mjs"
2222
},
2323
"require": {
24-
"types": "./lib/internal.d.ts",
25-
"default": "./lib/internal.js"
24+
"types": "./dist/botframework-webchat-api.internal.d.ts",
25+
"default": "./dist/botframework-webchat-api.internal.js"
2626
}
2727
},
2828
"./decorator": {
@@ -31,8 +31,8 @@
3131
"default": "./dist/botframework-webchat-api.decorator.mjs"
3232
},
3333
"require": {
34-
"types": "./lib/decorator/index.d.ts",
35-
"default": "./lib/decorator/index.js"
34+
"types": "./dist/botframework-webchat-api.decorator.d.ts",
35+
"default": "./dist/botframework-webchat-api.decorator.js"
3636
}
3737
}
3838
},
@@ -51,16 +51,13 @@
5151
"files": [
5252
"./dist/**/*",
5353
"./*.js",
54-
"./lib/**/*",
5554
"./src/**/*"
5655
],
5756
"homepage": "https://github.com/microsoft/BotFramework-WebChat/tree/main/packages/component#readme",
5857
"scripts": {
59-
"build": "npm run build:globalize && npm run build:tsup && npm run build:typescript && npm run build:babel",
60-
"build:babel": "cross-env build_tool=babel module_format=commonjs babel src --copy-files --extensions .js,.ts,.tsx --ignore **/*.spec.js,**/*.spec.ts,**/*.spec.tsx,**/*.test.js,**/*.test.ts,**/*.test.tsx,__tests__/**/*.js,__tests__/**/*.ts,__tests__/**/*.tsx --no-copy-ignored --out-dir lib --verbose",
58+
"build": "npm run build:globalize && npm run build:tsup",
6159
"build:globalize": "node scripts/createPrecompiledGlobalize.mjs",
6260
"build:tsup": "tsup --config ./tsup.config.ts",
63-
"build:typescript": "tsc --project src/tsconfig.json",
6461
"bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)",
6562
"bump:dev": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.devDependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install $PACKAGES_TO_BUMP || true",
6663
"bump:prod": "PACKAGES_TO_BUMP=$(cat package.json | jq -r '(.pinDependencies // {}) as $P | (.localDependencies // {} | keys) as $L | (.dependencies // {}) | to_entries | map(select(.key as $K | $L | contains([$K]) | not)) | map(.key + \"@\" + ($P[.key] // [\"latest\"])[0]) | join(\" \")') && [ ! -z \"$PACKAGES_TO_BUMP\" ] && npm install --save-exact $PACKAGES_TO_BUMP || true",
@@ -71,9 +68,7 @@
7168
"precommit:typecheck": "tsc --project ./src --emitDeclarationOnly false --esModuleInterop true --noEmit --pretty false",
7269
"preversion": "cat package.json | jq '(.localDependencies // {} | to_entries | map([if .value == \"production\" then \"dependencies\" else \"devDependencies\" end, .key])) as $P | delpaths($P)' > package-temp.json && mv package-temp.json package.json",
7370
"start": "concurrently --kill-others --prefix-colors \"auto\" \"npm:start:*\"",
74-
"start:babel": "npm run build:babel -- --skip-initial-build --watch",
75-
"start:tsup": "npm run build:tsup -- --watch",
76-
"start:typescript": "npm run build:typescript -- --watch"
71+
"start:tsup": "npm run build:tsup -- --watch"
7772
},
7873
"localDependencies": {
7974
"botframework-webchat-cldr-data": "development",

packages/api/src/hooks/Composer.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ import normalizeLanguage from '../utils/normalizeLanguage';
6969
import { SendBoxMiddlewareProvider, type SendBoxMiddleware } from './internal/SendBoxMiddleware';
7070
import { SendBoxToolbarMiddlewareProvider, type SendBoxToolbarMiddleware } from './internal/SendBoxToolbarMiddleware';
7171
import Tracker from './internal/Tracker';
72-
import { default as WebChatAPIContext } from './internal/WebChatAPIContext';
72+
import WebChatAPIContext, { type WebChatAPIContextType } from './internal/WebChatAPIContext';
7373
import WebChatReduxContext, { useDispatch } from './internal/WebChatReduxContext';
7474
import defaultSelectVoice from './internal/defaultSelectVoice';
7575
import applyMiddleware, {
@@ -218,7 +218,7 @@ type ComposerCoreProps = Readonly<{
218218
attachmentMiddleware?: OneOrMany<AttachmentMiddleware>;
219219
avatarMiddleware?: OneOrMany<AvatarMiddleware>;
220220
cardActionMiddleware?: OneOrMany<CardActionMiddleware>;
221-
children?: ReactNode | ((context: ContextOf<typeof WebChatAPIContext>) => ReactNode);
221+
children?: ReactNode | ((context: ContextOf<React.Context<WebChatAPIContextType>>) => ReactNode);
222222
dir?: string;
223223
directLine: DirectLineJSBotConnection;
224224
/**
@@ -543,7 +543,7 @@ const ComposerCore = ({
543543
* This context should consist of members that are not in the Redux store
544544
* i.e. members that are not interested in other types of UIs
545545
*/
546-
const context = useMemo<ContextOf<typeof WebChatAPIContext>>(
546+
const context = useMemo<ContextOf<React.Context<WebChatAPIContextType>>>(
547547
() => ({
548548
...cardActionContext,
549549
...groupActivitiesContext,

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { ScrollToEndButtonComponentFactory } from '../../types/ScrollToEndButton
2323
import TelemetryMeasurementEvent from '../../types/TelemetryMeasurementEvent';
2424
import { RenderToast } from '../../types/ToastMiddleware';
2525

26-
type WebChatAPIContext = {
26+
export type WebChatAPIContextType = {
2727
activityRenderer?: LegacyActivityRenderer;
2828
activityStatusRenderer: RenderActivityStatus;
2929
attachmentForScreenReaderRenderer?: AttachmentForScreenReaderComponentFactory;
@@ -88,7 +88,7 @@ type WebChatAPIContext = {
8888
username?: string;
8989
};
9090

91-
const context = createContext<WebChatAPIContext>(undefined);
91+
const context = createContext<WebChatAPIContextType>(undefined);
9292

9393
context.displayName = 'WebChatAPIContext';
9494

packages/api/src/tsconfig.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
{
22
"compilerOptions": {
33
"allowSyntheticDefaultImports": true,
4-
"declaration": true,
5-
"declarationDir": "../lib",
6-
"declarationMap": true,
74
"downlevelIteration": true,
8-
"emitDeclarationOnly": true,
95
"jsx": "react",
106
"module": "ESNext",
117
"moduleResolution": "Bundler",
12-
"preserveWatchOutput": true,
8+
"noEmit": true,
139
"pretty": true,
1410
"resolveJsonModule": true, // Required for localization files
1511
"skipLibCheck": true,

packages/api/tsup.config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ export default defineConfig({
88
'botframework-webchat-api.internal': './src/internal.ts',
99
'botframework-webchat-api.decorator': './src/decorator/index.ts'
1010
},
11-
noExternal: ['globalize']
11+
noExternal: ['globalize'],
12+
format: ['esm', 'cjs']
1213
});

packages/base/.eslintrc.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
extends:
2+
- ../../.eslintrc.production.yml
3+
4+
# This package is compatible with web browser.
5+
env:
6+
browser: true

packages/base/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/*.tgz
2+
/dist/
3+
/node_modules/

packages/base/README.md

Whitespace-only changes.

0 commit comments

Comments
 (0)