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