Skip to content

Commit

Permalink
refactor(ui): start using signals
Browse files Browse the repository at this point in the history
smaller DOM updates  & easier data update paths.
fix sl-select problems with force update on signal sub

Signed-off-by: Rachel Powers <[email protected]>
  • Loading branch information
Ryex committed Aug 17, 2024
1 parent 3da16d1 commit 70833e0
Show file tree
Hide file tree
Showing 11 changed files with 4,355 additions and 3,576 deletions.
223 changes: 223 additions & 0 deletions rust-testing.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
":dep stationeers_data = { path = \"./stationeers_data\" }\n",
":dep const-crc32 = \"1.3.0\"\n",
":dep color-eyre\n",
":dep serde_path_to_error\n",
":dep serde_ignored\n",
":dep serde\n",
":dep serde_json\n"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"use color_eyre::eyre;\n",
"pub fn parse_value<'a, T: serde::Deserialize<'a>>(\n",
" jd: impl serde::Deserializer<'a>,\n",
") -> Result<T, color_eyre::Report> {\n",
" let mut track = serde_path_to_error::Track::new();\n",
" let path = serde_path_to_error::Deserializer::new(jd, &mut track);\n",
" let mut fun = |path: serde_ignored::Path| {\n",
" eprintln!(\"Found ignored key: {path}\");\n",
" };\n",
" serde_ignored::deserialize(path, &mut fun).map_err(|e| {\n",
" eyre::eyre!(\n",
" \"path: {track} | error = {e}\",\n",
" track = track.path().to_string(),\n",
" )\n",
" })\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{7274344: StructureLogicDevice(StructureLogicDeviceTemplate { prefab: PrefabInfo { prefab_name: \"StructureAutoMinerSmall\", prefab_hash: 7274344, desc: \"The <link=Recurso><color=#0080FFFF>Recurso</color></link> SquareDig autominer is a structure that when built will mine a vertical 2x2 shaft until it hits bedrock. The autominer can be connected to a chute system, and is controllable by a logic network. Note that the autominer outputs more <link=OrePage><color=#0080FFFF>ore</color></link> than a conventional <link=ThingItemMiningDrill><color=green>Mining Drill</color></link> over the same area.\", name: \"Autominer (Small)\" }, structure: StructureInfo { small_grid: true }, thermal_info: None, internal_atmo_info: None, logic: LogicInfo { logic_slot_types: {0: {}, 1: {}}, logic_types: {Power: Read, Open: ReadWrite, Error: Read, Activate: ReadWrite, On: ReadWrite, RequiredPower: Read, ClearMemory: Write, ExportCount: Read, ImportCount: Read, PrefabHash: Read, ReferenceId: Read, NameHash: Read}, modes: None, transmission_receiver: false, wireless_logic: false, circuit_holder: false }, slots: [SlotInfo { name: \"Import\", typ: None }, SlotInfo { name: \"Export\", typ: None }], device: DeviceInfo { connection_list: [ConnectionInfo { typ: Chute, role: Input }, ConnectionInfo { typ: Chute, role: Output }, ConnectionInfo { typ: Data, role: None }, ConnectionInfo { typ: Power, role: None }], device_pins_length: None, has_activate_state: true, has_atmosphere: false, has_color_state: false, has_lock_state: false, has_mode_state: false, has_on_off_state: true, has_open_state: true, has_reagents: false } }), 111280987: ItemLogic(ItemLogicTemplate { prefab: PrefabInfo { prefab_name: \"ItemTerrainManipulator\", prefab_hash: 111280987, desc: \"0.Mode0\\n1.Mode1\", name: \"Terrain Manipulator\" }, item: ItemInfo { consumable: false, filter_type: None, ingredient: false, max_quantity: 1, reagents: None, slot_class: Tool, sorting_class: Default }, thermal_info: None, internal_atmo_info: None, logic: LogicInfo { logic_slot_types: {0: {Occupied: Read, OccupantHash: Read, Quantity: Read, Damage: Read, Charge: Read, ChargeRatio: Read, Class: Read, MaxQuantity: Read, ReferenceId: Read}, 1: {Occupied: Read, OccupantHash: Read, Quantity: Read, Damage: Read, Class: Read, MaxQuantity: Read, ReferenceId: Read}}, logic_types: {Power: Read, Mode: ReadWrite, Error: Read, Activate: ReadWrite, On: ReadWrite, ReferenceId: Read}, modes: Some({0: \"Mode0\", 1: \"Mode1\"}), transmission_receiver: false, wireless_logic: false, circuit_holder: false }, slots: [SlotInfo { name: \"Battery\", typ: Battery }, SlotInfo { name: \"Dirt Canister\", typ: Ore }] })}\n"
]
}
],
"source": [
"let entries = r#\"\n",
"{\n",
"\"7274344\": {\n",
" \"templateType\": \"StructureLogicDevice\",\n",
" \"prefab\": {\n",
" \"prefab_name\": \"StructureAutoMinerSmall\",\n",
" \"prefab_hash\": 7274344,\n",
" \"desc\": \"The <link=Recurso><color=#0080FFFF>Recurso</color></link> SquareDig autominer is a structure that when built will mine a vertical 2x2 shaft until it hits bedrock. The autominer can be connected to a chute system, and is controllable by a logic network. Note that the autominer outputs more <link=OrePage><color=#0080FFFF>ore</color></link> than a conventional <link=ThingItemMiningDrill><color=green>Mining Drill</color></link> over the same area.\",\n",
" \"name\": \"Autominer (Small)\"\n",
" },\n",
" \"structure\": {\n",
" \"small_grid\": true\n",
" },\n",
" \"logic\": {\n",
" \"logic_slot_types\": {\n",
" \"0\": {},\n",
" \"1\": {}\n",
" },\n",
" \"logic_types\": {\n",
" \"Power\": \"Read\",\n",
" \"Open\": \"ReadWrite\",\n",
" \"Error\": \"Read\",\n",
" \"Activate\": \"ReadWrite\",\n",
" \"On\": \"ReadWrite\",\n",
" \"RequiredPower\": \"Read\",\n",
" \"ClearMemory\": \"Write\",\n",
" \"ExportCount\": \"Read\",\n",
" \"ImportCount\": \"Read\",\n",
" \"PrefabHash\": \"Read\",\n",
" \"ReferenceId\": \"Read\",\n",
" \"NameHash\": \"Read\"\n",
" },\n",
" \"transmission_receiver\": false,\n",
" \"wireless_logic\": false,\n",
" \"circuit_holder\": false\n",
" },\n",
" \"slots\": [\n",
" {\n",
" \"name\": \"Import\",\n",
" \"typ\": \"None\"\n",
" },\n",
" {\n",
" \"name\": \"Export\",\n",
" \"typ\": \"None\"\n",
" }\n",
" ],\n",
" \"device\": {\n",
" \"connection_list\": [\n",
" {\n",
" \"typ\": \"Chute\",\n",
" \"role\": \"Input\"\n",
" },\n",
" {\n",
" \"typ\": \"Chute\",\n",
" \"role\": \"Output\"\n",
" },\n",
" {\n",
" \"typ\": \"Data\",\n",
" \"role\": \"None\"\n",
" },\n",
" {\n",
" \"typ\": \"Power\",\n",
" \"role\": \"None\"\n",
" }\n",
" ],\n",
" \"has_activate_state\": true,\n",
" \"has_atmosphere\": false,\n",
" \"has_color_state\": false,\n",
" \"has_lock_state\": false,\n",
" \"has_mode_state\": false,\n",
" \"has_on_off_state\": true,\n",
" \"has_open_state\": true,\n",
" \"has_reagents\": false\n",
" }\n",
" },\n",
" \"111280987\": {\n",
" \"templateType\": \"ItemLogic\",\n",
" \"prefab\": {\n",
" \"prefab_name\": \"ItemTerrainManipulator\",\n",
" \"prefab_hash\": 111280987,\n",
" \"desc\": \"0.Mode0\\n1.Mode1\",\n",
" \"name\": \"Terrain Manipulator\"\n",
" },\n",
" \"item\": {\n",
" \"consumable\": false,\n",
" \"ingredient\": false,\n",
" \"max_quantity\": 1,\n",
" \"slot_class\": \"Tool\",\n",
" \"sorting_class\": \"Default\"\n",
" },\n",
" \"logic\": {\n",
" \"logic_slot_types\": {\n",
" \"0\": {\n",
" \"Occupied\": \"Read\",\n",
" \"OccupantHash\": \"Read\",\n",
" \"Quantity\": \"Read\",\n",
" \"Damage\": \"Read\",\n",
" \"Charge\": \"Read\",\n",
" \"ChargeRatio\": \"Read\",\n",
" \"Class\": \"Read\",\n",
" \"MaxQuantity\": \"Read\",\n",
" \"ReferenceId\": \"Read\"\n",
" },\n",
" \"1\": {\n",
" \"Occupied\": \"Read\",\n",
" \"OccupantHash\": \"Read\",\n",
" \"Quantity\": \"Read\",\n",
" \"Damage\": \"Read\",\n",
" \"Class\": \"Read\",\n",
" \"MaxQuantity\": \"Read\",\n",
" \"ReferenceId\": \"Read\"\n",
" }\n",
" },\n",
" \"logic_types\": {\n",
" \"Power\": \"Read\",\n",
" \"Mode\": \"ReadWrite\",\n",
" \"Error\": \"Read\",\n",
" \"Activate\": \"ReadWrite\",\n",
" \"On\": \"ReadWrite\",\n",
" \"ReferenceId\": \"Read\"\n",
" },\n",
" \"modes\": {\n",
" \"0\": \"Mode0\",\n",
" \"1\": \"Mode1\"\n",
" },\n",
" \"transmission_receiver\": false,\n",
" \"wireless_logic\": false,\n",
" \"circuit_holder\": false\n",
" },\n",
" \"slots\": [\n",
" {\n",
" \"name\": \"Battery\",\n",
" \"typ\": \"Battery\"\n",
" },\n",
" {\n",
" \"name\": \"Dirt Canister\",\n",
" \"typ\": \"Ore\"\n",
" }\n",
" ]\n",
" }\n",
"}\n",
"\"#;\n",
"use std::collections::BTreeMap;\n",
"use stationeers_data::templates::ObjectTemplate;\n",
"let parsed_db: BTreeMap<i32, ObjectTemplate> =\n",
" parse_value(&mut serde_json::Deserializer::from_str(entries))?;\n",
"println!(\"{parsed_db:?}\");"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Rust",
"language": "rust",
"name": "rust"
},
"language_info": {
"codemirror_mode": "rust",
"file_extension": ".rs",
"mimetype": "text/rust",
"name": "rust",
"pygment_lexer": "rust",
"version": ""
}
},
"nbformat": 4,
"nbformat_minor": 2
}
8 changes: 6 additions & 2 deletions www/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"brnez",
"Circuitboard",
"codegen",
"Comlink",
"datapoints",
"Depressurising",
"deviceslength",
"endpos",
Expand All @@ -62,13 +64,16 @@
"hardwrap",
"hashables",
"hstack",
"idxs",
"infile",
"jetpack",
"Keybind",
"labelledby",
"lbns",
"logicable",
"LogicSlotType",
"logicslottypes",
"LogicSlotTypes",
"logictype",
"logictypes",
"lparen",
Expand All @@ -82,6 +87,7 @@
"pedia",
"pinf",
"popperjs",
"preact",
"preproc",
"Pressurising",
"putd",
Expand All @@ -103,8 +109,6 @@
"slotclass",
"slotlogic",
"slotlogicable",
"LogicSlotType",
"LogicSlotTypes",
"slottype",
"sltz",
"snan",
Expand Down
39 changes: 20 additions & 19 deletions www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,48 @@
"homepage": "https://github.com/ryex/ic10emu#readme",
"devDependencies": {
"@oneidentity/zstd-js": "^1.0.3",
"@rsbuild/core": "^0.6.4",
"@rsbuild/plugin-image-compress": "^0.6.4",
"@rsbuild/plugin-type-check": "^0.6.4",
"@rspack/cli": "^0.6.2",
"@rspack/core": "^0.6.2",
"@swc/helpers": "^0.5.10",
"@rsbuild/core": "^0.7.10",
"@rsbuild/plugin-image-compress": "^0.7.10",
"@rsbuild/plugin-type-check": "^0.7.10",
"@rspack/cli": "^0.7.5",
"@rspack/core": "^0.7.5",
"@swc/helpers": "^0.5.12",
"@types/ace": "^0.0.52",
"@types/bootstrap": "^5.2.10",
"@types/wicg-file-system-access": "^2023.10.5",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"lit-scss-loader": "^2.0.1",
"mini-css-extract-plugin": "^2.9.0",
"postcss-loader": "^8.1.1",
"sass": "^1.75.0",
"tailwindcss": "^3.4.3",
"sass": "^1.77.8",
"tailwindcss": "^3.4.10",
"ts-lit-plugin": "^2.0.2",
"ts-loader": "^9.5.1",
"typescript": "^5.4.5",
"typescript": "^5.5.4",
"typescript-lit-html-plugin": "^0.9.0"
},
"dependencies": {
"@leeoniya/ufuzzy": "^1.0.14",
"@lit/context": "^1.1.1",
"@lit-labs/preact-signals": "^1.0.2",
"@lit/context": "^1.1.2",
"@popperjs/core": "^2.11.8",
"@shoelace-style/shoelace": "^2.15.0",
"ace-builds": "^1.33.0",
"ace-linters": "^1.2.0",
"@shoelace-style/shoelace": "^2.16.0",
"ace-builds": "^1.35.4",
"ace-linters": "^1.2.3",
"bootstrap": "^5.3.3",
"bson": "^6.6.0",
"bson": "^6.8.0",
"buffer": "^6.0.3",
"comlink": "^4.4.1",
"crypto-browserify": "^3.12.0",
"ic10emu_wasm": "file:../ic10emu_wasm/pkg",
"ic10lsp_wasm": "file:../ic10lsp_wasm/pkg",
"ic10emu_wasm": "file:..\\ic10emu_wasm\\pkg",
"ic10lsp_wasm": "file:..\\ic10lsp_wasm\\pkg",
"idb": "^8.0.0",
"jquery": "^3.7.1",
"lit": "^3.1.3",
"lit": "^3.2.0",
"lzma-web": "^3.0.1",
"marked": "^12.0.2",
"marked": "^14.0.0",
"stream-browserify": "^3.0.0",
"uuid": "^9.0.1",
"uuid": "^10.0.0",
"vm-browserify": "^1.1.2"
}
}
Loading

0 comments on commit 70833e0

Please sign in to comment.