-
Notifications
You must be signed in to change notification settings - Fork 36
Home
js.io is a package management and module system for JavaScript. js.io modules can be evaluated in a JavaScript runtime (e.g. node.js) or precompiled into a single package for use on the client side.
js.io provides the following:
- A module system.
- Dependency graph that works in the client and the browser.
- Support and networking libraries that can be used on either platform.
See also:
js.io can be invoked as a compiler or a runtime.
To compile a js.io module, invoke from the command line:
jsio_compile module.path
Imports are preprocessed when the script is first compiled. Imports are located at the top of your scripts.
import path.module
import .relative.module
Gets evaluated at compilation time to resolve dynamic imports. Any folder that contains a non-dynamic import is checked at compile time for an __imports__.js
module, and, if found, the compiler runs the resolve
function.
exports.resolve = function (env, opts) { ... };
resolve
returns an array of imports (strings) to be compiled by the compiler. env
is the environment passed into jsio_compile
and opts
contains the full compiler options.
The following packages are provided by default in js.io:
-
$(string selector[, window]) — Selects an array of objects that match the given selector.
-
$(HTMLElement element) — Alias for
$.remove(element)
. -
$(object spec) — Alias for
$.create(spec)
. -
$(window window) — Alias for
$.size(window)
. -
$.id(string id[, window]) — Returns an element matching the given id.
-
$.id(HTMLElement element) — Identity function. Useful for accepting an id or element as an argument.
-
$.apply(HTMLElement element, object spec) — From the
spec
object, the following options can be applied:id
style
src
-
class
/className
-
parent
/parentNode
, and optionallyfirst
,before
,after
for its position html
text
children
first
-
$.isElement(object element) — Returns true if the given object is an element.
-
$.insertBefore(HTMLElement parentNode, HTMLElement element[, HTMLElement nextSibling]) — Inserts an element, before an optional element.
-
$.insertAfter(HTMLElement parentNode, HTMLElement element[, HTMLElement previousSibling]) — Inserts an element, after an optional element.
-
$.create(object spec) — Creates an element of the tag name
tag
, then calls $.apply() on the element with the givenspec
. -
$.show(HTMLElement element[, string display = "block"]) — Unhides an element, setting its display style to the optional
display
property. -
$.hide(HTMLElement element) — Hides an element by setting its display property to
none
. -
$.addClass(HTMLElement, (array classNames|string classNames)) — Sets a class or classes on an element.
-
$.getTag(HTMLElement ancestor, string tagName) — Gets all elements with the given
tagName
which descend from theancestor
. -
$.removeClass(HTMLElement element, (array classNames|string classNames)) — Removes the
classNames
from the element. -
$.style(HTMLElement element, object css) — Sets the style of the
element
according to the givencss
object. -
$.onEvent(HTMLElement element, string name, function callback) — Attaches an event listener to the
element
for the given event. Thethis
property of the callback will be assigned to the global context. -
$.removeEvent(HTMLElement element, string name, function callback) — Removes an event listener from an element.
-
$.stopEvent(Event event) — Stops an
event
object from propagating or performing the default action in the document. -
$.setText(HTMLElement element, string text) — Sets the text of the given
element
. -
$.setValue(HTMLElement element, string value) — Sets the
value
of the givenelement
or the first child of theelement
. -
$.remove(HTMLElement element) — Removes the
element
from its parent node. -
$.cursorPos(ClickEvent event, HTMLElement element) — Returns the cursor position relative to the origin coordinate of the page for the given click
event
. -
$.pos(HTMLElement element) — Returns the offset of the
element
from the origin coordinate of the page. -
$.size(HTMLElement element) — Returns an object with the dimensions of the element.
-
$.size(Window window) — Returns an object with the dimensions and position of the window relative to the document origin.
-
$.insertCSSFile(string url) — Inserts a new stylesheet to the page with the given URL.
MIT licensed.