orez 0.4.36 → 0.4.37
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.
|
@@ -17,6 +17,12 @@
|
|
|
17
17
|
* same in-place patching pattern as zero-litestream-patch.ts: idempotent,
|
|
18
18
|
* only touches orez's own resolved @rocicorp/zero.
|
|
19
19
|
*/
|
|
20
|
+
/**
|
|
21
|
+
* apply the handle-registry hooks to a specific compiled zqlite db.js.
|
|
22
|
+
* idempotent. shared entrypoint so it can be tested against real bundled
|
|
23
|
+
* output without resolving the installed package.
|
|
24
|
+
*/
|
|
25
|
+
export declare function applyZqliteHandleRegistry(dbPath: string): void;
|
|
20
26
|
/**
|
|
21
27
|
* patch zero-cache's sqlite Database wrapper to register open handles in
|
|
22
28
|
* `globalThis.__orez_open_sqlite_dbs`. idempotent and safe to call on
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zero-sqlite-handle-patch.d.ts","sourceRoot":"","sources":["../src/zero-sqlite-handle-patch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
1
|
+
{"version":3,"file":"zero-sqlite-handle-patch.d.ts","sourceRoot":"","sources":["../src/zero-sqlite-handle-patch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAsCH;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAiB9D;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,IAAI,IAAI,CAItD"}
|
|
@@ -21,8 +21,13 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
|
21
21
|
import { dirname, resolve } from 'node:path';
|
|
22
22
|
import { resolvePackage } from './sqlite-mode/package-resolve.js';
|
|
23
23
|
const OREZ_MARKER = '__orez_open_sqlite_dbs';
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
// the constructor's default-import binding for @rocicorp/zero-sqlite3 is chosen
|
|
25
|
+
// by zero's bundler and has flipped between `SQLite3Database` and
|
|
26
|
+
// `Sqlite3Database` across releases from identical source (rolldown re-picks the
|
|
27
|
+
// canonical name for the shared default import whenever a co-bundled module's
|
|
28
|
+
// imports change). match either spelling so the anchor survives that reshuffle.
|
|
29
|
+
const OPEN_ANCHOR = /this\.#db = new S[qQ][lL]ite3Database\(path, options\);/;
|
|
30
|
+
const OPEN_HOOK_SUFFIX = `
|
|
26
31
|
globalThis.__orez_open_sqlite_dbs?.add(this); /* orez: embed handle registry */`;
|
|
27
32
|
const CLOSE_ANCHOR = '\tclose() {';
|
|
28
33
|
const CLOSE_HOOK = `\tclose() {
|
|
@@ -43,26 +48,34 @@ function findZqliteDb() {
|
|
|
43
48
|
return existsSync(dbPath) ? dbPath : null;
|
|
44
49
|
}
|
|
45
50
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
51
|
+
* apply the handle-registry hooks to a specific compiled zqlite db.js.
|
|
52
|
+
* idempotent. shared entrypoint so it can be tested against real bundled
|
|
53
|
+
* output without resolving the installed package.
|
|
49
54
|
*/
|
|
50
|
-
export function
|
|
51
|
-
const dbPath = findZqliteDb();
|
|
52
|
-
if (!dbPath)
|
|
53
|
-
return;
|
|
55
|
+
export function applyZqliteHandleRegistry(dbPath) {
|
|
54
56
|
const content = readFileSync(dbPath, 'utf-8');
|
|
55
57
|
if (content.includes(OREZ_MARKER))
|
|
56
58
|
return; // already patched
|
|
57
|
-
if (!
|
|
59
|
+
if (!OPEN_ANCHOR.test(content) || !content.includes(CLOSE_ANCHOR)) {
|
|
58
60
|
// upstream shape changed — fail loudly so the embed restart contract
|
|
59
61
|
// never silently loses handle tracking.
|
|
60
62
|
throw new Error(`orez: could not patch zqlite Database handle registry — anchors not found in ${dbPath}. ` +
|
|
61
63
|
`@rocicorp/zero may have changed; update zero-sqlite-handle-patch.ts.`);
|
|
62
64
|
}
|
|
63
65
|
const patched = content
|
|
64
|
-
.replace(OPEN_ANCHOR,
|
|
66
|
+
.replace(OPEN_ANCHOR, (match) => `${match}${OPEN_HOOK_SUFFIX}`)
|
|
65
67
|
.replace(CLOSE_ANCHOR, CLOSE_HOOK);
|
|
66
68
|
writeFileSync(dbPath, patched);
|
|
67
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* patch zero-cache's sqlite Database wrapper to register open handles in
|
|
72
|
+
* `globalThis.__orez_open_sqlite_dbs`. idempotent and safe to call on
|
|
73
|
+
* every startup.
|
|
74
|
+
*/
|
|
75
|
+
export function installZeroSqliteHandleRegistry() {
|
|
76
|
+
const dbPath = findZqliteDb();
|
|
77
|
+
if (!dbPath)
|
|
78
|
+
return;
|
|
79
|
+
applyZqliteHandleRegistry(dbPath);
|
|
80
|
+
}
|
|
68
81
|
//# sourceMappingURL=zero-sqlite-handle-patch.js.map
|
|
@@ -1 +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,kCAAkC,CAAA;AAEjE,MAAM,WAAW,GAAG,wBAAwB,CAAA;AAE5C,MAAM,WAAW,GAAG,
|
|
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,kCAAkC,CAAA;AAEj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AAqE;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,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,GAAG,gBAAgB,EAAE,CAAC;SAC9D,OAAO,CAAC,YAAY,EAAE,UAAU,CAAC,CAAA;IACpC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,+BAA+B;IAC7C,MAAM,MAAM,GAAG,YAAY,EAAE,CAAA;IAC7B,IAAI,CAAC,MAAM;QAAE,OAAM;IACnB,yBAAyB,CAAC,MAAM,CAAC,CAAA;AACnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orez",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.37",
|
|
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.37",
|
|
91
91
|
"citty": "^0.2.0",
|
|
92
92
|
"pg-gateway": "0.3.0-beta.4",
|
|
93
93
|
"pgsql-parser": "^17.9.11",
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
}
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
|
-
"@rocicorp/zero": "1.7.0
|
|
110
|
+
"@rocicorp/zero": "1.7.0",
|
|
111
111
|
"@rocicorp/zero-sqlite3": "1.1.2",
|
|
112
112
|
"@types/node": "^22.0.0",
|
|
113
113
|
"@types/ws": "^8.18.1",
|