@sanbus/galley-bun 0.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/src/index.ts ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Galley JavaScript bindings for Bun — public surface.
3
+ *
4
+ * Binds the runtime-neutral `@sanbus/galley-core` to the `bun:ffi` port. Mirrors
5
+ * the layout of `bindings/python/galley.pyi` and the C header
6
+ * `bindings/c/galley.h`.
7
+ */
8
+
9
+ import { getBunPort, findLibrary } from "./ffi.ts";
10
+ import { Session } from "./session.ts";
11
+
12
+ // Core surface (Session base is shadowed by the adapter subclass below).
13
+ export * from "@sanbus/galley-core";
14
+ export { Session };
15
+ export { findLibrary };
16
+ export { getBunPort, libFileName } from "./ffi.ts";
17
+ export type { SessionOptions, WalkStep, Diagnostic, TreeSnapshot } from "@sanbus/galley-core";
18
+
19
+ // Module-level queries (mirror galley.h)
20
+ export function version(): string {
21
+ return getBunPort().version();
22
+ }
23
+
24
+ export function parserType(): number {
25
+ return getBunPort().parserType();
26
+ }
27
+
28
+ export function errorRecoveryMode(): number {
29
+ return getBunPort().errorRecoveryMode();
30
+ }
31
+
32
+ export function hasAst(): boolean {
33
+ return getBunPort().hasAst();
34
+ }
35
+
36
+ export function hasProcedures(): boolean {
37
+ return getBunPort().hasProcedures();
38
+ }
39
+
40
+ export function allowsNoAstTreeProcedures(): boolean {
41
+ return getBunPort().allowsNoAstTreeProcedures();
42
+ }
43
+
44
+ export function sourceRetentionEnabled(): boolean {
45
+ return getBunPort().sourceRetentionEnabled();
46
+ }
47
+
48
+ export function hasPositionTracking(): boolean {
49
+ return getBunPort().hasPositionTracking();
50
+ }
51
+
52
+ export function hasInputStreaming(): boolean {
53
+ return getBunPort().hasInputStreaming();
54
+ }
55
+
56
+ export function usesVerbatim(): boolean {
57
+ return getBunPort().usesVerbatim();
58
+ }
59
+
60
+ export function stackOverflowRecoveryAvailable(): boolean {
61
+ return getBunPort().stackOverflowRecoveryAvailable();
62
+ }
63
+
64
+ export function symbolCount(): number {
65
+ return getBunPort().symbolCount();
66
+ }
67
+
68
+ export function variableCount(): number {
69
+ return getBunPort().variableCount();
70
+ }
71
+
72
+ export function statusString(status: number): string | null {
73
+ return getBunPort().statusString(status);
74
+ }
75
+
76
+ // Preserve original Python naming aliases for docs parity
77
+ export const has_ast = hasAst;
78
+ export const has_procedures = hasProcedures;
79
+ export const has_position_tracking = hasPositionTracking;
package/src/session.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Bun `Session`: the core session bound to the `bun:ffi` port.
3
+ *
4
+ * Installs the host-procedure dispatch for the session's library (mirrors
5
+ * Node's import-time shim setup); the installer is a no-op for libraries
6
+ * built for C procedures.
7
+ */
8
+
9
+ import { Session as CoreSession } from "@sanbus/galley-core";
10
+ import type { SessionOptions } from "@sanbus/galley-core";
11
+ import { getBunPort } from "./ffi.ts";
12
+ import { ensureDispatchFor } from "./dispatch.ts";
13
+
14
+ export type { SessionOptions };
15
+
16
+ export class Session extends CoreSession {
17
+ constructor(options: SessionOptions = {}) {
18
+ const port = getBunPort(options.libraryPath);
19
+ try {
20
+ ensureDispatchFor(port);
21
+ } catch {
22
+ // installer missing (C build) — ignore.
23
+ }
24
+ super(port, options);
25
+ }
26
+ }