Skip to content

chore: migrate directlinespeech to tsup #5434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,336 changes: 326 additions & 1,010 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 5 additions & 16 deletions packages/directlinespeech/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"description": "Direct Line Speech SDK",
"files": [
"./dist/**/*",
"./lib/**/*",
"./src/**/*"
"./src/**/*",
"./*.js"
],
"main": "./lib/index.js",
"main": "./dist/botframework-directlinespeech-sdk.js",
"exports": {
".": {
"import": {
Expand All @@ -21,12 +21,8 @@
}
},
"scripts": {
"build": "npm run build:tsup && npm run build:babel && npm run build:webpack",
"build:babel": "cross-env build_tool=babel module_format=commonjs babel src --ignore **/*.spec.js,**/*.test.js,__tests__/**/*.js --out-dir lib --verbose",
"build": "npm run build:tsup",
"build:tsup": "tsup --config ./tsup.config.ts",
"build:webpack": "npm run build:webpack:development && npm run build:webpack:production",
"build:webpack:development": "cross-env node_env=development webpack-cli",
"build:webpack:production": "cross-env node_env=production 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",
"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",
Expand All @@ -37,10 +33,8 @@
"prettier": "prettier --check src/**/*.{js,ts}",
"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:serve": "serve",
"start:tsup": "npm run build:tsup -- --watch",
"start:webpack": "npm run build:webpack:development -- --watch",
"test": "jest --watch"
},
"author": "Microsoft Corporation",
Expand Down Expand Up @@ -104,15 +98,10 @@
"prettier": "^3.5.1",
"serve": "^14.2.4",
"simple-update-in": "^2.2.0",
"source-map-loader": "^5.0.0",
"webpack": "^5.98.0",
"webpack-cli": "^6.0.1",
"webpack-stats-plugin": "^1.1.3"
"source-map-loader": "^5.0.0"
},
"dependencies": {
"@babel/runtime": "7.19.0",
"abort-controller": "3.0.0",
"abort-controller-es5": "2.0.1",
"base64-arraybuffer": "1.0.2",
"core-js": "3.40.0",
"core-js-pure": "3.40.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import Observable from 'core-js/features/observable/index.js';
import random from 'math-random';

import shareObservable from './shareObservable';
import SpeechSynthesisAudioStreamUtterance from './SpeechSynthesisAudioStreamUtterance';
import shareObservable from './shareObservable.mjs';
import SpeechSynthesisAudioStreamUtterance from './SpeechSynthesisAudioStreamUtterance.mjs';

function randomActivityId() {
return random().toString(36).substr(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import {
PropertyId
} from 'microsoft-cognitiveservices-speech-sdk';

import createWebSpeechPonyfillFactory from './createWebSpeechPonyfillFactory';
import DirectLineSpeech from './DirectLineSpeech';
import patchDialogServiceConnectorInline from './patchDialogServiceConnectorInline';
import refreshDirectLineToken from './utils/refreshDirectLineToken';
import resolveFunctionOrReturnValue from './resolveFunctionOrReturnValue';
import createWebSpeechPonyfillFactory from './createWebSpeechPonyfillFactory.mjs';
import DirectLineSpeech from './DirectLineSpeech.mjs';
import patchDialogServiceConnectorInline from './patchDialogServiceConnectorInline.mjs';
import refreshDirectLineToken from './utils/refreshDirectLineToken.mjs';
import resolveFunctionOrReturnValue from './resolveFunctionOrReturnValue.mjs';

const DIRECT_LINE_TOKEN_RENEWAL_INTERVAL = 900000; // 15 minutes
const TOKEN_RENEWAL_INTERVAL = 120000;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import withResolvers from './utils/withResolvers';
import withResolvers from './utils/withResolvers.mjs';

export default function createTaskQueue() {
let queueWithCurrent = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint class-methods-use-this: ["error", { "exceptMethods": ["cancel", "getVoices", "speak"] }] */

import { AbortController } from 'abort-controller-es5';
import { AbortController } from 'abort-controller';
import { createSpeechRecognitionPonyfillFromRecognizer } from 'web-speech-cognitive-services';

import createTaskQueue from './createTaskQueue';
import createTaskQueue from './createTaskQueue.mjs';
import EventTarget, { Event, getEventAttributeValue, setEventAttributeValue } from 'event-target-shim';
import playCognitiveServicesStream from './playCognitiveServicesStream';
import playWhiteNoise from './playWhiteNoise';
import SpeechSynthesisAudioStreamUtterance from './SpeechSynthesisAudioStreamUtterance';
import playCognitiveServicesStream from './playCognitiveServicesStream.mjs';
import playWhiteNoise from './playWhiteNoise.mjs';
import SpeechSynthesisAudioStreamUtterance from './SpeechSynthesisAudioStreamUtterance.mjs';

export default function ({
audioContext,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global process:readonly */
import 'core-js/features/object/entries.js';

import createAdapters from './createAdapters';
import createAdapters from './createAdapters.mjs';

const buildTool = process.env.build_tool;
const moduleFormat = process.env.module_format;
Expand All @@ -27,3 +27,11 @@ if (typeof HTMLDocument !== 'undefined' && typeof document !== 'undefined' && do

document.head.appendChild(packageMeta);
}

if (moduleFormat === 'global') {
window.DirectLineSpeech = Object.freeze({
...window.DirectLineSpeech,
buildInfo,
createAdapters
});
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import withResolvers from './utils/withResolvers';
import withResolvers from './utils/withResolvers.mjs';

// Patching a function to add pre-processing of arguments and post-processing of result.
function patchFunction(fn, pre, post) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint no-await-in-loop: "off" */
/* eslint prefer-destructuring: "off" */

import createMultiBufferingPlayer from './createMultiBufferingPlayer';
import createMultiBufferingPlayer from './createMultiBufferingPlayer.mjs';

// Safari requires an audio buffer with a sample rate of 22050 Hz.
// Using a minimum sample rate of 44100 Hz as an example, the Speech SDK's default 16000 Hz will be upsampled to 48000 Hz.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fetchJSON from './fetchJSON';
import fetchJSON from './fetchJSON.mjs';

// Refreshes the given token
export default async function refreshDirectLineToken(token) {
Expand Down
21 changes: 20 additions & 1 deletion packages/directlinespeech/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const resolveCognitiveServicesToES2015 = {
const config: typeof baseConfig = {
...baseConfig,
entry: {
'botframework-directlinespeech-sdk': './src/index.js'
'botframework-directlinespeech-sdk': './src/index.mjs'
},
env: {
...baseConfig.env,
Expand All @@ -40,5 +40,24 @@ export default defineConfig([
...config,
format: 'cjs',
target: [...config.target, 'es2019']
},
{
...config,
dts: false,
entry: {
[process.env.NODE_ENV === 'production' ? 'directlinespeech.production.min' : 'directlinespeech.development']:
'./src/index.mjs'
},
env: {
...config.env,
module_format: 'global'
},
esbuildPlugins: [],
format: 'iife',
outExtension() {
return { js: '.js' };
},
platform: 'browser',
target: [...config.target, 'es2019']
}
]);
48 changes: 0 additions & 48 deletions packages/directlinespeech/webpack.config.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"@types/node": "^22.13.4",
"botframework-webchat-base": "0.0.0-0",
"cross-env": "^7.0.3",
"esbuild": "^0.25.1",
"type-fest": "^4.34.1",
"typescript": "^5.7.3"
},
Expand Down
Loading