Skip to content

Vendor

module Vendor
AssemblyNacara.Plugin.LiveExample
Attributes[<RequireQualifiedAccess>]

The compiler a live snippet runs on, and where a site gets it.

Three npm packages, fetched once per machine by Tool and copied into the site: the Fable compiler built for the browser, the assemblies it type-checks against, and - when snippets colour with tree-sitter - the browser build of tree-sitter.

Emitted into the output rather than loaded from a CDN, so a site works offline and behind a proxy.

Declared inside

LayoutWhere a build of the compiler, its references and a precompiled library are served from, each relative to Directory
PrecompiledWhat the build knows about a precompiled library, for the browser to be told

Functions and values

AssemblySuffix: string

The suffix put on every assembly the type-checker downloads.

GitHub Pages compresses by content type and will not compress a .dll - 6.9 MB uncompressed to anyone who presses Run. Named .dll.txt it is compressed like text, and the worker takes the suffix through refsExtraSuffix.

Default: FableRelease

The pair this plugin was built and tried against.

Directory: string

Where a site keeps all of this.

MetadataVersion: string
StandaloneVersion: string

Pinned, so a site built today builds the same tomorrow.

TreeSitterPath: string

Where the highlighting plugin's browser files are, relative to this one's.

The two plugins emit side by side and the grammars are shared, so a site that colours its snippets and its blocks with tree-sitter ships one copy of each.

agrees (browser: string option) (modules: string) : Result<unit,string>

Whether the Fable that precompiled a library is the one that will read it.

A precompiled library is only readable by the Fable that wrote it. The worker enforces that by answering CreateChecker with a bare LoadFailed, which reaches a reader as a snippet that never answers and says nothing about why - so it is worth knowing here, where there is still a build to say it in and a slower way to carry on.

Parameter
browserWhat the compiler in the browser is, when it says.
modulesThe fable_modules directory a precompile produced.
assets (release: FableRelease) (tag: string option) : Result<(Asset list * Layout * string option),string>

The compiler and what it checks against, as assets to emit.

Colouring is the highlighting plugin's: see browserAssetsWith for the grammars a snippet is coloured with.

Parameter
releaseWhich build of the compiler to fetch.
tagWhat the precompiled library is, when the site built one.

Returns. The assets, where all of it went, and the Fable this build of the compiler was made with - or the first reason one could not be had.

fableVersion (release: FableRelease) : string option

The Fable the compiler in the browser was built from.

Read before anything is compiled, which is what lets the same Fable be fetched to do the compiling. None when the package does not say, which is every build of it before fable-standalone 3.1.0.

Parameter
releaseWhich build of the compiler the site asked for.
layout (standalone: string) (metadata: string) (tag: string option) : Layout

Where each of those goes, for these versions and this library.

Parameter
standaloneThe version of fable-standalone in hand.
metadataThe version of fable-metadata in hand.
tagWhat the precompiled library is, when there is one.
metadataOf (version: string) : ToolRequest
precompileProject (projectRoot: AbsolutePath) (cli: FableCli) (project: string) : Result<string,string>

Precompile a project a site wrote, with everything it references.

Rebuilt when anything in it changes, and otherwise read from the last time.

Parameter
projectRootThe root of the site being built, where the output is kept.
cliWhich Fable to run it with.
projectThe .fsproj to compile.
precompileTag (modules: string) : string

What a precompile produced, as a short hash of it.

Parameter
modulesThe fable_modules directory a precompile produced.
precompiledAssets (layout: Layout) (modules: string) : Asset list

The precompiled library, as files to emit.

The assembly goes in with the ones the checker already reads, because that is where the worker looks for it. The JavaScript keeps the shape it was written in, so the relative imports inside it resolve on their own - except for the copy of fable-library it came with, which is dropped in favour of the compiler's: they are the same files, and the worker will not load a library built by a different Fable, so they cannot drift apart.

Parameter
layoutWhere this build of the compiler and library are served from.
modulesThe fable_modules directory a precompile produced.
precompiledInfo (modules: string) : Precompiled

Read what fable precompile recorded.

OutPath is where the compiled file was written on this machine; it is kept relative to the output so the browser can be told where the site serves it. Path is left exactly as it is: Fable matches a source file on it rather than reading from it.

Parameter
modulesThe fable_modules directory a precompile produced.
resolve (release: FableRelease) : string * string

The two versions to fetch, and how they were arrived at.

Parameter
releaseWhat the site asked for.
standaloneOf (version: string) : ToolRequest