@evomap/evolver-core 2.0.0-beta.0 → 2.0.0-beta.1

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.
@@ -3,10 +3,20 @@ import { dirname } from 'node:path';
3
3
  import { createRequire } from 'node:module';
4
4
  import { ulid as makeUlid } from 'ulid';
5
5
  import { createEnvelope } from './envelope.js';
6
- // node:sqlite 是较新内建,只暴露 `node:sqlite`(无 `sqlite` 裸别名)。
7
- // 经 createRequire 动态加载,避免打包器静态剥前缀成 `sqlite` 后解析失败(vitest/vite)。
8
6
  const nodeRequire = createRequire(import.meta.url);
9
- const { DatabaseSync } = nodeRequire('node:sqlite');
7
+ function isBunRuntime() {
8
+ return typeof process.versions === 'object' && typeof process.versions.bun === 'string';
9
+ }
10
+ function openSqliteDatabase(path) {
11
+ if (isBunRuntime()) {
12
+ const { Database } = nodeRequire('bun:sqlite');
13
+ return new Database(path);
14
+ }
15
+ // node:sqlite is exposed only as `node:sqlite` (no bare `sqlite` alias). Load it through createRequire so
16
+ // bundlers do not statically strip the prefix and break Vitest/Vite or Bun standalone builds.
17
+ const { DatabaseSync } = nodeRequire('node:sqlite');
18
+ return new DatabaseSync(path);
19
+ }
10
20
  export const MAX_ATTEMPTS = 5;
11
21
  export const DEFAULT_IMPORT_JSONL_MAX_LINE_BYTES = 16 * 1024 * 1024;
12
22
  const JSONL_READ_CHUNK_BYTES = 64 * 1024;
@@ -95,7 +105,7 @@ export class MailboxStore {
95
105
  db;
96
106
  constructor(opts) {
97
107
  mkdirSync(dirname(opts.path), { recursive: true });
98
- this.db = new DatabaseSync(opts.path);
108
+ this.db = openSqliteDatabase(opts.path);
99
109
  this.db.exec('PRAGMA journal_mode = WAL');
100
110
  // PRAGMA can't be parameterized, so the value is string-interpolated — sanitize to a non-negative integer
101
111
  // first so a non-numeric busyTimeoutMs can never become SQL injection (defense-in-depth; #196).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evomap/evolver-core",
3
- "version": "2.0.0-beta.0",
3
+ "version": "2.0.0-beta.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "hub-无关核心: 算法引擎/原材料/mailbox/资产库/workflow",