@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.
- package/LICENSE +23 -0
- package/NOTICE +1890 -0
- package/README.md +79 -0
- package/artefacts/amcheck.tar.gz +0 -0
- package/artefacts/initdb.d.ts +6 -0
- package/artefacts/initdb.js +2 -0
- package/artefacts/initdb.wasm +0 -0
- package/artefacts/postgres.d.ts +6 -0
- package/artefacts/postgres.data +37595 -8
- package/artefacts/postgres.js +2 -0
- package/artefacts/postgres.wasm +0 -0
- package/artefacts/prepopulated.tar.gz +0 -0
- package/dist/artefact-pins.d.ts +57 -0
- package/dist/artefact-pins.d.ts.map +1 -0
- package/dist/artefacts.d.ts +37 -0
- package/dist/artefacts.d.ts.map +1 -0
- package/dist/build.d.ts +53 -0
- package/dist/build.d.ts.map +1 -0
- package/dist/contrib/amcheck.d.ts +9 -0
- package/dist/contrib/amcheck.d.ts.map +1 -0
- package/dist/contrib/amcheck.js +13 -0
- package/dist/contrib/amcheck.js.map +10 -0
- package/dist/host/artefact-loader.d.ts +9 -0
- package/dist/host/artefact-loader.d.ts.map +1 -0
- package/dist/host/command-line.d.ts +11 -0
- package/dist/host/command-line.d.ts.map +1 -0
- package/dist/host/data-dir.d.ts +11 -0
- package/dist/host/data-dir.d.ts.map +1 -0
- package/dist/host/emscripten.d.ts +143 -0
- package/dist/host/emscripten.d.ts.map +1 -0
- package/dist/host/exit-code.d.ts +12 -0
- package/dist/host/exit-code.d.ts.map +1 -0
- package/dist/host/extensions.d.ts +15 -0
- package/dist/host/extensions.d.ts.map +1 -0
- package/dist/host/initdb.d.ts +25 -0
- package/dist/host/initdb.d.ts.map +1 -0
- package/dist/host/mounts/file.d.ts +17 -0
- package/dist/host/mounts/file.d.ts.map +1 -0
- package/dist/host/mounts/idb.d.ts +32 -0
- package/dist/host/mounts/idb.d.ts.map +1 -0
- package/dist/host/mounts/index.d.ts +6 -0
- package/dist/host/mounts/index.d.ts.map +1 -0
- package/dist/host/mounts/memory.d.ts +12 -0
- package/dist/host/mounts/memory.d.ts.map +1 -0
- package/dist/host/mounts/storage-mount.d.ts +15 -0
- package/dist/host/mounts/storage-mount.d.ts.map +1 -0
- package/dist/host/mounts/vfs.d.ts +15 -0
- package/dist/host/mounts/vfs.d.ts.map +1 -0
- package/dist/host/paths.d.ts +10 -0
- package/dist/host/paths.d.ts.map +1 -0
- package/dist/host/postgres-instance.d.ts +63 -0
- package/dist/host/postgres-instance.d.ts.map +1 -0
- package/dist/host/vfs-mount.d.ts +10 -0
- package/dist/host/vfs-mount.d.ts.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1393 -0
- package/dist/index.js.map +26 -0
- package/dist/prepopulated.d.ts +28 -0
- package/dist/prepopulated.d.ts.map +1 -0
- package/dist/prepopulated.js +15 -0
- package/dist/prepopulated.js.map +10 -0
- package/package.json +56 -0
- package/src/artefact-pins.ts +36 -0
- package/src/artefacts.ts +46 -0
- package/src/build.ts +326 -0
- package/src/contrib/amcheck.ts +17 -0
- package/src/host/artefact-loader.ts +75 -0
- package/src/host/command-line.ts +64 -0
- package/src/host/data-dir.ts +70 -0
- package/src/host/emscripten.ts +158 -0
- package/src/host/exit-code.ts +29 -0
- package/src/host/extensions.ts +83 -0
- package/src/host/initdb.ts +180 -0
- package/src/host/mounts/file.ts +44 -0
- package/src/host/mounts/idb.ts +152 -0
- package/src/host/mounts/index.ts +26 -0
- package/src/host/mounts/memory.ts +22 -0
- package/src/host/mounts/storage-mount.ts +15 -0
- package/src/host/mounts/vfs.ts +43 -0
- package/src/host/paths.ts +18 -0
- package/src/host/postgres-instance.ts +495 -0
- package/src/host/vfs-mount.ts +258 -0
- package/src/index.ts +3 -0
- package/src/prepopulated.ts +38 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const PG_ROOT = "/pgwasm";
|
|
2
|
+
export declare const PGDATA = "/pgwasm/data";
|
|
3
|
+
export declare const ICU_DATA_PATH = "/pgwasm/icu";
|
|
4
|
+
export declare const INITDB_EXE_PATH = "/pgwasm/bin/initdb";
|
|
5
|
+
export declare const POSTGRES_EXE_PATH = "/pgwasm/bin/postgres";
|
|
6
|
+
export declare const PG_STDOUT_PATH = "/pgwasm/pgstdout";
|
|
7
|
+
export declare const PG_STDIN_PATH = "/pgwasm/pgstdin";
|
|
8
|
+
/** The file `locale -a` output is served from. */
|
|
9
|
+
export declare const LOCALE_LIST_PATH = "/pgwasm/locale-a";
|
|
10
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/host/paths.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,MAAM,iBAAoB,CAAC;AACxC,eAAO,MAAM,aAAa,gBAAmB,CAAC;AAC9C,eAAO,MAAM,eAAe,uBAA0B,CAAC;AACvD,eAAO,MAAM,iBAAiB,yBAA4B,CAAC;AAC3D,eAAO,MAAM,cAAc,qBAAwB,CAAC;AACpD,eAAO,MAAM,aAAa,oBAAuB,CAAC;AAClD,kDAAkD;AAClD,eAAO,MAAM,gBAAgB,qBAAwB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { DebugLevel } from "@pgxsinkit/pgwasm/build";
|
|
2
|
+
import type { CBuildArtefactSet } from "../artefacts";
|
|
3
|
+
import type { PostgresModule } from "./emscripten";
|
|
4
|
+
/** The single-user-mode arguments every start begins with. */
|
|
5
|
+
export declare const DEFAULT_START_PARAMS: readonly string[];
|
|
6
|
+
/**
|
|
7
|
+
* Whether `error` is one of the exceptions the Emscripten runtime throws on purpose to unwind the wasm
|
|
8
|
+
* stack back to the main loop, which handles them:
|
|
9
|
+
* - `'unwind'` from emscripten_exit_with_live_runtime(): how pgl_longjmp (pglitec.c) delivers Postgres'
|
|
10
|
+
* siglongjmp to its main-loop error handler, and how a Terminate message ends the loop;
|
|
11
|
+
* - what an emscripten-mode longjmp throws, should one pass every invoke_* frame: an instance of the
|
|
12
|
+
* glue's (unexported) `EmscriptenSjLj` class on Emscripten 6.0.10 (pgwasm-postgres 18.6.1 onwards), a
|
|
13
|
+
* number on Emscripten 3.1.74 (18.3.0 and 18.6.0). Both are recognised, so the host works with either.
|
|
14
|
+
*
|
|
15
|
+
* An `ExitStatus` (from exit()/proc_exit(): a FATAL error) is not: the backend's exit callbacks have
|
|
16
|
+
* already torn its session down, so the loop cannot resume on it (see {@link exitStatusOf}).
|
|
17
|
+
*/
|
|
18
|
+
export declare function isEmscriptenUnwind(error: unknown): boolean;
|
|
19
|
+
/** The status of the `ExitStatus` the runtime throws from exit()/proc_exit(), or undefined for anything else. */
|
|
20
|
+
export declare function exitStatusOf(error: unknown): number | undefined;
|
|
21
|
+
export interface PostgresInstanceConfig {
|
|
22
|
+
/** The Postgres glue (`postgres.js`) and the size of the filesystem bundle it was packaged with. */
|
|
23
|
+
readonly glue: Pick<CBuildArtefactSet, "createPostgresModule" | "fsBundleBytes">;
|
|
24
|
+
readonly wasmModule: Promise<WebAssembly.Module>;
|
|
25
|
+
/** The filesystem bundle, a copy of its own for this instance. */
|
|
26
|
+
readonly fsBundle: Promise<ArrayBuffer>;
|
|
27
|
+
readonly user: string;
|
|
28
|
+
readonly database: string;
|
|
29
|
+
readonly debug: DebugLevel;
|
|
30
|
+
/** preRun steps that mount storage over the data directory; run after the filesystem bundle loads. */
|
|
31
|
+
readonly mountPreRun?: (module: PostgresModule) => void;
|
|
32
|
+
/** @internal A test's view of the module. */
|
|
33
|
+
readonly onModule?: (module: PostgresModule) => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* One Emscripten instance of the Postgres module and the host state around it: the socket callbacks
|
|
37
|
+
* the wire goes through, the `/dev/blob` device, and the external-command hooks.
|
|
38
|
+
*/
|
|
39
|
+
export declare class PostgresInstance {
|
|
40
|
+
#private;
|
|
41
|
+
readonly module: PostgresModule;
|
|
42
|
+
private constructor();
|
|
43
|
+
static create(config: PostgresInstanceConfig): Promise<PostgresInstance>;
|
|
44
|
+
setBlobReadSource(data: Uint8Array | undefined): void;
|
|
45
|
+
takeBlobWritten(): Uint8Array<ArrayBuffer>[] | undefined;
|
|
46
|
+
/** Run `callMain`, leaving the host's exit code as it was. */
|
|
47
|
+
callMain(args: string[]): number;
|
|
48
|
+
/** Start Postgres in single-user mode on the data directory. */
|
|
49
|
+
startSingleMode(startParams: readonly string[]): void;
|
|
50
|
+
/**
|
|
51
|
+
* One exchange on the single session: feed `message` to Postgres and hand every backend byte it
|
|
52
|
+
* produces to `onData`, synchronously. A startup packet (first byte 0) is processed as one; a
|
|
53
|
+
* Terminate (`X`) is ignored, as the session ends with the instance. A throw that is not Postgres'
|
|
54
|
+
* own error unwind means the wasm stack was abandoned mid-function, and an exit (a FATAL error) means
|
|
55
|
+
* the backend tore its session down: either fails the session, which refuses every later exchange.
|
|
56
|
+
*/
|
|
57
|
+
exchange(message: Uint8Array, onData: (chunk: Uint8Array) => void): void;
|
|
58
|
+
/** Postgres' clean exit: its atexit callbacks. An exit status of 0 is the normal outcome. */
|
|
59
|
+
shutdown(): void;
|
|
60
|
+
/** Release the callbacks and exit the runtime, which `noExitRuntime` otherwise keeps alive. */
|
|
61
|
+
dispose(exitStatus: number): void;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=postgres-instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-instance.d.ts","sourceRoot":"","sources":["../../src/host/postgres-instance.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAqC,cAAc,EAAE,MAAM,cAAc,CAAC;AAWtF,8DAA8D;AAC9D,eAAO,MAAM,oBAAoB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AgE;IAChE,eAAe,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAYpD;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,IAAI,CA0BvE;IAwDD,6FAA6F;IAC7F,QAAQ,IAAI,IAAI,CAWf;IAED,+FAA+F;IAC/F,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAgBhC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type BaseFilesystem } from "@pgxsinkit/pgwasm/fs";
|
|
2
|
+
import type { EmscriptenFilesystemType, PostgresModule } from "./emscripten";
|
|
3
|
+
/**
|
|
4
|
+
* An Emscripten filesystem over a pgwasm {@link BaseFilesystem}: each node and stream operation becomes a
|
|
5
|
+
* call on the filesystem, by path relative to the mount. A thrown error becomes an errno for Postgres —
|
|
6
|
+
* its `code` when it has one, `EIO` when it does not (a DOMException, a plain Error from the storage):
|
|
7
|
+
* rethrown, it would unwind the engine mid-syscall instead of failing that syscall.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createVfsFilesystem(module: PostgresModule, vfs: BaseFilesystem): EmscriptenFilesystemType;
|
|
10
|
+
//# sourceMappingURL=vfs-mount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vfs-mount.d.ts","sourceRoot":"","sources":["../../src/host/vfs-mount.ts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,KAAK,EAAE,wBAAwB,EAAoC,cAAc,EAAE,MAAM,cAAc,CAAC;AAc/G;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,EAAE,cAAc,GAAG,wBAAwB,CAwOzG"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|