Teloce-Py Integration Contracts
Verified against the indexed Teloce-Py reference repository with Xerj.
Public APIs
compile(source: str, filename: str = "<input>") -> dictcompiles in-memory.velsource.compile_file(filepath: str | Path, **options) -> dictcompiles a file from disk.build_project(root_dir, out_dir=None, options=None) -> dictbuilds a project and raisesRuntimeErrorwhen the result contains failed components.
Build and runtime layout
- Authored components live under
static/and are emitted underdist/static/. - The standard shared runtime is emitted as
dist/static/teloce-runtime.js(hashed in production builds). - Generated component modules import the shared runtime.
- The HTML shell mounts a generated module with
mount("#app"). teloce.config.jsonusesbuild.out_dir,build.static_dir, andbuild.shared_runtime;build.cleanmay remove the entiredist/tree before rebuilding.
Teloce-NPM bridge
- Teloce-NPM keeps its public default output at
dist/static/teloce-npmand derives/static/teloce-npmas its URL path. - For the standard layout, installation also mirrors generated npm assets to
static/teloce-npm. Teloce-Py then copies them into the cleaneddist/static/teloce-npmdirectory. - Set Teloce-Py's
build.hash_assetstofalsefor projects using the injected npm runtime. The generated loader intentionally requests stableloader.js,use.js, andmanifest.jsonURLs; hashing those files would make the injected URLs return 404. - Runtime injection remains framework-agnostic and adds
loader.jsanduse.jsunder the derived static URL. The entry HTML must still mount the Teloce-Py component at#app. Use <package> from teloce-npmdeclarations are discovered by Teloce-NPM's scanner; Teloce-Py can compile the component source independently.- MinifyJS is a core Teloce-NPM dependency.
bundling.modedefaults toauto: Tree-sitter is attempted first and the esbuild-backed MinifyJS backend is used when the static wrapper cannot process a package. Setmodetoalwaysfor libraries with complex JavaScript module graphs. - Lockfiles record the actual relative output path, including nested MinifyJS bundle paths.
Teloce-NPM preprocesses CSS imports in Python, inlines local font assets as data URLs, copies worker bundles, and records worker URLs in the package manifest before invoking MinifyJS. The generated loader exposes generic worker metadata and automatically configures MonacoEnvironment.getWorkerUrl when monaco-editor is loaded. pdfjs-dist and monaco-editor both install and build with their emitted runtime assets available under the package output directory.
Fixes applied
- Corrected SemVer 3.x validation and added npm-style range matching:
*,^,~, partial versions (3,3.x), comparators, hyphen ranges,||unions and dist-tags. - Implemented the missing
teloce-npm cleancommand. - Preserved bundled output paths across lockfile writes and cache restores.
- Mirrored standard npm assets into Teloce-Py's source static tree so
build.cleandoes not delete the integration.
Build scanning
build_project() takes its options from the call, not from teloce.config.json (the teloce build command does read the file). Teloce-Py scans the project folder for components and TypeScript unless static_dir or source_roots narrows it, and that includes .teloce-npm/. Always pass "static_dir": "static" (see HTML components).