Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: Preview

on:
pull_request_target:
types: [labeled, unlabeled, synchronize, reopened, closed]

concurrency:
group: preview-${{ github.event.pull_request.number }}
cancel-in-progress: true

permissions: {}

jobs:
build:
if: >-
(github.event.action == 'labeled' && github.event.label.name == 'preview') ||
(contains(fromJSON('["synchronize", "reopened"]'), github.event.action) &&
contains(github.event.pull_request.labels.*.name, 'preview'))
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
sha: ${{ steps.head.outputs.sha }}
steps:
- uses: actions/checkout@v7
with:
ref: refs/pull/${{ github.event.pull_request.number }}/head
- id: head
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v7
with:
node-version: 24
- run: pnpm install --frozen-lockfile
- run: pnpm build --base=/pr-preview/pr-${{ github.event.pull_request.number }}/
- name: Remove root-only CNAME
run: rm -f dist/CNAME
- uses: actions/upload-artifact@v4
with:
name: preview-dist
path: dist

deploy:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
concurrency:
group: gh-pages-push
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v4
with:
name: preview-dist
path: dist
- name: Deploy preview to gh-pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: dist
branch: gh-pages
target-folder: pr-preview/pr-${{ github.event.pull_request.number }}
clean: true
force: false
commit-message: "Deploy preview for PR #${{ github.event.pull_request.number }}"
- uses: marocchino/sticky-pull-request-comment@v2
with:
header: preview
number: ${{ github.event.pull_request.number }}
message: |
:mag: Preview: https://maps.outlasttrialsstats.com/pr-preview/pr-${{ github.event.pull_request.number }}/

Built from ${{ needs.build.outputs.sha }}. Updates on every push while the `preview` label is set.
Note: page reloads and deep links inside the preview are not supported.

cleanup:
if: >-
github.event.action == 'closed' ||
(github.event.action == 'unlabeled' && github.event.label.name == 'preview')
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
concurrency:
group: gh-pages-push
steps:
- uses: actions/checkout@v7
- name: Remove preview folder from gh-pages
env:
PR: ${{ github.event.pull_request.number }}
run: |
git fetch origin gh-pages:gh-pages --depth=1 || exit 0
git switch gh-pages
[ -d "pr-preview/pr-$PR" ] || exit 0
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git rm -r -q "pr-preview/pr-$PR"
git commit -m "Remove preview for PR #$PR"
git push origin gh-pages
- uses: marocchino/sticky-pull-request-comment@v2
with:
header: preview
number: ${{ github.event.pull_request.number }}
delete: true
25 changes: 10 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: write
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
concurrency:
group: gh-pages-push
steps:
- name: Ensure release runs from main
if: github.ref_name != 'main'
Expand Down Expand Up @@ -78,15 +75,14 @@ jobs:
- name: Add SPA fallback
run: cp dist/index.html dist/404.html

- uses: actions/configure-pages@v6

- uses: actions/upload-pages-artifact@v5
- name: Deploy to gh-pages
uses: JamesIves/github-pages-deploy-action@v4
with:
path: dist

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
folder: dist
branch: gh-pages
clean: true
clean-exclude: pr-preview/
force: false

- name: Commit, tag and push
env:
Expand All @@ -108,10 +104,9 @@ jobs:
- name: Summary
env:
VERSION: ${{ steps.bump.outputs.version }}
PAGE_URL: ${{ steps.deployment.outputs.page_url }}
run: |
{
echo "### Released v$VERSION"
echo
echo "Deployed to $PAGE_URL"
echo "Deployed to https://maps.outlasttrialsstats.com"
} >> "$GITHUB_STEP_SUMMARY"
1 change: 1 addition & 0 deletions public/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
maps.outlasttrialsstats.com
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function releasePressed() {

onMounted(() => {
// Preload the pressed variant so the first click does not flicker
new Image().src = '/images/cursor/cursor_pressed.webp'
new Image().src = `${import.meta.env.BASE_URL}images/cursor/cursor_pressed.webp`

window.addEventListener('pointermove', onPointerMove, { passive: true })
window.addEventListener('pointerdown', onPointerDown)
Expand Down
35 changes: 30 additions & 5 deletions src/core/constants.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/** Base URL of all content fetched at runtime (public/data). */
export const DATA_BASE_URL = '/data'
/** Base URL of all content fetched at runtime (public/data); BASE_URL always ends with '/'. */
export const DATA_BASE_URL = `${import.meta.env.BASE_URL}data`
export const MAPS_INDEX_URL = `${DATA_BASE_URL}/maps/index.json`
export const ELEMENT_LIBRARY_URL = `${DATA_BASE_URL}/elements.json`
export const ZONE_LIBRARY_URL = `${DATA_BASE_URL}/zones.json`
export const CONTRIBUTORS_URL = `${DATA_BASE_URL}/contributors.json`
export const SCHEMA_BASE_URL = '/schemas'
export const SCHEMA_BASE_URL = `${import.meta.env.BASE_URL}schemas`

/** Repo behind the join link of the contributors section. */
export const GITHUB_REPO_URL = 'https://github.com/OutlastTrialsStats/maps'
Expand All @@ -21,6 +21,14 @@ export const GRID_SNAP_DEFAULT = 5
/** Zoom factor, not percent. */
export const ZOOM_MIN = 0.25
export const ZOOM_MAX = 8
/** Scale step of the +/− zoom buttons. */
export const ZOOM_BUTTON_FACTOR = 1.5

/** Wheel deltas in line mode (Firefox) are converted to px before panning. */
export const WHEEL_LINE_HEIGHT_PX = 16

/** Below this pointer travel (screen px) a right-drag stays a plain right-click. */
export const RIGHT_DRAG_PAN_THRESHOLD_PX = 4

/** Fallback for elements without their own `size`, in map units. */
export const ICON_DEFAULT_SIZE = 10
Expand All @@ -44,6 +52,8 @@ export const EDITOR_AUTOSAVE_VERSION = 4
export const CURSOR_STORAGE_KEY = 'outlasttrials-maps:custom-cursor'
export const AUTOSAVE_DEBOUNCE_MS = 1000
export const UNDO_STACK_LIMIT = 100
/** Commits with the same coalesce key within this window share one undo snapshot. */
export const UNDO_COALESCE_MS = 800

export const VALIDATION_DEBOUNCE_MS = 500

Expand All @@ -56,6 +66,18 @@ export const GRID_MIN_SPACING_PX = 8
export const NUDGE_STEP = 1
export const NUDGE_STEP_LARGE = 5

/** Direction per arrow key; y grows downwards (screen and world alike). */
export const ARROW_DIRECTIONS: Record<string, [number, number]> = {
ArrowLeft: [-1, 0],
ArrowRight: [1, 0],
ArrowUp: [0, -1],
ArrowDown: [0, 1],
}

/** Arrow-key view panning (empty selection), in screen px; Shift uses the large step. */
export const VIEW_PAN_STEP_PX = 40
export const VIEW_PAN_STEP_LARGE_PX = 200

/**
* Rotations are limited to fixed steps (R key and properties select);
* in sync with the `multipleOf` of the `rotation` field in the map schema.
Expand All @@ -69,8 +91,11 @@ export const ROTATION_VALUES = Array.from(
/** Offset of duplicated objects (Ctrl+D) and of a paste without cursor position, in map units. */
export const DUPLICATE_OFFSET = 5

/** Hit radius for vertex handles and for switching the active drawing end, in map units. */
export const VERTEX_HIT_RADIUS = 4
/** Hit radius of vertex/resize handles in screen px; divided by the zoom for world-space hit tests. */
export const VERTEX_HIT_RADIUS_PX = 8

/** Below this pointer travel (screen px) an empty-canvas drag counts as a click, not a marquee. */
export const MARQUEE_MIN_DRAG_PX = 4

/** Smallest width/height a room can be resized to, in map units (one grid cell). */
export const ROOM_RESIZE_MIN_SIZE = 5
Expand Down
Loading
Loading