@pgxsinkit/pgwasm-c 0.5.0

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 (85) hide show
  1. package/LICENSE +23 -0
  2. package/NOTICE +1890 -0
  3. package/README.md +79 -0
  4. package/artefacts/amcheck.tar.gz +0 -0
  5. package/artefacts/initdb.d.ts +6 -0
  6. package/artefacts/initdb.js +2 -0
  7. package/artefacts/initdb.wasm +0 -0
  8. package/artefacts/postgres.d.ts +6 -0
  9. package/artefacts/postgres.data +37595 -8
  10. package/artefacts/postgres.js +2 -0
  11. package/artefacts/postgres.wasm +0 -0
  12. package/artefacts/prepopulated.tar.gz +0 -0
  13. package/dist/artefact-pins.d.ts +57 -0
  14. package/dist/artefact-pins.d.ts.map +1 -0
  15. package/dist/artefacts.d.ts +37 -0
  16. package/dist/artefacts.d.ts.map +1 -0
  17. package/dist/build.d.ts +53 -0
  18. package/dist/build.d.ts.map +1 -0
  19. package/dist/contrib/amcheck.d.ts +9 -0
  20. package/dist/contrib/amcheck.d.ts.map +1 -0
  21. package/dist/contrib/amcheck.js +13 -0
  22. package/dist/contrib/amcheck.js.map +10 -0
  23. package/dist/host/artefact-loader.d.ts +9 -0
  24. package/dist/host/artefact-loader.d.ts.map +1 -0
  25. package/dist/host/command-line.d.ts +11 -0
  26. package/dist/host/command-line.d.ts.map +1 -0
  27. package/dist/host/data-dir.d.ts +11 -0
  28. package/dist/host/data-dir.d.ts.map +1 -0
  29. package/dist/host/emscripten.d.ts +143 -0
  30. package/dist/host/emscripten.d.ts.map +1 -0
  31. package/dist/host/exit-code.d.ts +12 -0
  32. package/dist/host/exit-code.d.ts.map +1 -0
  33. package/dist/host/extensions.d.ts +15 -0
  34. package/dist/host/extensions.d.ts.map +1 -0
  35. package/dist/host/initdb.d.ts +25 -0
  36. package/dist/host/initdb.d.ts.map +1 -0
  37. package/dist/host/mounts/file.d.ts +17 -0
  38. package/dist/host/mounts/file.d.ts.map +1 -0
  39. package/dist/host/mounts/idb.d.ts +32 -0
  40. package/dist/host/mounts/idb.d.ts.map +1 -0
  41. package/dist/host/mounts/index.d.ts +6 -0
  42. package/dist/host/mounts/index.d.ts.map +1 -0
  43. package/dist/host/mounts/memory.d.ts +12 -0
  44. package/dist/host/mounts/memory.d.ts.map +1 -0
  45. package/dist/host/mounts/storage-mount.d.ts +15 -0
  46. package/dist/host/mounts/storage-mount.d.ts.map +1 -0
  47. package/dist/host/mounts/vfs.d.ts +15 -0
  48. package/dist/host/mounts/vfs.d.ts.map +1 -0
  49. package/dist/host/paths.d.ts +10 -0
  50. package/dist/host/paths.d.ts.map +1 -0
  51. package/dist/host/postgres-instance.d.ts +63 -0
  52. package/dist/host/postgres-instance.d.ts.map +1 -0
  53. package/dist/host/vfs-mount.d.ts +10 -0
  54. package/dist/host/vfs-mount.d.ts.map +1 -0
  55. package/dist/index.d.ts +4 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +1393 -0
  58. package/dist/index.js.map +26 -0
  59. package/dist/prepopulated.d.ts +28 -0
  60. package/dist/prepopulated.d.ts.map +1 -0
  61. package/dist/prepopulated.js +15 -0
  62. package/dist/prepopulated.js.map +10 -0
  63. package/package.json +56 -0
  64. package/src/artefact-pins.ts +36 -0
  65. package/src/artefacts.ts +46 -0
  66. package/src/build.ts +326 -0
  67. package/src/contrib/amcheck.ts +17 -0
  68. package/src/host/artefact-loader.ts +75 -0
  69. package/src/host/command-line.ts +64 -0
  70. package/src/host/data-dir.ts +70 -0
  71. package/src/host/emscripten.ts +158 -0
  72. package/src/host/exit-code.ts +29 -0
  73. package/src/host/extensions.ts +83 -0
  74. package/src/host/initdb.ts +180 -0
  75. package/src/host/mounts/file.ts +44 -0
  76. package/src/host/mounts/idb.ts +152 -0
  77. package/src/host/mounts/index.ts +26 -0
  78. package/src/host/mounts/memory.ts +22 -0
  79. package/src/host/mounts/storage-mount.ts +15 -0
  80. package/src/host/mounts/vfs.ts +43 -0
  81. package/src/host/paths.ts +18 -0
  82. package/src/host/postgres-instance.ts +495 -0
  83. package/src/host/vfs-mount.ts +258 -0
  84. package/src/index.ts +3 -0
  85. package/src/prepopulated.ts +38 -0
Binary file
Binary file
@@ -0,0 +1,57 @@
1
+ /**
2
+ * The C build's artefacts, pinned by release and checksum (ADR-0062 decision 9, ADR-0064).
3
+ *
4
+ * Written by `bun run pgwasm:pin <tag>`; never edit it by hand. The files are the assets of one
5
+ * pgxsinkit/pgwasm-postgres GitHub release, built from PostgreSQL plus patches derived from ElectricSQL's
6
+ * postgres-pglite (PostgreSQL License). They are not in git: `scripts/pgwasm-artefacts.ts` (the root
7
+ * `postinstall`) downloads each asset into `packages/pgwasm-c/artefacts/` and checks it against its bytes
8
+ * and sha256 below. The published package carries the files themselves. `C_BUILD_IDENTITY` takes its
9
+ * `release` and `dataFormat` from `ARTEFACT_RELEASE`.
10
+ */
11
+ /** The release the files are assets of. */
12
+ export declare const ARTEFACT_RELEASE: {
13
+ readonly repository: "pgxsinkit/pgwasm-postgres";
14
+ readonly tag: "18.6.2";
15
+ readonly name: "pgwasm-postgres 18.6.2";
16
+ readonly commit: "bf7938ad6acd51e1f68a9cb14fee9fea879a3b48";
17
+ readonly upstream: {
18
+ readonly tag: "REL_18_6";
19
+ readonly commit: "724edf9bde9d356724ad384a2e196edc3c9f80f7";
20
+ };
21
+ readonly dataFormat: 1;
22
+ readonly builderImage: "ghcr.io/pgxsinkit/pgwasm-builder@sha256:0c4d5255c5f1824216d1eb347cc231a6f881574c3d5b8172796a8cbe5f9f63c8";
23
+ readonly manifestSha256: "571b72a31003f89510f1bcbb37b5f70c142a5271cfdf24b7229423f9975d621d";
24
+ };
25
+ /** Every pinned file, by its name in `artefacts/` (the release asset of the same name). */
26
+ export declare const ARTEFACT_FILES: {
27
+ readonly "amcheck.tar.gz": {
28
+ readonly bytes: 21850;
29
+ readonly sha256: "6151f1f4ff507dd4401dc3dff9e5ad769727c2eb3d510e9fe75329bf52667c3f";
30
+ };
31
+ readonly "initdb.js": {
32
+ readonly bytes: 106390;
33
+ readonly sha256: "a402bd734fda0faf36696b68324471f853d52bd248ab8219893a6344386f6fac";
34
+ };
35
+ readonly "initdb.wasm": {
36
+ readonly bytes: 298938;
37
+ readonly sha256: "0fdc9cb46e2efe6dc1fc957c47c0c7364022c98d327eb8072af3f7fb75237d3e";
38
+ };
39
+ readonly "postgres.data": {
40
+ readonly bytes: 6246509;
41
+ readonly sha256: "012a2ed052fc0a05d50b9920afb5cb1692b3fbf9e09d486da61e4a59bb8f249a";
42
+ };
43
+ readonly "postgres.js": {
44
+ readonly bytes: 335115;
45
+ readonly sha256: "1bfb5740bd836121c0444d058593bbc7fa0de625596214a8e4805414191a23b2";
46
+ };
47
+ readonly "postgres.wasm": {
48
+ readonly bytes: 9140085;
49
+ readonly sha256: "f2d217be96e05dd01c02a6b62e89110d3658ac5be6032fe1d28effc9348b15ac";
50
+ };
51
+ readonly "prepopulated.tar.gz": {
52
+ readonly bytes: 4404457;
53
+ readonly sha256: "f5228a3690329edf675f630bedad6a4f6196f40c277f34aec3ac4d1ee426e0b3";
54
+ };
55
+ };
56
+ export type ArtefactName = keyof typeof ARTEFACT_FILES;
57
+ //# sourceMappingURL=artefact-pins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artefact-pins.d.ts","sourceRoot":"","sources":["../src/artefact-pins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,2CAA2C;AAC3C,eAAO,MAAM,gBAAgB;aAC3B,UAAU,EAAE,2BAA2B;aACvC,GAAG,EAAE,QAAQ;aACb,IAAI,EAAE,wBAAwB;aAC9B,MAAM,EAAE,0CAA0C;aAClD,QAAQ;iBAAI,GAAG,EAAE,UAAU;iBAAE,MAAM,EAAE,0CAA0C;;aAC/E,UAAU,EAAE,CAAC;aACb,YAAY,EACV,0GAA0G;aAC5G,cAAc,EAAE,kEAAkE;CAC1E,CAAC;AAEX,2FAA2F;AAC3F,eAAO,MAAM,cAAc;aACzB,gBAAgB;iBAAI,KAAK,EAAE,KAAK;iBAAE,MAAM,EAAE,kEAAkE;;aAC5G,WAAW;iBAAI,KAAK,EAAE,MAAM;iBAAE,MAAM,EAAE,kEAAkE;;aACxG,aAAa;iBAAI,KAAK,EAAE,MAAM;iBAAE,MAAM,EAAE,kEAAkE;;aAC1G,eAAe;iBAAI,KAAK,EAAE,OAAO;iBAAE,MAAM,EAAE,kEAAkE;;aAC7G,aAAa;iBAAI,KAAK,EAAE,MAAM;iBAAE,MAAM,EAAE,kEAAkE;;aAC1G,eAAe;iBAAI,KAAK,EAAE,OAAO;iBAAE,MAAM,EAAE,kEAAkE;;aAC7G,qBAAqB;iBAAI,KAAK,EAAE,OAAO;iBAAE,MAAM,EAAE,kEAAkE;;CAC3G,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,MAAM,OAAO,cAAc,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The C build's artefacts, referenced relative to this module so bundlers copy and fingerprint them.
3
+ *
4
+ * This is the ONLY module at `src/`'s depth that names `../artefacts/`: Bun.build rewrites neither a
5
+ * relative external import nor `new URL("…", import.meta.url)` when it bundles a module into a
6
+ * shallower output, and this file is bundled into `dist/index.js`, one level below the package root
7
+ * like itself (tests/unit/pgwasm-c-artefacts.test.ts enforces the rule). Each `new URL` stays a literal
8
+ * so bundlers can see it.
9
+ */
10
+ import createInitdbModule from "../artefacts/initdb.js";
11
+ import createPostgresModule from "../artefacts/postgres.js";
12
+ /** The URLs of the files the C build loads, for fetching and compiling them ahead of a boot. */
13
+ export declare const cBuildArtefacts: {
14
+ /** The Postgres WebAssembly module. */
15
+ readonly postgresWasm: URL;
16
+ /** The filesystem bundle (share/, lib/, the ICU data) the Postgres module mounts. */
17
+ readonly fsBundle: URL;
18
+ /** The initdb WebAssembly module, used when a data directory is created. */
19
+ readonly initdbWasm: URL;
20
+ };
21
+ /**
22
+ * @internal One C build's artefacts as the host runs them: the two Emscripten glue factories, the files
23
+ * they load, and the size of the filesystem bundle the Postgres glue was packaged with. The pinned build's
24
+ * are {@link pinnedCBuildArtefacts}; the IndexedDB browser lane assembles an earlier release's from its own
25
+ * files, to open stores that release wrote (the build seam stays one implementation).
26
+ */
27
+ export interface CBuildArtefactSet {
28
+ readonly createPostgresModule: typeof createPostgresModule;
29
+ readonly createInitdbModule: typeof createInitdbModule;
30
+ readonly postgresWasm: URL;
31
+ readonly fsBundle: URL;
32
+ readonly initdbWasm: URL;
33
+ readonly fsBundleBytes: number;
34
+ }
35
+ /** @internal The pinned release's artefacts (`artefact-pins.ts`). */
36
+ export declare const pinnedCBuildArtefacts: CBuildArtefactSet;
37
+ //# sourceMappingURL=artefacts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artefacts.d.ts","sourceRoot":"","sources":["../src/artefacts.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,kBAAkB,MAAM,wBAAwB,CAAC;AACxD,OAAO,oBAAoB,MAAM,0BAA0B,CAAC;AAG5D,gGAAgG;AAChG,eAAO,MAAM,eAAe;IAC1B,uCAAuC;aACvC,YAAY;IACZ,qFAAqF;aACrF,QAAQ;IACR,4EAA4E;aAC5E,UAAU;CACF,CAAC;AAEX;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,oBAAoB,EAAE,OAAO,oBAAoB,CAAC;IAC3D,QAAQ,CAAC,kBAAkB,EAAE,OAAO,kBAAkB,CAAC;IACvD,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC;IACzB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAED,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,EAAE,iBAKnC,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { BuildIdentity, PostgresBuild } from "@pgxsinkit/pgwasm/build";
2
+ import { type CBuildArtefactSet } from "./artefacts";
3
+ import type { PostgresModule } from "./host/emscripten";
4
+ /**
5
+ * The C build's identity, recorded in every data directory it creates (ADR-0063). Its release and data
6
+ * format are the pinned pgwasm-postgres release's (`bun run pgwasm:pin` writes both; ADR-0064): the
7
+ * release is the build's name in version(), and `pgwasm:pin` refuses a release of another data format.
8
+ */
9
+ export declare const C_BUILD_IDENTITY: BuildIdentity;
10
+ /**
11
+ * The C build's artefacts, fetched and compiled ahead of a boot (e.g. by an app's warm module on an earlier
12
+ * screen, from the URLs in `cBuildArtefacts`). A field left out is loaded by the build itself.
13
+ */
14
+ export interface CBuildAssets {
15
+ readonly postgresWasmModule?: WebAssembly.Module;
16
+ readonly initdbWasmModule?: WebAssembly.Module;
17
+ readonly fsBundle?: Blob;
18
+ }
19
+ export interface CBuildOptions {
20
+ /** The Postgres module, compiled ahead (e.g. on an earlier screen). */
21
+ readonly postgresWasmModule?: WebAssembly.Module | Promise<WebAssembly.Module>;
22
+ /** The initdb module, compiled ahead; used only when a data directory is created. */
23
+ readonly initdbWasmModule?: WebAssembly.Module | Promise<WebAssembly.Module>;
24
+ /** The filesystem bundle, fetched ahead. */
25
+ readonly fsBundle?: Blob | Promise<Blob>;
26
+ /**
27
+ * The artefacts being warmed ahead. A boot waits for the promise to settle and uses each asset it
28
+ * resolves with in place of that artefact's own load. The warm-up is only an accelerator: a rejected
29
+ * promise never fails a boot, the build loads the artefacts itself instead. An explicit
30
+ * `postgresWasmModule`, `initdbWasmModule` or `fsBundle` wins over the same asset.
31
+ */
32
+ readonly assets?: Promise<CBuildAssets>;
33
+ /** @internal A test's view of each Postgres module the build instantiates. */
34
+ readonly onPostgresModule?: (module: PostgresModule) => void;
35
+ /** @internal Every command line initdb runs through the host. */
36
+ readonly onInitdbCommand?: (command: string) => void;
37
+ }
38
+ /**
39
+ * A C build, optionally with its artefacts fetched and compiled ahead. `cBuild` is the build with
40
+ * defaults; a build object can boot any number of databases.
41
+ */
42
+ export declare function createCBuild(options?: CBuildOptions): PostgresBuild;
43
+ /**
44
+ * @internal A C build on the given artefacts, recording the given identity: what {@link createCBuild}
45
+ * builds on the pinned release's. Not exported from the package; the IndexedDB browser lane reaches it
46
+ * from source to boot an earlier release's glue and files, so the stores that release wrote can be opened
47
+ * by the current build (tests/e2e/pgwasm-idb/continuity-builds.ts). That list starts empty at 18.6.2: its
48
+ * filesystem root changed, so no earlier release's stores open under it; 18.6.2 is the first entry.
49
+ */
50
+ export declare function createCBuildFrom(identity: BuildIdentity, artefacts: CBuildArtefactSet, options?: CBuildOptions): PostgresBuild;
51
+ /** The C build with its defaults: the artefacts load from next to this module when first booted. */
52
+ export declare const cBuild: PostgresBuild;
53
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAIV,aAAa,EAGb,aAAa,EAKd,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,KAAK,iBAAiB,EAAyB,MAAM,aAAa,CAAC;AAG5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAMxD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAM9B,CAAC;AAUF;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;IACjD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;IAC/C,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,uEAAuE;IACvE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/E,qFAAqF;IACrF,QAAQ,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7E,4CAA4C;IAC5C,QAAQ,CAAC,QAAQ,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACxC,8EAA8E;IAC9E,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAC7D,iEAAiE;IACjE,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD;AAsJD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,aAAkB,GAAG,aAAa,CAEvE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,aAAa,EACvB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,GAAE,aAAkB,GAC1B,aAAa,CA6Ef;AAED,oGAAoG;AACpG,eAAO,MAAM,MAAM,EAAE,aAA8B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ServerExtension } from "@pgxsinkit/pgwasm/build";
2
+ /**
3
+ * `amcheck`, compiled for the C build: pass it in `extensions`, then `CREATE EXTENSION amcheck`.
4
+ *
5
+ * The bundle URL sits in this entry point, which is emitted at its own depth (dist/contrib/), so the
6
+ * relative reference stays valid once bundled.
7
+ */
8
+ export declare const amcheck: ServerExtension;
9
+ //# sourceMappingURL=amcheck.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"amcheck.d.ts","sourceRoot":"","sources":["../../src/contrib/amcheck.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,OAAO,EAAE,eAKrB,CAAC"}
@@ -0,0 +1,13 @@
1
+ // @bun
2
+ // packages/pgwasm-c/src/contrib/amcheck.ts
3
+ var amcheck = {
4
+ kind: "server",
5
+ name: "amcheck",
6
+ build: "c",
7
+ bundle: new URL("../../artefacts/amcheck.tar.gz", import.meta.url)
8
+ };
9
+ export {
10
+ amcheck
11
+ };
12
+
13
+ //# debugId=0710FCCC1121DFF364756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/contrib/amcheck.ts"],
4
+ "sourcesContent": [
5
+ "// Began as a copy of `@electric-sql/pglite` (taken under its PostgreSQL License option, © ElectricSQL\n// — see NOTICE). Owned outright (ADR-0062); compatibility with PGlite is an anti-goal — evolve freely.\n\nimport type { ServerExtension } from \"@pgxsinkit/pgwasm/build\";\n\n/**\n * `amcheck`, compiled for the C build: pass it in `extensions`, then `CREATE EXTENSION amcheck`.\n *\n * The bundle URL sits in this entry point, which is emitted at its own depth (dist/contrib/), so the\n * relative reference stays valid once bundled.\n */\nexport const amcheck: ServerExtension = {\n kind: \"server\",\n name: \"amcheck\",\n build: \"c\",\n bundle: new URL(\"../../artefacts/amcheck.tar.gz\", import.meta.url),\n};\n"
6
+ ],
7
+ "mappings": ";;AAWO,IAAM,UAA2B;AAAA,EACtC,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ,IAAI,IAAI,kCAAkC,YAAY,GAAG;AACnE;",
8
+ "debugId": "0710FCCC1121DFF364756E2164756E21",
9
+ "names": []
10
+ }
@@ -0,0 +1,9 @@
1
+ /** Start downloading an artefact now, so it is on its way when the boot needs it. */
2
+ export declare function prefetch(url: URL): void;
3
+ /** The compiled module at `url`, compiled once per URL. */
4
+ export declare function compileModule(url: URL): Promise<WebAssembly.Module>;
5
+ /** The filesystem bundle's bytes, fetched once per URL; every caller gets its own copy. */
6
+ export declare function loadBundle(url: URL): Promise<ArrayBuffer>;
7
+ /** A Blob or its promise, as bytes. */
8
+ export declare function bytesOf(source: Blob | Promise<Blob>): Promise<ArrayBuffer>;
9
+ //# sourceMappingURL=artefact-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"artefact-loader.d.ts","sourceRoot":"","sources":["../../src/host/artefact-loader.ts"],"names":[],"mappings":"AA6BA,qFAAqF;AACrF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAEvC;AAED,2DAA2D;AAC3D,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAoBnE;AAED,2FAA2F;AAC3F,wBAAsB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC,CAW/D;AAED,uCAAuC;AACvC,wBAAsB,OAAO,CAAC,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC,CAEhF"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The words of a command line initdb hands to `system()` / `popen()`, up to the first shell operator.
3
+ *
4
+ * initdb runs its backend through a shell command (`"/pgwasm/bin/postgres" --boot -X 1048576 …`, or
5
+ * `… template1 >"/dev/null"`); the host runs that backend itself, so it needs the argument words, not a
6
+ * shell. Quoting is honoured (`'…'`, `"…"` with `\` escaping `"`, `\`, `$` and backtick, and a bare
7
+ * `\`); the first redirection or control operator (`< > | & ; ( )`) ends the words, as a shell would
8
+ * end the command there.
9
+ */
10
+ export declare function commandWords(command: string): string[];
11
+ //# sourceMappingURL=command-line.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-line.d.ts","sourceRoot":"","sources":["../../src/host/command-line.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAsDtD"}
@@ -0,0 +1,11 @@
1
+ import type { DataDirEntry } from "@pgxsinkit/pgwasm/build";
2
+ import type { EmscriptenFS } from "./emscripten";
3
+ /** Every entry under the data directory, a directory before its contents. */
4
+ export declare function readDataDirEntries(FS: EmscriptenFS, root?: string): DataDirEntry[];
5
+ /** Write entries into the data directory, creating it and any missing parents. */
6
+ export declare function writeDataDirEntries(FS: EmscriptenFS, entries: readonly DataDirEntry[], root?: string): void;
7
+ /** Write one file, creating its directory. */
8
+ export declare function writeDataDirFile(FS: EmscriptenFS, path: string, data: Uint8Array, root?: string): void;
9
+ /** A file in the data directory, or `undefined` when it does not exist. */
10
+ export declare function readDataDirFile(FS: EmscriptenFS, path: string, root?: string): Uint8Array | undefined;
11
+ //# sourceMappingURL=data-dir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-dir.d.ts","sourceRoot":"","sources":["../../src/host/data-dir.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAOjD,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,SAAS,GAAG,YAAY,EAAE,CAoBlF;AAMD,kFAAkF;AAClF,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,SAAS,YAAY,EAAE,EAAE,IAAI,SAAS,GAAG,IAAI,CAa3G;AAED,8CAA8C;AAC9C,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,SAAS,GAAG,IAAI,CAItG;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,SAAS,GAAG,UAAU,GAAG,SAAS,CAMrG"}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * The parts of the Emscripten runtime the C build's host code uses, typed here rather than through
3
+ * `@types/emscripten` (a global-ambient package that would put a global `FS` into every file of the
4
+ * repository's single typecheck program). Only what is called is declared.
5
+ */
6
+ /** An Emscripten filesystem type (MEMFS, NODEFS, IDBFS, PROXYFS or one of ours). */
7
+ export interface EmscriptenFilesystemType {
8
+ readonly [member: string]: unknown;
9
+ }
10
+ export interface EmscriptenNode {
11
+ name: string;
12
+ mode: number;
13
+ id: number;
14
+ rdev: number;
15
+ parent: EmscriptenNode;
16
+ mount: {
17
+ opts: {
18
+ root?: string;
19
+ };
20
+ };
21
+ node_ops: unknown;
22
+ stream_ops: unknown;
23
+ }
24
+ export interface EmscriptenStream {
25
+ node: EmscriptenNode;
26
+ position: number;
27
+ nfd?: number;
28
+ shared: {
29
+ refcount: number;
30
+ };
31
+ }
32
+ export interface EmscriptenStat {
33
+ mode: number;
34
+ size: number;
35
+ mtime: Date | number;
36
+ }
37
+ export interface EmscriptenErrnoError extends Error {
38
+ errno: number;
39
+ }
40
+ export interface IdbfsType extends EmscriptenFilesystemType {
41
+ readonly dbs: Readonly<Record<string, {
42
+ close(): void;
43
+ } | undefined>>;
44
+ }
45
+ /** Emscripten's `FS` object. */
46
+ export interface EmscriptenFS {
47
+ readonly filesystems: {
48
+ readonly MEMFS: EmscriptenFilesystemType;
49
+ readonly NODEFS: EmscriptenFilesystemType;
50
+ readonly IDBFS: IdbfsType;
51
+ };
52
+ readonly ErrnoError: new (errno: number) => EmscriptenErrnoError;
53
+ analyzePath(path: string): {
54
+ exists: boolean;
55
+ };
56
+ mkdir(path: string, mode?: number): void;
57
+ mkdirTree(path: string, mode?: number): void;
58
+ mount(type: EmscriptenFilesystemType, opts: Record<string, unknown>, mountpoint: string): void;
59
+ symlink(target: string, path: string): void;
60
+ readdir(path: string): string[];
61
+ stat(path: string): EmscriptenStat;
62
+ isFile(mode: number): boolean;
63
+ isDir(mode: number): boolean;
64
+ readFile(path: string, options?: {
65
+ encoding: "binary";
66
+ }): Uint8Array;
67
+ writeFile(path: string, data: Uint8Array | string): void;
68
+ utime(path: string, atime: number, mtime: number): void;
69
+ chmod(path: string, mode: number): void;
70
+ unlink(path: string): void;
71
+ rmdir(path: string): void;
72
+ makedev(major: number, minor: number): number;
73
+ registerDevice(dev: number, ops: EmscriptenDeviceOps): void;
74
+ mkdev(path: string, dev: number): void;
75
+ createNode(parent: EmscriptenNode | null, name: string, mode: number, dev?: number): EmscriptenNode;
76
+ createPreloadedFile(parent: string, name: string, data: Uint8Array, canRead: boolean, canWrite: boolean, onload: () => void, onerror: () => void, dontCreateFile: boolean): void;
77
+ syncfs(populate: boolean, callback: (error: unknown) => void): void;
78
+ quit(): void;
79
+ }
80
+ export interface EmscriptenDeviceOps {
81
+ open(stream: EmscriptenStream): void;
82
+ close(stream: EmscriptenStream): void;
83
+ read(stream: EmscriptenStream, buffer: Uint8Array, offset: number, length: number, position: number): number;
84
+ write(stream: EmscriptenStream, buffer: Uint8Array, offset: number, length: number, position: number): number;
85
+ llseek(stream: EmscriptenStream, offset: number, whence: number): number;
86
+ }
87
+ /** What the module factories accept; the members the host sets. */
88
+ export interface ModuleOverrides<TModule> {
89
+ thisProgram: string;
90
+ arguments?: string[];
91
+ noExitRuntime?: boolean;
92
+ wasmMemory?: WebAssembly.Memory;
93
+ stdin?: () => number | null;
94
+ print?: (text: string) => void;
95
+ printErr?: (text: string) => void;
96
+ instantiateWasm?: (imports: Parameters<typeof WebAssembly.instantiate>[1], successCallback: (instance: WebAssembly.Instance, module: WebAssembly.Module) => void) => Record<string, never>;
97
+ getPreloadedPackage?: (name: string, size: number) => ArrayBuffer;
98
+ preRun?: ((module: TModule) => void)[];
99
+ }
100
+ /** The members every Emscripten module the C build loads has. */
101
+ export interface EmscriptenModuleBase {
102
+ readonly FS: EmscriptenFS;
103
+ readonly ENV: Record<string, string>;
104
+ readonly HEAPU8: Uint8Array;
105
+ readonly HEAP8: Int8Array;
106
+ onRuntimeInitialized?: () => void;
107
+ callMain(args: string[]): number;
108
+ addFunction(fn: (...args: number[]) => number | void, signature: string): number;
109
+ removeFunction(pointer: number): void;
110
+ UTF8ToString(pointer: number): string;
111
+ stringToUTF8OnStack(value: string): number;
112
+ _fopen(path: number, mode: number): number;
113
+ _fclose(stream: number): number;
114
+ _pgl_set_system_fn(fn: number): void;
115
+ _pgl_set_popen_fn(fn: number): void;
116
+ _pgl_set_pclose_fn(fn: number): void;
117
+ _pgl_freopen(path: number, mode: number, stream: number): number;
118
+ }
119
+ /** The Postgres module (`postgres.js`). */
120
+ export interface PostgresModule extends EmscriptenModuleBase {
121
+ readonly PROXYFS: EmscriptenFilesystemType;
122
+ _pgl_set_rw_cbs(readCallback: number, writeCallback: number): void;
123
+ _pgl_pq_flush(): void;
124
+ _pgl_setPGliteActive(value: number): number;
125
+ _pgl_startPGlite(): void;
126
+ _pgl_getMyProcPort(): number;
127
+ _pgl_sendConnData(): void;
128
+ _pgl_run_atexit_funcs(): void;
129
+ _pgl_setPGliteExitStatus(status: number): number;
130
+ _PostgresMainLoopOnce(): void;
131
+ _PostgresMainLongJmp(): void;
132
+ _PostgresSendReadyForQueryIfNecessary(): void;
133
+ _ProcessStartupPacket(port: number, sslDone: boolean, gssDone: boolean): number;
134
+ _pq_buffer_remaining_data(): number;
135
+ _emscripten_force_exit(status: number): void;
136
+ }
137
+ /** The initdb module (`initdb.js`). */
138
+ export interface InitdbModule extends EmscriptenModuleBase {
139
+ readonly PROXYFS: EmscriptenFilesystemType;
140
+ _pclose(stream: number): number;
141
+ }
142
+ export type ModuleFactory<TModule> = (overrides: ModuleOverrides<TModule>) => Promise<TModule>;
143
+ //# sourceMappingURL=emscripten.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emscripten.d.ts","sourceRoot":"","sources":["../../src/host/emscripten.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,oFAAoF;AACpF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;CACpC;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;I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AM,CAAC;IAChF,yBAAyB,IAAI,MAAM,CAAC;IACpC,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9C;AAED,uCAAuC;AACvC,MAAM,WAAW,YAAa,SAAQ,oBAAoB;IACxD,QAAQ,CAAC,OAAO,EAAE,wBAAwB,CAAC;IAC3C,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACjC;AAED,MAAM,MAAM,aAAa,CAAC,OAAO,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Emscripten's runtime writes an exit status onto the host's `process.exitCode` when the program
3
+ * exits, and Postgres' single-user mode reports a successful start by exiting with 99. Under Bun that
4
+ * sentinel would survive to the end of the process and fail an otherwise green run. Every glue call that
5
+ * can exit is wrapped so the host's own exit code is left as it was.
6
+ */
7
+ /**
8
+ * Run `fn`, restoring `process.exitCode` (where there is a process) to its value before. Bun ignores an
9
+ * assignment of `undefined`, so an exit code that was unset is restored as 0 — only when `fn` changed it.
10
+ */
11
+ export declare function preservingExitCode<T>(fn: () => T): T;
12
+ //# sourceMappingURL=exit-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exit-code.d.ts","sourceRoot":"","sources":["../../src/host/exit-code.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CASpD"}
@@ -0,0 +1,15 @@
1
+ import { type ServerExtension, type TarEntry } from "@pgxsinkit/pgwasm/build";
2
+ import type { PostgresModule } from "./emscripten";
3
+ /**
4
+ * An extension bundle's files, fetched now so the download overlaps the boot. The bundle is a gzipped
5
+ * tar; a server that already decompressed it (Content-Encoding) hands over the plain tar, which is
6
+ * recognised by its missing gzip magic.
7
+ */
8
+ export declare function fetchExtensionBundle(extension: ServerExtension): Promise<TarEntry[]>;
9
+ /**
10
+ * Install extension files under `/pgwasm` (`lib/postgresql/*.so`, `share/postgresql/extension/*`).
11
+ * Shared objects go through the runtime's preload plugin, which compiles them ahead of `dlopen`; a
12
+ * preload that fails leaves the plain file, and `dlopen` compiles it when it is first needed.
13
+ */
14
+ export declare function installExtensionFiles(module: PostgresModule, bundles: readonly TarEntry[][], log: (...args: unknown[]) => void): Promise<void>;
15
+ //# sourceMappingURL=extensions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../src/host/extensions.ts"],"names":[],"mappings":"AAGA,OAAO,EAA+B,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAE3G,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,cAAc,CAAC;AAGjE;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,SAAS,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAS1F;AAQD;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,SAAS,QAAQ,EAAE,EAAE,EAC9B,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,GAChC,OAAO,CAAC,IAAI,CAAC,CA2Cf"}
@@ -0,0 +1,25 @@
1
+ import type { CBuildArtefactSet } from "../artefacts";
2
+ import type { PostgresInstance } from "./postgres-instance";
3
+ export interface InitdbResult {
4
+ readonly exitCode: number;
5
+ readonly stderr: string;
6
+ readonly stdout: string;
7
+ }
8
+ /** The arguments every initdb run starts with. */
9
+ export declare const INITDB_ARGS: readonly string[];
10
+ /**
11
+ * Run initdb against a scratch Postgres instance. initdb is its own wasm module; the backend commands it
12
+ * shells out to (`postgres --boot`, `postgres --single`) are run on the scratch instance, whose heap is
13
+ * reset to its pristine state before each. initdb sees the instance's filesystem through PROXYFS, so the
14
+ * cluster it creates lands in the instance's `/pgwasm/data`.
15
+ */
16
+ export declare function runInitdb({ createInitdbModule, postgres, initdbWasm, debug, onCommand, }: {
17
+ /** The initdb glue (`initdb.js`) of the build whose `initdbWasm` this is. */
18
+ readonly createInitdbModule: CBuildArtefactSet["createInitdbModule"];
19
+ readonly postgres: PostgresInstance;
20
+ readonly initdbWasm: WebAssembly.Module;
21
+ readonly debug: number;
22
+ /** @internal Every command line initdb hands to the host (the tokenizer's test pins these). */
23
+ readonly onCommand?: (command: string) => void;
24
+ }): Promise<InitdbResult>;
25
+ //# sourceMappingURL=initdb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initdb.d.ts","sourceRoot":"","sources":["../../src/host/initdb.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAatD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,kDAAkD;AAClD,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAOxC,CAAC;AAMF;;;;;GAKG;AACH,wBAAsB,SAAS,CAAC,EAC9B,kBAAkB,EAClB,QAAQ,EACR,UAAU,EACV,KAAK,EACL,SAAS,GACV,EAAE;IACD,6EAA6E;IAC7E,QAAQ,CAAC,kBAAkB,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;IACrE,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+FAA+F;IAC/F,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAChD,GAAG,OAAO,CAAC,YAAY,CAAC,CAyHxB"}
@@ -0,0 +1,17 @@
1
+ import type { PostgresModule } from "../emscripten";
2
+ import type { StorageMount } from "./storage-mount";
3
+ /**
4
+ * The data directory as a directory on disk, through Emscripten's NODEFS (Bun). Writes go straight to
5
+ * the host filesystem, so there is nothing to persist; closing flushes the runtime's streams.
6
+ */
7
+ export declare class FileMount implements StorageMount {
8
+ #private;
9
+ constructor(path: string);
10
+ acquire(): Promise<void>;
11
+ get preRun(): (module: PostgresModule) => void;
12
+ initialSync(): Promise<void>;
13
+ persist(): Promise<void>;
14
+ close(module: PostgresModule | undefined): Promise<void>;
15
+ cleanupFailedInit(): Promise<void>;
16
+ }
17
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/host/mounts/file.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;GAGG;AACH,qBAAa,SAAU,YAAW,YAAY;;IAI5C,YAAY,IAAI,EAAE,MAAM,EAEvB;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAK7B;IAED,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAM7C;IAEK,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAG;IAE/B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAG;IAE3B,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D;IAEK,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAG;CAC5C"}
@@ -0,0 +1,32 @@
1
+ import type { PostgresModule } from "../emscripten";
2
+ import type { StorageMount } from "./storage-mount";
3
+ /**
4
+ * The IndexedDB database behind `idb://<name>`: `/pgwasm/<name>`. IDBFS names the database after its
5
+ * mount point, so this is both. It is a store's identity: a change to it (as the root rename in 18.6.2)
6
+ * opens a new, empty store and leaves the old database behind, never deleted here.
7
+ */
8
+ export declare function idbDatabaseName(name: string): string;
9
+ /** The Web Lock that guards `idb://<name>` against a second open: `pgwasm-idbfs:/pgwasm/<name>`. */
10
+ export declare function idbLockName(name: string): string;
11
+ /**
12
+ * The data directory in IndexedDB, through Emscripten's IDBFS: the whole directory lives in memory and
13
+ * is synced to an IndexedDB database named after its mount point, `/pgwasm/<name>`.
14
+ *
15
+ * One open per database: a Web Lock named after the database guards it, so a second open fails with
16
+ * {@link StorageInUseError}. Both names come from {@link idbDatabaseName} and {@link idbLockName} only.
17
+ *
18
+ * Deliberately no exclusive persist: a relaxed persist is a background snapshot that statements run
19
+ * beside (measured: an exclusive lane made relaxed as slow as strict, ~80 ms per statement). A crash
20
+ * during a snapshot can lose its tail, which is relaxed durability's documented loss window.
21
+ */
22
+ export declare class IdbMount implements StorageMount {
23
+ #private;
24
+ constructor(name: string);
25
+ acquire(): Promise<void>;
26
+ get preRun(): (module: PostgresModule) => void;
27
+ initialSync(module: PostgresModule): Promise<void>;
28
+ persist(module: PostgresModule): Promise<void>;
29
+ close(module: PostgresModule | undefined): Promise<void>;
30
+ cleanupFailedInit(module: PostgresModule | undefined): Promise<void>;
31
+ }
32
+ //# sourceMappingURL=idb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idb.d.ts","sourceRoot":"","sources":["../../../src/host/mounts/idb.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED,oGAAoG;AACpG,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEhD;AAWD;;;;;;;;;;GAUG;AACH,qBAAa,QAAS,YAAW,YAAY;;IAK3C,YAAY,IAAI,EAAE,MAAM,EAEvB;IAMK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CA+B7B;IAED,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAO7C;IAEK,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAEvD;IAEK,OAAO,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnD;IAEK,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D;IAEK,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzE;CAuCF"}
@@ -0,0 +1,6 @@
1
+ import type { StorageRequest } from "@pgxsinkit/pgwasm/build";
2
+ import type { StorageMount } from "./storage-mount";
3
+ export type { StorageMount } from "./storage-mount";
4
+ /** The mount for a storage request. */
5
+ export declare function mountFor(storage: StorageRequest): StorageMount;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/host/mounts/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAK9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,uCAAuC;AACvC,wBAAgB,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,YAAY,CAW9D"}
@@ -0,0 +1,12 @@
1
+ import type { PostgresModule } from "../emscripten";
2
+ import type { StorageMount } from "./storage-mount";
3
+ /** The data directory in the module's own memory (MEMFS): gone when the database closes. */
4
+ export declare class MemoryMount implements StorageMount {
5
+ readonly preRun: undefined;
6
+ acquire(): Promise<void>;
7
+ initialSync(): Promise<void>;
8
+ persist(): Promise<void>;
9
+ close(module: PostgresModule | undefined): Promise<void>;
10
+ cleanupFailedInit(): Promise<void>;
11
+ }
12
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/host/mounts/memory.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,4FAA4F;AAC5F,qBAAa,WAAY,YAAW,YAAY;IAC9C,QAAQ,CAAC,MAAM,YAAa;IAEtB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAG;IAE3B,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAG;IAE/B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAG;IAE3B,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7D;IAEK,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAAG;CAC5C"}
@@ -0,0 +1,15 @@
1
+ import type { PostgresModule } from "../emscripten";
2
+ /**
3
+ * How the C build mounts one kind of storage over the data directory. The lifecycle follows the boot:
4
+ * `acquire` before the module exists, `preRun` inside its instantiation, `initialSync` once mounted,
5
+ * `persist` after statements, then `close` (a normal close) or `cleanupFailedInit` (a failed boot).
6
+ */
7
+ export interface StorageMount {
8
+ acquire(): Promise<void>;
9
+ readonly preRun: ((module: PostgresModule) => void) | undefined;
10
+ initialSync(module: PostgresModule): Promise<void>;
11
+ persist(module: PostgresModule, relaxed: boolean): Promise<void>;
12
+ close(module: PostgresModule | undefined): Promise<void>;
13
+ cleanupFailedInit(module: PostgresModule | undefined): Promise<void>;
14
+ }
15
+ //# sourceMappingURL=storage-mount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storage-mount.d.ts","sourceRoot":"","sources":["../../../src/host/mounts/storage-mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAChE,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,KAAK,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtE"}
@@ -0,0 +1,15 @@
1
+ import type { BaseFilesystem } from "@pgxsinkit/pgwasm/fs";
2
+ import type { PostgresModule } from "../emscripten";
3
+ import type { StorageMount } from "./storage-mount";
4
+ /** The data directory on a pgwasm filesystem (`createPgwasm({ fs })`), mounted through an adapter. */
5
+ export declare class VfsMount implements StorageMount {
6
+ #private;
7
+ constructor(vfs: BaseFilesystem);
8
+ acquire(): Promise<void>;
9
+ get preRun(): (module: PostgresModule) => void;
10
+ initialSync(): Promise<void>;
11
+ persist(_module: PostgresModule, relaxed: boolean): Promise<void>;
12
+ close(): Promise<void>;
13
+ cleanupFailedInit(): Promise<void>;
14
+ }
15
+ //# sourceMappingURL=vfs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vfs.d.ts","sourceRoot":"","sources":["../../../src/host/mounts/vfs.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,sGAAsG;AACtG,qBAAa,QAAS,YAAW,YAAY;;IAG3C,YAAY,GAAG,EAAE,cAAc,EAE9B;IAEK,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAG;IAEjC,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAK7C;IAEK,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAEjC;IAEK,OAAO,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtE;IAEK,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAEK,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEvC;CACF"}