Files
SnowLuma/packages/proto-defs/package.json
T
DrSmoothl 6c7e56d5a1 refactor(proto-defs): extract wire-protobuf definitions into standalone package
Move `packages/core/src/bridge/proto/proton/*.ts` (13 files, ~3.3k
LOC) into a new `@snowluma/proto-defs` workspace package. The proton
spike landed in the previous commit means bare-specifier imports
(`@snowluma/proto-defs/oidb`, `…/message`, …) now resolve correctly
through proton's vite plugin, so call-site replacement still fires.

Why
---
- Lets downstream consumers share the same wire
  definitions without copy-pasting them — multiple workspace packages
  can now depend on `@snowluma/proto-defs` directly.
- Trims `@snowluma/core`'s surface: the bridge no longer owns the
  protocol schema, only its consumers.
- Sets up future #5 (`message-parsing perf`) and #6 (`Api-on-ctx
  refactor`) — both want a thinner core.

Layout
------
Per-file subpath exports (mirrors the legacy `proto/proton/<sub>`
shape 1:1). The barrel `index.ts` intentionally skips `highway` and
`oidb-actions/media` because the two files share six NTV2-prefixed
type names — `export *` would silently drop one side. Subpath imports
are unambiguous, which is also why every call site in core uses them.

Changes
-------
- New package `packages/proto-defs/` (package.json, tsconfig.json,
  src/index.ts).
- 13 `.ts` files moved via `git mv` to preserve history.
- 44 import sites across 26 source files + 15 tests rewritten via sed
  from `./[…/]proto/proton/<sub>` → `@snowluma/proto-defs/<sub>`.
- `@snowluma/core` depends on `@snowluma/proto-defs` (workspace:*).

Verification
------------
- proto-defs typecheck: clean
- core typecheck: clean
- core test suite: 587 passed (same baseline as before the refactor;
  one failure is the pre-existing websocket native addon, unrelated)
- proton test suite: 99 passed (8 files including the new
  cross-package.test.ts from the spike)
- Full workspace `pnpm -r typecheck`: all 8 projects clean

Note: proton's `dist/index.js` MUST be rebuilt for the vite plugin to
pick up the bare-specifier resolution. The previous commit's source
change is only effective after `pnpm -F @snowluma/proton build`.
2026-05-20 21:31:30 +08:00

74 lines
2.3 KiB
JSON

{
"name": "@snowluma/proto-defs",
"version": "1.9.0",
"private": true,
"type": "module",
"description": "SnowLuma QQ/Lagrange wire-protobuf type definitions. Pure TypeScript interfaces with proton's `pb<N, T>` marker types — `@snowluma/proton`'s vite plugin compiles them into zero-runtime encoder/decoder functions at the call sites in `@snowluma/core` (and any downstream consumer). Exposed as per-file subpaths (`@snowluma/proto-defs/oidb`, `@snowluma/proto-defs/message`, …) so the import-site shape mirrors the legacy `bridge/proto/proton/*` layout and avoids name collisions across files (notably `highway.ts` and `oidb-actions/media.ts` share NTV2-prefixed names).",
"main": "./src/index.ts",
"types": "./src/index.ts",
"exports": {
".": {
"types": "./src/index.ts",
"default": "./src/index.ts"
},
"./action": {
"types": "./src/action.ts",
"default": "./src/action.ts"
},
"./element": {
"types": "./src/element.ts",
"default": "./src/element.ts"
},
"./highway": {
"types": "./src/highway.ts",
"default": "./src/highway.ts"
},
"./longmsg": {
"types": "./src/longmsg.ts",
"default": "./src/longmsg.ts"
},
"./message": {
"types": "./src/message.ts",
"default": "./src/message.ts"
},
"./notify": {
"types": "./src/notify.ts",
"default": "./src/notify.ts"
},
"./oidb": {
"types": "./src/oidb.ts",
"default": "./src/oidb.ts"
},
"./oidb-action": {
"types": "./src/oidb-action.ts",
"default": "./src/oidb-action.ts"
},
"./oidb-actions/base": {
"types": "./src/oidb-actions/base.ts",
"default": "./src/oidb-actions/base.ts"
},
"./oidb-actions/group-album": {
"types": "./src/oidb-actions/group-album.ts",
"default": "./src/oidb-actions/group-album.ts"
},
"./oidb-actions/group-file": {
"types": "./src/oidb-actions/group-file.ts",
"default": "./src/oidb-actions/group-file.ts"
},
"./oidb-actions/media": {
"types": "./src/oidb-actions/media.ts",
"default": "./src/oidb-actions/media.ts"
}
},
"scripts": {
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@snowluma/proton": "workspace:*"
},
"devDependencies": {
"@types/node": "^24.12.2",
"typescript": "catalog:"
}
}