Skip to content

Commit

Permalink
Merge pull request #982 from UC-Davis-molecular-computing/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dave-doty authored Sep 6, 2024
2 parents ebf29a6 + b876256 commit 82b085b
Show file tree
Hide file tree
Showing 36 changed files with 573 additions and 641 deletions.
39 changes: 25 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,33 +248,35 @@ This project requires using Dart version **2.13**, not the latest version. Click
<details><summary><strong>Windows</strong></summary>
First, install <a href="https://chocolatey.org/install">Chocolatey</a> if you haven't already. If <code>choco help</code> shows a help menu for using Chocolatey, then you've set it up correctly.

Then, install Dart 2.13:
Then, install Dart 2.13.4:

<pre>
choco install dart-sdk --version 2.13
choco install dart-sdk --version 2.13.4
</pre>

To stop Chocolatey from automatically updating Dart to the latest version, pin it:

<pre>
choco pin --name="'dart-sdk'" --version="'2.13'"
choco pin --name="'dart-sdk'" --version="'2.13.4'"
</pre>

</details>

<details><summary><strong>macOS</strong></summary>
First, install <a href="https://brew.sh/">Homebrew</a> if you haven't already. If <code>brew -v</code> shows some version numbers, then you've set it up correctly.

Then, install Dart 2.13:
It may help to run `brew tap dart-lang/dart` first.

Then, install Dart 2.13.4:

<pre>
brew install [email protected]
brew install [email protected].4
</pre>

To stop Homebrew from automatically updating Dart to the latest version, pin it:

<pre>
brew pin [email protected]
brew pin [email protected].4
</pre>

If running `dart` in a terminal now does not work, you may need to follow <a href="https://docs.brew.sh/FAQ#my-mac-apps-dont-find-homebrew-utilities">these instructions</a>.
Expand All @@ -290,17 +292,17 @@ wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo gpg --dea
echo 'deb [signed-by=/usr/share/keyrings/dart.gpg arch=amd64] https://storage.googleapis.com/download.dartlang.org/linux/debian stable main' | sudo tee /etc/apt/sources.list.d/dart_stable.list
</pre>

Then, install Dart 2.13:
Then, install Dart 2.13.4:

<pre>
sudo apt-get update
sudo apt-get install dart=2.13
sudo apt-get install dart=2.13.4
</pre>

To stop apt from automatically updating Dart to the latest version, hold it:

<pre>
sudo apt-mark hold dart=2.13
sudo apt-mark hold dart=2.13.4
</pre>

</details>
Expand All @@ -312,35 +314,44 @@ After installing the Dart SDK, you should see a help menu when you run `dart`.
Once you have installed Dart, install all the Dart dependencies (from the same directory `scadnano` into which the project was cloned by git):

```
pub get
```

### Installing `webdev`

This project uses an older version of the `webdev` tool, not the latest version, to build and serve the web app. Install it with:

```
pub global activate webdev 2.5.9
```

Note that often a message like this appears:

```
Warning: Pub installs executables into C:\Users\pexat\AppData\Local\Pub\Cache\bin, which is not on your path.
You can fix that by adding that directory to your system's "Path" environment variable.
A web search for "configure windows path" will show you how.
```
So you may need to add the installation location of `webdev` to your PATH environment variable.


### Running a Local Server

Run

```
webdev serve
```

in the `scadnano` directory to compile your code
with the [Dart dev compiler](https://dart.dev/tools/dartdevc)
(dartdevc) and start up a [local
server](https://dart.dev/tools/webdev#serve).

Sometimes it may be necessary to clean out the generated files and cache if this has an error. See the file `clean.sh`, which has this line: `dart run build_runner clean`. Also see `remove_g.sh`, which removes all `.g.dart` files from the project, which can also help to fix compilation errors.

If that does not work, try `dart run build_runner clean --delete-conflicting-outputs`.

Running `webdev serve --release` will compile the project in production mode (instead of development mode), which is claimed to be faster in principle if you are not doing development and just want to run scadnano offline.
However, in scadnano, it doesn't appear to make a big difference whether development or production mode is used.
The webdev program will tell you which URL to enter in your browser; it will be something like
Expand Down
12 changes: 1 addition & 11 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
#TODO: don't know how to prevent this check from printing error message to the screen in case pub isn't found
if type pub > /dev/null; then
PUB=pub
echo "Using pub as dart pub command"
else
# on Windows the pub command is called pub.bat
PUB=pub.bat
echo "Using pub.bat as dart pub command"
fi

$PUB run build_runner clean
dart run build_runner clean
bash remove_g.sh
#rm -rf .dart_tool/build/

Expand Down
Binary file removed lib/src/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions lib/src/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.g.dart
#*.g 2.dart
/test_built_value.dart
.DS_Store
12 changes: 6 additions & 6 deletions lib/src/actions/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -754,19 +754,19 @@ abstract class ShowUnpairedInsertionDeletionsSet
_$showUnpairedInsertionDeletionsSetSerializer;
}

abstract class SetShowEditor
abstract class OxviewShowSet
with BuiltJsonSerializable
implements Action, Built<SetShowEditor, SetShowEditorBuilder> {
implements Action, Built<OxviewShowSet, OxviewShowSetBuilder> {
bool get show;

factory SetShowEditor(bool show) => SetShowEditor.from((b) => b..show = show);
factory OxviewShowSet(bool show) => OxviewShowSet.from((b) => b..show = show);

/************************ begin BuiltValue boilerplate ************************/
factory SetShowEditor.from([void Function(SetShowEditorBuilder) updates]) = _$SetShowEditor;
factory OxviewShowSet.from([void Function(OxviewShowSetBuilder) updates]) = _$OxviewShowSet;

SetShowEditor._();
OxviewShowSet._();

static Serializer<SetShowEditor> get serializer => _$setShowEditorSerializer;
static Serializer<OxviewShowSet> get serializer => _$oxviewShowSetSerializer;
}

abstract class SetDisplayBaseOffsetsOfMajorTicksOnlyFirstHelix
Expand Down
20 changes: 19 additions & 1 deletion lib/src/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import 'package:redux_dev_tools/redux_dev_tools.dart';
import 'package:over_react/over_react.dart' as react;
import 'package:scadnano/src/reducers/dna_extensions_move_reducer.dart';
import 'package:scadnano/src/state/dna_extensions_move.dart';
import 'package:scadnano/src/util.dart';

import 'middleware/all_middleware.dart';
import 'middleware/oxview_update_view.dart';
import 'middleware/throttle.dart';
import 'state/dna_ends_move.dart';
import 'state/helix_group_move.dart';
Expand Down Expand Up @@ -84,14 +86,30 @@ class App {
setup_undo_redo_keyboard_listeners();
setup_save_open_dna_file_keyboard_listeners();
copy_selected_strands_to_clipboard_image_keyboard_listeners();
// util.save_editor_content_to_js_context(state.editor_content);
restore_all_local_storage(app.store);
setup_warning_before_unload();
setup_save_design_to_localStorage_before_unload();
make_dart_functions_available_to_js(state);
DivElement app_root_element = querySelector('#top-container');
this.view = View(app_root_element);
this.view.render(state);
this.view.oxview_view.frame.onLoad.listen((event) {
const js_set_camera_commands = 'camera.up.multiplyScalar(-1)';
String text_blob_type = blob_type_to_string(BlobType.text);
Blob blob_js_camera_commands = new Blob([js_set_camera_commands], text_blob_type);
Map<String, dynamic> message_js_commands = {
'message': 'iframe_drop',
'files': [blob_js_camera_commands],
'ext': ['js'],
};
this
.view
.oxview_view
.frame
.contentWindow
?.postMessage(message_js_commands, 'https://sulcgroup.github.io/oxdna-viewer/');
update_oxview_view(app.state.design, this.view.oxview_view.frame);
});
// do next after view renders so that JS SVG pan zoom containers are defined
util.set_zoom_speed(store.state.ui_state.zoom_speed);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ import 'state/grid.dart';

// WARNING: Do not modify line below, except for the version string
// (and also add new version string to scadnano_versions_to_link).
const String CURRENT_VERSION = "0.19.3";
const String CURRENT_VERSION = "0.19.4";
const String INITIAL_VERSION = "0.1.0";

// scadnano versions that we deploy so that older versions can be used.
final scadnano_older_versions_to_link = [
"0.19.2",
"0.19.1",
"0.19.3",
"0.18.10",
"0.17.14",
// "0.17.13",
Expand Down Expand Up @@ -185,6 +184,7 @@ const default_display_angle = 35.0;
const default_display_length = 1.5;

const default_side_pane_width = '8%';
const default_design_width = "66%";

const default_group_name = 'default_group';

Expand Down
2 changes: 2 additions & 0 deletions lib/src/middleware/all_middleware.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'helix_offsets_change.dart';
import 'insertion_deletion_batching.dart';
import 'load_file.dart';
import 'oxdna_export.dart';
import 'oxview_update_view.dart';
import 'periodic_save_design_local_storage.dart';
import 'reselect_moved_dna_ends.dart';
import 'reselect_moved_copied_strands.dart';
Expand Down Expand Up @@ -80,4 +81,5 @@ final all_middleware = List<Middleware<AppState>>.unmodifiable([
system_clipboard_middleware,
zoom_speed_middleware,
oxdna_export_middleware,
oxview_update_view_middleware,
]);
4 changes: 3 additions & 1 deletion lib/src/middleware/local_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ save(AppState state, Storable storable) {
if (value_string != null) window.localStorage[storable_key] = value_string;
}

String side_pane_width() => window.localStorage[_LOCAL_STORAGE_PREFIX + 'side_pane_width'];
String side_pane_width() => window.localStorage[_LOCAL_STORAGE_PREFIX + 'side-pane-width'];
String design_width() =>
window.localStorage[_LOCAL_STORAGE_PREFIX + 'design-and-modes-buttons-container-width'];

restore(Store<AppState> store, Storable storable) {
try {
Expand Down
Loading

0 comments on commit 82b085b

Please sign in to comment.