diff --git a/packages/core/src/bridge/apis/group-album.ts b/packages/core/src/bridge/apis/group-album.ts index 77e0e1b6..c6ecf9cd 100644 --- a/packages/core/src/bridge/apis/group-album.ts +++ b/packages/core/src/bridge/apis/group-album.ts @@ -10,25 +10,8 @@ import type { } from '@snowluma/proto-defs/oidb-actions/group-album'; import { getGroupAlbumList, uploadImageToGroupAlbum } from '@snowluma/protocol/web/group-album'; import { protobuf_decode, protobuf_encode } from '@snowluma/proton'; -import type { Bridge } from '../bridge'; import type { BridgeContext } from '../bridge-context'; -// `getCookies` is part of WebApi — go through the hub so we don't -// duplicate the cookie acquisition flow. -function asBridge(ctx: BridgeContext): Bridge { return ctx as unknown as Bridge; } - -export interface GroupAlbumMediaResult { - mediaList: any[]; - nextAttachInfo: string; -} - -export interface GroupAlbumCommentResult { - id: string; - user: { uin: string }; - content: Array<{ type: number; content: string }>; - time: string; - clientKey: string; -} function convertBigIntToString(obj: any): any { if (obj === null || obj === undefined) return obj; @@ -277,3 +260,15 @@ export class GroupAlbumApi { return { success: true }; } } +export interface GroupAlbumMediaResult { + mediaList: any[]; + nextAttachInfo: string; +} + +export interface GroupAlbumCommentResult { + id: string; + user: { uin: string }; + content: Array<{ type: number; content: string }>; + time: string; + clientKey: string; +} diff --git a/packages/sqlite/src/index.ts b/packages/sqlite/src/index.ts index 7ccfd6a2..72d47db8 100644 --- a/packages/sqlite/src/index.ts +++ b/packages/sqlite/src/index.ts @@ -1,43 +1,13 @@ -// @snowluma/sqlite — wraps better-sqlite3 so the native `.node` binding -// is loaded from -// `dist/native/better-sqlite3-v--.node` instead -// of `node_modules/better-sqlite3/build/Release/`. This lets the -// production artifact ship as a single self-contained `dist/` -// directory (no `dist/node_modules/`, no `npm install --omit=dev` -// step) — the same pattern SnowLuma already uses for its -// `websocket--.node` and `snowluma-*.{dll,node,so}` -// addons (flat dir, dash-separated triplet). -// -// How it works: -// 1. better-sqlite3's `Database` constructor accepts a `nativeBinding` -// option (string path or already-`require()`-ed object) that -// overrides the default `require('bindings')('better_sqlite3.node')` -// lookup. We forward through every other option/argument -// verbatim and inject this one. -// 2. The vendored `.node` lives at one of two locations depending -// on whether we're in dev (workspace TS source) or production -// (bundled into dist/native/): -// - Prod: `/native/better-sqlite3-v-.node` -// - Dev: `/packages/runtime/native/better-sqlite3-v-.node` -// We probe both paths and take whichever exists. -// 3. `` is `-` (e.g. -// `darwin-arm64`, `linux-x64`, `linux-arm64`, `win32-x64`). -// 4. `` is `process.versions.modules` (NODE_MODULE_VERSION). -// better-sqlite3 is NOT N-API — its binding is locked to one -// Node ABI per build. Vendoring `vNNN` in the filename lets us -// ship multiple ABIs side-by-side (e.g. v127 for Node 22 LTS -// shipped to CI, v137 for Node 24 used by some dev boxes). - -import { createRequire } from 'node:module'; -import { fileURLToPath } from 'node:url'; -import { dirname, join, resolve } from 'node:path'; -import { existsSync } from 'node:fs'; import BetterSqlite3 from 'better-sqlite3'; +import { existsSync } from 'node:fs'; +import { createRequire } from 'node:module'; +import { dirname, join, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; // Re-export the public types/classes consumers need. `Database` and // `Statement` come straight from better-sqlite3 — we only intercept // the constructor at call time, not the class shape. -export type { Database, Statement, RunResult, Options } from 'better-sqlite3'; +export type { Database, Options, RunResult, Statement } from 'better-sqlite3'; function triplet(): string { return `${process.platform}-${process.arch}`; @@ -111,7 +81,7 @@ const Database = function Database(filename?: string | Buffer, options?: Databas // but its default export is a callable that *also* returns it via // an internal `new.target == null` branch. TS can't reconcile the // two without `as any`. - // eslint-disable-next-line @typescript-eslint/no-explicit-any + return new (BetterSqlite3 as any)(filename, opts); } as unknown as BetterSqlite3Type;