@whereby.com/core 0.9.0 → 0.9.2
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/{cjs/index.cjs → index.cjs} +93 -1
- package/dist/index.d.cts +5325 -0
- package/dist/index.d.mts +5325 -0
- package/dist/index.d.ts +15 -1
- package/dist/index.mjs +90 -2
- package/package.json +18 -22
- package/dist/cjs/utils.cjs +0 -113
- package/dist/utils.d.ts +0 -19
- package/dist/utils.mjs +0 -108
|
@@ -35,7 +35,7 @@ const createReactor = (selectors, callback) => {
|
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
const coreVersion = "0.9.
|
|
38
|
+
const coreVersion = "0.9.2";
|
|
39
39
|
|
|
40
40
|
const initialState$c = {
|
|
41
41
|
isNodeSdk: false,
|
|
@@ -408,6 +408,75 @@ const selectCloudRecordingStartedAt = (state) => state.cloudRecording.startedAt;
|
|
|
408
408
|
const selectCloudRecordingError = (state) => state.cloudRecording.error;
|
|
409
409
|
const selectIsCloudRecording = (state) => state.cloudRecording.isRecording;
|
|
410
410
|
|
|
411
|
+
function fakeAudioStream() {
|
|
412
|
+
const audioCtx = new AudioContext();
|
|
413
|
+
const oscillator = audioCtx.createOscillator();
|
|
414
|
+
const destination = audioCtx.createMediaStreamDestination();
|
|
415
|
+
oscillator.connect(destination);
|
|
416
|
+
oscillator.frequency.value = 400;
|
|
417
|
+
oscillator.type = "sine";
|
|
418
|
+
setInterval(() => {
|
|
419
|
+
if (oscillator.frequency.value <= 900) {
|
|
420
|
+
oscillator.frequency.value += 10;
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
oscillator.frequency.value = 200;
|
|
424
|
+
}
|
|
425
|
+
}, 20);
|
|
426
|
+
oscillator.start();
|
|
427
|
+
return destination.stream;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
let rotationAngle = 0;
|
|
431
|
+
function drawWebcamFrame(canvas) {
|
|
432
|
+
const context = canvas.getContext("2d");
|
|
433
|
+
if (!context) {
|
|
434
|
+
console.error("Canvas context not available");
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const wheelRadius = 100;
|
|
438
|
+
const wheelCenterX = canvas.width / 2;
|
|
439
|
+
const wheelCenterY = canvas.height / 2;
|
|
440
|
+
context.fillStyle = "darkgreen";
|
|
441
|
+
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
442
|
+
context.save();
|
|
443
|
+
context.translate(wheelCenterX, wheelCenterY);
|
|
444
|
+
context.rotate(rotationAngle);
|
|
445
|
+
const numSlices = 12;
|
|
446
|
+
const sliceAngle = (2 * Math.PI) / numSlices;
|
|
447
|
+
const colors = ["red", "orange", "yellow", "green", "blue", "purple"];
|
|
448
|
+
for (let i = 0; i < numSlices; i++) {
|
|
449
|
+
context.beginPath();
|
|
450
|
+
context.moveTo(0, 0);
|
|
451
|
+
context.arc(0, 0, wheelRadius, i * sliceAngle, (i + 1) * sliceAngle);
|
|
452
|
+
context.fillStyle = colors[i % colors.length];
|
|
453
|
+
context.fill();
|
|
454
|
+
context.closePath();
|
|
455
|
+
}
|
|
456
|
+
context.restore();
|
|
457
|
+
context.fillStyle = "white";
|
|
458
|
+
context.font = "42px Arial";
|
|
459
|
+
const topText = "Whereby Media Stream";
|
|
460
|
+
const topTextWidth = context.measureText(topText).width;
|
|
461
|
+
context.fillText(topText, canvas.width / 2 - topTextWidth / 2, 50);
|
|
462
|
+
context.font = "32px Arial";
|
|
463
|
+
const now = new Date();
|
|
464
|
+
const timeText = `time: ${now.getHours().toString().padStart(2, "0")}:${now
|
|
465
|
+
.getMinutes()
|
|
466
|
+
.toString()
|
|
467
|
+
.padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}.${now
|
|
468
|
+
.getMilliseconds()
|
|
469
|
+
.toString()
|
|
470
|
+
.padStart(3, "0")}`;
|
|
471
|
+
context.fillText(timeText, 10, canvas.height - 20);
|
|
472
|
+
context.fillText(`rotation angle: ${rotationAngle.toFixed(2)}`, canvas.width - canvas.width / 2, canvas.height - 20);
|
|
473
|
+
rotationAngle += 0.01;
|
|
474
|
+
}
|
|
475
|
+
function fakeWebcamFrame(canvas) {
|
|
476
|
+
drawWebcamFrame(canvas);
|
|
477
|
+
requestAnimationFrame(() => fakeWebcamFrame(canvas));
|
|
478
|
+
}
|
|
479
|
+
|
|
411
480
|
function debounce(fn, { delay = 500, edges } = {}) {
|
|
412
481
|
let timeout;
|
|
413
482
|
let nCalls = 0;
|
|
@@ -427,6 +496,25 @@ function debounce(fn, { delay = 500, edges } = {}) {
|
|
|
427
496
|
};
|
|
428
497
|
}
|
|
429
498
|
|
|
499
|
+
function parseRoomUrlAndSubdomain(roomAttribute, subdomainAttribute) {
|
|
500
|
+
if (!roomAttribute) {
|
|
501
|
+
throw new Error("Missing room attribute");
|
|
502
|
+
}
|
|
503
|
+
const m = /https:\/\/([^.]+)(\.whereby\.com|-ip-\d+-\d+-\d+-\d+.hereby.dev:4443)\/.+/.exec(roomAttribute);
|
|
504
|
+
const subdomain = (m && m[1]) || subdomainAttribute;
|
|
505
|
+
if (!subdomain) {
|
|
506
|
+
throw new Error("Missing subdomain attribute");
|
|
507
|
+
}
|
|
508
|
+
if (!m) {
|
|
509
|
+
throw new Error("Could not parse room URL");
|
|
510
|
+
}
|
|
511
|
+
const roomUrl = new URL(roomAttribute);
|
|
512
|
+
return {
|
|
513
|
+
subdomain,
|
|
514
|
+
roomUrl,
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
|
|
430
518
|
const initialLocalMediaState = {
|
|
431
519
|
busyDeviceIds: [],
|
|
432
520
|
cameraEnabled: false,
|
|
@@ -3017,6 +3105,7 @@ exports.createReactor = createReactor;
|
|
|
3017
3105
|
exports.createServices = createServices;
|
|
3018
3106
|
exports.createStore = createStore;
|
|
3019
3107
|
exports.createWebRtcEmitter = createWebRtcEmitter;
|
|
3108
|
+
exports.debounce = debounce;
|
|
3020
3109
|
exports.deviceBusy = deviceBusy;
|
|
3021
3110
|
exports.deviceCredentialsSlice = deviceCredentialsSlice;
|
|
3022
3111
|
exports.deviceIdentified = deviceIdentified;
|
|
@@ -3056,6 +3145,8 @@ exports.doStopScreenshare = doStopScreenshare;
|
|
|
3056
3145
|
exports.doSwitchLocalStream = doSwitchLocalStream;
|
|
3057
3146
|
exports.doToggleCamera = doToggleCamera;
|
|
3058
3147
|
exports.doUpdateDeviceList = doUpdateDeviceList;
|
|
3148
|
+
exports.fakeAudioStream = fakeAudioStream;
|
|
3149
|
+
exports.fakeWebcamFrame = fakeWebcamFrame;
|
|
3059
3150
|
exports.initialCloudRecordingState = initialCloudRecordingState;
|
|
3060
3151
|
exports.initialLocalMediaState = initialLocalMediaState;
|
|
3061
3152
|
exports.isAcceptingStreams = isAcceptingStreams;
|
|
@@ -3067,6 +3158,7 @@ exports.localScreenshareSlice = localScreenshareSlice;
|
|
|
3067
3158
|
exports.localStreamMetadataUpdated = localStreamMetadataUpdated;
|
|
3068
3159
|
exports.observeStore = observeStore;
|
|
3069
3160
|
exports.organizationSlice = organizationSlice;
|
|
3161
|
+
exports.parseRoomUrlAndSubdomain = parseRoomUrlAndSubdomain;
|
|
3070
3162
|
exports.participantStreamAdded = participantStreamAdded;
|
|
3071
3163
|
exports.participantStreamIdAdded = participantStreamIdAdded;
|
|
3072
3164
|
exports.recordingRequestStarted = recordingRequestStarted;
|