@tishlang/tish-format 1.0.12 → 2.0.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.
- package/Cargo.toml +51 -0
- package/LICENSE +13 -0
- package/bin/tish-format +0 -0
- package/crates/js_to_tish/Cargo.toml +11 -0
- package/crates/js_to_tish/README.md +18 -0
- package/crates/js_to_tish/src/error.rs +55 -0
- package/crates/js_to_tish/src/lib.rs +11 -0
- package/crates/js_to_tish/src/span_util.rs +35 -0
- package/crates/js_to_tish/src/transform/expr.rs +611 -0
- package/crates/js_to_tish/src/transform/stmt.rs +503 -0
- package/crates/js_to_tish/src/transform.rs +60 -0
- package/crates/tish/Cargo.toml +62 -0
- package/crates/tish/build.rs +21 -0
- package/crates/tish/src/cargo_native_registry.rs +32 -0
- package/crates/tish/src/cli_help.rs +576 -0
- package/crates/tish/src/main.rs +853 -0
- package/crates/tish/src/repl_completion.rs +199 -0
- package/crates/tish/tests/cargo_example_compile.rs +67 -0
- package/crates/tish/tests/error_source_location.rs +36 -0
- package/crates/tish/tests/fixtures/cargo_example_project/Cargo.toml +3 -0
- package/crates/tish/tests/fixtures/cargo_example_project/crates/demo-shim/Cargo.toml +11 -0
- package/crates/tish/tests/fixtures/cargo_example_project/crates/demo-shim/src/lib.rs +12 -0
- package/crates/tish/tests/fixtures/cargo_example_project/package.json +10 -0
- package/crates/tish/tests/fixtures/cargo_example_project/src/main.tish +3 -0
- package/crates/tish/tests/fixtures/runtime_error_location.tish +5 -0
- package/crates/tish/tests/fixtures/trycatch_runtime_errors.tish +15 -0
- package/crates/tish/tests/fixtures/tty_capability.tish +9 -0
- package/crates/tish/tests/integration_test.rs +1406 -0
- package/crates/tish/tests/run_optimize_stdout_parity.rs +50 -0
- package/crates/tish/tests/shortcircuit.rs +65 -0
- package/crates/tish/tests/trycatch_runtime_errors.rs +45 -0
- package/crates/tish/tests/tty_capability.rs +43 -0
- package/crates/tish_ast/Cargo.toml +9 -0
- package/crates/tish_ast/src/ast.rs +649 -0
- package/crates/tish_ast/src/lib.rs +5 -0
- package/crates/tish_build_utils/Cargo.toml +11 -0
- package/crates/tish_build_utils/src/lib.rs +577 -0
- package/crates/tish_builtins/Cargo.toml +22 -0
- package/crates/tish_builtins/src/array.rs +803 -0
- package/crates/tish_builtins/src/collections.rs +481 -0
- package/crates/tish_builtins/src/construct.rs +199 -0
- package/crates/tish_builtins/src/date.rs +538 -0
- package/crates/tish_builtins/src/globals.rs +293 -0
- package/crates/tish_builtins/src/helpers.rs +35 -0
- package/crates/tish_builtins/src/iterator.rs +129 -0
- package/crates/tish_builtins/src/lib.rs +21 -0
- package/crates/tish_builtins/src/math.rs +89 -0
- package/crates/tish_builtins/src/number.rs +96 -0
- package/crates/tish_builtins/src/object.rs +36 -0
- package/crates/tish_builtins/src/string.rs +646 -0
- package/crates/tish_builtins/src/symbol.rs +83 -0
- package/crates/tish_builtins/src/typedarrays.rs +298 -0
- package/crates/tish_bytecode/Cargo.toml +17 -0
- package/crates/tish_bytecode/src/chunk.rs +164 -0
- package/crates/tish_bytecode/src/compiler.rs +2604 -0
- package/crates/tish_bytecode/src/encoding.rs +102 -0
- package/crates/tish_bytecode/src/lib.rs +20 -0
- package/crates/tish_bytecode/src/opcode.rs +185 -0
- package/crates/tish_bytecode/src/peephole.rs +189 -0
- package/crates/tish_bytecode/src/serialize.rs +193 -0
- package/crates/tish_bytecode/tests/break_continue_bytecode.rs +44 -0
- package/crates/tish_bytecode/tests/constant_folding.rs +84 -0
- package/crates/tish_bytecode/tests/sort_optimization.rs +31 -0
- package/crates/tish_compile/Cargo.toml +27 -0
- package/crates/tish_compile/src/check.rs +774 -0
- package/crates/tish_compile/src/codegen.rs +7317 -0
- package/crates/tish_compile/src/infer.rs +1681 -0
- package/crates/tish_compile/src/lib.rs +206 -0
- package/crates/tish_compile/src/resolve.rs +1951 -0
- package/crates/tish_compile/src/types.rs +605 -0
- package/crates/tish_compile_js/Cargo.toml +18 -0
- package/crates/tish_compile_js/examples/jsx_vdom_smoke.tish +8 -0
- package/crates/tish_compile_js/src/codegen.rs +938 -0
- package/crates/tish_compile_js/src/error.rs +20 -0
- package/crates/tish_compile_js/src/lib.rs +26 -0
- package/crates/tish_compile_js/src/tests_jsx.rs +414 -0
- package/crates/tish_compiler_wasm/Cargo.toml +21 -0
- package/crates/tish_compiler_wasm/src/lib.rs +57 -0
- package/crates/tish_compiler_wasm/src/resolve_virtual.rs +473 -0
- package/crates/tish_core/Cargo.toml +32 -0
- package/crates/tish_core/src/console_style.rs +170 -0
- package/crates/tish_core/src/json.rs +430 -0
- package/crates/tish_core/src/lib.rs +20 -0
- package/crates/tish_core/src/macros.rs +36 -0
- package/crates/tish_core/src/shape.rs +85 -0
- package/crates/tish_core/src/uri.rs +118 -0
- package/crates/tish_core/src/value.rs +1350 -0
- package/crates/tish_core/src/vmref.rs +183 -0
- package/crates/tish_cranelift/Cargo.toml +19 -0
- package/crates/tish_cranelift/src/lib.rs +43 -0
- package/crates/tish_cranelift/src/link.rs +130 -0
- package/crates/tish_cranelift/src/lower.rs +85 -0
- package/crates/tish_cranelift_runtime/Cargo.toml +26 -0
- package/crates/tish_cranelift_runtime/src/lib.rs +45 -0
- package/crates/tish_eval/Cargo.toml +51 -0
- package/crates/tish_eval/src/eval.rs +4265 -0
- package/crates/tish_eval/src/http.rs +191 -0
- package/crates/tish_eval/src/lib.rs +99 -0
- package/crates/tish_eval/src/natives.rs +551 -0
- package/crates/tish_eval/src/promise.rs +179 -0
- package/crates/tish_eval/src/regex.rs +299 -0
- package/crates/tish_eval/src/timers.rs +120 -0
- package/crates/tish_eval/src/value.rs +336 -0
- package/crates/tish_eval/src/value_convert.rs +117 -0
- package/crates/tish_ffi/Cargo.toml +26 -0
- package/crates/tish_ffi/src/lib.rs +518 -0
- package/crates/tish_ffi/tests/fixtures/testmod/Cargo.toml +18 -0
- package/crates/tish_ffi/tests/fixtures/testmod/src/lib.rs +46 -0
- package/crates/tish_ffi/tests/loader.rs +65 -0
- package/crates/tish_fmt/Cargo.toml +16 -0
- package/crates/tish_fmt/src/bin/tish-fmt.rs +41 -0
- package/crates/tish_fmt/src/lib.rs +2157 -0
- package/crates/tish_jsx_web/Cargo.toml +9 -0
- package/crates/tish_jsx_web/README.md +5 -0
- package/crates/tish_jsx_web/src/lib.rs +2 -0
- package/crates/tish_lexer/Cargo.toml +9 -0
- package/crates/tish_lexer/src/lib.rs +1104 -0
- package/crates/tish_lexer/src/token.rs +170 -0
- package/crates/tish_lint/Cargo.toml +18 -0
- package/crates/tish_lint/src/bin/tish-lint.rs +195 -0
- package/crates/tish_lint/src/lib.rs +281 -0
- package/crates/tish_llvm/Cargo.toml +13 -0
- package/crates/tish_llvm/src/lib.rs +115 -0
- package/crates/tish_lsp/Cargo.toml +25 -0
- package/crates/tish_lsp/README.md +26 -0
- package/crates/tish_lsp/src/builtin_goto.rs +362 -0
- package/crates/tish_lsp/src/import_goto.rs +564 -0
- package/crates/tish_lsp/src/main.rs +1459 -0
- package/crates/tish_native/Cargo.toml +16 -0
- package/crates/tish_native/src/build.rs +481 -0
- package/crates/tish_native/src/config.rs +48 -0
- package/crates/tish_native/src/lib.rs +416 -0
- package/crates/tish_opt/Cargo.toml +13 -0
- package/crates/tish_opt/src/lib.rs +1046 -0
- package/crates/tish_parser/Cargo.toml +11 -0
- package/crates/tish_parser/src/lib.rs +386 -0
- package/crates/tish_parser/src/parser.rs +2726 -0
- package/crates/tish_pg/Cargo.toml +34 -0
- package/crates/tish_pg/README.md +38 -0
- package/crates/tish_pg/src/error.rs +52 -0
- package/crates/tish_pg/src/lib.rs +955 -0
- package/crates/tish_resolve/Cargo.toml +13 -0
- package/crates/tish_resolve/src/lib.rs +3601 -0
- package/crates/tish_resolve/src/pos.rs +141 -0
- package/crates/tish_runtime/Cargo.toml +100 -0
- package/crates/tish_runtime/src/http.rs +1347 -0
- package/crates/tish_runtime/src/http_fetch.rs +492 -0
- package/crates/tish_runtime/src/http_hyper.rs +441 -0
- package/crates/tish_runtime/src/http_prefork.rs +189 -0
- package/crates/tish_runtime/src/lib.rs +1447 -0
- package/crates/tish_runtime/src/native_promise.rs +15 -0
- package/crates/tish_runtime/src/promise.rs +558 -0
- package/crates/tish_runtime/src/promise_io.rs +38 -0
- package/crates/tish_runtime/src/timers.rs +172 -0
- package/crates/tish_runtime/src/tty.rs +226 -0
- package/crates/tish_runtime/src/ws.rs +778 -0
- package/crates/tish_runtime/tests/fetch_readable_stream.rs +102 -0
- package/crates/tish_ui/Cargo.toml +17 -0
- package/crates/tish_ui/src/jsx.rs +692 -0
- package/crates/tish_ui/src/lib.rs +20 -0
- package/crates/tish_ui/src/runtime/hooks.rs +573 -0
- package/crates/tish_ui/src/runtime/mod.rs +183 -0
- package/crates/tish_vm/Cargo.toml +60 -0
- package/crates/tish_vm/src/jit.rs +1050 -0
- package/crates/tish_vm/src/lib.rs +41 -0
- package/crates/tish_vm/src/vm.rs +3536 -0
- package/crates/tish_vm/tests/concurrent_shared_state.rs +140 -0
- package/crates/tish_vm/tests/fixtures/or_string_cmd.tish +2 -0
- package/crates/tish_vm/tests/lexical_scope_declare.rs +34 -0
- package/crates/tish_vm/tests/peephole_jump_chain_logical_or.rs +150 -0
- package/crates/tish_wasm/Cargo.toml +15 -0
- package/crates/tish_wasm/src/lib.rs +428 -0
- package/crates/tish_wasm_runtime/Cargo.toml +37 -0
- package/crates/tish_wasm_runtime/src/gpu.rs +429 -0
- package/crates/tish_wasm_runtime/src/lib.rs +42 -0
- package/crates/tishlang_cargo_bindgen/Cargo.toml +26 -0
- package/crates/tishlang_cargo_bindgen/src/classify.rs +261 -0
- package/crates/tishlang_cargo_bindgen/src/discover.rs +125 -0
- package/crates/tishlang_cargo_bindgen/src/infer.rs +382 -0
- package/crates/tishlang_cargo_bindgen/src/lib.rs +349 -0
- package/crates/tishlang_cargo_bindgen/src/main.rs +167 -0
- package/crates/tishlang_cargo_bindgen/src/metadata.rs +117 -0
- package/justfile +276 -0
- package/package.json +2 -2
- package/platform/darwin-arm64/tish-fmt +0 -0
- package/platform/darwin-x64/tish-fmt +0 -0
- package/platform/linux-arm64/tish-fmt +0 -0
- package/platform/linux-x64/tish-fmt +0 -0
- package/platform/win32-x64/tish-fmt.exe +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "tishlang_pg"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
description = "PostgreSQL driver for the Tish native runtime — tokio-postgres + deadpool"
|
|
6
|
+
license-file = { workspace = true }
|
|
7
|
+
repository = { workspace = true }
|
|
8
|
+
|
|
9
|
+
[lib]
|
|
10
|
+
name = "tishlang_pg"
|
|
11
|
+
crate-type = ["rlib"]
|
|
12
|
+
|
|
13
|
+
[features]
|
|
14
|
+
default = ["tish-bindings"]
|
|
15
|
+
# Exposes sync `pub fn(args: &[Value]) -> Value` wrappers for the bytecode VM
|
|
16
|
+
# (`cargo:tish_pg` module URL, registered by the `tishlang` CLI when built with `pg`).
|
|
17
|
+
tish-bindings = ["dep:tishlang_runtime", "dep:once_cell", "dep:slab"]
|
|
18
|
+
|
|
19
|
+
[dependencies]
|
|
20
|
+
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
|
|
21
|
+
tokio-postgres = { version = "0.7", features = ["with-serde_json-1", "with-uuid-1", "with-chrono-0_4"] }
|
|
22
|
+
futures = "0.3"
|
|
23
|
+
deadpool = "0.12"
|
|
24
|
+
deadpool-postgres = "0.14"
|
|
25
|
+
serde = { version = "1", features = ["derive"] }
|
|
26
|
+
serde_json = "1"
|
|
27
|
+
thiserror = "1"
|
|
28
|
+
url = "2"
|
|
29
|
+
tishlang_runtime = { path = "../tish_runtime", version = ">=0.1", optional = true, features = ["send-values"] }
|
|
30
|
+
once_cell = { version = "1", optional = true }
|
|
31
|
+
slab = { version = "0.4", optional = true }
|
|
32
|
+
|
|
33
|
+
[dev-dependencies]
|
|
34
|
+
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# tishlang_pg
|
|
2
|
+
|
|
3
|
+
**PostgreSQL for Tish** — a Rust library (`rlib`) that **Tish-compiled programs** use: Tish compiles to native Rust, and this crate is a normal Rust dependency of that output, so **authors still write `.tish`**.
|
|
4
|
+
|
|
5
|
+
## What this is **not**
|
|
6
|
+
|
|
7
|
+
- **No Node.js** / no N-API in this crate
|
|
8
|
+
- No JavaScript runtime in the driver itself
|
|
9
|
+
|
|
10
|
+
## What this **is**
|
|
11
|
+
|
|
12
|
+
- **`tokio-postgres`** + **`deadpool-postgres`** for the wire protocol and pooling.
|
|
13
|
+
- A **Rust API** (`PgPool`, `PoolConfig`, `QueryResult`) plus Tish-facing bindings (`cargo:tish_pg`) used when the CLI is built with the **`pg`** feature.
|
|
14
|
+
|
|
15
|
+
## From `.tish` (npm package)
|
|
16
|
+
|
|
17
|
+
Install the scoped package and import the same surface as the standalone `tish-pg` repo used to ship:
|
|
18
|
+
|
|
19
|
+
```tish
|
|
20
|
+
import { connect, queryPrepared, prepare, close } from '@tishlang/pg'
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Requires **`tish run` / `tish build` with the `pg` feature** (included in the default `full` feature set).
|
|
24
|
+
|
|
25
|
+
## Building in this workspace
|
|
26
|
+
|
|
27
|
+
From the `tish` repo root:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
cargo build -p tishlang_pg
|
|
31
|
+
cargo test -p tishlang_pg
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
See the workspace [`justfile`](../../justfile) for common tasks.
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
Same as the parent workspace (`LICENSE` at repo root).
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
use std::error::Error as StdError;
|
|
2
|
+
use std::fmt::Write as _;
|
|
3
|
+
|
|
4
|
+
use deadpool::managed::PoolError;
|
|
5
|
+
use thiserror::Error;
|
|
6
|
+
|
|
7
|
+
/// `tokio_postgres::Error`’s [`Display`] is often just `"db error"` for server
|
|
8
|
+
/// faults; the real text lives on [`tokio_postgres::Error::as_db_error`].
|
|
9
|
+
pub fn format_pg_error(e: &tokio_postgres::Error) -> String {
|
|
10
|
+
if let Some(db) = e.as_db_error() {
|
|
11
|
+
let mut s = format!("{} [{}]", db.message(), db.code().code());
|
|
12
|
+
if let Some(d) = db.detail() {
|
|
13
|
+
let _ = write!(s, " ({})", d);
|
|
14
|
+
}
|
|
15
|
+
if let Some(h) = db.hint() {
|
|
16
|
+
let _ = write!(s, " hint: {}", h);
|
|
17
|
+
}
|
|
18
|
+
return s;
|
|
19
|
+
}
|
|
20
|
+
let mut out = e.to_string();
|
|
21
|
+
if let Some(src) = e.source() {
|
|
22
|
+
let _ = write!(out, " ({})", src);
|
|
23
|
+
}
|
|
24
|
+
out
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
pub fn format_tish_pg_error(e: &TishPgError) -> String {
|
|
28
|
+
match e {
|
|
29
|
+
TishPgError::Postgres(pg) => format_pg_error(pg),
|
|
30
|
+
TishPgError::Pool(pe) => match pe {
|
|
31
|
+
PoolError::Backend(pg) => format_pg_error(pg),
|
|
32
|
+
_ => pe.to_string(),
|
|
33
|
+
},
|
|
34
|
+
_ => e.to_string(),
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
#[derive(Debug, Error)]
|
|
39
|
+
pub enum TishPgError {
|
|
40
|
+
#[error("invalid connection string: {0}")]
|
|
41
|
+
BadConnectionString(String),
|
|
42
|
+
#[error("invalid query parameter: {0}")]
|
|
43
|
+
BadParam(String),
|
|
44
|
+
#[error("postgres: {0}")]
|
|
45
|
+
Postgres(#[from] tokio_postgres::Error),
|
|
46
|
+
#[error("pool: {0}")]
|
|
47
|
+
Pool(#[from] deadpool::managed::PoolError<tokio_postgres::Error>),
|
|
48
|
+
#[error("build pool: {0}")]
|
|
49
|
+
Build(#[from] deadpool_postgres::BuildError),
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
pub type Result<T> = std::result::Result<T, TishPgError>;
|