@daily-co/react-native-daily-js 0.85.0 → 0.86.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,11 +2,18 @@ type CacheResponse = {
2
2
  code?: string;
3
3
  refetchHeaders?: Headers;
4
4
  };
5
+ export interface AsyncStorageInterface {
6
+ getItem(key: string): Promise<string | null>;
7
+ setItem(key: string, value: string): Promise<void>;
8
+ removeItem(key: string): Promise<void>;
9
+ }
5
10
  /**
6
11
  * A workaround for the fact that the iOS HTTP cache won't cache the call
7
12
  * object bundle due to size.
8
13
  */
9
14
  export default class iOSCallObjectBundleCache {
15
+ private static _storage;
16
+ static initialize(storage: AsyncStorageInterface): void;
10
17
  static get(url: string, ignoreExpiry?: boolean): Promise<CacheResponse | null>;
11
18
  static renew(url: string, headers: Headers): Promise<CacheResponse>;
12
19
  static set(url: string, code: string, headers: Headers): Promise<void>;
@@ -35,11 +35,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
38
  Object.defineProperty(exports, "__esModule", { value: true });
42
- var async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
43
39
  var FIELD_CACHE_EXPIRY = 'expiry';
44
40
  var FIELD_BUNDLE_CODE = 'code';
45
41
  var FIELD_BUNDLE_LAST_MODIFIED = 'last-modified';
@@ -56,6 +52,9 @@ function cacheKeyForUrl(url) {
56
52
  var iOSCallObjectBundleCache = /** @class */ (function () {
57
53
  function iOSCallObjectBundleCache() {
58
54
  }
55
+ iOSCallObjectBundleCache.initialize = function (storage) {
56
+ this._storage = storage;
57
+ };
59
58
  iOSCallObjectBundleCache.get = function (url_1) {
60
59
  return __awaiter(this, arguments, void 0, function (url, ignoreExpiry) {
61
60
  var now, cacheItemString, cacheItem, _i, REQUIRED_FIELDS_1, field, headers, e_1;
@@ -63,11 +62,15 @@ var iOSCallObjectBundleCache = /** @class */ (function () {
63
62
  return __generator(this, function (_a) {
64
63
  switch (_a.label) {
65
64
  case 0:
65
+ // console.log("[iOSCallObjectBundleCache] get", url);
66
+ if (!this._storage) {
67
+ return [2 /*return*/, null];
68
+ }
66
69
  now = Date.now();
67
70
  _a.label = 1;
68
71
  case 1:
69
72
  _a.trys.push([1, 3, , 4]);
70
- return [4 /*yield*/, async_storage_1.default.getItem(cacheKeyForUrl(url))];
73
+ return [4 /*yield*/, this._storage.getItem(cacheKeyForUrl(url))];
71
74
  case 2:
72
75
  cacheItemString = _a.sent();
73
76
  // If cache miss, return null
@@ -101,7 +104,7 @@ var iOSCallObjectBundleCache = /** @class */ (function () {
101
104
  e_1 = _a.sent();
102
105
  // console.log("[iOSCallObjectBundleCache] error in get", url, e);
103
106
  // Clear potentially problematic cache entry and return null
104
- async_storage_1.default.removeItem(cacheKeyForUrl(url));
107
+ this._storage.removeItem(cacheKeyForUrl(url));
105
108
  return [2 /*return*/, null];
106
109
  case 4: return [2 /*return*/];
107
110
  }
@@ -130,10 +133,10 @@ var iOSCallObjectBundleCache = /** @class */ (function () {
130
133
  var expiry, cacheControlHeader, expiryMatch, etag, lastModified, cacheItem;
131
134
  return __generator(this, function (_a) {
132
135
  // console.log("[iOSCallObjectBundleCache] set", url, headers);
133
- if (!code) {
136
+ if (!code || !this._storage) {
134
137
  return [2 /*return*/];
135
138
  }
136
- expiry = DEFAULT_EXPIRY_MS;
139
+ expiry = Date.now() + DEFAULT_EXPIRY_MS;
137
140
  cacheControlHeader = headers.get('cache-control');
138
141
  if (cacheControlHeader) {
139
142
  expiryMatch = cacheControlHeader.match(/max-age=([0-9]+)/i);
@@ -148,10 +151,11 @@ var iOSCallObjectBundleCache = /** @class */ (function () {
148
151
  cacheItem[FIELD_CACHE_EXPIRY] = expiry;
149
152
  cacheItem[FIELD_BUNDLE_ETAG] = etag;
150
153
  cacheItem[FIELD_BUNDLE_LAST_MODIFIED] = lastModified;
151
- return [2 /*return*/, async_storage_1.default.setItem(cacheKeyForUrl(url), JSON.stringify(cacheItem))];
154
+ return [2 /*return*/, this._storage.setItem(cacheKeyForUrl(url), JSON.stringify(cacheItem))];
152
155
  });
153
156
  });
154
157
  };
158
+ iOSCallObjectBundleCache._storage = null;
155
159
  return iOSCallObjectBundleCache;
156
160
  }());
157
161
  exports.default = iOSCallObjectBundleCache;
package/dist/index.js CHANGED
@@ -22,6 +22,7 @@ var daily_js_1 = __importDefault(require("@daily-co/daily-js"));
22
22
  var react_native_webrtc_1 = require("@daily-co/react-native-webrtc");
23
23
  var DailyMediaView_1 = __importDefault(require("./DailyMediaView"));
24
24
  exports.DailyMediaView = DailyMediaView_1.default;
25
+ var async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
25
26
  var iOSCallObjectBundleCache_1 = __importDefault(require("./iOSCallObjectBundleCache"));
26
27
  require("react-native-url-polyfill/auto"); // Applies global URL polyfill
27
28
  var react_native_background_timer_1 = __importDefault(require("react-native-background-timer"));
@@ -99,6 +100,7 @@ function setupGlobals() {
99
100
  global.atob = base_64_1.decode;
100
101
  // A workaround for iOS HTTP cache not caching call object bundle due to size
101
102
  if (react_native_1.Platform.OS === 'ios') {
103
+ iOSCallObjectBundleCache_1.default.initialize(async_storage_1.default);
102
104
  global.iOSCallObjectBundleCache = iOSCallObjectBundleCache_1.default;
103
105
  }
104
106
  // Let timers run while Android app is in the background.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daily-co/react-native-daily-js",
3
- "version": "0.85.0",
3
+ "version": "0.86.0",
4
4
  "description": "React Native library for making video calls using Daily",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -17,7 +17,7 @@
17
17
  "LICENSE"
18
18
  ],
19
19
  "scripts": {
20
- "build": "tsc",
20
+ "build": "rm -rf dist/ && tsc",
21
21
  "postbuild": "sed -E -i.bak 's|@daily-co/daily-js|../type-overrides/@daily-co/daily-js|g' ./dist/index.d.ts && rm ./dist/index.d.ts.bak",
22
22
  "prepare": "npm run build",
23
23
  "tag": "scripts/tag",
@@ -30,7 +30,7 @@
30
30
  "baseUrl": "https://github.com/daily-co/react-native-daily-js"
31
31
  },
32
32
  "dependencies": {
33
- "@daily-co/daily-js": "^0.90.0",
33
+ "@daily-co/daily-js": "^0.91.0",
34
34
  "@types/react-native-background-timer": "^2.0.0",
35
35
  "base-64": "^1.0.0",
36
36
  "react-native-url-polyfill": "^1.1.2"
@@ -38,14 +38,14 @@
38
38
  "///": "WHEN ONE OF THESE CHANGE, PLEASE UPDATE README.md INSTALL SNIPPET ACCORDINGLY",
39
39
  "peerDependencies": {
40
40
  "@daily-co/react-native-webrtc": "^124.0.6-daily.1",
41
- "@react-native-async-storage/async-storage": "^1.24.0",
41
+ "@react-native-async-storage/async-storage": "^1.24.0 || ^2.0.0 || ^3.0.0",
42
42
  "react-native": ">=0.68.0",
43
43
  "react-native-background-timer": "^2.4.1",
44
44
  "react-native-get-random-values": "^1.11.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@daily-co/react-native-webrtc": "^124.0.6-daily.1",
48
- "@react-native-async-storage/async-storage": "^1.24.0",
48
+ "@react-native-async-storage/async-storage": "^3.0.3",
49
49
  "@types/base-64": "^1.0.0",
50
50
  "@types/react": "18.3.21",
51
51
  "react-native": "0.76.9",
@@ -1553,6 +1553,7 @@ export interface DailyTranscriptionDeepgramOptions {
1553
1553
  includeRawResponse?: boolean;
1554
1554
  instanceId?: string;
1555
1555
  participants?: Array<string>;
1556
+ transcription_geo?: 'global' | 'eu';
1556
1557
  }
1557
1558
 
1558
1559
  export interface DailyTranscriptionUpdateOptions {