Publish Vulpes Preview 15 sources for desktop, Android and Tundra

Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
OverSu 2026-09-30 23:13:03 +02:00
commit b38dea0597
25901 changed files with 9982925 additions and 369 deletions

View file

@ -0,0 +1,12 @@
define(["exports"], function (exports) {
"use strict";
/* globals requirejs */
requirejs.config({
baseUrl: "components",
paths: { app: "../" }
});
requirejs(["app/js/index"]);
});

View file

@ -0,0 +1,84 @@
define(["exports", "fxos-mvc/dist/mvc", "app/js/models/app", "app/js/services/apps_service", "app/js/services/http_client_service", "app/js/services/p2p_service"], function (exports, _fxosMvcDistMvc, _appJsModelsApp, _appJsServicesAppsService, _appJsServicesHttpClientService, _appJsServicesP2pService) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Controller = _fxosMvcDistMvc.Controller;
var App = _appJsModelsApp["default"];
var AppsService = _appJsServicesAppsService["default"];
var HttpClientService = _appJsServicesHttpClientService["default"];
var P2pService = _appJsServicesP2pService["default"];
var AppController = (function (Controller) {
var AppController = function AppController(options) {
var _this = this;
Controller.call(this, options);
this._appsUpdated = function () {
return _this.main();
};
document.body.appendChild(this.view.el);
};
_extends(AppController, Controller);
AppController.prototype.main = function (appId) {
var _this2 = this;
var proxApps = P2pService.getApps();
this._app = App.getApp(proxApps, { manifestURL: appId });
this.header = this._app && this._app.manifest.name;
AppsService.getApps().then(function (installedApps) {
_this2._app = App.markInstalledApps(installedApps, [_this2._app])[0];
_this2.view.show(_this2._app);
AppsService.addEventListener("updated", _this2._appsUpdated);
});
};
AppController.prototype.teardown = function () {
this.view.hide();
AppsService.removeEventListener("updated", this._appsUpdated);
};
AppController.prototype.close = function () {
this.teardown();
};
AppController.prototype.download = function (e) {
var _this3 = this;
Sharing.ConfirmDownloadController.open(this._app, function () {
var progressDialogController = Sharing.ProgressDialogController;
progressDialogController.main();
HttpClientService.downloadApp(_this3._app).then(progressDialogController.success.bind(progressDialogController), progressDialogController.error.bind(progressDialogController));
});
};
AppController.prototype.open = function () {
var _this4 = this;
navigator.mozApps.mgmt.getAll().then(function (apps) {
apps.forEach(function (app) {
if (app.manifestURL === _this4._app.manifestURL) {
app.launch();
}
});
});
};
return AppController;
})(Controller);
exports["default"] = AppController;
});

View file

@ -0,0 +1,46 @@
define(["exports", "fxos-mvc/dist/mvc"], function (exports, _fxosMvcDistMvc) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Controller = _fxosMvcDistMvc.Controller;
var ConfirmDownloadController = (function (Controller) {
var ConfirmDownloadController = function ConfirmDownloadController(options) {
Controller.call(this, options);
this.view.render();
};
_extends(ConfirmDownloadController, Controller);
ConfirmDownloadController.prototype.open = function (app, cb) {
document.body.appendChild(this.view.el);
this.view.open(app);
this._cb = cb;
};
ConfirmDownloadController.prototype.cancel = function () {
this.view.close();
};
ConfirmDownloadController.prototype.install = function () {
this.view.close();
this._cb();
};
return ConfirmDownloadController;
})(Controller);
exports["default"] = ConfirmDownloadController;
});

View file

@ -0,0 +1,59 @@
define(["exports", "fxos-mvc/dist/mvc", "app/js/services/device_name_service"], function (exports, _fxosMvcDistMvc, _appJsServicesDeviceNameService) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Controller = _fxosMvcDistMvc.Controller;
var DeviceNameService = _appJsServicesDeviceNameService["default"];
var DeviceNameController = (function (Controller) {
var DeviceNameController = function DeviceNameController(options) {
var _this = this;
Controller.call(this, options);
this.view.render();
document.body.appendChild(this.view.el);
DeviceNameService.addEventListener("devicenamechange", function (e) {
return _this._updateDeviceName(e);
}, true);
};
_extends(DeviceNameController, Controller);
DeviceNameController.prototype.main = function () {
this.view.el.open();
};
DeviceNameController.prototype.handleOpened = function () {};
DeviceNameController.prototype.handleClosed = function () {
DeviceNameService.signalDeviceNameCanceled();
};
DeviceNameController.prototype.handleSubmit = function () {
DeviceNameService.setDeviceName(this.view.value);
};
DeviceNameController.prototype.handleInput = function () {
this.view.el.els.submit.disabled = !this.view.value;
};
DeviceNameController.prototype._updateDeviceName = function (e) {
this.view.value = e.deviceName;
};
return DeviceNameController;
})(Controller);
exports["default"] = DeviceNameController;
});

View file

@ -0,0 +1,57 @@
define(["exports", "fxos-mvc/dist/mvc", "app/js/views/main_view", "app/js/controllers/app_controller", "app/js/controllers/confirm_download_controller", "app/js/controllers/device_name_controller", "app/js/controllers/progress_dialog_controller", "app/js/controllers/proximity_apps_controller", "app/js/controllers/share_controller", "app/js/views/app_view", "app/js/views/confirm_download_view", "app/js/views/device_name_view", "app/js/views/progress_dialog_view", "app/js/services/activity_service", "app/js/services/achievements_service"], function (exports, _fxosMvcDistMvc, _appJsViewsMainView, _appJsControllersAppController, _appJsControllersConfirmDownloadController, _appJsControllersDeviceNameController, _appJsControllersProgressDialogController, _appJsControllersProximityAppsController, _appJsControllersShareController, _appJsViewsAppView, _appJsViewsConfirmDownloadView, _appJsViewsDeviceNameView, _appJsViewsProgressDialogView, _appJsServicesActivityService, _appJsServicesAchievementsService) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Controller = _fxosMvcDistMvc.Controller;
var MainView = _appJsViewsMainView["default"];
var AppController = _appJsControllersAppController["default"];
var ConfirmDownloadController = _appJsControllersConfirmDownloadController["default"];
var DeviceNameController = _appJsControllersDeviceNameController["default"];
var ProgressDialogController = _appJsControllersProgressDialogController["default"];
var ProximityAppsController = _appJsControllersProximityAppsController["default"];
var ShareController = _appJsControllersShareController["default"];
var AppView = _appJsViewsAppView["default"];
var ConfirmDownloadView = _appJsViewsConfirmDownloadView["default"];
var DeviceNameView = _appJsViewsDeviceNameView["default"];
var ProgressDialogView = _appJsViewsProgressDialogView["default"];
var MainController = (function (Controller) {
var MainController = function MainController() {
Controller.call(this);
this.view = new MainView({
controller: this,
el: document.body
});
window.Sharing = {
AppController: new AppController({ view: new AppView() }),
ConfirmDownloadController: new ConfirmDownloadController({ view: new ConfirmDownloadView() }),
DeviceNameController: new DeviceNameController({ view: new DeviceNameView() }),
ProgressDialogController: new ProgressDialogController({ view: new ProgressDialogView() }),
ProximityAppsController: new ProximityAppsController(),
ShareController: new ShareController()
};
window.requestAnimationFrame(function () {
document.documentElement.classList.remove("loading");
});
};
_extends(MainController, Controller);
return MainController;
})(Controller);
exports["default"] = MainController;
});

View file

@ -0,0 +1,57 @@
define(["exports", "fxos-mvc/dist/mvc", "app/js/views/progress_dialog_view"], function (exports, _fxosMvcDistMvc, _appJsViewsProgressDialogView) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Controller = _fxosMvcDistMvc.Controller;
var ProgressDialogView = _appJsViewsProgressDialogView["default"];
var ProgressDialogController = (function (Controller) {
var ProgressDialogController = function ProgressDialogController() {
this.view = new ProgressDialogView();
this.view.init(this);
};
_extends(ProgressDialogController, Controller);
ProgressDialogController.prototype.main = function () {
var _this = this;
this.view.render();
document.body.appendChild(this.view.el);
setTimeout(function () {
_this.view.open();
});
};
ProgressDialogController.prototype.teardown = function () {
document.body.removeChild(this.view.el);
};
ProgressDialogController.prototype.success = function (app) {
var _this2 = this;
this.view.success(app);
setTimeout(function () {
_this2.view.close();
}, 3000);
};
ProgressDialogController.prototype.error = function (e) {
this.view.error(e);
};
return ProgressDialogController;
})(Controller);
exports["default"] = ProgressDialogController;
});

View file

@ -0,0 +1,181 @@
define(["exports", "fxos-mvc/dist/mvc", "app/js/models/app", "app/js/services/apps_service", "app/js/services/broadcast_service", "app/js/services/http_client_service", "app/js/services/p2p_service", "app/js/services/wifi_service", "app/js/views/share_summary_view", "app/js/views/list_view", "app/js/views/proximity_empty_view", "app/js/views/templates/composite"], function (exports, _fxosMvcDistMvc, _appJsModelsApp, _appJsServicesAppsService, _appJsServicesBroadcastService, _appJsServicesHttpClientService, _appJsServicesP2pService, _appJsServicesWifiService, _appJsViewsShareSummaryView, _appJsViewsListView, _appJsViewsProximityEmptyView, _appJsViewsTemplatesComposite) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Controller = _fxosMvcDistMvc.Controller;
var App = _appJsModelsApp["default"];
var AppsService = _appJsServicesAppsService["default"];
var BroadcastService = _appJsServicesBroadcastService["default"];
var HttpClientService = _appJsServicesHttpClientService["default"];
var P2pService = _appJsServicesP2pService["default"];
var WifiService = _appJsServicesWifiService["default"];
var ShareSummaryView = _appJsViewsShareSummaryView["default"];
var ListView = _appJsViewsListView["default"];
var ProximityEmptyView = _appJsViewsProximityEmptyView["default"];
var CompositeTemplate = _appJsViewsTemplatesComposite["default"];
var ProximityAppsController = (function (Controller) {
var ProximityAppsController = function ProximityAppsController() {
var _this = this;
this.shareSummaryView = new ShareSummaryView({
controller: this
});
this.proximityEmptyView = new ProximityEmptyView({
controller: this
});
this.proximityAppsView = new ListView({
controller: this,
id: "proximity-apps",
title: "Available apps",
type: "download",
attr: "apps"
});
this.proximityAddonsView = new ListView({
controller: this,
id: "proximity-addons",
title: "Available add-ons",
type: "download",
attr: "addons"
});
this.proximityThemesView = new ListView({
controller: this,
id: "proximity-themes",
title: "Available themes",
type: "download",
attr: "themes"
});
this.marketplacesView = new ListView({
controller: this,
id: "marketplaces",
title: "Marketplaces",
type: "link",
attr: "marketplaces"
});
this.view = new CompositeTemplate({
controller: this,
header: {
title: "P2P Sharing"
},
active: true,
id: "proximity-apps-container",
views: [this.shareSummaryView, this.proximityEmptyView, this.proximityAppsView, this.proximityAddonsView, this.proximityThemesView, this.marketplacesView]
});
BroadcastService.addEventListener("broadcast", function (e) {
return _this._broadcastChanged(e);
}, true);
P2pService.addEventListener("proximity", function () {
return _this._renderList();
}, true);
AppsService.addEventListener("updated", function () {
return _this._renderList();
}, true);
WifiService.addEventListener("statuschange", function () {
return _this._renderList();
});
this._renderList();
};
_extends(ProximityAppsController, Controller);
ProximityAppsController.prototype.main = function () {
this.view.el.classList.add("active");
};
ProximityAppsController.prototype.teardown = function () {
this.view.el.classList.remove("active");
};
ProximityAppsController.prototype.download = function (e) {
var id = e.target.dataset.id;
var apps = P2pService.getApps();
var app = App.getApp(apps, { manifestURL: id });
Sharing.ConfirmDownloadController.open(app, function () {
var progressDialogController = Sharing.ProgressDialogController;
progressDialogController.main();
HttpClientService.downloadApp(app).then(progressDialogController.success.bind(progressDialogController), progressDialogController.error.bind(progressDialogController));
});
};
ProximityAppsController.prototype.open = function (e) {
var id = e.target.dataset.id;
navigator.mozApps.mgmt.getAll().then(function (apps) {
apps.forEach(function (app) {
if (app.manifestURL === id) {
app.launch();
}
});
});
};
ProximityAppsController.prototype.description = function (e) {
// In case the tap hit a child node of the <div> element with the data-id
// attribute set.
var appId = e.target.dataset.id || e.target.parentNode.dataset.id;
var list = e.target.closest(".app-list");
if (list.classList.contains("link")) {
this.open(e);
} else {
Sharing.AppController.main(appId);
}
};
ProximityAppsController.prototype.openSharePanel = function () {
this.teardown();
Sharing.ShareController.main();
};
ProximityAppsController.prototype._broadcastChanged = function (e) {
this.shareSummaryView.displayBroadcast(e.broadcast);
};
ProximityAppsController.prototype._renderList = function () {
var _this2 = this;
var proxApps = P2pService.getApps();
AppsService.getApps(true /* include defaults */).then(function (installedApps) {
var apps = App.filterApps(proxApps);
var addons = App.filterAddons(proxApps);
var themes = App.filterThemes(proxApps);
var marketplaces = App.filterMarketplaces(installedApps);
var proximityEmpty = apps.length === 0 && addons.length === 0 && themes.length === 0;
var noNetwork = !WifiService.isConnected();
_this2.proximityEmptyView.render();
_this2.proximityEmptyView.show({
proximityEmpty: proximityEmpty,
noNetwork: noNetwork
});
_this2.proximityAppsView.render(App.markInstalledApps(installedApps, apps));
_this2.proximityAddonsView.render(App.markInstalledApps(installedApps, addons));
_this2.proximityThemesView.render(App.markInstalledApps(installedApps, themes));
_this2.marketplacesView.render(marketplaces);
});
};
return ProximityAppsController;
})(Controller);
exports["default"] = ProximityAppsController;
});

View file

@ -0,0 +1,168 @@
define(["exports", "fxos-mvc/dist/mvc", "app/js/models/app", "app/js/services/apps_service", "app/js/services/broadcast_service", "app/js/services/device_name_service", "app/js/services/share_service", "app/js/views/share_settings_view", "app/js/views/list_view", "app/js/views/templates/composite"], function (exports, _fxosMvcDistMvc, _appJsModelsApp, _appJsServicesAppsService, _appJsServicesBroadcastService, _appJsServicesDeviceNameService, _appJsServicesShareService, _appJsViewsShareSettingsView, _appJsViewsListView, _appJsViewsTemplatesComposite) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Controller = _fxosMvcDistMvc.Controller;
var App = _appJsModelsApp["default"];
var AppsService = _appJsServicesAppsService["default"];
var BroadcastService = _appJsServicesBroadcastService["default"];
var DeviceNameService = _appJsServicesDeviceNameService["default"];
var ShareService = _appJsServicesShareService["default"];
var ShareSettingsView = _appJsViewsShareSettingsView["default"];
var ListView = _appJsViewsListView["default"];
var CompositeTemplate = _appJsViewsTemplatesComposite["default"];
var ShareController = (function (Controller) {
var ShareController = function ShareController() {
var _this = this;
this.shareSettingsView = new ShareSettingsView({
controller: this
});
this.sharedAppsView = new ListView({
controller: this,
id: "shared-apps",
title: "My apps",
type: "toggle",
disabled: true
});
this.sharedAddonsView = new ListView({
controller: this,
id: "shared-addons",
title: "My add-ons",
type: "toggle",
disabled: true
});
this.sharedThemesView = new ListView({
controller: this,
id: "shared-themes",
title: "My themes",
type: "toggle",
disabled: true
});
this.view = new CompositeTemplate({
controller: this,
header: {
title: "Share My Apps",
action: "back"
},
id: "share-apps-container",
views: [this.shareSettingsView, this.sharedAppsView, this.sharedAddonsView, this.sharedThemesView]
});
BroadcastService.addEventListener("broadcast", function (e) {
return _this._broadcastChanged(e);
}, true);
DeviceNameService.addEventListener("devicenamechange", function (e) {
return _this._deviceNameChanged(e);
}, true);
DeviceNameService.addEventListener("devicenamechange-cancel", function () {
return _this.back();
});
AppsService.addEventListener("updated", function () {
return _this._appsChanged();
}, true);
DeviceNameService.getDeviceName().then(function (deviceName) {
_this._deviceNameChanged({ deviceName: deviceName });
});
};
_extends(ShareController, Controller);
ShareController.prototype.main = function () {
this.view.el.classList.add("active");
if (DeviceNameService.isDefault()) {
Sharing.DeviceNameController.main();
}
};
ShareController.prototype.teardown = function () {
this.view.el.classList.remove("active");
};
ShareController.prototype._appsChanged = function () {
var _this2 = this;
// We want to fetch all of our apps, even if we're not broadcasting them, so
// that we can show them greyed out.
var options = { ignoreBroadcast: true };
Promise.all([AppsService.getApps(), ShareService.getApps(options)]).then(function (results) {
var installedApps = results[0];
var sharedApps = results[1];
var apps = App.markSharedApps(sharedApps, installedApps);
_this2.sharedAppsView.render(App.filterApps(apps));
_this2.sharedAddonsView.render(App.filterAddons(apps));
_this2.sharedThemesView.render(App.filterThemes(apps));
});
};
ShareController.prototype.toggleBroadcasting = function (toggle) {
BroadcastService.setBroadcast(toggle);
};
ShareController.prototype._broadcastChanged = function (e) {
var broadcast = e.broadcast;
this.shareSettingsView.displayBroadcast(broadcast);
this.sharedAppsView.toggle(!broadcast);
this.sharedAddonsView.toggle(!broadcast);
this.sharedThemesView.toggle(!broadcast);
};
ShareController.prototype._deviceNameChanged = function (e) {
this.shareSettingsView.deviceName = e.deviceName;
};
ShareController.prototype.back = function () {
this.teardown();
Sharing.ProximityAppsController.main();
};
ShareController.prototype.toggle = function (e) {
if (e && e.preventDefault) {
e.preventDefault();
}
var el = e.target.querySelector(".control") || e.target;
var checked = el.checked;
AppsService.getApps().then(function (apps) {
var app = App.getApp(apps, { manifestURL: el.dataset.id });
ShareService.setAppShare(app, !checked);
// If there's a .control element under this one, then the user must have
// tapped on the description.
if (e.target.querySelector(".control")) {
el.toggle();
}
});
};
ShareController.prototype.description = function (e) {
this.toggle({ target: e.target.parentNode });
};
ShareController.prototype.rename = function () {
Sharing.DeviceNameController.main();
};
return ShareController;
})(Controller);
exports["default"] = ShareController;
});

View file

@ -0,0 +1,5 @@
define(["exports"], function (exports) {
"use strict";
window.COMPONENTS_BASE_URL = "./components/";
});

View file

@ -0,0 +1,15 @@
define(["exports", "app/js/globals", "app/js/controllers/main_controller"], function (exports, _appJsGlobals, _appJsControllersMainController) {
"use strict";
var MainController = _appJsControllersMainController["default"];
var mainController = new MainController();
mainController.main();
// Generate a pseudo-GUID for this session.
window.session = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
var r = window.crypto.getRandomValues(new Uint32Array(1))[0] % 16, v = c == "x" ? r : (r & 3 | 8);
return v.toString(16);
});
});

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,90 @@
define(["exports", "fxos-mvc/dist/mvc"], function (exports, _fxosMvcDistMvc) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Model = _fxosMvcDistMvc.Model;
var App = (function (Model) {
var App = function App() {
Model.apply(this, arguments);
};
_extends(App, Model);
App.getApp = function (apps, filters) {
return apps.find(function (app) {
for (var filter in filters) {
if (app[filter] === filters[filter] || app.manifest[filter] === filters[filter]) {
return true;
}
}
return false;
});
};
App.markInstalledApps = function (installedApps, apps) {
return apps.map(function (app) {
if (App.getApp(installedApps, { manifestURL: app.manifestURL })) {
app.installed = true;
}
return app;
});
};
App.markSharedApps = function (sharedApps, apps) {
return apps.map(function (app) {
if (App.getApp(sharedApps, { manifestURL: app.manifestURL })) {
app.shared = true;
}
return app;
});
};
App.filterDefaults = function (apps) {
var filterOrigins = ["app://marketplace-dev.allizom.org", "app://marketplace.allizom.org", "http://mochi.test:8888"];
return apps.filter(function (app) {
return app.manifest.role !== "system" && app.removable === true && filterOrigins.indexOf(app.origin) === -1;
});
};
App.filterApps = function (apps) {
return apps.filter(function (app) {
return app.manifest.role !== "addon" && app.manifest.role !== "theme";
});
};
App.filterAddons = function (apps) {
return apps.filter(function (app) {
return app.manifest.role === "addon";
});
};
App.filterThemes = function (apps) {
return apps.filter(function (app) {
return app.manifest.role === "theme";
});
};
App.filterMarketplaces = function (apps) {
var filterManifestURLs = ["https://marketplace.firefox.com/packaged.webapp", "app://directory.gaiamobile.org/manifest.webapp"];
return apps.filter(function (app) {
return filterManifestURLs.indexOf(app.manifestURL) !== -1;
});
};
return App;
})(Model);
exports["default"] = App;
});

View file

@ -0,0 +1,70 @@
define(["exports", "fxos-mvc/dist/mvc", "app/js/services/share_service", "app/js/services/device_name_service"], function (exports, _fxosMvcDistMvc, _appJsServicesShareService, _appJsServicesDeviceNameService) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Model = _fxosMvcDistMvc.Model;
var ShareService = _appJsServicesShareService["default"];
var DeviceNameService = _appJsServicesDeviceNameService["default"];
var Peer = (function (Model) {
var Peer = function Peer() {
Model.apply(this, arguments);
};
_extends(Peer, Model);
Peer.getMe = function () {
return new Promise(function (resolve, reject) {
Promise.all([ShareService.getApps(), DeviceNameService.getDeviceName()]).then(function (result) {
var apps = result[0];
var deviceName = result[1];
resolve({
name: deviceName,
session: window.session,
apps: apps
});
}, reject);
});
};
Peer.stringify = function (peer) {
var peerObj = {};
for (var i in peer) {
peerObj[i] = peer[i];
}
peerObj.apps = peer.apps.map(function (app) {
return {
type: app.type,
manifest: {
name: app.manifest.name,
description: app.manifest.description,
developer: {
name: (app.manifest.developer && app.manifest.developer.name) || ""
},
role: app.manifest.role,
type: app.manifest.type
},
manifestURL: app.manifestURL,
icon: app.icon
};
});
return JSON.stringify(peerObj);
};
return Peer;
})(Model);
exports["default"] = Peer;
});

View file

@ -0,0 +1,33 @@
define(["exports", "fxos-achievements-service/dist/achievements-service", "app/js/services/broadcast_service"], function (exports, _fxosAchievementsServiceDistAchievementsService, _appJsServicesBroadcastService) {
"use strict";
var AchievementsService = _fxosAchievementsServiceDistAchievementsService["default"];
var BroadcastService = _appJsServicesBroadcastService["default"];
var ACHIEVEMENT_CRITERIA = "achievements/sharing-is-caring";
var ACHIEVEMENT_EVIDENCE = "urn:sharing:p2p_broadcast:true";
var AchievementsServiceWrapper = function AchievementsServiceWrapper() {
// Create an achievements service
var achievementsService = new AchievementsService();
// When sharing is enabled, reward an achievement
BroadcastService.addEventListener("broadcast", function (_ref) {
var broadcast = _ref.broadcast;
if (!broadcast) {
// Do nothing if sharing is disabled
return;
}
achievementsService.reward({
criteria: ACHIEVEMENT_CRITERIA,
evidence: ACHIEVEMENT_EVIDENCE,
name: "Sharing is Caring",
description: "Share your apps and add-ons with the Sharing app",
image: "icons/sharing-is-caring.png"
});
});
};
exports["default"] = new AchievementsServiceWrapper();
});

View file

@ -0,0 +1,38 @@
define(["exports", "fxos-mvc/dist/mvc"], function (exports, _fxosMvcDistMvc) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Service = _fxosMvcDistMvc.Service;
var ActivityService = (function (Service) {
var ActivityService = function ActivityService(guard) {
Service.call(this);
navigator.mozSetMessageHandler("activity", function (req) {
var option = req.source;
if (option.name === "share") {
window.activityHandled = "share";
var app = option.data.app;
window.alert("Sharing " + app + " is not implemented yet");
}
});
};
_extends(ActivityService, Service);
return ActivityService;
})(Service);
exports["default"] = new ActivityService();
});

View file

@ -0,0 +1,215 @@
define(["exports", "fxos-mvc/dist/mvc", "app/js/models/app"], function (exports, _fxosMvcDistMvc, _appJsModelsApp) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Service = _fxosMvcDistMvc.Service;
var App = _appJsModelsApp["default"];
var AppsService = (function (Service) {
var AppsService = function AppsService() {
var _this = this;
Service.call(this);
this._apps = [];
this._getApps();
var mgmt = navigator.mozApps.mgmt;
mgmt.addEventListener("install", function (app) {
return _this._handleInstall(app);
});
mgmt.addEventListener("uninstall", function (app) {
return _this._handleUninstall(app);
});
};
_extends(AppsService, Service);
AppsService.prototype.installAppBlob = function (appData) {
return new Promise(function (resolve, reject) {
var sdcard = navigator.getDeviceStorage("sdcard");
if (!sdcard) {
console.error("No SD card!");
reject({ name: "No SD card!" });
return;
}
var fileName = "temp-app.zip";
var delReq = sdcard["delete"](fileName);
delReq.onsuccess = delReq.onerror = function () {
var req = sdcard.addNamed(new Blob([appData], { type: "application/openwebapp+zip" }), fileName);
req.onsuccess = function () {
var getReq = sdcard.get(fileName);
getReq.onsuccess = function () {
var file = getReq.result;
navigator.mozApps.mgmt["import"](file).then(function (app) {
resolve(app);
}, function (e) {
console.error("error installing app", e);
reject(e);
});
};
getReq.onerror = function () {
console.error("error getting file", getReq.error.name);
reject(getReq.error);
};
};
req.onerror = function (e) {
console.error("error saving blob", e);
reject(e);
};
};
});
};
AppsService.prototype.markInstalledAppsInProximityApps = function (peers) {
var _this2 = this;
return new Promise(function (resolve, reject) {
_this2._getApps().then(function () {
resolve(peers);
});
});
/*
for (var peerIndex in peers) {
var peer = peers[peerIndex];
['apps', 'addons', 'themes'].forEach(appType => {
if (!peer[appType]) {
return;
}
for (var i = peer[appType].length - 1; i >= 0; i--) {
var app = peer[appType][i];
var matchingApp = this._apps.find((installedApp) => {
return installedApp.manifest.name === app.manifest.name;
});
if (matchingApp) {
peer[appType][i].installed = true;
}
}
});
}
resolve(peers);
});
});
*/
};
AppsService.prototype.getApps = function (noFilter) {
var _this3 = this;
return new Promise(function (resolve, reject) {
_this3._getApps().then(function () {
resolve(noFilter ? _this3._apps : App.filterDefaults(_this3._apps));
}, reject);
});
};
AppsService.prototype._getApp = function (app, resolve) {
var _this4 = this;
// XXX/drs: This is higher than we need, but some apps scale have
// icons as low as 16px, which look really bad. I'd rather we
// scale them down than up.
navigator.mozApps.mgmt.getIcon(app, "128").then(function (icon) {
var fr = new FileReader();
fr.addEventListener("loadend", function () {
app.icon = fr.result;
_this4._apps.push(app);
if (resolve) {
resolve();
}
});
fr.readAsDataURL(icon);
}, function () {
app.icon = "icons/default.png";
_this4._apps.push(app);
if (resolve) {
resolve();
}
});
};
AppsService.prototype._getApps = function () {
var _this5 = this;
if (!this._initialized) {
this._initialized = new Promise(function (oresolve, reject) {
_this5._apps = [];
var iconPromises = [];
var req = navigator.mozApps.mgmt.getAll();
req.onsuccess = function () {
var result = req.result;
for (var index in result) {
var app = result[index];
iconPromises.push(new Promise(function (resolve, reject) {
return _this5._getApp(app, resolve);
}));
}
Promise.all(iconPromises).then(function () {
oresolve(_this5._apps);
_this5._dispatchEvent("updated");
});
};
req.onerror = function (e) {
console.error("error fetching installed apps: ", e);
reject(e);
};
});
}
return this._initialized;
};
AppsService.prototype._handleInstall = function (e) {
var _this6 = this;
var app = e.application;
var updateApp = function () {
(new Promise(function (resolve, reject) {
_this6._apps = _this6._apps.filter(function (installedApp) {
return app.manifestURL !== installedApp.manifestURL;
});
_this6._getApp(app, resolve);
})).then(function () {
_this6._dispatchEvent("updated");
});
};
if (app.downloading) {
var downloaded = function () {
app.removeEventListener("downloadsuccess", downloaded);
updateApp();
};
app.addEventListener("downloadsuccess", downloaded);
} else {
updateApp();
}
};
AppsService.prototype._handleUninstall = function (e) {
var app = e.application;
this._apps = this._apps.filter(function (installedApp) {
return app.manifestURL !== installedApp.manifestURL;
});
this._dispatchEvent("updated");
};
return AppsService;
})(Service);
exports["default"] = new AppsService();
});

View file

@ -0,0 +1,77 @@
define(["exports", "fxos-mvc/dist/mvc"], function (exports, _fxosMvcDistMvc) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Service = _fxosMvcDistMvc.Service;
var BroadcastService = (function (Service) {
var BroadcastService = function BroadcastService() {
var _this = this;
Service.call(this);
this._initialized = new Promise(function (resolve, reject) {
navigator.mozSettings.addObserver("lightsaber.p2p_broadcast", function (e) {
_this._broadcastLoaded(e.settingValue);
});
var broadcastSetting = navigator.mozSettings.createLock().get("lightsaber.p2p_broadcast", false);
broadcastSetting.onsuccess = function () {
_this._broadcastLoaded(broadcastSetting.result["lightsaber.p2p_broadcast"]);
resolve();
};
broadcastSetting.onerror = function () {
console.error("error getting `lightsaber.p2p_broadcast` setting");
reject();
};
});
};
_extends(BroadcastService, Service);
BroadcastService.prototype.getBroadcast = function () {
var _this2 = this;
return new Promise(function (resolve, reject) {
_this2._initialized.then(function () {
resolve(_this2._broadcast);
}, reject);
});
};
BroadcastService.prototype.setBroadcast = function (val) {
new Promise(function (resolve, reject) {
var request = navigator.mozSettings.createLock().set({
"lightsaber.p2p_broadcast": val });
request.onsuccess = function () {
resolve();
};
request.onerror = function (e) {
console.error("error getting `lightsaber.p2p_broadcast` setting");
reject(e);
};
});
};
BroadcastService.prototype._broadcastLoaded = function (val) {
this._broadcast = val;
this._dispatchEvent("broadcast", { broadcast: val });
};
return BroadcastService;
})(Service);
exports["default"] = new BroadcastService();
});

View file

@ -0,0 +1,99 @@
define(["exports", "fxos-mvc/dist/mvc"], function (exports, _fxosMvcDistMvc) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Service = _fxosMvcDistMvc.Service;
var DeviceNameService = (function (Service) {
var DeviceNameService = function DeviceNameService() {
var _this = this;
Service.call(this);
navigator.mozSettings.addObserver("lightsaber.device_name", function (e) {
_this._deviceName = e.settingValue;
_this._dispatchEvent("devicenamechange", { deviceName: e.settingValue });
});
this._initialized = new Promise(function (resolve, reject) {
var request = navigator.mozSettings.createLock().get("lightsaber.device_name");
request.onsuccess = function () {
var result = request.result["lightsaber.device_name"];
if (!result) {
_this._isDefault = true;
}
_this._deviceName = result || "";
resolve();
};
request.onerror = function (e) {
console.error("error getting lightsaber.device_name: " + e);
reject(e);
};
}).then(function () {
_this._dispatchEvent("devicenamechange", { deviceName: _this._deviceName });
});
};
_extends(DeviceNameService, Service);
DeviceNameService.prototype.setDeviceName = function (deviceName) {
var _this2 = this;
return new Promise(function (resolve, reject) {
if (!deviceName) {
reject();
return;
}
var request = navigator.mozSettings.createLock().set({
"lightsaber.device_name": deviceName });
request.onsuccess = function () {
_this2._isDefault = false;
_this2._dispatchEvent("devicenamechange", { deviceName: deviceName });
resolve();
};
request.onerror = function (e) {
console.error("error setting lightsaber.device_name: " + e);
reject(e);
};
});
};
DeviceNameService.prototype.getDeviceName = function () {
var _this3 = this;
return new Promise(function (resolve, reject) {
return _this3._initialized.then(function () {
resolve(_this3._deviceName);
});
});
};
DeviceNameService.prototype.isDefault = function () {
return this._isDefault;
};
DeviceNameService.prototype.signalDeviceNameCanceled = function () {
if (this._isDefault) {
this._dispatchEvent("devicenamechange-cancel");
}
};
return DeviceNameService;
})(Service);
exports["default"] = new DeviceNameService();
});

View file

@ -0,0 +1,98 @@
define(["exports", "fxos-mvc/dist/mvc", "app/js/models/peer", "app/js/services/apps_service", "app/js/services/url_service"], function (exports, _fxosMvcDistMvc, _appJsModelsPeer, _appJsServicesAppsService, _appJsServicesUrlService) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Service = _fxosMvcDistMvc.Service;
var Peer = _appJsModelsPeer["default"];
var AppsService = _appJsServicesAppsService["default"];
var UrlService = _appJsServicesUrlService["default"];
var TIMEOUT = 2000;
var HttpClientService = (function (Service) {
var HttpClientService = function HttpClientService() {
Service.apply(this, arguments);
};
_extends(HttpClientService, Service);
HttpClientService.prototype.downloadApp = function (app) {
var _this = this;
var url = UrlService.getAppDownloadUrl(app);
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest({ mozAnon: true, mozSystem: true });
xhr.open("GET", url);
xhr.responseType = "blob";
xhr.onload = function () {
if (xhr.status === 200) {
AppsService.installAppBlob(xhr.response).then(resolve, reject);
}
};
_this._xhrAttachErrorListeners(xhr, reject, app.peer);
xhr.send();
});
};
HttpClientService.prototype.sendPeerInfo = function (fromPeer, toPeer) {
var _this2 = this;
return new Promise(function (resolve, reject) {
var url = UrlService.getPeerUrl(toPeer);
var body = Peer.stringify(fromPeer);
var xhr = new XMLHttpRequest({ mozAnon: true, mozSystem: true });
xhr.open("POST", url);
xhr.onload = function () {
if (xhr.status === 200) {
resolve();
}
};
_this2._xhrAttachErrorListeners(xhr, reject, toPeer);
xhr.send(body);
});
};
HttpClientService.prototype.signalDisconnecting = function (peer) {
return new Promise(function (resolve, reject) {
var xhr = new XMLHttpRequest({ mozAnon: true, mozSystem: true });
xhr.open("GET", UrlService.getPeerDisconnectUrl(peer));
xhr.send();
});
};
HttpClientService.prototype._xhrAttachErrorListeners = function (xhr, reject, peer) {
var _this3 = this;
xhr.timeout = TIMEOUT;
xhr.ontimeout = function () {
reject({ name: "Timeout" });
_this3._dispatchEvent("disconnect", { peer: peer });
};
xhr.onerror = function () {
reject({ name: "Network error" });
_this3._dispatchEvent("disconnect", { peer: peer });
};
xhr.addEventListener("load", function () {
if (xhr.status !== 200) {
reject({ name: "HTTP error", message: xhr.status });
_this3._dispatchEvent("disconnect", { peer: peer });
}
});
};
return HttpClientService;
})(Service);
exports["default"] = new HttpClientService();
});

View file

@ -0,0 +1,165 @@
define(["exports", "fxos-web-server/dist/fxos-web-server", "fxos-mvc/dist/mvc", "app/js/models/app", "app/js/services/device_name_service", "app/js/services/share_service"], function (exports, _fxosWebServerDistFxosWebServer, _fxosMvcDistMvc, _appJsModelsApp, _appJsServicesDeviceNameService, _appJsServicesShareService) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Service = _fxosMvcDistMvc.Service;
var App = _appJsModelsApp["default"];
var DeviceNameService = _appJsServicesDeviceNameService["default"];
var ShareService = _appJsServicesShareService["default"];
/*import P2pService from 'app/js/services/p2p_service';*/
var HttpServerService = (function (Service) {
var HttpServerService = function HttpServerService() {
var _this = this;
Service.call(this);
this._cache = {};
window.addEventListener("beforeunload", this._deactivate.bind(this));
DeviceNameService.addEventListener("devicenamechange", function (e) {
_this._deviceName = e.deviceName;
}, true);
this._activate();
};
_extends(HttpServerService, Service);
HttpServerService.prototype.clearPeerCache = function (peer) {
delete this._cache[peer.address];
};
HttpServerService.prototype._serverPeer = function (evt) {
var response = evt.response;
var request = evt.request;
var body = request.body;
var data = JSON.parse(body);
data.address = response.socket.host;
if (this._cache[data.address] !== body) {
this._cache[data.address] = body;
// XXX/drs: We get "P2pService undefined" errors if we try using it
// directly. I'm not sure why, but it's probably some kind of circular
// reference issue. For now, this fixes it, but we should figure out why
// we have to do this.
window.p2pService.receivePeerInfo(data);
}
response.send("");
};
HttpServerService.prototype._getAppFromRequest = function (evt) {
return new Promise(function (resolve, reject) {
var request = evt.request;
var appId = decodeURIComponent(request.params.app || "");
ShareService.getApps().then(function (apps) {
var app = App.getApp(apps, { manifestURL: appId });
if (app) {
resolve(app);
} else {
reject();
}
}, reject);
});
};
HttpServerService.prototype._serverManifest = function (evt) {
var response = evt.response;
this._getAppFromRequest(evt).then(function (app) {
response.headers["Content-Type"] = "application/x-web-app-manifest+json";
var manifest = app.manifest;
response.send(JSON.stringify(manifest));
}, function () {
return response.send("");
});
};
HttpServerService.prototype._serverDownload = function (evt) {
var response = evt.response;
this._getAppFromRequest(evt).then(function (app) {
app["export"]().then(function (blob) {
response.headers["Content-Type"] = blob.type;
response.sendFile(blob);
});
}, function () {
return response.send("");
});
};
HttpServerService.prototype._serverDisconnect = function (evt) {
var response = evt.response;
var peer = { address: response.socket.host };
window.p2pService.receivePeerDisconnect(peer);
this.clearPeerCache(peer);
response.send("");
};
HttpServerService.prototype._activate = function () {
var _this2 = this;
if (this.httpServer) {
return;
}
this.httpServer = new HTTPServer(8080);
this.httpServer.addEventListener("request", function (evt) {
var request = evt.request;
var path = request.path;
var routes = {
"/manifest.webapp": function (evt) {
return _this2._serverManifest(evt);
},
"/download": function (evt) {
return _this2._serverDownload(evt);
},
"/disconnect": function (evt) {
return _this2._serverDisconnect(evt);
},
"/peer": function (evt) {
return _this2._serverPeer(evt);
},
"/": function (evt) {
return evt.response.send("");
}
};
var route = routes[path];
if (route) {
route(evt);
}
});
this.httpServer.start();
};
HttpServerService.prototype._deactivate = function () {
if (!this.httpServer) {
return;
}
this.httpServer.stop();
this.httpServer = null;
};
return HttpServerService;
})(Service);
exports["default"] = new HttpServerService();
});

View file

@ -0,0 +1,62 @@
define(["exports", "fxos-mvc/dist/mvc"], function (exports, _fxosMvcDistMvc) {
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Service = _fxosMvcDistMvc.Service;
var singletonGuard = {};
var instance;
/* jshint -W101 */
var icons = ["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAANCAYAAAB2HjRBAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2hpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowMTgwMTE3NDA3MjA2ODExOEM5RkVDOTQxRDNGQzczQSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpBQjI5NUNCQzZBQ0ExMUUxOTEwMkY4NzAyQjVDRTJERCIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpBQjI5NUNCQjZBQ0ExMUUxOTEwMkY4NzAyQjVDRTJERCIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ1M1LjEgTWFjaW50b3NoIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NkY0OTRDMTgxNTIwNjgxMUIzNjVENjU0NThENUFEQkEiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6MDE4MDExNzQwNzIwNjgxMThDOUZFQzk0MUQzRkM3M0EiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz5n+0vmAAAA40lEQVR42mL8KCbBAAWWQBwOxJxAvAaIdzMggDEQRwHxXyDeBMRHQIKMUM2ZQDwZiJmRNDQBcT0Q50DlkEExEPeBNIsCGQ+hNjJgUdSFZigI/AJiDRYg4YpDIwj04hBnA+JAJiAhx0AekABpfk2m5hcgP/MDGTdAJpGg8QsQq4Js/gjEQVABYgBM/QsmqMBxINaD0vjADiDWhqUBJiSJ+0BsBcRZQPwdTRMocZQBsScQP4UJMmExfToQm4OcBeWDDAoF4m50hUw4nHcZassvqMb12BSx4PHfBSC2BeJTuBQABBgAkf0rYAW2ug4AAAAASUVORK5CYII=", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAAAE1JREFUOE9jYACC/2QAkD6wxqamJpIxSB9ezfgMxqsZ3SforsOpGWYjWTYPnGaQ/5ABttggOrSx+X0QaiYUx7AwoU0KI5TewQFGSa4CAIp5nbtWcD+xAAAAAElFTkSuQmCC", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAATCAYAAAB2pebxAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHRJREFUeNrM1G0KwCAIBuCMzuqhvKz7AEcrNbdF7P1Z9oAZATOnr4ElCBGdBYgIrxABJBZkIi3gQSpSA/shWTOhDtGAak+FbogHeNCFRAALysrFDd9FW5PThExBSrR3r9X/tKOO+EmOEZuPLQqs+08i2QQYAIoIXFlI2XeyAAAAAElFTkSuQmCC", "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAF9JREFUeNpiYKA34AfieiB+D8T/ofg9VIwfm+LzSArR8Xl0DSBT/r9//x6McWiqR9bwnggN7xmRNPwnxpNMpIYKsoYPRKj/wIzE4QBiBwIaOtAFSApW5ODFFnFgABBgADYiOslAa4FxAAAAAElFTkSuQmCC"];
var IconService = (function (Service) {
var IconService = function IconService(guard) {
if (guard !== singletonGuard) {
console.error("Cannot create singleton class");
return;
}
Service.call(this);
};
_extends(IconService, Service);
_classProps(IconService, {
instance: {
get: function () {
if (!instance) {
instance = new this(singletonGuard);
}
return instance;
}
}
}, {
icons: {
get: function () {
return icons;
}
}
});
return IconService;
})(Service);
exports["default"] = IconService;
});

View file

@ -0,0 +1,267 @@
define(["exports", "dns-sd.js/dist/dns-sd", "fxos-mvc/dist/mvc", "app/js/models/peer", "app/js/services/apps_service", "app/js/services/broadcast_service", "app/js/services/device_name_service", "app/js/services/http_client_service", "app/js/services/http_server_service", "app/js/services/share_service", "app/js/services/wifi_service"], function (exports, _dnsSdJsDistDnsSd, _fxosMvcDistMvc, _appJsModelsPeer, _appJsServicesAppsService, _appJsServicesBroadcastService, _appJsServicesDeviceNameService, _appJsServicesHttpClientService, _appJsServicesHttpServerService, _appJsServicesShareService, _appJsServicesWifiService) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Service = _fxosMvcDistMvc.Service;
var Peer = _appJsModelsPeer["default"];
var AppsService = _appJsServicesAppsService["default"];
var BroadcastService = _appJsServicesBroadcastService["default"];
var DeviceNameService = _appJsServicesDeviceNameService["default"];
var HttpClientService = _appJsServicesHttpClientService["default"];
var HttpServerService = _appJsServicesHttpServerService["default"];
var ShareService = _appJsServicesShareService["default"];
var WifiService = _appJsServicesWifiService["default"];
/*import IconService from 'app/js/services/icon_service';*/
var P2pService = (function (Service) {
var P2pService = function P2pService() {
var _this = this;
Service.call(this);
window.p2pService = this;
this._peers = [];
this._ipAddresses = new Promise(function (resolve, reject) {
IPUtils.getAddresses(function (ipAddress) {
// XXX/drs: This will break if we have multiple IP addresses.
resolve([ipAddress]);
});
});
this._enableP2pConnection();
window.addEventListener("visibilitychange", function () {
return DNSSD.startDiscovery();
});
window.addEventListener("beforeunload", function () {
return _this._beforeUnload();
});
AppsService.addEventListener("updated", function () {
return _this.sendPeersInfo();
});
DeviceNameService.addEventListener("devicenamechange", function () {
return _this.sendPeersInfo();
});
HttpClientService.addEventListener("disconnect", function (e) {
return _this.receivePeerInfo({ address: e.peer.address });
});
BroadcastService.addEventListener("broadcast", function () {
return _this.sendPeersInfo();
});
ShareService.addEventListener("share", function () {
return _this.sendPeersInfo();
});
WifiService.addEventListener("statuschange", function (status) {
return _this._wifiStatusChange(status);
});
};
_extends(P2pService, Service);
P2pService.prototype.getApps = function () {
if (!this._peers.length) {
return [];
}
var reduceApps = function (el) {
var apps = el && el.apps || [];
return apps.map(function (app) {
app.peer = el;
return app;
});
};
if (this._peers.length === 1) {
return reduceApps(this._peers[0]);
}
return this._peers.reduce(function (prev, cur) {
return reduceApps(prev).concat(reduceApps(cur));
});
};
P2pService.prototype.receivePeerInfo = function (peer) {
var _this2 = this;
for (var i = 0; i < this._peers.length; i++) {
if (this._peers[i].address === peer.address) {
if (peer.address && Object.keys(peer).length === 1) {
HttpServerService.clearPeerCache(peer);
this._peers.splice(i, 1);
this._dispatchEvent("proximity");
return;
}
if (this._peers[i].session !== peer.session) {
Peer.getMe().then(function (me) {
return _this2._sendPeerInfo(me, peer);
});
}
this._peers[i] = peer;
this._dispatchEvent("proximity");
return;
}
}
this._peers.push(peer);
this._dispatchEvent("proximity");
};
P2pService.prototype._sendPeerInfo = function (me, peer) {
HttpClientService.sendPeerInfo(me, peer);
};
P2pService.prototype.sendPeersInfo = function () {
var _this3 = this;
Peer.getMe().then(function (me) {
return _this3._peers.forEach(function (peer) {
return _this3._sendPeerInfo(me, peer);
});
});
};
P2pService.prototype.receivePeerDisconnect = function (peer) {
for (var i = 0; i < this._peers.length; i++) {
if (this._peers[i].address === peer.address) {
this._peers.splice(i, 1);
this._dispatchEvent("proximity");
}
}
};
P2pService.prototype._deletePeer = function (peer) {
this.receivePeerInfo({ address: peer.address });
};
P2pService.prototype._enableP2pConnection = function () {
var _this4 = this;
DNSSD.registerService("_fxos-sharing._tcp.local", 8080, {});
DNSSD.addEventListener("discovered", function (e) {
var isSharingPeer = e.services.find(function (service) {
return service === "_fxos-sharing._tcp.local";
});
if (!isSharingPeer) {
return;
}
var address = e.address;
_this4._ipAddresses.then(function (ipAddresses) {
// Make sure we're not trying to connect to ourself.
if (ipAddresses.indexOf(address) !== -1) {
return;
}
var peer = { address: address };
Peer.getMe().then(function (me) {
_this4._sendPeerInfo(me, peer);
});
});
});
DNSSD.startDiscovery();
setInterval(function () {
return DNSSD.startDiscovery();
}, 30000 /* every 30 seconds */);
setInterval(function () {
return _this4.sendPeersInfo();
}, 30000 /* every 30 seconds */);
};
P2pService.prototype._beforeUnload = function () {
this._peers.forEach(function (peer) {
HttpClientService.signalDisconnecting(peer);
});
};
P2pService.prototype._wifiStatusChange = function (status) {
if (status !== "connected") {
this._peers = [];
this._dispatchEvent("proximity");
}
}
/**
* Debug tool. Used only to insert fake data for testing.
*/
/*
insertFakeData() {
var icons = IconService.instance.icons;
setTimeout(() => {
this._updatePeerInfo('127.0.0.1', {name: '', apps: [{
manifestURL: 'abc',
icon: icons[0],
manifest: {
name: 'Sharing',
description: 'doo',
developer: {
name: 'Dougiashdfihajksdhfkashdfkjhkasjhdfasdffd'
}
},
}, {
manifestURL: 'def',
icon: icons[1],
manifest: {
name: 'HelloWorld',
description: 'too',
developer: {
name: 'Hammasjdjkfhakshdfjkhaskjd'
}
}
}, {
manifestURL: 'ghi',
icon: icons[2],
manifest: {
name: 'Rail Rush',
description: 'game',
developer: {
name: 'Gamer'
}
}
}], addons: [{
manifestURL: 'jkl',
icon: icons[3],
role: 'addon',
manifest: {
name: 'test',
description: 'ham',
developer: {
name: 'abcabcacbasdasdasd'
}
}
}]});
}, 0);
setTimeout(() => {
this._updatePeerInfo('192.168.100.100', {name: 'garbage', apps: []});
}, 2000);
}
*/
;
return P2pService;
})(Service);
exports["default"] = new P2pService();
});

View file

@ -0,0 +1,161 @@
define(["exports", "fxos-mvc/dist/mvc", "app/js/models/app", "app/js/services/apps_service", "app/js/services/broadcast_service"], function (exports, _fxosMvcDistMvc, _appJsModelsApp, _appJsServicesAppsService, _appJsServicesBroadcastService) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Service = _fxosMvcDistMvc.Service;
var App = _appJsModelsApp["default"];
var AppsService = _appJsServicesAppsService["default"];
var BroadcastService = _appJsServicesBroadcastService["default"];
// Prune the database 60 seconds after opening the app.
var PRUNE_TIMER = 60000;
var ShareService = (function (Service) {
var ShareService = function ShareService() {
var _this = this;
Service.call(this);
this._shares = {};
this._initialized = new Promise(function (resolve, reject) {
navigator.getDataStores("p2p_shares").then(function (stores) {
_this._store = stores[0];
_this._store.getLength().then(function (length) {
if (!length) {
resolve();
return;
}
var cursor = _this._store.sync();
_this._runNextTask(cursor, resolve, reject, function (id, data) {
return _this._loadShare(id, data);
});
});
});
setTimeout(function () {
return _this._pruneStore();
}, PRUNE_TIMER);
}).then(function () {
return _this._dispatchEvent("share");
});
};
_extends(ShareService, Service);
ShareService.prototype.getApps = function (options) {
var _this2 = this;
options = options || {};
return new Promise(function (resolve, reject) {
Promise.all([BroadcastService.getBroadcast(), AppsService.getApps(), _this2._initialized]).then(function (results) {
var broadcast = results[0];
if (!broadcast && !options.ignoreBroadcast) {
resolve([]);
return;
}
var apps = results[1];
resolve(apps.filter(function (app) {
return !!_this2._shares[app.manifestURL];
}));
}, reject);
});
};
ShareService.prototype.setAppShare = function (app, enable) {
var _this3 = this;
return new Promise(function (resolve, reject) {
if (enable) {
_this3._store.add(app.manifestURL).then(function (id) {
_this3._loadShare(id, app.manifestURL);
resolve();
_this3._dispatchEvent("share");
}, reject);
} else {
_this3._store.remove(_this3._shares[app.manifestURL]).then(function (success) {
if (success) {
delete _this3._shares[app.manifestURL];
resolve();
_this3._dispatchEvent("share");
} else {
reject();
}
}, reject);
}
});
};
ShareService.prototype._runNextTask = function (cursor, resolve, reject, cb) {
var _this4 = this;
cursor.next().then(function (task) {
return _this4._manageTask(cursor, task, resolve, reject, cb);
});
};
ShareService.prototype._manageTask = function (cursor, task, resolve, reject, cb) {
switch (task.operation) {
case "done":
resolve();
break;
case "add":
cb(task.id, task.data);
/* falls through */
default:
this._runNextTask(cursor, resolve, reject, cb);
break;
}
};
ShareService.prototype._loadShare = function (id, manifestURL) {
this._shares[manifestURL] = id;
};
ShareService.prototype._pruneShare = function (id, data) {
var _this5 = this;
AppsService.getApps().then(function (apps) {
var app = App.getApp(apps, { manifestURL: data });
// If this app isn't installed, or has occurred multiple times in the
// DataStore, delete it.
if (!app || _this5._prunedShares[data]) {
_this5._store.remove(id);
}
_this5._prunedShares[data] = id;
});
};
ShareService.prototype._pruneStore = function () {
var _this6 = this;
new Promise(function (resolve, reject) {
_this6._initialized.then(function () {
// Keep an array with all of the app instances that we've run into so
// far, to determine uniqueness.
_this6._prunedShares = {};
var cursor = _this6._store.sync();
_this6._runNextTask(cursor, resolve, reject, function (id, data) {
return _this6._pruneShare(id, data);
});
});
// Clear the array as it's no longer needed.
}).then(function () {
return delete _this6._prunedShares;
});
};
return ShareService;
})(Service);
exports["default"] = new ShareService();
});

View file

@ -0,0 +1,50 @@
define(["exports", "fxos-mvc/dist/mvc"], function (exports, _fxosMvcDistMvc) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Service = _fxosMvcDistMvc.Service;
var UrlService = (function (Service) {
var UrlService = function UrlService() {
Service.apply(this, arguments);
};
_extends(UrlService, Service);
UrlService.getPeerUrl = function (peer) {
return "http://" + peer.address + ":8080/peer";
};
UrlService.getPeerPingUrl = function (peer) {
return "http://" + peer.address + ":8080";
};
UrlService.getPeerDisconnectUrl = function (peer) {
return "http://" + peer.address + ":8080/disconnect";
};
UrlService.getAppDownloadUrl = function (app) {
var id = encodeURIComponent(app.manifestURL);
return "http://" + app.peer.address + ":8080/download?app=" + id;
};
UrlService.getAppManifestUrl = function (app) {
var id = encodeURIComponent(app.manifestURL);
return "http://" + app.peer.address + ":8080/manifest?app=" + id;
};
return UrlService;
})(Service);
exports["default"] = UrlService;
});

View file

@ -0,0 +1,41 @@
define(["exports", "fxos-mvc/dist/mvc"], function (exports, _fxosMvcDistMvc) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var Service = _fxosMvcDistMvc.Service;
var WifiService = (function (Service) {
var WifiService = function WifiService(options) {
var _this = this;
Service.call(this, options);
navigator.mozWifiManager.addEventListener("statuschange", function (e) {
return _this._statusChange(e.status);
});
};
_extends(WifiService, Service);
WifiService.prototype.isConnected = function () {
return navigator.mozWifiManager.connection.status === "connected";
};
WifiService.prototype._statusChange = function (status) {
this._dispatchEvent("statuschange", { status: status });
};
return WifiService;
})(Service);
exports["default"] = new WifiService();
});

View file

@ -0,0 +1,83 @@
define(["exports", "fxos-mvc/dist/mvc", "gaia-button"], function (exports, _fxosMvcDistMvc, _gaiaButton) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var View = _fxosMvcDistMvc.View;
var AppView = (function (View) {
var AppView = function AppView(options) {
View.call(this, options);
this.el = document.createElement("div");
this.el.id = "app-view";
this.render();
};
_extends(AppView, View);
AppView.prototype.template = function () {
var string = "\n <gaia-header action=\"close\" data-action=\"close\">\n <h1></h1>\n </gaia-header>\n <gaia-list class=\"app-list\">\n <li>\n <img></img>\n <div flex class=\"description\">\n <h3></h3>\n <h4></h4>\n </div>\n <gaia-button class=\"control\">\n <span></span>\n </gaia-button>\n </li>\n </gaia-list>\n <p></p>\n ";
return string;
};
AppView.prototype.render = function () {
var _this = this;
View.prototype.render.call(this);
setTimeout(function () {
_this.on("action", "gaia-header");
_this.on("click", "gaia-button");
_this.els = {};
_this.els.title = _this.$("h1");
_this.els.icon = _this.$("img");
_this.els.name = _this.$("h3");
_this.els.owner = _this.$("h4");
_this.els.description = _this.$("p");
_this.els.button = _this.$("gaia-button");
_this.els.buttonText = _this.els.button.querySelector("span");
});
};
AppView.prototype.show = function (app) {
this.el.classList.add("active");
this.els.icon.src = app.icon || "icons/default.png";
this.els.title.textContent = app.manifest.name;
this.els.name.textContent = app.manifest.name;
this.els.owner.textContent = app.manifest.developer && app.manifest.developer.name;
this.els.description.textContent = app.manifest.description;
this.els.button.dataset.id = app.manifestURL;
this.els.button.dataset.action = app.installed ? "open" : "download";
this.els.button.disabled = false;
if (app.installed) {
if (app.manifest.role === "addon" || app.manifest.role === "theme") {
this.els.buttonText.textContent = "Installed";
this.els.button.disabled = true;
} else {
this.els.buttonText.textContent = "Open";
}
} else {
this.els.buttonText.textContent = "Install";
}
};
AppView.prototype.hide = function () {
this.el.classList.remove("active");
};
return AppView;
})(View);
exports["default"] = AppView;
});

View file

@ -0,0 +1,72 @@
define(["exports", "fxos-mvc/dist/mvc", "gaia-dialog"], function (exports, _fxosMvcDistMvc, _gaiaDialog) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var View = _fxosMvcDistMvc.View;
var ConfirmDownloadView = (function (View) {
var ConfirmDownloadView = function ConfirmDownloadView() {
View.apply(this, arguments);
};
_extends(ConfirmDownloadView, View);
ConfirmDownloadView.prototype.template = function () {
var string = "\n <section>\n <img></img>\n <div>\n <h3><strong></strong></h3>\n <h4></h4>\n </div>\n <hr/>\n <p>Do you want to download and install this application?</p>\n </section>\n <fieldset>\n <button data-action=\"cancel\">Cancel</button>\n <button class=\"primary\" data-action=\"install\">Install</button>\n </fieldset>\n ";
return string;
};
ConfirmDownloadView.prototype.render = function () {
var _this = this;
this.el = document.createElement("gaia-dialog");
this.el.classList.add("install");
this.el.addEventListener("opened", function () {
return _this._opened();
});
this.el.addEventListener("closed", function () {
return _this._closed();
});
View.prototype.render.call(this);
setTimeout(function () {
_this._icon = _this.$("img");
_this._header = _this.$("h3 strong");
_this._subheader = _this.$("h4");
});
};
ConfirmDownloadView.prototype.open = function (app) {
this._icon.src = app.icon;
this._header.textContent = app.manifest.name;
this._subheader.textContent = (app.manifest.developer && app.manifest.developer.name) || app.manifest.description;
this.el.open();
};
ConfirmDownloadView.prototype.close = function () {
this.el.close();
};
ConfirmDownloadView.prototype._opened = function () {
this.on("click", "button");
};
ConfirmDownloadView.prototype._closed = function () {
this.off("click", "button");
};
return ConfirmDownloadView;
})(View);
exports["default"] = ConfirmDownloadView;
});

View file

@ -0,0 +1,80 @@
define(["exports", "fxos-mvc/dist/mvc", "gaia-icons", "gaia-dialog/gaia-dialog-prompt", "app/js/services/device_name_service"], function (exports, _fxosMvcDistMvc, _gaiaIcons, _gaiaDialogGaiaDialogPrompt, _appJsServicesDeviceNameService) {
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var View = _fxosMvcDistMvc.View;
var DeviceNameService = _appJsServicesDeviceNameService["default"];
var DeviceNameView = (function (View) {
var DeviceNameView = function DeviceNameView() {
View.apply(this, arguments);
};
_extends(DeviceNameView, View);
DeviceNameView.prototype.render = function () {
var _this = this;
this.el = document.createElement("gaia-dialog-prompt");
View.prototype.render.call(this);
setTimeout(function () {
_this.els = _this.el.els;
_this.els.submit.addEventListener("click", function (e) {
return _this.controller.handleSubmit(e);
});
_this.els.submit.disabled = true;
_this.el.addEventListener("opened", function (e) {
return _this.controller.handleOpened(e);
});
_this.el.addEventListener("closed", function (e) {
return _this.controller.handleClosed(e);
});
_this.els.input.placeholder = "Name your device";
_this.els.input.addEventListener("input", function (e) {
return _this.controller.handleInput(e);
});
DeviceNameService.getDeviceName().then(function (deviceName) {
_this.value = deviceName;
if (deviceName) {
_this.els.submit.disabled = false;
}
});
});
};
_classProps(DeviceNameView, null, {
value: {
get: function () {
return this.els.input.value;
},
set: function (val) {
this.els.input.value = val;
}
}
});
return DeviceNameView;
})(View);
exports["default"] = DeviceNameView;
});

View file

@ -0,0 +1,97 @@
define(["exports", "fxos-mvc/dist/mvc", "gaia-list", "gaia-checkbox", "gaia-sub-header", "gaia-loading", "gaia-button", "gaia-icons"], function (exports, _fxosMvcDistMvc, _gaiaList, _gaiaCheckbox, _gaiaSubHeader, _gaiaLoading, _gaiaButton, _gaiaIcons) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var View = _fxosMvcDistMvc.View;
var ListView = (function (View) {
var ListView = function ListView(options) {
View.call(this, options);
this.el = document.createElement("div");
this.el.id = options.id;
this.el.classList.add("app-list");
this.el.classList.add(options.type);
if (options.disabled) {
this.el.setAttribute("disabled", true);
}
this.title = options.title;
this.type = options.type;
this.attr = options.attr;
};
_extends(ListView, View);
ListView.prototype.layout = function (template) {
var string = "\n <gaia-sub-header>" + this.title + "</gaia-sub-header>\n <gaia-list>\n " + template + "\n </gaia-list>";
return string;
};
ListView.prototype.render = function (params) {
if (!params.length) {
this.el.innerHTML = "";
return;
}
View.prototype.render.call(this, params);
this.on("click", ".app-list li *");
};
ListView.prototype.template = function (app) {
var desc = (app.peer && app.peer.name) || (app.manifest.developer && app.manifest.developer.name) || app.manifest.description || "No information available";
desc = "<h4>" + desc + "</h4>";
if (this.type === "link") {
desc = "";
}
var toggle = (this.type === "toggle" && "data-action=\"toggle\"") || "";
var string = "\n <li tabindex=\"0\" " + toggle + ">\n <img data-action=\"description\" data-id=\"" + app.manifestURL + "\"\n src=\"" + app.icon + "\"></img>\n <div flex class=\"description\" data-action=\"description\"\n data-id=\"" + app.manifestURL + "\">\n <h3>" + app.manifest.name + "</h3>\n " + desc + "\n </div>\n " + this._control(app) + "\n </li>";
return string;
};
ListView.prototype.toggle = function (enable) {
if (enable) {
this.el.setAttribute("disabled", "");
} else {
this.el.removeAttribute("disabled");
}
};
ListView.prototype._control = function (app) {
var string;
if (this.type === "toggle") {
var enabled = app.shared && "checked" || "";
string = "<gaia-checkbox data-id=\"" + app.manifestURL + "\" data-action=\"toggle\"\n class=\"control\" " + enabled + ">\n </gaia-checkbox>";
} else if (this.type === "download") {
if (app.installed) {
if (app.manifest.role === "addon" || app.manifest.role === "theme") {
string = "<gaia-button disabled>Installed</gaia-button>";
} else {
string = "<gaia-button data-id=\"" + app.manifestURL + "\" data-action=\"open\"\n class=\"control\">\n Open\n </gaia-button>";
}
} else {
string = "<gaia-button data-id=\"" + app.manifestURL + "\" data-action=\"download\"\n class=\"control\">\n Install\n </gaia-button>";
}
} else if (this.type === "link") {
string = "<i data-id=\"" + app.manifestURL + "\" data-action=\"open\"\n aria-hidden=\"true\" data-icon=\"forward-light\"></i>";
}
return string;
};
return ListView;
})(View);
exports["default"] = ListView;
});

View file

@ -0,0 +1,37 @@
define(["exports", "fxos-mvc/dist/mvc", "gaia-header", "gaia-icons", "fxos-dev-mode-dialog"], function (exports, _fxosMvcDistMvc, _gaiaHeader, _gaiaIcons, _fxosDevModeDialog) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var View = _fxosMvcDistMvc.View;
var MainView = (function (View) {
var MainView = function MainView(options) {
View.call(this, options);
this.els = {};
this.els.devModeDialog = document.createElement("fxos-dev-mode-dialog");
this.el.appendChild(this.els.devModeDialog);
this.on("action", "gaia-header");
this.on("contextmenu", "gaia-header h1");
};
_extends(MainView, View);
MainView.prototype.render = function () {};
return MainView;
})(View);
exports["default"] = MainView;
});

View file

@ -0,0 +1,73 @@
define(["exports", "fxos-mvc/dist/mvc", "gaia-dialog", "gaia-progress", "gaia-button"], function (exports, _fxosMvcDistMvc, _gaiaDialog, _gaiaProgress, _gaiaButton) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var View = _fxosMvcDistMvc.View;
var ProgressDialogView = (function (View) {
var ProgressDialogView = function ProgressDialogView() {
View.apply(this, arguments);
};
_extends(ProgressDialogView, View);
ProgressDialogView.prototype.template = function () {
var string = "\n <h1>Downloading app</h1>\n <gaia-progress></gaia-progress>\n ";
return string;
};
ProgressDialogView.prototype.render = function () {
this.el = document.createElement("gaia-dialog");
View.prototype.render.call(this);
this.el.addEventListener("closed", this.controller.teardown.bind(this.controller));
this.el.addEventListener("touchstart", this._handleTouchStart.bind(this));
};
ProgressDialogView.prototype.success = function (app) {
this.el.innerHTML = "\n <p>Successfully downloaded " + app.manifest.name + "!</p>\n ";
this._loading = false;
};
ProgressDialogView.prototype.error = function (e) {
var _this = this;
this.el.innerHTML = "\n <p>Error downloading app: " + (e.name || "") + " " + (e.description || "") + "</p>\n <section><gaia-button>Ok</gaia-button></section>\n ";
this._loading = false;
setTimeout(function () {
var button = _this.el.querySelector("gaia-button");
button.addEventListener("click", _this.close.bind(_this));
});
};
ProgressDialogView.prototype.open = function (app) {
this.el.open();
this._loading = true;
};
ProgressDialogView.prototype.close = function () {
this.el.close();
};
ProgressDialogView.prototype._handleTouchStart = function (e) {
if (this._loading) {
e.preventDefault();
}
};
return ProgressDialogView;
})(View);
exports["default"] = ProgressDialogView;
});

View file

@ -0,0 +1,57 @@
define(["exports", "fxos-mvc/dist/mvc"], function (exports, _fxosMvcDistMvc) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var View = _fxosMvcDistMvc.View;
var ProximityEmptyView = (function (View) {
var ProximityEmptyView = function ProximityEmptyView(options) {
this.el = document.createElement("gaia-list");
this.el.id = "proximity-empty-list";
View.call(this, options);
this.els = {};
};
_extends(ProximityEmptyView, View);
ProximityEmptyView.prototype.template = function () {
var string = "<li class=\"hide\"></li>\n <li id=\"no-network\" class=\"hide\">\n You are not currently connected to a WiFi network. Connect to one to\n discover people nearby to share with.\n </li>\n <li id=\"proximity-empty\" class=\"hide\">\n <div>\n No users found sharing on your WiFi network.\n <gaia-loading></gaia-loading>\n </div>\n </li>";
return string;
};
ProximityEmptyView.prototype.render = function () {
var _this = this;
View.prototype.render.call(this);
setTimeout(function () {
_this.els.noNetwork = _this.$("#no-network");
_this.els.proximityEmpty = _this.$("#proximity-empty");
});
};
ProximityEmptyView.prototype.show = function (params) {
var _this2 = this;
setTimeout(function () {
_this2.el.classList.toggle("hide", !params.noNetwork && !params.proximityEmpty);
_this2.els.noNetwork.classList.toggle("hide", !params.noNetwork);
_this2.els.proximityEmpty.classList.toggle("hide", params.noNetwork || !params.proximityEmpty);
});
};
return ProximityEmptyView;
})(View);
exports["default"] = ProximityEmptyView;
});

View file

@ -0,0 +1,100 @@
define(["exports", "fxos-mvc/dist/mvc", "gaia-button", "gaia-switch"], function (exports, _fxosMvcDistMvc, _gaiaButton, _gaiaSwitch) {
"use strict";
var _classProps = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var View = _fxosMvcDistMvc.View;
var ShareSettingsView = (function (View) {
var ShareSettingsView = function ShareSettingsView(options) {
View.call(this, options);
this.el = document.createElement("gaia-list");
this.el.id = "share-settings";
this.el.classList.add("app-list");
this.render();
};
_extends(ShareSettingsView, View);
ShareSettingsView.prototype.render = function () {
var _this = this;
View.prototype.render.call(this);
setTimeout(function () {
_this.els = {};
_this.els.shareEnabled = _this.$("#share-enabled");
_this.els.shareEnabled.addEventListener("change", function (e) {
return _this._handleShareEnabledChange(e);
});
_this.els.shareDescription = _this.$("#share-description");
_this.els.renameDevice = _this.$("#rename-device");
_this.els.deviceName = _this.$("#device-name");
_this.on("click", "#rename-device");
});
};
ShareSettingsView.prototype.template = function () {
var string = "<li>\n <div flex>\n <h3>Share My Apps</h3>\n <h4 id=\"share-description\">Turn on to share apps</h4>\n </div>\n <gaia-switch id=\"share-enabled\"></gaia-switch>\n </li>\n <li>\n <div flex>\n <h3>Device Name</h3>\n <h4 id=\"device-name\">Loading...</h4>\n </div>\n <a aria-disabled=\"true\" data-action=\"rename\" id=\"rename-device\">\n Rename\n </a>\n </li>";
return string;
};
ShareSettingsView.prototype.displayBroadcast = function (enabled) {
var _this2 = this;
setTimeout(function () {
_this2.els.shareDescription.textContent = enabled ? "Sharing On" : "Turn on to share apps";
if (enabled) {
_this2.els.shareEnabled.setAttribute("checked", "");
} else {
_this2.els.shareEnabled.removeAttribute("checked");
}
}, 0);
};
ShareSettingsView.prototype._handleShareEnabledChange = function (e) {
this.controller.toggleBroadcasting(e.target.checked);
};
_classProps(ShareSettingsView, null, {
deviceName: {
get: function () {
console.error("DONT USE ME LOL!");
return this.els.deviceName.textContent;
},
set: function (deviceName) {
var _this3 = this;
setTimeout(function () {
_this3.els.renameDevice.removeAttribute("aria-disabled");
_this3.els.deviceName.textContent = deviceName;
});
}
}
});
return ShareSettingsView;
})(View);
exports["default"] = ShareSettingsView;
});

View file

@ -0,0 +1,59 @@
define(["exports", "fxos-mvc/dist/mvc", "gaia-list"], function (exports, _fxosMvcDistMvc, _gaiaList) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var View = _fxosMvcDistMvc.View;
var ShareSummaryView = (function (View) {
var ShareSummaryView = function ShareSummaryView(options) {
View.call(this, options);
this.el = document.createElement("gaia-list");
this.el.id = "sharing-summary";
this.el.addEventListener("click", this._handleClick.bind(this));
this.el.classList.add("app-list");
this.render();
};
_extends(ShareSummaryView, View);
ShareSummaryView.prototype.template = function () {
var string = "\n <li>\n <div flex>\n <h3>Share My Apps</h3>\n <h4 id=\"sharing-summary-status\">Sharing Off</h4>\n </div>\n <i id=\"sharing-summary-caret\" data-icon=\"forward-light\"\n aria-hidden=\"true\"></i>\n </li>";
return string;
};
ShareSummaryView.prototype.render = function () {
var _this = this;
View.prototype.render.call(this);
setTimeout(function () {
_this.broadcastElt = _this.$("#sharing-summary-status");
});
};
ShareSummaryView.prototype.displayBroadcast = function (enable) {
if (this.broadcastElt) {
this.broadcastElt.textContent = "Sharing " + (enable ? "On" : "Off");
}
};
ShareSummaryView.prototype._handleClick = function (e) {
this.controller.openSharePanel();
};
return ShareSummaryView;
})(View);
exports["default"] = ShareSummaryView;
});

View file

@ -0,0 +1,54 @@
define(["exports", "fxos-mvc/dist/mvc"], function (exports, _fxosMvcDistMvc) {
"use strict";
var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
};
var View = _fxosMvcDistMvc.View;
var CompositeTemplate = (function (View) {
var CompositeTemplate = function CompositeTemplate(options) {
var _this = this;
View.call(this, options);
this.el = document.createElement("div");
this.el.id = options.id;
if (options.active) {
this.el.classList.add("active");
}
if (options.header) {
var header = document.createElement("gaia-header");
header.innerHTML = "<h1>" + options.header.title + "</h1>";
if (options.header.action) {
header.setAttribute("action", options.header.action);
header.dataset.action = options.header.action;
this.on("action", "gaia-header");
}
this.el.appendChild(header);
}
options.views.forEach(function (view) {
_this.el.appendChild(view.el);
});
document.body.appendChild(this.el);
};
_extends(CompositeTemplate, View);
CompositeTemplate.prototype.render = function () {};
return CompositeTemplate;
})(View);
exports["default"] = CompositeTemplate;
});