Skip to content

Instantly share code, notes, and snippets.

@rksm
Created January 4, 2018 11:35
Show Gist options
  • Save rksm/c0019af0d03e7de29189ff51c080ceb6 to your computer and use it in GitHub Desktop.
Save rksm/c0019af0d03e7de29189ff51c080ceb6 to your computer and use it in GitHub Desktop.
Build livelify-web.js
/*global require, __dirname*/
let fs = require("fs"),
path = require("path"),
files = [
require.resolve("babel-standalone/babel.js"),
require.resolve("systemjs/dist/system.src.js"),
require.resolve("lively.modules/dist/lively.modules.js"),
require.resolve("lively-system-interface/dist/lively-system-interface-only-local.js"),
require.resolve("lively.keyboard/dist/lively.keyboard.min.js"),
require.resolve("lively.2lively/dist/lively.2lively_client.js"),
],
targetFile = "livelify-web.js",
init = `
(function() {
let query = lively.resources.parseQuery(document.location.search),
host = query["L2L_SESSIONTRACKER_SERVER"] || query["l2l_sessiontracker_server"] || document.location.origin,
url = host + '/lively-socket.io';
lively.l2l.client = lively.l2l.L2LClient.ensure(
{url, namespace: "l2l", info: {type: "livelify-web", location: String(document.location)}});
lively.l2l.client.whenRegistered(20*1000)
.then(() => console.log("[l2l] online"))
.catch(err => console.error("[l2l] failed:", err));
})();`;
fs.writeFileSync(targetFile,
files.map(ea => fs.readFileSync(ea)).concat(init).join("\n\n"));
console.log(path.join(__dirname, targetFile) + " written");
@rksm
Copy link
Author

rksm commented Jan 4, 2018

Assumes to be run in nodejs inside the folder created by the lively.installer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment