initial commit
This commit is contained in:
26
node_modules/jibo-tools/electron/index.html
generated
vendored
Normal file
26
node_modules/jibo-tools/electron/index.html
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head lang="en">
|
||||
<meta charset="utf-8">
|
||||
<title>Jibo Simulator</title>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="../styles/main.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="visualizer"></div>
|
||||
<div id="face"></div>
|
||||
</div>
|
||||
<div id="chat"></div>
|
||||
|
||||
<script>
|
||||
var head = document.getElementsByTagName('head')[0];
|
||||
var link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
link.href = require.resolve('jibo-atom-styles/lib/atom-dark-ui.css');
|
||||
head.appendChild(link);
|
||||
require('../lib/simulator/simulator/main');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
226
node_modules/jibo-tools/electron/main.js
generated
vendored
Normal file
226
node_modules/jibo-tools/electron/main.js
generated
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
var app = require('app'),
|
||||
globalShortcut = require('global-shortcut'),
|
||||
BrowserWindow = require('browser-window'),
|
||||
Menu = require('menu'),
|
||||
mainWindow = null,
|
||||
path = require('path'),
|
||||
ipc = require('ipc'),
|
||||
program = require('commander'),
|
||||
settings = require('../lib/simulator/settings'),
|
||||
devTools = require('../lib/simulator/dev-tools');
|
||||
|
||||
|
||||
program
|
||||
.option('-p, --path <path>', 'The path to the skill')
|
||||
.option('-r, --remote <address>', 'Run this as a remote simulation')
|
||||
.option('-t, --token <token>', 'Run this as a remote simulation')
|
||||
.option('-f, --frameless', 'Run with frameless window (no menu bar)')
|
||||
.parse(process.argv);
|
||||
|
||||
var inRemoteMode = typeof program.remote !== "undefined" && program.remote.length > 0;
|
||||
ipc.on('is-remote-mode', function (event) {
|
||||
event.returnValue = inRemoteMode.toString();
|
||||
});
|
||||
|
||||
if (!program.path) {
|
||||
console.error("You must specify a --path");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Figure out which short cut style we should do based on the current platform
|
||||
var toggleDevToolsShortcutStem = 'Alt+Command+';
|
||||
if (process.platform != 'darwin'){
|
||||
toggleDevToolsShortcutStem = "Shift+Control+"
|
||||
}
|
||||
|
||||
settings.init();
|
||||
|
||||
var windowing = require('../lib/simulator/windowing');
|
||||
|
||||
function shutdown(windowThatClosed){
|
||||
if(mainWindow){
|
||||
if( mainWindow !== windowThatClosed ){
|
||||
mainWindow.close();
|
||||
}
|
||||
mainWindow = null;
|
||||
}
|
||||
|
||||
windowing.shutdown();
|
||||
|
||||
devTools.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called by the visualizer when running in the simulator. It uses
|
||||
* this to load in the entire simulator module. This way the simulator module doesn't
|
||||
* bloat up the size of the jibo module.
|
||||
*/
|
||||
ipc.on('get-skill-path', function (event) {
|
||||
event.returnValue = program.path;
|
||||
});
|
||||
|
||||
var template = [
|
||||
{
|
||||
label: 'Electron',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Quit',
|
||||
accelerator: 'CommandOrControl+Q',
|
||||
click: function () {
|
||||
app.quit();
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Edit',
|
||||
submenu: [
|
||||
{label: 'Undo', accelerator: 'Command+Z', selector: 'undo:'},
|
||||
{label: 'Redo', accelerator: 'Command+Shift+Z', selector: 'redo:'},
|
||||
{type: 'separator'},
|
||||
{label: 'Cut', accelerator: 'Command+X', selector: 'cut:'},
|
||||
{label: 'Copy', accelerator: 'Command+C', selector: 'copy:'},
|
||||
{label: 'Paste', accelerator: 'Command+V', selector: 'paste:'},
|
||||
{label: 'Select All', accelerator: 'Command+A', selector: 'selectAll:'},
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Reload',
|
||||
accelerator: 'CommandOrControl+R',
|
||||
click: function () {
|
||||
if (mainWindow) {
|
||||
mainWindow.webContents.send('reload-skill');
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'separator'
|
||||
}
|
||||
]
|
||||
// Defer to the window windowing module to set up it's related menu items
|
||||
.concat(windowing.getMenuItems())
|
||||
.concat([
|
||||
{
|
||||
label: 'Developer',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Developer Tools',
|
||||
accelerator: toggleDevToolsShortcutStem + 'I',
|
||||
click: function () {
|
||||
if(mainWindow){
|
||||
settings.update({
|
||||
isDevToolsOpened: !settings.get('isDevToolsOpened')
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
}
|
||||
];
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
if (process.platform != 'darwin'){
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
function loadSkill() {
|
||||
var registryHost = inRemoteMode ? program.remote : undefined;
|
||||
//
|
||||
if(!inRemoteMode){
|
||||
// The simulator window tell us where the registry end point is
|
||||
ipc.on('registry-init', function (event, _registryHost) {
|
||||
registryHost = _registryHost;
|
||||
});
|
||||
}
|
||||
|
||||
// Set the window size taking into consideration retina display type
|
||||
// monitors so that our simulation window is pixel perfect
|
||||
var screen = require('screen'), display;
|
||||
// Try to guess which screen the window will end up so that we can
|
||||
// factor in the display's scaleFactor
|
||||
try{
|
||||
display = screen.getDisplayMatching({
|
||||
x: settings.get('windowX'),
|
||||
y: settings.get('windowY'),
|
||||
width: settings.get('contentWidth'),
|
||||
height: settings.get('contentHeight')
|
||||
});
|
||||
} catch(error){
|
||||
display = screen.getDisplayMatching({
|
||||
x: 100, //settings.get('windowX'),
|
||||
y: 100, //settings.get('windowY'),
|
||||
width: 1000, //settings.get('contentWidth'),
|
||||
height: 1000 // settings.get('contentHeight')
|
||||
});
|
||||
};
|
||||
|
||||
// Force 2d mode if running remote mode
|
||||
if(inRemoteMode){
|
||||
settings.update({
|
||||
viewMode: '2d'
|
||||
});
|
||||
}
|
||||
var options = {
|
||||
//"zoom-factor": windowing.getInitialZoomFactor()
|
||||
};
|
||||
|
||||
if( settings.get('fullscreen') ){
|
||||
options.fullscreen = true;
|
||||
} else {
|
||||
// This ensures the width/height of the body are actually what we set
|
||||
// and unaffected by os specific window framing elements
|
||||
options["use-content-size"] = true;
|
||||
options.x = settings.get('windowX');
|
||||
options.y = settings.get('windowY');
|
||||
options.width = settings.get('contentWidth') / display.scaleFactor;
|
||||
options.height = settings.get('contentHeight') / display.scaleFactor;
|
||||
}
|
||||
|
||||
mainWindow = new BrowserWindow(options);
|
||||
|
||||
devTools.init(mainWindow);
|
||||
|
||||
// Add an unlisted shortcut for opening/closing the dev tools of the visualizer itself
|
||||
globalShortcut.register(toggleDevToolsShortcutStem + 'J', function(){
|
||||
if(mainWindow){
|
||||
mainWindow.webContents.toggleDevTools();
|
||||
}
|
||||
});
|
||||
|
||||
windowing.setWindow(mainWindow);
|
||||
|
||||
settings.setWindow(mainWindow);
|
||||
|
||||
ipc.on('get-registry-host', function (event, arg) {
|
||||
event.sender.send('set-registry-host', {
|
||||
registryHost: registryHost,
|
||||
token: program.token
|
||||
});
|
||||
});
|
||||
|
||||
var indexPath = program.path;
|
||||
|
||||
// Make sure the working directory is the root directory of the skill
|
||||
process.chdir(path.dirname(indexPath));
|
||||
|
||||
// Load the visualizer web app which will itself load the skill's index.html
|
||||
mainWindow.loadUrl('file://' + path.resolve(__dirname, "index.html") );
|
||||
|
||||
mainWindow.on('closed', function () {
|
||||
shutdown(mainWindow);
|
||||
});
|
||||
}
|
||||
|
||||
app.on('ready', function () {
|
||||
// Set the context menu
|
||||
var menu = Menu.buildFromTemplate(template);
|
||||
Menu.setApplicationMenu(menu);
|
||||
|
||||
loadSkill();
|
||||
});
|
||||
6
node_modules/jibo-tools/electron/package.json
generated
vendored
Normal file
6
node_modules/jibo-tools/electron/package.json
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "jibo-simulator",
|
||||
"version": "0.5.0",
|
||||
"description": "",
|
||||
"main": "main.js"
|
||||
}
|
||||
Reference in New Issue
Block a user