diff options
| author | eunhhu <[email protected]> | 2026-09-26 11:54:31 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-26 11:54:31 +0100 |
| commit | 8e2b3ffadcf83dba74d58dbf9ee2c57cef5f1ad5 (patch) | |
| tree | c99c2c0066af352e9f7487763cf016740467f917 /docs/design/001-first-component.md | |
| parent | 932df09ea211a83a24210d821dc3d0093ed73561 (diff) | |
| download | vega-8e2b3ffadcf83dba74d58dbf9ee2c57cef5f1ad5.tar.gz vega-8e2b3ffadcf83dba74d58dbf9ee2c57cef5f1ad5.zip | |
Swap a running app's module: --watch and the swap command
vega tui|web MODULE --watch replaces the running app's module when its
file is written again (aup watch writes it); states keep their values by
name through pure_app_replace and every web page hears of it. The file is
compared by the digest of its bytes, at most five times a second, so a
module of the same size written within the same second is not missed; a
module that does not load leaves the app as it was and is not tried
again. Modules alternate between two slots so a failed load never touches
the running one. Scripts get swap MODULE; whether a module runs frames is
now a property of the screen.
Diffstat (limited to 'docs/design/001-first-component.md')
| -rw-r--r-- | docs/design/001-first-component.md | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/docs/design/001-first-component.md b/docs/design/001-first-component.md index 5d1adce..0a747fc 100644 --- a/docs/design/001-first-component.md +++ b/docs/design/001-first-component.md @@ -93,6 +93,28 @@ TUI는 매 변경마다 격자를 앱에서 다시 그리지만(보이는 칸만 무작위 입력 4,800 프레임(40×12, 24×9, 80×30)에서 모두 같았다. 한 프레임이 보내는 바이트는 평균 1,220 B(전체)에서 143 B(변경분)로 줄었다. SSH처럼 느린 터미널에서 입력 한 번의 화면 갱신이 그만큼 가볍다. +## 고쳐 쓰는 동안 (`--watch`) + +```sh +AUP_PATH=lib aup watch app.aup -o app.pmod & # 저장할 때마다 다시 빌드 +vega tui app.pmod --watch --store ~/.app # 또는 vega web app.pmod --watch +``` + +`--watch`(tui, web)는 모듈 파일이 다시 쓰이면 실행 중인 앱의 모듈을 새것으로 바꾼다. 상태는 Pure의 +`pure_app_replace`가 이름으로 이어받는다. 목록의 항목은 필드 이름으로, 포커스와 완료 표시는 그대로 남고, 새 상태는 +초기값으로 시작한다. 화면(제목·필드·목록·입력줄)은 새 모듈에서 다시 읽고, 웹은 열린 모든 페이지에 알린다. +스크립트에서는 `swap MODULE`이 같은 일을 한다. + +- **바이트로 본다.** 파일 시각이 아니라 읽은 바이트의 digest를 비교한다. 1초 안에 같은 크기로 다시 쓴 모듈도 + 놓치지 않는다. 확인은 초당 다섯 번까지이고, 모듈 하나(수 KB)를 읽는 비용이다. +- **로드되지 않는 모듈은 거절한다.** 검증을 통과하지 못하거나 바꿀 수 없는 모듈이면 실행 중인 앱을 그대로 두고 + stderr에 이유를 한 번 쓴다. 같은 바이트는 다시 시도하지 않는다. aup는 모듈을 임시 파일에 쓰고 rename하므로 반쯤 + 쓰인 모듈을 읽는 일이 없다. 다른 도구가 제자리에 쓰면 읽다 만 모듈은 검증에서 거절되고, 다 쓴 모듈이 다음 + 확인에서 들어온다. +- **두 칸.** 모듈은 두 칸을 번갈아 쓴다. 새 모듈을 빈 칸에 로드하고 바꾸는 데 성공해야 그 칸이 실행 칸이 된다. + 그래서 실패한 로드가 실행 중인 모듈을 건드리지 않는다. 로드된 모듈은 파일 바이트를 붙잡지 않으므로 읽기 버퍼는 + 하나다. + ## 규약 검사 (`vega check`) `vega check app.pmod`는 모듈이 뜻한 듯하지만 규약에 맞지 않는 곳을 알린다. 표면은 이런 보기를 조용히 다른 @@ -140,6 +162,8 @@ CLI나 문장 표면이 그대로 이어받는다. Vega에도 앱에도 저장 � 같다(포커스는 그 항목을 가진 목록에만 있다). 웹 JSON은 다른 목록의 포커스를 null로 준다. - 무작위 스크립트에 `point`(범위 밖 포함)와 TUI `click`을 섞어도 CLI·문장·프레임이 모델과 같다. 가상 터미널에서 마우스로 행을 클릭하면 포커스가 옮겨지고, 저장소를 쓰는 다음 실행이 그 포커스에서 시작한다. +- 모듈 교체: 스크립트의 `swap`, 웹의 `--watch`(새 제목과 필드, 같은 항목, 모든 페이지에 알림), 1초 안에 같은 크기로 + 다시 쓴 모듈, 깨진 모듈의 거절, 가상 터미널 TUI의 `--watch`(포커스와 완료 표시 유지)를 확인한다. ## 남은 것 |
