Skip to content

Commit

Permalink
Merge branch 'johnsle/update_caller_interface' of https://github.com/…
Browse files Browse the repository at this point in the history
…OfficeDev/microsoft-teams-library-js into johnsle/update_caller_interface
  • Loading branch information
MSJohnnyLee committed Sep 30, 2024
2 parents be248cd + 9c931e1 commit 7894fd5
Show file tree
Hide file tree
Showing 71 changed files with 2,335 additions and 660 deletions.
9 changes: 8 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"cSpell.words": ["adal", "ipados", "teamspace", "uninitialize", "xvfb"],
"cSpell.words": ["adal", "frameless", "ipados", "teamsjs", "teamspace", "uninitialize", "xvfb"],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.workingDirectories": [
"./apps/ssr-test-app/",
"./apps/teams-perf-test-app",
"./apps/teams-test-app/",
"./apps/typed-dependency-tester/",
"./packages/teams-js/"
],
"editor.formatOnSave": true,
"editor.insertSpaces": true,
"editor.tabSize": 2,
Expand Down
2 changes: 1 addition & 1 deletion apps/blazor-test-app/Blazor-Test-App.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion apps/blazor-test-app/global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": ">=7.0.14"
"version": ">=8.0.4"
}
}
4 changes: 2 additions & 2 deletions apps/teams-test-app/index_cdn.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script
src="https://res.cdn.office.net/teams-js/2.26.0/js/MicrosoftTeams.min.js"
integrity="sha384-gqPg5qCjdUgTGRZ/stLskrnJllL5h5+f4kTqvxVqtl2FdT7PVRa9Q7zq4gFlZ7bO"
src="https://res.cdn.office.net/teams-js/2.28.0/js/MicrosoftTeams.min.js"
integrity="sha384-gT2igbByugSUPXBgDA+rtfKk4JMSCfG+3DKSivyLqF2Riv4vTLqaC/tFpySw0eIM"
crossorigin="anonymous"
></script>
<div id="root"></div>
Expand Down
4 changes: 2 additions & 2 deletions apps/teams-test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"private": true,
"author": "Microsoft Teams",
"description": "Teams Test App utilizing Teams JavaScript client SDK to test Hosts",
"version": "2.26.0",
"version": "2.28.0",
"scripts": {
"build": "pnpm build:bundle",
"build:bundle": "pnpm lint && webpack",
"build:CDN": "pnpm lint && webpack --config webpack.cdn.config.js",
"build:local": "pnpm lint && webpack --config webpack.local.config.js && pnpm copy",
"clean": "rimraf ./build",
"copy": "shx cp ../../packages/teams-js/dist/MicrosoftTeams.min.js ./build/ && shx cp ../../packages/teams-js/dist/MicrosoftTeams.min.js.map ./build/",
"copy": "shx cp ../../packages/teams-js/dist/umd/MicrosoftTeams.min.js ./build/ && shx cp ../../packages/teams-js/dist/umd/MicrosoftTeams.min.js.map ./build/",
"lint": "pnpm eslint ./src --max-warnings 0 --fix --ext .tsx",
"start": "pnpm start:bundle",
"start:bundle": "webpack serve",
Expand Down
4 changes: 2 additions & 2 deletions apps/teams-test-app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { BrowserRouter, Route, Routes } from 'react-router-dom';

import { isTestBackCompat } from './components/utils/isTestBackCompat';
import { SecondRoute } from './pages/SecondRoute';
import { TestApp } from './pages/TestApp';
import { appInitializationTestQueryParameter, TestApp } from './pages/TestApp';

const urlParams = new URLSearchParams(window.location.search);

Expand All @@ -29,7 +29,7 @@ if (!urlParams.has('customInit') || !urlParams.get('customInit')) {
// we do it by adding appInitializationTest=true to query string
if (
(urlParams.has('customInit') && urlParams.get('customInit')) ||
(urlParams.has('appInitializationTest') && urlParams.get('appInitializationTest'))
(urlParams.has(appInitializationTestQueryParameter) && urlParams.get(appInitializationTestQueryParameter))
) {
console.info('Not calling appInitialization because part of App Initialization Test run');
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { externalAppCardActions } from '@microsoft/teams-js';
import { externalAppCardActions, IAdaptiveCardActionSubmit } from '@microsoft/teams-js';
import React from 'react';

import { ApiWithoutInput, ApiWithTextInput } from '../utils';
Expand All @@ -15,7 +15,7 @@ const CheckExternalAppCardActionsCapability = (): React.ReactElement =>
const ProcessActionSubmit = (): React.ReactElement =>
ApiWithTextInput<{
appId: string;
actionSubmitPayload: externalAppCardActions.IAdaptiveCardActionSubmit;
actionSubmitPayload: IAdaptiveCardActionSubmit;
}>({
name: 'processActionSubmit',
title: 'Process Action Submit',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { AppId, externalAppCardActionsForCEA, IAdaptiveCardActionSubmit } from '@microsoft/teams-js';
import React from 'react';

import { ApiWithoutInput, ApiWithTextInput } from '../utils';
import { ModuleWrapper } from '../utils/ModuleWrapper';

const CheckExternalAppCardActionsForCEACapability = (): React.ReactElement =>
ApiWithoutInput({
name: 'checkExternalAppCardActionsForCEACapability',
title: 'Check External App Card Actions For CEA Capability',
onClick: async () =>
`External App Card Actions For CEA module ${
externalAppCardActionsForCEA.isSupported() ? 'is' : 'is not'
} supported`,
});

const CECProcessActionSubmit = (): React.ReactElement =>
ApiWithTextInput<{
appId: AppId;
conversationId: string;
actionSubmitPayload: IAdaptiveCardActionSubmit;
}>({
name: 'processActionSubmitForCEA',
title: 'Process Action Submit For CEA',
onClick: {
validateInput: (input) => {
if (!input.appId) {
throw new Error('appId is required');
}
if (!input.actionSubmitPayload) {
throw new Error('actionSubmitPayload is required');
}
},
submit: async (input) => {
await externalAppCardActionsForCEA.processActionSubmit(
input.appId,
input.conversationId,
input.actionSubmitPayload,
);
return 'Completed';
},
},
defaultInput: JSON.stringify({
appId: 'b7f8c0a0-6c1d-4a9a-9c0a-2c3f1c0a3b0a',
actionSubmitPayload: {
id: 'submitId',
data: 'data1',
},
}),
});

const CECProcessActionOpenUrl = (): React.ReactElement =>
ApiWithTextInput<{
appId: AppId;
conversationId: string;
url: string;
}>({
name: 'processActionOpenUrlForCEA',
title: 'Process Action Open Url For CEA',
onClick: {
validateInput: (input) => {
if (!input.appId) {
throw new Error('appId is required');
}
if (!input.url) {
throw new Error('url is required');
}
},
submit: async (input) => {
const result = await externalAppCardActionsForCEA.processActionOpenUrl(
input.appId,
input.conversationId,
new URL(input.url),
);
return JSON.stringify(result);
},
},
defaultInput: JSON.stringify({
appId: 'b7f8c0a0-6c1d-4a9a-9c0a-2c3f1c0a3b0a',
url: 'https://www.example.com',
}),
});

const ExternalAppCardActionsForCEAAPIs = (): React.ReactElement => (
<ModuleWrapper title="External App Card Actions For CEA">
<CheckExternalAppCardActionsForCEACapability />
<CECProcessActionSubmit />
<CECProcessActionOpenUrl />
</ModuleWrapper>
);

export default ExternalAppCardActionsForCEAAPIs;
22 changes: 22 additions & 0 deletions apps/teams-test-app/src/pages/TestApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import ChatAPIs from '../components/privateApis/ChatAPIs';
import CopilotAPIs from '../components/privateApis/CopilotAPIs';
import ExternalAppAuthenticationAPIs from '../components/privateApis/ExternalAppAuthenticationAPIs';
import ExternalAppCardActionsAPIs from '../components/privateApis/ExternalAppCardActionsAPIs';
import ExternalAppCardActionsForCEAAPIs from '../components/privateApis/ExternalAppCardActionsForCEAAPIs';
import ExternalAppCommandsAPIs from '../components/privateApis/ExternalAppCommandsAPIs';
import FilesAPIs from '../components/privateApis/FilesAPIs';
import FullTrustAPIs from '../components/privateApis/FullTrustAPIs';
Expand All @@ -66,12 +67,32 @@ import VideoAPIs from '../components/VideoEffectsApis';
import VisualMediaAPIs from '../components/VisualMediaAPIs';
import WebStorageAPIs from '../components/WebStorageAPIs';

export const appInitializationTestQueryParameter = 'appInitializationTest';

export const TestApp: React.FC = () => {
const dialogWindowRef = React.useRef<IAppWindow | null>(null);
const [iframeUrl, setIframeUrl] = React.useState<URL | null>(null);

const loadCurrentUrl = (): void => {
setIframeUrl(new URL(window.location.href + `?${appInitializationTestQueryParameter}=true`));
};

return (
<>
<button id="button_reload" onClick={() => window.location.reload()}>
Reload This App
</button>
<button id="button_iframe" onClick={loadCurrentUrl}>
Load Current URL in child Iframe for initialization testing
</button>
<div className="App-container">
{iframeUrl !== null && (
<div>
IFRAME: <br></br>
{/*eslint-disable-next-line @microsoft/sdl/react-iframe-missing-sandbox -- always use the sandbox attribute, but this is a test app and we fully control the content going into it, so it's okay not to here. */}
<iframe src={iframeUrl.toString()} width="100%" height="500px" />
</div>
)}
<AppAPIs />
<AppInitializationAPIs />
<AppInstallDialogAPIs />
Expand All @@ -94,6 +115,7 @@ export const TestApp: React.FC = () => {
<DialogUrlParentCommunicationAPIs childWindowRef={dialogWindowRef} />
<ExternalAppAuthenticationAPIs />
<ExternalAppCardActionsAPIs />
<ExternalAppCardActionsForCEAAPIs />
<ExternalAppCommandsAPIs />
<FilesAPIs />
<FullTrustAPIs />
Expand Down
26 changes: 26 additions & 0 deletions apps/tree-shaking-test-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "tree-shaking-test-app",
"private": true,
"author": "Noah",
"description": "Test app to test the tree-shakability of TeamsJS",
"version": "0.0.1",
"main": "index.ts",
"type": "module",
"scripts": {
"build-rollup": "pnpm clean && rollup --c",
"build-webpack": "webpack",
"clean": "rimraf ./dist"
},
"dependencies": {
"@microsoft/teams-js": "workspace:*"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-typescript": "^11.1.6",
"@rollup/plugin-terser": "0.4.4",
"rollup": "^4.18.0",
"webpack": "^5.18.0",
"webpack-cli": "^4.3.1",
"testlibraryfortreeshaking": "^1.0.24"
}
}
28 changes: 28 additions & 0 deletions apps/tree-shaking-test-app/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';

// rollup.config.mjs
export default {
input: 'src/index.ts',
output: [
{
file: 'dist/bundle.js',
format: 'es',
sourcemap: true,
},
{
file: 'dist/bundle.min.js',
format: 'es',
plugins: [terser()],
sourcemap: true,
},
],
plugins: [
nodeResolve({
extension: ['.js', '.ts', '.d.ts', '.json'],
}),
typescript(),
],
treeshake: true,
};
5 changes: 5 additions & 0 deletions apps/tree-shaking-test-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { barCode } from 'testlibraryfortreeshaking';
import { geoLocation } from '@microsoft/teams-js';
barCode.hasPermission();
geoLocation.requestPermission();
geoLocation.map.isSupported();
28 changes: 28 additions & 0 deletions apps/tree-shaking-test-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"esModuleInterop": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "es6",
"moduleResolution": "node",
"resolveJsonModule": true,
"jsx": "react",
"sourceMap": true,
"outDir": "./dist"
},
"include": ["src"],
"exclude": [
"**/build/*",
"build",
"node_modules",
"**/*.test.*",
"webpack.config.js",
"webpack.cdn.config.js",
"webpack.cdnV1.config.js",
"webpack.local.config.js"
]
}
30 changes: 30 additions & 0 deletions apps/tree-shaking-test-app/webpack.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* eslint @typescript-eslint/no-var-requires: off*/
/* eslint-disable no-undef */
const path = require('path');

module.exports = {
entry: './src/index.ts',
output: {
filename: 'index.js',
path: path.resolve(__dirname, 'dist'),
},
mode: 'development',
optimization: {
usedExports: true,
innerGraph: true,
sideEffects: false,
},
devtool: false,
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
};
2 changes: 1 addition & 1 deletion apps/typed-dependency-tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "0.0.1",
"scripts": {
"build": "pnpm i && pnpm copy && pnpm tsc && pnpm clean",
"copy": "cp ./node_modules/@microsoft/teams-js/dist/MicrosoftTeams.d.ts ./ || xcopy .\\node_modules\\@microsoft\\teams-js\\dist\\MicrosoftTeams.d.ts .\\ /Y",
"copy": "cp ./node_modules/@microsoft/teams-js/dist/umd/MicrosoftTeams.d.ts ./ || xcopy .\\node_modules\\@microsoft\\teams-js\\dist\\umd\\MicrosoftTeams.d.ts .\\ /Y",
"clean": "rimraf node_modules && rimraf MicrosoftTeams.d.ts"
},
"dependencies": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"type": "minor",
"comment": "Added new `AppId` class to use as a type where app ids are being stored",
"comment": "Added logging for version on startup",
"packageName": "@microsoft/teams-js",
"email": "[email protected]",
"dependentChangeType": "patch"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Updated `pages.navigateToApp` to now optionally accept a more type-safe input object",
"packageName": "@microsoft/teams-js",
"email": "[email protected]",
"dependentChangeType": "patch"
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Added APIs for `externalAppCardActionsForCEA` capability.",
"packageName": "@microsoft/teams-js",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Loading

0 comments on commit 7894fd5

Please sign in to comment.