orez 0.2.27 → 0.2.30
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 +3 -0
- package/dist/cf-do/worker.d.ts.map +1 -1
- package/dist/cf-do/worker.js +37 -15
- package/dist/cf-do/worker.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
- package/src/admin/admin-data.test.ts +0 -348
- package/src/admin/http-proxy.ts +0 -252
- package/src/admin/log-store.ts +0 -192
- package/src/admin/server.ts +0 -471
- package/src/admin/ui.ts +0 -1322
- package/src/bench/proxy-throughput.bench.ts +0 -343
- package/src/bench/serial-mutations.bench.ts +0 -270
- package/src/browser.ts +0 -203
- package/src/cf-do/.wrangler/cache/cf.json +0 -1
- package/src/cf-do/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite +0 -0
- package/src/cf-do/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite-shm +0 -0
- package/src/cf-do/.wrangler/state/v3/cache/miniflare-CacheObject/metadata.sqlite-wal +0 -0
- package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/0ffaabee41a60e04dd0eb7db3073f0a40139e6a97ccd26823967acb652b89a7b.sqlite +0 -0
- package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/metadata.sqlite +0 -0
- package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/metadata.sqlite-shm +0 -0
- package/src/cf-do/.wrangler/state/v3/do/zero-do-ZeroDO/metadata.sqlite-wal +0 -0
- package/src/cf-do/.wrangler/tmp/bundle-0z4CpE/middleware-insertion-facade.js +0 -11
- package/src/cf-do/.wrangler/tmp/bundle-0z4CpE/middleware-loader.entry.ts +0 -134
- package/src/cf-do/.wrangler/tmp/bundle-vYmw0E/middleware-insertion-facade.js +0 -11
- package/src/cf-do/.wrangler/tmp/bundle-vYmw0E/middleware-loader.entry.ts +0 -134
- package/src/cf-do/.wrangler/tmp/dev-cbILNo/worker.js +0 -1059
- package/src/cf-do/.wrangler/tmp/dev-cbILNo/worker.js.map +0 -8
- package/src/cf-do/.wrangler/tmp/dev-qbho19/worker.js +0 -1059
- package/src/cf-do/.wrangler/tmp/dev-qbho19/worker.js.map +0 -8
- package/src/cf-do/ARCHITECTURE.md +0 -93
- package/src/cf-do/CHAT_E2E.md +0 -213
- package/src/cf-do/watermark.test.ts +0 -103
- package/src/cf-do/watermark.ts +0 -118
- package/src/cf-do/worker.ts +0 -1041
- package/src/cf-do/wrangler.toml +0 -11
- package/src/cf-pglite/README.md +0 -19
- package/src/change-tracking.ts +0 -25
- package/src/child-process.test.ts +0 -147
- package/src/child-process.ts +0 -90
- package/src/cli-entry.ts +0 -72
- package/src/cli.test.ts +0 -40
- package/src/cli.ts +0 -1214
- package/src/config.ts +0 -150
- package/src/do-sql-tracking.test.ts +0 -19
- package/src/do-sql-tracking.ts +0 -19
- package/src/index.ts +0 -1215
- package/src/integration/integration.test.ts +0 -517
- package/src/integration/native-binary.guard.test.ts +0 -13
- package/src/integration/native-startup.test.ts +0 -44
- package/src/integration/replication-latency.test.ts +0 -428
- package/src/integration/restore-live-stress.test.ts +0 -433
- package/src/integration/restore-reset.test.ts +0 -400
- package/src/integration/restore.test.ts +0 -274
- package/src/integration/test-permissions.ts +0 -147
- package/src/load-config.ts +0 -46
- package/src/log.ts +0 -96
- package/src/mutex.ts +0 -47
- package/src/pg-proxy-browser.singledb.test.ts +0 -233
- package/src/pg-proxy-browser.ts +0 -2022
- package/src/pg-proxy-do-backend.test.ts +0 -3890
- package/src/pg-proxy-do-backend.ts +0 -7191
- package/src/pg-proxy.ts +0 -1087
- package/src/pg-sqlite-compiler/README.md +0 -53
- package/src/pg-sqlite-compiler/catalog/seed.ts +0 -524
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/arithmetic.json +0 -307
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/array.json +0 -377
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/cast.json +0 -12
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/catalog.json +0 -447
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/create-table.json +0 -32
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/datetime.json +0 -397
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/enum.json +0 -337
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/insert.json +0 -337
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/json.json +0 -537
- package/src/pg-sqlite-compiler/fixtures/pgsqlite/misc.json +0 -1837
- package/src/pg-sqlite-compiler/index.ts +0 -73
- package/src/pg-sqlite-compiler/integration.test.ts +0 -136
- package/src/pg-sqlite-compiler/passes/ast-utils.ts +0 -113
- package/src/pg-sqlite-compiler/passes/catalog.ts +0 -65
- package/src/pg-sqlite-compiler/passes/datetime.ts +0 -74
- package/src/pg-sqlite-compiler/passes/index.ts +0 -49
- package/src/pg-sqlite-compiler/passes/types.ts +0 -156
- package/src/pg-sqlite-compiler/smoke.test.ts +0 -69
- package/src/pg-sqlite-compiler/test/catalog.test.ts +0 -171
- package/src/pg-sqlite-compiler/test/corpus.test.ts +0 -161
- package/src/pg-sqlite-compiler/test/datetime.oracle.test.ts +0 -102
- package/src/pg-sqlite-compiler/test/oracle.ts +0 -237
- package/src/pg-sqlite-compiler/test/types.test.ts +0 -109
- package/src/pg-sqlite-compiler/types.ts +0 -63
- package/src/pglite-ipc.test.ts +0 -116
- package/src/pglite-ipc.ts +0 -266
- package/src/pglite-manager.ts +0 -557
- package/src/pglite-web-proxy.test.ts +0 -57
- package/src/pglite-web-proxy.ts +0 -221
- package/src/pglite-web-worker.ts +0 -152
- package/src/pglite-worker-thread.ts +0 -253
- package/src/port.ts +0 -25
- package/src/process-title.ts +0 -9
- package/src/recovery.ts +0 -155
- package/src/replication/change-tracker.test.ts +0 -357
- package/src/replication/change-tracker.ts +0 -279
- package/src/replication/handler.test.ts +0 -511
- package/src/replication/handler.ts +0 -1190
- package/src/replication/pgoutput-encoder.test.ts +0 -697
- package/src/replication/pgoutput-encoder.ts +0 -373
- package/src/replication/tcp-replication.test.ts +0 -876
- package/src/replication/zero-compat.test.ts +0 -1150
- package/src/restore-stress.test.ts +0 -188
- package/src/s3-local.ts +0 -203
- package/src/shim/hooks.mjs +0 -120
- package/src/shim/register.mjs +0 -4
- package/src/sqlite-mode/apply-mode.ts +0 -224
- package/src/sqlite-mode/index.ts +0 -15
- package/src/sqlite-mode/native-binary.ts +0 -89
- package/src/sqlite-mode/package-resolve.ts +0 -17
- package/src/sqlite-mode/resolve-mode.ts +0 -80
- package/src/sqlite-mode/shim-template.ts +0 -159
- package/src/sqlite-mode/sqlite-mode.test.ts +0 -427
- package/src/sqlite-mode/types.ts +0 -30
- package/src/vite-plugin.ts +0 -67
- package/src/wasm-sqlite.test.ts +0 -537
- package/src/worker/browser-admin.ts +0 -52
- package/src/worker/browser-build-config.test.ts +0 -71
- package/src/worker/browser-build-config.ts +0 -109
- package/src/worker/browser-embed-admin.test.ts +0 -75
- package/src/worker/browser-embed.ts +0 -345
- package/src/worker/cf-patches.ts +0 -384
- package/src/worker/embed-integration.test.ts +0 -321
- package/src/worker/index.ts +0 -138
- package/src/worker/shims/fastify.test.ts +0 -255
- package/src/worker/shims/fastify.ts +0 -306
- package/src/worker/shims/http-service.test.ts +0 -355
- package/src/worker/shims/http-service.ts +0 -293
- package/src/worker/shims/node-stub.ts +0 -290
- package/src/worker/shims/oxfmt.ts +0 -3
- package/src/worker/shims/postgres-browser.ts +0 -59
- package/src/worker/shims/postgres-socket.test.ts +0 -576
- package/src/worker/shims/postgres-socket.ts +0 -310
- package/src/worker/shims/postgres.test.ts +0 -364
- package/src/worker/shims/postgres.ts +0 -1454
- package/src/worker/shims/sqlite-browser.test.ts +0 -233
- package/src/worker/shims/sqlite-browser.ts +0 -175
- package/src/worker/shims/sqlite.test.ts +0 -786
- package/src/worker/shims/sqlite.ts +0 -978
- package/src/worker/shims/stream-browser.ts +0 -15
- package/src/worker/shims/ws-browser.test.ts +0 -205
- package/src/worker/shims/ws-browser.ts +0 -248
- package/src/worker/shims/ws.test.ts +0 -288
- package/src/worker/shims/ws.ts +0 -467
- package/src/worker/shims/zero-process-env.ts +0 -11
- package/src/worker/types.ts +0 -75
- package/src/worker/worker-integration.test.ts +0 -223
- package/src/worker/worker.test.ts +0 -136
- package/src/worker/zero-cache-embed-cf.ts +0 -463
- package/src/worker/zero-cache-embed.ts +0 -277
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* stub for Node.js built-in modules not used in SINGLE_PROCESS mode.
|
|
3
|
-
*
|
|
4
|
-
* zero-cache imports modules like node:fs, node:net, node:child_process
|
|
5
|
-
* at the top level, but only uses them in multi-process mode. in
|
|
6
|
-
* SINGLE_PROCESS mode (browser or CF Workers), these imports are dead
|
|
7
|
-
* code. this stub provides empty exports so the bundler can resolve them.
|
|
8
|
-
*
|
|
9
|
-
* usage with bundler alias:
|
|
10
|
-
* alias: { 'node:fs': 'orez/worker/shims/node-stub' }
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
// stub for node:http (Server class used in instanceof check)
|
|
14
|
-
export class Server {}
|
|
15
|
-
|
|
16
|
-
// stub for node:fs
|
|
17
|
-
export function existsSync() {
|
|
18
|
-
return false
|
|
19
|
-
}
|
|
20
|
-
export function readFileSync() {
|
|
21
|
-
return ''
|
|
22
|
-
}
|
|
23
|
-
export function writeFileSync() {}
|
|
24
|
-
export function rmSync() {}
|
|
25
|
-
export function mkdirSync() {}
|
|
26
|
-
export function statSync() {
|
|
27
|
-
return { size: 0, isFile: () => false, isDirectory: () => false }
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// stub for node:fs/promises
|
|
31
|
-
export function writeFile() {
|
|
32
|
-
return Promise.resolve()
|
|
33
|
-
}
|
|
34
|
-
export function readFile() {
|
|
35
|
-
return Promise.resolve('')
|
|
36
|
-
}
|
|
37
|
-
export function stat() {
|
|
38
|
-
return Promise.resolve({ size: 0, isFile: () => false, isDirectory: () => false })
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// stub for node:child_process
|
|
42
|
-
export function fork() {
|
|
43
|
-
throw new Error('fork() not available in browser')
|
|
44
|
-
}
|
|
45
|
-
export function spawn() {
|
|
46
|
-
throw new Error('spawn() not available in browser')
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// stub for node:net
|
|
50
|
-
export function createServer() {
|
|
51
|
-
return new Server()
|
|
52
|
-
}
|
|
53
|
-
export function createConnection() {
|
|
54
|
-
throw new Error('createConnection() not available in browser')
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// stub for node:os
|
|
58
|
-
export function hostname() {
|
|
59
|
-
return 'browser'
|
|
60
|
-
}
|
|
61
|
-
export function platform() {
|
|
62
|
-
return 'browser'
|
|
63
|
-
}
|
|
64
|
-
export function tmpdir() {
|
|
65
|
-
return '/tmp'
|
|
66
|
-
}
|
|
67
|
-
export function homedir() {
|
|
68
|
-
return '/tmp'
|
|
69
|
-
}
|
|
70
|
-
export function availableParallelism() {
|
|
71
|
-
return 1
|
|
72
|
-
}
|
|
73
|
-
export function loadavg() {
|
|
74
|
-
return [0, 0, 0]
|
|
75
|
-
}
|
|
76
|
-
export function uptime() {
|
|
77
|
-
return 0
|
|
78
|
-
}
|
|
79
|
-
export function totalmem() {
|
|
80
|
-
return 128 * 1024 * 1024
|
|
81
|
-
}
|
|
82
|
-
export function freemem() {
|
|
83
|
-
return 64 * 1024 * 1024
|
|
84
|
-
}
|
|
85
|
-
export function cpus() {
|
|
86
|
-
return [{ model: 'worker', speed: 0 }]
|
|
87
|
-
}
|
|
88
|
-
export function networkInterfaces() {
|
|
89
|
-
return {
|
|
90
|
-
lo: [
|
|
91
|
-
{
|
|
92
|
-
address: '127.0.0.1',
|
|
93
|
-
family: 'IPv4',
|
|
94
|
-
internal: true,
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// stub for node:crypto
|
|
101
|
-
export function timingSafeEqual(a: unknown, b: unknown) {
|
|
102
|
-
return a === b
|
|
103
|
-
}
|
|
104
|
-
export function randomBytes(n: number) {
|
|
105
|
-
const arr = new Uint8Array(n)
|
|
106
|
-
crypto.getRandomValues(arr)
|
|
107
|
-
return arr
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// stub for node:url
|
|
111
|
-
export function fileURLToPath(url: string) {
|
|
112
|
-
return url.replace('file://', '')
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// stub for node:inspector/promises
|
|
116
|
-
export class Session {
|
|
117
|
-
connect() {}
|
|
118
|
-
post() {
|
|
119
|
-
return Promise.resolve()
|
|
120
|
-
}
|
|
121
|
-
disconnect() {}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// stub for node:v8
|
|
125
|
-
export function getHeapStatistics() {
|
|
126
|
-
const heapSizeLimit = 128 * 1024 * 1024
|
|
127
|
-
return {
|
|
128
|
-
total_heap_size: 64 * 1024 * 1024,
|
|
129
|
-
total_heap_size_executable: 0,
|
|
130
|
-
total_physical_size: 64 * 1024 * 1024,
|
|
131
|
-
total_available_size: 64 * 1024 * 1024,
|
|
132
|
-
used_heap_size: 32 * 1024 * 1024,
|
|
133
|
-
heap_size_limit: heapSizeLimit,
|
|
134
|
-
malloced_memory: 0,
|
|
135
|
-
peak_malloced_memory: 0,
|
|
136
|
-
does_zap_garbage: 0,
|
|
137
|
-
number_of_native_contexts: 1,
|
|
138
|
-
number_of_detached_contexts: 0,
|
|
139
|
-
total_global_handles_size: 0,
|
|
140
|
-
used_global_handles_size: 0,
|
|
141
|
-
external_memory: 0,
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// stub for node:zlib
|
|
146
|
-
export function gzip(_data: unknown, cb: (err: null, result: Uint8Array) => void) {
|
|
147
|
-
cb(null, new Uint8Array(0))
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// stub for node:util
|
|
151
|
-
export function promisify(fn: unknown) {
|
|
152
|
-
return fn
|
|
153
|
-
}
|
|
154
|
-
export function inspect(obj: unknown) {
|
|
155
|
-
return String(obj)
|
|
156
|
-
}
|
|
157
|
-
export function stripVTControlCharacters(str: string) {
|
|
158
|
-
return str
|
|
159
|
-
}
|
|
160
|
-
export function inherits(ctor: any, superCtor: any) {
|
|
161
|
-
ctor.prototype = Object.create(superCtor.prototype)
|
|
162
|
-
ctor.prototype.constructor = ctor
|
|
163
|
-
}
|
|
164
|
-
export function deprecate(fn: any) {
|
|
165
|
-
return fn
|
|
166
|
-
}
|
|
167
|
-
export const types = {
|
|
168
|
-
isProxy: () => false,
|
|
169
|
-
isRegExp: (v: unknown) => v instanceof RegExp,
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// stub for node:assert
|
|
173
|
-
export function strict() {}
|
|
174
|
-
export function ok() {}
|
|
175
|
-
|
|
176
|
-
// stub for node:module
|
|
177
|
-
export function createRequire() {
|
|
178
|
-
return () => ({})
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// stub for node:child_process (named exports)
|
|
182
|
-
export function execSync() {
|
|
183
|
-
return ''
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// stub for node:perf_hooks
|
|
187
|
-
export const performance = globalThis.performance
|
|
188
|
-
export const constants = {
|
|
189
|
-
NODE_PERFORMANCE_GC_MAJOR: 4,
|
|
190
|
-
NODE_PERFORMANCE_GC_MINOR: 1,
|
|
191
|
-
NODE_PERFORMANCE_GC_INCREMENTAL: 8,
|
|
192
|
-
NODE_PERFORMANCE_GC_WEAKCB: 16,
|
|
193
|
-
}
|
|
194
|
-
export class PerformanceObserver {
|
|
195
|
-
constructor(_cb: any) {}
|
|
196
|
-
observe() {}
|
|
197
|
-
disconnect() {}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// stub for node:worker_threads
|
|
201
|
-
export class Worker {
|
|
202
|
-
constructor() {
|
|
203
|
-
throw new Error('Worker not available in browser')
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
export const isMainThread = true
|
|
207
|
-
export const parentPort = null
|
|
208
|
-
|
|
209
|
-
// stub for node:stream/promises
|
|
210
|
-
export function pipeline(..._args: unknown[]) {
|
|
211
|
-
return Promise.resolve()
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// stub for node:fs (promises sub-export)
|
|
215
|
-
export const promises = {
|
|
216
|
-
readFile: () => Promise.resolve(''),
|
|
217
|
-
writeFile: () => Promise.resolve(),
|
|
218
|
-
stat: () => Promise.resolve({ size: 0 }),
|
|
219
|
-
mkdir: () => Promise.resolve(),
|
|
220
|
-
rm: () => Promise.resolve(),
|
|
221
|
-
access: () => Promise.reject(new Error('not available')),
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// stub for node:crypto (additional)
|
|
225
|
-
export function randomUUID() {
|
|
226
|
-
return crypto.randomUUID()
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// stub for node:os (additional)
|
|
230
|
-
export function arch() {
|
|
231
|
-
return 'wasm'
|
|
232
|
-
}
|
|
233
|
-
export function release() {
|
|
234
|
-
return '0.0.0'
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// default export for modules that use default import or CJS require()
|
|
238
|
-
export default {
|
|
239
|
-
randomUUID,
|
|
240
|
-
randomBytes,
|
|
241
|
-
timingSafeEqual,
|
|
242
|
-
hostname,
|
|
243
|
-
platform,
|
|
244
|
-
tmpdir,
|
|
245
|
-
homedir,
|
|
246
|
-
availableParallelism,
|
|
247
|
-
loadavg,
|
|
248
|
-
uptime,
|
|
249
|
-
totalmem,
|
|
250
|
-
freemem,
|
|
251
|
-
cpus,
|
|
252
|
-
arch,
|
|
253
|
-
release,
|
|
254
|
-
networkInterfaces,
|
|
255
|
-
existsSync,
|
|
256
|
-
readFileSync,
|
|
257
|
-
writeFileSync,
|
|
258
|
-
rmSync,
|
|
259
|
-
mkdirSync,
|
|
260
|
-
statSync,
|
|
261
|
-
writeFile,
|
|
262
|
-
readFile,
|
|
263
|
-
promises,
|
|
264
|
-
fork,
|
|
265
|
-
spawn,
|
|
266
|
-
execSync,
|
|
267
|
-
createServer,
|
|
268
|
-
createConnection,
|
|
269
|
-
fileURLToPath,
|
|
270
|
-
promisify,
|
|
271
|
-
inspect,
|
|
272
|
-
stripVTControlCharacters,
|
|
273
|
-
inherits,
|
|
274
|
-
deprecate,
|
|
275
|
-
types,
|
|
276
|
-
performance,
|
|
277
|
-
constants,
|
|
278
|
-
PerformanceObserver,
|
|
279
|
-
getHeapStatistics,
|
|
280
|
-
gzip,
|
|
281
|
-
strict,
|
|
282
|
-
ok,
|
|
283
|
-
createRequire,
|
|
284
|
-
pipeline,
|
|
285
|
-
Server,
|
|
286
|
-
Session,
|
|
287
|
-
Worker,
|
|
288
|
-
isMainThread,
|
|
289
|
-
parentPort,
|
|
290
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* postgres browser shim — real postgres package over MessagePort.
|
|
3
|
-
*
|
|
4
|
-
* replaces the old postgres.ts shim. uses the REAL postgres npm package
|
|
5
|
-
* with a custom socket factory that speaks wire protocol over MessagePort
|
|
6
|
-
* to pg-proxy-browser.
|
|
7
|
-
*
|
|
8
|
-
* setup: set globalThis.__orez_proxy_connect before importing.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
// import the REAL postgres package — the bundler aliases 'postgres-real' to the
|
|
12
|
-
// actual postgres npm package, avoiding circular resolution since 'postgres'
|
|
13
|
-
// is aliased to this file.
|
|
14
|
-
// @ts-expect-error — resolved by bundler alias
|
|
15
|
-
import postgres from 'postgres-real'
|
|
16
|
-
|
|
17
|
-
import { createSocketFactory } from './postgres-socket.js'
|
|
18
|
-
|
|
19
|
-
const getProxyConnect = (): ((port: MessagePort) => void) => {
|
|
20
|
-
const fn = (globalThis as any).__orez_proxy_connect
|
|
21
|
-
if (!fn) throw new Error('__orez_proxy_connect not set')
|
|
22
|
-
return fn
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function browserPostgres(urlOrOptions?: any, options?: any) {
|
|
26
|
-
const opts: any =
|
|
27
|
-
typeof urlOrOptions === 'string'
|
|
28
|
-
? { ...(options || {}), host: urlOrOptions }
|
|
29
|
-
: { ...(urlOrOptions || {}) }
|
|
30
|
-
|
|
31
|
-
opts.socket = createSocketFactory(getProxyConnect())
|
|
32
|
-
|
|
33
|
-
if (typeof urlOrOptions === 'string') {
|
|
34
|
-
try {
|
|
35
|
-
const parsed = new URL(urlOrOptions.replace('pglite://', 'http://'))
|
|
36
|
-
opts.database = parsed.pathname.replace(/^\//, '') || 'postgres'
|
|
37
|
-
opts.host = '127.0.0.1'
|
|
38
|
-
opts.port = 0
|
|
39
|
-
} catch {}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
opts.ssl = false
|
|
43
|
-
opts.password = (globalThis as any).__orez_proxy_password || ''
|
|
44
|
-
opts.username = (globalThis as any).__orez_proxy_user || 'user'
|
|
45
|
-
// disable auto-subscribe
|
|
46
|
-
if (opts.no_subscribe === undefined) opts.no_subscribe = true
|
|
47
|
-
// limit pool size — too many concurrent connections overwhelm the MessagePort proxy
|
|
48
|
-
// limit pool size for browser — too many concurrent connections can overwhelm
|
|
49
|
-
if (!opts.max || opts.max > 2) opts.max = 2
|
|
50
|
-
|
|
51
|
-
console.debug(
|
|
52
|
-
`[postgres-browser] creating client db=${opts.database} repl=${!!opts.connection?.replication} fetch_types=${opts.fetch_types} max=${opts.max} keys=${Object.keys(opts).sort().join(',')}`
|
|
53
|
-
)
|
|
54
|
-
const client = postgres(opts)
|
|
55
|
-
return client
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
Object.assign(browserPostgres, postgres)
|
|
59
|
-
export default browserPostgres
|