Exemple #1
0
        public Export(IProject project, IFuse fuse, BuildArgs args)
        {
            var output = new Subject <string>();

            LogMessages = output;

            var isMac = fuse.Platform == OS.Mac;

            ExportForAndroid = project.FilePath.CombineLatest(args.All, (path, allArgs) =>
                                                              Command.Enabled(
                                                                  action: () => fuse.RunFuse(
                                                                      "build",
                                                                      new[] { path.NativePath, "-t=android", "--run" }.Concat(allArgs).ToArray(),
                                                                      Observer.Create <string>(output.OnNext))))
                               .Switch();

            ExportForIos = project.FilePath.CombineLatest(args.All, (path, allArgs) =>
                                                          Command.Create(
                                                              isEnabled: isMac,
                                                              action: () => fuse.RunFuse(
                                                                  "build",
                                                                  new[] { path.NativePath, "-t=ios", "--run" }.Concat(allArgs).ToArray(),
                                                                  Observer.Create <string>(output.OnNext))))
                           .Switch();

            Menu = Menu.Item("Export for Android", ExportForAndroid)
                   + Menu.Item("Export for iOS" + (!isMac ? " (Mac only)" : ""), ExportForIos);
        }
Exemple #2
0
        public static void Create(IFuse fuse, Subject <Unit> startedAndroidPreview)
        {
            var showNotification    = new BehaviorSubject <bool>(false);
            var dontCheckForAndroid = UserSettings.Bool("DontCheckForAndroid").AutoInvalidate();

            Application.Desktop.CreateSingletonWindow(
                isVisible: showNotification,
                window: dialog => new Window
            {
                Title   = Observable.Return("No Android tools detected"),
                Size    = Optional.Some(Property.Constant(Optional.Some(new Size <Points>(600, 270)))),
                Content = Control.Lazy(() => CreateContent(showNotification, dontCheckForAndroid))
                          .WithBackground(Theme.PanelBackground),
                Background = Theme.PanelBackground,
                Foreground = Theme.DefaultText,
                Border     = Separator.MediumStroke,
            });

            startedAndroidPreview
            .Take(1)
            .WithLatestFromBuffered(dontCheckForAndroid.Select(v => v.Or(false)), (_, v) => v)
            .Where(v => !v)
            .SubscribeOn(TaskPoolScheduler.Default)
            .Subscribe(_ =>
                       Task.Run(() =>
            {
                if (new AndroidInstaller().Status == ComponentStatus.NotInstalled)
                {
                    showNotification.OnNext(true);
                }
            }));
        }
        public static void Create(IFuse fuse, IObservable <Unit> doneLoadingMainWindow, BehaviorSubject <bool> showSetupGuide)
        {
            var showSublimeNotification   = new BehaviorSubject <bool>(false);
            var dontCheckForSublimePlugin = UserSettings.Bool("DontCheckForSublimePlugin").AutoInvalidate();

            Application.Desktop.CreateSingletonWindow(
                isVisible: showSublimeNotification.CombineLatest(doneLoadingMainWindow, (show, _) => show),
                window: dialog => new Window
            {
                Title   = Observable.Return("No editor plugin detected"),
                Size    = Optional.Some(Property.Constant(Optional.Some(new Size <Points>(600, 270)))),
                Content = Control.Lazy(() => CreateContent(showSublimeNotification, showSetupGuide, dontCheckForSublimePlugin))
                          .WithBackground(Theme.PanelBackground),
                Background = Theme.PanelBackground,
                Foreground = Theme.DefaultText,
                Border     = Separator.MediumStroke,
            });

            dontCheckForSublimePlugin
            .Select(v => v.Or(false))
            .Where(v => !v)
            .Take(1)
            .SubscribeOn(TaskPoolScheduler.Default)
            .Subscribe(_ => Task.Run(() =>
            {
                if (new SublimePlugin(fuse.ModulesDir).Status == ComponentStatus.NotInstalled)
                {
                    showSublimeNotification.OnNext(true);
                }
            }));
        }
 public KillAllCommand(IFuse fuse, ColoredTextWriter coloredConsole, IFuseKiller killer)
     : base("kill-all", "Kill all Fuse processes (even the daemon)")
 {
     _fuse           = fuse;
     _coloredConsole = coloredConsole;
     _killer         = killer;
 }
        public PreviewOnDevice(IFuse fuse, IProject project, BuildArgs args)
        {
            var output = new Subject <string>();

            LogMessages = output;

            var isMac = fuse.Platform == OS.Mac;
            var startedAndroidPreview = new Subject <Unit>();

            MissingAndroidNotification.Create(fuse, startedAndroidPreview);

            PreviewAndroidApp = project.FilePath.CombineLatest(args.All, (path, allArgs) =>
                                                               Command.Enabled(
                                                                   action: () =>
            {
                startedAndroidPreview.OnNext(Unit.Default);
                fuse.RunFuse(
                    "preview",
                    new[] { path.NativePath, "-t=android", "--quit-after-apk-launch" }.Concat(allArgs).ToArray(),
                    Observer.Create <string>(output.OnNext));
            }))
                                .Switch();

            PreviewIosApp = project.FilePath.CombineLatest(args.All, (path, allArgs) =>
                                                           Command.Create(
                                                               isEnabled: isMac,
                                                               action: () => fuse.RunFuse(
                                                                   "preview",
                                                                   new[] { path.NativePath, "-t=ios" }.Concat(allArgs).ToArray(),
                                                                   Observer.Create <string>(output.OnNext))))
                            .Switch();

            Menu = Menu.Item("Preview on Android", PreviewAndroidApp)
                   + Menu.Item("Preview on iOS" + (!isMac ? " (Mac only)" : ""), PreviewIosApp);
        }
Exemple #6
0
        public PreviewCommand(ColoredTextWriter textWriter, PreviewArgumentResolver argumentResolver, PreviewMain preview, IFuse fuse)
            : base("preview", "Preview an app")
        {
            _textWriter       = textWriter;
            _preview          = preview;
            _argumentResolver = argumentResolver;
            _fuse             = fuse;
            _optionSet        = CreateOptions();
            _helpArguments    = new HelpArguments(
                new HelpHeader("fuse " + Name, Description),
                new HelpSynopsis("fuse preview [<Options>] [<AppSource>]"),
                new HelpDetailedDescription(@"Previews an app by using a simulator. 
Your app will instantly reload when there are any saved changes to an UX file. 
<AppSource> can be a relative or an absolute path to a project file. 
It can also be the relative or absolute path to the containing directory of the project.
Working directory is used as <AppSource> if not specified otherwise.

NOTE: The project must contain an UX file with an App tag for preview to work."),
                new HelpOptions(new []
            {
                _optionSet.ToTable(),
                new Table("Preview Targets", new []
                {
                    new Row("Local", "Preview locally (default)"),
                    new Row("Android", "Preview on an Android device."),
                    new Row("iOS", "Preview on an iOS device. NOTE: Only OSX can target this device"),
                    //new Row("MSVC", "Export preview app project for MSVC"),
                    //new Row("Cmake", "Export preview app project for Cmake"),
                }),
            }));
        }
Exemple #7
0
        public SetupGuide(IFuse fuse, IObservable <Unit> doneLoadingMainWindow)
        {
            var output = new Subject <string>();

            LogMessages = output;

            var report    = fuse.Report;
            var softwares = new SoftwareCollectionStatus(fuse);

            var showSetupGuide = new BehaviorSubject <bool>(false);

            MissingPluginNotification.Create(fuse, doneLoadingMainWindow, showSetupGuide);

            Application.Desktop.CreateSingletonWindow(
                isVisible: showSetupGuide.CombineLatest(doneLoadingMainWindow, (s, _) => s),
                window: dialog => new Window
            {
                Title   = Observable.Return("Setup guide"),
                Size    = Optional.Some(Property.Constant(Optional.Some(new Size <Points>(500, 300)))),
                Content = Control.Lazy(() => Create(softwares, report, dialog).ShowWhen(showSetupGuide))
                          .WithBackground(Theme.PanelBackground),
                Background = Theme.PanelBackground,
                Foreground = Theme.DefaultText,
                Border     = Separator.MediumStroke,
                Style      = WindowStyle.Fat,
            });

            Menu
                = Menu.Item("Install Android SDKs", () => fuse.RunFuse("install", new [] { "android" }, Observer.Create <string>(output.OnNext)))
                  + Menu.Item("Setup guide", () => showSetupGuide.OnNext(true));
        }
Exemple #8
0
 static Menu CreateFileMenu(IFuse fuse)
 {
     return(CreateSplashScreenItem()
            + CreateOpenItem()
            + (fuse.Platform == OS.Windows
                                 ? Menu.Separator + CreateQuitItem(fuse)
                                 : Menu.Empty));
 }
Exemple #9
0
        static Menu CreateQuitItem(IFuse fuse)
        {
            var quitOrExit = fuse.Platform == OS.Mac ? "Quit" : "Exit";
            var quitItem   = Menu.Item(
                quitOrExit + " " + "Fuse",
                hotkey: fuse.Platform == OS.Windows ? HotKey.Create(ModifierKeys.Alt, Key.F4) : HotKey.Create(ModifierKeys.Command, Key.Q),
                action: () => { Application.Exit(0); });

            return(quitItem);
        }
 public ComponentInstallers(IFuse fuse)
 {
     Components = new List <ComponentInstaller>
     {
         new AndroidInstaller(),
         new AtomPlugin(),
         new VsCodePlugin(),
         new SublimePlugin(fuse.ModulesDir)
     };
 }
Exemple #11
0
 public PreviewMain(
     IFileSystem shell,
     IFuse fuse,
     PreviewExported exportedPreview,
     ColoredTextWriter textWriter)
 {
     _fuse            = fuse;
     _exportedPreview = exportedPreview;
     _textWriter      = textWriter;
     _shell           = shell;
 }
Exemple #12
0
 public InstallCommand(
     ColoredTextWriter output,
     IFuse fuse)
     : base("install", "Install an external component")
 {
     _componentInstallers = new ComponentInstallers(fuse);
     _output  = output;
     _fuse    = fuse;
     _options = new OptionSet()
     {
         { "s|status", "Check install status of a package.", a => _mode = InstallMode.CheckStatus }
     };
 }
 public EventViewerCommand(ColoredTextWriter textWriter, IFuse fuse) : base("event-viewer", "Dump all events", true)
 {
     _textWriter    = textWriter;
     _fuse          = fuse;
     _optionSet     = CreateOptions();
     _report        = _fuse.Report;
     _helpArguments = new HelpArguments(
         new HelpHeader("fuse " + Name, Description),
         new HelpSynopsis("fuse " + Name + " [<Options>]"),
         new HelpDetailedDescription("Dumps all Fuse events to the console."),
         new HelpOptions(new[]
     {
         _optionSet.ToTable(),
     }));
 }
 public ViewportFactory(
     ProjectPreview preview,
     IProperty <bool> selectionEnabled,
     int port,
     IProject project,
     IFuse fuse,
     IObserver <OpenGlVersion> glVersion)
 {
     _preview          = preview;
     _selectionEnabled = selectionEnabled;
     _assembly         = preview.Assembly.Replay(1).RefCount();
     _port             = port;
     _project          = project;
     _fuse             = fuse;
     _glVersion        = glVersion;
 }
Exemple #15
0
 public Dashboard(CreateProject createProject, IFuse fuse)
 {
     Application.Desktop.CreateSingletonWindow(
         isVisible: _isVisible,
         window: window => new Window
     {
         Style      = WindowStyle.Fat,
         Title      = Observable.Return("Fuse"),
         Size       = Optional.Some(Property.Constant(Optional.Some(new Size <Points>(970, 608)))),
         Content    = Control.Lazy(() => CreateContent(createProject, window, fuse.Version)),
         Foreground = Theme.DefaultText,
         Background = Theme.PanelBackground,
         Border     = Separator.MediumStroke,
         HideTitle  = true,
     });
 }
        public ViewportController(
            VirtualDevice initialDevice,
            Action <ViewportController> onFocus,
            Action <ViewportController> onClose,
            Func <ViewportController, Menu> menu,
            ProjectPreview preview,
            IObservable <AssemblyBuilt> assembly,
            int port,
            IFuse fuse,
            Action <IUnoHostControl> initialize,
            IObserver <OpenGlVersion> glVersion)
        {
            VirtualDevice = new BehaviorSubject <VirtualDevice>(initialDevice);
            _onClose      = onClose;
            _onFocus      = onFocus;

            var simulatorControl = assembly
                                   .Select(assemblyPath =>
                                           Observable.Start(() =>
                                                            Observable.Using(() =>
                                                                             preview.LockBuild(assemblyPath.BuildDirectory),
                                                                             assemblyLock =>
                                                                             Observable.Using(() =>
                                                                                              SpawnUnoHost(assemblyPath, port, fuse, menu(this), initialize, glVersion),
                                                                                              unoHost =>
                                                                                              Observable
                                                                                              // never end stream, we don't want to dispose until we've gotten a new one
                                                                                              .Never <Optional <IUnoHostControl> >()
                                                                                              .StartWith(Optional.Some(unoHost)))))
                                           .Switch()
                                           .StartWith(Optional.None <IUnoHostControl>()))
                                   .Switch()
                                   .Replay(1);

            _subscription = simulatorControl.Connect();

            Control = simulatorControl
                      .StartWith(Optional.None <IUnoHostControl>())
                      .Select(c => c.Select(cc => cc.Control).Or(() => CreateLoadingIndicator()))
                      .Switch()
                      .WithBackground(Color.White);

            var realControl = simulatorControl.NotNone().Replay(1).RefCount();

            _send = message => realControl.Take(1).Subscribe(unoHost => unoHost.MessagesTo.OnNext(message));
        }
Exemple #17
0
 public CreateCommand(
     IFileSystem shell,
     Func <IEnumerable <Template> > projectTemplates,
     Func <IEnumerable <Template> > fileTemplates,
     ColoredTextWriter textWriter,
     IFuse fuse)
     : base("create", "Create a project or file from a template")
 {
     _fileTemplates    = fileTemplates;
     _textWriter       = textWriter;
     _fuse             = fuse;
     _projectTemplates = projectTemplates;
     _fileSystem       = shell;
     _optionSet        = new OptionSet()
     {
         { "l|list", "List all available templates.", s => { _shouldListPackages = true; } }
     };
 }
Exemple #18
0
        public OpenProject(
            PreviewService previewService,
            IShell shell,
            IFuse fuse,
            IMessagingService daemon,
            IObservable <Exception> errors)
        {
            _previewService = previewService;
            _shell          = shell;
            _fuse           = fuse;
            _daemon         = daemon;
            _errors         = errors;

            var doneLoading = _mainWindowFocused.FirstAsync();

            _setupGuide = new SetupGuide(fuse, doneLoading);

            RespondToFocusRequests.Start(_daemon, _projectsOpen);
        }
Exemple #19
0
        public static Menu Create(
            IFuse fuse,
            IShell shell,
            StageController stage,
            Help help,
            Menu elementMenu,
            Menu projectMenu,
            Build preview,
            Export export,
            SetupGuide setupGuide,
            Menu windowMenu,
            Debug debug)
        {
            var about = new About(fuse.Version, debug);

            var toolsMenu
                = setupGuide.Menu
                  + Menu.Separator;

            var menus
                = Menu.Submenu("File", CreateFileMenu(fuse))
                  + Menu.Submenu("Edit", Application.EditMenu)
                  + Menu.Submenu("Element", elementMenu)
                  + Menu.Submenu("Project", projectMenu)
                  + Menu.Submenu("Viewport", stage.Menu)
                  + Menu.Submenu("Preview", preview.Menu)
                  + Menu.Submenu("Export", export.Menu)
                  + Menu.Submenu("Tools", toolsMenu)
                  + Menu.Submenu("Window", windowMenu)
                  + Menu.Submenu("Help", CreateHelpMenu(fuse, help, about.Menu))
                  + debug.Menu;

            var fuseMenu = Menu.Submenu("Fuse", CreateFuseMenu(fuse, about.Menu));

            if (fuse.Platform == OS.Mac)
            {
                return(fuseMenu + menus);
            }

            return(menus);
        }
        IUnoHostControl SpawnUnoHost(AssemblyBuilt assemblyPath, int port, IFuse fuse, Menu menu, Action <IUnoHostControl> initialize, IObserver <OpenGlVersion> glVersion)
        {
            var unoHost = UnoHostControl.Create(
                assemblyPath.Assembly,
                Command.Enabled(Focus),
                menu,
                fuse.UserDataDir / new FileName("designer-config.json"),
                initialize,
                m =>
            {
                glVersion.OnNext(m);
                fuse.Report.Info(m.GlVersion, ReportTo.LogAndUser);
            },

                // args
                "--host",
                IPAddress.Loopback.ToString(),
                port.ToString(CultureInfo.InvariantCulture));

            return(unoHost);
        }
Exemple #21
0
        /// <summary>
        /// Initiates the Theatre plugin.
        /// </summary>
        public void Initiate(IFuse fuse)
        {
            this.fuse = fuse;

            if (!plugin_initiated)
                createTheatre ();

            fuse.AddWidget (main_widget, "Theatre");
            fuse.Quiting += on_quit;
        }
Exemple #22
0
 /// <summary>
 /// Disables the Theatre plugin.
 /// </summary>
 public void Deinitiate(IFuse fuse)
 {
     saveSettings ();
     fuse.RemoveWidget (main_widget);
     fuse.Quiting -= on_quit;
 }
Exemple #23
0
 private static Menu CreateHelpMenu(IFuse fuse, Help help, Menu aboutMenuItem)
 {
     return(fuse.Platform == OS.Windows ? help.Menu + Menu.Separator + aboutMenuItem : help.Menu);
 }
        /// <exception cref="SocketException" />
        /// <exception cref="UnableToResolveHostNameException" />
        /// <exception cref="BuildFailed" />
        /// <exception cref="RunFailed" />
        public void BuildAndRunExported(PreviewArguments args, IMessagingService client, IFileSystem shell, IFuse fuse)
        {
            var buildEvents = new Subject <IBinaryMessage>();

            var builder = UnoBuildWrapper.Create(
                shell, fuse.Version, buildEvents, false,
                new MissingRequiredPackageReferences(),
                new InstallAndroidRequired());

            var projectId = ProjectIdComputer.IdFor(args.Project);

            using (PushEventsToDaemon.Start(buildEvents, client, args.Project, projectId, GetBuildTarget(args.Target)))
                using (buildEvents.Subscribe(_output.WriteBuildEvent))
                {
                    if (args.Endpoints.Count == 0)
                    {
                        args = args.AddEndpoints(GetProxyEndPoints());
                    }

                    var build = builder
                                .LoadOrBuildRunnable(args, CancellationToken.None)
                                .GetResultAndUnpackExceptions();

                    if (args.CompileOnly == false)
                    {
                        build.Run(buildEvents.ToProgress());
                    }
                }
        }
Exemple #25
0
        /// <summary>
        /// Initiates the tray icon plugin.
        /// </summary>
        public void Initiate(IFuse fuse)
        {
            this.fuse = fuse;

            if (!plugin_initiated)
                createTrayIcon ();

            tray.ShowTray ();

            broadcaster = fuse.PluginCommunicator.RegisterPlugin ("Fuse.Plugin.TrayIcon", Version, broadcastHandler);
            fuse.Quiting += on_quit;
        }
Exemple #26
0
        /// <summary>
        /// Initiates the Library plugin.
        /// </summary>
        public void Initiate(IFuse fuse)
        {
            this.fuse = fuse;

            if (!plugin_initiated)
                createLibrary ();

            fuse.AddWidget (main_widget, "Library");
            fuse.Quiting += on_quit;
        }
Exemple #27
0
        /// <summary>
        /// Initiates the News plugin.
        /// </summary>
        public void Initiate(IFuse fuse)
        {
            this.fuse = fuse;

            if (!plugin_initiated)
                createNews ();

            fuse.AddWidget (main_widget, "News");
            fuse.Quiting += on_quit;

            timer.Elapsed += refresh_timer;
            int timeout = (refresh * 60) * 1000;
            timer.Start (timeout);
        }
Exemple #28
0
 /// <summary>
 /// Disables the News plugin.
 /// </summary>
 public void Deinitiate(IFuse fuse)
 {
     saveSettings ();
     fuse.RemoveWidget (main_widget);
     fuse.Quiting -= on_quit;
     timer.Elapsed -= refresh_timer;
     timer.Stop ();
 }
 public DaemonClientCommand(ColoredTextWriter textWriter, IFuse fuse) : base("daemon-client", "Create a connection to a daemon.")
 {
     _textWriter   = textWriter;
     _fuseLauncher = fuse;
     _optionSet    = CreateOptions();
 }
Exemple #30
0
 public SoftwareCollectionStatus(IFuse fuse)
 {
     SublimeApp    = new SublimeAppStatus(fuse.Report);
     SublimePlugin = new SublimePluginStatus(fuse);
 }
Exemple #31
0
 public OpenCommand(IFileSystem fileSystem, IFuse fuse)
     : base("open", "Open fuse project")
 {
     _fileSystem = fileSystem;
     _fuse       = fuse;
 }
Exemple #32
0
        /// <summary>
        /// Disables the tray icon plugin.
        /// </summary>
        public void Deinitiate(IFuse fuse)
        {
            saveSettings ();
            tray.HideTray ();

            fuse.PluginCommunicator.UnregisterPlugin (broadcaster);
            fuse.Quiting -= on_quit;
        }
Exemple #33
0
 static Menu CreateFuseMenu(IFuse fuse, Menu aboutMenuItem)
 {
     return(aboutMenuItem
            + Menu.Separator
            + CreateQuitItem(fuse));
 }
 public SublimePluginStatus(IFuse fuse)
     : base("Sublime Fuse Plugin", fuse.Report)
 {
     _sublimePlugin = new SublimePlugin(fuse.ModulesDir);
 }
Exemple #35
0
 public CreateProject(IFuse fuse)
 {
     _fuse  = fuse;
     _shell = new Shell();
 }