orez 0.4.7 → 0.4.9
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.
- package/dist/cf-do/worker.d.ts +1 -0
- package/dist/cf-do/worker.d.ts.map +1 -1
- package/dist/cf-do/worker.js +21 -0
- package/dist/cf-do/worker.js.map +1 -1
- package/dist/pg-proxy-do-backend.d.ts +8 -0
- package/dist/pg-proxy-do-backend.d.ts.map +1 -1
- package/dist/pg-proxy-do-backend.js +12 -1
- package/dist/pg-proxy-do-backend.js.map +1 -1
- package/dist/worker/embed-generation.d.ts +36 -0
- package/dist/worker/embed-generation.d.ts.map +1 -0
- package/dist/worker/embed-generation.js +49 -0
- package/dist/worker/embed-generation.js.map +1 -0
- package/dist/worker/shims/fastify.d.ts +9 -0
- package/dist/worker/shims/fastify.d.ts.map +1 -1
- package/dist/worker/shims/fastify.js +12 -0
- package/dist/worker/shims/fastify.js.map +1 -1
- package/dist/worker/shims/sqlite.d.ts +0 -20
- package/dist/worker/shims/sqlite.d.ts.map +1 -1
- package/dist/worker/shims/sqlite.js +28 -0
- package/dist/worker/shims/sqlite.js.map +1 -1
- package/dist/worker/zero-cache-embed-cf.d.ts.map +1 -1
- package/dist/worker/zero-cache-embed-cf.js +12 -0
- package/dist/worker/zero-cache-embed-cf.js.map +1 -1
- package/dist/worker/zero-cache-embed.d.ts.map +1 -1
- package/dist/worker/zero-cache-embed.js +14 -0
- package/dist/worker/zero-cache-embed.js.map +1 -1
- package/dist/zero-sqlite-handle-patch.d.ts +26 -0
- package/dist/zero-sqlite-handle-patch.d.ts.map +1 -0
- package/dist/zero-sqlite-handle-patch.js +68 -0
- package/dist/zero-sqlite-handle-patch.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* register zero-cache's sqlite handles for the embed restart contract (node).
|
|
3
|
+
*
|
|
4
|
+
* zero-cache opens every sqlite connection through zqlite's `Database`
|
|
5
|
+
* wrapper. this patch adds pure tracking to the compiled wrapper: each
|
|
6
|
+
* instance registers itself in `globalThis.__orez_open_sqlite_dbs` on open
|
|
7
|
+
* and deregisters on close. when the registry global is absent (the normal
|
|
8
|
+
* child-process zero-cache, or the write-worker thread's own isolate) the
|
|
9
|
+
* optional-chained calls are no-ops, so behavior is unchanged everywhere.
|
|
10
|
+
*
|
|
11
|
+
* the registry exists so a second embed generation in the same process can
|
|
12
|
+
* reclaim handles the dead generation leaked — see
|
|
13
|
+
* worker/embed-generation.ts for the contract. on CF the sqlite shim
|
|
14
|
+
* registers its own instances instead, so the overlay does not need this
|
|
15
|
+
* patch.
|
|
16
|
+
*
|
|
17
|
+
* same in-place patching pattern as zero-litestream-patch.ts: idempotent,
|
|
18
|
+
* only touches orez's own resolved @rocicorp/zero.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* patch zero-cache's sqlite Database wrapper to register open handles in
|
|
22
|
+
* `globalThis.__orez_open_sqlite_dbs`. idempotent and safe to call on
|
|
23
|
+
* every startup.
|
|
24
|
+
*/
|
|
25
|
+
export declare function installZeroSqliteHandleRegistry(): void;
|
|
26
|
+
//# sourceMappingURL=zero-sqlite-handle-patch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zero-sqlite-handle-patch.d.ts","sourceRoot":"","sources":["../src/zero-sqlite-handle-patch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAiCH;;;;GAIG;AACH,wBAAgB,+BAA+B,IAAI,IAAI,CAoBtD"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* register zero-cache's sqlite handles for the embed restart contract (node).
|
|
3
|
+
*
|
|
4
|
+
* zero-cache opens every sqlite connection through zqlite's `Database`
|
|
5
|
+
* wrapper. this patch adds pure tracking to the compiled wrapper: each
|
|
6
|
+
* instance registers itself in `globalThis.__orez_open_sqlite_dbs` on open
|
|
7
|
+
* and deregisters on close. when the registry global is absent (the normal
|
|
8
|
+
* child-process zero-cache, or the write-worker thread's own isolate) the
|
|
9
|
+
* optional-chained calls are no-ops, so behavior is unchanged everywhere.
|
|
10
|
+
*
|
|
11
|
+
* the registry exists so a second embed generation in the same process can
|
|
12
|
+
* reclaim handles the dead generation leaked — see
|
|
13
|
+
* worker/embed-generation.ts for the contract. on CF the sqlite shim
|
|
14
|
+
* registers its own instances instead, so the overlay does not need this
|
|
15
|
+
* patch.
|
|
16
|
+
*
|
|
17
|
+
* same in-place patching pattern as zero-litestream-patch.ts: idempotent,
|
|
18
|
+
* only touches orez's own resolved @rocicorp/zero.
|
|
19
|
+
*/
|
|
20
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
21
|
+
import { dirname, resolve } from 'node:path';
|
|
22
|
+
import { resolvePackage } from './sqlite-mode/package-resolve.js';
|
|
23
|
+
const OREZ_MARKER = '__orez_open_sqlite_dbs';
|
|
24
|
+
const OPEN_ANCHOR = 'this.#db = new SQLite3Database(path, options);';
|
|
25
|
+
const OPEN_HOOK = `${OPEN_ANCHOR}
|
|
26
|
+
globalThis.__orez_open_sqlite_dbs?.add(this); /* orez: embed handle registry */`;
|
|
27
|
+
const CLOSE_ANCHOR = '\tclose() {';
|
|
28
|
+
const CLOSE_HOOK = `\tclose() {
|
|
29
|
+
globalThis.__orez_open_sqlite_dbs?.delete(this); /* orez: embed handle registry */`;
|
|
30
|
+
/** locate the compiled zqlite db.js inside the resolved @rocicorp/zero */
|
|
31
|
+
function findZqliteDb() {
|
|
32
|
+
const zeroEntry = resolvePackage('@rocicorp/zero');
|
|
33
|
+
if (!zeroEntry)
|
|
34
|
+
return null;
|
|
35
|
+
let dir = dirname(zeroEntry);
|
|
36
|
+
while (dir && !existsSync(resolve(dir, 'package.json'))) {
|
|
37
|
+
const parent = resolve(dir, '..');
|
|
38
|
+
if (parent === dir)
|
|
39
|
+
break;
|
|
40
|
+
dir = parent;
|
|
41
|
+
}
|
|
42
|
+
const dbPath = resolve(dir, 'out', 'zqlite', 'src', 'db.js');
|
|
43
|
+
return existsSync(dbPath) ? dbPath : null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* patch zero-cache's sqlite Database wrapper to register open handles in
|
|
47
|
+
* `globalThis.__orez_open_sqlite_dbs`. idempotent and safe to call on
|
|
48
|
+
* every startup.
|
|
49
|
+
*/
|
|
50
|
+
export function installZeroSqliteHandleRegistry() {
|
|
51
|
+
const dbPath = findZqliteDb();
|
|
52
|
+
if (!dbPath)
|
|
53
|
+
return;
|
|
54
|
+
const content = readFileSync(dbPath, 'utf-8');
|
|
55
|
+
if (content.includes(OREZ_MARKER))
|
|
56
|
+
return; // already patched
|
|
57
|
+
if (!content.includes(OPEN_ANCHOR) || !content.includes(CLOSE_ANCHOR)) {
|
|
58
|
+
// upstream shape changed — fail loudly so the embed restart contract
|
|
59
|
+
// never silently loses handle tracking.
|
|
60
|
+
throw new Error(`orez: could not patch zqlite Database handle registry — anchors not found in ${dbPath}. ` +
|
|
61
|
+
`@rocicorp/zero may have changed; update zero-sqlite-handle-patch.ts.`);
|
|
62
|
+
}
|
|
63
|
+
const patched = content
|
|
64
|
+
.replace(OPEN_ANCHOR, OPEN_HOOK)
|
|
65
|
+
.replace(CLOSE_ANCHOR, CLOSE_HOOK);
|
|
66
|
+
writeFileSync(dbPath, patched);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=zero-sqlite-handle-patch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zero-sqlite-handle-patch.js","sourceRoot":"","sources":["../src/zero-sqlite-handle-patch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,kCA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EAAE,CAAC;QACtE,qEAAqE;QACrE,wCAAwC;QACxC,MAAM,IAAI,KAAK,CACb,gFAAgF,MAAM,IAAI;YACxF,sEAAsE,CACzE,CAAA;IACH,CAAC;IAED,MAAM,OAAO,GAAG,OAAO;SACpB,OAAO,CAAC,WAAW,EAAE,SAAS,CAAC;SAC/B,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;IACpC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orez",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"description": "PGlite-powered zero-sync development backend. No Docker required.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"@electric-sql/pglite": "0.4.1",
|
|
88
88
|
"@electric-sql/pglite-tools": "^0.3.1",
|
|
89
89
|
"@pgsql/traverse": "17.2.6",
|
|
90
|
-
"bedrock-sqlite": "0.4.
|
|
90
|
+
"bedrock-sqlite": "0.4.9",
|
|
91
91
|
"citty": "^0.2.0",
|
|
92
92
|
"pg-gateway": "0.3.0-beta.4",
|
|
93
93
|
"pgsql-parser": "^17.9.11",
|