@whereby.com/core 0.7.0 → 0.9.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.
package/dist/utils.d.ts CHANGED
@@ -9,16 +9,6 @@ interface Options {
9
9
  interface DebouncedFunction {
10
10
  (...args: any[]): void;
11
11
  }
12
- /**
13
- * Debounce function.
14
- *
15
- * @param {Function} fn - Function to debounce.
16
- * @param {Object} [options] - Options.
17
- * @param {number} [options.delay=500] - Delay in milliseconds.
18
- * @param {boolean} [options.edges=false] - Whether to call the function on the
19
- * leading and trailing edges of the wait timeout.
20
- * @returns {Function} Debounced function.
21
- */
22
12
  declare function debounce(fn: DebouncedFunction, { delay, edges }?: Options): DebouncedFunction;
23
13
 
24
14
  declare function parseRoomUrlAndSubdomain(roomAttribute?: string, subdomainAttribute?: string): {
@@ -1,5 +1,3 @@
1
- export { d as debounce } from './debounce-B-cWYxqK.js';
2
-
3
1
  function fakeAudioStream() {
4
2
  const audioCtx = new AudioContext();
5
3
  const oscillator = audioCtx.createOscillator();
@@ -69,6 +67,25 @@ function fakeWebcamFrame(canvas) {
69
67
  requestAnimationFrame(() => fakeWebcamFrame(canvas));
70
68
  }
71
69
 
70
+ function debounce(fn, { delay = 500, edges } = {}) {
71
+ let timeout;
72
+ let nCalls = 0;
73
+ return (...args) => {
74
+ nCalls += 1;
75
+ if (edges && nCalls === 1) {
76
+ fn(...args);
77
+ }
78
+ clearTimeout(timeout);
79
+ timeout = setTimeout(() => {
80
+ if (!edges || nCalls > 1) {
81
+ fn(...args);
82
+ }
83
+ timeout = undefined;
84
+ nCalls = 0;
85
+ }, delay);
86
+ };
87
+ }
88
+
72
89
  function parseRoomUrlAndSubdomain(roomAttribute, subdomainAttribute) {
73
90
  if (!roomAttribute) {
74
91
  throw new Error("Missing room attribute");
@@ -88,4 +105,4 @@ function parseRoomUrlAndSubdomain(roomAttribute, subdomainAttribute) {
88
105
  };
89
106
  }
90
107
 
91
- export { fakeAudioStream, fakeWebcamFrame, parseRoomUrlAndSubdomain };
108
+ export { debounce, fakeAudioStream, fakeWebcamFrame, parseRoomUrlAndSubdomain };
package/package.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "name": "@whereby.com/core",
3
3
  "description": "Core library for whereby.com sdk",
4
4
  "author": "Whereby AS",
5
- "version": "0.7.0",
5
+ "version": "0.9.0",
6
6
  "license": "MIT",
7
7
  "scripts": {
8
- "build": "rimraf dist && rollup -c rollup.config.cjs",
8
+ "build": "rimraf dist && rollup -c rollup.config.js",
9
9
  "test": "yarn test:lint && yarn test:unit",
10
10
  "test:lint": "eslint src/",
11
11
  "test:unit": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js",
@@ -15,17 +15,18 @@
15
15
  "access": "public"
16
16
  },
17
17
  "files": [
18
- "dist/*.js",
18
+ "dist/**/*.cjs",
19
+ "dist/*.mjs",
19
20
  "dist/*.d.ts"
20
21
  ],
21
- "type": "module",
22
+ "main": "/dist/cjs/index.cjs",
22
23
  "exports": {
23
24
  ".": {
24
- "import": "./dist/index.js",
25
+ "import": "./dist/index.mjs",
25
26
  "types": "./dist/index.d.ts"
26
27
  },
27
28
  "./utils": {
28
- "import": "./dist/utils.js",
29
+ "import": "./dist/utils.mjs",
29
30
  "types": "./dist/utils.d.ts"
30
31
  }
31
32
  },
@@ -48,7 +49,7 @@
48
49
  "@types/node": "^20.11.19",
49
50
  "@types/uuid": "^9.0.7",
50
51
  "deep-object-diff": "^1.1.9",
51
- "dotenv": "^16.3.1",
52
+ "dotenv": "^16.4.5",
52
53
  "dotenv-run-script": "^0.4.1",
53
54
  "rimraf": "^5.0.5",
54
55
  "rollup": "^4.12.0",
@@ -61,9 +62,8 @@
61
62
  "yalc": "^1.0.0-pre.53"
62
63
  },
63
64
  "dependencies": {
64
- "@reduxjs/toolkit": "^2.0.1",
65
- "@swc/helpers": "^0.3.13",
66
- "@whereby/jslib-media": "whereby/jslib-media.git#1.9.7",
65
+ "@reduxjs/toolkit": "^2.2.3",
66
+ "@whereby.com/media": "*",
67
67
  "axios": "^1.2.3",
68
68
  "btoa": "^1.2.1",
69
69
  "events": "^3.3.0"
@@ -1,20 +0,0 @@
1
- function debounce(fn, { delay = 500, edges } = {}) {
2
- let timeout;
3
- let nCalls = 0;
4
- return (...args) => {
5
- nCalls += 1;
6
- if (edges && nCalls === 1) {
7
- fn(...args);
8
- }
9
- clearTimeout(timeout);
10
- timeout = setTimeout(() => {
11
- if (!edges || nCalls > 1) {
12
- fn(...args);
13
- }
14
- timeout = undefined;
15
- nCalls = 0;
16
- }, delay);
17
- };
18
- }
19
-
20
- export { debounce as d };