Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Feb 13, 2023
1 parent 54ea2e1 commit ca95d2f
Show file tree
Hide file tree
Showing 69 changed files with 370 additions and 964 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ packages/project-editor/flow/runtime/cpp/lvgl-runtime/build
!packages/project-editor/flow/runtime/lvgl_runtime.js
!packages/project-editor/flow/runtime/cpp/lvgl-runtime/pre.js
!packages/project-editor/flow/runtime/cpp/lvgl-runtime/post.js

npm-module/packages
npm-module/libs
npm-module/resources
30 changes: 30 additions & 0 deletions npm-module-publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const fse = require("fs-extra");
const { spawn } = require("child_process");

const FOLDERS = ["packages", "libs", "resources"];
for (const folder of FOLDERS) {
console.log(`Copy ${folder} to npm-module/${folder} ...`);
fse.copySync(folder, `npm-module/${folder}`, { overwrite: true });
}

console.log(`Remove npm-module/packages/project-editor/flow/runtime/cpp ...`);
fse.removeSync(`npm-module/packages/project-editor/flow/runtime/cpp`);

console.log("Spawn npm publish ...");
const dir = spawn(
process.platform == "win32" ? "npm.cmd" : "npm",
["publish"],
{ cwd: __dirname + "/npm-module" }
);

dir.stdout.on("data", data => console.log(data.toString()));
dir.stderr.on("data", data => console.log(data.toString()));

dir.on("error", err => console.log(err.toString()));

dir.on("close", code => {
for (const folder of FOLDERS) {
console.log(`Remove npm-module/${folder} ...`);
fse.removeSync(`npm-module/${folder}`);
}
});
10 changes: 10 additions & 0 deletions npm-module/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "eez-studio",
"author": "Envox <[email protected]>",
"description": "EEZ Studio for building standalone dashboard applications",
"repository": "https://github.com/eez-open/studio",
"version": "0.0.7",
"revision": "1",
"license": "GPL-3.0-only",
"files": ["packages", "libs", "resources"]
}
4 changes: 2 additions & 2 deletions packages/eez-studio-shared/extensions/extension.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { UNITS } from "eez-studio-shared/units";
import type { IStore } from "eez-studio-shared/store";
import type { IActivityLogEntry } from "eez-studio-shared/activity-log-interfaces";

import type { IActivityLogEntry } from "instrument/window/history/activity-log-interfaces";

import type { IShortcut } from "shortcuts/interfaces";

import type { IFieldProperties } from "eez-studio-ui/generic-dialog";

export type { IFieldProperties } from "eez-studio-ui/generic-dialog";

import type { IEezFlowEditor } from "eez-studio-types";
Expand Down
1 change: 1 addition & 0 deletions packages/eez-studio-shared/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type * as ElectronModule from "electron";
import type * as ElectronRemoteModule from "@electron/remote";
import { ipcMain, ipcRenderer } from "electron";

import { isRenderer } from "eez-studio-shared/util-electron";
import { guid } from "eez-studio-shared/guid";

Expand Down
3 changes: 2 additions & 1 deletion packages/eez-studio-shared/service.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type * as ElectronModule from "electron";
import type * as ElectronRemoteModule from "@electron/remote";
import { toJS } from "mobx";

import { isRenderer } from "eez-studio-shared/util-electron";
import { guid } from "eez-studio-shared/guid";
import { toJS } from "mobx";
import { sourceRootDir } from "eez-studio-shared/util";

// Execute given function in service process.
Expand Down
27 changes: 8 additions & 19 deletions packages/eez-studio-shared/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { observable, runInAction } from "mobx";

import { UNITS } from "eez-studio-shared/units";

import { filterInteger } from "eez-studio-shared/validation-filters";

export {
filterInteger,
filterFloat,
filterNumber
} from "eez-studio-shared/validation-filters";

const VALIDATION_MESSAGE_INVALID_VALUE = "Invalid value.";
export const VALIDATION_MESSAGE_REQUIRED = "Please fill out this field.";
export const VALIDATION_MESSAGE_RANGE_INCLUSIVE =
Expand All @@ -13,17 +21,6 @@ const VALIDATION_MESSAGE_RANGE_EXCLUSIVE =
const VALIDATION_MESSAGE_RANGE_EXCLUSIVE_WITHOUT_MAX =
"Please enter value greater than ${min}.";
const VALIDATION_MESSAGE_NOT_UNIQUE = "This field has no unique value.";
const VALIDATION_MESSAGE_INVALID_IDENTIFIER =
"Not a valid identifier. Identifier starts with a letter or an underscore (_), followed by zero or more letters, digits, or underscores. Spaces are not allowed.";

import { filterInteger } from "eez-studio-shared/validation-filters";
import { parseIdentifier } from "project-editor/flow/expression/helper";

export {
filterInteger,
filterFloat,
filterNumber
} from "eez-studio-shared/validation-filters";

export type Rule = (
object: any,
Expand Down Expand Up @@ -134,14 +131,6 @@ export const validators = {
}
return null;
};
},

identifier: (object: any, ruleName: string) => {
const value = object[ruleName];
if (!parseIdentifier(value) || value.startsWith("$")) {
return VALIDATION_MESSAGE_INVALID_IDENTIFIER;
}
return null;
}
};

Expand Down
27 changes: 0 additions & 27 deletions packages/eez-studio-ui/_stylesheets/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -3506,33 +3506,6 @@ button.EezStudio_Action {
}
}

.EezStudio_CommandPaletteWrapper {
z-index: 1000;
position: absolute;
top: 0;
left: calc(50% - 300px);
width: 600px;
height: 500px;
padding: 10px;
display: flex;
flex-direction: column;

background-color: rgb(243, 243, 243);
color: rgb(97, 97, 97);
box-shadow: rgba(0, 0, 0, 0.16) 0px 0px 8px 2px;

input {
width: 100%;
}

& > div {
flex-grow: 1;
background-color: white;
margin-top: 10px;
border: 1px solid @borderColor;
}
}

.EezStudio_ProjectEditors {
flex-grow: 1;
display: flex;
Expand Down
87 changes: 52 additions & 35 deletions packages/home/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { getAppStore } from "home/history";
import "home/home-tab";

import { SessionInfo } from "instrument/window/history/session/info-view";
import { InstrumentObject, instruments } from "instrument/instrument-object";
import type { InstrumentObject } from "instrument/instrument-object";
import { instruments } from "instrument/instrument-object";

////////////////////////////////////////////////////////////////////////////////

Expand All @@ -26,8 +27,7 @@ const AppComponent = observer(
super(props);

makeObservable(this, {
addTabAttention: computed,
webSimulators: computed
addTabAttention: computed
});
}

Expand All @@ -41,20 +41,6 @@ const AppComponent = observer(
);
}

get webSimulators() {
const webSimulators: InstrumentObject[] = [];
instruments.forEach(instrument => {
if (
!instrument.connection.isIdle &&
instrument.extension &&
instrument.lastConnection?.type == "web-simulator"
) {
webSimulators.push(instrument);
}
});
return webSimulators;
}

render() {
const appStore = getAppStore();

Expand All @@ -76,34 +62,23 @@ const AppComponent = observer(
}
)}
/>
{appStore.history.sessions.activeSession && (
<div className="EezStudio_SessionInfoContainer">
<SessionInfo appStore={appStore} />
</div>
)}
{tabs.instrumentsVisible &&
appStore.history.sessions.activeSession && (
<div className="EezStudio_SessionInfoContainer">
<SessionInfo appStore={appStore} />
</div>
)}
</Header>
<Body>
<Tabs />
</Body>
</VerticalHeaderWithBody>
);

const webSimulatorConnections = this.webSimulators;
if (webSimulatorConnections.length == 0) {
return content;
}

const simulators = webSimulatorConnections.map(instrument => (
<WebSimulatorPanel
key={instrument.id}
instrument={instrument}
/>
));

return (
<>
{content}
{simulators}
<WebSimulators />
</>
);
}
Expand Down Expand Up @@ -148,6 +123,48 @@ const Tabs = observer(

////////////////////////////////////////////////////////////////////////////////

const WebSimulators = observer(
class WebSimulators extends React.Component {
constructor(props: any) {
super(props);

makeObservable(this, {
webSimulators: computed
});
}

get webSimulators() {
const webSimulators: InstrumentObject[] = [];
instruments.forEach(instrument => {
if (
!instrument.connection.isIdle &&
instrument.extension &&
instrument.lastConnection?.type == "web-simulator"
) {
webSimulators.push(instrument);
}
});
return webSimulators;
}

render() {
const webSimulatorConnections = this.webSimulators;
if (webSimulatorConnections.length == 0) {
return null;
}

return webSimulatorConnections.map(instrument => (
<WebSimulatorPanel
key={instrument.id}
instrument={instrument}
/>
));
}
}
);

////////////////////////////////////////////////////////////////////////////////

class WebSimulatorPanel extends React.Component<{
instrument: InstrumentObject;
}> {
Expand Down
6 changes: 0 additions & 6 deletions packages/home/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,6 @@ ipcRenderer.on("new-project", async (sender: any, filePath: any) => {
showNewProjectWizard();
});

ipcRenderer.on("command-palette", () => {
if (tabs.activeTab && tabs.activeTab.showCommandPalette) {
tabs.activeTab.showCommandPalette();
}
});

const Main = observer(
class Main extends React.Component<{ children: React.ReactNode }> {
render() {
Expand Down
6 changes: 2 additions & 4 deletions packages/home/settings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ipcRenderer } from "electron";
import { ipcRenderer, shell } from "electron";
import { dialog, getCurrentWindow } from "@electron/remote";
import React from "react";
import {
Expand All @@ -13,7 +13,6 @@ import { observer } from "mobx-react";
import moment from "moment";
import classNames from "classnames";

const shell = require("electron").shell;
import { app, createEmptyFile } from "eez-studio-shared/util-electron";
import { stringCompare } from "eez-studio-shared/string";
import { getDbPath, setDbPath } from "eez-studio-shared/db-path";
Expand All @@ -32,17 +31,16 @@ import { formatBytes } from "eez-studio-shared/formatBytes";

import { showDialog, Dialog } from "eez-studio-ui/dialog";
import { Loader } from "eez-studio-ui/loader";

import {
BooleanProperty,
PropertyList,
SelectProperty
} from "eez-studio-ui/properties";
import { FileInputProperty } from "eez-studio-ui/properties-electron";
import * as notification from "eez-studio-ui/notification";
import { Header } from "eez-studio-ui/header-with-body";

import dbVacuum from "db-services/vacuum";
import { Header } from "eez-studio-ui/header-with-body";

////////////////////////////////////////////////////////////////////////////////

Expand Down
10 changes: 1 addition & 9 deletions packages/home/tabs-store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export interface IHomeTab extends ITab {
render(): React.ReactNode;
attention?: boolean;
beforeAppClose?(): Promise<boolean>;
showCommandPalette?(): void;
titleStr: string;
}

Expand Down Expand Up @@ -334,7 +333,7 @@ class HomeSectionTab implements IHomeTab {

////////////////////////////////////////////////////////////////////////////////

class InstrumentTab implements IHomeTab {
export class InstrumentTab implements IHomeTab {
constructor(public tabs: Tabs, public object: InstrumentObject) {
makeObservable(this, {
_active: observable,
Expand Down Expand Up @@ -440,7 +439,6 @@ export class ProjectEditorTab implements IHomeTab {
projectEditorStore: observable,
error: observable,
makeActive: action,
showCommandPalette: action,
_icon: observable
});
}
Expand Down Expand Up @@ -726,12 +724,6 @@ export class ProjectEditorTab implements IHomeTab {
return true;
}

showCommandPalette() {
if (this.projectEditorStore) {
this.projectEditorStore.uiStateStore.showCommandPalette = true;
}
}

loadDebugInfo(filePath: string) {
if (this.projectEditorStore) {
this.projectEditorStore.loadDebugInfo(filePath);
Expand Down
2 changes: 1 addition & 1 deletion packages/instrument/connection/connection-base.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { computed, makeObservable } from "mobx";

import type { IActivityLogEntry } from "eez-studio-shared/activity-log";
import type { IActivityLogEntry } from "instrument/window/history/activity-log";

import type { IInstrumentObjectProps } from "instrument/instrument-object";
import type { ConnectionParameters } from "instrument/connection/interface";
Expand Down
2 changes: 1 addition & 1 deletion packages/instrument/connection/connection-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
makeObservable
} from "mobx";

import { activityLogStore, log } from "eez-studio-shared/activity-log";
import { activityLogStore, log } from "instrument/window/history/activity-log";
import {
registerSource,
unregisterSource,
Expand Down
Loading

0 comments on commit ca95d2f

Please sign in to comment.