Skip to content

Commit

Permalink
Switch back to tsc generated types and relative engine import paths t…
Browse files Browse the repository at this point in the history
…o support that
  • Loading branch information
anoek committed Jun 25, 2024
1 parent 8fddf0a commit 55f759a
Show file tree
Hide file tree
Showing 40 changed files with 169 additions and 133 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ typings/

lib/
node/
build/
doc/
docs/
deployment-staging-area/
Expand Down
13 changes: 5 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,16 @@ SLACK_WEBHOOK=$(shell cat ../ogs/.slack-webhook)
all dev:
yarn run dev

build: lib types
build: lib

lib: build-debug build-production types
lib: build-debug build-production

build-debug:
yarn run build-debug

build-production:
yarn run build-production

types:
yarn run dts
yarn run dts-engine


lint:
yarn run lint
Expand All @@ -35,7 +31,7 @@ publish_docs: typedoc
cd docs && git add docs && git commit -m "Update docs" && git push

clean:
rm -Rf lib node
rm -Rf lib node build engine/build

publish push: publish_npm publish_docs upload_to_cdn notify

Expand Down Expand Up @@ -63,4 +59,5 @@ upload_to_cdn:
cp lib/goban.min.js* deployment-staging-area
gsutil -m rsync -r deployment-staging-area/ gs://ogs-site-files/goban/`node -pe 'JSON.parse(require("fs").readFileSync("package.json")).version'`/

.PHONY: doc build docs test clean all dev typedoc publich push lib types
.PHONY: doc build docs test clean all dev typedoc publish push lib publish_npm upload_to_cdn notify beta beta_npm publish-beta publish_docs build-debug build-production detect-duplicate-code duplicate-code-detection lint

8 changes: 3 additions & 5 deletions engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
"name": "goban-engine",
"version": "0.8.1",
"description": "",
"main": "goban-engine.js",
"types": "goban-engine.d.ts",
"main": "build/goban-engine.js",
"types": "build/engine/index.d.ts",
"files": [
"goban-engine.js",
"goban-engine.d.ts",
"goban-engine.js.map"
"build/"
],
"keywords": [
"go",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "goban",
"version": "0.8.1",
"description": "",
"main": "lib/goban.js",
"types": "lib/goban.d.ts",
"main": "build/goban.js",
"types": "build/src/index.d.ts",
"files": [
"lib/"
"build/"
],
"keywords": [
"go",
Expand Down
15 changes: 15 additions & 0 deletions scripts/fetch_game_for_autoscore_testing.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
#!/usr/bin/env ts-node
/*
* Copyright (C) Online-Go.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/*
Expand Down
16 changes: 8 additions & 8 deletions src/Goban/CanvasRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,31 @@
* limitations under the License.
*/

import { JGOF, JGOFIntersection, JGOFNumericPlayerColor } from "engine/formats/JGOF";
import { JGOF, JGOFIntersection, JGOFNumericPlayerColor } from "../engine/formats/JGOF";

import { AdHocFormat } from "engine/formats/AdHocFormat";
import { AdHocFormat } from "../engine/formats/AdHocFormat";

import { GobanConfig } from "../GobanBase";
import { GobanEngine } from "engine";
import { MoveTree } from "engine/MoveTree";
import { GobanEngine } from "../engine";
import { MoveTree } from "../engine/MoveTree";
import { GobanTheme, THEMES } from "./themes";
import { MoveTreePenMarks } from "engine/MoveTree";
import { MoveTreePenMarks } from "../engine/MoveTree";
import {
createDeviceScaledCanvas,
resizeDeviceScaledCanvas,
allocateCanvasOrError,
getRelativeEventPosition,
} from "./canvas_utils";
import { _ } from "engine/translate";
import { formatMessage, MessageID } from "engine/messages";
import { _ } from "../engine/translate";
import { formatMessage, MessageID } from "../engine/messages";
import {
color_blend,
encodeMove,
encodeMoves,
encodePrettyXCoordinate,
getRandomInt,
makeMatrix,
} from "engine/util";
} from "../engine/util";
import { callbacks } from "./callbacks";
import { Goban, GobanMetrics, GobanSelectedThemes, GOBAN_FONT } from "./Goban";

Expand Down
2 changes: 1 addition & 1 deletion src/Goban/Goban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { MARK_TYPES } from "./InteractiveBase";
import { OGSConnectivity } from "./OGSConnectivity";
import { GobanConfig } from "../GobanBase";
import { callbacks } from "./callbacks";
import { makeMatrix, StoneStringBuilder } from "engine";
import { makeMatrix, StoneStringBuilder } from "../engine";
import { getRelativeEventPosition } from "./canvas_utils";
import { THEMES, THEMES_SORTED } from "./themes";

Expand Down
70 changes: 9 additions & 61 deletions src/Goban/InteractiveBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,20 @@
import {
GobanEngine,
GobanEnginePhase,
GobanEngineRules,
ReviewMessage,
PlayerColor,
PuzzlePlacementSetting,
Score,
ConditionalMoveTree,
GobanMoveError,
} from "engine";
import { NumberMatrix, encodeMove, makeMatrix, makeEmptyMatrix } from "engine/util";
import { MoveTree, MarkInterface } from "engine/MoveTree";
import { ScoreEstimator } from "engine/ScoreEstimator";
import { computeAverageMoveTime, niceInterval, matricesAreEqual } from "engine/util";
import { _ } from "engine/translate";
import {
JGOFIntersection,
JGOFPlayerClock,
JGOFTimeControlSystem,
JGOFNumericPlayerColor,
} from "engine/formats/JGOF";
import { AdHocClock, AdHocPauseControl } from "engine/formats/AdHocFormat";
import { ServerToClient, StallingScoreEstimate } from "engine/protocol";
} from "../engine";
import { NumberMatrix, encodeMove, makeMatrix, makeEmptyMatrix } from "../engine/util";
import { MoveTree, MarkInterface } from "../engine/MoveTree";
import { ScoreEstimator } from "../engine/ScoreEstimator";
import { computeAverageMoveTime, niceInterval, matricesAreEqual } from "../engine/util";
import { _ } from "../engine/translate";
import { JGOFIntersection, JGOFPlayerClock, JGOFNumericPlayerColor } from "../engine/formats/JGOF";
import { AdHocClock, AdHocPauseControl } from "../engine/formats/AdHocFormat";
import { StallingScoreEstimate } from "../engine/protocol";
import { callbacks } from "./callbacks";
import {
GobanBase,
Expand Down Expand Up @@ -74,28 +67,6 @@ export interface ColoredCircle {
border_color?: string;
}

export interface AudioClockEvent {
/** Number of seconds left in the current period */
countdown_seconds: number;

/** Full player clock information */
clock: JGOFPlayerClock;

/** The player (id) whose turn it is */
player_id: string;

/** The player whose turn it is */
color: PlayerColor;

/** Time control system being used by the clock */
time_control_system: JGOFTimeControlSystem;

/** True if we are in overtime. This is only ever set for systems that have
* a concept of overtime.
*/
in_overtime: boolean;
}

export interface MoveCommand {
//game_id?: number | string;
game_id: number;
Expand All @@ -104,29 +75,6 @@ export interface MoveCommand {
clock?: JGOFPlayerClock;
}

export interface StateUpdateEvents {
mode: (d: GobanModes) => void;
title: (d: string) => void;
phase: (d: GobanEnginePhase) => void;
cur_move: (d: MoveTree) => void;
cur_review_move: (d: MoveTree | undefined) => void;
last_official_move: (d: MoveTree) => void;
submit_move: (d: (() => void) | undefined) => void;
analyze_tool: (d: AnalysisTool) => void;
analyze_subtool: (d: AnalysisSubTool) => void;
score_estimate: (d: ScoreEstimator | null) => void;
strict_seki_mode: (d: boolean) => void;
rules: (d: GobanEngineRules) => void;
winner: (d: number | undefined) => void;
undo_requested: (d: number | undefined) => void; // move number of the last undo request
undo_canceled: () => void;
paused: (d: boolean) => void;
outcome: (d: string) => void;
review_owner_id: (d: number | undefined) => void;
review_controller_id: (d: number | undefined) => void;
stalling_score_estimate: ServerToClient["game/:id/stalling_score_estimate"];
}

/**
* This class serves as a functionality layer encapsulating core interactions
* we do with a Goban, we have it as a separate base class simply to help with
Expand Down
10 changes: 5 additions & 5 deletions src/Goban/OGSConnectivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
* limitations under the License.
*/

import { AudioClockEvent, GobanInteractive, MARK_TYPES, MoveCommand } from "./InteractiveBase";
import { GobanConfig, JGOFClockWithTransmitting } from "../GobanBase";
import { GobanInteractive, MARK_TYPES, MoveCommand } from "./InteractiveBase";
import { AudioClockEvent, GobanConfig, JGOFClockWithTransmitting } from "../GobanBase";
import { callbacks } from "./callbacks";
import { _, interpolate } from "engine/translate";
import { _, interpolate } from "../engine/translate";
import { focus_tracker } from "./focus_tracker";
import {
AdHocClock,
Expand Down Expand Up @@ -45,13 +45,13 @@ import {
ScoreEstimator,
JGOFMove,
makeMatrix,
} from "engine";
} from "../engine";
import {
//ServerToClient,
GameChatMessage,
//GameChatLine,
//StallingScoreEstimate,
} from "engine/protocol";
} from "../engine/protocol";

declare let swal: any;

Expand Down
16 changes: 8 additions & 8 deletions src/Goban/SVGRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
* limitations under the License.
*/

import { JGOF, JGOFIntersection, JGOFNumericPlayerColor } from "engine/formats/JGOF";
import { JGOF, JGOFIntersection, JGOFNumericPlayerColor } from "../engine/formats/JGOF";

import { AdHocFormat } from "engine/formats/AdHocFormat";
import { AdHocFormat } from "../engine/formats/AdHocFormat";

//import { GobanCore, GobanSelectedThemes, GobanMetrics, GOBAN_FONT } from "./GobanCore";
import { GobanConfig } from "../GobanBase";
import { GobanEngine } from "engine";
import { MoveTree } from "engine/MoveTree";
import { GobanEngine } from "../engine";
import { MoveTree } from "../engine/MoveTree";
import { GobanTheme, THEMES } from "./themes";
import { MoveTreePenMarks } from "engine/MoveTree";
import { MoveTreePenMarks } from "../engine/MoveTree";
import { getRelativeEventPosition } from "./canvas_utils";
import { _ } from "engine/translate";
import { formatMessage, MessageID } from "engine/messages";
import { _ } from "../engine/translate";
import { formatMessage, MessageID } from "../engine/messages";
import {
color_blend,
encodeMove,
encodeMoves,
encodePrettyXCoordinate,
getRandomInt,
makeMatrix,
} from "engine/util";
} from "../engine/util";
import { callbacks } from "./callbacks";
import { Goban, GobanMetrics, GobanSelectedThemes } from "./Goban";

Expand Down
6 changes: 3 additions & 3 deletions src/Goban/TestGoban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
*/

import { GobanConfig } from "../GobanBase";
import { GobanEngine } from "engine/GobanEngine";
import { MessageID } from "engine/messages";
import { MoveTreePenMarks } from "engine/MoveTree";
import { GobanEngine } from "../engine/GobanEngine";
import { MessageID } from "../engine/messages";
import { MoveTreePenMarks } from "../engine/MoveTree";
import { Goban, GobanSelectedThemes } from "./Goban";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Goban/themes/board_plain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { GobanTheme, GobanThemeBackgroundCSS } from "./GobanTheme";
import { ThemesInterface } from "./";
import { callbacks } from "../callbacks";
import { _ } from "engine/translate";
import { _ } from "../../engine/translate";

// Converts a six-digit hex string to rgba() notation
function hexToRgba(raw: string, alpha: number = 1): string {
Expand Down
2 changes: 1 addition & 1 deletion src/Goban/themes/board_woods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { GobanTheme, GobanThemeBackgroundCSS } from "./GobanTheme";
import { ThemesInterface } from "./";
import { _ } from "engine/translate";
import { _ } from "../../engine/translate";
import { callbacks } from "../callbacks";

function getCDNReleaseBase() {
Expand Down
2 changes: 1 addition & 1 deletion src/Goban/themes/image_stones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { GobanTheme } from "./GobanTheme";
import { ThemesInterface } from "./";
import { _ } from "engine/translate";
import { _ } from "../../engine/translate";
import { deviceCanvasScalingRatio, allocateCanvasOrError } from "../canvas_utils";
import { renderShadow } from "./rendered_stones";
import { renderPlainStone } from "./plain_stones";
Expand Down
2 changes: 1 addition & 1 deletion src/Goban/themes/plain_stones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { GobanTheme } from "./GobanTheme";
import { ThemesInterface } from "./";
import { _ } from "engine/translate";
import { _ } from "../../engine/translate";

export function renderPlainStone(
ctx: CanvasRenderingContext2D,
Expand Down
2 changes: 1 addition & 1 deletion src/Goban/themes/rendered_stones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { GobanTheme } from "./GobanTheme";
import { ThemesInterface } from "./";
import { _ } from "engine/translate";
import { _ } from "../../engine/translate";
import { deviceCanvasScalingRatio, allocateCanvasOrError } from "../canvas_utils";

type StoneType = { stone: HTMLCanvasElement; shadow: HTMLCanvasElement };
Expand Down
18 changes: 9 additions & 9 deletions src/GobanBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import {
PlayerColor,
PuzzleConfig,
PuzzlePlacementSetting,
} from "engine";
import { MoveTree, MoveTreePenMarks } from "engine/MoveTree";
import { ScoreEstimator } from "engine/ScoreEstimator";
import { setGobanTranslations } from "engine/translate";
} from "./engine";
import { MoveTree, MoveTreePenMarks } from "./engine/MoveTree";
import { ScoreEstimator } from "./engine/ScoreEstimator";
import { setGobanTranslations } from "./engine/translate";
import {
JGOFClock,
JGOFIntersection,
Expand All @@ -36,11 +36,11 @@ import {
JGOFSealingIntersection,
JGOFNumericPlayerColor,
JGOFMove,
} from "engine/formats/JGOF";
import { AdHocPackedMove, AdHocPauseControl } from "engine/formats/AdHocFormat";
import { MessageID } from "engine/messages";
import type { GobanSocket } from "engine/GobanSocket";
import type { ServerToClient, GameChatLine } from "engine/protocol";
} from "./engine/formats/JGOF";
import { AdHocPackedMove, AdHocPauseControl } from "./engine/formats/AdHocFormat";
import { MessageID } from "./engine/messages";
import type { GobanSocket } from "./engine/GobanSocket";
import type { ServerToClient, GameChatLine } from "./engine/protocol";
import { EventEmitter } from "eventemitter3";
import { setGobanCallbacks } from "./Goban/callbacks";

Expand Down
Loading

0 comments on commit 55f759a

Please sign in to comment.