Skip to content

Commit

Permalink
make client build
Browse files Browse the repository at this point in the history
  • Loading branch information
Pistonight committed Jan 18, 2024
1 parent 75f1be9 commit 0ef4bfe
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 21 deletions.
15 changes: 11 additions & 4 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
version: '3'

includes:
compiler-base:
taskfile: ./compiler-base
aliases: [base]
dir: ./compiler-base

compiler-core:
taskfile: ./compiler-core
aliases: [core]
Expand Down Expand Up @@ -57,10 +62,12 @@ tasks:
- task: themes:check

check:rs:
deps: [core:grammar]
deps: [base:grammar]
cmds:
- cargo clippy --package compiler-macros --all-targets -- -D warnings -D clippy::todo
- cargo clippy --package compiler-core --features native,test --all-targets -- -D warnings -D clippy::todo
- cargo clippy --package compiler-base --features native --all-targets -- -D warnings -D clippy::todo
- cargo clippy --package compiler-base --features wasm --all-targets -- -D warnings -D clippy::todo
- cargo clippy --package compiler-core --features native --all-targets -- -D warnings -D clippy::todo
- cargo clippy --package compiler-core --features wasm --all-targets -- -D warnings -D clippy::todo
- cargo clippy --package compiler-wasm --all-targets -- -D warnings -D clippy::todo
- cargo clippy --package web-server --all-targets -- -D warnings -D clippy::todo
Expand All @@ -79,7 +86,7 @@ tasks:

build:server:
deps:
- core:grammar
- base:grammar
dir: ./web-server
cmds:
- rustup default stable
Expand All @@ -95,7 +102,7 @@ tasks:
build:wasm:
dir: ./compiler-wasm/build
deps:
- core:grammar
- base:grammar
cmds:
- cargo run --bin buildwasm --release

Expand Down
1 change: 1 addition & 0 deletions compiler-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
[dependencies.celerb]
package = "compiler-base"
path = "../compiler-base"
default-features = false

[dependencies]
derivative = "2.2.0"
Expand Down
3 changes: 1 addition & 2 deletions compiler-core/src/comp/comp_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ use serde_json::Value;

use crate::json::RouteBlobRef;
use crate::lang::{DocDiagnostic, DocRichText, DocRichTextBlock};
use crate::macros::derive_wasm;
use crate::pack::{Compiler, PackError};
use crate::util::StringMap;

use super::{CompError, CompMarker, CompMovement, DocNote};

#[derive(PartialEq, Default, Serialize, Deserialize, Debug, Clone)]
#[derive_wasm]
pub struct CompLine {
/// Primary text content of the line
pub text: DocRichText,
Expand Down
14 changes: 10 additions & 4 deletions compiler-wasm/build/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ fn main_internal() -> io::Result<()> {

println!("copying files");
fs::create_dir_all(OUTPUT_PUBLIC_DIR)?;
fs::copy(
Path::new(TEMP_OUTPUT_DIR).join(BINDING_TS),
Path::new(OUTPUT_LOW_DIR).join(BINDING_TS),
)?;
// there is some problem with wasm-bindgen (or tsify), where it doesn't generate
// the correct bindings in debug mode
if cfg!(debug_assertions) {
println!("not copying generated bindings in debug mode. Please run in release mode if bindings are updated!");
} else {
fs::copy(
Path::new(TEMP_OUTPUT_DIR).join(BINDING_TS),
Path::new(OUTPUT_LOW_DIR).join(BINDING_TS),
)?;
}

fs::copy(
Path::new(TEMP_OUTPUT_DIR).join(WORKER_JS),
Expand Down
4 changes: 2 additions & 2 deletions web-client/src/ui/doc/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Utilities

import { DocColor, DocTag } from "low/celerc";
import { DocTagColor, DocTag } from "low/celerc";
import { DOMClass, DOMId, Logger } from "low/utils";

export const DocLog = new Logger("doc");
Expand Down Expand Up @@ -177,7 +177,7 @@ export const getInjectedStyleTag = (id: string): HTMLStyleElement => {
return styleTag as HTMLStyleElement;
};

const createCssStringForColor = (color: DocColor, type: "fg" | "bg") => {
const createCssStringForColor = (color: DocTagColor, type: "fg" | "bg") => {
if (typeof color === "string") {
return `--rich-text-${type}-light:${color};--rich-text-${type}-dark:${color};`;
}
Expand Down
10 changes: 5 additions & 5 deletions web-client/src/ui/map/MapLayerMgr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import L from "leaflet";
import "leaflet-rastercoords";

import { AppDispatcher, viewActions } from "core/store";
import { MapLayerAttr, MapTilesetTransform, GameCoord } from "low/celerc";
import { MapLayer, MapTilesetTransform, GameCoord } from "low/celerc";

import { MapLog, getAttributionHtml } from "./utils";

/// Tile layer wrapper
type MapLayer = {
type MapTileLayer = {
/// The tile layer
layer: L.TileLayer;
/// The start Z value
Expand All @@ -26,7 +26,7 @@ export class MapLayerMgr {
/// Reference to the app store for dispatching actions
private dispatcher: AppDispatcher;
/// The tileset layers
private layers: MapLayer[] = [];
private layers: MapTileLayer[] = [];
/// The active tileset layer
private activeLayerIndex = -1;

Expand All @@ -39,7 +39,7 @@ export class MapLayerMgr {
/// This will also set the map to the initial coord
public initLayers(
map: L.Map,
mapLayers: MapLayerAttr[],
mapLayers: MapLayer[],
initialCoord: GameCoord,
) {
MapLog.info("initializing map layers");
Expand Down Expand Up @@ -69,7 +69,7 @@ export class MapLayerMgr {
this.setActiveLayer(map, initialLayer);
}

private getActiveLayer(): MapLayer | undefined {
private getActiveLayer(): MapTileLayer | undefined {
return this.layers[this.activeLayerIndex];
}

Expand Down
6 changes: 5 additions & 1 deletion web-client/src/ui/map/MapRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export const MapRoot: React.FC = () => {
return <LoadScreen color="green" />;
}

if (document.project.map.layers.length <= 0) {
const { map } = document.project;
if (!map) {
return <HintScreen>This document has no map</HintScreen>;
}
if (map.layers.length <= 0) {
return <HintScreen>This map has no layers</HintScreen>;
}

Expand Down
16 changes: 14 additions & 2 deletions web-client/src/ui/map/MapState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
viewActions,
viewSelector,
} from "core/store";
import { ExecDoc } from "low/celerc";
import { ExecDoc, GameCoord, MapLayer } from "low/celerc";
import { Debouncer } from "low/utils";

import { MapLog, roughlyEquals } from "./utils";
Expand Down Expand Up @@ -206,7 +206,19 @@ export class MapState {
newDoc.project.source !== oldDoc.project.source ||
newDoc.project.version !== oldDoc.project.version
) {
const { initialCoord, initialZoom, layers } = newDoc.project.map;
const newMap = newDoc.project.map;
let initialCoord: GameCoord;
let initialZoom;
let layers: MapLayer[];
if (newMap) {
initialCoord = newMap.initialCoord;
initialZoom = newMap.initialZoom;
layers = newMap.layers;
} else {
initialCoord = [0, 0, 0];
initialZoom = 0;
layers = [];
}
this.layerMgr.initLayers(this.map, layers, initialCoord);
const [center, _] = this.layerMgr.unproject(initialCoord);
// initLayers above already sets the correct layer
Expand Down
6 changes: 5 additions & 1 deletion web-client/src/ui/toolbar/SwitchMapLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ const useMapLayerNames = () => {
if (!document) {
return [];
}
return document.project.map.layers.map(
const map = document.project.map;
if (!map) {
return [];
}
return map.layers.map(
(layer) => layer.name || "(Unnamed layer)",
);
};
Expand Down

0 comments on commit 0ef4bfe

Please sign in to comment.