compiler

@hlang-org/compiler

Ahead-of-time compiler for hlang: compiles an IGraph program into a standalone ES module. Version 2.0.1, 9 exports.

Classes

CompileError

Defined in: packages/compiler/src/errors.ts:8

Thrown by compile for problems specific to code generation. Problems with the graph itself surface as GraphError from @hlang-org/ir.

Extends

  • Error

Constructors

Constructor
TypeScript
new CompileError(code, message): CompileError;

Defined in: packages/compiler/src/errors.ts:11

Parameters
ParameterType
codeCompileErrorCode
messagestring
Returns

CompileError

Overrides

Error.constructor

Properties

PropertyModifierTypeDefined in
codereadonlyCompileErrorCodepackages/compiler/src/errors.ts:9

GraphError

Defined in: packages/ir/lib/index.d.ts:136

Thrown by planGraph when a graph violates hlang's rules.

Extends

  • Error

Constructors

Constructor
TypeScript
new GraphError(code, message): GraphError;

Defined in: packages/ir/lib/index.d.ts:138

Parameters
ParameterType
codeGraphErrorCode
messagestring
Returns

GraphError

Overrides

Error.constructor

Properties

PropertyModifierTypeDefined in
codereadonlyGraphErrorCodepackages/ir/lib/index.d.ts:137

Interfaces

CompileOptions

Defined in: packages/compiler/src/compile.ts:47

Options for compile.

Properties

PropertyModifierTypeDescriptionDefined in
nodesreadonlyReadonly<Record<string, NodeImport>>The import for every node code used by the graph.packages/compiler/src/compile.ts:49
runtime?readonlystringModule that exports the runtime Flow. Defaults to @hlang-org/runtime.packages/compiler/src/compile.ts:51
rxjs?readonlystringModule that exports RxJS Subject, used for the stop signal. Defaults to rxjs.packages/compiler/src/compile.ts:53

CompileResult

Defined in: packages/compiler/src/compile.ts:57

The compiled program.

Properties

PropertyModifierTypeDescriptionDefined in
codereadonlystringES module source. Exports run(options?).packages/compiler/src/compile.ts:59
importsreadonlyreadonly string[]Every module specifier the program imports, in import order.packages/compiler/src/compile.ts:61

IGraph

Defined in: packages/ir/lib/index.d.ts:88

The complete serialized graph.

Properties

PropertyModifierTypeDefined in
connectionsreadonlyreadonly IConnection[]packages/ir/lib/index.d.ts:90
deps?readonlyreadonly IPackageInfo[]packages/ir/lib/index.d.ts:89
nodeListreadonlyreadonly INodeInfo[]packages/ir/lib/index.d.ts:91

NodeImport

Defined in: packages/compiler/src/compile.ts:39

Where a node class comes from: an ES module and one of its exports.

Properties

PropertyModifierTypeDescriptionDefined in
fromreadonlystringModule specifier written into the generated import (package name, path, or URL).packages/compiler/src/compile.ts:41
name?readonlystringExport name. Defaults to the module's default export.packages/compiler/src/compile.ts:43

Type Aliases

CompileErrorCode

TypeScript
type CompileErrorCode = "unresolved-node" | "invalid-import" | "unserializable-config";

Defined in: packages/compiler/src/errors.ts:2

Machine-readable reasons compile rejects its input.


GraphErrorCode

TypeScript
type GraphErrorCode = 
  | "duplicate-node-id"
  | "invalid-node-kind"
  | "unknown-node"
  | "invalid-connection"
  | "no-readable-root";

Defined in: packages/ir/lib/index.d.ts:134

Machine-readable reasons a graph cannot be planned.

Functions

compile()

TypeScript
function compile(graph, options): CompileResult;

Defined in: packages/compiler/src/compile.ts:70

Compile graph to an ES module. Throws GraphError or CompileError.

Parameters

ParameterType
graphIGraph
optionsCompileOptions

Returns

CompileResult

Generated by TypeDoc from packages/compiler/src at build time.