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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ server_stderr.log
/tools/xeto/checkXetoFiles.sh

# Local tool output
/tools/editor-dev.env
/.playwright-mcp/
/editor_connected.png
17 changes: 17 additions & 0 deletions HowToUses/03_WEB_EDITOR.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@
http://<host>:8085/editor
```

## Vue editor against a real device (development)

The Vue Sedona editor (`sedonaWebEditor`, branch `trkrDevelop`) runs from its
dev server and proxies `/live`, `/api`, `/file` to a device:

```bash
# Device address: argument, SANDSTAR_DEVICE, or tools/editor-dev.env
# (git-ignored; one line SANDSTAR_DEVICE=<host>)
bash tools/editor-dev.sh [device[:port]]
```

The script checks the device (`/api/about`, whether the editor gate asks for
a login) and starts the editor at `http://localhost:8091/`. Add a connection
with the device user; leave `peer` empty (it defaults to the page origin).
With auth on, the device needs `--ws-allowed-origins http://localhost:8091`.
Edits in the editor go to the running app on the device.

## Layout
- **Left sidebar**: Tree navigator (top) + Component palette (bottom)
- **Center canvas**: Visual wire sheet (only user-added components)
Expand Down
84 changes: 84 additions & 0 deletions tools/editor-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env bash
# Start the Vue Sedona editor dev server against a real Sandstar device.
#
# The editor runs at http://localhost:<port>/ and its dev proxy forwards
# /live, /api, /file and /auth to http://<device>:8085 (vue.config.js,
# SOX_PROXY_URL). Same origin for the browser, so the S-32 session cookie
# works when auth is on.
#
# Usage:
# bash tools/editor-dev.sh [device[:port]]
#
# Device address, first match wins (host/IP is never written in the repo):
# 1. first argument;
# 2. SANDSTAR_DEVICE environment variable;
# 3. tools/editor-dev.env (git-ignored), a line: SANDSTAR_DEVICE=<host>
#
# Optional environment:
# SEDONA_EDITOR_DIR editor checkout (default C:/Coding/swe/sedonaWebEditor)
# EDITOR_PORT dev server port (default 8091)
#
# With auth on, the device must allow this page origin:
# --ws-allowed-origins http://localhost:<port>
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ENV_FILE="${SCRIPT_DIR}/editor-dev.env"

DEVICE="${1:-${SANDSTAR_DEVICE:-}}"
if [ -z "$DEVICE" ] && [ -f "$ENV_FILE" ]; then
DEVICE="$(sed -n 's/^SANDSTAR_DEVICE=//p' "$ENV_FILE" | tr -d '\r' | head -1)"
fi
if [ -z "$DEVICE" ]; then
echo "error: no device address. Pass it as an argument, set SANDSTAR_DEVICE," >&2
echo " or write SANDSTAR_DEVICE=<host> to ${ENV_FILE}" >&2
exit 2
fi
case "$DEVICE" in
*:*) TARGET="http://${DEVICE}" ;;
*) TARGET="http://${DEVICE}:8085" ;;
esac

EDITOR_DIR="${SEDONA_EDITOR_DIR:-C:/Coding/swe/sedonaWebEditor}"
PORT="${EDITOR_PORT:-8091}"

if [ ! -f "${EDITOR_DIR}/vue.config.js" ]; then
echo "error: editor not found at ${EDITOR_DIR} (set SEDONA_EDITOR_DIR)" >&2
exit 2
fi
if [ ! -d "${EDITOR_DIR}/node_modules" ]; then
echo "error: ${EDITOR_DIR}/node_modules missing; run 'npm ci' there first" >&2
exit 2
fi

# Refuse to start a second server on the same port.
if curl -s -o /dev/null -m 2 "http://localhost:${PORT}/"; then
echo "error: something already answers on localhost:${PORT}" >&2
exit 1
fi

echo "== device"
if ! about="$(curl -sf -m 5 "${TARGET}/api/about")"; then
echo "error: device not reachable (GET /api/about failed)" >&2
exit 1
fi
version="$(printf '%s' "$about" | grep -oE '2\.[0-9]+\.[0-9]+\+[0-9a-f]+' | head -1 || true)"
echo " version: ${version:-unknown}"
gate="$(curl -s -o /dev/null -m 5 -w '%{http_code}' -I "${TARGET}/live/sedonaState" || true)"
case "$gate" in
200) echo " auth: off (editor gate open)" ;;
401) echo " auth: on (log in with a Sandstar user)" ;;
*) echo " auth: unknown (HEAD /live/sedonaState -> ${gate})" ;;
esac

echo "== editor"
branch="$(git -C "$EDITOR_DIR" branch --show-current 2>/dev/null || echo '?')"
commit="$(git -C "$EDITOR_DIR" log -1 --format=%h 2>/dev/null || echo '?')"
echo " ${EDITOR_DIR} (${branch} ${commit})"
echo " open http://localhost:${PORT}/ and add a connection with host localhost:${PORT}"
echo " this is a real device: edits in the editor go to the running app"
echo

cd "$EDITOR_DIR"
export SOX_PROXY_URL="$TARGET"
exec npx vue-cli-service serve --port "$PORT"
Loading