From 21a4ec1d6d4e6069a7d4fb26b4a61d0bbb689734 Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 2 Oct 2024 21:38:22 +0000 Subject: [PATCH] Add base package (#5176) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add base package * Self review * fix wording Co-authored-by: William Wong * 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 --- .github/workflows/pull-request-validation.yml | 4 +- package-lock.json | 39 ++++++++++- package.json | 1 + packages/README.md | 11 ++- packages/api/.gitignore | 1 - packages/api/decorator.js | 2 +- packages/api/internal.js | 2 +- packages/api/package.json | 25 +++---- packages/api/src/hooks/Composer.tsx | 6 +- .../src/hooks/internal/WebChatAPIContext.ts | 4 +- packages/api/src/tsconfig.json | 6 +- packages/api/tsup.config.ts | 3 +- packages/base/.eslintrc.yml | 6 ++ packages/base/.gitignore | 3 + packages/base/README.md | 0 packages/base/package.json | 68 +++++++++++++++++++ packages/base/src/build/index.ts | 0 packages/base/src/index.ts | 0 packages/base/src/tsconfig.json | 12 ++++ packages/base/src/utils/index.ts | 1 + .../{core => base}/src/utils/withResolvers.ts | 1 + packages/base/tsup.config.ts | 11 +++ packages/base/utils.js | 3 + packages/bundle/package.json | 15 ++-- packages/bundle/src/tsconfig.json | 8 +-- packages/bundle/tsup.config.ts | 3 +- packages/bundle/webpack.config.js | 8 +-- packages/component/.gitignore | 1 - packages/component/package.json | 31 ++++----- packages/component/src/tsconfig.json | 8 +-- packages/component/tsup.config.ts | 3 +- packages/core/.gitignore | 1 - packages/core/package.json | 19 +++--- .../src/actions/{connect.js => connect.ts} | 0 ...tusUpdate.js => connectionStatusUpdate.ts} | 0 .../actions/{disconnect.js => disconnect.ts} | 0 ...ingIndicator.js => emitTypingIndicator.ts} | 0 ...ngActivity.js => queueIncomingActivity.ts} | 0 .../actions/{reconnect.js => reconnect.ts} | 0 .../actions/{sendEvent.js => sendEvent.ts} | 0 ...{sendMessageBack.js => sendMessageBack.ts} | 0 .../{sendPostBack.js => sendPostBack.ts} | 0 ...ctateInterims.js => setDictateInterims.ts} | 0 ...{setDictateState.js => setDictateState.ts} | 0 .../{setLanguage.js => setLanguage.ts} | 0 .../actions/{setSendBox.js => setSendBox.ts} | 0 .../{setSendTimeout.js => setSendTimeout.ts} | 0 .../{startDictate.js => startDictate.ts} | 0 ...ngActivity.js => startSpeakingActivity.ts} | 0 .../{stopDictate.js => stopDictate.ts} | 0 ...ingActivity.js => stopSpeakingActivity.ts} | 0 .../{submitSendBox.js => submitSendBox.ts} | 2 +- ...ionStatus.js => updateConnectionStatus.ts} | 0 packages/core/src/createPromiseQueue.js | 2 +- packages/core/src/index.ts | 3 +- packages/core/src/tsconfig.json | 9 +-- .../core/src/utils/getOrgSchemaMessage.ts | 6 +- packages/core/tsup.config.ts | 3 +- packages/fluent-theme/package.json | 6 +- packages/styles/package.json | 7 +- 60 files changed, 231 insertions(+), 113 deletions(-) create mode 100644 packages/base/.eslintrc.yml create mode 100644 packages/base/.gitignore create mode 100644 packages/base/README.md create mode 100644 packages/base/package.json create mode 100644 packages/base/src/build/index.ts create mode 100644 packages/base/src/index.ts create mode 100644 packages/base/src/tsconfig.json create mode 100644 packages/base/src/utils/index.ts rename packages/{core => base}/src/utils/withResolvers.ts (88%) create mode 100644 packages/base/tsup.config.ts create mode 100644 packages/base/utils.js rename packages/core/src/actions/{connect.js => connect.ts} (100%) rename packages/core/src/actions/{connectionStatusUpdate.js => connectionStatusUpdate.ts} (100%) rename packages/core/src/actions/{disconnect.js => disconnect.ts} (100%) rename packages/core/src/actions/{emitTypingIndicator.js => emitTypingIndicator.ts} (100%) rename packages/core/src/actions/{queueIncomingActivity.js => queueIncomingActivity.ts} (100%) rename packages/core/src/actions/{reconnect.js => reconnect.ts} (100%) rename packages/core/src/actions/{sendEvent.js => sendEvent.ts} (100%) rename packages/core/src/actions/{sendMessageBack.js => sendMessageBack.ts} (100%) rename packages/core/src/actions/{sendPostBack.js => sendPostBack.ts} (100%) rename packages/core/src/actions/{setDictateInterims.js => setDictateInterims.ts} (100%) rename packages/core/src/actions/{setDictateState.js => setDictateState.ts} (100%) rename packages/core/src/actions/{setLanguage.js => setLanguage.ts} (100%) rename packages/core/src/actions/{setSendBox.js => setSendBox.ts} (100%) rename packages/core/src/actions/{setSendTimeout.js => setSendTimeout.ts} (100%) rename packages/core/src/actions/{startDictate.js => startDictate.ts} (100%) rename packages/core/src/actions/{startSpeakingActivity.js => startSpeakingActivity.ts} (100%) rename packages/core/src/actions/{stopDictate.js => stopDictate.ts} (100%) rename packages/core/src/actions/{stopSpeakingActivity.js => stopSpeakingActivity.ts} (100%) rename packages/core/src/actions/{submitSendBox.js => submitSendBox.ts} (84%) rename packages/core/src/actions/{updateConnectionStatus.js => updateConnectionStatus.ts} (100%) diff --git a/.github/workflows/pull-request-validation.yml b/.github/workflows/pull-request-validation.yml index 4246d9cbd4..1f3c8a59b9 100644 --- a/.github/workflows/pull-request-validation.yml +++ b/.github/workflows/pull-request-validation.yml @@ -183,7 +183,7 @@ jobs: - run: npm run build --if-present - name: Run tsd under packages/bundle (CJS) - run: ../../node_modules/.bin/tsd -t ./lib/index.d.ts + run: ../../node_modules/.bin/tsd -t ./dist/botframework-webchat.d.ts working-directory: ./packages/bundle - name: Run tsd under packages/bundle (ESM) @@ -191,7 +191,7 @@ jobs: working-directory: ./packages/bundle - name: Run tsd under packages/core (CJS) - run: ../../node_modules/.bin/tsd -t ./lib/index.d.ts + run: ../../node_modules/.bin/tsd -t ./dist/botframework-webchat-core.d.ts working-directory: ./packages/core - name: Run tsd under packages/core (ESM) diff --git a/package-lock.json b/package-lock.json index e5c0285e10..7016ddf20f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "4.18.1-0", "license": "MIT", "workspaces": [ + "./packages/base", "./packages/test/dev-server", "./packages/test/harness", "./packages/test/web-server", @@ -6607,6 +6608,10 @@ "resolved": "packages/api", "link": true }, + "node_modules/botframework-webchat-base": { + "resolved": "packages/base", + "link": true + }, "node_modules/botframework-webchat-cldr-data": { "resolved": "packages/support/cldr-data", "link": true @@ -23961,6 +23966,32 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "packages/base": { + "name": "botframework-webchat-base", + "version": "0.0.0-0", + "license": "MIT", + "devDependencies": { + "@tsconfig/strictest": "^2.0.5", + "@types/node": "^20.10.3", + "core-js-pure": "3.38.1", + "cross-env": "^7.0.3", + "type-fest": "^4.18.2", + "typescript": "^5.3.2" + } + }, + "packages/base/node_modules/type-fest": { + "version": "4.26.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.26.1.tgz", + "integrity": "sha512-yOGpmOAL7CkKe/91I5O3gPICmJNLJ1G4zFYVAsRHg7M64biSnPtRj0WNQt++bRkjYOqjWXrhnUw1utzmVErAdg==", + "dev": true, + "license": "(MIT OR CC0-1.0)", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "packages/bundle": { "name": "botframework-webchat", "version": "0.0.0-0", @@ -24007,6 +24038,7 @@ "babel-loader": "^9.1.3", "babel-plugin-istanbul": "^6.1.1", "babel-plugin-transform-inline-environment-variables": "^0.4.4", + "botframework-webchat-base": "0.0.0-0", "concurrently": "^8.2.2", "cross-env": "^7.0.3", "esbuild": "^0.21.1", @@ -24153,7 +24185,6 @@ "base64-js": "1.5.1", "botframework-webchat-api": "0.0.0-0", "botframework-webchat-core": "0.0.0-0", - "botframework-webchat-styles": "0.0.0-0", "classnames": "2.5.1", "compute-scroll-into-view": "1.0.20", "deep-freeze-strict": "1.1.1", @@ -24187,6 +24218,8 @@ "@types/react": "^16.14.60", "babel-plugin-istanbul": "^6.1.1", "babel-plugin-transform-inline-environment-variables": "^0.4.4", + "botframework-webchat-base": "0.0.0-0", + "botframework-webchat-styles": "0.0.0-0", "concurrently": "^8.2.2", "core-js": "^3.37.0", "cross-env": "^7.0.3", @@ -24226,7 +24259,6 @@ "dependencies": { "@babel/runtime": "7.19.0", "@redux-devtools/extension": "3.3.0", - "core-js-pure": "3.38.1", "jwt-decode": "4.0.0", "math-random": "2.0.1", "mime": "4.0.3", @@ -24245,6 +24277,7 @@ "babel-plugin-istanbul": "^6.1.1", "babel-plugin-transform-inline-environment-variables": "^0.4.4", "botframework-directlinejs": "^0.15.5", + "botframework-webchat-base": "0.0.0-0", "concurrently": "^8.2.2", "cross-env": "^7.0.3", "tsd": "^0.31.0", @@ -25423,7 +25456,6 @@ "botframework-webchat-api": "0.0.0-0", "botframework-webchat-component": "0.0.0-0", "botframework-webchat-core": "0.0.0-0", - "botframework-webchat-styles": "0.0.0-0", "classnames": "2.5.1", "inject-meta-tag": "0.0.1", "math-random": "2.0.1", @@ -25435,6 +25467,7 @@ "@types/math-random": "^1.0.2", "@types/node": "^20.12.11", "@types/react": "^16.14.60", + "botframework-webchat-styles": "0.0.0-0", "tsup": "^8.0.2", "typescript": "^5.4.5" }, diff --git a/package.json b/package.json index 47e09e6144..a37d61b2c4 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "keywords": [], "cldr-data-coverage": "full", "workspaces": [ + "./packages/base", "./packages/test/dev-server", "./packages/test/harness", "./packages/test/web-server", diff --git a/packages/README.md b/packages/README.md index 5341094289..a272e07124 100644 --- a/packages/README.md +++ b/packages/README.md @@ -2,6 +2,7 @@ Web Chat consists of the following packages: +- [`base`](#base) - [`core`](#core) - [`component`](#component) - [`bundle`](#bundle) @@ -9,6 +10,10 @@ Web Chat consists of the following packages: - [`embed`](#embed) - [`isomorphic-*`](#isomorphic-*) +## `base` + +Essentials and utilities used in the project. + ## `core` Stateful data layer as Redux store. @@ -69,9 +74,9 @@ We offer 3 build flavors: | | Instrumented | Minified | Source maps | | ----------- | ------------ | -------- | ----------- | -| Production | ❌ | ✔ | ❌ | -| Test | ✔ | ✔ | ❌ | -| Development | ❌ | ❌ | ✔ | +| Production | ❌ | ✔ | ❌ | +| Test | ✔ | ✔ | ❌ | +| Development | ❌ | ❌ | ✔ | > Instrumentation code is added by Istanbul via Babel. > Minification is carried out by Terser via Webpack. diff --git a/packages/api/.gitignore b/packages/api/.gitignore index 2c682dccd0..4b22227adf 100644 --- a/packages/api/.gitignore +++ b/packages/api/.gitignore @@ -1,5 +1,4 @@ /*.tgz /dist/ -/lib/ /node_modules/ /src/external/ diff --git a/packages/api/decorator.js b/packages/api/decorator.js index 16dcf52fc7..8506fc240b 100644 --- a/packages/api/decorator.js +++ b/packages/api/decorator.js @@ -1,3 +1,3 @@ // This is required for Webpack 4 which does not support named exports. // eslint-disable-next-line no-undef -module.exports = require('./lib/decorator/index'); +module.exports = require('./dist/botframework-webchat-api.decorator'); diff --git a/packages/api/internal.js b/packages/api/internal.js index 2a05a7c53f..ea85579df0 100644 --- a/packages/api/internal.js +++ b/packages/api/internal.js @@ -1,3 +1,3 @@ // This is required for Webpack 4 which does not support named exports. // eslint-disable-next-line no-undef -module.exports = require('./lib/internal'); +module.exports = require('./dist/botframework-webchat-api.internal'); diff --git a/packages/api/package.json b/packages/api/package.json index 736075df2a..aa3ad627b4 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -2,8 +2,8 @@ "name": "botframework-webchat-api", "version": "0.0.0-0", "description": "React DOM component of botframework-webchat", - "main": "./lib/index.js", - "types": "./lib/index.d.ts", + "main": "./dist/botframework-webchat-api.js", + "types": "./dist/botframework-webchat-api.d.ts", "exports": { ".": { "import": { @@ -11,8 +11,8 @@ "default": "./dist/botframework-webchat-api.mjs" }, "require": { - "types": "./lib/index.d.ts", - "default": "./lib/index.js" + "types": "./dist/botframework-webchat-api.d.ts", + "default": "./dist/botframework-webchat-api.js" } }, "./internal": { @@ -21,8 +21,8 @@ "default": "./dist/botframework-webchat-api.internal.mjs" }, "require": { - "types": "./lib/internal.d.ts", - "default": "./lib/internal.js" + "types": "./dist/botframework-webchat-api.internal.d.ts", + "default": "./dist/botframework-webchat-api.internal.js" } }, "./decorator": { @@ -31,8 +31,8 @@ "default": "./dist/botframework-webchat-api.decorator.mjs" }, "require": { - "types": "./lib/decorator/index.d.ts", - "default": "./lib/decorator/index.js" + "types": "./dist/botframework-webchat-api.decorator.d.ts", + "default": "./dist/botframework-webchat-api.decorator.js" } } }, @@ -51,16 +51,13 @@ "files": [ "./dist/**/*", "./*.js", - "./lib/**/*", "./src/**/*" ], "homepage": "https://github.com/microsoft/BotFramework-WebChat/tree/main/packages/component#readme", "scripts": { - "build": "npm run build:globalize && npm run build:tsup && npm run build:typescript && npm run build:babel", - "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", + "build": "npm run build:globalize && npm run build:tsup", "build:globalize": "node scripts/createPrecompiledGlobalize.mjs", "build:tsup": "tsup --config ./tsup.config.ts", - "build:typescript": "tsc --project src/tsconfig.json", "bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)", "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", "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 @@ "precommit:typecheck": "tsc --project ./src --emitDeclarationOnly false --esModuleInterop true --noEmit --pretty false", "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", "start": "concurrently --kill-others --prefix-colors \"auto\" \"npm:start:*\"", - "start:babel": "npm run build:babel -- --skip-initial-build --watch", - "start:tsup": "npm run build:tsup -- --watch", - "start:typescript": "npm run build:typescript -- --watch" + "start:tsup": "npm run build:tsup -- --watch" }, "localDependencies": { "botframework-webchat-cldr-data": "development", diff --git a/packages/api/src/hooks/Composer.tsx b/packages/api/src/hooks/Composer.tsx index 3a14905824..6ae1f9340d 100644 --- a/packages/api/src/hooks/Composer.tsx +++ b/packages/api/src/hooks/Composer.tsx @@ -69,7 +69,7 @@ import normalizeLanguage from '../utils/normalizeLanguage'; import { SendBoxMiddlewareProvider, type SendBoxMiddleware } from './internal/SendBoxMiddleware'; import { SendBoxToolbarMiddlewareProvider, type SendBoxToolbarMiddleware } from './internal/SendBoxToolbarMiddleware'; import Tracker from './internal/Tracker'; -import { default as WebChatAPIContext } from './internal/WebChatAPIContext'; +import WebChatAPIContext, { type WebChatAPIContextType } from './internal/WebChatAPIContext'; import WebChatReduxContext, { useDispatch } from './internal/WebChatReduxContext'; import defaultSelectVoice from './internal/defaultSelectVoice'; import applyMiddleware, { @@ -218,7 +218,7 @@ type ComposerCoreProps = Readonly<{ attachmentMiddleware?: OneOrMany; avatarMiddleware?: OneOrMany; cardActionMiddleware?: OneOrMany; - children?: ReactNode | ((context: ContextOf) => ReactNode); + children?: ReactNode | ((context: ContextOf>) => ReactNode); dir?: string; directLine: DirectLineJSBotConnection; /** @@ -543,7 +543,7 @@ const ComposerCore = ({ * This context should consist of members that are not in the Redux store * i.e. members that are not interested in other types of UIs */ - const context = useMemo>( + const context = useMemo>>( () => ({ ...cardActionContext, ...groupActivitiesContext, diff --git a/packages/api/src/hooks/internal/WebChatAPIContext.ts b/packages/api/src/hooks/internal/WebChatAPIContext.ts index 4f1e3b2727..b7e6041e6e 100644 --- a/packages/api/src/hooks/internal/WebChatAPIContext.ts +++ b/packages/api/src/hooks/internal/WebChatAPIContext.ts @@ -23,7 +23,7 @@ import { ScrollToEndButtonComponentFactory } from '../../types/ScrollToEndButton import TelemetryMeasurementEvent from '../../types/TelemetryMeasurementEvent'; import { RenderToast } from '../../types/ToastMiddleware'; -type WebChatAPIContext = { +export type WebChatAPIContextType = { activityRenderer?: LegacyActivityRenderer; activityStatusRenderer: RenderActivityStatus; attachmentForScreenReaderRenderer?: AttachmentForScreenReaderComponentFactory; @@ -88,7 +88,7 @@ type WebChatAPIContext = { username?: string; }; -const context = createContext(undefined); +const context = createContext(undefined); context.displayName = 'WebChatAPIContext'; diff --git a/packages/api/src/tsconfig.json b/packages/api/src/tsconfig.json index fe93844f28..33529ce44d 100644 --- a/packages/api/src/tsconfig.json +++ b/packages/api/src/tsconfig.json @@ -1,15 +1,11 @@ { "compilerOptions": { "allowSyntheticDefaultImports": true, - "declaration": true, - "declarationDir": "../lib", - "declarationMap": true, "downlevelIteration": true, - "emitDeclarationOnly": true, "jsx": "react", "module": "ESNext", "moduleResolution": "Bundler", - "preserveWatchOutput": true, + "noEmit": true, "pretty": true, "resolveJsonModule": true, // Required for localization files "skipLibCheck": true, diff --git a/packages/api/tsup.config.ts b/packages/api/tsup.config.ts index d0398b7f39..423f6dfe2e 100644 --- a/packages/api/tsup.config.ts +++ b/packages/api/tsup.config.ts @@ -8,5 +8,6 @@ export default defineConfig({ 'botframework-webchat-api.internal': './src/internal.ts', 'botframework-webchat-api.decorator': './src/decorator/index.ts' }, - noExternal: ['globalize'] + noExternal: ['globalize'], + format: ['esm', 'cjs'] }); diff --git a/packages/base/.eslintrc.yml b/packages/base/.eslintrc.yml new file mode 100644 index 0000000000..1aa1350134 --- /dev/null +++ b/packages/base/.eslintrc.yml @@ -0,0 +1,6 @@ +extends: + - ../../.eslintrc.production.yml + +# This package is compatible with web browser. +env: + browser: true diff --git a/packages/base/.gitignore b/packages/base/.gitignore new file mode 100644 index 0000000000..18976f7c55 --- /dev/null +++ b/packages/base/.gitignore @@ -0,0 +1,3 @@ +/*.tgz +/dist/ +/node_modules/ diff --git a/packages/base/README.md b/packages/base/README.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/base/package.json b/packages/base/package.json new file mode 100644 index 0000000000..b4ca52cb18 --- /dev/null +++ b/packages/base/package.json @@ -0,0 +1,68 @@ +{ + "name": "botframework-webchat-base", + "version": "0.0.0-0", + "description": "Base botframework-webchat package", + "main": "./dist/botframework-webchat-base.js", + "types": "./dist/botframework-webchat-base.d.ts", + "exports": { + ".": { + "import": { + "types": "./dist/botframework-webchat-base.d.mts", + "default": "./dist/botframework-webchat-base.mjs" + }, + "require": { + "types": "./dist/botframework-webchat-base.d.ts", + "default": "./dist/botframework-webchat-base.js" + } + }, + "./utils": { + "import": { + "types": "./dist/botframework-webchat-base.utils.d.mts", + "default": "./dist/botframework-webchat-base.utils.mjs" + }, + "require": { + "types": "./dist/botframework-webchat-base.utils.d.ts", + "default": "./dist/botframework-webchat-base.utils.js" + } + } + }, + "author": "Microsoft Corporation", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/microsoft/BotFramework-WebChat.git" + }, + "bugs": { + "url": "https://github.com/microsoft/BotFramework-WebChat/issues" + }, + "files": [ + "./dist/**/*", + "./src/**/*", + "*.js" + ], + "homepage": "https://github.com/microsoft/BotFramework-WebChat/tree/main/packages/component#readme", + "private": true, + "scripts": { + "build": "npm run build:tsup", + "build:tsup": "tsup --config ./tsup.config.ts", + "bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)", + "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", + "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", + "eslint": "npm run precommit", + "postversion": "cat package.json | jq '.version as $V | (.localDependencies // {} | with_entries(select(.value == \"production\") | { key: .key, value: $V })) as $L1 | (.localDependencies // {} | with_entries(select(.value == \"development\") | { key: .key, value: $V })) as $L2 | ((.dependencies // {}) + $L1 | to_entries | sort_by(.key) | from_entries) as $D1 | ((.devDependencies // {}) + $L2 | to_entries | sort_by(.key) | from_entries) as $D2 | . + { dependencies: $D1, devDependencies: $D2 }' > package-temp.json && mv package-temp.json package.json", + "precommit": "npm run precommit:eslint -- src && npm run precommit:typecheck", + "precommit:eslint": "../../node_modules/.bin/eslint --report-unused-disable-directives --max-warnings 0", + "precommit:typecheck": "tsc --project ./src --emitDeclarationOnly false --esModuleInterop true --noEmit --pretty false", + "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", + "start": "concurrently --kill-others --prefix-colors \"auto\" \"npm:start:*\"", + "start:tsup": "npm run build:tsup -- --watch" + }, + "devDependencies": { + "@tsconfig/strictest": "^2.0.5", + "@types/node": "^20.10.3", + "core-js-pure": "3.38.1", + "cross-env": "^7.0.3", + "type-fest": "^4.18.2", + "typescript": "^5.3.2" + } +} diff --git a/packages/base/src/build/index.ts b/packages/base/src/build/index.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/base/src/index.ts b/packages/base/src/index.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/base/src/tsconfig.json b/packages/base/src/tsconfig.json new file mode 100644 index 0000000000..a1c645b8b5 --- /dev/null +++ b/packages/base/src/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "checkJs": false, + "jsx": "react", + "moduleResolution": "Bundler", + "noEmit": true, + "skipLibCheck": true, + "target": "ESNext" + }, + "extends": "@tsconfig/strictest/tsconfig.json" +} diff --git a/packages/base/src/utils/index.ts b/packages/base/src/utils/index.ts new file mode 100644 index 0000000000..051a60908a --- /dev/null +++ b/packages/base/src/utils/index.ts @@ -0,0 +1 @@ +export { default as withResolvers, type PromiseWithResolvers } from './withResolvers'; diff --git a/packages/core/src/utils/withResolvers.ts b/packages/base/src/utils/withResolvers.ts similarity index 88% rename from packages/core/src/utils/withResolvers.ts rename to packages/base/src/utils/withResolvers.ts index f549d42d4f..1dfc07cb8a 100644 --- a/packages/core/src/utils/withResolvers.ts +++ b/packages/base/src/utils/withResolvers.ts @@ -1,3 +1,4 @@ +// @ts-expect-error: no types available import coreJSWithResolvers from 'core-js-pure/features/promise/with-resolvers.js'; export type PromiseWithResolvers = { diff --git a/packages/base/tsup.config.ts b/packages/base/tsup.config.ts new file mode 100644 index 0000000000..4c25ec196d --- /dev/null +++ b/packages/base/tsup.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from 'tsup'; +import baseConfig from '../../tsup.base.config'; + +export default defineConfig({ + ...baseConfig, + entry: { + 'botframework-webchat-base': './src/index.ts', + 'botframework-webchat-base.utils': './src/utils/index.ts' + }, + format: ['esm', 'cjs'] +}); diff --git a/packages/base/utils.js b/packages/base/utils.js new file mode 100644 index 0000000000..be22dd8b5f --- /dev/null +++ b/packages/base/utils.js @@ -0,0 +1,3 @@ +// This is required for Webpack 4 which does not support named exports. +// eslint-disable-next-line no-undef +module.exports = require('./dist/botframework-webchat-base.utils'); diff --git a/packages/bundle/package.json b/packages/bundle/package.json index 37ad4a7efa..4223df1e15 100644 --- a/packages/bundle/package.json +++ b/packages/bundle/package.json @@ -2,8 +2,8 @@ "name": "botframework-webchat", "version": "0.0.0-0", "description": "A highly-customizable web-based chat client for Azure Bot Services.", - "main": "./lib/index.js", - "types": "./lib/index.d.ts", + "main": "./dist/botframework-webchat.js", + "types": "./dist/botframework-webchat.d.ts", "exports": { ".": { "import": { @@ -11,8 +11,8 @@ "default": "./dist/botframework-webchat.mjs" }, "require": { - "types": "./lib/index.d.ts", - "default": "./lib/index.js" + "types": "./dist/botframework-webchat.d.ts", + "default": "./dist/botframework-webchat.js" } } }, @@ -31,7 +31,6 @@ "homepage": "https://github.com/microsoft/BotFramework-WebChat/#readme", "files": [ "./dist/**/*", - "./lib/**/*", "./src/**/*" ], "tsd": { @@ -46,10 +45,8 @@ } }, "scripts": { - "build": "npm run build:tsup && npm run build:typescript && npm run build:babel && npm run build:webpack", - "build:babel": "cross-env build_tool=babel module_format=commonjs babel src --extensions .js,.ts,.tsx --ignore **/*.spec.js,**/*.spec.ts,**/*.spec.tsx,**/*.test.js,**/*.test.ts,**/*.test.tsx,__tests__/**/*.js,__tests__/**/*.ts,__tests__/**/*.tsx --out-dir lib --verbose", + "build": "npm run build:tsup && npm run build:webpack", "build:tsup": "tsup --config ./tsup.config.ts", - "build:typescript": "tsc --project src/tsconfig.json", "build:webpack": "webpack-cli", "bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)", "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", @@ -68,6 +65,7 @@ }, "localDependencies": { "botframework-directlinespeech-sdk": "production", + "botframework-webchat-base": "development", "botframework-webchat-api": "production", "botframework-webchat-component": "production", "botframework-webchat-core": "production", @@ -170,6 +168,7 @@ "babel-loader": "^9.1.3", "babel-plugin-istanbul": "^6.1.1", "babel-plugin-transform-inline-environment-variables": "^0.4.4", + "botframework-webchat-base": "0.0.0-0", "concurrently": "^8.2.2", "cross-env": "^7.0.3", "esbuild": "^0.21.1", diff --git a/packages/bundle/src/tsconfig.json b/packages/bundle/src/tsconfig.json index 6ce9732671..a390e3ff1a 100644 --- a/packages/bundle/src/tsconfig.json +++ b/packages/bundle/src/tsconfig.json @@ -1,17 +1,11 @@ { "compilerOptions": { "allowSyntheticDefaultImports": true, - "declaration": true, - "declarationDir": "../lib", - "declarationMap": true, - "emitDeclarationOnly": true, "jsx": "react", "module": "ESNext", "moduleResolution": "Bundler", - "preserveWatchOutput": true, - "pretty": true, + "noEmit": true, "skipLibCheck": true, - "sourceMap": true, "target": "ESNext" } } diff --git a/packages/bundle/tsup.config.ts b/packages/bundle/tsup.config.ts index 374cfdf0f3..1b2201ca35 100644 --- a/packages/bundle/tsup.config.ts +++ b/packages/bundle/tsup.config.ts @@ -34,5 +34,6 @@ export default defineConfig({ 'memoize-one', 'microsoft-cognitiveservices-speech-sdk', 'web-speech-cognitive-services' - ] + ], + format: ['esm', 'cjs'] }); diff --git a/packages/bundle/webpack.config.js b/packages/bundle/webpack.config.js index c2b0281a2f..9185579d63 100644 --- a/packages/bundle/webpack.config.js +++ b/packages/bundle/webpack.config.js @@ -120,10 +120,10 @@ if (node_env !== 'production' && node_env !== 'test') { { enforce: 'pre', include: [ - join(__dirname, './lib'), - join(__dirname, '../component/lib'), - join(__dirname, '../core/lib'), - join(__dirname, '../directlinespeech/lib') + join(__dirname, './dist'), + join(__dirname, '../component/dist'), + join(__dirname, '../core/dist'), + join(__dirname, '../directlinespeech/dist') ], test: /\.js$/iu, use: ['source-map-loader'] diff --git a/packages/component/.gitignore b/packages/component/.gitignore index 62b899b6ae..18976f7c55 100644 --- a/packages/component/.gitignore +++ b/packages/component/.gitignore @@ -1,4 +1,3 @@ /*.tgz /dist/ -/lib/ /node_modules/ diff --git a/packages/component/package.json b/packages/component/package.json index 2089c9fa8f..a7282db9a5 100644 --- a/packages/component/package.json +++ b/packages/component/package.json @@ -2,8 +2,8 @@ "name": "botframework-webchat-component", "version": "0.0.0-0", "description": "React component of botframework-webchat", - "main": "./lib/index.js", - "types": "./lib/index.d.ts", + "main": "./dist/botframework-webchat-component.js", + "types": "./dist/botframework-webchat-component.d.ts", "exports": { ".": { "import": { @@ -11,8 +11,8 @@ "default": "./dist/botframework-webchat-component.mjs" }, "require": { - "types": "./lib/index.d.ts", - "default": "./lib/index.js" + "types": "./dist/botframework-webchat-component.d.ts", + "default": "./dist/botframework-webchat-component.js" } }, "./internal": { @@ -21,8 +21,8 @@ "default": "./dist/botframework-webchat-component.internal.mjs" }, "require": { - "types": "./lib/internal.d.ts", - "default": "./lib/internal.js" + "types": "./dist/botframework-webchat-component.internal.d.ts", + "default": "./dist/botframework-webchat-component.internal.js" } }, "./decorator": { @@ -31,8 +31,8 @@ "default": "./dist/botframework-webchat-component.decorator.mjs" }, "require": { - "types": "./lib/decorator/index.d.ts", - "default": "./lib/decorator/index.js" + "types": "./dist/botframework-webchat-component.decorator.d.ts", + "default": "./dist/botframework-webchat-component.decorator.js" } } }, @@ -51,15 +51,12 @@ "files": [ "./dist/**/*", "./*.js", - "./lib/**/*", "./src/**/*" ], "homepage": "https://github.com/microsoft/BotFramework-WebChat/tree/main/packages/component#readme", "scripts": { - "build": "npm run build:tsup && npm run build:typescript && npm run build:babel", - "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", + "build": "npm run build:tsup", "build:tsup": "tsup --config ./tsup.config.ts", - "build:typescript": "tsc --project src/tsconfig.json", "bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)", "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", "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", @@ -70,14 +67,13 @@ "precommit:typecheck": "tsc --project ./src --emitDeclarationOnly false --esModuleInterop true --noEmit --pretty false", "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", "start": "concurrently --kill-others --prefix-colors \"auto\" \"npm:start:*\"", - "start:babel": "npm run build:babel -- --skip-initial-build --watch", - "start:tsup": "npm run build:tsup -- --watch", - "start:typescript": "npm run build:typescript -- --watch" + "start:tsup": "npm run build:tsup -- --watch" }, "localDependencies": { "botframework-webchat-api": "production", + "botframework-webchat-base": "development", "botframework-webchat-core": "production", - "botframework-webchat-styles": "production" + "botframework-webchat-styles": "development" }, "pinDependencies": { "@babel/cli": [ @@ -131,6 +127,8 @@ "@types/react": "^16.14.60", "babel-plugin-istanbul": "^6.1.1", "babel-plugin-transform-inline-environment-variables": "^0.4.4", + "botframework-webchat-base": "0.0.0-0", + "botframework-webchat-styles": "0.0.0-0", "concurrently": "^8.2.2", "core-js": "^3.37.0", "cross-env": "^7.0.3", @@ -143,7 +141,6 @@ "base64-js": "1.5.1", "botframework-webchat-api": "0.0.0-0", "botframework-webchat-core": "0.0.0-0", - "botframework-webchat-styles": "0.0.0-0", "classnames": "2.5.1", "compute-scroll-into-view": "1.0.20", "deep-freeze-strict": "1.1.1", diff --git a/packages/component/src/tsconfig.json b/packages/component/src/tsconfig.json index c5855241a1..939d80b609 100644 --- a/packages/component/src/tsconfig.json +++ b/packages/component/src/tsconfig.json @@ -1,18 +1,12 @@ { "compilerOptions": { "allowSyntheticDefaultImports": true, - "declaration": true, - "declarationDir": "../lib", - "declarationMap": true, "downlevelIteration": true, - "emitDeclarationOnly": true, "jsx": "react", "module": "ESNext", "moduleResolution": "Bundler", - "preserveWatchOutput": true, - "pretty": true, + "noEmit": true, "skipLibCheck": true, - "sourceMap": true, "target": "ESNext" }, "extends": [ diff --git a/packages/component/tsup.config.ts b/packages/component/tsup.config.ts index 4e4c8c8a68..d3afbefcba 100644 --- a/packages/component/tsup.config.ts +++ b/packages/component/tsup.config.ts @@ -18,5 +18,6 @@ export default defineConfig({ 'botframework-webchat-component': './src/index.ts', 'botframework-webchat-component.internal': './src/internal.ts', 'botframework-webchat-component.decorator': './src/decorator/index.ts' - } + }, + format: ['esm', 'cjs'] }); diff --git a/packages/core/.gitignore b/packages/core/.gitignore index 62b899b6ae..18976f7c55 100644 --- a/packages/core/.gitignore +++ b/packages/core/.gitignore @@ -1,4 +1,3 @@ /*.tgz /dist/ -/lib/ /node_modules/ diff --git a/packages/core/package.json b/packages/core/package.json index 2f448f8569..88cb466fe0 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -2,8 +2,8 @@ "name": "botframework-webchat-core", "version": "0.0.0-0", "description": "Core of botframework-webchat", - "main": "./lib/index.js", - "types": "./lib/index.d.ts", + "main": "./dist/botframework-webchat-core.js", + "types": "./dist/botframework-webchat-core.d.ts", "exports": { ".": { "import": { @@ -11,8 +11,8 @@ "default": "./dist/botframework-webchat-core.mjs" }, "require": { - "types": "./lib/index.d.ts", - "default": "./lib/index.js" + "types": "./dist/botframework-webchat-core.d.ts", + "default": "./dist/botframework-webchat-core.js" } } }, @@ -30,7 +30,6 @@ }, "files": [ "./dist/**/*", - "./lib/**/*", "./src/**/*" ], "homepage": "https://github.com/microsoft/BotFramework-WebChat/packages/core#readme", @@ -46,10 +45,8 @@ } }, "scripts": { - "build": "npm run build:tsup && npm run build:typescript && npm run build:babel", - "build:babel": "cross-env build_tool=babel module_format=commonjs babel src --extensions .js,.ts,.tsx --ignore **/*.spec.js,**/*.spec.ts,**/*.spec.tsx,**/*.test.js,**/*.test.ts,**/*.test.tsx,__tests__/**/*.js,__tests__/**/*.ts,__tests__/**/*.tsx --out-dir lib --verbose", + "build": "npm run build:tsup", "build:tsup": "tsup --config ./tsup.config.ts", - "build:typescript": "tsc --project src/tsconfig.json", "bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)", "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", "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", @@ -67,7 +64,9 @@ "engines": { "node": ">=12.0.0" }, - "localDependences": {}, + "localDependences": { + "botframework-webchat-base": "development" + }, "pinDependencies": { "@babel/cli": [ "7.18.10", @@ -104,6 +103,7 @@ "babel-plugin-istanbul": "^6.1.1", "babel-plugin-transform-inline-environment-variables": "^0.4.4", "botframework-directlinejs": "^0.15.5", + "botframework-webchat-base": "0.0.0-0", "concurrently": "^8.2.2", "cross-env": "^7.0.3", "tsd": "^0.31.0", @@ -113,7 +113,6 @@ "dependencies": { "@babel/runtime": "7.19.0", "@redux-devtools/extension": "3.3.0", - "core-js-pure": "3.38.1", "jwt-decode": "4.0.0", "math-random": "2.0.1", "mime": "4.0.3", diff --git a/packages/core/src/actions/connect.js b/packages/core/src/actions/connect.ts similarity index 100% rename from packages/core/src/actions/connect.js rename to packages/core/src/actions/connect.ts diff --git a/packages/core/src/actions/connectionStatusUpdate.js b/packages/core/src/actions/connectionStatusUpdate.ts similarity index 100% rename from packages/core/src/actions/connectionStatusUpdate.js rename to packages/core/src/actions/connectionStatusUpdate.ts diff --git a/packages/core/src/actions/disconnect.js b/packages/core/src/actions/disconnect.ts similarity index 100% rename from packages/core/src/actions/disconnect.js rename to packages/core/src/actions/disconnect.ts diff --git a/packages/core/src/actions/emitTypingIndicator.js b/packages/core/src/actions/emitTypingIndicator.ts similarity index 100% rename from packages/core/src/actions/emitTypingIndicator.js rename to packages/core/src/actions/emitTypingIndicator.ts diff --git a/packages/core/src/actions/queueIncomingActivity.js b/packages/core/src/actions/queueIncomingActivity.ts similarity index 100% rename from packages/core/src/actions/queueIncomingActivity.js rename to packages/core/src/actions/queueIncomingActivity.ts diff --git a/packages/core/src/actions/reconnect.js b/packages/core/src/actions/reconnect.ts similarity index 100% rename from packages/core/src/actions/reconnect.js rename to packages/core/src/actions/reconnect.ts diff --git a/packages/core/src/actions/sendEvent.js b/packages/core/src/actions/sendEvent.ts similarity index 100% rename from packages/core/src/actions/sendEvent.js rename to packages/core/src/actions/sendEvent.ts diff --git a/packages/core/src/actions/sendMessageBack.js b/packages/core/src/actions/sendMessageBack.ts similarity index 100% rename from packages/core/src/actions/sendMessageBack.js rename to packages/core/src/actions/sendMessageBack.ts diff --git a/packages/core/src/actions/sendPostBack.js b/packages/core/src/actions/sendPostBack.ts similarity index 100% rename from packages/core/src/actions/sendPostBack.js rename to packages/core/src/actions/sendPostBack.ts diff --git a/packages/core/src/actions/setDictateInterims.js b/packages/core/src/actions/setDictateInterims.ts similarity index 100% rename from packages/core/src/actions/setDictateInterims.js rename to packages/core/src/actions/setDictateInterims.ts diff --git a/packages/core/src/actions/setDictateState.js b/packages/core/src/actions/setDictateState.ts similarity index 100% rename from packages/core/src/actions/setDictateState.js rename to packages/core/src/actions/setDictateState.ts diff --git a/packages/core/src/actions/setLanguage.js b/packages/core/src/actions/setLanguage.ts similarity index 100% rename from packages/core/src/actions/setLanguage.js rename to packages/core/src/actions/setLanguage.ts diff --git a/packages/core/src/actions/setSendBox.js b/packages/core/src/actions/setSendBox.ts similarity index 100% rename from packages/core/src/actions/setSendBox.js rename to packages/core/src/actions/setSendBox.ts diff --git a/packages/core/src/actions/setSendTimeout.js b/packages/core/src/actions/setSendTimeout.ts similarity index 100% rename from packages/core/src/actions/setSendTimeout.js rename to packages/core/src/actions/setSendTimeout.ts diff --git a/packages/core/src/actions/startDictate.js b/packages/core/src/actions/startDictate.ts similarity index 100% rename from packages/core/src/actions/startDictate.js rename to packages/core/src/actions/startDictate.ts diff --git a/packages/core/src/actions/startSpeakingActivity.js b/packages/core/src/actions/startSpeakingActivity.ts similarity index 100% rename from packages/core/src/actions/startSpeakingActivity.js rename to packages/core/src/actions/startSpeakingActivity.ts diff --git a/packages/core/src/actions/stopDictate.js b/packages/core/src/actions/stopDictate.ts similarity index 100% rename from packages/core/src/actions/stopDictate.js rename to packages/core/src/actions/stopDictate.ts diff --git a/packages/core/src/actions/stopSpeakingActivity.js b/packages/core/src/actions/stopSpeakingActivity.ts similarity index 100% rename from packages/core/src/actions/stopSpeakingActivity.js rename to packages/core/src/actions/stopSpeakingActivity.ts diff --git a/packages/core/src/actions/submitSendBox.js b/packages/core/src/actions/submitSendBox.ts similarity index 84% rename from packages/core/src/actions/submitSendBox.js rename to packages/core/src/actions/submitSendBox.ts index a212ab3e98..8a4e7420f8 100644 --- a/packages/core/src/actions/submitSendBox.js +++ b/packages/core/src/actions/submitSendBox.ts @@ -1,6 +1,6 @@ const SUBMIT_SEND_BOX = 'WEB_CHAT/SUBMIT_SEND_BOX'; -export default function submitSendBox(method = 'keyboard', { channelData } = {}) { +export default function submitSendBox(method = 'keyboard', { channelData } = { channelData: undefined }) { return { type: SUBMIT_SEND_BOX, payload: { channelData, method } diff --git a/packages/core/src/actions/updateConnectionStatus.js b/packages/core/src/actions/updateConnectionStatus.ts similarity index 100% rename from packages/core/src/actions/updateConnectionStatus.js rename to packages/core/src/actions/updateConnectionStatus.ts diff --git a/packages/core/src/createPromiseQueue.js b/packages/core/src/createPromiseQueue.js index 5fb3c93cbb..e5b3fd920c 100644 --- a/packages/core/src/createPromiseQueue.js +++ b/packages/core/src/createPromiseQueue.js @@ -1,4 +1,4 @@ -import withResolvers from './utils/withResolvers'; +import { withResolvers } from 'botframework-webchat-base/utils'; export default function createPromiseQueue() { let promiseWithResolvers; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 93551bf91a..2eb76a2da6 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,3 +1,5 @@ +import { withResolvers, type PromiseWithResolvers } from 'botframework-webchat-base/utils'; + import clearSuggestedActions from './actions/clearSuggestedActions'; import connect from './actions/connect'; import disconnect from './actions/disconnect'; @@ -43,7 +45,6 @@ import isForbiddenPropertyName from './utils/isForbiddenPropertyName'; import onErrorResumeNext from './utils/onErrorResumeNext'; import singleToArray from './utils/singleToArray'; import warnOnce from './utils/warnOnce'; -import withResolvers, { type PromiseWithResolvers } from './utils/withResolvers'; import type { GlobalScopePonyfill } from './types/GlobalScopePonyfill'; import type { SendBoxAttachment } from './types/SendBoxAttachment'; diff --git a/packages/core/src/tsconfig.json b/packages/core/src/tsconfig.json index 2631d90ba9..2046a9792d 100644 --- a/packages/core/src/tsconfig.json +++ b/packages/core/src/tsconfig.json @@ -1,19 +1,12 @@ { "compilerOptions": { "allowSyntheticDefaultImports": true, - "declaration": true, - "declarationDir": "../lib", - "declarationMap": true, - "downlevelIteration": true, - "emitDeclarationOnly": true, "jsx": "react", "module": "ESNext", "moduleResolution": "Bundler", - "preserveWatchOutput": true, - "pretty": true, + "noEmit": true, "resolveJsonModule": true, // Required for localization files "skipLibCheck": true, - "sourceMap": true, "target": "ESNext" }, "files": ["index.ts"] diff --git a/packages/core/src/utils/getOrgSchemaMessage.ts b/packages/core/src/utils/getOrgSchemaMessage.ts index e751aac8bc..69308575ee 100644 --- a/packages/core/src/utils/getOrgSchemaMessage.ts +++ b/packages/core/src/utils/getOrgSchemaMessage.ts @@ -2,9 +2,9 @@ import { type WebChatActivity } from '../types/WebChatActivity'; import { parseCreativeWork, type CreativeWork } from '../types/external/OrgSchema/CreativeWork'; import { parseThing } from '../types/external/OrgSchema/Thing'; -export default function getOrgSchemaMessage( - graph: readonly WebChatActivity['entities'][0][] -): CreativeWork | undefined { +type EntityType = NonNullable[number]; + +export default function getOrgSchemaMessage(graph: readonly EntityType[]): CreativeWork | undefined { const messageEntity = (graph || []).find(entity => { const isThing = entity.type?.startsWith('https://schema.org/'); diff --git a/packages/core/tsup.config.ts b/packages/core/tsup.config.ts index b420a3920a..50741e1df5 100644 --- a/packages/core/tsup.config.ts +++ b/packages/core/tsup.config.ts @@ -5,5 +5,6 @@ export default defineConfig({ ...baseConfig, entry: { 'botframework-webchat-core': './src/index.ts' - } + }, + format: ['esm', 'cjs'] }); diff --git a/packages/fluent-theme/package.json b/packages/fluent-theme/package.json index 9bfbe0d92a..6ed20451aa 100644 --- a/packages/fluent-theme/package.json +++ b/packages/fluent-theme/package.json @@ -52,9 +52,10 @@ }, "localDependencies": { "botframework-webchat-api": "production", + "botframework-webchat-base": "development", "botframework-webchat-component": "production", "botframework-webchat-core": "production", - "botframework-webchat-styles": "production" + "botframework-webchat-styles": "development" }, "pinDependencies": { "@types/react": [ @@ -67,6 +68,8 @@ "@types/math-random": "^1.0.2", "@types/node": "^20.12.11", "@types/react": "^16.14.60", + "botframework-webchat-base": "0.0.0-0", + "botframework-webchat-styles": "0.0.0-0", "tsup": "^8.0.2", "typescript": "^5.4.5" }, @@ -74,7 +77,6 @@ "botframework-webchat-api": "0.0.0-0", "botframework-webchat-component": "0.0.0-0", "botframework-webchat-core": "0.0.0-0", - "botframework-webchat-styles": "0.0.0-0", "classnames": "2.5.1", "inject-meta-tag": "0.0.1", "math-random": "2.0.1", diff --git a/packages/styles/package.json b/packages/styles/package.json index 7d8e79e8cb..56a6f5070e 100644 --- a/packages/styles/package.json +++ b/packages/styles/package.json @@ -55,11 +55,13 @@ "./src/**/*", "*.js" ], + "localDependencies": { + "botframework-webchat-base": "development" + }, "homepage": "https://github.com/microsoft/BotFramework-WebChat/tree/main/packages/styles#readme", "scripts": { - "build": "npm run build:tsup && npm run build:typescript", + "build": "npm run build:tsup", "build:tsup": "tsup --config ./tsup.config.ts", - "build:typescript": "tsc --project src/tsconfig.json", "bump": "npm run bump:prod && npm run bump:dev && (npm audit fix || exit 0)", "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", "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", @@ -77,6 +79,7 @@ "@jridgewell/sourcemap-codec": "^1.4.15", "@tsconfig/strictest": "^2.0.5", "@types/node": "^20.10.3", + "botframework-webchat-base": "0.0.0-0", "cross-env": "^7.0.3", "type-fest": "^4.14.0", "typescript": "^5.3.2"