@sanbus/galley-node 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/README.md +7 -0
- package/build.mjs +36 -0
- package/dist/dispatch.d.ts +14 -0
- package/dist/dispatch.js +146 -0
- package/dist/dispatch.js.map +1 -0
- package/dist/ffi.d.ts +268 -0
- package/dist/ffi.js +842 -0
- package/dist/ffi.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -0
- package/dist/session.d.ts +13 -0
- package/dist/session.js +25 -0
- package/dist/session.js.map +1 -0
- package/package.json +49 -0
- package/src/dispatch.ts +147 -0
- package/src/ffi.ts +1498 -0
- package/src/index.ts +79 -0
- package/src/session.ts +28 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Galley JavaScript bindings for Node — public surface.
|
|
3
|
+
*
|
|
4
|
+
* Binds the runtime-neutral `@sanbus/galley-core` to the koffi port. Mirrors the
|
|
5
|
+
* layout of `bindings/python/galley.pyi` and the C header
|
|
6
|
+
* `bindings/c/galley.h`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { getNodePort, 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 { getNodePort, 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 getNodePort().version();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function parserType(): number {
|
|
25
|
+
return getNodePort().parserType();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function errorRecoveryMode(): number {
|
|
29
|
+
return getNodePort().errorRecoveryMode();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function hasAst(): boolean {
|
|
33
|
+
return getNodePort().hasAst();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function hasProcedures(): boolean {
|
|
37
|
+
return getNodePort().hasProcedures();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function allowsNoAstTreeProcedures(): boolean {
|
|
41
|
+
return getNodePort().allowsNoAstTreeProcedures();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function sourceRetentionEnabled(): boolean {
|
|
45
|
+
return getNodePort().sourceRetentionEnabled();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function hasPositionTracking(): boolean {
|
|
49
|
+
return getNodePort().hasPositionTracking();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function hasInputStreaming(): boolean {
|
|
53
|
+
return getNodePort().hasInputStreaming();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function usesVerbatim(): boolean {
|
|
57
|
+
return getNodePort().usesVerbatim();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function stackOverflowRecoveryAvailable(): boolean {
|
|
61
|
+
return getNodePort().stackOverflowRecoveryAvailable();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function symbolCount(): number {
|
|
65
|
+
return getNodePort().symbolCount();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function variableCount(): number {
|
|
69
|
+
return getNodePort().variableCount();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function statusString(status: number): string | null {
|
|
73
|
+
return getNodePort().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,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node `Session`: the core session bound to the koffi port.
|
|
3
|
+
*
|
|
4
|
+
* Installs the host-procedure dispatch for the session's library (mirrors
|
|
5
|
+
* Python'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 { getNodePort } 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 = getNodePort(options.libraryPath);
|
|
19
|
+
// Ensure host-procedure dispatch is installed for this library even if
|
|
20
|
+
// the first Session is created before any installProcedure call.
|
|
21
|
+
try {
|
|
22
|
+
ensureDispatchFor(port.ffi, port);
|
|
23
|
+
} catch {
|
|
24
|
+
// installer missing (C build) — ignore.
|
|
25
|
+
}
|
|
26
|
+
super(port, options);
|
|
27
|
+
}
|
|
28
|
+
}
|