mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 18:46:19 +08:00
feat: bump eslint & oxlint (#14452)
#### PR Dependency Tree * **PR #14452** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved null-safety, dependency tracking, upload validation, and error logging for more reliable uploads, clipboard, calendar linking, telemetry, PDF/theme printing, and preview/zoom behavior. * Tightened handling of all-day calendar events (missing date now reported). * **Deprecations** * Removed deprecated RadioButton and RadioButtonGroup; use RadioGroup. * **Chores** * Unified and upgraded linting/config, reorganized imports, and standardized binary handling for more consistent builds and tooling. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Convert binary data to a strict ArrayBuffer for DOM APIs whose types
|
||||
* require ArrayBuffer-backed views (not ArrayBufferLike).
|
||||
*/
|
||||
export function toArrayBuffer(
|
||||
data: ArrayBuffer | ArrayBufferLike | ArrayBufferView
|
||||
): ArrayBuffer {
|
||||
if (data instanceof ArrayBuffer) {
|
||||
return data;
|
||||
}
|
||||
|
||||
if (ArrayBuffer.isView(data)) {
|
||||
if (data.buffer instanceof ArrayBuffer) {
|
||||
if (data.byteOffset === 0 && data.byteLength === data.buffer.byteLength) {
|
||||
return data.buffer;
|
||||
}
|
||||
return data.buffer.slice(
|
||||
data.byteOffset,
|
||||
data.byteOffset + data.byteLength
|
||||
);
|
||||
}
|
||||
|
||||
const bytes = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
||||
const copy = new Uint8Array(bytes.byteLength);
|
||||
copy.set(bytes);
|
||||
return copy.buffer;
|
||||
}
|
||||
|
||||
const bytes = new Uint8Array(data);
|
||||
const copy = new Uint8Array(bytes.byteLength);
|
||||
copy.set(bytes);
|
||||
return copy.buffer;
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { apis } from '@affine/electron-api';
|
||||
import { ArrayBufferTarget, Muxer } from 'mp4-muxer';
|
||||
|
||||
import { isLink } from '../modules/navigation/utils';
|
||||
import { toArrayBuffer } from './array-buffer';
|
||||
|
||||
interface AudioEncodingConfig {
|
||||
sampleRate: number;
|
||||
@@ -38,16 +39,6 @@ async function blobToArrayBuffer(
|
||||
return toArrayBuffer(blob);
|
||||
}
|
||||
|
||||
function toArrayBuffer(data: ArrayBuffer | ArrayBufferView): ArrayBuffer {
|
||||
if (data instanceof ArrayBuffer) {
|
||||
return data;
|
||||
}
|
||||
return data.buffer.slice(
|
||||
data.byteOffset,
|
||||
data.byteOffset + data.byteLength
|
||||
) as ArrayBuffer;
|
||||
}
|
||||
|
||||
function getRecordingFileUrl(filepath: string): URL {
|
||||
const base =
|
||||
typeof location !== 'undefined' && location.protocol === 'assets:'
|
||||
@@ -175,7 +166,7 @@ async function encodeAudioFrames({
|
||||
numberOfFrames: chunk.length / numberOfChannels,
|
||||
numberOfChannels,
|
||||
timestamp: (offset * 1000000) / sampleRate,
|
||||
data: chunk,
|
||||
data: toArrayBuffer(chunk),
|
||||
});
|
||||
|
||||
encoder.encode(frame);
|
||||
@@ -448,7 +439,7 @@ export const createStreamEncoder = (
|
||||
numberOfFrames:
|
||||
buffer.length / BYTES_PER_SAMPLE / codecs.numberOfChannels,
|
||||
timestamp: 0,
|
||||
data: buffer,
|
||||
data: toArrayBuffer(buffer),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user