type

FilePack

src const class FilePack : Obj, Weblet

FilePack is an in-memory cache of multiple text files to service static resources via HTTP. It takes one or more text files and creates one compound file. The result is stored in RAM using GZIP compression. Or you can use the pack utility method to store the result to your own files/buffers.

The onGet method is used to service GET requests for the bundle. The Content-Type header is set based on file extension of files bundled. It also implictly supports ETag/Last-Modified for 304 optimization.

The core factory is the makeFiles constructor. A suite of utility methods is provided for standard bundling of Fantom JavaScrit and CSS files.

constructors

makeFiles

Construct a bundle for the given list of text files

methods

onGet

Service an HTTP GET request for this bundle file

pack

Pack multiple text files together and write to the given output stream.

toAppCssFiles

Given a set of pods return a list of CSS files that form a complete Fantom application

toAppJsFiles

Given a set of pods return a list of JavaScript files that form a complete Fantom application

toEtcJsFiles

Return the required sys etc files

toIndexPropsJsFile

Compile the indexed props database into a JavaScript file "index-props.js"

toLocaleJsFile

Compile the locale props into a JavaScript file "{locale}.js"

toMimeJsFile

Compile the mime type database into a Javascript file "mime.js"

toPodCssFiles

Map a set of pods to "/res/css/{name}.css" CSS files.

toPodJsFile

Get the standard pod JavaScript file or null if no JS code.

toPodJsFiles

Map a set of pods to "/{name}.js" JavaScript files.

toPodJsMapFile

Compile a list of pod JavaScript files into a single unified source map file.

toTimezonesJsFile

Compile the timezone database into a JavaScript file "tz.js"

toUnitsJsFile

Compile the unit database into a JavaScript file "unit.js"

Slot Details

makeFiles

src static new makeFiles(File[] files, MimeType? mimeType := null)

Construct a bundle for the given list of text files

onGet

src virtual override Void onGet()

Service an HTTP GET request for this bundle file

pack

src static OutStream pack(File[] files, OutStream out)

Pack multiple text files together and write to the given output stream. A trailing newline is automatically added if the file is missing one. Empty files are skipped. The stream is not closed. Return the given out stream.

toAppCssFiles

src static File[] toAppCssFiles(Pod[] pods)

Given a set of pods return a list of CSS files that form a complete Fantom application:

toAppJsFiles

src static File[] toAppJsFiles(Pod[] pods)

Given a set of pods return a list of JavaScript files that form a complete Fantom application:

toEtcJsFiles

src static File[] toEtcJsFiles()

Return the required sys etc files:

toIndexPropsJsFile

src static File toIndexPropsJsFile(Pod[] pods := Pod.list())

Compile the indexed props database into a JavaScript file "index-props.js"

toLocaleJsFile

src static File toLocaleJsFile(Locale locale, Pod[] pods := Pod.list())

Compile the locale props into a JavaScript file "{locale}.js"

toMimeJsFile

src static File toMimeJsFile()

Compile the mime type database into a Javascript file "mime.js"

toPodCssFiles

src static File[] toPodCssFiles(Pod[] pods)

Map a set of pods to "/res/css/{name}.css" CSS files. Ignore pods that are missing a CSS file. This method does not flatten/order the pods.

toPodJsFile

src static File? toPodJsFile(Pod pod)

Get the standard pod JavaScript file or null if no JS code. The standard location used by the Fantom JS compiler is "/{pod-name}.js"

toPodJsFiles

src static File[] toPodJsFiles(Pod[] pods)

Map a set of pods to "/{name}.js" JavaScript files. Ignore pods that are missing a JavaScript file. This method does not flatten/order the pods.

toPodJsMapFile

src static File toPodJsMapFile(File[] files, [Str:Obj]? options := null)

Compile a list of pod JavaScript files into a single unified source map file. The list of files passed to this method should match exactly the list of files used to create the corresponding JavaScript FilePack. If the file is the standard pod JS file, then we will include an offset version of "{pod}.js.map" generated by the JavaScript compiler. Otherwise if the file is another JavaScript file (such as units.js) then we just add the appropiate offset.

The sourceRoot option may be passed in to replace "/dev/{podName}" as the root URI used to fetch source files from the server.

toTimezonesJsFile

src @Deprecated { msg=... }
static File toTimezonesJsFile()

Compile the timezone database into a JavaScript file "tz.js"

toUnitsJsFile

src static File toUnitsJsFile()

Compile the unit database into a JavaScript file "unit.js"