@pgxsinkit/pgwasm-repl 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 pgxsinkit contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,48 @@
1
+ @pgxsinkit/pgwasm-repl
2
+ ======================
3
+
4
+ This package includes software that began as a copy of third-party code. It is owned
5
+ outright and diverges freely (ADR-0062); this attribution is permanent.
6
+
7
+ ------------------------------------------------------------------------------
8
+ ElectricSQL — @electric-sql/pglite-repl
9
+ ------------------------------------------------------------------------------
10
+
11
+ The REPL component under `src/` began as a copy of ElectricSQL's PGlite REPL
12
+ (`packages/pglite-repl`):
13
+
14
+ Source: https://github.com/electric-sql/pglite
15
+ License: PostgreSQL License. PGlite is dual-licensed under the Apache License 2.0
16
+ and the PostgreSQL License, at the licensee's choice; pgxsinkit takes it
17
+ under the PostgreSQL License.
18
+ Copyright (c) ElectricSQL and contributors
19
+
20
+ The code is owned outright (ADR-0062) and diverges freely; compatibility with PGlite
21
+ is an explicit anti-goal. This attribution is retained because the code began as a
22
+ copy. The PostgreSQL License text, as PGlite ships it (POSTGRES-LICENSE):
23
+
24
+ Copyright (c) ElectricSQL and contributors
25
+
26
+ PostgreSQL Database Management System
27
+ (formerly known as Postgres, then as Postgres95)
28
+
29
+ Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
30
+
31
+ Portions Copyright (c) 1994, The Regents of the University of California
32
+
33
+ Permission to use, copy, modify, and distribute this software and its
34
+ documentation for any purpose, without fee, and without a written agreement
35
+ is hereby granted, provided that the above copyright notice and this
36
+ paragraph and the following two paragraphs appear in all copies.
37
+
38
+ IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
39
+ DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
40
+ LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
41
+ DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
42
+ POSSIBILITY OF SUCH DAMAGE.
43
+
44
+ THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
45
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
46
+ AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
47
+ ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
48
+ PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # @pgxsinkit/pgwasm-repl
2
+
3
+ An interactive SQL prompt, as a React component, for a
4
+ [`@pgxsinkit/pgwasm`](https://www.npmjs.com/package/@pgxsinkit/pgwasm) database or a pgxsinkit
5
+ client: [CodeMirror](https://codemirror.net) input with autocompletion of keywords, tables and
6
+ columns, input history (Up and Down), and psql's `\d` family of commands (through
7
+ [psql-describe](https://www.npmjs.com/package/psql-describe)).
8
+
9
+ ```bash
10
+ bun add @pgxsinkit/pgwasm-repl
11
+ ```
12
+
13
+ It needs React 19.3 or later (`react` and `react-dom`).
14
+
15
+ ```tsx
16
+ import { createPgwasm } from "@pgxsinkit/pgwasm";
17
+ import { cBuild } from "@pgxsinkit/pgwasm-c";
18
+ import { Repl } from "@pgxsinkit/pgwasm-repl";
19
+
20
+ const pg = await createPgwasm({ build: cBuild });
21
+
22
+ export function Console() {
23
+ return <Repl pg={pg} />;
24
+ }
25
+ ```
26
+
27
+ Enter runs the input. Everything else typed is SQL; a line starting with a backslash is a psql
28
+ describe command, such as `\dt` or `\d my_table`.
29
+
30
+ ## The database
31
+
32
+ `pg` is required. It is anything with pgwasm's `query` and `exec` (the `ReplDatabase` type): a
33
+ `Pgwasm`, or a pgxsinkit client's inspection surface through `replAdapter(client)` from
34
+ `@pgxsinkit/client`, which works on a worker-attached client too. When `pg` has a `waitReady`
35
+ promise, the prompt waits for it.
36
+
37
+ ## Props
38
+
39
+ | Prop | Default | What it does |
40
+ | --------------------- | ------------ | --------------------------------------------------------------------- |
41
+ | `pg` | (required) | the database |
42
+ | `border` | `false` | an outer border |
43
+ | `theme` | `"auto"` | `"light"`, `"dark"`, or `"auto"` to follow the system's colour scheme |
44
+ | `lightTheme` | GitHub light | a CodeMirror theme extension |
45
+ | `darkTheme` | GitHub dark | a CodeMirror theme extension |
46
+ | `showTime` | `false` | show how long each input took |
47
+ | `disableUpdateSchema` | `false` | do not re-read the tables for autocompletion after each input |
48
+
49
+ The GitHub themes are exported as `defaultLightTheme` and `defaultDarkTheme`, with
50
+ `defaultLightThemeInit` and `defaultDarkThemeInit` to make variants of them.
51
+
52
+ ## Styling
53
+
54
+ The component brings its own stylesheet: React adds it to the page once, however many prompts are
55
+ mounted, so there is no CSS file to import. It fills its container. Its classes start with
56
+ `pgwasm-repl-`, and `--pgwasm-repl-font-size` (12px by default) sets its text size; the colours come
57
+ from the editor's theme.
58
+
59
+ Licensed under the MIT License. `NOTICE` records the component's origin in ElectricSQL's PGlite REPL.
@@ -0,0 +1,3 @@
1
+ export { defaultDarkTheme, defaultDarkThemeInit, defaultLightTheme, defaultLightThemeInit, Repl, type ReplProps, type ReplTheme, } from "./repl";
2
+ export type { ReplDatabase, ReplQueryOptions, ReplResults } from "./types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,EACrB,IAAI,EACJ,KAAK,SAAS,EACd,KAAK,SAAS,GACf,MAAM,QAAQ,CAAC;AAChB,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}