diff --git a/LICENSE.md b/LICENSE.md index fdbf1d8..85564f3 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -Copyright (c) 2021 Zoom Video Communications, Inc. +Copyright (c) 2022 Zoom Video Communications, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index b2f4cd2..52bb48a 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,12 @@ Alternatively, you can load the SDK from a CDN, using a script tag in your HTML ``` +You can also load a minified SDK, using a script tag in your HTML document: + +``` + +``` + ## Usage If you installed Zoom Apps SDK from NPM, import `zoomSdk` into the component where you wanted to use the SDK and call `config` as your first call to verify your application with Zoom. @@ -116,6 +122,10 @@ sendAppInvitation ({ participantUUIDs: [participantUUID1, participantUUID2, ...] Refer to Apps SDK documentation [here](https://marketplace.zoom.us/docs/zoom-apps/js-sdk/reference). +## Release notes + +Refer to [release notes](https://github.com/zoom/appssdk/releases) to discover changes made in the Apps SDK. + ## Resources to create a Zoom App - Create your first Zoom App following these [steps](https://marketplace.zoom.us/docs/zoom-apps/getstarted). diff --git a/dist/sdk.d.ts b/dist/sdk.d.ts index a1fe261..8cb1d32 100644 --- a/dist/sdk.d.ts +++ b/dist/sdk.d.ts @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021 Zoom Video Communications, Inc. + * Copyright (c) 2022 Zoom Video Communications, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -751,7 +751,7 @@ declare type GetMeetingContextResponse = { meetingTopic: string; meetingID: string; }; -declare type Apis = 'addBreakoutRoom' | 'allowParticipantToRecord' | 'assignParticipantsToBreakoutRoom' | 'assignParticipantToBreakoutRoom' | 'authorize' | 'changeBreakoutRoom' | 'clearImage' | 'clearParticipant' | 'clearWebView' | 'closeBreakoutRooms' | 'closeChannel' | 'closeLobby' | 'closeRenderingContext' | 'cloudRecording' | 'configureBreakoutRooms' | 'connect' | 'createBreakoutRooms' | 'deleteBreakoutRoom' | 'drawImage' | 'drawParticipant' | 'drawWebView' | 'endCollaborate' | 'endSyncData' | 'executeOnZoomAction' | 'expandApp' | 'getBreakoutRoomList' | 'getImmersiveViewContext' | 'getMeetingContext' | 'getMeetingJoinUrl' | 'getMeetingParticipants' | 'getMeetingUUID' | 'getMyOpenedAppList' | 'getOnZoomProperties' | 'getPairingStatus' | 'getRecordingContext' | 'getRunningContext' | 'getScreenshot' | 'getSupportedJsApis' | 'getUserContext' | 'getUserMediaAudio' | 'getUserMediaVideo' | 'joinCollaborate' | 'joinOnZoomEvent' | 'joinZoomRoom' | 'launchAppInMeeting' | 'leaveCollaborate' | 'listCameras' | 'onActiveSpeakerChange' | 'onAppPopout' | 'onAuthenticate' | 'onAuthorized' | 'onBreakoutRoomChange' | 'onCloseAppForParticipants' | 'onCloudRecording' | 'onCollaborateChange' | 'onConnect' | 'onExpandApp' | 'onExtendedProcessing' | 'onImmersiveViewChange' | 'onMeeting' | 'onMeetingConfigChanged' | 'onMessage' | 'onMyActiveSpeakerChange' | 'onMyAppListChanged' | 'onMyMediaChange' | 'onMyReaction' | 'onMyUserContextChange' | 'onOnZoomJoinStatusChange' | 'onOpenCloseApp' | 'onPairingStatusChange' | 'onParticipantChange' | 'onReaction' | 'onRunningContextChange' | 'onSendAppInvitation' | 'onShareApp' | 'onThemeModeChange' | 'onUserAction' | 'openApp' | 'openBreakoutRooms' | 'openChannel' | 'openDM' | 'openUrl' | 'postMessage' | 'promptAuthorize' | 'pushState' | 'removeImmersiveView' | 'removeVirtualBackground' | 'removeVirtualForeground' | 'renameBreakoutRoom' | 'runRenderingContext' | 'sendAppInvitation' | 'sendAppInvitationToAllParticipants' | 'sendAppInvitationToMeetingOwner' | 'setAuthCancel' | 'setAuthResult' | 'setCamera' | 'setImmersiveView' | 'setUserMediaAudio' | 'setUserMediaVideo' | 'setVideoMirrorEffect' | 'setVirtualBackground' | 'setVirtualForeground' | 'shareApp' | 'showAppInvitationDialog' | 'showNotification' | 'startCollaborate' | 'toggleParticipantMediaAudio' | 'onInviteCollaboration'; +declare type Apis = 'addBreakoutRoom' | 'allowParticipantToRecord' | 'assignParticipantsToBreakoutRoom' | 'assignParticipantToBreakoutRoom' | 'authorize' | 'changeBreakoutRoom' | 'clearImage' | 'clearParticipant' | 'clearWebView' | 'closeBreakoutRooms' | 'closeChannel' | 'closeLobby' | 'closeRenderingContext' | 'cloudRecording' | 'configureBreakoutRooms' | 'connect' | 'createBreakoutRooms' | 'deleteBreakoutRoom' | 'drawImage' | 'drawParticipant' | 'drawWebView' | 'endCollaborate' | 'endSyncData' | 'executeOnZoomAction' | 'expandApp' | 'getBreakoutRoomList' | 'getImmersiveViewContext' | 'getMeetingContext' | 'getMeetingJoinUrl' | 'getMeetingParticipants' | 'getMeetingUUID' | 'getOnZoomProperties' | 'getPairingStatus' | 'getRecordingContext' | 'getRunningContext' | 'getScreenshot' | 'getSupportedJsApis' | 'getUserContext' | 'getUserMediaAudio' | 'getUserMediaVideo' | 'joinCollaborate' | 'joinOnZoomEvent' | 'joinZoomRoom' | 'launchAppInMeeting' | 'leaveCollaborate' | 'listCameras' | 'onActiveSpeakerChange' | 'onAppPopout' | 'onAuthenticate' | 'onAuthorized' | 'onBreakoutRoomChange' | 'onCloseAppForParticipants' | 'onCloudRecording' | 'onCollaborateChange' | 'onConnect' | 'onExpandApp' | 'onExtendedProcessing' | 'onImmersiveViewChange' | 'onMeeting' | 'onMeetingConfigChanged' | 'onMessage' | 'onMyActiveSpeakerChange' | 'onMyMediaChange' | 'onMyReaction' | 'onMyUserContextChange' | 'onOnZoomJoinStatusChange' | 'onPairingStatusChange' | 'onParticipantChange' | 'onReaction' | 'onRunningContextChange' | 'onSendAppInvitation' | 'onShareApp' | 'onThemeModeChange' | 'openBreakoutRooms' | 'openChannel' | 'openDM' | 'openUrl' | 'postMessage' | 'promptAuthorize' | 'pushState' | 'removeImmersiveView' | 'removeVirtualBackground' | 'removeVirtualForeground' | 'renameBreakoutRoom' | 'runRenderingContext' | 'sendAppInvitation' | 'sendAppInvitationToAllParticipants' | 'sendAppInvitationToMeetingOwner' | 'setCamera' | 'setImmersiveView' | 'setUserMediaAudio' | 'setUserMediaVideo' | 'setVideoMirrorEffect' | 'setVirtualBackground' | 'setVirtualForeground' | 'shareApp' | 'showAppInvitationDialog' | 'showNotification' | 'startCollaborate' | 'toggleParticipantMediaAudio' | 'onInviteCollaboration'; /** * Example: * ``` @@ -1018,16 +1018,27 @@ declare type LaunchAppInMeetingOptions = { */ /** `"immersive"` to fill the entire meeting canvas, or `"camera"` to affect only the user's video stream. */ declare type RenderingContextView = 'immersive' | 'camera'; -/** The cutout behavior of `drawParticipant()`: `"person"` says to cut out backgrounds, or `"rectangle"` says to display their full video rectangle.*/ -declare type RenderingContextCutout = 'person' | 'rectangle'; +/** The cutout behavior of `drawParticipant()`: + * + * _Introduced in client version 5.11.3_: + * - `"person"`: Cut out the participant's background + * - `"rectangle"`: Crop the participant's video into a rectangle with rounded corners + * + * _Additional shapes added in client version 5.11.6_: + * - `"standard"`: Display the participant's full uncropped video + * - `"circle"`: Crop the participant's video into a circle + * - `"square"`: Crop the participant's video into a square with rounded corners + * - `"verticalRectangle"`: Crop the participant's video into a vertical rectangle with rounded corners + */ +declare type ParticipantCutoutShape = 'person' | 'standard' | 'rectangle' | 'circle' | 'square' | 'verticalRectangle'; /** * @category Core Endpoints */ declare type RunRenderingContextOptions = { /** `"immersive"` to fill the entire meeting canvas, or `"camera"` to affect only the user's video stream. */ view?: RenderingContextView; - /** The default cutout behavior of `drawParticipant()`: `"person"` says to cut out backgrounds, or `"rectangle"` says to display their full video rectangle.*/ - defaultCutout?: RenderingContextCutout; + /** The default cutout behavior of `drawParticipant()`: `"person"` means cut out the background; other shapes mean crop the participant's video into the named shape */ + defaultCutout?: ParticipantCutoutShape; }; /** * Pixel-related values: @@ -1060,6 +1071,10 @@ declare type DrawParticipantOptions = { height?: PixelValue; /** The relative z-ordering of the item (Default: 1). */ zIndex?: number; + /** The cutout behavior: `"person"` means cut out the background; other shapes mean crop the participant's video into the named shape. + * Introduced in client version 5.11.3. Additional shapes added in client version 5.11.6. + */ + cutout?: ParticipantCutoutShape; }; /** * @category Core Endpoints @@ -1152,8 +1167,10 @@ declare type OnRenderedAppOpenedEvent = { timestamp: number; /** The rendered app's view type: `"immersive"` filling the entire meeting canvas, or `"camera"` affecting only the user's video stream. */ view: RenderingContextView; - /** The default cutout behavior of `drawParticipant()`: `"person"` says to cut out backgrounds, or `"rectangle"` says to display their full video rectangle.*/ - defaultCutout?: RenderingContextCutout; + /** The default cutout behavior of `drawParticipant()`: `"person"` means cut out the background; other shapes mean crop the participant's video into the named shape. + * Introduced in client version 5.11.3. Additional shapes added in client version 5.11.6. + */ + defaultCutout?: ParticipantCutoutShape; /** The rendered app was opened as the result of an invitation */ byInvitation?: boolean; }; @@ -1351,8 +1368,12 @@ declare type GetUserMediaAudioResponse = { declare type ToggleParticipantMediaAudioOptions = { /** mute or unmute participants. true = unmute, false = mute */ audio: boolean; - /** Target participants with specified ParticipantUUIDs. If list is empty, all participants are muted or unmuted based on the action specified. Maximum 10 participantIDs. For more than 10, use mute/unmute all. You can use getMeetingParticipants to get a list of meeting participants.*/ - participants: string[]; + /** use participantUUID instead of participantId + * @deprecated + */ + participants?: string[]; + /** Target participants with specified participantUUIDs. If list is empty, all participants are muted or unmuted based on the action specified. Maximum 10 participantUUIDs. For more than 10, use mute/unmute all. You can use getMeetingParticipants to get a list of meeting participants. */ + participantUUIDs?: string[]; }; /** * # Zoom Apps SDK @@ -1469,6 +1490,10 @@ declare type ToggleParticipantMediaAudioOptions = { * sendAppInvitation ({ participantUUIDs: [participantUUID1, participantUUID2, ...], message: ""}) * ``` * + * ## Release notes + * + * Refer to [release notes](https://github.com/zoom/appssdk/releases) to discover changes made in the Apps SDK. + * * ## Resources to create a Zoom App * * - Create your first Zoom App following these [steps](https://marketplace.zoom.us/docs/zoom-apps/getstarted). @@ -1583,7 +1608,7 @@ declare class ZoomSdk { * await zoomSdk.openUrl({ url: "https://awesome-zoom-app.com/login" }); * ``` * - * *You must whitelist the URL's domain in your Marketplace app configuration before it can be called with this API.* + * *You must whitelist the URL's domain in your Marketplace app configuration, otherwise the browser will show a warning "Accessing Untrusted Web Site". And the user has to manually click the link to trigger marketplace to redirect them to the specified url.* * * @category Core Endpoints */ @@ -1956,11 +1981,8 @@ declare class ZoomSdk { * await zoomSdk.launchAppInMeeting({ joinURL: 'xxx' }) * ``` * - * The behavior of this method changes depending on whether the context is inMeeting or inMainClient and whether or not a joinURL is provided. The table below details what to expect. - * * | | with joinURL | without joinURL| * | -------------------- | ------------- | -------- | - * | inMeeting | Launches app in current meeting | Launches app in current meeting | * | inMainClient | Joins meeting associated with the `joinURL` and launches app in it | Starts a new meeting and launches app in it | * * @category Core Endpoints @@ -2463,6 +2485,7 @@ declare class ZoomSdk { * **Note:** * 1. Rooms need to be open * 2. Room configuration should allow user to initiate the change + * 3. This method returns success when changing breakout rooms is initiated, but the transition for the user might not be completed in some scenarios. Use onBreakoutRoomChange to confirm successful transition. If the event doesn’t fire, repeat changeBreakoutRoom call * * @category Managing Breakout Rooms */ @@ -2604,24 +2627,28 @@ declare class ZoomSdk { * * **Supports Guest Mode**: No * - * **Return values**: None - * * **Scope label**: Manage Devices * * **Scope hierarchy**: zoomapps.meetings / zoomapps.webinar * - * **Confirmation / Consent moments**: none + * **Confirmation / Consent moments** + * + * - ###### All participants + * "[AppName] wants to unmute all participants" [Don’t Allow] [Allow] + * + * - ###### Single participant + * "[AppName] wants to unmute this participant: [Screen name]" [Don’t Allow] [Allow] + * + * - ###### Multiple participants + * "[AppName] wants to unmute these participants: [Screen name 1], [Screen name 2], [Screen name 3],…" [Don’t Allow] [Allow] * - * Usage Example: * ``` - * zoomSdk.toggleParticipantMediaAudio( {// (host/cohost) - * "participants":['participantUUID1','participantUUID2'....], + * zoomSdk.toggleParticipantMediaAudio({ + * "participantUUIDs":['participantUUID1','participantUUID2'....], * "audio": true | false - * }) - * .then(function(response) => {}) - * .catch(function(error) => { - * // handle error - * }) + * }) + * .then((response) => { console.log(response); }) + * .catch((e) => { console.log(e); }) * ``` * @category Core Endpoints */ diff --git a/dist/sdk.es.js b/dist/sdk.es.js index 82aeea9..40fa099 100644 --- a/dist/sdk.es.js +++ b/dist/sdk.es.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021 Zoom Video Communications, Inc. + * Copyright (c) 2022 Zoom Video Communications, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -20,7 +20,7 @@ * SOFTWARE. */ -var version = "0.16.2"; +var version = "0.16.3"; var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || @@ -357,54 +357,53 @@ var helpers = { }, }; -var _a$1, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17; +var BASE_VERSION = '0.0.0'; +var MAX_MAX_MAX = '999.999.999'; + +var _a$1, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57; var mappings = (_a$1 = {}, _a$1[NativeApis.SEND_APP_INVITATION] = (_b = {}, - _b[ZERO_SIXTEEN] = { - '0.0.0': { + _b[ZERO_SIXTEEN] = (_c = {}, + _c[BASE_VERSION] = { mapInput: renameKeys({ participants: 'user_list', participantUUIDs: 'user_UUID_list', }), }, - }, + _c), _b), - _a$1[NativeApis.TOGGLE_PARTICIPANT_MEDIA_AUDIO] = (_c = {}, - _c[ZERO_SIXTEEN] = { - '0.0.0': { - mapInput: renameKeys({ participants: 'user_list' }), + _a$1[NativeApis.TOGGLE_PARTICIPANT_MEDIA_AUDIO] = (_d = {}, + _d[ZERO_SIXTEEN] = (_e = {}, + _e[BASE_VERSION] = { + mapInput: renameKeys({ + participants: 'user_list', + participantUUIDs: 'user_UUID_list', + }), mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _c), - _a$1[NativeApis.GET_RUNNING_CONTEXT] = (_d = {}, - _d[ZERO_SIXTEEN] = { - '0.0.0': { + _e), + _d), + _a$1[NativeApis.GET_RUNNING_CONTEXT] = (_f = {}, + _f[ZERO_SIXTEEN] = (_g = {}, + _g[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'context', value: value }); }, }, - }, - _d), - _a$1[NativeApis.GET_RUNNING_CONTEXT] = (_e = {}, - _e[ZERO_SIXTEEN] = { - '0.0.0': { - mapOutput: function (context) { return ({ context: context }); }, - }, - }, - _e), - _a$1[NativeApis.OPEN_URL] = (_f = {}, - _f[ZERO_FOURTEEN] = { - '0.0.0': { + _g), + _f), + _a$1[NativeApis.OPEN_URL] = (_h = {}, + _h[ZERO_FOURTEEN] = (_j = {}, + _j[BASE_VERSION] = { validate: function (data) { new URL(data.url); }, }, - }, - _f[ZERO_SIXTEEN] = { - '0.0.0': { + _j), + _h[ZERO_SIXTEEN] = (_k = {}, + _k[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, @@ -412,299 +411,299 @@ var mappings = (_a$1 = {}, new URL(data.url); }, }, - }, - _f), - _a$1[NativeApis.SET_VIRTUAL_BACKGROUND] = (_g = {}, - _g[ZERO_SIXTEEN] = { - '0.0.0': { + _k), + _h), + _a$1[NativeApis.SET_VIRTUAL_BACKGROUND] = (_l = {}, + _l[ZERO_SIXTEEN] = (_m = {}, + _m[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _g), - _a$1[NativeApis.REMOVE_VIRTUAL_BACKGROUND] = (_h = {}, - _h[ZERO_SIXTEEN] = { - '0.0.0': { + _m), + _l), + _a$1[NativeApis.REMOVE_VIRTUAL_BACKGROUND] = (_o = {}, + _o[ZERO_SIXTEEN] = (_p = {}, + _p[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _h), - _a$1[NativeApis.SET_VIRTUAL_FOREGROUND] = (_j = {}, - _j[ZERO_SIXTEEN] = { - '0.0.0': { + _p), + _o), + _a$1[NativeApis.SET_VIRTUAL_FOREGROUND] = (_q = {}, + _q[ZERO_SIXTEEN] = (_r = {}, + _r[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _j), - _a$1[NativeApis.REMOVE_VIRTUAL_FOREGROUND] = (_k = {}, - _k[ZERO_SIXTEEN] = { - '0.0.0': { + _r), + _q), + _a$1[NativeApis.REMOVE_VIRTUAL_FOREGROUND] = (_s = {}, + _s[ZERO_SIXTEEN] = (_t = {}, + _t[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _k), - _a$1[NativeApis.SHOW_NOTIFICATION] = (_l = {}, - _l[ZERO_SIXTEEN] = { - '0.0.0': { + _t), + _s), + _a$1[NativeApis.SHOW_NOTIFICATION] = (_u = {}, + _u[ZERO_SIXTEEN] = (_v = {}, + _v[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _l), - _a$1[NativeApis.CLOUD_RECORDING] = (_m = {}, - _m[ZERO_SIXTEEN] = { - '0.0.0': { + _v), + _u), + _a$1[NativeApis.CLOUD_RECORDING] = (_w = {}, + _w[ZERO_SIXTEEN] = (_x = {}, + _x[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _m), - _a$1[NativeApis.SHARE_APP] = (_o = {}, - _o[ZERO_SIXTEEN] = { - '0.0.0': { + _x), + _w), + _a$1[NativeApis.SHARE_APP] = (_y = {}, + _y[ZERO_SIXTEEN] = (_z = {}, + _z[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _o), - _a$1[NativeApis.SET_CAMERA] = (_p = {}, - _p[ZERO_SIXTEEN] = { - '0.0.0': { + _z), + _y), + _a$1[NativeApis.SET_CAMERA] = (_0 = {}, + _0[ZERO_SIXTEEN] = (_1 = {}, + _1[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _p), - _a$1[NativeApis.SET_VIDEO_MIRROR_EFFECT] = (_q = {}, - _q[ZERO_SIXTEEN] = { - '0.0.0': { + _1), + _0), + _a$1[NativeApis.SET_VIDEO_MIRROR_EFFECT] = (_2 = {}, + _2[ZERO_SIXTEEN] = (_3 = {}, + _3[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _q), - _a$1[NativeApis.EXPAND_APP] = (_r = {}, - _r[ZERO_SIXTEEN] = { - '0.0.0': { + _3), + _2), + _a$1[NativeApis.EXPAND_APP] = (_4 = {}, + _4[ZERO_SIXTEEN] = (_5 = {}, + _5[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _r), - _a$1[NativeApis.CONNECT] = (_s = {}, - _s[ZERO_SIXTEEN] = { - '0.0.0': { + _5), + _4), + _a$1[NativeApis.CONNECT] = (_6 = {}, + _6[ZERO_SIXTEEN] = (_7 = {}, + _7[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _s), - _a$1[NativeApis.POST_MESSAGE] = (_t = {}, - _t[ZERO_SIXTEEN] = { - '0.0.0': { + _7), + _6), + _a$1[NativeApis.POST_MESSAGE] = (_8 = {}, + _8[ZERO_SIXTEEN] = (_9 = {}, + _9[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _t), - _a$1[NativeApis.ALLOW_PARTICIPANT_TO_RECORD] = (_u = {}, - _u[ZERO_SIXTEEN] = { - '0.0.0': { + _9), + _8), + _a$1[NativeApis.ALLOW_PARTICIPANT_TO_RECORD] = (_10 = {}, + _10[ZERO_SIXTEEN] = (_11 = {}, + _11[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _u), - _a$1[NativeApis.LAUNCH_APP_IN_MEETING] = (_v = {}, - _v[ZERO_SIXTEEN] = { - '0.0.0': { + _11), + _10), + _a$1[NativeApis.LAUNCH_APP_IN_MEETING] = (_12 = {}, + _12[ZERO_SIXTEEN] = (_13 = {}, + _13[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _v), - _a$1[NativeApis.SHOW_APP_INVITATION_DIALOG] = (_w = {}, - _w[ZERO_SIXTEEN] = { - '0.0.0': { + _13), + _12), + _a$1[NativeApis.SHOW_APP_INVITATION_DIALOG] = (_14 = {}, + _14[ZERO_SIXTEEN] = (_15 = {}, + _15[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _w), - _a$1[NativeApis.RUN_RENDERING_CONTEXT] = (_x = {}, - _x[ZERO_SIXTEEN] = { - '0.0.0': { + _15), + _14), + _a$1[NativeApis.RUN_RENDERING_CONTEXT] = (_16 = {}, + _16[ZERO_SIXTEEN] = (_17 = {}, + _17[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _x), - _a$1[NativeApis.CLOSE_RENDERING_CONTEXT] = (_y = {}, - _y[ZERO_SIXTEEN] = { - '0.0.0': { + _17), + _16), + _a$1[NativeApis.CLOSE_RENDERING_CONTEXT] = (_18 = {}, + _18[ZERO_SIXTEEN] = (_19 = {}, + _19[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _y), - _a$1[NativeApis.DRAW_PARTICIPANT] = (_z = {}, - _z[ZERO_SIXTEEN] = { - '0.0.0': { + _19), + _18), + _a$1[NativeApis.DRAW_PARTICIPANT] = (_20 = {}, + _20[ZERO_SIXTEEN] = (_21 = {}, + _21[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _z), - _a$1[NativeApis.CLEAR_PARTICIPANT] = (_0 = {}, - _0[ZERO_SIXTEEN] = { - '0.0.0': { + _21), + _20), + _a$1[NativeApis.CLEAR_PARTICIPANT] = (_22 = {}, + _22[ZERO_SIXTEEN] = (_23 = {}, + _23[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _0), - _a$1[NativeApis.CLEAR_IMAGE] = (_1 = {}, - _1[ZERO_SIXTEEN] = { - '0.0.0': { + _23), + _22), + _a$1[NativeApis.CLEAR_IMAGE] = (_24 = {}, + _24[ZERO_SIXTEEN] = (_25 = {}, + _25[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _1), - _a$1[NativeApis.DRAW_WEBVIEW] = (_2 = {}, - _2[ZERO_SIXTEEN] = { - '0.0.0': { + _25), + _24), + _a$1[NativeApis.DRAW_WEBVIEW] = (_26 = {}, + _26[ZERO_SIXTEEN] = (_27 = {}, + _27[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _2), - _a$1[NativeApis.CLEAR_WEBVIEW] = (_3 = {}, - _3[ZERO_SIXTEEN] = { - '0.0.0': { + _27), + _26), + _a$1[NativeApis.CLEAR_WEBVIEW] = (_28 = {}, + _28[ZERO_SIXTEEN] = (_29 = {}, + _29[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _3), - _a$1[NativeApis.BREAKOUT_ROOMS_OPEN] = (_4 = {}, - _4[ZERO_SIXTEEN] = { - '0.0.0': { + _29), + _28), + _a$1[NativeApis.BREAKOUT_ROOMS_OPEN] = (_30 = {}, + _30[ZERO_SIXTEEN] = (_31 = {}, + _31[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _4), - _a$1[NativeApis.BREAKOUT_ROOMS_CLOSE] = (_5 = {}, - _5[ZERO_SIXTEEN] = { - '0.0.0': { + _31), + _30), + _a$1[NativeApis.BREAKOUT_ROOMS_CLOSE] = (_32 = {}, + _32[ZERO_SIXTEEN] = (_33 = {}, + _33[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _5), - _a$1[NativeApis.BREAKOUT_ROOM_DELETE] = (_6 = {}, - _6[ZERO_SIXTEEN] = { - '0.0.0': { + _33), + _32), + _a$1[NativeApis.BREAKOUT_ROOM_DELETE] = (_34 = {}, + _34[ZERO_SIXTEEN] = (_35 = {}, + _35[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _6), - _a$1[NativeApis.BREAKOUT_ROOM_RENAME] = (_7 = {}, - _7[ZERO_SIXTEEN] = { - '0.0.0': { + _35), + _34), + _a$1[NativeApis.BREAKOUT_ROOM_RENAME] = (_36 = {}, + _36[ZERO_SIXTEEN] = (_37 = {}, + _37[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _7), - _a$1[NativeApis.BREAKOUT_ROOM_ASSIGN_PARTICIPANT] = (_8 = {}, - _8[ZERO_SIXTEEN] = { - '0.0.0': { + _37), + _36), + _a$1[NativeApis.BREAKOUT_ROOM_ASSIGN_PARTICIPANT] = (_38 = {}, + _38[ZERO_SIXTEEN] = (_39 = {}, + _39[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _8), - _a$1[NativeApis.BREAKOUT_ROOM_CHANGE] = (_9 = {}, - _9[ZERO_SIXTEEN] = { - '0.0.0': { + _39), + _38), + _a$1[NativeApis.BREAKOUT_ROOM_CHANGE] = (_40 = {}, + _40[ZERO_SIXTEEN] = (_41 = {}, + _41[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _9), - _a$1[NativeApis.COLLABORATE_START] = (_10 = {}, - _10[ZERO_SIXTEEN] = { - '0.0.0': { + _41), + _40), + _a$1[NativeApis.COLLABORATE_START] = (_42 = {}, + _42[ZERO_SIXTEEN] = (_43 = {}, + _43[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _10), - _a$1[NativeApis.COLLABORATE_END] = (_11 = {}, - _11[ZERO_SIXTEEN] = { - '0.0.0': { + _43), + _42), + _a$1[NativeApis.COLLABORATE_END] = (_44 = {}, + _44[ZERO_SIXTEEN] = (_45 = {}, + _45[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _11), - _a$1[NativeApis.COLLABORATE_LEAVE] = (_12 = {}, - _12[ZERO_SIXTEEN] = { - '0.0.0': { + _45), + _44), + _a$1[NativeApis.COLLABORATE_LEAVE] = (_46 = {}, + _46[ZERO_SIXTEEN] = (_47 = {}, + _47[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _12), - _a$1[NativeApis.COLLABORATE_JOIN] = (_13 = {}, - _13[ZERO_SIXTEEN] = { - '0.0.0': { + _47), + _46), + _a$1[NativeApis.COLLABORATE_JOIN] = (_48 = {}, + _48[ZERO_SIXTEEN] = (_49 = {}, + _49[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _13), - _a$1[NativeApis.AUTHORIZE] = (_14 = {}, - _14[ZERO_SIXTEEN] = { - '0.0.0': { + _49), + _48), + _a$1[NativeApis.AUTHORIZE] = (_50 = {}, + _50[ZERO_SIXTEEN] = (_51 = {}, + _51[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, @@ -714,35 +713,35 @@ var mappings = (_a$1 = {}, } }, }, - }, - _14), - _a$1[NativeApis.PROMPT_AUTHORIZE] = (_15 = {}, - _15[ZERO_SIXTEEN] = { - '0.0.0': { + _51), + _50), + _a$1[NativeApis.PROMPT_AUTHORIZE] = (_52 = {}, + _52[ZERO_SIXTEEN] = (_53 = {}, + _53[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _15), - _a$1[NativeApis.SET_USER_MEDIA_VIDEO] = (_16 = {}, - _16[ZERO_SIXTEEN] = { - '0.0.0': { + _53), + _52), + _a$1[NativeApis.SET_USER_MEDIA_VIDEO] = (_54 = {}, + _54[ZERO_SIXTEEN] = (_55 = {}, + _55[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _16), - _a$1[NativeApis.SET_USER_MEDIA_AUDIO] = (_17 = {}, - _17[ZERO_SIXTEEN] = { - '0.0.0': { + _55), + _54), + _a$1[NativeApis.SET_USER_MEDIA_AUDIO] = (_56 = {}, + _56[ZERO_SIXTEEN] = (_57 = {}, + _57[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _17), + _57), + _56), _a$1); function renameKeys(keyMap) { return function (data) { @@ -763,40 +762,40 @@ function wrapInObject(_a) { var identity = function (x) { return x; }; var noop = function (x) { }; -function getMappingFunctions(apiName, sdkVersion, clientVersion) { +function getMappingFunctions(apiName, sdkVersionInput, clientVersionInput) { var fns = { mapInput: identity, mapOutput: identity, validate: noop, }; - var convertedSdkVersion = convertVersion(sdkVersion); + var majorSdkVersion = getMajorVersionFromExact(sdkVersionInput); var apiMappings = mappings[apiName]; if (!apiMappings) return fns; - var sdkMappings = apiMappings[convertedSdkVersion]; + var sdkMappings = apiMappings[majorSdkVersion]; if (!sdkMappings) return fns; - var versions = Object.keys(sdkMappings).sort(compareVersions); - var matchedVersion = versions - .reverse() - .find(function (version) { return compareVersions(clientVersion, version) >= 0; }); - if (!matchedVersion) - return fns; - var _a = sdkMappings[matchedVersion], mapInput = _a.mapInput, mapOutput = _a.mapOutput, validate = _a.validate; - if (mapInput) - fns.mapInput = mapInput; - if (mapOutput) - fns.mapOutput = mapOutput; - if (validate) - fns.validate = validate; + var clientVals = clientVersionInput.split('.').map(function (n) { return parseInt(n); }); + if (clientVals.some(isNaN)) { + clientVersionInput = MAX_MAX_MAX; + } + var possibleClientVersions = Object.keys(sdkMappings) + .filter(function (clientVersion) { return compareVersions(clientVersionInput, clientVersion) >= 0; }) + .sort(compareVersions); + possibleClientVersions.forEach(function (clientVersion) { + var _a = sdkMappings[clientVersion], mapInput = _a.mapInput, mapOutput = _a.mapOutput, validate = _a.validate; + if (mapInput) + fns.mapInput = mapInput; + if (mapOutput) + fns.mapOutput = mapOutput; + if (validate) + fns.validate = validate; + }); return fns; } function compareVersions(v1, v2) { var vals1 = v1.split('.').map(function (n) { return parseInt(n); }); var vals2 = v2.split('.').map(function (n) { return parseInt(n); }); - if (vals1.some(isNaN)) { - return -1; - } var a1 = vals1[0], b1 = vals1[1], c1 = vals1[2]; var a2 = vals2[0], b2 = vals2[1], c2 = vals2[2]; if (a1 > a2) @@ -813,7 +812,7 @@ function compareVersions(v1, v2) { return 1; return 0; } -function convertVersion(sdkVersion) { +function getMajorVersionFromExact(sdkVersion) { if (typeof sdkVersion !== 'string') { console.warn('You have not provided a valid sdk version'); return; @@ -826,6 +825,7 @@ function convertVersion(sdkVersion) { return ZERO_SIXTEEN; default: console.warn('You have not provided a valid sdk version'); + return; } } @@ -861,9 +861,9 @@ var ZoomSdk = (function () { }; ZoomSdk.prototype.callZoomApi = function (apiName, data, timeout) { return __awaiter(this, void 0, void 0, function () { - var jsCallId, nativeApiRequest, _a, mapInput, mapOutput, validate; + var jsCallId, nativeApiRequest, mapping, mapInput, mapOutput, validate; var _this = this; - return __generator(this, function (_b) { + return __generator(this, function (_a) { jsCallId = getJsCallId(); nativeApiRequest = { jsCallId: jsCallId, @@ -873,7 +873,15 @@ var ZoomSdk = (function () { (!isString(this._version) || !isString(this._clientVersion))) { throw new Error('must call zoomSdk.config before using other API methods'); } - _a = mappingFunctionCache[apiName], mapInput = _a.mapInput, mapOutput = _a.mapOutput, validate = _a.validate; + mapping = mappingFunctionCache[apiName]; + if (!mapping) { + mapping = { + mapInput: identity, + mapOutput: identity, + validate: noop, + }; + } + mapInput = mapping.mapInput, mapOutput = mapping.mapOutput, validate = mapping.validate; if (data) { validate(data); nativeApiRequest.data = mapInput(data); diff --git a/dist/sdk.module.js b/dist/sdk.module.js index 7473355..266fb3e 100644 --- a/dist/sdk.module.js +++ b/dist/sdk.module.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2021 Zoom Video Communications, Inc. + * Copyright (c) 2022 Zoom Video Communications, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ 'use strict'; -var version = "0.16.2"; +var version = "0.16.3"; var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || @@ -359,54 +359,53 @@ var helpers = { }, }; -var _a$1, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17; +var BASE_VERSION = '0.0.0'; +var MAX_MAX_MAX = '999.999.999'; + +var _a$1, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, _56, _57; var mappings = (_a$1 = {}, _a$1[NativeApis.SEND_APP_INVITATION] = (_b = {}, - _b[ZERO_SIXTEEN] = { - '0.0.0': { + _b[ZERO_SIXTEEN] = (_c = {}, + _c[BASE_VERSION] = { mapInput: renameKeys({ participants: 'user_list', participantUUIDs: 'user_UUID_list', }), }, - }, + _c), _b), - _a$1[NativeApis.TOGGLE_PARTICIPANT_MEDIA_AUDIO] = (_c = {}, - _c[ZERO_SIXTEEN] = { - '0.0.0': { - mapInput: renameKeys({ participants: 'user_list' }), + _a$1[NativeApis.TOGGLE_PARTICIPANT_MEDIA_AUDIO] = (_d = {}, + _d[ZERO_SIXTEEN] = (_e = {}, + _e[BASE_VERSION] = { + mapInput: renameKeys({ + participants: 'user_list', + participantUUIDs: 'user_UUID_list', + }), mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _c), - _a$1[NativeApis.GET_RUNNING_CONTEXT] = (_d = {}, - _d[ZERO_SIXTEEN] = { - '0.0.0': { + _e), + _d), + _a$1[NativeApis.GET_RUNNING_CONTEXT] = (_f = {}, + _f[ZERO_SIXTEEN] = (_g = {}, + _g[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'context', value: value }); }, }, - }, - _d), - _a$1[NativeApis.GET_RUNNING_CONTEXT] = (_e = {}, - _e[ZERO_SIXTEEN] = { - '0.0.0': { - mapOutput: function (context) { return ({ context: context }); }, - }, - }, - _e), - _a$1[NativeApis.OPEN_URL] = (_f = {}, - _f[ZERO_FOURTEEN] = { - '0.0.0': { + _g), + _f), + _a$1[NativeApis.OPEN_URL] = (_h = {}, + _h[ZERO_FOURTEEN] = (_j = {}, + _j[BASE_VERSION] = { validate: function (data) { new URL(data.url); }, }, - }, - _f[ZERO_SIXTEEN] = { - '0.0.0': { + _j), + _h[ZERO_SIXTEEN] = (_k = {}, + _k[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, @@ -414,299 +413,299 @@ var mappings = (_a$1 = {}, new URL(data.url); }, }, - }, - _f), - _a$1[NativeApis.SET_VIRTUAL_BACKGROUND] = (_g = {}, - _g[ZERO_SIXTEEN] = { - '0.0.0': { + _k), + _h), + _a$1[NativeApis.SET_VIRTUAL_BACKGROUND] = (_l = {}, + _l[ZERO_SIXTEEN] = (_m = {}, + _m[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _g), - _a$1[NativeApis.REMOVE_VIRTUAL_BACKGROUND] = (_h = {}, - _h[ZERO_SIXTEEN] = { - '0.0.0': { + _m), + _l), + _a$1[NativeApis.REMOVE_VIRTUAL_BACKGROUND] = (_o = {}, + _o[ZERO_SIXTEEN] = (_p = {}, + _p[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _h), - _a$1[NativeApis.SET_VIRTUAL_FOREGROUND] = (_j = {}, - _j[ZERO_SIXTEEN] = { - '0.0.0': { + _p), + _o), + _a$1[NativeApis.SET_VIRTUAL_FOREGROUND] = (_q = {}, + _q[ZERO_SIXTEEN] = (_r = {}, + _r[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _j), - _a$1[NativeApis.REMOVE_VIRTUAL_FOREGROUND] = (_k = {}, - _k[ZERO_SIXTEEN] = { - '0.0.0': { + _r), + _q), + _a$1[NativeApis.REMOVE_VIRTUAL_FOREGROUND] = (_s = {}, + _s[ZERO_SIXTEEN] = (_t = {}, + _t[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _k), - _a$1[NativeApis.SHOW_NOTIFICATION] = (_l = {}, - _l[ZERO_SIXTEEN] = { - '0.0.0': { + _t), + _s), + _a$1[NativeApis.SHOW_NOTIFICATION] = (_u = {}, + _u[ZERO_SIXTEEN] = (_v = {}, + _v[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _l), - _a$1[NativeApis.CLOUD_RECORDING] = (_m = {}, - _m[ZERO_SIXTEEN] = { - '0.0.0': { + _v), + _u), + _a$1[NativeApis.CLOUD_RECORDING] = (_w = {}, + _w[ZERO_SIXTEEN] = (_x = {}, + _x[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _m), - _a$1[NativeApis.SHARE_APP] = (_o = {}, - _o[ZERO_SIXTEEN] = { - '0.0.0': { + _x), + _w), + _a$1[NativeApis.SHARE_APP] = (_y = {}, + _y[ZERO_SIXTEEN] = (_z = {}, + _z[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _o), - _a$1[NativeApis.SET_CAMERA] = (_p = {}, - _p[ZERO_SIXTEEN] = { - '0.0.0': { + _z), + _y), + _a$1[NativeApis.SET_CAMERA] = (_0 = {}, + _0[ZERO_SIXTEEN] = (_1 = {}, + _1[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _p), - _a$1[NativeApis.SET_VIDEO_MIRROR_EFFECT] = (_q = {}, - _q[ZERO_SIXTEEN] = { - '0.0.0': { + _1), + _0), + _a$1[NativeApis.SET_VIDEO_MIRROR_EFFECT] = (_2 = {}, + _2[ZERO_SIXTEEN] = (_3 = {}, + _3[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _q), - _a$1[NativeApis.EXPAND_APP] = (_r = {}, - _r[ZERO_SIXTEEN] = { - '0.0.0': { + _3), + _2), + _a$1[NativeApis.EXPAND_APP] = (_4 = {}, + _4[ZERO_SIXTEEN] = (_5 = {}, + _5[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _r), - _a$1[NativeApis.CONNECT] = (_s = {}, - _s[ZERO_SIXTEEN] = { - '0.0.0': { + _5), + _4), + _a$1[NativeApis.CONNECT] = (_6 = {}, + _6[ZERO_SIXTEEN] = (_7 = {}, + _7[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _s), - _a$1[NativeApis.POST_MESSAGE] = (_t = {}, - _t[ZERO_SIXTEEN] = { - '0.0.0': { + _7), + _6), + _a$1[NativeApis.POST_MESSAGE] = (_8 = {}, + _8[ZERO_SIXTEEN] = (_9 = {}, + _9[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _t), - _a$1[NativeApis.ALLOW_PARTICIPANT_TO_RECORD] = (_u = {}, - _u[ZERO_SIXTEEN] = { - '0.0.0': { + _9), + _8), + _a$1[NativeApis.ALLOW_PARTICIPANT_TO_RECORD] = (_10 = {}, + _10[ZERO_SIXTEEN] = (_11 = {}, + _11[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _u), - _a$1[NativeApis.LAUNCH_APP_IN_MEETING] = (_v = {}, - _v[ZERO_SIXTEEN] = { - '0.0.0': { + _11), + _10), + _a$1[NativeApis.LAUNCH_APP_IN_MEETING] = (_12 = {}, + _12[ZERO_SIXTEEN] = (_13 = {}, + _13[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _v), - _a$1[NativeApis.SHOW_APP_INVITATION_DIALOG] = (_w = {}, - _w[ZERO_SIXTEEN] = { - '0.0.0': { + _13), + _12), + _a$1[NativeApis.SHOW_APP_INVITATION_DIALOG] = (_14 = {}, + _14[ZERO_SIXTEEN] = (_15 = {}, + _15[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _w), - _a$1[NativeApis.RUN_RENDERING_CONTEXT] = (_x = {}, - _x[ZERO_SIXTEEN] = { - '0.0.0': { + _15), + _14), + _a$1[NativeApis.RUN_RENDERING_CONTEXT] = (_16 = {}, + _16[ZERO_SIXTEEN] = (_17 = {}, + _17[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _x), - _a$1[NativeApis.CLOSE_RENDERING_CONTEXT] = (_y = {}, - _y[ZERO_SIXTEEN] = { - '0.0.0': { + _17), + _16), + _a$1[NativeApis.CLOSE_RENDERING_CONTEXT] = (_18 = {}, + _18[ZERO_SIXTEEN] = (_19 = {}, + _19[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _y), - _a$1[NativeApis.DRAW_PARTICIPANT] = (_z = {}, - _z[ZERO_SIXTEEN] = { - '0.0.0': { + _19), + _18), + _a$1[NativeApis.DRAW_PARTICIPANT] = (_20 = {}, + _20[ZERO_SIXTEEN] = (_21 = {}, + _21[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _z), - _a$1[NativeApis.CLEAR_PARTICIPANT] = (_0 = {}, - _0[ZERO_SIXTEEN] = { - '0.0.0': { + _21), + _20), + _a$1[NativeApis.CLEAR_PARTICIPANT] = (_22 = {}, + _22[ZERO_SIXTEEN] = (_23 = {}, + _23[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _0), - _a$1[NativeApis.CLEAR_IMAGE] = (_1 = {}, - _1[ZERO_SIXTEEN] = { - '0.0.0': { + _23), + _22), + _a$1[NativeApis.CLEAR_IMAGE] = (_24 = {}, + _24[ZERO_SIXTEEN] = (_25 = {}, + _25[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _1), - _a$1[NativeApis.DRAW_WEBVIEW] = (_2 = {}, - _2[ZERO_SIXTEEN] = { - '0.0.0': { + _25), + _24), + _a$1[NativeApis.DRAW_WEBVIEW] = (_26 = {}, + _26[ZERO_SIXTEEN] = (_27 = {}, + _27[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _2), - _a$1[NativeApis.CLEAR_WEBVIEW] = (_3 = {}, - _3[ZERO_SIXTEEN] = { - '0.0.0': { + _27), + _26), + _a$1[NativeApis.CLEAR_WEBVIEW] = (_28 = {}, + _28[ZERO_SIXTEEN] = (_29 = {}, + _29[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _3), - _a$1[NativeApis.BREAKOUT_ROOMS_OPEN] = (_4 = {}, - _4[ZERO_SIXTEEN] = { - '0.0.0': { + _29), + _28), + _a$1[NativeApis.BREAKOUT_ROOMS_OPEN] = (_30 = {}, + _30[ZERO_SIXTEEN] = (_31 = {}, + _31[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _4), - _a$1[NativeApis.BREAKOUT_ROOMS_CLOSE] = (_5 = {}, - _5[ZERO_SIXTEEN] = { - '0.0.0': { + _31), + _30), + _a$1[NativeApis.BREAKOUT_ROOMS_CLOSE] = (_32 = {}, + _32[ZERO_SIXTEEN] = (_33 = {}, + _33[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _5), - _a$1[NativeApis.BREAKOUT_ROOM_DELETE] = (_6 = {}, - _6[ZERO_SIXTEEN] = { - '0.0.0': { + _33), + _32), + _a$1[NativeApis.BREAKOUT_ROOM_DELETE] = (_34 = {}, + _34[ZERO_SIXTEEN] = (_35 = {}, + _35[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _6), - _a$1[NativeApis.BREAKOUT_ROOM_RENAME] = (_7 = {}, - _7[ZERO_SIXTEEN] = { - '0.0.0': { + _35), + _34), + _a$1[NativeApis.BREAKOUT_ROOM_RENAME] = (_36 = {}, + _36[ZERO_SIXTEEN] = (_37 = {}, + _37[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _7), - _a$1[NativeApis.BREAKOUT_ROOM_ASSIGN_PARTICIPANT] = (_8 = {}, - _8[ZERO_SIXTEEN] = { - '0.0.0': { + _37), + _36), + _a$1[NativeApis.BREAKOUT_ROOM_ASSIGN_PARTICIPANT] = (_38 = {}, + _38[ZERO_SIXTEEN] = (_39 = {}, + _39[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _8), - _a$1[NativeApis.BREAKOUT_ROOM_CHANGE] = (_9 = {}, - _9[ZERO_SIXTEEN] = { - '0.0.0': { + _39), + _38), + _a$1[NativeApis.BREAKOUT_ROOM_CHANGE] = (_40 = {}, + _40[ZERO_SIXTEEN] = (_41 = {}, + _41[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _9), - _a$1[NativeApis.COLLABORATE_START] = (_10 = {}, - _10[ZERO_SIXTEEN] = { - '0.0.0': { + _41), + _40), + _a$1[NativeApis.COLLABORATE_START] = (_42 = {}, + _42[ZERO_SIXTEEN] = (_43 = {}, + _43[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _10), - _a$1[NativeApis.COLLABORATE_END] = (_11 = {}, - _11[ZERO_SIXTEEN] = { - '0.0.0': { + _43), + _42), + _a$1[NativeApis.COLLABORATE_END] = (_44 = {}, + _44[ZERO_SIXTEEN] = (_45 = {}, + _45[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _11), - _a$1[NativeApis.COLLABORATE_LEAVE] = (_12 = {}, - _12[ZERO_SIXTEEN] = { - '0.0.0': { + _45), + _44), + _a$1[NativeApis.COLLABORATE_LEAVE] = (_46 = {}, + _46[ZERO_SIXTEEN] = (_47 = {}, + _47[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _12), - _a$1[NativeApis.COLLABORATE_JOIN] = (_13 = {}, - _13[ZERO_SIXTEEN] = { - '0.0.0': { + _47), + _46), + _a$1[NativeApis.COLLABORATE_JOIN] = (_48 = {}, + _48[ZERO_SIXTEEN] = (_49 = {}, + _49[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _13), - _a$1[NativeApis.AUTHORIZE] = (_14 = {}, - _14[ZERO_SIXTEEN] = { - '0.0.0': { + _49), + _48), + _a$1[NativeApis.AUTHORIZE] = (_50 = {}, + _50[ZERO_SIXTEEN] = (_51 = {}, + _51[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, @@ -716,35 +715,35 @@ var mappings = (_a$1 = {}, } }, }, - }, - _14), - _a$1[NativeApis.PROMPT_AUTHORIZE] = (_15 = {}, - _15[ZERO_SIXTEEN] = { - '0.0.0': { + _51), + _50), + _a$1[NativeApis.PROMPT_AUTHORIZE] = (_52 = {}, + _52[ZERO_SIXTEEN] = (_53 = {}, + _53[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _15), - _a$1[NativeApis.SET_USER_MEDIA_VIDEO] = (_16 = {}, - _16[ZERO_SIXTEEN] = { - '0.0.0': { + _53), + _52), + _a$1[NativeApis.SET_USER_MEDIA_VIDEO] = (_54 = {}, + _54[ZERO_SIXTEEN] = (_55 = {}, + _55[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _16), - _a$1[NativeApis.SET_USER_MEDIA_AUDIO] = (_17 = {}, - _17[ZERO_SIXTEEN] = { - '0.0.0': { + _55), + _54), + _a$1[NativeApis.SET_USER_MEDIA_AUDIO] = (_56 = {}, + _56[ZERO_SIXTEEN] = (_57 = {}, + _57[BASE_VERSION] = { mapOutput: function (value) { return wrapInObject({ key: 'message', value: value }); }, }, - }, - _17), + _57), + _56), _a$1); function renameKeys(keyMap) { return function (data) { @@ -765,40 +764,40 @@ function wrapInObject(_a) { var identity = function (x) { return x; }; var noop = function (x) { }; -function getMappingFunctions(apiName, sdkVersion, clientVersion) { +function getMappingFunctions(apiName, sdkVersionInput, clientVersionInput) { var fns = { mapInput: identity, mapOutput: identity, validate: noop, }; - var convertedSdkVersion = convertVersion(sdkVersion); + var majorSdkVersion = getMajorVersionFromExact(sdkVersionInput); var apiMappings = mappings[apiName]; if (!apiMappings) return fns; - var sdkMappings = apiMappings[convertedSdkVersion]; + var sdkMappings = apiMappings[majorSdkVersion]; if (!sdkMappings) return fns; - var versions = Object.keys(sdkMappings).sort(compareVersions); - var matchedVersion = versions - .reverse() - .find(function (version) { return compareVersions(clientVersion, version) >= 0; }); - if (!matchedVersion) - return fns; - var _a = sdkMappings[matchedVersion], mapInput = _a.mapInput, mapOutput = _a.mapOutput, validate = _a.validate; - if (mapInput) - fns.mapInput = mapInput; - if (mapOutput) - fns.mapOutput = mapOutput; - if (validate) - fns.validate = validate; + var clientVals = clientVersionInput.split('.').map(function (n) { return parseInt(n); }); + if (clientVals.some(isNaN)) { + clientVersionInput = MAX_MAX_MAX; + } + var possibleClientVersions = Object.keys(sdkMappings) + .filter(function (clientVersion) { return compareVersions(clientVersionInput, clientVersion) >= 0; }) + .sort(compareVersions); + possibleClientVersions.forEach(function (clientVersion) { + var _a = sdkMappings[clientVersion], mapInput = _a.mapInput, mapOutput = _a.mapOutput, validate = _a.validate; + if (mapInput) + fns.mapInput = mapInput; + if (mapOutput) + fns.mapOutput = mapOutput; + if (validate) + fns.validate = validate; + }); return fns; } function compareVersions(v1, v2) { var vals1 = v1.split('.').map(function (n) { return parseInt(n); }); var vals2 = v2.split('.').map(function (n) { return parseInt(n); }); - if (vals1.some(isNaN)) { - return -1; - } var a1 = vals1[0], b1 = vals1[1], c1 = vals1[2]; var a2 = vals2[0], b2 = vals2[1], c2 = vals2[2]; if (a1 > a2) @@ -815,7 +814,7 @@ function compareVersions(v1, v2) { return 1; return 0; } -function convertVersion(sdkVersion) { +function getMajorVersionFromExact(sdkVersion) { if (typeof sdkVersion !== 'string') { console.warn('You have not provided a valid sdk version'); return; @@ -828,6 +827,7 @@ function convertVersion(sdkVersion) { return ZERO_SIXTEEN; default: console.warn('You have not provided a valid sdk version'); + return; } } @@ -863,9 +863,9 @@ var ZoomSdk = (function () { }; ZoomSdk.prototype.callZoomApi = function (apiName, data, timeout) { return __awaiter(this, void 0, void 0, function () { - var jsCallId, nativeApiRequest, _a, mapInput, mapOutput, validate; + var jsCallId, nativeApiRequest, mapping, mapInput, mapOutput, validate; var _this = this; - return __generator(this, function (_b) { + return __generator(this, function (_a) { jsCallId = getJsCallId(); nativeApiRequest = { jsCallId: jsCallId, @@ -875,7 +875,15 @@ var ZoomSdk = (function () { (!isString(this._version) || !isString(this._clientVersion))) { throw new Error('must call zoomSdk.config before using other API methods'); } - _a = mappingFunctionCache[apiName], mapInput = _a.mapInput, mapOutput = _a.mapOutput, validate = _a.validate; + mapping = mappingFunctionCache[apiName]; + if (!mapping) { + mapping = { + mapInput: identity, + mapOutput: identity, + validate: noop, + }; + } + mapInput = mapping.mapInput, mapOutput = mapping.mapOutput, validate = mapping.validate; if (data) { validate(data); nativeApiRequest.data = mapInput(data); diff --git a/package.json b/package.json index abb784f..e0e97b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@zoom/appssdk", - "version": "0.16.2", + "version": "0.16.3", "description": "Zoom Apps SDK", "license": "MIT", "files": [ @@ -23,8 +23,9 @@ "lint": "eslint . --ext .ts,.js", "lint:fix": "npm run lint -- --fix", "prepare": "husky install", - "rollup": "npm run clean && rollup -c", - "test": "jest --env=jsdom" + "build": "npm run clean && rollup -c", + "test": "jest --env=jsdom", + "test_types": "tsc test/sdk/typestest" }, "lint-staged": { "src/**/*.{js,ts,jsx,tsx}": [ @@ -59,6 +60,7 @@ "rollup-plugin-dts": "^4.2.2", "rollup-plugin-license": "^2.8.1", "rollup-plugin-terser": "^7.0.2", + "rollup-plugin-version-injector": "^1.3.3", "ts-jest": "^28.0.5", "tslib": "^2.4.0", "typedoc": "^0.22.13",