Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
@swim Add additional downlink documentation to @swim/client README Aug 15, 2019
bin
.gitignore git subrepo pull swim-system-js Aug 11, 2019
.gitrepo git subrepo commit (merge) swim-system-js Jul 22, 2019
LICENSE Migrate to swim-system-java and swim-system-js integration repos Jul 16, 2019
README.md Add documentation to @swim/client README Aug 15, 2019
build.config.js git subrepo pull swim-system-js Aug 11, 2019
package.json git subrepo pull swim-system-js Aug 11, 2019
tsconfig-main.json Migrate to swim-system-java and swim-system-js integration repos Jul 16, 2019
tsconfig-test.json Migrate to swim-system-java and swim-system-js integration repos Jul 16, 2019
tsconfig.json Migrate to swim-system-java and swim-system-js integration repos Jul 16, 2019
tslint.json Migrate to swim-system-java and swim-system-js integration repos Jul 16, 2019

README.md

Swim Mesh Framework

package documentation chat

The Swim mesh framework implements a multiplexed streaming WARP client that runs in both Node.js and web browsers. Swim Mesh can be used in concert with the @swim/ui and @swim/ux user interface toolkits to build massively real-time streaming applications. Swim Mesh is part of the broader Swim System framework.

Libraries

The Swim mesh framework consists of the following component libraries:

  • @swim/mesh – umbrella package that depends on, and re-exports, all Swim Mesh libraries.
  • @swim/warp – WebSocket protocol for dynamically multiplexing large numbers of bidirectional links to streaming APIs, called lanes, of URI-addressed distributed objects, called nodes, that run stateful distributed processes, called Web Agents.
  • @swim/client – streaming API client for linking to lanes of stateful Web Agents using the WARP protocol, enabling massively real-time applications that continuously synchronize all shared states with ping latency.
  • @swim/cli – command line client for linking to Web Agent lanes over the WARP protocol.

Swim Mesh builds on the Swim Core framework; it has no additional dependencies when run in a web browser, and depends only on a WebSocket implementation when run in Node.js.

Installation

npm

For an npm-managed project, npm install @swim/mesh to make it a dependency. TypeScript sources will be installed into node_modules/@swim/mesh/main. Transpiled JavaScript and TypeScript definition files install into node_modules/@swim/mesh/lib/main. And a pre-built UMD script, which bundles all @swim/mesh component libraries, can be found in node_modules/@swim/mesh/dist/main/swim-mesh.js.

Browser

Browser applications can load swim-mesh.js, along with its swim-core.js dependency, from the Swim CDN.

<script src="https://cdn.swim.ai/js/latest/swim-core.js"></script>
<script src="https://cdn.swim.ai/js/latest/swim-mesh.js"></script>

Alternatively, the standalone swim-system.js script may be loaded from the Swim CDN, which bundles @swim/mesh along with all other @swim/system frameworks.

<script src="https://cdn.swim.ai/js/latest/swim-system.js"></script>

Usage

ES6/TypeScript

@swim/mesh can be imported as an ES6 module from TypeScript and other ES6-compatible environments. All component libraries are re-exported, in their entirety, from the top-level @swim/mesh namespace.

import * as swim from "@swim/mesh";

CommonJS/Node.js

@swim/mesh can also be used as a CommonJS module in Node.js applications. All component libraries are re-exported by the umbrella @swim/mesh module.

var swim = require("@swim/mesh");

Browser

When loaded by a web browser, the swim-mesh.js script adds all component library exports to the global swim namespace. The swim-mesh.js script requires that swim-core.js has already been loaded.

The swim-system.js script also adds all @swim/mesh component library exports to the global swim namespace, making it a drop-in replacement for swim-mesh.js when additional @swim/system frameworks are needed.

Development

Note: swim-mesh-js can be built against the currently checked out swim-core-js sources by compiling it from the parent swim-system-js directory.

Setup

Install build dependencies:

swim-mesh-js $ npm install

Build script

Use the bin/build.js script to build the Swim Mesh framework. The build script supports compile, test, doc, and watch commands, described below. All build script commands take an optional --projects (-p) option to restrict the build to a comma-separated list of projects.

Each project supports multiple output targets; typical targets for a project include main, to build the main sources, and test, to build the test sources. A specific target can be built for a project by appending a colon (:) and the target name to the project name. For example, to build just the main sources of the util project, pass -p util:main to the build script.

Most build commands take a --devel (-d) option to expedite development builds by skipping the minification step.

Run bin/build.js help to see a complete list of build commands. Run bin/build.js <command> --help to see a list of options supported by a particular build command.

Compiling sources

Use the compile build script command to compile, bundle, and minify TypeScript sources into JavaScript universal module definitions, output to the dist subdirectory of each project. To compile all targets, of all projects, run:

swim-mesh-js $ bin/build.js compile

To compile a subset of projects and targets, include a --projects (-p) option, with a comma-separated list of $project:($target)? specifiers. For example, to build the main target of the client project, and all targets of the cli project, run:

swim-mesh-js $ bin/build.js compile -p client:main,cli

Running tests

Use the test build script command to compile and run unit tests. For example, to compile and test the warp project, run:

swim-mesh-js $ bin/build.js test -p warp

Continuous development builds

Use the watch build script command to automatically rebuild projects when dependent source files change. For example, to continuously recompile the main target of the cli project when any source file in the project–or in one of the project's transitive local dependencies–changes, run:

swim-mesh-js $ bin/build.js watch -p cli:main

Pass the --devel (-d) option to expedite recompilation by skipping the minification step. Add the --test (-t) option to automatically run unit tests after each successful compilation. For example, to continuosly compile and test the client project, bypassing minification, and skipping generation of the main script, run:

swim-mesh-js $ bin/build.js watch -p client:test -d -t
You can’t perform that action at this time.