Skip to content

Commit

Permalink
Merge branch 'main' into report-low-power-and-thermal-info
Browse files Browse the repository at this point in the history
  • Loading branch information
kristian-mkd committed Dec 16, 2024
2 parents edba555 + c655d29 commit 1219bfd
Show file tree
Hide file tree
Showing 14 changed files with 141 additions and 102 deletions.
6 changes: 3 additions & 3 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"start": "rollup -w -c",
"build": "yarn clean && rollup -c",
"test": "vitest",
"test-ci": "vitest --coverage",
"test-ci": "vitest run --coverage",
"generate:open-api": "./generate-openapi.sh protocol",
"generate:open-api:dev": "./generate-openapi.sh chat",
"generate:timer-worker": "./generate-timer-worker.sh"
Expand Down Expand Up @@ -45,15 +45,15 @@
"@stream-io/node-sdk": "^0.4.3",
"@types/sdp-transform": "^2.4.7",
"@types/ua-parser-js": "^0.7.37",
"@vitest/coverage-v8": "^2.1.4",
"@vitest/coverage-v8": "^2.1.8",
"dotenv": "^16.3.1",
"happy-dom": "^11.0.2",
"prettier": "^3.3.2",
"rimraf": "^5.0.7",
"rollup": "^4.22.0",
"typescript": "^5.5.2",
"vite": "^5.4.6",
"vitest": "^2.1.4",
"vitest": "^2.1.8",
"vitest-mock-extended": "^2.0.2"
}
}
7 changes: 5 additions & 2 deletions packages/client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { defineConfig } from 'vitest/config';

export default defineConfig({
// TODO: move build process to Vite
build: {},
test: {
coverage: {
ignoreEmptyLines: true,
provider: 'v8',
include: ['src/**'],
exclude: ['**/__tests__/**', 'src/gen/**'],
reportsDirectory: './coverage',
reporter: ['lcov'],
},
},
Expand Down
1 change: 1 addition & 0 deletions packages/react-native-sdk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ buck-out/

# Bundle artifact
*.jsbundle
*.tgz

# Ruby / CocoaPods
/ios/Pods/
Expand Down
7 changes: 7 additions & 0 deletions packages/react-native-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).

## [1.4.18](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-1.4.17...@stream-io/video-react-native-sdk-1.4.18) (2024-12-16)


### Bug Fixes

* metro commonjs issues with optional libs ([#1625](https://github.com/GetStream/stream-video-js/issues/1625)) ([78b5f05](https://github.com/GetStream/stream-video-js/commit/78b5f050c20c67f77c154a8fd5d1c4e59b72989f)), closes [#1620](https://github.com/GetStream/stream-video-js/issues/1620)

## [1.4.17](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-react-native-sdk-1.4.16...@stream-io/video-react-native-sdk-1.4.17) (2024-12-13)


Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stream-io/video-react-native-sdk",
"version": "1.4.17",
"version": "1.4.18",
"packageManager": "[email protected]",
"main": "dist/commonjs/index.js",
"module": "dist/module/index.js",
Expand Down
6 changes: 4 additions & 2 deletions packages/react-native-sdk/src/utils/push/ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { pushNonRingingCallData$ } from './internal/rxSubjects';
import {
ExpoNotification,
getExpoNotificationsLib,
getNotifeeLibThrowIfNotInstalledForPush,
getPushNotificationIosLib,
PushNotificationiOSType,
} from './libs';
import { StreamVideoClient, getLogger } from '@stream-io/video-client';
import { setPushLogoutCallback } from '../internal/pushLogoutCallback';
import { EventType, Event } from '@notifee/react-native';
import type { Event } from '@notifee/react-native';
import { StreamVideoRN } from '../StreamVideoRN';
import { StreamPushPayload } from './utils';

Expand Down Expand Up @@ -51,7 +52,8 @@ export const oniOSNotifeeEvent = ({
if (Platform.OS !== 'ios') return;
const pushConfig = StreamVideoRN.getConfig().push;
const { type, detail } = event;
if (pushConfig && type === EventType.PRESS) {
const notifeeLib = getNotifeeLibThrowIfNotInstalledForPush();
if (pushConfig && type === notifeeLib.EventType.PRESS) {
const streamPayload = detail.notification?.data?.stream as
| StreamPushPayload
| undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
import { getLogger } from '@stream-io/video-client';
import { Type, lib } from './lib';

export type { FirebaseMessagingTypes } from '@react-native-firebase/messaging';
export type FirebaseMessagingType =
typeof import('@react-native-firebase/messaging').default;

let messaging: FirebaseMessagingType | undefined;

try {
messaging = require('@react-native-firebase/messaging').default;
} catch (_e) {}
export type FirebaseMessagingType = Type;

const INSTALLATION_INSTRUCTION =
'Please see https://rnfirebase.io/messaging/usage#installation for installation instructions';

export function getFirebaseMessagingLib() {
if (!messaging) {
if (!lib) {
throw Error(
'@react-native-firebase/messaging is not installed. ' +
INSTALLATION_INSTRUCTION
);
}
return messaging;
return lib;
}

export function getFirebaseMessagingLibNoThrow(isExpo: boolean) {
if (!messaging) {
if (!lib) {
const logger = getLogger(['getFirebaseMessagingLibNoThrow']);
logger(
'warn',
Expand All @@ -34,5 +29,5 @@ export function getFirebaseMessagingLibNoThrow(isExpo: boolean) {
}${INSTALLATION_INSTRUCTION}`
);
}
return messaging;
return lib;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export type Type = typeof import('@react-native-firebase/messaging').default;

let lib: Type | undefined;

try {
lib = require('@react-native-firebase/messaging').default;
} catch (_e) {}

export { lib };

/*
IMPORTANT: must keep a failing import in a different file
Else on commonjs, metro doesnt resolve any other modules properly in a file, if one of the module is not installed
*/
4 changes: 2 additions & 2 deletions packages/react-native-sdk/src/utils/push/libs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export * from './callkeep';
export * from './notifee';

/*
NOTE: must keep each libs in different files
Else on commonjs, metro doesnt resolve modules properly if one of the module is not installed
NOTE: must keep each libs in different files
Else on commonjs, metro doesnt resolve modules properly if one of the module is not installed
*/
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { getLogger } from '@stream-io/video-client';
import { PermissionsAndroid } from 'react-native';
import { Type, lib } from './lib';

export type NotifeeLib = typeof import('@notifee/react-native');
export type NotifeeLib = Type;

enum AndroidForegroundServiceType {
FOREGROUND_SERVICE_TYPE_CAMERA = 64,
Expand All @@ -21,34 +22,28 @@ enum AndroidForegroundServiceType {
FOREGROUND_SERVICE_TYPE_MANIFEST = -1,
}

let notifeeLib: NotifeeLib | undefined;

try {
notifeeLib = require('@notifee/react-native');
} catch (_e) {}

const INSTALLATION_INSTRUCTION =
'Please see https://notifee.app/react-native/docs/installation for installation instructions';

export function getNotifeeLibThrowIfNotInstalledForPush() {
if (!notifeeLib) {
if (!lib) {
throw Error(
'@notifee/react-native is not installed. It is required for implementing push notifications. ' +
INSTALLATION_INSTRUCTION
);
}
return notifeeLib;
return lib;
}

export function getNotifeeLibNoThrowForKeepCallAlive() {
if (!notifeeLib) {
if (!lib) {
const logger = getLogger(['getNotifeeLibNoThrow']);
logger(
'info',
`${'@notifee/react-native library not installed. It is required to keep call alive in the background for Android. '}${INSTALLATION_INSTRUCTION}`
);
}
return notifeeLib;
return lib;
}

export async function getKeepCallAliveForegroundServiceTypes() {
Expand Down
14 changes: 14 additions & 0 deletions packages/react-native-sdk/src/utils/push/libs/notifee/lib.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export type Type = typeof import('@notifee/react-native');

let lib: Type | undefined;

try {
lib = require('@notifee/react-native');
} catch (_e) {}

export { lib };

/*
IMPORTANT: must keep a failing import in a different file
Else on commonjs, metro doesnt resolve any other modules properly in a file, if one of the module is not installed
*/
2 changes: 1 addition & 1 deletion packages/react-native-sdk/src/utils/push/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Event } from '@notifee/react-native';
import type { Event } from '@notifee/react-native';
import { FirebaseMessagingTypes } from './libs/firebaseMessaging';
import { ExpoNotification } from './libs/expoNotifications';
import { NonRingingPushEvent } from '../StreamVideoRN/types';
Expand Down
2 changes: 1 addition & 1 deletion sample-apps/react-native/dogfood/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@stream-io/video-react-native-dogfood",
"version": "4.9.6",
"version": "4.9.7",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand Down
Loading

0 comments on commit 1219bfd

Please sign in to comment.