feat: add async SQLite on Node 24 and improve messaging diagnostics (#520)
Move database work off the main thread on Node.js 24 and improve message handling and runtime diagnostics. Preserve migration, restart, and concurrency coverage with the async SQLite driver.
This commit is contained in:
1 parent
20f48d11ec
commit
c7428363cb
170 files changed
+7748
-3913
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import type { KnownMessageSegment, MessageSegment } from '../types/index';
|
||||
import type { AnyMessageSegment } from '../types/index';
|
||||
|
||||
export function escapeCqText(text: string): string {
|
||||
return text.replace(/&/g, '&').replace(/\[/g, '[').replace(/\]/g, ']');
|
||||
@@ -8,15 +8,23 @@ export function escapeCqParam(text: string): string {
|
||||
return escapeCqText(text).replace(/,/g, ',');
|
||||
}
|
||||
|
||||
export function segmentsToCQString(segments: Array<KnownMessageSegment | MessageSegment>): string {
|
||||
export function segmentsToCQString(segments: AnyMessageSegment[]): string {
|
||||
return segments.map(segmentToCq).join('');
|
||||
}
|
||||
|
||||
function segmentToCq(segment: KnownMessageSegment | MessageSegment): string {
|
||||
function segmentToCq(segment: AnyMessageSegment): string {
|
||||
if (segment.type === 'text') {
|
||||
return escapeCqText(String(segment.data.text ?? ''));
|
||||
}
|
||||
|
||||
if (
|
||||
segment.type === 'reply' &&
|
||||
segment.data.message !== undefined &&
|
||||
typeof segment.data.message !== 'string'
|
||||
) {
|
||||
throw new TypeError('reply.message containing message segments must be sent as JSON');
|
||||
}
|
||||
|
||||
const params = Object.entries(segment.data)
|
||||
.filter(([, value]) => value !== undefined && value !== null)
|
||||
.map(([key, value]) => `${key}=${escapeCqParam(String(value))}`)
|
||||
|
||||
Reference in new issue
Block a user