codegen.ts

Declarations
#

5 declarations

view source

create_banner
#

codegen.ts view source

(origin_path: string): string

Creates a file banner comment.

origin_path

type string

returns

string

generate_phase_handlers
#

codegen.ts view source

(spec: { method: "completion_create" | "completion_progress" | "directory_create" | "diskfile_delete" | "diskfile_update" | "filer_change" | "ollama_copy" | "ollama_create" | ... 11 more ... | "toggle_main_menu"; ... 6 more ...; async: true; } | { ...; } | { ...; }, executor: "frontend" | "backend", imports: ImportBuilder): string

Generates the phase handlers for an action spec using the unified ActionEvent type with the new phase/step type parameters.

spec

type { method: "completion_create" | "completion_progress" | "directory_create" | "diskfile_delete" | "diskfile_update" | "filer_change" | "ollama_copy" | "ollama_create" | "ollama_delete" | ... 10 more ... | "toggle_main_menu"; ... 6 more ...; async: true; } | { ...; } | { ...; }

executor

type "frontend" | "backend"

imports

returns

string

get_executor_phases
#

codegen.ts view source

(spec: { method: "completion_create" | "completion_progress" | "directory_create" | "diskfile_delete" | "diskfile_update" | "filer_change" | "ollama_copy" | "ollama_create" | ... 11 more ... | "toggle_main_menu"; ... 6 more ...; async: true; } | { ...; } | { ...; }, executor: "frontend" | "backend"): ("send_request" | ... 7 more ... | "execute")[]

Determines which phases an executor can handle based on the action spec.

spec

type { method: "completion_create" | "completion_progress" | "directory_create" | "diskfile_delete" | "diskfile_update" | "filer_change" | "ollama_copy" | "ollama_create" | "ollama_delete" | ... 10 more ... | "toggle_main_menu"; ... 6 more ...; async: true; } | { ...; } | { ...; }

executor

type "frontend" | "backend"

returns

("send_request" | "receive_request" | "send_response" | "receive_response" | "send_error" | "receive_error" | "send" | "receive" | "execute")[]

get_handler_return_type
#

codegen.ts view source

(spec: { method: "completion_create" | "completion_progress" | "directory_create" | "diskfile_delete" | "diskfile_update" | "filer_change" | "ollama_copy" | "ollama_create" | ... 11 more ... | "toggle_main_menu"; ... 6 more ...; async: true; } | { ...; } | { ...; }, phase: "send_request" | ... 7 more ... | "execute", imports: ImportBuilder, path_prefix: string): string

Gets the handler return type for a specific phase and spec. Also adds necessary imports to the ImportBuilder.

spec

type { method: "completion_create" | "completion_progress" | "directory_create" | "diskfile_delete" | "diskfile_update" | "filer_change" | "ollama_copy" | "ollama_create" | "ollama_delete" | ... 10 more ... | "toggle_main_menu"; ... 6 more ...; async: true; } | { ...; } | { ...; }

phase

type "send_request" | "receive_request" | "send_response" | "receive_response" | "send_error" | "receive_error" | "send" | "receive" | "execute"

imports

path_prefix

type string

returns

string

ImportBuilder
#

codegen.ts view source

Manages imports for generated code, building them on demand. Automatically optimizes type-only imports to use import type syntax.

Why this matters: - import type statements are completely removed during compilation - Mixed imports like import { type A, B } cannot be safely removed - This ensures optimal tree-shaking and smaller bundle sizes

examples

Example 1

imports

type Map<string, Map<string, ImportItem>>

add

Add a value import to be included in the generated code.

type (from: string, what: string): this

from

The module to import from

type string
what

What to import (value)

type string
returns this

add_type

Add a type import to be included in the generated code.

type (from: string, what: string): this

from

The module to import from

type string
what

What to import (type)

type string
returns this

add_many

Add multiple value imports from the same module.

type (from: string, ...items: string[]): this

from
type string
items
type string[]
returns this

add_types

Add multiple type imports from the same module.

type (from: string, ...items: string[]): this

from
type string
items
type string[]
returns this

build

Generate the import statements. If all imports from a module are types, uses import type syntax.

type (): string

returns string

has_imports

Check if the builder has any imports.

type (): boolean

returns boolean

preview

Preview what imports will be generated (useful for debugging).

type (): string[]

returns string[]

Array of import statement strings

clear

Clear all imports.

type (): this

returns this

Depends on
#

Imported by
#