@powerhousedao/reactor-api 6.2.3-dev.9 → 6.2.3-dev.91
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/README.md +7 -2
- package/dist/{adapter-gateway-apollo-CxJNBVyD.mjs → adapter-gateway-apollo-D-EdZ4e-.mjs} +23 -23
- package/dist/adapter-gateway-apollo-D-EdZ4e-.mjs.map +1 -0
- package/dist/{adapter-gateway-mercurius-CZVy88Za.mjs → adapter-gateway-mercurius-CdxLge5p.mjs} +4 -12
- package/dist/adapter-gateway-mercurius-CdxLge5p.mjs.map +1 -0
- package/dist/{adapter-http-express-B39rPhqH.mjs → adapter-http-express-78KD77cI.mjs} +11 -11
- package/dist/adapter-http-express-78KD77cI.mjs.map +1 -0
- package/dist/{adapter-http-fastify-BwXO6rqE.mjs → adapter-http-fastify-Dk7aT_xw.mjs} +14 -13
- package/dist/adapter-http-fastify-Dk7aT_xw.mjs.map +1 -0
- package/dist/base-document-models-CNHrVpOU.mjs +1861 -0
- package/dist/base-document-models-CNHrVpOU.mjs.map +1 -0
- package/dist/create-schema-ClPWjRPY.d.mts +161 -0
- package/dist/create-schema-ClPWjRPY.d.mts.map +1 -0
- package/dist/error-info-Cr6oQACe.mjs +601 -0
- package/dist/error-info-Cr6oQACe.mjs.map +1 -0
- package/dist/index.d.mts +3234 -979
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7300 -2723
- package/dist/index.mjs.map +1 -1
- package/dist/package-subgraph-check-DdZLhOHW.mjs +138 -0
- package/dist/package-subgraph-check-DdZLhOHW.mjs.map +1 -0
- package/dist/pglite-like-CKQEL_Q0.d.mts +27 -0
- package/dist/pglite-like-CKQEL_Q0.d.mts.map +1 -0
- package/dist/pglite-node-CcX2YT-l.mjs +744 -0
- package/dist/pglite-node-CcX2YT-l.mjs.map +1 -0
- package/dist/rolldown-runtime-8H4AJuhK.mjs +16 -0
- package/dist/run-node-handler-CQjyjOuN.mjs +52 -0
- package/dist/run-node-handler-CQjyjOuN.mjs.map +1 -0
- package/dist/src/graphql/subgraph-types.d.mts +43 -0
- package/dist/src/graphql/subgraph-types.d.mts.map +1 -0
- package/dist/src/graphql/subgraph-types.mjs +14 -0
- package/dist/src/graphql/subgraph-types.mjs.map +1 -0
- package/dist/src/packages/https-hooks.d.mts +4 -4
- package/dist/src/packages/https-hooks.d.mts.map +1 -1
- package/dist/src/packages/https-hooks.mjs +2 -2
- package/dist/src/packages/https-hooks.mjs.map +1 -1
- package/dist/src/packages/vite-loader.d.mts +30 -9
- package/dist/src/packages/vite-loader.d.mts.map +1 -1
- package/dist/src/packages/vite-loader.mjs +198 -85
- package/dist/src/packages/vite-loader.mjs.map +1 -1
- package/dist/src/pglite/pglite-node.d.mts +434 -0
- package/dist/src/pglite/pglite-node.d.mts.map +1 -0
- package/dist/src/pglite/pglite-node.mjs +5 -0
- package/dist/src/pglite/worker/entry.d.mts +2 -0
- package/dist/src/pglite/worker/entry.mjs +298 -0
- package/dist/src/pglite/worker/entry.mjs.map +1 -0
- package/dist/subgraph-extraction-DioqM_Dc.mjs +1879 -0
- package/dist/subgraph-extraction-DioqM_Dc.mjs.map +1 -0
- package/dist/subgraph-schema-owner-BEjuk2Xv.mjs +10 -0
- package/dist/subgraph-schema-owner-BEjuk2Xv.mjs.map +1 -0
- package/dist/types-PXB1ctpi.d.mts +99 -0
- package/dist/types-PXB1ctpi.d.mts.map +1 -0
- package/package.json +39 -26
- package/dist/adapter-gateway-apollo-CxJNBVyD.mjs.map +0 -1
- package/dist/adapter-gateway-apollo-DowrX6E_.mjs +0 -4
- package/dist/adapter-gateway-mercurius-CZVy88Za.mjs.map +0 -1
- package/dist/adapter-gateway-stitching-CaZjvRzx.mjs +0 -316
- package/dist/adapter-gateway-stitching-CaZjvRzx.mjs.map +0 -1
- package/dist/adapter-http-express-B39rPhqH.mjs.map +0 -1
- package/dist/adapter-http-fastify-BwXO6rqE.mjs.map +0 -1
- package/dist/path-normalize-BOQwY9wR.mjs +0 -23
- package/dist/path-normalize-BOQwY9wR.mjs.map +0 -1
- package/dist/types-DcYyNcHJ.d.mts +0 -48
- package/dist/types-DcYyNcHJ.d.mts.map +0 -1
- package/dist/utils-XWVecaNn.mjs +0 -653
- package/dist/utils-XWVecaNn.mjs.map +0 -1
- package/dist/websocket-DncAB9XK.mjs +0 -18
- package/dist/websocket-DncAB9XK.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pglite-node-CcX2YT-l.mjs","sources":["../src/pglite/snapshot-reader.ts","../src/pglite/convert-snapshot-dir.ts","../src/pglite/preflight.ts","../src/pglite/wasm-wrapper-tiering.ts","../src/pglite/worker/errors.ts","../src/pglite/worker/protocol.ts","../src/pglite/worker/threaded-pglite.ts"],"sourcesContent":["import { promises as fs } from \"node:fs\";\nimport type { FileHandle } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { syncTree, type SyncTreeHostFs } from \"./sync-tree.js\";\n\n// v1: magic, u32 version, u32 count; then u8 type, u32 mode, path, u32 len, data.\nexport const SNAPSHOT_FILE_NAME = \"snapshot.bin\";\nconst MAGIC = new Uint8Array([0x50, 0x47, 0x4c, 0x41]);\nconst FORMAT_VERSION = 1;\nconst HEADER_SIZE = 12;\nconst ENTRY_PREFIX_SIZE = 9;\nconst SKIPPED_ENTRIES = new Set([\"postmaster.pid\"]);\n// Node rejects a single read above 2^31-1 bytes.\nconst DEFAULT_IO_CHUNK_SIZE = 64 * 1024 * 1024;\n\nexport interface ExtractSnapshotOptions {\n chunkSize?: number;\n /** Default true: one fsync pass over the tree after the last write. */\n sync?: boolean;\n hostFs?: SyncTreeHostFs;\n}\n\nexport interface ExtractedSnapshot {\n pgVersionMajor: number;\n /** `global/pg_control` bytes; absent only in synthetic trees. */\n pgControl?: Buffer;\n /** Entries written to disk; skipped entries are not counted. */\n entries: number;\n /** Size of the snapshot file. */\n bytes: number;\n}\n\n/** Unpacks a snapshot into the existing `outDir`. */\nexport async function extractSnapshot(\n snapshotPath: string,\n outDir: string,\n options: ExtractSnapshotOptions = {},\n): Promise<ExtractedSnapshot> {\n const fh = await fs.open(snapshotPath, \"r\");\n try {\n const { size } = await fh.stat();\n return await extractFromHandle(fh, size, outDir, options);\n } finally {\n await fh.close();\n }\n}\n\nasync function extractFromHandle(\n fh: FileHandle,\n fileSize: number,\n outDir: string,\n options: ExtractSnapshotOptions,\n): Promise<ExtractedSnapshot> {\n const root = path.resolve(outDir);\n const chunkSize = Math.min(\n options.chunkSize ?? DEFAULT_IO_CHUNK_SIZE,\n Math.max(1, fileSize),\n );\n const reader = new ChunkedReader(fh, chunkSize);\n\n const header = await reader.take(HEADER_SIZE);\n for (let i = 0; i < MAGIC.length; i++) {\n if (header[i] !== MAGIC[i]) {\n throw new Error(\"snapshot.bin: invalid snapshot magic\");\n }\n }\n const version = header.readUInt32LE(4);\n if (version !== FORMAT_VERSION) {\n throw new Error(`snapshot.bin: unsupported snapshot version ${version}`);\n }\n const count = header.readUInt32LE(8);\n\n const decoder = new TextDecoder();\n let pgVersionText: string | undefined;\n let pgControl: Buffer | undefined;\n let written = 0;\n\n for (let i = 0; i < count; i++) {\n const prefix = await reader.take(ENTRY_PREFIX_SIZE);\n const type = prefix.readUInt8(0);\n const mode = prefix.readUInt32LE(1) & 0o7777;\n const pathLen = prefix.readUInt32LE(5);\n const relPath = decoder.decode(await reader.take(pathLen));\n const dataLen = (await reader.take(4)).readUInt32LE(0);\n const data = await reader.take(dataLen);\n\n const full = resolveInside(root, relPath);\n if (SKIPPED_ENTRIES.has(relPath)) continue;\n\n if (type === 0) {\n await fs.mkdir(full, { recursive: true });\n await fs.chmod(full, dirMode(mode));\n } else if (type === 1) {\n await fs.mkdir(path.dirname(full), { recursive: true });\n await fs.writeFile(full, data);\n await fs.chmod(full, mode);\n if (relPath === \"PG_VERSION\") pgVersionText = data.toString(\"utf8\");\n if (relPath === \"global/pg_control\") pgControl = data;\n } else {\n throw new Error(`snapshot.bin: unknown entry type ${type}`);\n }\n written++;\n }\n\n if (pgVersionText === undefined) {\n throw new Error(\"snapshot.bin: no PG_VERSION entry\");\n }\n const pgVersionMajor = Number.parseInt(pgVersionText.trim(), 10);\n if (!Number.isInteger(pgVersionMajor) || pgVersionMajor <= 0) {\n throw new Error(\n `snapshot.bin: unreadable PG_VERSION ${JSON.stringify(pgVersionText)}`,\n );\n }\n\n if (options.sync ?? true) syncTree(root, options.hostFs);\n\n return { pgVersionMajor, pgControl, entries: written, bytes: fileSize };\n}\n\nfunction resolveInside(root: string, relPath: string): string {\n const full = path.resolve(root, relPath);\n if (full !== root && !full.startsWith(root + path.sep)) {\n throw new Error(`snapshot.bin: entry escapes the data dir: ${relPath}`);\n }\n return full;\n}\n\n/** NTFS has no execute bit; a Windows snapshot can carry untraversable dirs. */\nexport function dirMode(mode: number): number {\n return (mode & 0o7777) | 0o111;\n}\n\nclass ChunkedReader {\n private readonly buf: Buffer;\n private start = 0;\n private end = 0;\n private position = 0;\n\n constructor(\n private readonly fh: Pick<FileHandle, \"read\">,\n chunkSize: number,\n ) {\n this.buf = Buffer.allocUnsafe(Math.max(1, chunkSize));\n }\n\n async take(n: number): Promise<Buffer> {\n const out = Buffer.allocUnsafe(n);\n let filled = 0;\n while (filled < n) {\n if (this.start === this.end) {\n if (n - filled >= this.buf.byteLength) {\n filled += await this.readInto(out, filled, n - filled);\n continue;\n }\n this.start = 0;\n this.end = await this.readInto(this.buf, 0, this.buf.byteLength);\n }\n const k = Math.min(this.end - this.start, n - filled);\n this.buf.copy(out, filled, this.start, this.start + k);\n this.start += k;\n filled += k;\n }\n return out;\n }\n\n private async readInto(\n target: Buffer,\n offset: number,\n length: number,\n ): Promise<number> {\n const { bytesRead } = await this.fh.read(\n target,\n offset,\n Math.min(length, this.buf.byteLength),\n this.position,\n );\n if (bytesRead <= 0) {\n throw new Error(\"snapshot.bin: truncated snapshot\");\n }\n this.position += bytesRead;\n return bytesRead;\n }\n}\n","import type { ILogger } from \"document-model\";\nimport { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { extractSnapshot, SNAPSHOT_FILE_NAME } from \"./snapshot-reader.js\";\nimport { syncDirectory, syncTree, type SyncTreeHostFs } from \"./sync-tree.js\";\n\nexport interface VerifyHandle {\n query<T>(sql: string): Promise<{ rows: T[] }>;\n close(): Promise<void>;\n}\n\nexport type ConversionStep =\n | \"extract\"\n | \"verify\"\n | \"renameOld\"\n | \"renameNew\"\n | \"removeOld\";\n\nexport interface ConversionDeps {\n /** Opens `dataDir` with the stock NodeFS of the PGlite module for `major`. */\n openForVerify: (major: number, dataDir: string) => Promise<VerifyHandle>;\n logger: ILogger;\n /** Test hook: throw after a named step to simulate a crash there. */\n afterStep?: (step: ConversionStep) => void | Promise<void>;\n hostFs?: SyncTreeHostFs;\n}\n\n// Backoff doubles per retry; five keeps a scanner-held file to ~3 s.\nconst RM_OPTIONS = {\n recursive: true,\n force: true,\n maxRetries: 5,\n retryDelay: 100,\n} as const;\n\ninterface Siblings {\n dir: string;\n converting: string;\n old: string;\n snapshot: string;\n}\n\nfunction siblingsOf(dir: string): Siblings {\n const resolved = path.resolve(dir);\n return {\n dir: resolved,\n converting: `${resolved}.converting`,\n old: `${resolved}.old`,\n snapshot: path.join(resolved, SNAPSHOT_FILE_NAME),\n };\n}\n\n/** Settles the debris of an interrupted conversion; runs before it at boot. */\nexport async function recoverConversion(\n dir: string,\n deps: ConversionDeps,\n): Promise<void> {\n const s = siblingsOf(dir);\n const [dirExists, convertingExists, oldExists] = await Promise.all([\n exists(s.dir),\n exists(s.converting),\n exists(s.old),\n ]);\n\n if (!dirExists) {\n if (convertingExists) {\n // Died between the two renames: finish the swap.\n await fs.rename(s.converting, s.dir);\n if (oldExists) await fs.rm(s.old, RM_OPTIONS);\n deps.logger.warn(\n `PGlite conversion of ${s.dir} was interrupted after the swap started; completed it`,\n );\n return;\n }\n if (oldExists) {\n throw new Error(\n `PGlite data dir ${s.dir} is missing but ${s.old} exists; refusing to initialize beside it. Inspect and rename or remove ${s.old}.`,\n );\n }\n return;\n }\n\n const snapshotExists = await exists(s.snapshot);\n if (snapshotExists) {\n // The snapshot is authoritative; anything beside it is debris.\n if (convertingExists) await fs.rm(s.converting, RM_OPTIONS);\n if (oldExists) await fs.rm(s.old, RM_OPTIONS);\n return;\n }\n\n // dir is a converted PGDATA; anything beside it is superseded.\n if (oldExists) await fs.rm(s.old, RM_OPTIONS);\n if (convertingExists) {\n deps.logger.warn(\n `Removing stray ${s.converting}; ${s.dir} holds no snapshot and is authoritative`,\n );\n await fs.rm(s.converting, RM_OPTIONS);\n }\n}\n\n/** Extracts into `.converting`, verifies by opening it, swaps through `.old`. */\nexport async function convertSnapshotDir(\n dir: string,\n deps: ConversionDeps,\n): Promise<\"converted\" | \"none\"> {\n const s = siblingsOf(dir);\n if (!(await exists(s.snapshot))) return \"none\";\n\n const startedAt = performance.now();\n await fs.rm(s.converting, RM_OPTIONS);\n await fs.mkdir(s.converting, { mode: 0o700 });\n\n let snapshotBytes: number;\n let entries: number;\n try {\n ({ bytes: snapshotBytes, entries } = await extractAndVerify(s, deps));\n } catch (err) {\n await fs.rm(s.converting, RM_OPTIONS);\n throw err;\n }\n\n // Parent synced after each rename: a power loss lands on one recovery row.\n const parent = path.dirname(s.dir);\n await fs.rename(s.dir, s.old);\n syncDirectory(parent, deps.hostFs);\n await deps.afterStep?.(\"renameOld\");\n await fs.rename(s.converting, s.dir);\n syncDirectory(parent, deps.hostFs);\n await deps.afterStep?.(\"renameNew\");\n try {\n await fs.rm(s.old, RM_OPTIONS);\n } catch (err) {\n // The converted dir is in place; recoverConversion removes .old next boot.\n deps.logger.warn(\n `Could not remove ${s.old} after conversion; it is removed at the next boot: ${String(err)}`,\n );\n }\n await deps.afterStep?.(\"removeOld\");\n\n const convertedBytes = await treeBytes(s.dir);\n const durationMs = Math.round(performance.now() - startedAt);\n deps.logger.info(\n `Converted PGlite snapshot at ${s.dir}: snapshot ${snapshotBytes} bytes -> ${convertedBytes} bytes on disk, ${entries} entries, ${durationMs} ms`,\n );\n return \"converted\";\n}\n\nasync function extractAndVerify(\n s: Siblings,\n deps: ConversionDeps,\n): Promise<{ bytes: number; entries: number }> {\n const extracted = await extractSnapshot(s.snapshot, s.converting, {\n sync: false,\n });\n await deps.afterStep?.(\"extract\");\n\n if (!extracted.pgControl) {\n throw new Error(`${s.snapshot} has no global/pg_control entry`);\n }\n const expectedIdentifier = extracted.pgControl.readBigUInt64LE(0).toString();\n const handle = await deps.openForVerify(\n extracted.pgVersionMajor,\n s.converting,\n );\n try {\n await verifyOpenStore(handle, expectedIdentifier);\n } finally {\n // Must close before the renames; Windows refuses to rename an open dir.\n await handle.close();\n }\n await fs.rm(path.join(s.converting, \"postmaster.pid\"), { force: true });\n if (await exists(path.join(s.converting, SNAPSHOT_FILE_NAME))) {\n throw new Error(\n `Extracted PGlite data dir ${s.converting} contains ${SNAPSHOT_FILE_NAME}`,\n );\n }\n // One pass covers the extraction and the verify open's own writes.\n syncTree(s.converting, deps.hostFs);\n await deps.afterStep?.(\"verify\");\n return { bytes: extracted.bytes, entries: extracted.entries };\n}\n\nasync function verifyOpenStore(\n handle: VerifyHandle,\n expectedIdentifier: string,\n): Promise<void> {\n // numeric parses to a float above 2^53; compare as text.\n const ident = await handle.query<{ system_identifier: string }>(\n \"SELECT system_identifier::text AS system_identifier FROM pg_control_system()\",\n );\n const actual = ident.rows[0]?.system_identifier;\n if (actual !== expectedIdentifier) {\n throw new Error(\n `PGlite system identifier mismatch after extraction: pg_control says ${expectedIdentifier}, server says ${String(actual)}`,\n );\n }\n const tables = await handle.query<{ qualified: string }>(\n \"SELECT format('%I.%I', schemaname, tablename) AS qualified FROM pg_tables WHERE schemaname NOT IN ('pg_catalog', 'information_schema') ORDER BY 1\",\n );\n for (const { qualified } of tables.rows) {\n await handle.query(`SELECT count(*) FROM ${qualified}`);\n }\n}\n\nasync function exists(p: string): Promise<boolean> {\n try {\n await fs.lstat(p);\n return true;\n } catch {\n return false;\n }\n}\n\nasync function treeBytes(dir: string): Promise<number> {\n let total = 0;\n const entries = await fs.readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n total += await treeBytes(full);\n } else if (entry.isFile()) {\n total += (await fs.stat(full)).size;\n }\n }\n return total;\n}\n","import { PGlite } from \"@electric-sql/pglite\";\nimport { NodeFS } from \"@electric-sql/pglite/nodefs\";\nimport type { ILogger } from \"document-model\";\nimport { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport {\n convertSnapshotDir,\n recoverConversion,\n type ConversionDeps,\n type VerifyHandle,\n} from \"./convert-snapshot-dir.js\";\n\n/** PG major of the pinned @electric-sql/pglite; it exports none, so the test checks initdb. */\nexport const CURRENT_PGLITE_MAJOR = 17;\n\n/** `openForVerify` over the loaded PGlite module only. */\nexport async function openCurrentPgliteForVerify(\n major: number,\n dataDir: string,\n): Promise<VerifyHandle> {\n if (major !== CURRENT_PGLITE_MAJOR) {\n throw new Error(\n `PGlite snapshot at ${dataDir} is PG${major}; this process only opens PG${CURRENT_PGLITE_MAJOR} data dirs`,\n );\n }\n const pg = new PGlite({ fs: new NodeFS(dataDir) });\n await pg.waitReady;\n return pg;\n}\n\n/** Converts a snapshot store and clears the files a previous run leaves behind. */\nexport async function preparePgliteDataDir(\n dir: string,\n deps: ConversionDeps,\n): Promise<void> {\n await recoverConversion(dir, deps);\n await convertSnapshotDir(dir, deps);\n await removeStalePgliteFiles(dir, deps.logger);\n}\n\n/** PGlite leaves `postmaster.pid` after every close and `pg_wal/xlogtemp.*` after some. */\nexport async function removeStalePgliteFiles(\n dir: string,\n logger: Pick<ILogger, \"debug\">,\n): Promise<void> {\n const lockfile = path.join(dir, \"postmaster.pid\");\n let hadLockfile = true;\n try {\n await fs.unlink(lockfile);\n } catch {\n hadLockfile = false;\n }\n if (hadLockfile) logger.debug(`Removed PGlite lockfile ${lockfile}`);\n\n const walDir = path.join(dir, \"pg_wal\");\n let names: string[];\n try {\n names = await fs.readdir(walDir);\n } catch {\n return;\n }\n for (const name of names) {\n if (!name.startsWith(\"xlogtemp.\")) continue;\n await fs.rm(path.join(walDir, name), { force: true });\n logger.debug(`Removed PGlite temp WAL file ${path.join(walDir, name)}`);\n }\n}\n","import v8 from \"node:v8\";\n\nexport const WASM_WRAPPER_TIERING_FLAG =\n \"--wasm-wrapper-tiering-budget=1000000000\";\n\nlet applied = false;\n\n/** Node 24 V8 double-frees tiered wasm wrappers as instances die (#66366). */\nexport function disableWasmWrapperTiering(): boolean {\n // TODO(nodejs/node#66376): narrow to 24.x releases older than the backport.\n if (applied || process.versions.node.split(\".\")[0] !== \"24\") return false;\n v8.setFlagsFromString(WASM_WRAPPER_TIERING_FLAG);\n applied = true;\n return true;\n}\n","/** Base class for failures of the worker itself, as opposed to SQL errors. */\nexport class PGliteWorkerError extends Error {\n constructor(\n readonly label: string,\n message: string,\n options?: { cause?: unknown },\n ) {\n super(message, options);\n this.name = \"PGliteWorkerError\";\n }\n}\n\n/** The worker could not open its store; every call on the stand-in fails with this. */\nexport class PGliteWorkerInitError extends PGliteWorkerError {\n constructor(label: string, options?: { cause?: unknown }) {\n super(\n label,\n `PGlite worker for ${label} failed to open its store`,\n options,\n );\n this.name = \"PGliteWorkerInitError\";\n }\n}\n\n/** The worker thread exited (crash, terminate, out of memory) before answering. */\nexport class PGliteWorkerExitedError extends PGliteWorkerError {\n constructor(\n label: string,\n readonly exitCode: number,\n options?: { cause?: unknown },\n ) {\n super(\n label,\n `PGlite worker for ${label} exited with code ${exitCode}`,\n options,\n );\n this.name = \"PGliteWorkerExitedError\";\n }\n}\n\n/** A call was made after `close()` started. */\nexport class PGliteWorkerClosedError extends PGliteWorkerError {\n constructor(label: string) {\n super(label, `PGlite worker for ${label} is closed`);\n this.name = \"PGliteWorkerClosedError\";\n }\n}\n","import type {\n TableRewriteRequest,\n TableRewriteResult,\n} from \"@powerhousedao/reactor\";\n\n/**\n * Wire protocol between a {@link ThreadedPGlite} stand-in on the main thread\n * and the worker thread that owns one PGlite store.\n *\n * Every payload is structured-cloned, so it holds data only: functions such as\n * row parsers are named by preset and built inside the worker.\n */\n\n/** Module specifiers the worker imports PGlite and its NodeFS from. */\nexport type PGliteModuleSpec = {\n /** Specifier or file URL of the PGlite package entry, e.g. `@electric-sql/pglite`. */\n pglite: string;\n /** Specifier or file URL of the matching NodeFS entry, e.g. `@electric-sql/pglite/nodefs`. */\n nodefs: string;\n};\n\nexport const CURRENT_PGLITE_MODULE: PGliteModuleSpec = {\n pglite: \"@electric-sql/pglite\",\n nodefs: \"@electric-sql/pglite/nodefs\",\n};\n\n/** Row parser sets the worker knows how to build. */\nexport type PGliteParserPreset = \"none\" | \"utc-timestamps\";\n\n/** DurableNodeFs settings; see `DurableNodeFsOptions`. */\nexport type PGliteWorkerDurableFsOptions = {\n fsync: boolean;\n /** Undefined keeps the DurableNodeFs default (5 min); 0 disables. */\n maintenanceIntervalMs?: number;\n /** Undefined keeps the DurableNodeFs default (256 MB); 0 disables. */\n vacuumFullAboveBytes?: number;\n /** Undefined keeps the DurableNodeFs default (60 s); 0 runs VACUUM FULL on the first pass. */\n vacuumFullQuietMs?: number;\n /** Undefined keeps the DurableNodeFs default (0: the quiet window only); a deadline in ms forces the run past it. */\n vacuumFullMaxDeferMs?: number;\n /** Undefined keeps the DurableNodeFs default (1 s). */\n rewriteQuietMs?: number;\n};\n\n/** What the worker opens. */\nexport type PGliteWorkerStoreOptions = {\n /** Names the store in logs and errors, e.g. `read-storage`. */\n label: string;\n /** PGlite data dir; null opens an in-memory store. */\n dataDir: string | null;\n module: PGliteModuleSpec;\n /** DurableNodeFs over `dataDir`; null uses the module's stock NodeFS. Ignored in memory. */\n durableFs: PGliteWorkerDurableFsOptions | null;\n parsers: PGliteParserPreset;\n};\n\n/** The structured-clonable subset of PGlite's `QueryOptions`. */\nexport type WorkerQueryOptions = {\n rowMode?: \"object\" | \"array\";\n paramTypes?: number[];\n};\n\nexport type PGliteErrorInfo = {\n name: string;\n message: string;\n stack?: string;\n cause?: PGliteErrorInfo;\n /** Postgres error fields, copied when present. */\n fields: Record<string, string>;\n};\n\nexport type WorkerResults = {\n rows: unknown[];\n affectedRows?: number;\n fields: { name: string; dataTypeID: number }[];\n};\n\nexport type InitRequest = {\n type: \"init\";\n id: number;\n store: PGliteWorkerStoreOptions;\n};\n\nexport type QueryRequest = {\n type: \"query\";\n id: number;\n /** The reservation this statement runs under, or null for the request queue. */\n admission: number | null;\n sql: string;\n params: unknown[];\n options: WorkerQueryOptions;\n};\n\nexport type ExecRequest = {\n type: \"exec\";\n id: number;\n admission: number | null;\n sql: string;\n options: WorkerQueryOptions;\n};\n\nexport type CloseRequest = {\n type: \"close\";\n id: number;\n};\n\n/**\n * Asks for the connection: answered with `admitted` once everything queued\n * ahead (requests and maintenance passes) has finished. Until the matching\n * `release`, the worker runs only statements tagged with this reservation.\n */\nexport type ReserveRequest = {\n type: \"reserve\";\n id: number;\n};\n\n/**\n * Rewrites one table through the store's maintenance. Runs beside the request\n * queue, since it waits for a quiet store; the rewrite itself takes its turn.\n */\nexport type RewriteTableRequest = {\n type: \"rewrite-table\";\n id: number;\n request: TableRewriteRequest;\n};\n\n/** Ends a reservation; the request queue resumes. Not answered. */\nexport type ReleaseRequest = {\n type: \"release\";\n id: number;\n};\n\n/** Asks for the store's memory; answered outside the admission queue. */\nexport type StatsRequest = {\n type: \"stats\";\n id: number;\n};\n\nexport type HostMessage =\n | StatsRequest\n | InitRequest\n | QueryRequest\n | ExecRequest\n | CloseRequest\n | ReserveRequest\n | ReleaseRequest\n | RewriteTableRequest;\n\nexport type StatsMessage = {\n type: \"stats-result\";\n id: number;\n /** Bytes of WASM linear memory; 0 before the store has opened. */\n wasmBytes: number;\n};\n\nexport type AdmittedMessage = {\n type: \"admitted\";\n id: number;\n inTransaction: boolean;\n};\n\nexport type ReadyMessage = {\n type: \"ready\";\n id: number;\n inTransaction: boolean;\n};\n\nexport type QueryResultMessage = {\n type: \"query-result\";\n id: number;\n result: WorkerResults;\n inTransaction: boolean;\n};\n\nexport type ExecResultMessage = {\n type: \"exec-result\";\n id: number;\n results: WorkerResults[];\n inTransaction: boolean;\n};\n\nexport type RewriteTableResultMessage = {\n type: \"rewrite-table-result\";\n id: number;\n result: TableRewriteResult;\n inTransaction: boolean;\n};\n\nexport type ClosedMessage = {\n type: \"closed\";\n id: number;\n};\n\nexport type ErrorMessage = {\n type: \"error\";\n id: number;\n error: PGliteErrorInfo;\n inTransaction: boolean;\n};\n\n/** The wasm runtime aborted (a Postgres PANIC); the store is dead. */\nexport type AbortMessage = {\n type: \"abort\";\n reason: string;\n};\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nexport type LogMessage = {\n type: \"log\";\n level: LogLevel;\n message: string;\n error?: PGliteErrorInfo;\n};\n\nexport type WorkerMessage =\n | StatsMessage\n | AdmittedMessage\n | ReadyMessage\n | QueryResultMessage\n | ExecResultMessage\n | RewriteTableResultMessage\n | ClosedMessage\n | ErrorMessage\n | AbortMessage\n | LogMessage;\n","import type { QueryOptions, Results } from \"@electric-sql/pglite\";\nimport {\n registerTelemetryWorker,\n type IStoreMaintenance,\n type TableRewriteRequest,\n type TableRewriteResult,\n type WorkerMemorySample,\n} from \"@powerhousedao/reactor\";\nimport { childLogger, type ILogger } from \"document-model\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\nimport { existsSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { Worker, type ResourceLimits } from \"node:worker_threads\";\nimport type { PGliteLike } from \"../pglite-like.js\";\nimport { disableWasmWrapperTiering } from \"../wasm-wrapper-tiering.js\";\nimport { fromPGliteErrorInfo } from \"./error-info.js\";\nimport {\n PGliteWorkerClosedError,\n PGliteWorkerExitedError,\n PGliteWorkerInitError,\n} from \"./errors.js\";\nimport type {\n HostMessage,\n LogMessage,\n PGliteWorkerStoreOptions,\n WorkerMessage,\n WorkerQueryOptions,\n WorkerResults,\n} from \"./protocol.js\";\n\nexport const DEFAULT_PGLITE_WORKER_MEMORY_MB = 1024;\nexport const DEFAULT_PGLITE_WORKER_CLOSE_GRACE_MS = 60_000;\n\nexport type ThreadedPGliteOptions = {\n store: PGliteWorkerStoreOptions;\n /** Caps the worker's JS heap; defaults to {@link resolvePgliteWorkerMemoryMb}. WebAssembly memory is outside it. */\n memoryLimitMb?: number;\n /** The worker script; defaults to the built entry next to this module. Tests pass a tsx bootstrap. */\n workerScript?: string | URL;\n /** Bound on PGlite's own close (its shutdown checkpoint) before the thread is terminated. */\n closeGraceMs?: number;\n logger?: ILogger;\n};\n\n/** Called once, when the worker reports that the wasm runtime aborted. */\nexport type PGliteAbortListener = (reason: string) => void;\n\n/** Called once, when the worker thread is gone; `error` is null after a clean close. */\nexport type PGliteExitListener = (error: Error | null) => void;\n\ntype PendingKind =\n | \"init\"\n | \"query\"\n | \"exec\"\n | \"close\"\n | \"reserve\"\n | \"stats\"\n | \"rewrite\";\n\ntype Pending = {\n kind: PendingKind;\n resolve: (value: unknown) => void;\n reject: (error: Error) => void;\n};\n\ntype Phase = \"starting\" | \"ready\" | \"closing\" | \"closed\";\n\n/** `PH_PGLITE_WORKER_MEMORY_MB`, else {@link DEFAULT_PGLITE_WORKER_MEMORY_MB}. */\nexport function resolvePgliteWorkerMemoryMb(\n env: Record<string, string | undefined>,\n): number {\n const raw = env.PH_PGLITE_WORKER_MEMORY_MB;\n if (raw === undefined || raw.trim() === \"\") {\n return DEFAULT_PGLITE_WORKER_MEMORY_MB;\n }\n const parsed = Number(raw);\n if (!Number.isInteger(parsed) || parsed <= 0) {\n throw new Error(\n `PH_PGLITE_WORKER_MEMORY_MB must be a positive integer (got: ${raw})`,\n );\n }\n return parsed;\n}\n\n/**\n * Main-thread stand-in for a PGlite instance whose store lives in a worker\n * thread. It has the surface knex-pglite, kysely-pglite-dialect and\n * `HardenedPGliteDialect` use: `waitReady`, `query`, `exec`, a synchronous\n * `isInTransaction()`, `closed` and `close()`.\n *\n * Construction is synchronous and starts the worker; calls made before the\n * worker is ready are queued behind its open. The worker runs requests one at\n * a time in arrival order, and every answer carries the transaction status.\n * The instance is a plain extensible object, since knex stores its own\n * bookkeeping on the connection.\n */\nexport class ThreadedPGlite implements PGliteLike, IStoreMaintenance {\n readonly label: string;\n /** Settles once the worker has opened the store; rejects with {@link PGliteWorkerInitError}. */\n readonly waitReady: Promise<void>;\n\n private readonly worker: Worker;\n private readonly logger: ILogger;\n private readonly closeGraceMs: number;\n private readonly pending = new Map<number, Pending>();\n /** The reservation an `admit` run is executing under, carried through its async calls. */\n private readonly admission = new AsyncLocalStorage<number>();\n private readonly abortListeners = new Set<PGliteAbortListener>();\n private readonly exitListeners = new Set<PGliteExitListener>();\n private nextId = 1;\n private phase: Phase = \"starting\";\n private inTransaction = false;\n private terminalError: Error | null = null;\n private workerError: Error | null = null;\n private abortReason: string | null = null;\n private closePromise: Promise<void> | null = null;\n private readonly forgetTelemetry: () => void;\n\n constructor(options: ThreadedPGliteOptions) {\n this.label = options.store.label;\n this.logger =\n options.logger ??\n childLogger([\"reactor-api\", \"pglite-worker\", this.label]);\n this.closeGraceMs =\n options.closeGraceMs ?? DEFAULT_PGLITE_WORKER_CLOSE_GRACE_MS;\n const memoryLimitMb =\n options.memoryLimitMb ?? resolvePgliteWorkerMemoryMb(process.env);\n\n const workerScript = options.workerScript ?? pgliteWorkerEntryPath;\n if (workerScript === null) {\n throw new Error(\n \"No PGlite worker script is available: build @powerhousedao/reactor-api or pass workerScript\",\n );\n }\n disableWasmWrapperTiering();\n this.worker = new Worker(workerScript, {\n name: `pglite:${this.label}`,\n resourceLimits: { maxOldGenerationSizeMb: memoryLimitMb },\n });\n this.worker.on(\"message\", (msg: WorkerMessage) => this.handleMessage(msg));\n this.worker.on(\"error\", (err: Error) => this.handleWorkerError(err));\n this.worker.on(\"exit\", (code: number) => this.handleExit(code));\n this.forgetTelemetry = registerTelemetryWorker(`pglite:${this.label}`, () =>\n this.memoryStats(),\n );\n\n this.waitReady = this.request<void>(\"init\", (id) => ({\n type: \"init\",\n id,\n store: options.store,\n })).then(\n () => {\n if (this.phase === \"starting\") {\n this.phase = \"ready\";\n }\n },\n (error: unknown) => {\n const initError =\n error instanceof PGliteWorkerInitError\n ? error\n : new PGliteWorkerInitError(this.label, { cause: error });\n this.fail(initError);\n throw initError;\n },\n );\n this.waitReady.catch(() => undefined);\n }\n\n /** JS heap of the worker and the WASM linear memory, which only grows. */\n async memoryStats(): Promise<WorkerMemorySample> {\n const [heap, wasm] = await Promise.all([\n this.worker.getHeapStatistics(),\n this.request<number>(\"stats\", (id) => ({ type: \"stats\", id })),\n ]);\n return { heapUsed: heap.used_heap_size, wasm };\n }\n\n /** True once the store is open and until close starts. */\n get ready(): boolean {\n return this.phase === \"ready\";\n }\n\n /** True once close has started or the worker is gone. */\n get closed(): boolean {\n return this.phase === \"closing\" || this.phase === \"closed\";\n }\n\n /** The reason the worker reported for a wasm abort, or null. */\n get aborted(): string | null {\n return this.abortReason;\n }\n\n /** The limits the worker thread runs under (empty once it has exited). */\n get resourceLimits(): ResourceLimits {\n return this.worker.resourceLimits ?? {};\n }\n\n /** The worker's thread id, for diagnostics. */\n get threadId(): number {\n return this.worker.threadId;\n }\n\n async query<T = Record<string, unknown>>(\n sql: string,\n params?: unknown[],\n options?: QueryOptions,\n ): Promise<Results<T>> {\n const wireOptions = toWireOptions(options);\n const result = await this.request<WorkerResults>(\"query\", (id) => ({\n type: \"query\",\n id,\n admission: this.currentAdmission(),\n sql,\n params: params ?? [],\n options: wireOptions,\n }));\n return toResults<T>(result);\n }\n\n async exec(sql: string, options?: QueryOptions): Promise<Results[]> {\n const wireOptions = toWireOptions(options);\n const results = await this.request<WorkerResults[]>(\"exec\", (id) => ({\n type: \"exec\",\n id,\n admission: this.currentAdmission(),\n sql,\n options: wireOptions,\n }));\n return results.map((result) => toResults(result));\n }\n\n /**\n * `HardenedPGliteDialect`'s admission hook: `run` starts only once the worker\n * can run its statements at once, with nothing queued ahead and no\n * maintenance pass in progress, so the dialect's statement deadline (which\n * starts inside `run`) never counts time spent waiting behind other work.\n * Statements `run` issues bypass the queue until it settles; everything\n * else waits behind them.\n */\n async admit<T>(run: () => Promise<T>): Promise<T> {\n let reservation = 0;\n await this.request<void>(\"reserve\", (id) => {\n reservation = id;\n return { type: \"reserve\", id };\n });\n try {\n return await this.admission.run(reservation, run);\n } finally {\n this.release(reservation);\n }\n }\n\n /** Rewrites one table through the store's maintenance inside the worker. */\n rewriteTable(request: TableRewriteRequest): Promise<TableRewriteResult> {\n return this.request<TableRewriteResult>(\"rewrite\", (id) => ({\n type: \"rewrite-table\",\n id,\n request,\n }));\n }\n\n /** The status after the most recently answered request, as PGlite reported it. */\n isInTransaction(): boolean {\n return this.inTransaction;\n }\n\n /** Closes PGlite inside the worker (its shutdown checkpoint), then terminates the thread. */\n close(): Promise<void> {\n if (this.closePromise !== null) {\n return this.closePromise;\n }\n if (this.phase === \"closed\") {\n return Promise.resolve();\n }\n this.closePromise = this.closeWorker();\n return this.closePromise;\n }\n\n /** Stops the thread at once, without PGlite's close; pending calls reject. */\n async terminate(): Promise<void> {\n if (this.phase === \"closed\") {\n return;\n }\n await this.worker.terminate();\n }\n\n onAbort(listener: PGliteAbortListener): () => void {\n this.abortListeners.add(listener);\n return () => {\n this.abortListeners.delete(listener);\n };\n }\n\n onExit(listener: PGliteExitListener): () => void {\n this.exitListeners.add(listener);\n return () => {\n this.exitListeners.delete(listener);\n };\n }\n\n private async closeWorker(): Promise<void> {\n if (this.terminalError !== null) {\n this.phase = \"closing\";\n await this.worker.terminate();\n return;\n }\n const closing = this.request<void>(\"close\", (id) => ({\n type: \"close\",\n id,\n }));\n this.phase = \"closing\";\n let timer: ReturnType<typeof setTimeout> | undefined;\n const grace = new Promise<\"timeout\">((resolve) => {\n timer = setTimeout(() => resolve(\"timeout\"), this.closeGraceMs);\n });\n let outcome: \"closed\" | \"timeout\" = \"closed\";\n let closeError: Error | null = null;\n try {\n outcome = await Promise.race([\n closing.then(() => \"closed\" as const),\n grace,\n ]);\n } catch (error) {\n closeError = error instanceof Error ? error : new Error(String(error));\n } finally {\n clearTimeout(timer);\n }\n if (outcome === \"timeout\") {\n this.logger.warn(\n `PGlite worker for ${this.label} did not close within ${this.closeGraceMs}ms; terminating`,\n );\n }\n await this.worker.terminate();\n if (closeError !== null) {\n throw closeError;\n }\n }\n\n private currentAdmission(): number | null {\n return this.admission.getStore() ?? null;\n }\n\n private release(reservation: number): void {\n if (this.phase === \"closed\") {\n return;\n }\n const message: HostMessage = { type: \"release\", id: reservation };\n this.worker.postMessage(message);\n }\n\n private request<T>(\n kind: PendingKind,\n build: (id: number) => HostMessage,\n ): Promise<T> {\n if (this.terminalError !== null) {\n return Promise.reject(this.terminalError);\n }\n if (kind !== \"init\" && this.closed) {\n return Promise.reject(new PGliteWorkerClosedError(this.label));\n }\n const id = this.nextId++;\n const promise = new Promise<T>((resolve, reject) => {\n this.pending.set(id, {\n kind,\n resolve: resolve as (value: unknown) => void,\n reject,\n });\n });\n this.worker.postMessage(build(id));\n return promise;\n }\n\n private handleMessage(msg: WorkerMessage): void {\n switch (msg.type) {\n case \"admitted\":\n this.settle(msg.id, msg.inTransaction, undefined);\n return;\n case \"ready\":\n this.settle(msg.id, msg.inTransaction, undefined);\n return;\n case \"query-result\":\n this.settle(msg.id, msg.inTransaction, msg.result);\n return;\n case \"exec-result\":\n this.settle(msg.id, msg.inTransaction, msg.results);\n return;\n case \"stats-result\":\n this.settle(msg.id, this.inTransaction, msg.wasmBytes);\n return;\n case \"rewrite-table-result\":\n this.settle(msg.id, msg.inTransaction, msg.result);\n return;\n case \"closed\":\n this.settle(msg.id, false, undefined);\n return;\n case \"error\":\n this.settleError(\n msg.id,\n msg.inTransaction,\n fromPGliteErrorInfo(msg.error),\n );\n return;\n case \"abort\":\n this.handleAbort(msg.reason);\n return;\n case \"log\":\n this.handleLog(msg);\n return;\n default: {\n const exhaustive: never = msg;\n void exhaustive;\n }\n }\n }\n\n private settle(id: number, inTransaction: boolean, value: unknown): void {\n this.inTransaction = inTransaction;\n const entry = this.pending.get(id);\n if (entry === undefined) {\n return;\n }\n this.pending.delete(id);\n entry.resolve(value);\n }\n\n private settleError(id: number, inTransaction: boolean, error: Error): void {\n this.inTransaction = inTransaction;\n const entry = this.pending.get(id);\n if (entry === undefined) {\n return;\n }\n this.pending.delete(id);\n entry.reject(error);\n }\n\n private handleAbort(reason: string): void {\n if (this.abortReason !== null) {\n return;\n }\n this.abortReason = reason;\n this.logger.error(\n `PGlite worker for ${this.label} aborted: @reason`,\n reason,\n );\n for (const listener of [...this.abortListeners]) {\n try {\n listener(reason);\n } catch (error) {\n this.logger.error(\"PGlite abort listener threw: @error\", error);\n }\n }\n }\n\n private handleLog(msg: LogMessage): void {\n const message = `[${this.label}] ${msg.message}`;\n const args =\n msg.error === undefined ? [] : [fromPGliteErrorInfo(msg.error)];\n const template = args.length > 0 ? `${message}: @error` : message;\n switch (msg.level) {\n case \"debug\":\n this.logger.debug(template, ...args);\n return;\n case \"info\":\n this.logger.info(template, ...args);\n return;\n case \"warn\":\n this.logger.warn(template, ...args);\n return;\n case \"error\":\n this.logger.error(template, ...args);\n return;\n default: {\n const exhaustive: never = msg.level;\n void exhaustive;\n }\n }\n }\n\n private handleWorkerError(err: Error): void {\n this.workerError = err;\n this.logger.error(`PGlite worker for ${this.label} failed: @error`, err);\n }\n\n private handleExit(code: number): void {\n this.forgetTelemetry();\n const graceful = this.phase === \"closing\" && this.terminalError === null;\n this.phase = \"closed\";\n this.inTransaction = false;\n const error = graceful\n ? null\n : (this.terminalError ??\n new PGliteWorkerExitedError(this.label, code, {\n cause: this.workerError ?? undefined,\n }));\n if (error !== null && this.terminalError === null) {\n this.terminalError = error;\n }\n this.rejectPending(error ?? new PGliteWorkerClosedError(this.label));\n for (const listener of [...this.exitListeners]) {\n try {\n listener(error);\n } catch (listenerError) {\n this.logger.error(\"PGlite exit listener threw: @error\", listenerError);\n }\n }\n this.exitListeners.clear();\n this.abortListeners.clear();\n }\n\n /** Records a fatal error and stops the thread; the exit rejects what is pending. */\n private fail(error: Error): void {\n if (this.terminalError === null) {\n this.terminalError = error;\n }\n this.rejectPending(error);\n void this.worker.terminate();\n }\n\n private rejectPending(error: Error): void {\n const entries = [...this.pending.values()];\n this.pending.clear();\n for (const entry of entries) {\n entry.reject(error);\n }\n }\n}\n\nfunction toWireOptions(options: QueryOptions | undefined): WorkerQueryOptions {\n if (options === undefined) {\n return {};\n }\n if (\n options.parsers !== undefined ||\n options.serializers !== undefined ||\n options.blob !== undefined ||\n options.onNotice !== undefined\n ) {\n throw new Error(\n \"ThreadedPGlite does not support parsers, serializers, blob or onNotice per query; configure parsers on the worker\",\n );\n }\n const wire: WorkerQueryOptions = {};\n if (options.rowMode !== undefined) {\n wire.rowMode = options.rowMode;\n }\n if (options.paramTypes !== undefined) {\n wire.paramTypes = options.paramTypes;\n }\n return wire;\n}\n\nfunction toResults<T>(result: WorkerResults): Results<T> {\n const out: Results<T> = {\n rows: result.rows as T[],\n fields: result.fields,\n };\n if (result.affectedRows !== undefined) {\n out.affectedRows = result.affectedRows;\n }\n return out;\n}\n\n/**\n * The worker script: the built entry (chunking may place this module in\n * `dist/` or `dist/src/pglite/`), or, when this module runs from its\n * TypeScript source, a bootstrap that loads the entry through tsx. Null when\n * neither is available.\n */\nfunction resolvePgliteWorkerEntryPath(): string | null {\n if (/\\.m?ts$/.test(new URL(import.meta.url).pathname)) {\n return resolveSourceBootstrap();\n }\n const candidates = [\n \"./src/pglite/worker/entry.mjs\",\n \"./worker/entry.mjs\",\n \"./entry.mjs\",\n ].map((relative) => fileUrlToPath(new URL(relative, import.meta.url)));\n return candidates.find((candidate) => existsSync(candidate)) ?? null;\n}\n\nfunction resolveSourceBootstrap(): string | null {\n const bootstrap = fileUrlToPath(\n new URL(\"./source-bootstrap.mjs\", import.meta.url),\n );\n if (!existsSync(bootstrap)) {\n return null;\n }\n try {\n createRequire(import.meta.url).resolve(\"tsx/esm/api\");\n } catch {\n return null;\n }\n return bootstrap;\n}\n\nfunction fileUrlToPath(url: URL): string {\n if (url.protocol !== \"file:\") {\n return url.href;\n }\n let pathname = decodeURIComponent(url.pathname);\n if (/^\\/[A-Za-z]:[/\\\\]/.test(pathname)) {\n pathname = pathname.slice(1);\n }\n return pathname;\n}\n\n/** Absolute path of the worker script for `new Worker(...)`; null when none can run here. */\nexport const pgliteWorkerEntryPath = resolvePgliteWorkerEntryPath();\n"],"names":["fs","fs","fs"],"mappings":";;;;;;;;;;;;;;AAMA,MAAa,qBAAqB;AAClC,MAAM,QAAQ,IAAI,WAAW;CAAC;CAAM;CAAM;CAAM;AAAI,CAAC;AACrD,MAAM,iBAAiB;AACvB,MAAM,cAAc;AACpB,MAAM,oBAAoB;AAC1B,MAAM,kCAAkB,IAAI,IAAI,CAAC,gBAAgB,CAAC;AAElD,MAAM,wBAAwB;;AAoB9B,eAAsB,gBACpB,cACA,QACA,UAAkC,CAAC,GACP;CAC5B,MAAM,KAAK,MAAMA,SAAG,KAAK,cAAc,GAAG;CAC1C,IAAI;EACF,MAAM,EAAE,SAAS,MAAM,GAAG,KAAK;EAC/B,OAAO,MAAM,kBAAkB,IAAI,MAAM,QAAQ,OAAO;CAC1D,UAAU;EACR,MAAM,GAAG,MAAM;CACjB;AACF;AAEA,eAAe,kBACb,IACA,UACA,QACA,SAC4B;CAC5B,MAAM,OAAO,KAAK,QAAQ,MAAM;CAKhC,MAAM,SAAS,IAAI,cAAc,IAJf,KAAK,IACrB,QAAQ,aAAa,uBACrB,KAAK,IAAI,GAAG,QAAQ,CAEe,CAAS;CAE9C,MAAM,SAAS,MAAM,OAAO,KAAK,WAAW;CAC5C,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAChC,IAAI,OAAO,OAAO,MAAM,IACtB,MAAM,IAAI,MAAM,sCAAsC;CAG1D,MAAM,UAAU,OAAO,aAAa,CAAC;CACrC,IAAI,YAAY,gBACd,MAAM,IAAI,MAAM,8CAA8C,SAAS;CAEzE,MAAM,QAAQ,OAAO,aAAa,CAAC;CAEn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GAC1B,IAAI,eAAe,OAAO;CAE5B,OAAO;AACT;;;;;;;AAQA,SAAS,+BAA8C;CACrD,IAAI,UAAU,KAAK,IAAI,IAAI,YAAY,GAAG,CAAC,CAAC,QAAQ,GAClD,OAAO,uBAAuB;CAOhC,OALmB;EACjB;EACA;EACA;CACF,CAAC,CAAC,KAAK,aAAa,cAAc,IAAI,IAAI,UAAU,YAAY,GAAG,CAAC,CACpD,CAAC,CAAC,MAAM,cAAc,WAAW,SAAS,CAAC,KAAK;AAClE;AAEA,SAAS,yBAAwC;CAC/C,MAAM,YAAY,cAChB,IAAI,IAAI,0BAA0B,YAAY,GAAG,CACnD;CACA,IAAI,CAAC,WAAW,SAAS,GACvB,OAAO;CAET,IAAI;EACF,cAAc,YAAY,GAAG,CAAC,CAAC,QAAQ,aAAa;CACtD,QAAQ;EACN,OAAO;CACT;CACA,OAAO;AACT;AAEA,SAAS,cAAc,KAAkB;CACvC,IAAI,IAAI,aAAa,SACnB,OAAO,IAAI;CAEb,IAAI,WAAW,mBAAmB,IAAI,QAAQ;CAC9C,IAAI,oBAAoB,KAAK,QAAQ,GACnC,WAAW,SAAS,MAAM,CAAC;CAE7B,OAAO;AACT;;AAGA,MAAa,wBAAwB,6BAA6B","debug_id":"8c5d8636-4e82-5d46-982c-c40ed34f74ce"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __exportAll = (all, no_symbols) => {
|
|
5
|
+
let target = {};
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
11
|
+
return target;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { __exportAll as t };
|
|
15
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e3b80eba-208e-51a9-b437-5ac76accf5d0")}catch(e){}}();
|
|
16
|
+
//# debugId=e3b80eba-208e-51a9-b437-5ac76accf5d0
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b96f00d4-5192-57bc-b435-7cc0f7c0f5c8")}catch(e){}}();
|
|
3
|
+
import { childLogger } from "document-model";
|
|
4
|
+
//#region src/graphql/gateway/path-normalize.ts
|
|
5
|
+
/**
|
|
6
|
+
* Normalises a route path for path-to-regexp v8:
|
|
7
|
+
* - Collapses duplicate slashes (e.g. "//explorer" → "/explorer")
|
|
8
|
+
* - Converts legacy optional-param syntax "/:param?" → "{/:param}". The
|
|
9
|
+
* slash must move inside the group: in p-r v8 a group whose content
|
|
10
|
+
* begins with "/" is what makes the slash and the parameter optional
|
|
11
|
+
* together, while a literal "/" left in front of the group compiles to
|
|
12
|
+
* a pattern that matches nothing (and v8 rejects a bare ":param?").
|
|
13
|
+
*
|
|
14
|
+
* Shared by both http adapters so registry dispatch matches the same path
|
|
15
|
+
* shapes regardless of which framework is in use.
|
|
16
|
+
*/
|
|
17
|
+
function normalizePath(path) {
|
|
18
|
+
return path.replace(/\/+/g, "/").replace(/\/:(\w+)\?/g, "{/:$1}");
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/graphql/gateway/run-node-handler.ts
|
|
22
|
+
const logger = childLogger(["reactor-api", "node-route"]);
|
|
23
|
+
/**
|
|
24
|
+
* Runs a node route handler without awaiting it. A throw or rejection is
|
|
25
|
+
* logged and answered with a 500, or ends the socket if headers already went
|
|
26
|
+
* out; it never reaches the process as an unhandled rejection.
|
|
27
|
+
*/
|
|
28
|
+
function runNodeHandler(handler, req, res, body) {
|
|
29
|
+
const fail = (err) => {
|
|
30
|
+
logger.error("Node route handler failed for @method @url: @error", req.method, req.url, err);
|
|
31
|
+
if (res.headersSent) {
|
|
32
|
+
res.destroy();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
res.statusCode = 500;
|
|
36
|
+
res.setHeader("Content-Type", "application/json");
|
|
37
|
+
res.end(JSON.stringify({ error: "Internal error" }));
|
|
38
|
+
};
|
|
39
|
+
let result;
|
|
40
|
+
try {
|
|
41
|
+
result = handler(req, res, body);
|
|
42
|
+
} catch (err) {
|
|
43
|
+
fail(err);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (result) result.catch(fail);
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { normalizePath as n, runNodeHandler as t };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=run-node-handler-CQjyjOuN.mjs.map
|
|
52
|
+
//# debugId=b96f00d4-5192-57bc-b435-7cc0f7c0f5c8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-node-handler-CQjyjOuN.mjs","sources":["../src/graphql/gateway/path-normalize.ts","../src/graphql/gateway/run-node-handler.ts"],"sourcesContent":["/**\n * Normalises a route path for path-to-regexp v8:\n * - Collapses duplicate slashes (e.g. \"//explorer\" → \"/explorer\")\n * - Converts legacy optional-param syntax \"/:param?\" → \"{/:param}\". The\n * slash must move inside the group: in p-r v8 a group whose content\n * begins with \"/\" is what makes the slash and the parameter optional\n * together, while a literal \"/\" left in front of the group compiles to\n * a pattern that matches nothing (and v8 rejects a bare \":param?\").\n *\n * Shared by both http adapters so registry dispatch matches the same path\n * shapes regardless of which framework is in use.\n */\nexport function normalizePath(path: string): string {\n return path.replace(/\\/+/g, \"/\").replace(/\\/:(\\w+)\\?/g, \"{/:$1}\");\n}\n","import { childLogger } from \"document-model\";\nimport type http from \"node:http\";\n\nconst logger = childLogger([\"reactor-api\", \"node-route\"]);\n\nexport type NodeHandler = (\n req: http.IncomingMessage,\n res: http.ServerResponse,\n body?: unknown,\n) => void | Promise<void>;\n\n/**\n * Runs a node route handler without awaiting it. A throw or rejection is\n * logged and answered with a 500, or ends the socket if headers already went\n * out; it never reaches the process as an unhandled rejection.\n */\nexport function runNodeHandler(\n handler: NodeHandler,\n req: http.IncomingMessage,\n res: http.ServerResponse,\n body: unknown,\n): void {\n const fail = (err: unknown): void => {\n logger.error(\n \"Node route handler failed for @method @url: @error\",\n req.method,\n req.url,\n err,\n );\n if (res.headersSent) {\n res.destroy();\n return;\n }\n res.statusCode = 500;\n res.setHeader(\"Content-Type\", \"application/json\");\n res.end(JSON.stringify({ error: \"Internal error\" }));\n };\n\n let result: void | Promise<void>;\n try {\n result = handler(req, res, body);\n } catch (err) {\n fail(err);\n return;\n }\n if (result) {\n result.catch(fail);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAYA,SAAgB,cAAc,MAAsB;CAClD,OAAO,KAAK,QAAQ,QAAQ,GAAG,CAAC,CAAC,QAAQ,eAAe,QAAQ;AAClE;;;ACXA,MAAM,SAAS,YAAY,CAAC,eAAe,YAAY,CAAC;;;;;;AAaxD,SAAgB,eACd,SACA,KACA,KACA,MACM;CACN,MAAM,QAAQ,QAAuB;EACnC,OAAO,MACL,sDACA,IAAI,QACJ,IAAI,KACJ,GACF;EACA,IAAI,IAAI,aAAa;GACnB,IAAI,QAAQ;GACZ;EACF;EACA,IAAI,aAAa;EACjB,IAAI,UAAU,gBAAgB,kBAAkB;EAChD,IAAI,IAAI,KAAK,UAAU,EAAE,OAAO,iBAAiB,CAAC,CAAC;CACrD;CAEA,IAAI;CACJ,IAAI;EACF,SAAS,QAAQ,KAAK,KAAK,IAAI;CACjC,SAAS,KAAK;EACZ,KAAK,GAAG;EACR;CACF;CACA,IAAI,QACF,OAAO,MAAM,IAAI;AAErB","debug_id":"b96f00d4-5192-57bc-b435-7cc0f7c0f5c8"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { a as ReservedTypeNames } from "../../create-schema-ClPWjRPY.mjs";
|
|
2
|
+
import { DocumentNode } from "graphql";
|
|
3
|
+
import { DocumentModelGlobalState } from "@powerhousedao/shared/document-model";
|
|
4
|
+
//#region src/graphql/subgraph-type-ownership.d.ts
|
|
5
|
+
type OwnershipConflict = {
|
|
6
|
+
claim: string;
|
|
7
|
+
owner: string;
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/graphql/subgraph-schema-owner.d.ts
|
|
11
|
+
/** Owner of the types every generated document-model schema carries. */
|
|
12
|
+
export declare const DOCUMENT_MODEL_SCHEMA_OWNER = "document-model schema";
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/graphql/subgraph-types.d.ts
|
|
15
|
+
/** A package's own subgraph, in the order the package exports it. */
|
|
16
|
+
export type PackageSubgraph = {
|
|
17
|
+
name: string;
|
|
18
|
+
typeDefs: DocumentNode;
|
|
19
|
+
};
|
|
20
|
+
export type PackageSubgraphConflicts = {
|
|
21
|
+
/** Who takes the name; "package" is a later same-name subgraph. */
|
|
22
|
+
nameHeldBy?: "core" | "document model" | "package";
|
|
23
|
+
/** Types and root fields the subgraph loses. */
|
|
24
|
+
claims: OwnershipConflict[];
|
|
25
|
+
};
|
|
26
|
+
export type RefusedDocumentModel = {
|
|
27
|
+
name: string;
|
|
28
|
+
reason: string;
|
|
29
|
+
/** Only the model's own subgraph is refused; its types are served. */
|
|
30
|
+
subgraphOnly: boolean;
|
|
31
|
+
};
|
|
32
|
+
export type PackageSubgraphReport = {
|
|
33
|
+
/** By subgraph name; subgraphs without a conflict are left out. */
|
|
34
|
+
conflicts: Map<string, PackageSubgraphConflicts>;
|
|
35
|
+
/** The package's models, or their subgraphs, the server refuses. */
|
|
36
|
+
refusedModels: RefusedDocumentModel[];
|
|
37
|
+
};
|
|
38
|
+
/** Loaded on call: the check pulls in the base models and core schemas. */
|
|
39
|
+
export declare function findPackageSubgraphConflicts(subgraphs: readonly PackageSubgraph[], documentModels: readonly DocumentModelGlobalState[]): Promise<PackageSubgraphReport>;
|
|
40
|
+
//#endregion
|
|
41
|
+
export type { OwnershipConflict, ReservedTypeNames };
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=subgraph-types.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph-types.d.mts","names":[],"sources":["../../../src/graphql/subgraph-type-ownership.ts","../../../src/graphql/subgraph-schema-owner.ts","../../../src/graphql/subgraph-types.ts"],"mappings":";;;;KAqJY;EAAsB;EAAe;;;;;qBCpJpC;;;;YCSD;EAAoB;EAAc,UAAU;;YAE5C;;EAEV;;EAEA,QAAQ;;YAGE;EACV;EACA;;EAEA;;YAGU;;EAEV,WAAW,YAAY;;EAEvB,eAAe;;;wBAIK,6BACpB,oBAAoB,mBACpB,yBAAyB,6BACxB,QAAQ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="31efa70a-ce7c-5c46-b58e-114594b7ff58")}catch(e){}}();
|
|
3
|
+
import { t as DOCUMENT_MODEL_SCHEMA_OWNER } from "../../subgraph-schema-owner-BEjuk2Xv.mjs";
|
|
4
|
+
//#region src/graphql/subgraph-types.ts
|
|
5
|
+
/** Loaded on call: the check pulls in the base models and core schemas. */
|
|
6
|
+
async function findPackageSubgraphConflicts(subgraphs, documentModels) {
|
|
7
|
+
const { checkPackageSubgraphs } = await import("../../package-subgraph-check-DdZLhOHW.mjs");
|
|
8
|
+
return checkPackageSubgraphs(subgraphs, documentModels);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { DOCUMENT_MODEL_SCHEMA_OWNER, findPackageSubgraphConflicts };
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=subgraph-types.mjs.map
|
|
14
|
+
//# debugId=31efa70a-ce7c-5c46-b58e-114594b7ff58
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph-types.mjs","sources":["../../../src/graphql/subgraph-types.ts"],"sourcesContent":["import type { DocumentModelGlobalState } from \"@powerhousedao/shared/document-model\";\nimport type { DocumentNode } from \"graphql\";\nimport type { OwnershipConflict } from \"./subgraph-type-ownership.js\";\n\nexport type { ReservedTypeNames } from \"../utils/create-schema.js\";\nexport type { OwnershipConflict } from \"./subgraph-type-ownership.js\";\n\nexport { DOCUMENT_MODEL_SCHEMA_OWNER } from \"./subgraph-schema-owner.js\";\n\n/** A package's own subgraph, in the order the package exports it. */\nexport type PackageSubgraph = { name: string; typeDefs: DocumentNode };\n\nexport type PackageSubgraphConflicts = {\n /** Who takes the name; \"package\" is a later same-name subgraph. */\n nameHeldBy?: \"core\" | \"document model\" | \"package\";\n /** Types and root fields the subgraph loses. */\n claims: OwnershipConflict[];\n};\n\nexport type RefusedDocumentModel = {\n name: string;\n reason: string;\n /** Only the model's own subgraph is refused; its types are served. */\n subgraphOnly: boolean;\n};\n\nexport type PackageSubgraphReport = {\n /** By subgraph name; subgraphs without a conflict are left out. */\n conflicts: Map<string, PackageSubgraphConflicts>;\n /** The package's models, or their subgraphs, the server refuses. */\n refusedModels: RefusedDocumentModel[];\n};\n\n/** Loaded on call: the check pulls in the base models and core schemas. */\nexport async function findPackageSubgraphConflicts(\n subgraphs: readonly PackageSubgraph[],\n documentModels: readonly DocumentModelGlobalState[],\n): Promise<PackageSubgraphReport> {\n const { checkPackageSubgraphs } = await import(\"./package-subgraph-check.js\");\n return checkPackageSubgraphs(subgraphs, documentModels);\n}\n"],"names":[],"mappings":";;;;;AAkCA,eAAsB,6BACpB,WACA,gBACgC;CAChC,MAAM,EAAE,0BAA0B,MAAM,OAAO;CAC/C,OAAO,sBAAsB,WAAW,cAAc;AACxD","debug_id":"31efa70a-ce7c-5c46-b58e-114594b7ff58"}
|
|
@@ -25,15 +25,15 @@ type NextLoad = (url: string, context: LoadContext) => Promise<LoadResult>;
|
|
|
25
25
|
/**
|
|
26
26
|
* Resolve hook: resolves relative specifiers against HTTP/HTTPS parent URLs.
|
|
27
27
|
*/
|
|
28
|
-
declare function resolve(specifier: string, context: ResolveContext, nextResolve: NextResolve): Promise<ResolveResult>;
|
|
28
|
+
export declare function resolve(specifier: string, context: ResolveContext, nextResolve: NextResolve): Promise<ResolveResult>;
|
|
29
29
|
/**
|
|
30
30
|
* Load hook: fetches module source from HTTP/HTTPS URLs.
|
|
31
31
|
*/
|
|
32
|
-
declare function load(url: string, context: LoadContext, nextLoad: NextLoad): Promise<LoadResult>;
|
|
32
|
+
export declare function load(url: string, context: LoadContext, nextLoad: NextLoad): Promise<LoadResult>;
|
|
33
33
|
/**
|
|
34
34
|
* Path to this hooks file for use with node:module register()
|
|
35
35
|
*/
|
|
36
|
-
declare const httpsHooksPath: string;
|
|
36
|
+
export declare const httpsHooksPath: string;
|
|
37
37
|
//#endregion
|
|
38
|
-
export {
|
|
38
|
+
export {};
|
|
39
39
|
//# sourceMappingURL=https-hooks.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"https-hooks.d.mts","names":[],"sources":["../../../src/packages/https-hooks.mts"],"mappings":";;;;;KASK
|
|
1
|
+
{"version":3,"file":"https-hooks.d.mts","names":[],"sources":["../../../src/packages/https-hooks.mts"],"mappings":";;;;;KASK;EAAmB;EAAoB;;KACvC;EACH;EACA;EACA;;KAEG,eACH,mBACA,SAAS,mBACN,QAAQ;KAER;EAAgB;;KAChB;EAAe;EAAgB;EAAwB;;KACvD,YAAY,aAAa,SAAS,gBAAgB,QAAQ;;;;wBAKzC,QACpB,mBACA,SAAS,gBACT,aAAa,cACZ,QAAQ;;;;wBAgEW,KACpB,aACA,SAAS,aACT,UAAU,WACT,QAAQ;;;;qBAoFE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8149a6c4-bab0-57e3-a471-cfc77d529bbf")}catch(e){}}();
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import { get } from "node:http";
|
|
5
5
|
import { get as get$1 } from "node:https";
|
|
@@ -99,4 +99,4 @@ const httpsHooksPath = import.meta.url;
|
|
|
99
99
|
export { httpsHooksPath, load, resolve };
|
|
100
100
|
|
|
101
101
|
//# sourceMappingURL=https-hooks.mjs.map
|
|
102
|
-
//# debugId=
|
|
102
|
+
//# debugId=8149a6c4-bab0-57e3-a471-cfc77d529bbf
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"https-hooks.mjs","sources":["../../../src/packages/https-hooks.mts"],"sourcesContent":["import { get as httpGet } from \"node:http\";\nimport { get } from \"node:https\";\nimport { pathToFileURL } from \"node:url\";\n\n/**\n * Node.js module loader hooks that enable importing from HTTP/HTTPS URLs.\n * See: https://nodejs.org/docs/latest-v24.x/api/module.html#import-from-https\n */\n\ntype ResolveContext = { parentURL?: string; conditions?: string[] };\ntype ResolveResult = {\n url: string;\n shortCircuit?: boolean;\n format?: string;\n};\ntype NextResolve = (\n specifier: string,\n context: ResolveContext,\n) => Promise<ResolveResult>;\n\ntype LoadContext = { format?: string };\ntype LoadResult = { format: string; shortCircuit?: boolean; source: string };\ntype NextLoad = (url: string, context: LoadContext) => Promise<LoadResult>;\n\n/**\n * Resolve hook: resolves relative specifiers against HTTP/HTTPS parent URLs.\n */\nexport async function resolve(\n specifier: string,\n context: ResolveContext,\n nextResolve: NextResolve,\n): Promise<ResolveResult> {\n const { parentURL } = context;\n\n // If the specifier is already an HTTP(S) URL, resolve it directly\n if (specifier.startsWith(\"https://\") || specifier.startsWith(\"http://\")) {\n return { url: specifier, shortCircuit: true, format: \"module\" };\n }\n\n // If the parent is an HTTP(S) URL and specifier is relative, resolve against it.\n // Only handle relative specifiers (./ or ../), not bare package specifiers.\n if (\n parentURL &&\n (parentURL.startsWith(\"https://\") || parentURL.startsWith(\"http://\")) &&\n (specifier.startsWith(\"./\") || specifier.startsWith(\"../\"))\n ) {\n const resolved = new URL(specifier, parentURL).href;\n return { url: resolved, shortCircuit: true, format: \"module\" };\n }\n\n // Bare specifiers from HTTP modules need a node_modules root to resolve\n // against. Under pnpm's strict isolation the deps a registry-built bundle\n // needs split into two classes:\n // - Peer deps the *consumer* declared (react, react-dom, graphql, …) —\n // live at the consumer project root.\n // - Things reactor-api keeps external by design (the reactor-api package\n // itself, for class identity; internal helpers) — live in reactor-api's\n // own tree.\n // Neither root sees the other under strict mode, so try the consumer first\n // (its declared peers win on version) and fall back to reactor-api's tree.\n //\n // At this point: specifier is not an http(s):// URL (branch 1) and not\n // relative (branch 2). Only redirect bare package specifiers; let absolute\n // paths and other URL schemes (e.g. \"node:fs\", \"file://…\") fall through.\n if (\n parentURL &&\n (parentURL.startsWith(\"https://\") || parentURL.startsWith(\"http://\"))\n ) {\n const isBareSpecifier =\n !specifier.startsWith(\"/\") && !/^[a-z][a-z0-9+.-]*:/i.test(specifier);\n if (isBareSpecifier) {\n const consumerRoot = pathToFileURL(process.cwd() + \"/\").href;\n try {\n return await nextResolve(specifier, {\n ...context,\n parentURL: consumerRoot,\n });\n } catch (e) {\n const code = (e as NodeJS.ErrnoException | undefined)?.code;\n if (code !== \"ERR_MODULE_NOT_FOUND\") throw e;\n return nextResolve(specifier, {\n ...context,\n parentURL: import.meta.url,\n });\n }\n }\n }\n\n // Let Node.js handle all other specifiers\n return nextResolve(specifier, context);\n}\n\n/**\n * Load hook: fetches module source from HTTP/HTTPS URLs.\n */\nexport async function load(\n url: string,\n context: LoadContext,\n nextLoad: NextLoad,\n): Promise<LoadResult> {\n // Handle HTTPS URLs\n if (url.startsWith(\"https://\")) {\n const source = await fetchModule(url, get);\n return {\n format: \"module\",\n shortCircuit: true,\n source: patchCreateRequire(source),\n };\n }\n\n // Handle HTTP URLs (for local development)\n if (url.startsWith(\"http://\")) {\n const source = await fetchModule(url, httpGet);\n return {\n format: \"module\",\n shortCircuit: true,\n source: patchCreateRequire(source),\n };\n }\n\n // Let Node.js handle all other URLs\n return nextLoad(url, context);\n}\n\n/**\n * Rewrite `createRequire(import.meta.url)` in HTTP-loaded modules so that\n * `createRequire` receives a local file URL instead of an HTTP URL it cannot handle.\n *\n * The base is baked in at hook time as a string literal. Injecting a live\n * `process.cwd()` call into the module source (the previous approach) crashes\n * with \"process.cwd is not a function\": HTTP-loaded modules execute in the\n * module-customization realm, which has no full `process`. This hook itself\n * runs where `process.cwd()` works, so we resolve the base here and embed the\n * resulting file URL as a literal — no runtime `process` access in the loaded\n * module. Any package whose bundle contains `createRequire(import.meta.url)`\n * (common CJS interop) failed to load before this.\n */\nfunction patchCreateRequire(source: string): string {\n const requireBase = pathToFileURL(process.cwd() + \"/\").href;\n return source.replace(\n /createRequire\\(import\\.meta\\.url\\)/g,\n `createRequire(${JSON.stringify(requireBase)})`,\n );\n}\n\nfunction fetchModule(\n url: string,\n getter: typeof get | typeof httpGet,\n): Promise<string> {\n return new Promise((resolve, reject) => {\n getter(url, (res) => {\n // Handle redirects\n if (\n res.statusCode &&\n res.statusCode >= 300 &&\n res.statusCode < 400 &&\n res.headers.location\n ) {\n const redirectUrl = res.headers.location;\n const redirectGetter = redirectUrl.startsWith(\"https://\")\n ? get\n : httpGet;\n fetchModule(redirectUrl, redirectGetter).then(resolve).catch(reject);\n return;\n }\n\n if (res.statusCode && res.statusCode >= 400) {\n reject(new Error(`Failed to fetch ${url}: ${res.statusCode}`));\n return;\n }\n\n let data = \"\";\n res.setEncoding(\"utf8\");\n res.on(\"data\", (chunk) => (data += chunk));\n res.on(\"end\", () => resolve(data));\n res.on(\"error\", reject);\n }).on(\"error\", reject);\n });\n}\n\n/**\n * Path to this hooks file for use with node:module register()\n */\nexport const httpsHooksPath: string = import.meta.url;\n"],"names":["get","httpGet"],"mappings":";;;;;;;;;AA2BA,eAAsB,QACpB,WACA,SACA,aACwB;CACxB,MAAM,EAAE,cAAc;
|
|
1
|
+
{"version":3,"file":"https-hooks.mjs","sources":["../../../src/packages/https-hooks.mts"],"sourcesContent":["import { get as httpGet } from \"node:http\";\nimport { get } from \"node:https\";\nimport { pathToFileURL } from \"node:url\";\n\n/**\n * Node.js module loader hooks that enable importing from HTTP/HTTPS URLs.\n * See: https://nodejs.org/docs/latest-v24.x/api/module.html#import-from-https\n */\n\ntype ResolveContext = { parentURL?: string; conditions?: string[] };\ntype ResolveResult = {\n url: string;\n shortCircuit?: boolean;\n format?: string;\n};\ntype NextResolve = (\n specifier: string,\n context: ResolveContext,\n) => Promise<ResolveResult>;\n\ntype LoadContext = { format?: string };\ntype LoadResult = { format: string; shortCircuit?: boolean; source: string };\ntype NextLoad = (url: string, context: LoadContext) => Promise<LoadResult>;\n\n/**\n * Resolve hook: resolves relative specifiers against HTTP/HTTPS parent URLs.\n */\nexport async function resolve(\n specifier: string,\n context: ResolveContext,\n nextResolve: NextResolve,\n): Promise<ResolveResult> {\n const { parentURL } = context;\n\n // If the specifier is already an HTTP(S) URL, resolve it directly\n if (specifier.startsWith(\"https://\") || specifier.startsWith(\"http://\")) {\n return { url: specifier, shortCircuit: true, format: \"module\" };\n }\n\n // If the parent is an HTTP(S) URL and specifier is relative, resolve against it.\n // Only handle relative specifiers (./ or ../), not bare package specifiers.\n if (\n parentURL &&\n (parentURL.startsWith(\"https://\") || parentURL.startsWith(\"http://\")) &&\n (specifier.startsWith(\"./\") || specifier.startsWith(\"../\"))\n ) {\n const resolved = new URL(specifier, parentURL).href;\n return { url: resolved, shortCircuit: true, format: \"module\" };\n }\n\n // Bare specifiers from HTTP modules need a node_modules root to resolve\n // against. Under pnpm's strict isolation the deps a registry-built bundle\n // needs split into two classes:\n // - Peer deps the *consumer* declared (react, react-dom, graphql, …) —\n // live at the consumer project root.\n // - Things reactor-api keeps external by design (the reactor-api package\n // itself, for class identity; internal helpers) — live in reactor-api's\n // own tree.\n // Neither root sees the other under strict mode, so try the consumer first\n // (its declared peers win on version) and fall back to reactor-api's tree.\n //\n // At this point: specifier is not an http(s):// URL (branch 1) and not\n // relative (branch 2). Only redirect bare package specifiers; let absolute\n // paths and other URL schemes (e.g. \"node:fs\", \"file://…\") fall through.\n if (\n parentURL &&\n (parentURL.startsWith(\"https://\") || parentURL.startsWith(\"http://\"))\n ) {\n const isBareSpecifier =\n !specifier.startsWith(\"/\") && !/^[a-z][a-z0-9+.-]*:/i.test(specifier);\n if (isBareSpecifier) {\n const consumerRoot = pathToFileURL(process.cwd() + \"/\").href;\n try {\n return await nextResolve(specifier, {\n ...context,\n parentURL: consumerRoot,\n });\n } catch (e) {\n const code = (e as NodeJS.ErrnoException | undefined)?.code;\n if (code !== \"ERR_MODULE_NOT_FOUND\") throw e;\n return nextResolve(specifier, {\n ...context,\n parentURL: import.meta.url,\n });\n }\n }\n }\n\n // Let Node.js handle all other specifiers\n return nextResolve(specifier, context);\n}\n\n/**\n * Load hook: fetches module source from HTTP/HTTPS URLs.\n */\nexport async function load(\n url: string,\n context: LoadContext,\n nextLoad: NextLoad,\n): Promise<LoadResult> {\n // Handle HTTPS URLs\n if (url.startsWith(\"https://\")) {\n const source = await fetchModule(url, get);\n return {\n format: \"module\",\n shortCircuit: true,\n source: patchCreateRequire(source),\n };\n }\n\n // Handle HTTP URLs (for local development)\n if (url.startsWith(\"http://\")) {\n const source = await fetchModule(url, httpGet);\n return {\n format: \"module\",\n shortCircuit: true,\n source: patchCreateRequire(source),\n };\n }\n\n // Let Node.js handle all other URLs\n return nextLoad(url, context);\n}\n\n/**\n * Rewrite `createRequire(import.meta.url)` in HTTP-loaded modules so that\n * `createRequire` receives a local file URL instead of an HTTP URL it cannot handle.\n *\n * The base is baked in at hook time as a string literal. Injecting a live\n * `process.cwd()` call into the module source (the previous approach) crashes\n * with \"process.cwd is not a function\": HTTP-loaded modules execute in the\n * module-customization realm, which has no full `process`. This hook itself\n * runs where `process.cwd()` works, so we resolve the base here and embed the\n * resulting file URL as a literal — no runtime `process` access in the loaded\n * module. Any package whose bundle contains `createRequire(import.meta.url)`\n * (common CJS interop) failed to load before this.\n */\nfunction patchCreateRequire(source: string): string {\n const requireBase = pathToFileURL(process.cwd() + \"/\").href;\n return source.replace(\n /createRequire\\(import\\.meta\\.url\\)/g,\n `createRequire(${JSON.stringify(requireBase)})`,\n );\n}\n\nfunction fetchModule(\n url: string,\n getter: typeof get | typeof httpGet,\n): Promise<string> {\n return new Promise((resolve, reject) => {\n getter(url, (res) => {\n // Handle redirects\n if (\n res.statusCode &&\n res.statusCode >= 300 &&\n res.statusCode < 400 &&\n res.headers.location\n ) {\n const redirectUrl = res.headers.location;\n const redirectGetter = redirectUrl.startsWith(\"https://\")\n ? get\n : httpGet;\n fetchModule(redirectUrl, redirectGetter).then(resolve).catch(reject);\n return;\n }\n\n if (res.statusCode && res.statusCode >= 400) {\n reject(new Error(`Failed to fetch ${url}: ${res.statusCode}`));\n return;\n }\n\n let data = \"\";\n res.setEncoding(\"utf8\");\n res.on(\"data\", (chunk) => (data += chunk));\n res.on(\"end\", () => resolve(data));\n res.on(\"error\", reject);\n }).on(\"error\", reject);\n });\n}\n\n/**\n * Path to this hooks file for use with node:module register()\n */\nexport const httpsHooksPath: string = import.meta.url;\n"],"names":["get","httpGet"],"mappings":";;;;;;;;;AA2BA,eAAsB,QACpB,WACA,SACA,aACwB;CACxB,MAAM,EA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AK,UAAU,WAAW,EAAE,EAC/C;AACF;AAEA,SAAS,YACP,KACA,QACiB;CACjB,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,OAAO,MAAM,QAAQ;GAEnB,IACE,IAAI,cACJ,IAAI,cAAc,OAClB,IAAI,aAAa,OACjB,IAAI,QAAQ,UACZ;IACA,MAAM,cAAc,IAAI,QAAQ;IAIhC,YAAY,aAHW,YAAY,WAAW,UAAU,IACpDD,QACAC,GACmC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,MAAM,MAAM;IACnE;GACF;GAEA,IAAI,IAAI,cAAc,IAAI,cAAc,KAAK;IAC3C,uBAAO,IAAI,MAAM,mBAAmB,IAAI,IAAI,IAAI,YAAY,CAAC;IAC7D;GACF;GAEA,IAAI,OAAO;GACX,IAAI,YAAY,MAAM;GACtB,IAAI,GAAG,SAAS,UAAW,QAAQ,KAAM;GACzC,IAAI,GAAG,aAAa,QAAQ,IAAI,CAAC;GACjC,IAAI,GAAG,SAAS,MAAM;EACxB,CAAC,CAAC,CAAC,GAAG,SAAS,MAAM;CACvB,CAAC;AACH;;;;AAKA,MAAa,iBAAyB,YAAY","debug_id":"8149a6c4-bab0-57e3-a471-cfc77d529bbf"}
|
|
@@ -1,30 +1,51 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as ScalarExport, f as ReportError, o as ISubscribablePackageLoader, s as ISubscriptionOptions, u as PackagePieceEntry } from "../../types-PXB1ctpi.mjs";
|
|
2
2
|
import { ILogger } from "document-model";
|
|
3
3
|
import { DocumentModelModule, UpgradeManifest } from "@powerhousedao/shared/document-model";
|
|
4
4
|
import { Logger, ViteDevServer } from "vite";
|
|
5
5
|
import { ProcessorFactoryBuilder, SubgraphClass } from "@powerhousedao/reactor-api";
|
|
6
|
-
|
|
7
6
|
//#region src/packages/vite-loader.d.mts
|
|
8
|
-
declare function createViteLogger(logger: ILogger, prefix?: string): Logger;
|
|
9
|
-
|
|
7
|
+
export declare function createViteLogger(logger: ILogger, prefix?: string): Logger;
|
|
8
|
+
export interface VitePackageLoaderOptions {
|
|
9
|
+
/** Modules, as paths or file URLs, whose dependencies a package the project
|
|
10
|
+
* does not install may resolve from. This loader's own module always is. */
|
|
11
|
+
resolveFrom?: string[];
|
|
12
|
+
reportError?: ReportError;
|
|
13
|
+
}
|
|
14
|
+
export declare class VitePackageLoader implements ISubscribablePackageLoader {
|
|
10
15
|
#private;
|
|
11
16
|
private readonly logger;
|
|
12
17
|
private readonly vite;
|
|
18
|
+
private readonly importers;
|
|
13
19
|
readonly name = "VitePackageLoader";
|
|
14
|
-
static build(vite: ViteDevServer): VitePackageLoader;
|
|
15
|
-
constructor(vite: ViteDevServer);
|
|
20
|
+
static build(vite: ViteDevServer, options?: VitePackageLoaderOptions): VitePackageLoader;
|
|
21
|
+
constructor(vite: ViteDevServer, options?: VitePackageLoaderOptions);
|
|
16
22
|
private getDocumentModelsPath;
|
|
17
23
|
private getSubgraphsPath;
|
|
24
|
+
private getScalarsPath;
|
|
18
25
|
private getProcessorsPath;
|
|
19
|
-
|
|
26
|
+
private getPiecesPath;
|
|
27
|
+
private aliasedRoot;
|
|
28
|
+
private pieceRoot;
|
|
29
|
+
loadDocumentModels(identifier: string): Promise<DocumentModelModule[]>;
|
|
20
30
|
loadUpgradeManifests(identifier: string): Promise<UpgradeManifest<readonly number[]>[]>;
|
|
21
31
|
loadSubgraphs(identifier: string): Promise<SubgraphClass[]>;
|
|
32
|
+
loadScalars(identifier: string): Promise<ScalarExport[]>;
|
|
22
33
|
loadProcessors(identifier: string): Promise<ProcessorFactoryBuilder | null>;
|
|
34
|
+
loadPieces(identifier: string): Promise<PackagePieceEntry[]>;
|
|
23
35
|
onDocumentModelsChange(identifier: string, handler: (documentModels: DocumentModelModule[]) => void, options?: ISubscriptionOptions): () => void;
|
|
24
36
|
onSubgraphsChange(identifier: string, handler: (subgraphs: SubgraphClass[]) => void, options?: ISubscriptionOptions): () => void;
|
|
37
|
+
onScalarsChange(identifier: string, handler: (scalars: ScalarExport[]) => void, options?: ISubscriptionOptions): () => void;
|
|
25
38
|
onProcessorsChange(identifier: string, handler: (processors: ProcessorFactoryBuilder | null) => void, options?: ISubscriptionOptions): () => void;
|
|
39
|
+
onPiecesChange(identifier: string, handler: (pieces: PackagePieceEntry[]) => void, options?: ISubscriptionOptions): () => void;
|
|
26
40
|
}
|
|
27
|
-
|
|
41
|
+
/**
|
|
42
|
+
* The project's build output, but for the built piece list `onPiecesChange`
|
|
43
|
+
* watches: its own `dist/` and a Tauri shell's Rust `target/`. On Windows
|
|
44
|
+
* every watched file costs a synchronous `fs.watch` at startup, over a
|
|
45
|
+
* minute for a built project with a built desktop shell.
|
|
46
|
+
*/
|
|
47
|
+
export declare function ignoreBuildOutputButPieces(root: string): (file: string) => boolean;
|
|
48
|
+
export declare function startViteServer(root: string, logger?: Logger): Promise<ViteDevServer>;
|
|
28
49
|
//#endregion
|
|
29
|
-
export {
|
|
50
|
+
export {};
|
|
30
51
|
//# sourceMappingURL=vite-loader.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-loader.d.mts","names":[],"sources":["../../../src/packages/vite-loader.mts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite-loader.d.mts","names":[],"sources":["../../../src/packages/vite-loader.mts"],"mappings":";;;;;;wBAwCgB,iBAAiB,QAAQ,SAAS,kBAAW;iBA2B5C;;;EAGf;EACA,cAAc;;qBAQH,6BAA6B;;mBACvB;mBAEA;mBAEA;WAIR;SAEF,MAAM,MAAM,eAAe,UAAU,2BAAwB;EAIpE,YAAY,MAAM,eAAe,UAAS;UA+DlC;UAIA;UAIA;UAIA;UAIA;UAMA;UASA;EAcF,mBAAmB,qBAAqB,QAAQ;EAmBhD,qBACJ,qBACC,QAAQ;EAoBL,cAAc,qBAAqB,QAAQ;EAiB3C,YAAY,qBAAqB,QAAQ;EAczC,eACJ,qBACC,QAAQ;EAkBL,WAAW,qBAAqB,QAAQ;EA6E9C,uBACE,oBACA,UAAU,gBAAgB,gCAC1B,UAAU;EAgBZ,kBACE,oBACA,UAAU,WAAW,0BACrB,UAAU;EAaZ,gBACE,oBACA,UAAU,SAAS,yBACnB,UAAU;EAaZ,mBACE,oBACA,UAAU,YAAY,yCACtB,UAAU;EAaZ,eACE,oBACA,UAAU,QAAQ,8BAClB,UAAU;;;;;;;;wBA4BE,2BAA2B,gBAAY;wBAqBjC,gBAAgB,cAAc,SAAS,SAAM,QAAA"}
|