makeDependency: Process Javascript for HTML dependency.

Description Usage Arguments Details Value Author(s) Examples

View source: R/rglwidget.R

Description

A utility function to help in development of internal Javascript code, this function processes the Javascript to minify it and report on errors and bad style.

Usage

1
2
3
4
makeDependency(name, src, script = NULL, package, 
               version = packageVersion(package),
               minifile = paste0(basename(src), ".min.js"),
               debugging = FALSE, ...)

Arguments

name, src, script, package, version, ...

Arguments to pass to htmltools::htmlDependency.

minifile

Basename of minified file.

debugging

See details below.

Details

This is a utility function used by rgl to process its Javascript code used when displaying rglwidget values. It may be helpful in other packages to use in their own installation.

If the js package version 1.2 or greater is installed, the Javascript code will be minified and stored in the file named by minifile in the src directory. Syntax errors in the code will stop the process; unused variables will be reported.

If debugging is TRUE, the locations of Javascript syntax errors will be reported, along with hints about improvements, and the original files will be used in the dependency object that is created.

If debugging is FALSE (the default), the minified file will be used in the dependency object, hints won't be given, and syntax errors will lead to an uninformative failure to minify.

Value

An object that can be included in a list of dependencies passed to htmltools::attachDependencies.

Author(s)

Duncan Murdoch

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# This is the code used to produce one of the dependencies
# for rglwidget().  
# It writes to the system library copy of rgl so 
# has been marked not to run in the example code.

## Not run: 
makeDependency("rglwidgetClass", 
    src = "htmlwidgets/lib/rglClass",
    script = c("rglClass.src.js",
               "utils.src.js",
               "subscenes.src.js",
               "shaders.src.js",
               "textures.src.js",
               "projection.src.js",
               "mouse.src.js",
               "init.src.js",
               "pieces.src.js",
               "draw.src.js",
               "controls.src.js",
               "selection.src.js",
               "rglTimer.src.js"),
    stylesheet = "rgl.css",
    package = "rgl",
    debugging = nchar(Sys.getenv("RGL_DEBUGGING", "")) > 0)

## End(Not run)

rgl documentation built on Feb. 1, 2021, 3:01 a.m.