@powerhousedao/reactor-api 6.2.3 → 6.3.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/{adapter-gateway-apollo-B54G_cXT.mjs → adapter-gateway-apollo-D-EdZ4e-.mjs} +12 -14
  2. package/dist/adapter-gateway-apollo-D-EdZ4e-.mjs.map +1 -0
  3. package/dist/{adapter-gateway-mercurius-rbKlwF9m.mjs → adapter-gateway-mercurius-CdxLge5p.mjs} +4 -12
  4. package/dist/adapter-gateway-mercurius-CdxLge5p.mjs.map +1 -0
  5. package/dist/{adapter-http-express-CWqziB1p.mjs → adapter-http-express-78KD77cI.mjs} +7 -7
  6. package/dist/adapter-http-express-78KD77cI.mjs.map +1 -0
  7. package/dist/{adapter-http-fastify-CYZQ6FFv.mjs → adapter-http-fastify-Dk7aT_xw.mjs} +7 -7
  8. package/dist/adapter-http-fastify-Dk7aT_xw.mjs.map +1 -0
  9. package/dist/base-document-models-caJpqTLw.mjs +2083 -0
  10. package/dist/base-document-models-caJpqTLw.mjs.map +1 -0
  11. package/dist/create-schema-BCArFBv9.d.mts +167 -0
  12. package/dist/create-schema-BCArFBv9.d.mts.map +1 -0
  13. package/dist/error-info-Cr6oQACe.mjs +601 -0
  14. package/dist/error-info-Cr6oQACe.mjs.map +1 -0
  15. package/dist/index.d.mts +2944 -930
  16. package/dist/index.d.mts.map +1 -1
  17. package/dist/index.mjs +7111 -2845
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/package-subgraph-check-BxKx9kcQ.mjs +138 -0
  20. package/dist/package-subgraph-check-BxKx9kcQ.mjs.map +1 -0
  21. package/dist/pglite-like-CKQEL_Q0.d.mts +27 -0
  22. package/dist/pglite-like-CKQEL_Q0.d.mts.map +1 -0
  23. package/dist/pglite-node-CcX2YT-l.mjs +744 -0
  24. package/dist/pglite-node-CcX2YT-l.mjs.map +1 -0
  25. package/dist/src/graphql/subgraph-types.d.mts +43 -0
  26. package/dist/src/graphql/subgraph-types.d.mts.map +1 -0
  27. package/dist/src/graphql/subgraph-types.mjs +14 -0
  28. package/dist/src/graphql/subgraph-types.mjs.map +1 -0
  29. package/dist/src/packages/vite-loader.d.mts +13 -2
  30. package/dist/src/packages/vite-loader.d.mts.map +1 -1
  31. package/dist/src/packages/vite-loader.mjs +122 -69
  32. package/dist/src/packages/vite-loader.mjs.map +1 -1
  33. package/dist/src/pglite/pglite-node.d.mts +434 -0
  34. package/dist/src/pglite/pglite-node.d.mts.map +1 -0
  35. package/dist/src/pglite/pglite-node.mjs +5 -0
  36. package/dist/src/pglite/worker/entry.d.mts +2 -0
  37. package/dist/src/pglite/worker/entry.mjs +298 -0
  38. package/dist/src/pglite/worker/entry.mjs.map +1 -0
  39. package/dist/subgraph-extraction-uJ8BR0he.mjs +2020 -0
  40. package/dist/subgraph-extraction-uJ8BR0he.mjs.map +1 -0
  41. package/dist/subgraph-schema-owner-BEjuk2Xv.mjs +10 -0
  42. package/dist/subgraph-schema-owner-BEjuk2Xv.mjs.map +1 -0
  43. package/dist/{types-CuSz_zv6.d.mts → types-Bz_xjf8j.d.mts} +41 -7
  44. package/dist/types-Bz_xjf8j.d.mts.map +1 -0
  45. package/package.json +36 -23
  46. package/dist/adapter-gateway-apollo-B54G_cXT.mjs.map +0 -1
  47. package/dist/adapter-gateway-apollo-D2DNlPY0.mjs +0 -4
  48. package/dist/adapter-gateway-mercurius-rbKlwF9m.mjs.map +0 -1
  49. package/dist/adapter-gateway-stitching-Dzv10u8D.mjs +0 -321
  50. package/dist/adapter-gateway-stitching-Dzv10u8D.mjs.map +0 -1
  51. package/dist/adapter-http-express-CWqziB1p.mjs.map +0 -1
  52. package/dist/adapter-http-fastify-CYZQ6FFv.mjs.map +0 -1
  53. package/dist/pieces-swupjgIO.mjs +0 -790
  54. package/dist/pieces-swupjgIO.mjs.map +0 -1
  55. package/dist/types-CuSz_zv6.d.mts.map +0 -1
  56. package/dist/websocket-_SH5aBcy.mjs +0 -18
  57. package/dist/websocket-_SH5aBcy.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"vite-loader.mjs","sources":["../../../src/packages/vite-loader.mts"],"sourcesContent":["import { viteCommonjs } from \"@originjs/vite-plugin-commonjs\";\nimport type {\n ProcessorFactoryBuilder,\n SubgraphClass,\n} from \"@powerhousedao/reactor-api\";\nimport type {\n DocumentModelModule,\n UpgradeManifest,\n} from \"@powerhousedao/shared/document-model\";\nimport { childLogger, type ILogger } from \"document-model\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { readPackage } from \"read-pkg\";\nimport type { Logger, PluginOption, ViteDevServer } from \"vite\";\nimport { createLogger, createServer } from \"vite\";\nimport { isSubgraphClass } from \"../graphql/utils.js\";\nimport {\n BUILT_PIECE_LIST,\n PIECES_SUBPATH,\n packageRootOf,\n pieceListLocation,\n piecesFromListModule,\n} from \"./pieces.js\";\nimport type {\n ISubscribablePackageLoader,\n ISubscriptionOptions,\n PackagePieceEntry,\n} from \"./types.js\";\nimport { debounce, extractUpgradeManifests, isSubpath } from \"./util.js\";\n\nexport function createViteLogger(logger: ILogger, prefix = \"\") {\n const customLogger = createLogger(\"info\", {\n prefix,\n });\n // Wrapped rather than assigned: the logger methods are bound to their own\n // instance, and re-homing them onto Vite's logger object made every Vite\n // log line throw.\n //\n // Vite's text goes through as a replacement, never as the format string: it\n // is somebody else's prose, not a template. `ILogger` substitutes `@token`,\n // and Vite log lines are full of npm scopes, so `pre-transforming\n // @powerhousedao/design-system` came out as `pre-transforming\n // null/design-system`. Substituting into `@line` instead emits it verbatim.\n //\n // Vite's second argument is dropped for the same reason. It is `LogOptions`\n // -- `{ clear, timestamp }` -- and forwarding it made it the replacement for\n // whatever `@token` the line happened to contain, or got appended as JSON.\n // Only `error` keeps it, where it carries the error itself.\n customLogger.info = (msg) => logger.info(\"@line\", msg);\n customLogger.warn = (msg) => logger.warn(\"@line\", msg);\n customLogger.error = (msg, options) =>\n options?.error\n ? logger.error(\"@line\", msg, options.error)\n : logger.error(\"@line\", msg);\n return customLogger;\n}\n\nexport interface VitePackageLoaderOptions {\n /** Modules, as paths or file URLs, whose dependencies a package the project\n * does not install may resolve from. This loader's own module always is. */\n resolveFrom?: string[];\n}\n\ninterface LoadedModule {\n id: string;\n namespace: Record<string, unknown>;\n}\n\nexport class VitePackageLoader implements ISubscribablePackageLoader {\n private readonly logger = childLogger([\"reactor-api\", \"vite-loader\"]);\n\n private readonly vite: ViteDevServer;\n\n private readonly importers: string[];\n\n readonly name = \"VitePackageLoader\";\n\n static build(vite: ViteDevServer, options?: VitePackageLoaderOptions) {\n return new VitePackageLoader(vite, options);\n }\n\n constructor(vite: ViteDevServer, options: VitePackageLoaderOptions = {}) {\n this.vite = vite;\n this.importers = [...(options.resolveFrom ?? []), import.meta.url].map(\n (from) => (from.startsWith(\"file:\") ? fileURLToPath(from) : from),\n );\n }\n\n // The project first, then the host's own dependencies. A bare name or a path\n // Vite cannot resolve is a package without that module, not an error.\n async #resolve(identifier: string, subpath: string) {\n const aliased = path.isAbsolute(identifier)\n ? undefined\n : this.aliasedRoot(identifier);\n const specifier = path.posix.join(aliased ?? identifier, subpath);\n const bare = !aliased && !path.isAbsolute(identifier);\n const importers = bare ? [undefined, ...this.importers] : [undefined];\n const container = this.vite.environments.ssr.pluginContainer;\n for (const importer of importers) {\n try {\n const resolved = await container.resolveId(specifier, importer);\n if (resolved && !resolved.external) return resolved.id;\n } catch (e) {\n this.logger.debug(\"Could not resolve @specifier: @error\", specifier, e);\n }\n }\n return undefined;\n }\n\n // Resolved before it is loaded, so only a module that exists and fails is\n // reported; one a package does not have is a debug-level miss.\n async #load(\n identifier: string,\n subpath: string,\n ): Promise<LoadedModule | undefined> {\n const id = await this.#resolve(identifier, subpath);\n if (id === undefined) {\n this.logger.debug(\"No @subpath module in @pkg\", subpath, identifier);\n return undefined;\n }\n try {\n const namespace = (await this.vite.ssrLoadModule(id)) as Record<\n string,\n unknown\n >;\n return { id, namespace };\n } catch (e) {\n this.logger.error(\n \"Failed to load @subpath of @pkg from @id: @error\",\n subpath,\n identifier,\n id,\n e instanceof Error ? e.message : e,\n );\n return undefined;\n }\n }\n\n private getDocumentModelsPath(identifier: string): string {\n return path.posix.join(identifier, \"./document-models\");\n }\n\n private getSubgraphsPath(identifier: string): string {\n return path.posix.join(identifier, \"./subgraphs\");\n }\n\n private getProcessorsPath(identifier: string): string {\n return path.posix.join(identifier, \"./processors\");\n }\n\n private getPiecesPath(identifier: string): string {\n return path.posix.join(identifier, `./${PIECES_SUBPATH}`);\n }\n\n // The dev server aliases the local project by its own package name, so a\n // package that is this project is rooted at the source tree vite serves.\n private aliasedRoot(identifier: string): string | undefined {\n const alias = this.vite.config.resolve.alias;\n const entries = Array.isArray(alias) ? alias : [];\n const hit = entries.find((entry) => entry.find === identifier);\n return typeof hit?.replacement === \"string\" ? hit.replacement : undefined;\n }\n\n // What a declared piece path is relative to. Not the module vite loaded: a\n // list read from source still points at the built output beside it.\n private pieceRoot(identifier: string, listId?: string): string | undefined {\n if (!path.isAbsolute(identifier)) {\n const aliased = this.aliasedRoot(identifier);\n if (aliased) return aliased;\n // A built list resolved from wherever the package is installed.\n if (listId) return packageRootOf(path.dirname(listId));\n }\n try {\n return pieceListLocation(identifier).root;\n } catch {\n return undefined;\n }\n }\n\n public loadDocumentModels(identifier: string, immediate = false) {\n return this.#loadDocumentModelsWithDebounce(immediate, identifier);\n }\n\n #loadDocumentModelsWithDebounce = debounce(\n this.#loadDocumentModels.bind(this),\n 500,\n );\n\n async #loadDocumentModels(\n identifier: string,\n ): Promise<DocumentModelModule[]> {\n this.logger.debug(\n \"Loading document models from\",\n this.getDocumentModelsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"document-models\");\n if (!loaded) return [];\n\n // duck type\n const documentModels = Object.values(loaded.namespace).filter(\n (dm): dm is DocumentModelModule =>\n dm !== null && typeof dm === \"object\" && \"documentModel\" in dm,\n );\n this.logger.verbose(\n ` ➜ Loaded ${documentModels.length} Document Models from: ${identifier}`,\n );\n return documentModels;\n }\n\n async loadUpgradeManifests(\n identifier: string,\n ): Promise<UpgradeManifest<readonly number[]>[]> {\n // Projects generated before the aggregate index re-exported the\n // manifests only expose them at document-models/upgrade-manifests.\n for (const subpath of [\n \"document-models\",\n \"document-models/upgrade-manifests\",\n ]) {\n const loaded = await this.#load(identifier, subpath);\n if (!loaded) continue;\n const manifests = extractUpgradeManifests(loaded.namespace);\n if (manifests.length > 0) {\n this.logger.verbose(\n ` ➜ Loaded ${manifests.length} Upgrade Manifests from: ${identifier}`,\n );\n return manifests;\n }\n }\n return [];\n }\n\n async loadSubgraphs(identifier: string): Promise<SubgraphClass[]> {\n this.logger.verbose(\n \"Loading subgraphs from\",\n this.getSubgraphsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"subgraphs\");\n if (!loaded) return [];\n\n const subgraphs: SubgraphClass[] = [];\n for (const [name, subgraph] of Object.entries(\n loaded.namespace as Record<string, Record<string, SubgraphClass>>,\n )) {\n const SubgraphClass = subgraph[name];\n if (isSubgraphClass(SubgraphClass)) {\n subgraphs.push(SubgraphClass);\n }\n }\n\n this.logger.debug(\n ` ➜ Loaded ${subgraphs.length} Subgraphs from: ${identifier}`,\n );\n\n return subgraphs;\n }\n\n async loadProcessors(\n identifier: string,\n ): Promise<ProcessorFactoryBuilder | null> {\n this.logger.verbose(\n \"Loading processors from\",\n this.getProcessorsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"processors\");\n const factory = loaded?.namespace.processorFactory;\n if (typeof factory === \"function\") {\n this.logger.verbose(` ➜ Loaded Processor Factory from: ${identifier}`);\n return factory as ProcessorFactoryBuilder;\n }\n\n this.logger.verbose(` ➜ No Processor Factory found for: ${identifier}`);\n return null;\n }\n\n // The list only, never a piece: in dev it is usually the TypeScript source,\n // and what it names is still the built bundle a worker will load.\n async loadPieces(identifier: string): Promise<PackagePieceEntry[]> {\n this.logger.verbose(\"Loading pieces from\", this.getPiecesPath(identifier));\n const loaded = await this.#load(identifier, PIECES_SUBPATH);\n if (!loaded) return [];\n\n const root = this.pieceRoot(identifier, loaded.id);\n if (root === undefined) {\n this.logger.debug(` ➜ No package root found for: ${identifier}`);\n return [];\n }\n\n const pieces = piecesFromListModule(loaded.namespace, {\n root,\n identifier,\n logger: this.logger,\n });\n this.logger.debug(\n ` ➜ Loaded ${pieces.length} Pieces from: ${identifier}`,\n );\n return pieces;\n }\n\n onDocumentModelsChange(\n identifier: string,\n handler: (documentModels: DocumentModelModule[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const listener = async (changedPath: string) => {\n const documentModelsPath = this.getDocumentModelsPath(identifier);\n if (isSubpath(documentModelsPath, changedPath)) {\n const documentModels = await this.loadDocumentModels(identifier);\n handler(documentModels);\n }\n };\n\n // \"change\" alone misses files that are created or deleted: a removed\n // document-models/ entry would never report an empty result, and the\n // package's registered models would leak.\n this.vite.watcher.on(\"change\", listener);\n this.vite.watcher.on(\"add\", listener);\n this.vite.watcher.on(\"unlink\", listener);\n\n return () => {\n this.vite.watcher.off(\"change\", listener);\n this.vite.watcher.off(\"add\", listener);\n this.vite.watcher.off(\"unlink\", listener);\n };\n }\n\n onSubgraphsChange(\n identifier: string,\n handler: (subgraphs: SubgraphClass[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const subgraphsPath = this.getSubgraphsPath(identifier);\n const listener = async (changedPath: string) => {\n if (isSubpath(subgraphsPath, changedPath)) {\n const subgraphs = await this.loadSubgraphs(identifier);\n handler(subgraphs);\n }\n };\n // \"change\" alone misses files that are created or deleted: a removed\n // subgraphs/ entry would never report an empty result, and the\n // package's registered subgraphs would leak.\n this.vite.watcher.on(\"change\", listener);\n this.vite.watcher.on(\"add\", listener);\n this.vite.watcher.on(\"unlink\", listener);\n\n return () => {\n this.vite.watcher.off(\"change\", listener);\n this.vite.watcher.off(\"add\", listener);\n this.vite.watcher.off(\"unlink\", listener);\n };\n }\n\n onProcessorsChange(\n identifier: string,\n handler: (processors: ProcessorFactoryBuilder | null) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const processorsPath = this.getProcessorsPath(identifier);\n const listener = async (changedPath: string) => {\n if (isSubpath(processorsPath, changedPath)) {\n const processors = await this.loadProcessors(identifier);\n handler(processors);\n }\n };\n // \"change\" alone misses files that are created or deleted: a removed\n // processors/ entry would never report an empty result, and the\n // package's registered processor factories would leak.\n this.vite.watcher.on(\"change\", listener);\n this.vite.watcher.on(\"add\", listener);\n this.vite.watcher.on(\"unlink\", listener);\n\n return () => {\n this.vite.watcher.off(\"change\", listener);\n this.vite.watcher.off(\"add\", listener);\n this.vite.watcher.off(\"unlink\", listener);\n };\n }\n\n onPiecesChange(\n identifier: string,\n handler: (pieces: PackagePieceEntry[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n // Both the source list and the build output: the list says which pieces a\n // package ships, and only the build decides whether one is there to run.\n const watched = [this.getPiecesPath(identifier)];\n const root = this.pieceRoot(identifier);\n if (root !== undefined) {\n watched.push(path.dirname(path.resolve(root, BUILT_PIECE_LIST)));\n }\n const listener = async (changedPath: string) => {\n if (!watched.some((dir) => isSubpath(dir, changedPath))) return;\n handler(await this.loadPieces(identifier));\n };\n // \"change\" alone misses files that are created or deleted, and a piece\n // appearing for the first time is exactly the build this watches for.\n this.vite.watcher.on(\"change\", listener);\n this.vite.watcher.on(\"add\", listener);\n this.vite.watcher.on(\"unlink\", listener);\n\n return () => {\n this.vite.watcher.off(\"change\", listener);\n this.vite.watcher.off(\"add\", listener);\n this.vite.watcher.off(\"unlink\", listener);\n };\n }\n}\n\nexport async function startViteServer(root: string, logger?: Logger) {\n const packageJson = await readPackage({ cwd: root });\n\n const vite = await createServer({\n root,\n configFile: false,\n logger,\n server: { middlewareMode: true, watch: { ignored: [\"**/.ph/**\"] } },\n appType: \"custom\",\n build: {\n rollupOptions: {\n input: [],\n },\n },\n resolve: {\n tsconfigPaths: true,\n alias: {\n [packageJson.name]: root,\n },\n },\n plugins: [\n // cast: the plugin ships types built against an older vite, and the\n // mismatched Plugin type crashes tsc 6 during assignability checking\n viteCommonjs() as PluginOption,\n {\n name: \"suppress-hmr\",\n handleHotUpdate() {\n return []; // return empty array to suppress server refresh\n },\n },\n ],\n });\n\n return vite;\n}\n"],"names":[],"mappings":";;;;;;;;;;AA8BA,SAAgB,iBAAiB,QAAiB,SAAS,IAAI;CAC7D,MAAM,eAAe,aAAa,QAAQ,EACxC,OACF,CAAC;CAeD,aAAa,QAAQ,QAAQ,OAAO,KAAK,SAAS,GAAG;CACrD,aAAa,QAAQ,QAAQ,OAAO,KAAK,SAAS,GAAG;CACrD,aAAa,SAAS,KAAK,YACzB,SAAS,QACL,OAAO,MAAM,SAAS,KAAK,QAAQ,KAAK,IACxC,OAAO,MAAM,SAAS,GAAG;CAC/B,OAAO;AACT;AAaA,IAAa,oBAAb,MAAa,kBAAwD;CACnE,SAA0B,YAAY,CAAC,eAAe,aAAa,CAAC;CAEpE;CAEA;CAEA,OAAgB;CAEhB,OAAO,MAAM,MAAqB,SAAoC;EACpE,OAAO,IAAI,kBAAkB,MAAM,OAAO;CAC5C;CAEA,YAAY,MAAqB,UAAoC,CAAC,GAAG;EACvE,KAAK,OAAO;EACZ,KAAK,YAAY,CAAC,GAAI,QAAQ,eAAe,CAAC,GAAI,YAAY,GAAG,CAAC,CAAC,KAChE,SAAU,KAAK,WAAW,OAAO,IAAI,cAAc,IAAI,IAAI,IAC9D;CACF;CAIA,MAAM,SAAS,YAAoB,SAAiB;EAClD,MAAM,UAAU,KAAK,WAAW,UAAU,IACtC,KAAA,IACA,KAAK,YAAY,UAAU;EAC/B,MAAM,YAAY,KAAK,MAAM,KAAK,WAAW,YAAY,OAAO;EAEhE,MAAM,YADO,CAAC,WAAW,CAAC,KAAK,WAAW,UAAU,IAC3B,CAAC,KAAA,GAAW,GAAG,KAAK,SAAS,IAAI,CAAC,KAAA,CAAS;EACpE,MAAM,YAAY,KAAK,KAAK,aAAa,IAAI;EAC7C,KAAK,MAAM,YAAY,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AAM,WAAW,OAAO,gBAAwB;GAC9C,IAAI,CAAC,QAAQ,MAAM,QAAQ,UAAU,KAAK,WAAW,CAAC,GAAG;GACzD,QAAQ,MAAM,KAAK,WAAW,UAAU,CAAC;EAC3C;EAGA,KAAK,KAAK,QAAQ,GAAG,UAAU,QAAQ;EACvC,KAAK,KAAK,QAAQ,GAAG,OAAO,QAAQ;EACpC,KAAK,KAAK,QAAQ,GAAG,UAAU,QAAQ;EAEvC,aAAa;GACX,KAAK,KAAK,QAAQ,IAAI,UAAU,QAAQ;GACxC,KAAK,KAAK,QAAQ,IAAI,OAAO,QAAQ;GACrC,KAAK,KAAK,QAAQ,IAAI,UAAU,QAAQ;EAC1C;CACF;AACF;AAEA,eAAsB,gBAAgB,MAAc,QAAiB;CACnE,MAAM,cAAc,MAAM,YAAY,EAAE,KAAK,KAAK,CAAC;CAgCnD,OAAO,MA9BY,aAAa;EAC9B;EACA,YAAY;EACZ;EACA,QAAQ;GAAE,gBAAgB;GAAM,OAAO,EAAE,SAAS,CAAC,WAAW,EAAE;EAAE;EAClE,SAAS;EACT,OAAO,EACL,eAAe,EACb,OAAO,CAAC,EACV,EACF;EACA,SAAS;GACP,eAAe;GACf,OAAO,GACJ,YAAY,OAAO,KACtB;EACF;EACA,SAAS,CAGP,aAAa,GACb;GACE,MAAM;GACN,kBAAkB;IAChB,OAAO,CAAC;GACV;EACF,CACF;CACF,CAAC;AAGH","debug_id":"33a7684d-ff05-56ac-b4f5-910a2adca3e5"}
1
+ {"version":3,"file":"vite-loader.mjs","sources":["../../../src/packages/vite-loader.mts"],"sourcesContent":["import { viteCommonjs } from \"@originjs/vite-plugin-commonjs\";\nimport type {\n ProcessorFactoryBuilder,\n SubgraphClass,\n} from \"@powerhousedao/reactor-api\";\nimport type {\n DocumentModelModule,\n UpgradeManifest,\n} from \"@powerhousedao/shared/document-model\";\nimport { getCodegenStatusRegistry } from \"@powerhousedao/shared/processors\";\nimport { childLogger, type ILogger } from \"document-model\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { readPackage } from \"read-pkg\";\nimport type { Logger, PluginOption, ViteDevServer } from \"vite\";\nimport { createLogger, createServer } from \"vite\";\nimport { extractDocumentModels } from \"./document-model-detection.js\";\nimport { type ScalarExport, scalarExportsOf } from \"./scalar-exports.js\";\nimport { extractSubgraphs } from \"./subgraph-extraction.js\";\nimport {\n BUILT_PIECE_LIST,\n PIECES_SUBPATH,\n packageRootOf,\n pieceListLocation,\n piecesFromListModule,\n} from \"./pieces.js\";\nimport type {\n ISubscribablePackageLoader,\n ISubscriptionOptions,\n PackagePieceEntry,\n} from \"./types.js\";\nimport {\n PACKAGE_MODULE_FAILED,\n debounce,\n extractUpgradeManifests,\n failedLoadHeader,\n isSubpath,\n} from \"./util.js\";\nimport { runDetached, type ReportError } from \"../utils/detached.js\";\n\nexport function createViteLogger(logger: ILogger, prefix = \"\") {\n const customLogger = createLogger(\"info\", {\n prefix,\n });\n // Wrapped rather than assigned: the logger methods are bound to their own\n // instance, and re-homing them onto Vite's logger object made every Vite\n // log line throw.\n //\n // Vite's text goes through as a replacement, never as the format string: it\n // is somebody else's prose, not a template. `ILogger` substitutes `@token`,\n // and Vite log lines are full of npm scopes, so `pre-transforming\n // @powerhousedao/design-system` came out as `pre-transforming\n // null/design-system`. Substituting into `@line` instead emits it verbatim.\n //\n // Vite's second argument is dropped for the same reason. It is `LogOptions`\n // -- `{ clear, timestamp }` -- and forwarding it made it the replacement for\n // whatever `@token` the line happened to contain, or got appended as JSON.\n // Only `error` keeps it, where it carries the error itself.\n customLogger.info = (msg) => logger.info(\"@line\", msg);\n customLogger.warn = (msg) => logger.warn(\"@line\", msg);\n customLogger.error = (msg, options) =>\n options?.error\n ? logger.error(\"@line\", msg, options.error)\n : logger.error(\"@line\", msg);\n return customLogger;\n}\n\nexport interface VitePackageLoaderOptions {\n /** Modules, as paths or file URLs, whose dependencies a package the project\n * does not install may resolve from. This loader's own module always is. */\n resolveFrom?: string[];\n reportError?: ReportError;\n}\n\ninterface LoadedModule {\n id: string;\n namespace: Record<string, unknown>;\n}\n\nconst FILE_EVENTS = [\"change\", \"add\", \"unlink\"] as const;\n\n// Vite's chokidar drops a \"change\" for a path that already changed in the\n// last 50ms, and never emits it later. A reload must start after that window,\n// or a second quick write to the same file is read stale and never reloaded.\nconst WATCHER_CHANGE_THROTTLE_MS = 50;\n\nexport class VitePackageLoader implements ISubscribablePackageLoader {\n private readonly logger = childLogger([\"reactor-api\", \"vite-loader\"]);\n\n private readonly vite: ViteDevServer;\n\n private readonly importers: string[];\n\n readonly #reportError?: ReportError;\n\n // One watcher listener per event for every subscription, so Vite's watcher\n // stays under its listener limit however many packages are watched.\n readonly #fileListeners = new Set<(changedPath: string) => void>();\n\n readonly name = \"VitePackageLoader\";\n\n static build(vite: ViteDevServer, options?: VitePackageLoaderOptions) {\n return new VitePackageLoader(vite, options);\n }\n\n constructor(vite: ViteDevServer, options: VitePackageLoaderOptions = {}) {\n this.vite = vite;\n this.importers = [...(options.resolveFrom ?? []), import.meta.url].map(\n (from) => (from.startsWith(\"file:\") ? fileURLToPath(from) : from),\n );\n this.#reportError = options.reportError;\n }\n\n // The project first, then the host's own dependencies. A bare name or a path\n // Vite cannot resolve is a package without that module, not an error.\n async #resolve(identifier: string, subpath: string) {\n const aliased = path.isAbsolute(identifier)\n ? undefined\n : this.aliasedRoot(identifier);\n const specifier = path.posix.join(aliased ?? identifier, subpath);\n const bare = !aliased && !path.isAbsolute(identifier);\n const importers = bare ? [undefined, ...this.importers] : [undefined];\n const container = this.vite.environments.ssr.pluginContainer;\n for (const importer of importers) {\n try {\n const resolved = await container.resolveId(specifier, importer);\n if (resolved && !resolved.external) return resolved.id;\n } catch (e) {\n this.logger.debug(\"Could not resolve @specifier: @error\", specifier, e);\n }\n }\n return undefined;\n }\n\n // Resolved before it is loaded, so only a module that exists and fails is\n // reported and thrown; one a package does not have is a debug-level miss.\n async #load(\n identifier: string,\n subpath: string,\n kind: string,\n ): Promise<LoadedModule | undefined> {\n const id = await this.#resolve(identifier, subpath);\n if (id === undefined) {\n this.logger.debug(\"No @subpath module in @pkg\", subpath, identifier);\n return undefined;\n }\n try {\n const namespace = (await this.vite.ssrLoadModule(id)) as Record<\n string,\n unknown\n >;\n return { id, namespace };\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n this.logger.error(\n `${failedLoadHeader(kind)}\\n @id: @error`,\n identifier,\n id,\n message,\n );\n // Tagged: vite's own code can read as a package without the module.\n throw Object.assign(\n new Error(`Failed to load ${id}: ${message}`, { cause: e }),\n { code: PACKAGE_MODULE_FAILED },\n );\n }\n }\n\n private getDocumentModelsPath(identifier: string): string {\n return path.posix.join(identifier, \"./document-models\");\n }\n\n private getSubgraphsPath(identifier: string): string {\n return path.posix.join(identifier, \"./subgraphs\");\n }\n\n private getScalarsPath(identifier: string): string {\n return path.posix.join(identifier, \"./scalars\");\n }\n\n private getProcessorsPath(identifier: string): string {\n return path.posix.join(identifier, \"./processors\");\n }\n\n private getPiecesPath(identifier: string): string {\n return path.posix.join(identifier, `./${PIECES_SUBPATH}`);\n }\n\n // The dev server aliases the local project by its own package name, so a\n // package that is this project is rooted at the source tree vite serves.\n private aliasedRoot(identifier: string): string | undefined {\n const alias = this.vite.config.resolve.alias;\n const entries = Array.isArray(alias) ? alias : [];\n const hit = entries.find((entry) => entry.find === identifier);\n return typeof hit?.replacement === \"string\" ? hit.replacement : undefined;\n }\n\n // What a declared piece path is relative to. Not the module vite loaded: a\n // list read from source still points at the built output beside it.\n private pieceRoot(identifier: string, listId?: string): string | undefined {\n if (!path.isAbsolute(identifier)) {\n const aliased = this.aliasedRoot(identifier);\n if (aliased) return aliased;\n // A built list resolved from wherever the package is installed.\n if (listId) return packageRootOf(path.dirname(listId));\n }\n try {\n return pieceListLocation(identifier).root;\n } catch {\n return undefined;\n }\n }\n\n async loadDocumentModels(identifier: string): Promise<DocumentModelModule[]> {\n this.logger.debug(\n \"Loading document models from\",\n this.getDocumentModelsPath(identifier),\n );\n const loaded = await this.#load(\n identifier,\n \"document-models\",\n \"document models\",\n );\n if (!loaded) return [];\n\n const documentModels = extractDocumentModels(loaded.namespace);\n this.logger.verbose(\n ` ➜ Loaded ${documentModels.length} Document Models from: ${identifier}`,\n );\n return documentModels;\n }\n\n async loadUpgradeManifests(\n identifier: string,\n ): Promise<UpgradeManifest<readonly number[]>[]> {\n // Projects generated before the aggregate index re-exported the\n // manifests only expose them at document-models/upgrade-manifests.\n for (const subpath of [\n \"document-models\",\n \"document-models/upgrade-manifests\",\n ]) {\n const loaded = await this.#load(identifier, subpath, \"upgrade manifests\");\n if (!loaded) continue;\n const manifests = extractUpgradeManifests(loaded.namespace);\n if (manifests.length > 0) {\n this.logger.verbose(\n ` ➜ Loaded ${manifests.length} Upgrade Manifests from: ${identifier}`,\n );\n return manifests;\n }\n }\n return [];\n }\n\n async loadSubgraphs(identifier: string): Promise<SubgraphClass[]> {\n this.logger.verbose(\n \"Loading subgraphs from\",\n this.getSubgraphsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"subgraphs\", \"subgraphs\");\n if (!loaded) return [];\n\n const subgraphs = extractSubgraphs(loaded.namespace);\n\n this.logger.debug(\n ` ➜ Loaded ${subgraphs.length} Subgraphs from: ${identifier}`,\n );\n\n return subgraphs;\n }\n\n async loadScalars(identifier: string): Promise<ScalarExport[]> {\n this.logger.verbose(\n \"Loading scalars from\",\n this.getScalarsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"scalars\", \"scalars\");\n if (!loaded) return [];\n const scalars = scalarExportsOf(loaded.namespace);\n this.logger.debug(\n ` ➜ Loaded ${scalars.length} Scalars from: ${identifier}`,\n );\n return scalars;\n }\n\n async loadProcessors(\n identifier: string,\n ): Promise<ProcessorFactoryBuilder | null> {\n this.logger.verbose(\n \"Loading processors from\",\n this.getProcessorsPath(identifier),\n );\n const loaded = await this.#load(identifier, \"processors\", \"processors\");\n const factory = loaded?.namespace.processorFactory;\n if (typeof factory === \"function\") {\n this.logger.verbose(` ➜ Loaded Processor Factory from: ${identifier}`);\n return factory as ProcessorFactoryBuilder;\n }\n\n this.logger.verbose(` ➜ No Processor Factory found for: ${identifier}`);\n return null;\n }\n\n // The list only, never a piece: in dev it is usually the TypeScript source,\n // and what it names is still the built bundle a worker will load.\n async loadPieces(identifier: string): Promise<PackagePieceEntry[]> {\n this.logger.verbose(\"Loading pieces from\", this.getPiecesPath(identifier));\n const loaded = await this.#load(identifier, PIECES_SUBPATH, \"pieces\");\n if (!loaded) return [];\n\n const root = this.pieceRoot(identifier, loaded.id);\n if (root === undefined) {\n this.logger.debug(` ➜ No package root found for: ${identifier}`);\n return [];\n }\n\n const pieces = piecesFromListModule(loaded.namespace, {\n root,\n identifier,\n logger: this.logger,\n });\n this.logger.debug(\n ` ➜ Loaded ${pieces.length} Pieces from: ${identifier}`,\n );\n return pieces;\n }\n\n // One detached reload per burst of file events. \"add\" and \"unlink\" too, or a\n // removed entry never reports empty and its registrations leak. Once\n // unsubscribed, no pending or running reload reaches `handler`, and a\n // failed load leaves the last good set.\n #watch<T>(\n label: string,\n reported: { pkg: string; kind: string },\n matches: (changedPath: string) => unknown,\n load: () => Promise<T>,\n handler: (value: T) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n let subscribed = true;\n // Read by reactor-mcp's getCodegenStatus, e.g. for broken generated code.\n const report = (failure?: string) =>\n getCodegenStatusRegistry().reportLoad(\n reported.pkg,\n reported.kind,\n failure,\n );\n const reloadOnce = debounce(\n () =>\n runDetached(\n label,\n async () => {\n if (!subscribed) return;\n let value: T;\n try {\n value = await load();\n } catch (e) {\n if ((e as NodeJS.ErrnoException).code === PACKAGE_MODULE_FAILED) {\n report(`[${this.name}] ${(e as Error).message}`);\n return;\n }\n throw e;\n }\n report();\n if (subscribed) handler(value);\n },\n { logger: this.logger, report: this.#reportError },\n ),\n Math.max(options?.debounce ?? 100, WATCHER_CHANGE_THROTTLE_MS),\n );\n const listener = (changedPath: string) => {\n if (matches(changedPath)) void reloadOnce();\n };\n if (this.#fileListeners.size === 0) {\n for (const event of FILE_EVENTS) {\n this.vite.watcher.on(event, this.#dispatchFileEvent);\n }\n }\n this.#fileListeners.add(listener);\n\n return () => {\n subscribed = false;\n if (!this.#fileListeners.delete(listener)) return;\n if (this.#fileListeners.size > 0) return;\n for (const event of FILE_EVENTS) {\n this.vite.watcher.off(event, this.#dispatchFileEvent);\n }\n };\n }\n\n readonly #dispatchFileEvent = (changedPath: string) => {\n for (const listener of [...this.#fileListeners]) listener(changedPath);\n };\n\n onDocumentModelsChange(\n identifier: string,\n handler: (documentModels: DocumentModelModule[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const watched = [\n this.getDocumentModelsPath(identifier),\n this.getScalarsPath(identifier),\n ];\n return this.#watch(\n `Reloading the document models of ${identifier}`,\n { pkg: identifier, kind: \"document models\" },\n (changedPath) => watched.some((dir) => isSubpath(dir, changedPath)),\n () => this.loadDocumentModels(identifier),\n handler,\n options,\n );\n }\n\n onSubgraphsChange(\n identifier: string,\n handler: (subgraphs: SubgraphClass[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const subgraphsPath = this.getSubgraphsPath(identifier);\n return this.#watch(\n `Reloading the subgraphs of ${identifier}`,\n { pkg: identifier, kind: \"subgraphs\" },\n (changedPath) => isSubpath(subgraphsPath, changedPath),\n () => this.loadSubgraphs(identifier),\n handler,\n options,\n );\n }\n\n onScalarsChange(\n identifier: string,\n handler: (scalars: ScalarExport[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const scalarsPath = this.getScalarsPath(identifier);\n return this.#watch(\n `Reloading the scalars of ${identifier}`,\n { pkg: identifier, kind: \"scalars\" },\n (changedPath) => isSubpath(scalarsPath, changedPath),\n () => this.loadScalars(identifier),\n handler,\n options,\n );\n }\n\n onProcessorsChange(\n identifier: string,\n handler: (processors: ProcessorFactoryBuilder | null) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n const processorsPath = this.getProcessorsPath(identifier);\n return this.#watch(\n `Reloading the processors of ${identifier}`,\n { pkg: identifier, kind: \"processors\" },\n (changedPath) => isSubpath(processorsPath, changedPath),\n () => this.loadProcessors(identifier),\n handler,\n options,\n );\n }\n\n onPiecesChange(\n identifier: string,\n handler: (pieces: PackagePieceEntry[]) => void,\n options?: ISubscriptionOptions,\n ): () => void {\n // Both the source list and the build output: the list says which pieces a\n // package ships, and only the build decides whether one is there to run.\n const watched = [this.getPiecesPath(identifier)];\n const root = this.pieceRoot(identifier);\n if (root !== undefined) {\n watched.push(path.dirname(path.resolve(root, BUILT_PIECE_LIST)));\n }\n return this.#watch(\n `Reloading the pieces of ${identifier}`,\n { pkg: identifier, kind: \"pieces\" },\n (changedPath) => watched.some((dir) => isSubpath(dir, changedPath)),\n () => this.loadPieces(identifier),\n handler,\n options,\n );\n }\n}\n\nconst toSlashes = (file: string) => file.replaceAll(\"\\\\\", \"/\");\n\n/**\n * The project's build output, but for the built piece list `onPiecesChange`\n * watches: its own `dist/` and a Tauri shell's Rust `target/`. On Windows\n * every watched file costs a synchronous `fs.watch` at startup, over a\n * minute for a built project with a built desktop shell.\n */\nexport function ignoreBuildOutputButPieces(root: string) {\n const dist = `${toSlashes(path.resolve(root, \"dist\"))}/`;\n const pieces = toSlashes(path.dirname(path.resolve(root, BUILT_PIECE_LIST)));\n return (file: string) => {\n const at = toSlashes(path.resolve(root, file));\n if (\n at.includes(\"/tauri-shell/target/\") ||\n at.includes(\"/src-tauri/target/\")\n ) {\n return true;\n }\n if (!at.startsWith(dist)) return false;\n // The piece list's folder, what is in it, and the folders leading to it stay watched.\n return !(\n at === pieces ||\n at.startsWith(`${pieces}/`) ||\n pieces.startsWith(`${at}/`)\n );\n };\n}\n\nexport async function startViteServer(root: string, logger?: Logger) {\n const packageJson = await readPackage({ cwd: root });\n\n const vite = await createServer({\n root,\n configFile: false,\n customLogger: logger,\n server: {\n middlewareMode: true,\n // It loads modules, never serves a page: no HMR, and no WebSocket port\n // (24678 by default) for a second project's Vetra to collide on.\n hmr: false,\n ws: false,\n watch: { ignored: [\"**/.ph/**\", ignoreBuildOutputButPieces(root)] },\n },\n appType: \"custom\",\n // Its own cache, and no client deps to optimize: Studio's cache is the\n // project's node_modules/.vite, which it would otherwise rewrite.\n cacheDir: path.join(root, \"node_modules\", \".vite-reactor\"),\n optimizeDeps: { noDiscovery: true, include: [], entries: [] },\n build: {\n rollupOptions: {\n input: [],\n },\n },\n resolve: {\n tsconfigPaths: true,\n alias: {\n [packageJson.name]: root,\n },\n },\n plugins: [\n // cast: the plugin ships types built against an older vite, and the\n // mismatched Plugin type crashes tsc 6 during assignability checking\n viteCommonjs() as PluginOption,\n {\n name: \"suppress-hmr\",\n handleHotUpdate() {\n return []; // return empty array to suppress server refresh\n },\n },\n ],\n });\n\n return vite;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAwCA,SAAgB,iBAAiB,QAAiB,SAAS,IAAI;CAC7D,MAAM,eAAe,aAAa,QAAQ,EACxC,OACF,CAAC;CAeD,aAAa,QAAQ,QAAQ,OAAO,KAAK,SAAS,GAAG;CACrD,aAAa,QAAQ,QAAQ,OAAO,KAAK,SAAS,GAAG;CACrD,aAAa,SAAS,KAAK,YACzB,SAAS,QACL,OAAO,MAAM,SAAS,KAAK,QAAQ,KAAK,IACxC,OAAO,MAAM,SAAS,GAAG;CAC/B,OAAO;AACT;AAcA,MAAM,cAAc;CAAC;CAAU;CAAO;AAAQ;AAK9C,MAAM,6BAA6B;AAEnC,IAAa,oBAAb,MAAa,kBAAwD;CACnE,SAA0B,YAAY,CAAC,eAAe,aAAa,CAAC;CAEpE;CAEA;CAEA;CAIA,iCAA0B,IAAI,IAAmC;CAEjE,OAAgB;CAEhB,OAAO,MAAM,MAAqB,SAAoC;EACpE,OAAO,IAAI,kBAAkB,MAAM,OAAO;CAC5C;CAEA,YAAY,MAAqB,UAAoC,CAAC,GAAG;EACvE,KAAK,OAAO;EACZ,KAAK,YAAY,CAAC,GAAI,QAAQ,eAAe,CAAC,GAAI,YAAY,GAAG,CAAC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,CAAC;AAGH","debug_id":"965b1ab0-1682-52b9-bfc8-96818d4e2a14"}
@@ -0,0 +1,434 @@
1
+ import { n as PGLITE_UTC_PARSERS, t as PGliteLike } from "../../pglite-like-CKQEL_Q0.mjs";
2
+ import { ILogger } from "document-model";
3
+ import { IStoreMaintenance, TableRewriteRequest, TableRewriteResult, WorkerMemorySample } from "@powerhousedao/reactor";
4
+ import nodeFs from "node:fs";
5
+ import { PGlite, QueryOptions, Results } from "@electric-sql/pglite";
6
+ import { NodeFS } from "@electric-sql/pglite/nodefs";
7
+ import { ResourceLimits } from "node:worker_threads";
8
+ //#region src/pglite/maintenance.d.ts
9
+ export declare const DEFAULT_MAINTENANCE_INTERVAL_MS: number;
10
+ export declare const DEFAULT_VACUUM_FULL_ABOVE_BYTES: number;
11
+ export declare const DEFAULT_VACUUM_FULL_QUIET_MS: number;
12
+ /**
13
+ * How long a pending VACUUM FULL waits for a quiet store before it runs
14
+ * anyway: by default it never does (0), because a forced rewrite of a large
15
+ * store under load holds the only connection for minutes, every caller times
16
+ * out, and the dir needs about twice its size in free space meanwhile.
17
+ * `PH_PGLITE_VACUUM_FULL=forced` restores a deadline.
18
+ */
19
+ export declare const DEFAULT_VACUUM_FULL_MAX_DEFER_MS = 0;
20
+ /** The deadline `PH_PGLITE_VACUUM_FULL=forced` sets. */
21
+ export declare const FORCED_VACUUM_FULL_MAX_DEFER_MS: number;
22
+ /**
23
+ * A table rewrite waits for this long a gap between the store's statements.
24
+ * Short, because PGlite syncs after every statement and an idle reactor still
25
+ * reads every 2 s (catch-up, sync polls), so a longer gap never comes.
26
+ */
27
+ export declare const DEFAULT_REWRITE_QUIET_MS = 1000;
28
+ /** How long a table rewrite waits for that gap before it reports the store busy. */
29
+ export declare const DEFAULT_REWRITE_MAX_WAIT_MS: number;
30
+ type MaintenanceOutcome = "vacuum" | "vacuum-full" | "idle" | "not-ready" | "in-transaction" | "failed";
31
+ interface MaintenanceLogger {
32
+ warn(message: string): void;
33
+ /** A finished VACUUM FULL is reported here; `warn` when absent. */
34
+ info?(message: string): void;
35
+ }
36
+ /** Runs a maintenance pass in the owner's turn; see {@link MaintenanceOptions.gate}. */
37
+ type MaintenanceGate = <T>(task: () => Promise<T>) => Promise<T>;
38
+ interface MaintenanceOptions {
39
+ /** VACUUM + CHECKPOINT cadence; PGlite has no autovacuum. Default 5 min; 0 disables. */
40
+ intervalMs?: number;
41
+ /** First pass runs VACUUM FULL when `base/` exceeds this at open. Default 256 MB; 0 disables. */
42
+ vacuumFullAboveBytes?: number;
43
+ /**
44
+ * VACUUM FULL holds the store for minutes on a large dir, so it waits for a
45
+ * store with no synced statement (no write, no catch-up) for this long,
46
+ * counted from open; until then a pass runs plain VACUUM and keeps the
47
+ * VACUUM FULL pending. Default 60 s; 0 runs it on the first pass.
48
+ */
49
+ vacuumFullQuietMs?: number;
50
+ /**
51
+ * The longest a pending VACUUM FULL waits for that quiet window, counted
52
+ * from open; past it the next pass runs VACUUM FULL anyway. Default 0,
53
+ * which waits for the quiet window however long it takes.
54
+ */
55
+ vacuumFullMaxDeferMs?: number;
56
+ /**
57
+ * Queues each pass with the store's other work, e.g. behind a worker's
58
+ * pending requests, so a pass never starts ahead of a statement already
59
+ * admitted. A pass still waiting here when the store closes is skipped.
60
+ */
61
+ gate?: MaintenanceGate;
62
+ logger?: MaintenanceLogger;
63
+ /** Clock for the quiet window; tests pass their own. */
64
+ now?: () => number;
65
+ /** The gap between statements a table rewrite waits for. Default 1 s. */
66
+ rewriteQuietMs?: number;
67
+ /** How long a table rewrite waits for that gap. Default 15 min. */
68
+ rewriteMaxWaitMs?: number;
69
+ }
70
+ export declare class PgliteMaintenance implements IStoreMaintenance {
71
+ private readonly intervalMs;
72
+ private readonly vacuumFullAboveBytes;
73
+ private readonly vacuumFullQuietMs;
74
+ private readonly vacuumFullMaxDeferMs;
75
+ private readonly gate?;
76
+ private readonly logger?;
77
+ private readonly now;
78
+ private readonly rewriteQuietMs;
79
+ private readonly rewriteMaxWaitMs;
80
+ private pg?;
81
+ private label;
82
+ private closing;
83
+ private syncsSinceMaintenance;
84
+ private vacuumFullPending;
85
+ private timer?;
86
+ private inFlight?;
87
+ private active;
88
+ private deferralLogged;
89
+ private lastSyncAt;
90
+ private openedAt;
91
+ private rewriting?;
92
+ constructor(options?: MaintenanceOptions);
93
+ get scheduled(): boolean;
94
+ get running(): boolean;
95
+ start(pg: PGlite, label: string, baseBytes: number): void;
96
+ noteSync(): void;
97
+ /** Waits for a pass that has started; one still queued at the gate is left to skip itself. */
98
+ stop(): Promise<void>;
99
+ run(): Promise<MaintenanceOutcome>;
100
+ /**
101
+ * Rewrites one table with VACUUM FULL and a CHECKPOINT, in the turn of the
102
+ * store's other work, never the whole store. Waits for a gap in the store's
103
+ * statements first; nothing else runs on it while the table is rewritten.
104
+ */
105
+ rewriteTable(request: TableRewriteRequest): Promise<TableRewriteResult>;
106
+ private runNow;
107
+ private pass;
108
+ /** Undefined when a transaction is open, so the caller waits and tries again. */
109
+ private rewriteNow;
110
+ /** Why the disk cannot hold the rewrite; undefined when it can or nobody can tell. */
111
+ private diskShortage;
112
+ private schedule;
113
+ private cancel;
114
+ }
115
+ /** The maintenance of a store opened on DurableNodeFs; undefined for any other. */
116
+ export declare function maintenanceOf(store: {
117
+ fs?: unknown;
118
+ }): PgliteMaintenance | undefined;
119
+ //#endregion
120
+ //#region src/pglite/durable-node-fs.d.ts
121
+ type NodeFsClass = typeof NodeFS;
122
+ interface DurableNodeFsOptions {
123
+ /** Default true; `PH_PGLITE_FSYNC=0` turns it off (power-loss durability off). */
124
+ fsync?: boolean;
125
+ /** Default 5 min; 0 disables. */
126
+ maintenanceIntervalMs?: number;
127
+ /** `base/` size at open; default 256 MB; 0 disables. */
128
+ vacuumFullAboveBytes?: number;
129
+ /** See `MaintenanceOptions.vacuumFullQuietMs`; default 60 s. */
130
+ vacuumFullQuietMs?: number;
131
+ /** See `MaintenanceOptions.vacuumFullMaxDeferMs`; default 0 (quiet window only). */
132
+ vacuumFullMaxDeferMs?: number;
133
+ /** See `MaintenanceOptions.gate`. */
134
+ maintenanceGate?: MaintenanceGate;
135
+ /** The gap between statements a table rewrite waits for. Default 1 s. */
136
+ rewriteQuietMs?: number;
137
+ /** How long a table rewrite waits for that gap. Default 15 min. */
138
+ rewriteMaxWaitMs?: number;
139
+ /** Clock for the maintenance quiet window; tests pass their own. */
140
+ now?: () => number;
141
+ logger?: {
142
+ warn(message: string): void;
143
+ info?(message: string): void;
144
+ };
145
+ /** Emscripten abort (a Postgres PANIC, e.g. ENOSPC on WAL). */
146
+ onAbort?: (what: unknown) => void;
147
+ hostFs?: Pick<typeof nodeFs, "fsyncSync" | "fdatasyncSync">;
148
+ }
149
+ type DurableNodeFs = InstanceType<NodeFsClass> & {
150
+ readonly maintenance: PgliteMaintenance;
151
+ };
152
+ export declare function resolvePgliteFsync(env: Record<string, string | undefined>): boolean;
153
+ /** `PH_PGLITE_VACUUM_FULL`: when an oversized store's one-time VACUUM FULL may run. */
154
+ type PgliteVacuumFullMode = "off" | "quiet" | "forced";
155
+ /** The VACUUM FULL settings an environment selects; see {@link resolvePgliteMaintenance}. */
156
+ type PgliteMaintenanceSettings = Pick<DurableNodeFsOptions, "vacuumFullAboveBytes" | "vacuumFullQuietMs" | "vacuumFullMaxDeferMs">;
157
+ /**
158
+ * Reads the VACUUM FULL knobs. `PH_PGLITE_VACUUM_FULL` is `off` (the
159
+ * default: never), `quiet` (only after the quiet window, however long that
160
+ * takes) or `forced` (a deadline of 30 min from open, after which it runs
161
+ * under load). Off is the default because a full rewrite of a large store
162
+ * needs about twice its size in free disk and holds the only connection for
163
+ * minutes, and on a store that is live data rather than bloat it reclaims
164
+ * nothing; a quiet window of a minute arrives naturally between jobs, so
165
+ * `quiet` is an opt-in for stores known to be small or bloated.
166
+ * `PH_PGLITE_VACUUM_FULL_ABOVE_MB` sets the size that makes a store
167
+ * eligible; `PH_PGLITE_VACUUM_FULL_QUIET_MS` and
168
+ * `PH_PGLITE_VACUUM_FULL_MAX_DEFER_MS` override the mode's timings. A value
169
+ * that is not a non-negative number is left to the default; an unknown mode
170
+ * throws, since silently running a rewrite is what this guards against.
171
+ */
172
+ export declare function resolvePgliteMaintenance(env: Record<string, string | undefined>): PgliteMaintenanceSettings;
173
+ /** Built over the passed-in class so PG16 dirs on `pglite-legacy-02` get the same behaviour. */
174
+ export declare function createDurableNodeFs(Base: NodeFsClass, dataDir: string, options?: DurableNodeFsOptions): DurableNodeFs;
175
+ //#endregion
176
+ //#region src/pglite/sync-tree.d.ts
177
+ interface SyncTreeHostFs {
178
+ fsyncSync(fd: number): void;
179
+ }
180
+ interface SyncTreeResult {
181
+ files: number;
182
+ dirs: number;
183
+ }
184
+ /** One pass over a finished tree; interleaving fsync with writes costs seconds. */
185
+ export declare function syncTree(root: string, hostFs?: SyncTreeHostFs): SyncTreeResult;
186
+ /** fsyncs a directory's entries; false where the platform refuses (Windows). */
187
+ export declare function syncDirectory(dir: string, hostFs?: SyncTreeHostFs): boolean;
188
+ //#endregion
189
+ //#region src/pglite/snapshot-reader.d.ts
190
+ export declare const SNAPSHOT_FILE_NAME = "snapshot.bin";
191
+ interface ExtractSnapshotOptions {
192
+ chunkSize?: number;
193
+ /** Default true: one fsync pass over the tree after the last write. */
194
+ sync?: boolean;
195
+ hostFs?: SyncTreeHostFs;
196
+ }
197
+ interface ExtractedSnapshot {
198
+ pgVersionMajor: number;
199
+ /** `global/pg_control` bytes; absent only in synthetic trees. */
200
+ pgControl?: Buffer;
201
+ /** Entries written to disk; skipped entries are not counted. */
202
+ entries: number;
203
+ /** Size of the snapshot file. */
204
+ bytes: number;
205
+ }
206
+ /** Unpacks a snapshot into the existing `outDir`. */
207
+ export declare function extractSnapshot(snapshotPath: string, outDir: string, options?: ExtractSnapshotOptions): Promise<ExtractedSnapshot>;
208
+ //#endregion
209
+ //#region src/pglite/convert-snapshot-dir.d.ts
210
+ interface VerifyHandle {
211
+ query<T>(sql: string): Promise<{
212
+ rows: T[];
213
+ }>;
214
+ close(): Promise<void>;
215
+ }
216
+ type ConversionStep = "extract" | "verify" | "renameOld" | "renameNew" | "removeOld";
217
+ interface ConversionDeps {
218
+ /** Opens `dataDir` with the stock NodeFS of the PGlite module for `major`. */
219
+ openForVerify: (major: number, dataDir: string) => Promise<VerifyHandle>;
220
+ logger: ILogger;
221
+ /** Test hook: throw after a named step to simulate a crash there. */
222
+ afterStep?: (step: ConversionStep) => void | Promise<void>;
223
+ hostFs?: SyncTreeHostFs;
224
+ }
225
+ /** Settles the debris of an interrupted conversion; runs before it at boot. */
226
+ export declare function recoverConversion(dir: string, deps: ConversionDeps): Promise<void>;
227
+ /** Extracts into `.converting`, verifies by opening it, swaps through `.old`. */
228
+ export declare function convertSnapshotDir(dir: string, deps: ConversionDeps): Promise<"converted" | "none">;
229
+ //#endregion
230
+ //#region src/pglite/preflight.d.ts
231
+ /** PG major of the pinned @electric-sql/pglite; it exports none, so the test checks initdb. */
232
+ export declare const CURRENT_PGLITE_MAJOR = 17;
233
+ /** `openForVerify` over the loaded PGlite module only. */
234
+ export declare function openCurrentPgliteForVerify(major: number, dataDir: string): Promise<VerifyHandle>;
235
+ /** Converts a snapshot store and clears the files a previous run leaves behind. */
236
+ export declare function preparePgliteDataDir(dir: string, deps: ConversionDeps): Promise<void>;
237
+ /** PGlite leaves `postmaster.pid` after every close and `pg_wal/xlogtemp.*` after some. */
238
+ export declare function removeStalePgliteFiles(dir: string, logger: Pick<ILogger, "debug">): Promise<void>;
239
+ //#endregion
240
+ //#region src/pglite/wasm-wrapper-tiering.d.ts
241
+ export declare const WASM_WRAPPER_TIERING_FLAG = "--wasm-wrapper-tiering-budget=1000000000";
242
+ /** Node 24 V8 double-frees tiered wasm wrappers as instances die (#66366). */
243
+ export declare function disableWasmWrapperTiering(): boolean;
244
+ //#endregion
245
+ //#region src/pglite/worker/protocol.d.ts
246
+ /**
247
+ * Wire protocol between a {@link ThreadedPGlite} stand-in on the main thread
248
+ * and the worker thread that owns one PGlite store.
249
+ *
250
+ * Every payload is structured-cloned, so it holds data only: functions such as
251
+ * row parsers are named by preset and built inside the worker.
252
+ */
253
+ /** Module specifiers the worker imports PGlite and its NodeFS from. */
254
+ type PGliteModuleSpec = {
255
+ /** Specifier or file URL of the PGlite package entry, e.g. `@electric-sql/pglite`. */
256
+ pglite: string;
257
+ /** Specifier or file URL of the matching NodeFS entry, e.g. `@electric-sql/pglite/nodefs`. */
258
+ nodefs: string;
259
+ };
260
+ export declare const CURRENT_PGLITE_MODULE: PGliteModuleSpec;
261
+ /** Row parser sets the worker knows how to build. */
262
+ type PGliteParserPreset = "none" | "utc-timestamps";
263
+ /** DurableNodeFs settings; see `DurableNodeFsOptions`. */
264
+ type PGliteWorkerDurableFsOptions = {
265
+ fsync: boolean;
266
+ /** Undefined keeps the DurableNodeFs default (5 min); 0 disables. */
267
+ maintenanceIntervalMs?: number;
268
+ /** Undefined keeps the DurableNodeFs default (256 MB); 0 disables. */
269
+ vacuumFullAboveBytes?: number;
270
+ /** Undefined keeps the DurableNodeFs default (60 s); 0 runs VACUUM FULL on the first pass. */
271
+ vacuumFullQuietMs?: number;
272
+ /** Undefined keeps the DurableNodeFs default (0: the quiet window only); a deadline in ms forces the run past it. */
273
+ vacuumFullMaxDeferMs?: number;
274
+ /** Undefined keeps the DurableNodeFs default (1 s). */
275
+ rewriteQuietMs?: number;
276
+ };
277
+ /** What the worker opens. */
278
+ type PGliteWorkerStoreOptions = {
279
+ /** Names the store in logs and errors, e.g. `read-storage`. */
280
+ label: string;
281
+ /** PGlite data dir; null opens an in-memory store. */
282
+ dataDir: string | null;
283
+ module: PGliteModuleSpec;
284
+ /** DurableNodeFs over `dataDir`; null uses the module's stock NodeFS. Ignored in memory. */
285
+ durableFs: PGliteWorkerDurableFsOptions | null;
286
+ parsers: PGliteParserPreset;
287
+ };
288
+ type PGliteErrorInfo = {
289
+ name: string;
290
+ message: string;
291
+ stack?: string;
292
+ cause?: PGliteErrorInfo;
293
+ /** Postgres error fields, copied when present. */
294
+ fields: Record<string, string>;
295
+ };
296
+ //#endregion
297
+ //#region src/pglite/worker/error-info.d.ts
298
+ /** Flattens an error and its cause chain into a structured-clonable shape. */
299
+ export declare function toPGliteErrorInfo(err: unknown, depth?: number): PGliteErrorInfo;
300
+ /** Rebuilds an `Error` carrying the original name, stack, Postgres fields and cause chain. */
301
+ export declare function fromPGliteErrorInfo(info: PGliteErrorInfo): Error;
302
+ //#endregion
303
+ //#region src/pglite/worker/errors.d.ts
304
+ /** Base class for failures of the worker itself, as opposed to SQL errors. */
305
+ export declare class PGliteWorkerError extends Error {
306
+ readonly label: string;
307
+ constructor(label: string, message: string, options?: {
308
+ cause?: unknown;
309
+ });
310
+ }
311
+ /** The worker could not open its store; every call on the stand-in fails with this. */
312
+ export declare class PGliteWorkerInitError extends PGliteWorkerError {
313
+ constructor(label: string, options?: {
314
+ cause?: unknown;
315
+ });
316
+ }
317
+ /** The worker thread exited (crash, terminate, out of memory) before answering. */
318
+ export declare class PGliteWorkerExitedError extends PGliteWorkerError {
319
+ readonly exitCode: number;
320
+ constructor(label: string, exitCode: number, options?: {
321
+ cause?: unknown;
322
+ });
323
+ }
324
+ /** A call was made after `close()` started. */
325
+ export declare class PGliteWorkerClosedError extends PGliteWorkerError {
326
+ constructor(label: string);
327
+ }
328
+ //#endregion
329
+ //#region src/pglite/worker/threaded-pglite.d.ts
330
+ export declare const DEFAULT_PGLITE_WORKER_MEMORY_MB = 1024;
331
+ export declare const DEFAULT_PGLITE_WORKER_CLOSE_GRACE_MS = 60000;
332
+ type ThreadedPGliteOptions = {
333
+ store: PGliteWorkerStoreOptions;
334
+ /** Caps the worker's JS heap; defaults to {@link resolvePgliteWorkerMemoryMb}. WebAssembly memory is outside it. */
335
+ memoryLimitMb?: number;
336
+ /** The worker script; defaults to the built entry next to this module. Tests pass a tsx bootstrap. */
337
+ workerScript?: string | URL;
338
+ /** Bound on PGlite's own close (its shutdown checkpoint) before the thread is terminated. */
339
+ closeGraceMs?: number;
340
+ logger?: ILogger;
341
+ };
342
+ /** Called once, when the worker reports that the wasm runtime aborted. */
343
+ type PGliteAbortListener = (reason: string) => void;
344
+ /** Called once, when the worker thread is gone; `error` is null after a clean close. */
345
+ type PGliteExitListener = (error: Error | null) => void;
346
+ /** `PH_PGLITE_WORKER_MEMORY_MB`, else {@link DEFAULT_PGLITE_WORKER_MEMORY_MB}. */
347
+ export declare function resolvePgliteWorkerMemoryMb(env: Record<string, string | undefined>): number;
348
+ /**
349
+ * Main-thread stand-in for a PGlite instance whose store lives in a worker
350
+ * thread. It has the surface knex-pglite, kysely-pglite-dialect and
351
+ * `HardenedPGliteDialect` use: `waitReady`, `query`, `exec`, a synchronous
352
+ * `isInTransaction()`, `closed` and `close()`.
353
+ *
354
+ * Construction is synchronous and starts the worker; calls made before the
355
+ * worker is ready are queued behind its open. The worker runs requests one at
356
+ * a time in arrival order, and every answer carries the transaction status.
357
+ * The instance is a plain extensible object, since knex stores its own
358
+ * bookkeeping on the connection.
359
+ */
360
+ export declare class ThreadedPGlite implements PGliteLike, IStoreMaintenance {
361
+ readonly label: string;
362
+ /** Settles once the worker has opened the store; rejects with {@link PGliteWorkerInitError}. */
363
+ readonly waitReady: Promise<void>;
364
+ private readonly worker;
365
+ private readonly logger;
366
+ private readonly closeGraceMs;
367
+ private readonly pending;
368
+ /** The reservation an `admit` run is executing under, carried through its async calls. */
369
+ private readonly admission;
370
+ private readonly abortListeners;
371
+ private readonly exitListeners;
372
+ private nextId;
373
+ private phase;
374
+ private inTransaction;
375
+ private terminalError;
376
+ private workerError;
377
+ private abortReason;
378
+ private closePromise;
379
+ private readonly forgetTelemetry;
380
+ constructor(options: ThreadedPGliteOptions);
381
+ /** JS heap of the worker and the WASM linear memory, which only grows. */
382
+ memoryStats(): Promise<WorkerMemorySample>;
383
+ /** True once the store is open and until close starts. */
384
+ get ready(): boolean;
385
+ /** True once close has started or the worker is gone. */
386
+ get closed(): boolean;
387
+ /** The reason the worker reported for a wasm abort, or null. */
388
+ get aborted(): string | null;
389
+ /** The limits the worker thread runs under (empty once it has exited). */
390
+ get resourceLimits(): ResourceLimits;
391
+ /** The worker's thread id, for diagnostics. */
392
+ get threadId(): number;
393
+ query<T = Record<string, unknown>>(sql: string, params?: unknown[], options?: QueryOptions): Promise<Results<T>>;
394
+ exec(sql: string, options?: QueryOptions): Promise<Results[]>;
395
+ /**
396
+ * `HardenedPGliteDialect`'s admission hook: `run` starts only once the worker
397
+ * can run its statements at once, with nothing queued ahead and no
398
+ * maintenance pass in progress, so the dialect's statement deadline (which
399
+ * starts inside `run`) never counts time spent waiting behind other work.
400
+ * Statements `run` issues bypass the queue until it settles; everything
401
+ * else waits behind them.
402
+ */
403
+ admit<T>(run: () => Promise<T>): Promise<T>;
404
+ /** Rewrites one table through the store's maintenance inside the worker. */
405
+ rewriteTable(request: TableRewriteRequest): Promise<TableRewriteResult>;
406
+ /** The status after the most recently answered request, as PGlite reported it. */
407
+ isInTransaction(): boolean;
408
+ /** Closes PGlite inside the worker (its shutdown checkpoint), then terminates the thread. */
409
+ close(): Promise<void>;
410
+ /** Stops the thread at once, without PGlite's close; pending calls reject. */
411
+ terminate(): Promise<void>;
412
+ onAbort(listener: PGliteAbortListener): () => void;
413
+ onExit(listener: PGliteExitListener): () => void;
414
+ private closeWorker;
415
+ private currentAdmission;
416
+ private release;
417
+ private request;
418
+ private handleMessage;
419
+ private settle;
420
+ private settleError;
421
+ private handleAbort;
422
+ private handleLog;
423
+ private handleWorkerError;
424
+ private handleExit;
425
+ /** Records a fatal error and stops the thread; the exit rejects what is pending. */
426
+ private fail;
427
+ private rejectPending;
428
+ }
429
+ /** Absolute path of the worker script for `new Worker(...)`; null when none can run here. */
430
+ export declare const pgliteWorkerEntryPath: string | null;
431
+ //#endregion
432
+ export { type ConversionDeps, type ConversionStep, type DurableNodeFs, type DurableNodeFsOptions, type ExtractSnapshotOptions, type ExtractedSnapshot, type MaintenanceGate, type MaintenanceLogger, type MaintenanceOptions, type MaintenanceOutcome, type NodeFsClass, PGLITE_UTC_PARSERS, type PGliteAbortListener, type PGliteErrorInfo, type PGliteExitListener, type PGliteLike, type PGliteModuleSpec, type PGliteParserPreset, type PGliteWorkerDurableFsOptions, type PGliteWorkerStoreOptions, type PgliteMaintenanceSettings, type PgliteVacuumFullMode, type SyncTreeHostFs, type SyncTreeResult, type ThreadedPGliteOptions, type VerifyHandle };
433
+ export {};
434
+ //# sourceMappingURL=pglite-node.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pglite-node.d.mts","names":[],"sources":["../../../src/pglite/maintenance.ts","../../../src/pglite/durable-node-fs.ts","../../../src/pglite/sync-tree.ts","../../../src/pglite/snapshot-reader.ts","../../../src/pglite/convert-snapshot-dir.ts","../../../src/pglite/preflight.ts","../../../src/pglite/wasm-wrapper-tiering.ts","../../../src/pglite/worker/protocol.ts","../../../src/pglite/worker/error-info.ts","../../../src/pglite/worker/errors.ts","../../../src/pglite/worker/threaded-pglite.ts"],"mappings":";;;;;;;;qBASa;qBACA;qBACA;;;;;;;;qBAQA;;qBAEA;;;;;;qBAOA;;qBAEA;KAGD;UAQK;EACf,KAAK;;EAEL,MAAM;;;KAII,mBAAmB,GAAG,YAAY,QAAQ,OAAO,QAAQ;UAEpD;;EAEf;;EAEA;;;;;;;EAOA;;;;;;EAMA;;;;;;EAMA,OAAO;EACP,SAAS;;EAET;;EAEA;;EAEA;;qBAGW,6BAA6B;mBACvB;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;mBACA;UAET;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;EAER,YAAY,UAAS;MAyBjB;MAIA;EAIJ,MAAM,IAAI,QAAQ,eAAe;EAUjC;;EAMM,QAAQ;EAOR,OAAO,QAAQ;;;;;;EAUf,aACJ,SAAS,sBACR,QAAQ;UAgCG;UASA;;UAqEA;;UAiDA;UAgBN;UAoBA;;;wBAiCM,cAAc;EAC5B;IACE;;;KCxYQ,qBAAqB;UAKhB;;EAEf;;EAEA;;EAEA;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BAA8B;EACzC,YAAY,eAAe;IAAY;;;;qBAW5B,gCAAgC;WAGhC;EAFX,YACE,eACS,kBACT;IAAY;;;;qBAYH,gCAAgC;EAC3C,YAAY;;;;qBCZD;qBACA;KAED;EACV,OAAO;;EAEP;;EAEA,wBAAwB;;EAExB;EACA,SAAS;;;KAIC,uBAAuB;;KAGvB,sBAAsB,OAAO;;wBAoBzB,4BACd,KAAK;;;;;;;;;;;;;qBA2BM,0BAA0B,YAAY;WACxC;;WAEA,WAAW;mBAEH;mBACA;mBACA;mBACA;;mBAEA;mBACA;mBACA;UACT;UACA;UACA;UACA;UACA;UACA;UACA;mBACS;EAEjB,YAAY,SAAS;;EAmDf,eAAe,QAAQ;;MASzB;;MAKA;;MAKA;;MAKA,kBAAkB;;MAKlB;EAIE,MAAM,IAAI,yBACd,aACA,oBACA,UAAU,eACT,QAAQ,QAAQ;EAab,KAAK,aAAa,UAAU,eAAe,QAAQ;;;;;;;;;EAoBnD,MAAM,GAAG,WAAW,QAAQ,KAAK,QAAQ;;EAc/C,aAAa,SAAS,sBAAsB,QAAQ;;EASpD;;EAKA,SAAS;;EAYH,aAAa;EAOnB,QAAQ,UAAU;EAOlB,OAAO,UAAU;UAOH;UAsCN;UAIA;UAQA;UAsBA;UA2CA;UAUA;UAUA;UAkBA;UAyBA;UAKA;;UA2BA;UAQA;;;qBAyFG"}
@@ -0,0 +1,5 @@
1
+ import { _ as PGLITE_UTC_PARSERS, a as resolvePgliteMaintenance, c as DEFAULT_MAINTENANCE_INTERVAL_MS, d as DEFAULT_VACUUM_FULL_ABOVE_BYTES, f as DEFAULT_VACUUM_FULL_MAX_DEFER_MS, g as maintenanceOf, h as PgliteMaintenance, i as resolvePgliteFsync, l as DEFAULT_REWRITE_MAX_WAIT_MS, m as FORCED_VACUUM_FULL_MAX_DEFER_MS, n as toPGliteErrorInfo, o as syncDirectory, p as DEFAULT_VACUUM_FULL_QUIET_MS, r as createDurableNodeFs, s as syncTree, t as fromPGliteErrorInfo, u as DEFAULT_REWRITE_QUIET_MS } from "../../error-info-Cr6oQACe.mjs";
2
+ import { _ as convertSnapshotDir, a as resolvePgliteWorkerMemoryMb, b as extractSnapshot, c as PGliteWorkerError, d as WASM_WRAPPER_TIERING_FLAG, f as disableWasmWrapperTiering, g as removeStalePgliteFiles, h as preparePgliteDataDir, i as pgliteWorkerEntryPath, l as PGliteWorkerExitedError, m as openCurrentPgliteForVerify, n as DEFAULT_PGLITE_WORKER_MEMORY_MB, o as CURRENT_PGLITE_MODULE, p as CURRENT_PGLITE_MAJOR, r as ThreadedPGlite, s as PGliteWorkerClosedError, t as DEFAULT_PGLITE_WORKER_CLOSE_GRACE_MS, u as PGliteWorkerInitError, v as recoverConversion, y as SNAPSHOT_FILE_NAME } from "../../pglite-node-CcX2YT-l.mjs";
3
+ export { CURRENT_PGLITE_MAJOR, CURRENT_PGLITE_MODULE, DEFAULT_MAINTENANCE_INTERVAL_MS, DEFAULT_PGLITE_WORKER_CLOSE_GRACE_MS, DEFAULT_PGLITE_WORKER_MEMORY_MB, DEFAULT_REWRITE_MAX_WAIT_MS, DEFAULT_REWRITE_QUIET_MS, DEFAULT_VACUUM_FULL_ABOVE_BYTES, DEFAULT_VACUUM_FULL_MAX_DEFER_MS, DEFAULT_VACUUM_FULL_QUIET_MS, FORCED_VACUUM_FULL_MAX_DEFER_MS, PGLITE_UTC_PARSERS, PGliteWorkerClosedError, PGliteWorkerError, PGliteWorkerExitedError, PGliteWorkerInitError, PgliteMaintenance, SNAPSHOT_FILE_NAME, ThreadedPGlite, WASM_WRAPPER_TIERING_FLAG, convertSnapshotDir, createDurableNodeFs, disableWasmWrapperTiering, extractSnapshot, fromPGliteErrorInfo, maintenanceOf, openCurrentPgliteForVerify, pgliteWorkerEntryPath, preparePgliteDataDir, recoverConversion, removeStalePgliteFiles, resolvePgliteFsync, resolvePgliteMaintenance, resolvePgliteWorkerMemoryMb, syncDirectory, syncTree, toPGliteErrorInfo };
4
+ !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]="afdaa565-b941-5b93-a8c8-f1f4270baa52")}catch(e){}}();
5
+ //# debugId=afdaa565-b941-5b93-a8c8-f1f4270baa52
@@ -0,0 +1,2 @@
1
+ export {}
2
+ export {};