Documentation
¶
Overview ¶
Package source resolves an authorized extension path into one conventional factory or exact isolated standalone definition.
Index ¶
- Constants
- func EnableLisp()
- func IsGoSDKModulePath(path string) bool
- func NodeDeclaresExtensions(dir string) bool
- func NodeDirectoryEntries(dir string) []string
- func NodeDirectoryImport(dir string) (file string, ok bool)
- func NodeManifestEntries(root string) (entries, missing []string, declared bool, err error)
- func NodeRootEntries(dir string) []string
- type Definition
- type Form
- type ResolveFunc
- type UnknownFileExtensionError
Constants ¶
const GoSDKModulePath = "github.com/MichaelKinsy/PiG/extensions/sdk"
GoSDKModulePath is the Go SDK module path that current Pig scaffolds import.
const LegacyGoSDKModulePath = "github.com/mainstai/pig/extensions/sdk"
LegacyGoSDKModulePath is the module path the same Go SDK carried in Pig 0.84 and earlier. Factories written against it stay loadable: generated runners alias it to the current SDK source, so the extension compiles against the SDK that speaks the running host's protocol.
Variables ¶
This section is empty.
Functions ¶
func EnableLisp ¶
func EnableLisp()
EnableLisp makes Resolve classify Lisp extension roots and files.
func IsGoSDKModulePath ¶
IsGoSDKModulePath reports whether path names the Go SDK module under its current or legacy module path.
func NodeDeclaresExtensions ¶
NodeDeclaresExtensions reports whether dir's package.json has a "pi" manifest with a non-empty "pi.extensions" list. Upstream loads only what such a manifest names.
func NodeDirectoryEntries ¶
NodeDirectoryEntries returns the extension entry files in dir as upstream Pi's collectAutoExtensionEntries (core/package-manager.ts) does: the entries dir's own package.json "pi.extensions" declares when any exist, else dir/index.ts, else dir/index.js; otherwise every .ts and .js file in dir and the entry of every subdirectory that has one, skipping hidden entries, node_modules, and paths excluded by dir's .gitignore, .ignore, or .fdignore. A directory with none of these has no entries.
func NodeDirectoryImport ¶
NodeDirectoryImport returns the file upstream's jiti import of the directory dir loads: <dir><ext>, then <dir>/index<ext> over jiti's extensions, then require.resolve's package.json "main" (the file, then with .js, .json or .node, then its index.js, index.json or index.node), then dir's index.js, index.json or index.node. ok is false when none exists.
func NodeManifestEntries ¶
NodeManifestEntries returns the extension entry files a Node package's package.json "pi.extensions" names, in declaration order, as upstream Pi's package manager collects them (collectFilesFromManifestEntries in core/package-manager.ts): a file entry is itself, a directory entry expands with NodeDirectoryEntries, and an entry that does not exist is reported in missing. declared is false when package.json has no non-empty "pi.extensions".
func NodeRootEntries ¶
NodeRootEntries is upstream's resolveExtensionEntries (core/package-manager.ts): the existing entries dir's package.json "pi.extensions" declares, else index.ts, else index.js, else nil. Declared entries are returned as declared, without expanding a directory among them, as upstream does.
Types ¶
type Definition ¶
type Definition struct {
Language string
Form Form
Root string
Entrypoint string
ModulePath string
Package string
Factory string
Packable bool
GoWorkspaceModules []string
// SDKModulePath is the Go SDK module path a Go factory imports.
SDKModulePath string
}
Definition is the complete runtime input derived from one authorized source.
func Resolve ¶
func Resolve(input string) (Definition, error)
Resolve classifies one exact source path without reading any extension metadata file.
type ResolveFunc ¶
type ResolveFunc func(string) (Definition, error)
ResolveFunc classifies one exact extension source path. Callers that own a bounded resolution snapshot use it to share one source scan across startup validation, discovery, trust, and loading.
type UnknownFileExtensionError ¶
UnknownFileExtensionError is a non-executable file whose extension Node has no loader for. Its message is Node's ERR_UNKNOWN_FILE_EXTENSION, which upstream's loader reports for such a file.
func (*UnknownFileExtensionError) Error ¶
func (e *UnknownFileExtensionError) Error() string