Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2388603322 | ||
|
|
750564ab7e | ||
|
|
3fadee87d3 | ||
|
|
ba231e7187 | ||
|
|
a1915f070b |
No files matched your search
@@ -33,7 +33,7 @@ jobs:
|
|||||||
version: ${{ steps.version.outputs.version }}
|
version: ${{ steps.version.outputs.version }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
@@ -63,14 +63,14 @@ jobs:
|
|||||||
- { type: apk, sdk: 'itdoginfo/openwrt-sdk-apk:25.12.3@sha256:6d832008ddd1b8ec4edc84f5e6e0bf22a13ba2d6888083a8e69fa26d752c276f' }
|
- { type: apk, sdk: 'itdoginfo/openwrt-sdk-apk:25.12.3@sha256:6d832008ddd1b8ec4edc84f5e6e0bf22a13ba2d6888083a8e69fa26d752c276f' }
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5
|
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: '26'
|
||||||
cache: npm
|
cache: npm
|
||||||
cache-dependency-path: web/package-lock.json
|
cache-dependency-path: web/package-lock.json
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ jobs:
|
|||||||
run: scripts/build-packages.sh ${{ matrix.type }}
|
run: scripts/build-packages.sh ${{ matrix.type }}
|
||||||
|
|
||||||
- name: Upload
|
- name: Upload
|
||||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
with:
|
with:
|
||||||
name: package-${{ matrix.type }}
|
name: package-${{ matrix.type }}
|
||||||
# The app and its translation packages (luci-i18n-dawnline-<lang>).
|
# The app and its translation packages (luci-i18n-dawnline-<lang>).
|
||||||
@@ -105,7 +105,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
# The whole history and the tags: the notes list the commits since the previous tag.
|
# The whole history and the tags: the notes list the commits since the previous tag.
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
@@ -116,7 +116,7 @@ jobs:
|
|||||||
cat notes.md
|
cat notes.md
|
||||||
|
|
||||||
- name: Download packages
|
- name: Download packages
|
||||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||||
with:
|
with:
|
||||||
pattern: package-*
|
pattern: package-*
|
||||||
path: release
|
path: release
|
||||||
@@ -129,7 +129,7 @@ jobs:
|
|||||||
cat sha256sums.txt
|
cat sha256sums.txt
|
||||||
|
|
||||||
- name: Publish the release
|
- name: Publish the release
|
||||||
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2
|
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3
|
||||||
with:
|
with:
|
||||||
name: Dawnline ${{ github.ref_name }}
|
name: Dawnline ${{ github.ref_name }}
|
||||||
tag_name: ${{ github.ref_name }}
|
tag_name: ${{ github.ref_name }}
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ jobs:
|
|||||||
working-directory: web
|
working-directory: web
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v5
|
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||||
with:
|
with:
|
||||||
node-version: '22'
|
node-version: '26'
|
||||||
cache: npm
|
cache: npm
|
||||||
cache-dependency-path: web/package-lock.json
|
cache-dependency-path: web/package-lock.json
|
||||||
|
|
||||||
@@ -51,6 +51,20 @@ jobs:
|
|||||||
id: types
|
id: types
|
||||||
run: npm run --silent typecheck
|
run: npm run --silent typecheck
|
||||||
|
|
||||||
|
# oxlint's correctness rules: what the types let through (a stray expression, a needless escape).
|
||||||
|
- name: Lint
|
||||||
|
id: lint
|
||||||
|
run: npm run --silent lint
|
||||||
|
|
||||||
|
# Exports nobody imports, files nobody reaches, dependencies used but not listed (or listed but unused).
|
||||||
|
- name: Unused code
|
||||||
|
id: knip
|
||||||
|
run: |
|
||||||
|
if ! npm run --silent knip; then
|
||||||
|
echo "::error::knip found unused code or a dependency problem: remove it, or drop the export when only its own file uses it."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# The catalogs follow the code: every string collected, translated, its placeholders kept.
|
# The catalogs follow the code: every string collected, translated, its placeholders kept.
|
||||||
- name: Translations
|
- name: Translations
|
||||||
id: i18n
|
id: i18n
|
||||||
@@ -64,17 +78,17 @@ jobs:
|
|||||||
id: tests
|
id: tests
|
||||||
run: npm test
|
run: npm test
|
||||||
|
|
||||||
# The bundles under package/ are committed: a build must change nothing
|
# The bundles under package/ are not committed (build.yml builds them
|
||||||
# and leave no new file behind (an output nobody added to git would be
|
# before packaging): a build must touch no tracked file and leave every
|
||||||
# missing from the package).
|
# output it writes ignored by .gitignore, so none ends up in a commit.
|
||||||
- name: Build bundles and check they are committed
|
- name: Build bundles and check they stay out of git
|
||||||
id: build
|
id: build
|
||||||
run: |
|
run: |
|
||||||
npm run --silent build
|
npm run --silent build
|
||||||
changed="$(git status --porcelain --untracked-files=all -- ../package)"
|
changed="$(git status --porcelain --untracked-files=all -- ../package)"
|
||||||
if [ -n "$changed" ]; then
|
if [ -n "$changed" ]; then
|
||||||
echo "$changed"
|
echo "$changed"
|
||||||
echo "::error::The committed bundles are out of date or the build left new files. Run 'npm run build' in web/ and commit the result."
|
echo "::error::The build changed a tracked file under package/ or wrote one .gitignore does not cover."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -88,6 +102,8 @@ jobs:
|
|||||||
echo "|---|---|"
|
echo "|---|---|"
|
||||||
echo "| Formatting | ${{ steps.format.outcome }} |"
|
echo "| Formatting | ${{ steps.format.outcome }} |"
|
||||||
echo "| Types | ${{ steps.types.outcome }} |"
|
echo "| Types | ${{ steps.types.outcome }} |"
|
||||||
|
echo "| Lint | ${{ steps.lint.outcome }} |"
|
||||||
|
echo "| Unused code | ${{ steps.knip.outcome }} |"
|
||||||
echo "| Translations | ${{ steps.i18n.outcome }} |"
|
echo "| Translations | ${{ steps.i18n.outcome }} |"
|
||||||
echo "| Tests | ${{ steps.tests.outcome }} |"
|
echo "| Tests | ${{ steps.tests.outcome }} |"
|
||||||
echo "| Bundles | ${{ steps.build.outcome }} |"
|
echo "| Bundles | ${{ steps.build.outcome }} |"
|
||||||
@@ -98,7 +114,7 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
@@ -127,7 +143,7 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
@@ -174,7 +190,7 @@ jobs:
|
|||||||
release: ['24.10', '25.12']
|
release: ['24.10', '25.12']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
|
|
||||||
|
|||||||
@@ -2,3 +2,6 @@ node_modules/
|
|||||||
dist/
|
dist/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
web/coverage/
|
web/coverage/
|
||||||
|
# The web bundles: web/ builds them (npm run build), CI before packaging.
|
||||||
|
package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/
|
||||||
|
package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/
|
||||||
@@ -17,7 +17,7 @@ This repo usually sits inside the router-admin workspace (`../AGENTS.md`). Its r
|
|||||||
## Layout
|
## Layout
|
||||||
|
|
||||||
- `package/luci-app-dawnline/root/` — what lands on the router: ucode modules in `usr/share/ucode/dawnline/` (`rpc/` for the LuCI backend), the agent and updater in `usr/libexec/dawnline/`, the portal in `usr/share/dawnline/portal/`, the init script, rpcd ACL.
|
- `package/luci-app-dawnline/root/` — what lands on the router: ucode modules in `usr/share/ucode/dawnline/` (`rpc/` for the LuCI backend), the agent and updater in `usr/libexec/dawnline/`, the portal in `usr/share/dawnline/portal/`, the init script, rpcd ACL.
|
||||||
- `web/` — TypeScript sources of the admin UI (`src/admin`) and the portal (`src/portal`), shared code in `src/shared`; the built bundles are committed under `package/`. `web/i18n/` — the string catalogs' tools (`extract.ts`, `po.ts`, `lmo.ts`).
|
- `web/` — TypeScript sources of the admin UI (`src/admin`) and the portal (`src/portal`), shared code in `src/shared`; `npm run build` writes the bundles under `package/` (git-ignored: CI builds them before packaging). `web/i18n/` — the string catalogs' tools (`extract.ts`, `po.ts`, `lmo.ts`).
|
||||||
- `package/luci-app-dawnline/po/` — the admin's catalog (`templates/dawnline.pot`, `ru/dawnline.po`): luci.mk builds the `luci-i18n-dawnline-ru` package from it. The portal's catalog is `web/src/portal/i18n/ru.po`, bundled into the portal.
|
- `package/luci-app-dawnline/po/` — the admin's catalog (`templates/dawnline.pot`, `ru/dawnline.po`): luci.mk builds the `luci-i18n-dawnline-ru` package from it. The portal's catalog is `web/src/portal/i18n/ru.po`, bundled into the portal.
|
||||||
- `install.sh`, `uninstall.sh` — the standalone installer and uninstaller (both have `--dry-run`).
|
- `install.sh`, `uninstall.sh` — the standalone installer and uninstaller (both have `--dry-run`).
|
||||||
- `scripts/` — `lint-ucode.py`, `compile-ucode.sh` (compiles every ucode file of a tree wherever ucode runs), `check-ucode.sh` (the same on the router, without installing), `ucode-container.sh` (compile and unit tests in the OpenWrt rootfs containers CI uses), `deploy.sh` (dev deploy over SSH), `build-packages.sh`, `build-release.sh`, `release-notes.sh`.
|
- `scripts/` — `lint-ucode.py`, `compile-ucode.sh` (compiles every ucode file of a tree wherever ucode runs), `check-ucode.sh` (the same on the router, without installing), `ucode-container.sh` (compile and unit tests in the OpenWrt rootfs containers CI uses), `deploy.sh` (dev deploy over SSH), `build-packages.sh`, `build-release.sh`, `release-notes.sh`.
|
||||||
@@ -27,7 +27,7 @@ This repo usually sits inside the router-admin workspace (`../AGENTS.md`). Its r
|
|||||||
|
|
||||||
- `python3 scripts/lint-ucode.py` (use before definition, exports, POSIX regexes, rpcd methods; layering notes are informational).
|
- `python3 scripts/lint-ucode.py` (use before definition, exports, POSIX regexes, rpcd methods; layering notes are informational).
|
||||||
- `scripts/ucode-container.sh` (needs docker): compiles every ucode file and runs `tests/ucode` on OpenWrt 24.10 and 25.12, exactly what CI does. `scripts/check-ucode.sh` compiles on the router instead when there is no docker. New ucode entry points are added to the compile list in `scripts/compile-ucode.sh`, to `lint-ucode.py`, and to the executables list in `.github/workflows/ci.yml`; a pure function gets a case in `tests/ucode/<module>.test.uc`.
|
- `scripts/ucode-container.sh` (needs docker): compiles every ucode file and runs `tests/ucode` on OpenWrt 24.10 and 25.12, exactly what CI does. `scripts/check-ucode.sh` compiles on the router instead when there is no docker. New ucode entry points are added to the compile list in `scripts/compile-ucode.sh`, to `lint-ucode.py`, and to the executables list in `.github/workflows/ci.yml`; a pure function gets a case in `tests/ucode/<module>.test.uc`.
|
||||||
- In `web/`: `npm run format:check`, `npm run typecheck` (sources and tests), `npm run i18n:check` (after changing visible text: `npm run i18n`, translate the new entries in each `ru.po`), `npm test`, `npm run build` — and commit the rebuilt bundles and the catalogs (CI fails on a changed or new file under `package/`).
|
- In `web/`: `npm run format:check`, `npm run typecheck` (sources and tests), `npm run lint` (oxlint), `npm run knip` (unused exports and dependencies), `npm run i18n:check` (after changing visible text: `npm run i18n`, translate the new entries in each `ru.po`), `npm test`, `npm run build` — and commit the catalogs (the bundles stay out of git; CI fails when the build leaves a file under `package/` that `.gitignore` does not cover).
|
||||||
- `shellcheck -S warning` for the shell scripts (CI finds them by shebang).
|
- `shellcheck -S warning` for the shell scripts (CI finds them by shebang).
|
||||||
- A tag builds only after CI passes on it (`build.yml` calls `ci.yml`).
|
- A tag builds only after CI passes on it (`build.yml` calls `ci.yml`).
|
||||||
|
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ scripts/ build, deploy and check scripts
|
|||||||
cd web
|
cd web
|
||||||
npm ci
|
npm ci
|
||||||
npm run format # Prettier
|
npm run format # Prettier
|
||||||
npm run ci # format check, types, catalogs, tests, minified bundles
|
npm run ci # format check, types, lint, unused code, catalogs, tests, minified bundles
|
||||||
npm run i18n # collect new strings into the catalogs (then translate them in ru.po)
|
npm run i18n # collect new strings into the catalogs (then translate them in ru.po)
|
||||||
|
|
||||||
scripts/lint-ucode.py # static ucode checks
|
scripts/lint-ucode.py # static ucode checks
|
||||||
@@ -412,8 +412,9 @@ scripts/capture-portal.mjs # the portal's from its demo, in Englis
|
|||||||
scripts/frame-screenshots.py # frame them for this README
|
scripts/frame-screenshots.py # frame them for this README
|
||||||
```
|
```
|
||||||
|
|
||||||
The web bundles and the catalogs are committed: CI fails when they are out of
|
The web bundles are built, not committed (`npm run build` before
|
||||||
date or a string is untranslated (`rules/i18n.md`). Pushing a tag `vX.Y.Z`
|
`scripts/build-packages.sh`); the catalogs are committed, and CI fails when they
|
||||||
|
are out of date or a string is untranslated (`rules/i18n.md`). Pushing a tag `vX.Y.Z`
|
||||||
(matching `PKG_VERSION`) builds the packages and their translations with the
|
(matching `PKG_VERSION`) builds the packages and their translations with the
|
||||||
OpenWrt SDK and publishes a release with `sha256sums.txt`.
|
OpenWrt SDK and publishes a release with `sha256sums.txt`.
|
||||||
|
|
||||||
|
|||||||
@@ -404,7 +404,7 @@ scripts/ скрипты сборки, деплоя и
|
|||||||
cd web
|
cd web
|
||||||
npm ci
|
npm ci
|
||||||
npm run format # Prettier
|
npm run format # Prettier
|
||||||
npm run ci # форматирование, типы, каталоги, тесты, минифицированные бандлы
|
npm run ci # форматирование, типы, линтер, неиспользуемый код, каталоги, тесты, бандлы
|
||||||
npm run i18n # собрать новые строки в каталоги (затем перевести их в ru.po)
|
npm run i18n # собрать новые строки в каталоги (затем перевести их в ru.po)
|
||||||
|
|
||||||
scripts/lint-ucode.py # статические проверки ucode
|
scripts/lint-ucode.py # статические проверки ucode
|
||||||
@@ -416,8 +416,9 @@ scripts/capture-portal.mjs # скриншоты портала д
|
|||||||
scripts/frame-screenshots.py # оформить их для README
|
scripts/frame-screenshots.py # оформить их для README
|
||||||
```
|
```
|
||||||
|
|
||||||
Бандлы и каталоги лежат в репозитории: CI падает, если они устарели или строка
|
Бандлы не лежат в репозитории, они собираются (`npm run build` перед
|
||||||
не переведена (`rules/i18n.md`). Тег `vX.Y.Z` (совпадающий с `PKG_VERSION`)
|
`scripts/build-packages.sh`); каталоги лежат, и CI падает, если они устарели или
|
||||||
|
строка не переведена (`rules/i18n.md`). Тег `vX.Y.Z` (совпадающий с `PKG_VERSION`)
|
||||||
собирает пакеты и переводы в OpenWrt SDK и публикует релиз с `sha256sums.txt`.
|
собирает пакеты и переводы в OpenWrt SDK и публикует релиз с `sha256sums.txt`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Builds luci-app-dawnline with the OpenWrt SDK.
|
# Builds luci-app-dawnline with the OpenWrt SDK.
|
||||||
# docker build -f build/Dockerfile --build-arg SDK_IMAGE=itdoginfo/openwrt-sdk-ipk:24.10.6 .
|
# docker build -f build/Dockerfile --build-arg SDK_IMAGE=itdoginfo/openwrt-sdk-ipk:24.10.6 .
|
||||||
# The web bundles (htdocs/.../app.js, portal assets) are built by npm first and
|
# The web bundles (htdocs/.../app.js, portal assets) are built by npm first
|
||||||
# committed; the SDK only packs files, so the package is the same on every arch.
|
# (not committed); the SDK only packs files, so the package is the same on every arch.
|
||||||
ARG SDK_IMAGE=itdoginfo/openwrt-sdk-ipk:24.10.6
|
ARG SDK_IMAGE=itdoginfo/openwrt-sdk-ipk:24.10.6
|
||||||
FROM ${SDK_IMAGE}
|
FROM ${SDK_IMAGE}
|
||||||
|
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 388 KiB After Width: | Height: | Size: 387 KiB |
|
Before Width: | Height: | Size: 86 KiB After Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 186 KiB After Width: | Height: | Size: 186 KiB |
@@ -6,7 +6,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-dawnline
|
PKG_NAME:=luci-app-dawnline
|
||||||
PKG_VERSION:=0.14.0
|
PKG_VERSION:=0.16.0
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
PKG_LICENSE:=MIT
|
PKG_LICENSE:=MIT
|
||||||
# po/<lang>/dawnline.po becomes luci-i18n-dawnline-<lang> (luci.mk), released
|
# po/<lang>/dawnline.po becomes luci-i18n-dawnline-<lang> (luci.mk), released
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
// Generated from dawnline/web — do not edit by hand.
|
|
||||||
'use strict';
|
|
||||||
'require baseclass';
|
|
||||||
'require dom';
|
|
||||||
'require poll';
|
|
||||||
'require rpc';
|
|
||||||
'require ui';
|
|
||||||
var va=Object.create;var ds=Object.defineProperty;var ba=Object.getOwnPropertyDescriptor;var xa=Object.getOwnPropertyNames;var wa=Object.getPrototypeOf,ya=Object.prototype.hasOwnProperty;var ka=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var _a=(t,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of xa(e))!ya.call(t,r)&&r!==o&&ds(t,r,{get:()=>e[r],enumerable:!(s=ba(e,r))||s.enumerable});return t};var Ca=(t,e,o)=>(o=t!=null?va(wa(t)):{},_a(e||!t||!t.__esModule?ds(o,"default",{value:t,enumerable:!0}):o,t));var _s=ka((ys,ks)=>{"use strict";var ws=(function(){var t=function(P,R){var w=236,k=17,y=P,O=o[R],b=null,f=0,T=null,C=[],A={},K=function(z,$){f=y*4+17,b=(function(E){for(var I=new Array(E),D=0;D<E;D+=1){I[D]=new Array(E);for(var W=0;W<E;W+=1)I[D][W]=null}return I})(f),Y(0,0),Y(f-7,0),Y(0,f-7),Z(),j(),me(z,$),y>=7&&te(z),T==null&&(T=ne(y,O,C)),ke(T,$)},Y=function(z,$){for(var E=-1;E<=7;E+=1)if(!(z+E<=-1||f<=z+E))for(var I=-1;I<=7;I+=1)$+I<=-1||f<=$+I||(0<=E&&E<=6&&(I==0||I==6)||0<=I&&I<=6&&(E==0||E==6)||2<=E&&E<=4&&2<=I&&I<=4?b[z+E][$+I]=!0:b[z+E][$+I]=!1)},Q=function(){for(var z=0,$=0,E=0;E<8;E+=1){K(!0,E);var I=r.getLostPoint(A);(E==0||z>I)&&(z=I,$=E)}return $},j=function(){for(var z=8;z<f-8;z+=1)b[z][6]==null&&(b[z][6]=z%2==0);for(var $=8;$<f-8;$+=1)b[6][$]==null&&(b[6][$]=$%2==0)},Z=function(){for(var z=r.getPatternPosition(y),$=0;$<z.length;$+=1)for(var E=0;E<z.length;E+=1){var I=z[$],D=z[E];if(b[I][D]==null)for(var W=-2;W<=2;W+=1)for(var ee=-2;ee<=2;ee+=1)W==-2||W==2||ee==-2||ee==2||W==0&&ee==0?b[I+W][D+ee]=!0:b[I+W][D+ee]=!1}},te=function(z){for(var $=r.getBCHTypeNumber(y),E=0;E<18;E+=1){var I=!z&&($>>E&1)==1;b[Math.floor(E/3)][E%3+f-8-3]=I}for(var E=0;E<18;E+=1){var I=!z&&($>>E&1)==1;b[E%3+f-8-3][Math.floor(E/3)]=I}},me=function(z,$){for(var E=O<<3|$,I=r.getBCHTypeInfo(E),D=0;D<15;D+=1){var W=!z&&(I>>D&1)==1;D<6?b[D][8]=W:D<8?b[D+1][8]=W:b[f-15+D][8]=W}for(var D=0;D<15;D+=1){var W=!z&&(I>>D&1)==1;D<8?b[8][f-D-1]=W:D<9?b[8][15-D-1+1]=W:b[8][15-D-1]=W}b[f-8][8]=!z},ke=function(z,$){for(var E=-1,I=f-1,D=7,W=0,ee=r.getMaskFunction($),X=f-1;X>0;X-=2)for(X==6&&(X-=1);;){for(var ve=0;ve<2;ve+=1)if(b[I][X-ve]==null){var Le=!1;W<z.length&&(Le=(z[W]>>>D&1)==1);var re=ee(I,X-ve);re&&(Le=!Le),b[I][X-ve]=Le,D-=1,D==-1&&(W+=1,D=7)}if(I+=E,I<0||f<=I){I-=E,E=-E;break}}},U=function(z,$){for(var E=0,I=0,D=0,W=new Array($.length),ee=new Array($.length),X=0;X<$.length;X+=1){var ve=$[X].dataCount,Le=$[X].totalCount-ve;I=Math.max(I,ve),D=Math.max(D,Le),W[X]=new Array(ve);for(var re=0;re<W[X].length;re+=1)W[X][re]=255&z.getBuffer()[re+E];E+=ve;var ze=r.getErrorCorrectPolynomial(Le),Re=a(W[X],ze.getLength()-1),is=Re.mod(ze);ee[X]=new Array(ze.getLength()-1);for(var re=0;re<ee[X].length;re+=1){var as=re+is.getLength()-ee[X].length;ee[X][re]=as>=0?is.getAt(as):0}}for(var ls=0,re=0;re<$.length;re+=1)ls+=$[re].totalCount;for(var ao=new Array(ls),hn=0,re=0;re<I;re+=1)for(var X=0;X<$.length;X+=1)re<W[X].length&&(ao[hn]=W[X][re],hn+=1);for(var re=0;re<D;re+=1)for(var X=0;X<$.length;X+=1)re<ee[X].length&&(ao[hn]=ee[X][re],hn+=1);return ao},ne=function(z,$,E){for(var I=l.getRSBlocks(z,$),D=d(),W=0;W<E.length;W+=1){var ee=E[W];D.put(ee.getMode(),4),D.put(ee.getLength(),r.getLengthInBits(ee.getMode(),z)),ee.write(D)}for(var X=0,W=0;W<I.length;W+=1)X+=I[W].dataCount;if(D.getLengthInBits()>X*8)throw"code length overflow. ("+D.getLengthInBits()+">"+X*8+")";for(D.getLengthInBits()+4<=X*8&&D.put(0,4);D.getLengthInBits()%8!=0;)D.putBit(!1);for(;!(D.getLengthInBits()>=X*8||(D.put(w,8),D.getLengthInBits()>=X*8));)D.put(k,8);return U(D,I)};A.addData=function(z,$){$=$||"Byte";var E=null;switch($){case"Numeric":E=c(z);break;case"Alphanumeric":E=p(z);break;case"Byte":E=u(z);break;case"Kanji":E=g(z);break;default:throw"mode:"+$}C.push(E),T=null},A.isDark=function(z,$){if(z<0||f<=z||$<0||f<=$)throw z+","+$;return b[z][$]},A.getModuleCount=function(){return f},A.make=function(){if(y<1){for(var z=1;z<40;z++){for(var $=l.getRSBlocks(z,O),E=d(),I=0;I<C.length;I++){var D=C[I];E.put(D.getMode(),4),E.put(D.getLength(),r.getLengthInBits(D.getMode(),z)),D.write(E)}for(var W=0,I=0;I<$.length;I++)W+=$[I].dataCount;if(E.getLengthInBits()<=W*8)break}y=z}K(!1,Q())},A.createTableTag=function(z,$){z=z||2,$=typeof $>"u"?z*4:$;var E="";E+='<table style="',E+=" border-width: 0px; border-style: none;",E+=" border-collapse: collapse;",E+=" padding: 0px; margin: "+$+"px;",E+='">',E+="<tbody>";for(var I=0;I<A.getModuleCount();I+=1){E+="<tr>";for(var D=0;D<A.getModuleCount();D+=1)E+='<td style="',E+=" border-width: 0px; border-style: none;",E+=" border-collapse: collapse;",E+=" padding: 0px; margin: 0px;",E+=" width: "+z+"px;",E+=" height: "+z+"px;",E+=" background-color: ",E+=A.isDark(I,D)?"#000000":"#ffffff",E+=";",E+='"/>';E+="</tr>"}return E+="</tbody>",E+="</table>",E},A.createSvgTag=function(z,$,E,I){var D={};typeof arguments[0]=="object"&&(D=arguments[0],z=D.cellSize,$=D.margin,E=D.alt,I=D.title),z=z||2,$=typeof $>"u"?z*4:$,E=typeof E==Line truncated
|
|
||||||
`}return E%2&&z>0?Re.substring(0,Re.length-E-1)+Array(E+1).join("▀"):Re.substring(0,Re.length-1)};return A.createASCII=function(z,$){if(z=z||1,z<2)return fe($);z-=1,$=typeof $>"u"?z*2:$;var E=A.getModuleCount()*z+$*2,I=$,D=E-$,W,ee,X,ve,Le=Array(z+1).join("██"),re=Array(z+1).join(" "),ze="",Re="";for(W=0;W<E;W+=1){for(X=Math.floor((W-I)/z),Re="",ee=0;ee<E;ee+=1)ve=1,I<=ee&&ee<D&&I<=W&&W<D&&A.isDark(X,Math.floor((ee-I)/z))&&(ve=0),Re+=ve?Le:re;for(X=0;X<z;X+=1)ze+=Re+`
|
|
||||||
`}return ze.substring(0,ze.length-1)},A.renderTo2dContext=function(z,$){$=$||2;for(var E=A.getModuleCount(),I=0;I<E;I++)for(var D=0;D<E;D++)z.fillStyle=A.isDark(I,D)?"black":"white",z.fillRect(I*$,D*$,$,$)},A};t.stringToBytesFuncs={default:function(P){for(var R=[],w=0;w<P.length;w+=1){var k=P.charCodeAt(w);R.push(k&255)}return R}},t.stringToBytes=t.stringToBytesFuncs.default,t.createStringToBytes=function(P,R){var w=(function(){for(var y=h(P),O=function(){var j=y.read();if(j==-1)throw"eof";return j},b=0,f={};;){var T=y.read();if(T==-1)break;var C=O(),A=O(),K=O(),Y=String.fromCharCode(T<<8|C),Q=A<<8|K;f[Y]=Q,b+=1}if(b!=R)throw b+" != "+R;return f})(),k=63;return function(y){for(var O=[],b=0;b<y.length;b+=1){var f=y.charCodeAt(b);if(f<128)O.push(f);else{var T=w[y.charAt(b)];typeof T=="number"?(T&255)==T?O.push(T):(O.push(T>>>8),O.push(T&255)):O.push(k)}}return O}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},o={L:1,M:0,Q:3,H:2},s={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r=(function(){var P=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],R=1335,w=7973,k=21522,y={},O=function(b){for(var f=0;b!=0;)f+=1,b>>>=1;return f};return y.getBCHTypeInfo=function(b){for(var f=b<<10;O(f)-O(R)>=0;)f^=R<<O(f)-O(R);return(b<<10|f)^k},y.getBCHTypeNumber=function(b){for(var f=b<<12;O(f)-O(w)>=0;)f^=w<<O(f)-O(w);return b<<12|f},y.getPatternPosition=function(b){return P[b-1]},y.getMaskFunction=function(b){switch(b){case s.PATTERN000:return function(f,T){return(f+T)%2==0};case s.PATTERN001:return function(f,T){return f%2==0};case s.PATTERN010:return function(f,T){return T%3==0};case s.PATTERN011:return function(f,T){return(f+T)%3==0};case s.PATTERN100:return function(f,T){return(Math.floor(f/2)+Math.floor(T/3))%2==0};case s.PATTERN101:return function(f,T){return f*T%2+f*T%3==0};case s.PATTERN110:return function(f,T){return(f*T%2+f*T%3)%2==0};case s.PATTERN111:return function(f,T){return(f*T%3+(f+T)%2)%2==0};default:throw"bad maskPattern:"+b}},y.getErrorCorrectPolynomial=function(b){for(var f=a([1],0),T=0;T<b;T+=1)f=f.multiply(a([1,i.gexp(T)],0));return f},y.getLengthInBits=function(b,f){if(1<=f&&f<10)switch(b){case e.MODE_NUMBER:return 10;case e.MODE_ALPHA_NUM:return 9;case e.MODE_8BIT_BYTE:return 8;case e.MODE_KANJI:return 8;default:throw"mode:"+b}else if(f<27)switch(b){case e.MODE_NUMBER:return 12;case e.MODE_ALPHA_NUM:return 11;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 10;default:throw"mode:"+b}else if(f<41)switch(b){case e.MODE_NUMBER:return 14;case e.MODE_ALPHA_NUM:return 13;case e.MODE_8BIT_BYTE:return 16;case e.MODE_KANJI:return 12;default:throw"mode:"+b}else throw"type:"+f},y.getLostPoint=function(b){for(var f=b.getModuleCount(),T=0,C=0;C<f;C+=1)for(var A=0;A<f;A+=1){for(var K=0,Y=b.isDark(C,A),Q=-1;Q<=1;Q+=1)if(!(C+Q<0||f<=C+Q))for(var j=-1;j<=1;j+=1)A+j<0||f<=A+j||Q==0&&j==0||Y==b.isDark(C+Q,A+j)&&(K+=1);K>5&&(T+=3+K-5)}for(var C=0;C<f-1;C+=1)for(var A=0;A<f-1;A+=1){var Z=0;b.isDark(C,A)&&(Z+=1),b.isDark(C+1,A)&&(Z+=1),b.isDark(C,A+1)&&(Z+=1),b.isDark(C+1,A+1)&&(Z+=1),(Z==0||Z==4)&&(T+=3)}for(var C=0;C<f;C+=1)for(var A=0;A<f-6;A+=1)b.isDark(C,A)&&!b.isDark(C,A+1)&&b.isDark(C,A+2)&&b.isDark(C,A+3)&&b.isDark(C,A+4)&&!b.isDark(C,A+5)&&b.isDark(C,A+6)&&(T+=40);for(var A=0;A<f;A+=1)for(var C=0;C<f-6;C+=1)b.isDark(C,A)&&!b.isDark(C+1,A)&&b.isDark(C+2,A)&&b.isDark(C+3,A)&&b.isDark(C+4,A)&&!b.isDark(C+5,A)&&b.isDark(C+6,A)&&(T+=40);for(var te=0,A=0;A<f;A+=1)for(var C=0;C<f;C+=1)b.isDark(C,A)&&(te+=1);var me=Math.abs(100*te/f/f-50)/5;return T+=me*10,T},y})(),i=(function(){for(var P=new Array(256),R=new Array(256),w=0;w<8;w+=1)P[w]=1<<w;for(var w=8;w<256;w+=1)P[w]=P[w-4]^P[w-5]^P[w-6]^P[w-8];for(var w=0;w<255;w+=1)R[P[w]]=w;var k={};return k.glog=function(y){if(y<1)throw"glog("+y+")";return R[y]},k.gexp=function(y){for(;y<0;)y+=255;for(;y>=256;)y-=255;return P[y]},k})();function a(P,R){if(typeof P.length>"u")throw P.length+"/"+R;var w=(function(){for(var y=0;y<P.length&&P[y]==0;)y+=1;for(var O=new Array(P.length-y+R),b=0;b<P.length-y;b+=1)O[b]=P[b+y];return O})(),k={};return k.getAt=function(y){return w[y]},k.getLength=function(){return w.length},k.multiply=function(y){for(var O=new Array(k.getLength()+y.getLength()-1),b=0;b<k.getLength();b+=1)for(var f=0;f<y.getLength();f+=1)O[b+f]^=i.gexp(i.glog(k.getAt(b))+i.glog(y.getAt(f)));return a(O,0)},k.mod=function(y){if(k.getLengt
Line truncated
|
|
||||||
`)}function ol(t){let e=new Map(t.people.map(s=>[s.id,s.name])),o=new Map(t.people.flatMap(s=>s.devices.map(r=>[r.id,r.name])));return{people:e,devices:o}}function Xe(t,e,o,s="",r=[]){let i=ol(t),a=[...e.map(u=>({ts:u.ts,category:Zt(u.type),type:u.type,person:u.person?i.people.get(u.person)??u.pname??u.person:"",device:u.device?i.devices.get(u.device)??u.dname??u.device:"",detail:u.detail??"",where:u.where??"",by:Ve(u)??""})),...r.map(u=>({ts:u.ts,category:"system",type:`${u.src}.${u.level}`,person:"",device:"",detail:`${u.who?`${u.who} `:""}${u.msg}${u.detail?`
|
|
||||||
${u.detail}`:""}`,where:Qt(u.src),by:""}))].sort((u,g)=>u.ts-g.ts).map(({ts:u,...g})=>({time:new Date(u*1e3).toISOString(),...g})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${s?`-${s}`:""}-${l}.${o}`;if(o==="json"){Ae(d,JSON.stringify(a,null,2),"application/json");return}let c=["time","category","type","person","device","detail","where","by"],p={time:_("Time"),category:_("Category"),type:_("Type"),person:_("Person"),device:_("Device"),detail:_("Detail"),where:_("Where"),by:_("By")};Ae(d,nr(c,a,p),"text/csv")}var sl=["","7","30","90"],rl=t=>t?G(Number(t),"Older than %s day","Older than %s days"):_("Everything"),or=t=>t?G(t,"%s event removed","%s events removed"):_("Nothing matched");function dt(t,e,o,s,r,i=!1){let a=n("select",{class:"cbi-input-select"},[n("option",{value:""},_("All categories")),...Rt.map(d=>n("option",{value:d,selected:d===r?"selected":null},Ke(d))),i?n("option",{value:"system",selected:r==="system"?"selected":null},_("System")):""]),l=n("select",{class:"cbi-input-select"},sl.map(d=>n("option",{value:d},rl(d))));ae(t,[n("p",{class:"dl-muted"},`${e} ${_("This cannot be undone; export first if you want a copy.")}`),n("label",{class:"dl-fld"},[n("span",{class:"dl-fld-label"},_("Category")),a]),n("label",{class:"dl-fld"},[n("span",{class:"dl-fld-label"},_("Which events")),l])],[de()," ",H(_("Clear"),async()=>{let d=0;if(a.value!=="system")try{d+=(await N.logsClear({...o,category:a.value,older_days:l.value})).removed}catch(c){F(_e(c),"error",1e4);return}if(i&&(a.value==="system"||a.value===""))try{d+=(await N.serviceLogClear(l.value)).removed}catch(c){le();let p=m(_("The service log was not cleared: %s"),_e(c));F(a.value==="system"?p:`${m(_("Activity: %s."),or(d).toLowerCase())} ${p}`,"error",1e4),s();return}le(),F(or(d),"success",3e3),s()},"negative")])}function It(t,e,o,s){let r=t==="device"?m(_("Clears %s's daily and monthly traffic history. Their person's totals and data limit are not changed."),o):t==="person"?m(_("Clears %s's traffic history and that of their devices. Their data limit starts again from zero."),o):_("Clears traffic history for everyone. Data limits start again from zero.");ae(t==="all"?_("Reset all traffic history?"):m(_("Reset traffic history for %s?"),o),[n("p",{class:"dl-muted"},r)],[de()," ",H(_("Reset"),async()=>{await q(()=>N.usageClear(t,e),_("Traffic history reset"))&&(le(),s())},"negative")])}var il={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"",s4:"",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},al={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function ll(t){let e={};for(let[o,s]of Object.entries(al))t[o]!=null&&t[o]!==""&&(e[s]=String(t[o]));return e}function dl(t,e){let o=t.amnezia,s=o.obfuscation??{},r=d=>s[d]!=null&&s[d]!==""?String(s[d]):il[d],i=o.host.replace(/^\[(.*)\]$/,"$1"),a={H1:r("h1"),H2:r("h2"),H3:r("h3"),H4:r("h4"),I1:r("i1"),I2:r("i2"),I3:r("i3"),I4:r("i4"),I5:r("i5"),Jc:r("jc"),Jmin:r("jmin"),Jmax:r("jmax"),S1:r("s1"),S2:r("s2"),S3:r("s3"),S4:r("s4"),...ll(s),allowed_ips:o.allowed_ips,client_ip:o.client_ip,client_priv_key:o.client_priv_key,client_pub_key:o.client_pub_key,config:t.conf.replace(/\r?\n/g,`\r
|
|
||||||
`),hostName:i,mtu:o.mtu,persistent_keep_alive:o.persistent_keep_alive,port:Number(o.port),psk_key:o.psk_key,server_pub_key:o.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(a),port:String(o.port),protocol_version:s.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:i};return o.dns[0]&&(l.dns1=o.dns[0],l.dns2=o.dns[1]||o.dns[0]),l}function cl(t){let e="";for(let o=0;o<t.length;o+=32768)e+=String.fromCharCode(...t.subarray(o,o+32768));return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function pl(t){let e=globalThis;if(typeof e.CompressionStream>"u")return null;try{let o=new e.Blob([t]).stream().pipeThrough(new e.CompressionStream("deflate")),s=new Uint8Array(await new e.Response(o).arrayBuffer()),r=new Uint8Array(4+s.length);return new DataView(r.buffer).setUint32(0,t.length,!1),r.set(s,4),r}catch{return null}}async function Po(t,e,o=!0){let s=new TextEncoder().encode(JSON.stringify(dl(t,e))),r=o?await pl(s):null;return`vpn://${cl(r??s)}`}function rr(){return[{id:"off",title:_("Off"),ic:"zap",stealth:0,speed:4,text:_("Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block."),apps:_("Any WireGuard app"),short:_("Any WireGuard app")},{id:"balanced",title:_("Balanced"),ic:"shield",stealth:3,speed:4,needs:"v2",text:_("AmneziaWG 2.0: junk packets, padded packets and a first packet that looks like DNS. For networks that learned to spot 1.0-style junk."),apps:_("AmneziaVPN 4.8.12 or newer, AmneziaWG 2.0+ apps"),short:_("AmneziaWG 2.0+ apps")},{id:"max",title:_("Maximum"),ic:"lock",stealth:4,speed:3,needs:"v3",text:_("AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS."),apps:_("Apps with AmneziaWG 3.1 (current AmneziaVPN)"),short:_("AmneziaWG 3.1 apps")}]}var Xt=t=>rr().find(e=>e.id===t),$n=t=>t.v3?"max":t.v2?"balanced":"off",en=t=>t==="standard"?_("Standard (old)"):t==="strong"?_("Strong (old)"):null;function ul(t,e){return e?t==="v2"?_("Needs AmneziaWG 2.0 or newer on the router (kmod-amneziawg and amneziawg-tools from July 2025 on)."):_("Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."):t==="v2"?_("Needs AmneziaWG on the router."):_("Needs AmneziaWG 3.1 on the router: install it first.")}function sr(t,e){return n("span",{class:"dl-dots",title:m(_("%s: %s of 4"),e,t)},[n("span",{class:"dl-dots-label"},e),n("span",{class:"dl-dots-row"},[0,1,2,3].map(o=>n("i",{class:o<t?"on":""})))])}function Dn(t,e,o,s,r=!0){let i=n("div",{class:"dl-methods",role:"radiogroup","aria-label":_("Disguise method")}),a=()=>dom.content(i,rr().map(l=>{let d=!l.needs||t[l.needs],c=l.id===e;return n("button",{type:"button",role:"radio","aria-checked":c?"true":"false","aria-disabled":d?null:"true",class:`dl-method${c?" on":""}${d?"":" off"}`,click:()=>{!d||c||(e=l.id,a(),o(l.id))}},[n("div",{class:"dl-method-head"},[n("span",{class:"dl-method-ic"},v(l.ic)),n("b",{},l.title),l.id===s?n("span",{class:"dl-pill ok"},_("Current")):""]),n("p",{},l.text),n("div",{class:"dl-method-meters"},[sr(l.stealth,_("Stealth")),sr(l.speed,_("Speed"))]),n("div",{class:"dl-method-foot"},d?[v(l.id==="off"?"wireguard":"amneziawg"),n("span",{},l.apps)]:[v("alert"),n("span",{},ul(l.needs,r))])])}));return a(),i}function ir(t,e){return n("div",{class:"dl-corehead"},[n("h3",{},t),e?n("span",{class:"dl-sub"},e):""])}var ar=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function ml(t,e){let o=p=>p==="header_protection_key"?e:t[p]!=null&&t[p]!=="",s=ar.filter(([p])=>o(p));if(!s.length)return null;let r=(p,u)=>n("span",{class:"dl-pv"},[n("i",{},u),n("b",{},p==="header_protection_key"?_("set","key"):t[p])]),i=(p,u,g,M)=>{let x=ar.filter(([h])=>M.includes(h)&&o(h));return x.length?n("div",{class:"dl-pgroup"},[n("div",{class:"dl-pgroup-head"},[v(u),n("b",{},p)]),n("p",{},g),n("div",{class:"dl-pvals"},x.map(([h,S])=>r(h,S)))]):""},a=Number(t.jc||0),l=(t.i1??"").includes("0x8580")?_("A first packet shaped like a DNS answer."):_("Extra packets sent before the handshake."),d=s.filter(([p])=>p!=="header_protection_key").map(([p,u])=>`${u} = ${t[p]}`).join(`
|
|
||||||
`),c=n("div",{class:"dl-pgrid"},[i(_("Junk packets"),"zap",a?m(N_(a,"%s random packet of %s–%s bytes before each handshake.","%s random packets of %s–%s bytes before each handshake."),V(a),t.jmin,t.jmax):_("No junk packets."),["jc","jmin","jmax"]),i(_("Padding"),"archive",_("Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard."),["s1","s2","s3","s4"]),i(_("Packet types"),"key",_("The values that replace WireGuard’s recognisable message types."),["h1","h2","h3","h4"]),i(_("Signatures"),"globe",l,["i1","i2","i3","i4","i5"]),i(_("Protection"),"lock",_("AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets."),["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),i(_("Timing"),"clock",_("Handshake and key timers vary within these ranges instead of WireGuard’s fixed values."),["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return n("details",{class:"dl-params"},[n("summary",{},[v("chevron"),n("span",{},_("Current parameters")),n("span",{class:"dl-pcount"},String(s.length)),n("span",{class:"dl-spacer"}),n("button",{type:"button",class:"dl-linkbtn",click:p=>{p.preventDefault(),xe(d,e?_("Parameters copied. The header protection key is in each device’s file."):_("Parameters copied"))}},_("Copy as config"))]),c])}function lr(t,e){if(/^\s*\[.+\]\s*$/.test(t))return n("span",{class:"dl-conf-sec"},t);let o=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(t);if(!o)return document.createTextNode(t);let s=/^(\s*)(PrivateKey|PresharedKey)\b/.test(t);return n("span",{},[n("span",{class:"dl-conf-k"},o[1])," ",s&&!e?n("span",{class:"dl-conf-mask"},"••••••••••••••••"):o[2]])}function hl(t){let e=!1,o=n("pre",{class:"dl-conf"}),s=()=>dom.content(o,t.conf.split(`
|
|
||||||
`).flatMap((a,l)=>l?[`
|
|
||||||
`,lr(a,e)]:[lr(a,e)])),r=n("button",{type:"button",class:"dl-chipbtn",click:a=>{a.preventDefault(),e=!e,dom.content(r,[v(e?"x":"key"),e?_("Hide key"):_("Show key")]),s()}},[v("key"),_("Show key")]);s();let i=new Blob([t.conf]).size;return n("div",{class:"dl-stack gap8"},[n("div",{class:"dl-filecard"},[n("span",{class:"dl-filecard-ic"},".conf"),n("span",{class:"dl-stack"},[n("span",{class:"dl-mono dl-ellipsis"},t.filename),n("span",{class:"dl-sub"},`AmneziaWG · ${G(i,"%s byte","%s bytes")}`)]),H([v("download")," ",_("Download")],()=>Ae(t.filename,t.conf,"application/octet-stream"),"positive")]),n("details",{class:"dl-params"},[n("summary",{},[v("chevron"),n("span",{},_("Configuration")),n("span",{class:"dl-spacer"}),r,n("button",{type:"button",class:"dl-chipbtn",click:a=>{a.preventDefault(),xe(t.conf,_("Configuration copied"))}},[v("copy"),_("Copy")])]),o])])}function $o(t){let e=t.amnezia.obfuscation??{},o={h1:"1",h2:"2",h3:"3",h4:"4"};return Object.entries(e).every(([s,r])=>r==null||r===""||r===(o[s]??"0"))}async function fl(t,e="file"){if(!t.has_private_key)return n("div",{class:"dl-hint"},_("This device generated its own keys in the browser, so its full configuration only exists on that device."));let o=await Po(t,t.server),s={qr:()=>n("div",{class:"dl-qr-pane"},[_n(t.conf),n("span",{class:"dl-sub"},$o(t)?_("Scan with AmneziaVPN or any WireGuard app on the device."):_("Scan with AmneziaVPN or AmneziaWG on the device."))]),key:()=>n("div",{class:"dl-stack gap8"},[n("div",{class:"dl-linkbox"},[n("span",{class:"dl-mono"},o),H(_("Copy"),()=>xe(o,_("Key copied")))]),n("span",{class:"dl-sub"},m(_("AmneziaVPN → %s. Keep it private."),["+",_("Insert","AmneziaVPN app"),_("Continue","AmneziaVPN app")].join(" → ")))]),file:()=>hl(t)},r=n("div",{class:"dl-connect-body"}),i=n("div",{class:"dl-seg"}),a=l=>{i.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(r,s[l]())};for(let[l,d]of[["file",_("File")],["key",_("Key")],["qr",_("QR code")]])i.appendChild(n("button",{type:"button","data-id":l,click:()=>a(l)},d));return a(e),n("div",{class:"dl-stack gap12"},[i,r])}async function gl(t,e,o,s){let r=Xt(o),a=t.st.people.filter(d=>d.server===e.id).reduce((d,c)=>d+c.devices.length,0);await pe(s?_("Generate new disguise values?"):m(_("Switch to %s?"),r.title),[G(a,"%s AmneziaWG device stops connecting until it imports its configuration again (from their personal link or from you).","%s AmneziaWG devices stop connecting until they import their configuration again (from their personal link or from you)."),o==="max"?_("They need an app with AmneziaWG 3.1."):o==="balanced"?_("They need an app with AmneziaWG 2.0 or newer."):"",t.st.servers.length===1&&a?_("To keep the old disguise for some people, add a second server and move them there."):""].filter(Boolean).join(" "),s?_("Generate and apply"):_("Switch and apply"),!0)&&await q(()=>N.serverObfuscation(e.id,o),s?_("New values applied"):m(_("%s applied"),r.title))&&(F(_("Devices are marked “Update config” until they import again."),"info",6e3),await t.refresh())}function vl(t,e){let o=t.st,s=ue(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),r=ue(e.mtu?String(e.mtu):"",{placeholder:_("Auto"),inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=ue(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),a=Xt(e.preset)?e.preset:void 0,l=a??$n(o.awg),d=H("",()=>gl(t,e,l,l===a),"neutral"),c=()=>dom.content(d,l===a?[v("reset")," ",_("Generate new values")]:[m(_("Switch to %s"),Xt(l).title)]);c();let p=o.awg_state?.tools!==!1,u=[],g=Ce(_("UDP port"),s,()=>Jt(Number(s.value),u,[_("Opened on the WAN firewall automatically."),Number(s.value)===4500?_("4500 is IPsec’s port: most networks let it through."):""].filter(Boolean).join(" ")));N.serverPorts(e.id).then(h=>{u=h.udp_taken??[],g.refresh()}).catch(()=>{});let M=Ce("MTU",r,()=>$s(r.value,e.mtus)),x=Ce(_("Keep-alive"),i,()=>Ds(i.value));return Vt("",[ir("AmneziaWG",e.ifname),ye("globe",_("Listening"),_("Where devices reach this core from the internet"),[g]),ye("file",_("In every device configuration"),_("Changing these marks devices “Update config” until they import again"),[M,x]),ye("shield",_("Disguise"),_("So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard"),[en(e.preset)?yt("warn",oe(_("%s is AmneziaWG 1.0 junk only, which networks learned to spot; it is not offered any more. Switch to %s or %s: devices import their configuration again."),n("b",{},en(e.preset)),n("b",{},_("Balanced")),n("b",{},_("Maximum")))):"",Dn(o.awg,l,h=>{l=h,c()},a,p),p&&!o.awg.v3?yt("info",oe(_("This router runs an older AmneziaWG. %s becomes available with kmod-amneziawg and amneziawg-tools 3.1."),n("b",{},_("Maximum")))):"",ml(e.obf??{},e.hpk)??"",n("div",{class:"dl-row-end"},[n("span",{class:"dl-sub"},_("Applies at once: every AmneziaWG device imports its configuration again.")),d])]),n
Line truncated
|
|
||||||
`),_("Log copied")))]),p,u]),[g],"wide"),x([n("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},r?_("Checking…"):_("Working…"))]);let S=o??null,B=o?.id,P,R=0,w=T=>{B!==T.id&&(B=T.id,e.onJob?.(T))};if(o)e.onJob?.(o);else try{let T=await N.updatesStatus().catch(()=>null);P=T?.job?.id,R=T?.now??0;let C=await N.updatesRun(t);C.job&&C.job.state==="running"&&C.job.id!==P&&(S=C.job,w(C.job))}catch(T){return M=[_e(T)],p.textContent=M[0],dom.content(u,n("div",{class:"dl-comp-status warn"},[v("alert"),n("span",{},_e(T))])),x([h(!0)]),F(_e(T),"error"),null}let k=null,y=0;for(;;){if(await Vo(1e3),k=await N.updatesStatus().catch(()=>null),!k){if(++y>60)break;continue}y=0;let T=k.job;if(!T||!oi(T,B,P,R)){if(Date.now()-i>15e3)break;continue}if(w(T),S=T,T.log.length){M=T.log;let C=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=M.join(`
|
|
||||||
`),C&&(p.scrollTop=p.scrollHeight)}if(l.textContent=ti(T,e.version??""),!l.isConnected&&l.textContent&&a.after(l),c.textContent=ei((T.finished??k.now)-T.started),T.state==="running"){d.hidden=!T.phase,d.textContent=T.phase;continue}break}if(p.scrollTop=p.scrollHeight,d.hidden=!1,!S||S.state==="running")return d.className="dl-pill warn",d.textContent=_("No answer"),dom.content(u,n("div",{class:"dl-comp-status warn"},[v("alert"),n("span",{},_("The router stopped answering. The job may still finish: reopen Components in a minute."))])),x([h()]),e.onDone?.(k),S;if(S.state==="failed")return d.className="dl-pill bad",d.textContent=_("Failed"),dom.content(u,n("div",{class:"dl-comp-status bad"},[v("x"),n("span",{},[n("b",{},(S.error??_("Operation failed")).replace(/\.$/,"")),r?"":`. ${_("Nothing else was changed.")}`])])),x([H(_("Copy log"),()=>xe(M.join(`
|
|
||||||
`),_("Log copied"))),h(!0)]),F(`${Un(s)??_("Update","noun")}: ${S.error??_("failed")}`,"error"),e.onDone?.(k),S;if(d.className="dl-pill ok",d.textContent=_("Finished"),r&&k){let T=ni(k,s);if(dom.content(u,n("div",{class:`dl-comp-status ${T.tone}`},[v(T.tone==="ok"?"check":T.tone==="warn"?"alert":"download"),n("span",{},T.text)])),F(T.text,T.tone==="warn"?"warning":"success"),e.onDone?.(k),T.update&&e.onUpdate){let C=k;x([h(),H(m(_("Update to %s"),T.update),()=>e.onUpdate(C),"positive")])}else x([h()]),T.tone==="ok"&&setTimeout(()=>u.isConnected&&le(),1200);return S}let O=/^app:(lang:|nolang$)/.exec(S.component??"");if(O){let T=()=>{ui.menu?.flushCache(),location.reload()};return dom.content(u,n("div",{class:"dl-comp-status ok"},[v("check"),n("span",{},[n("b",{},O[1]==="nolang"?_("The translation is removed."):_("The translation is installed."))," ",_("Reloading the page…")])])),x([h(),H(_("Reload now"),T,"positive")]),await Vo(4e3),u.isConnected&&T(),S}if(s==="app"&&S.to){let T=S.to,C=n("span",{},_("Waiting for the router to restart its services…"));dom.content(u,n("div",{class:"dl-comp-status ok"},[v("check"),n("span",{},[n("b",{},m(_("Dawnline %s is installed."),T))," ",C])]));let A=()=>{ui.menu?.flushCache(),location.reload()};x([h(),H(_("Reload now"),A,"positive")]),F(m(_("Dawnline updated to %s"),T),"success",6e3);for(let K=1;K<=30;K++)if(C.textContent=m(_("Waiting for the router to restart its services (%s of 30)…"),K),await Vo(1500),(await N.updatesStatus().catch(()=>null))?.version===T)return C.textContent=_("Services are back. Reloading…"),setTimeout(A,800),S;return C.textContent=_("Services restarted. Reload the page to use the new version."),S}let b=[...S.result?.pkgs?.updated??[],...S.result?.pkgs?.installed??[]],f=s==="pkgs"?b.length?m(_("Updated %s"),b.join(", ")):_("Updated system packages"):s==="amneziawg"?S.to?m(_("AmneziaWG %s is installed"),S.to):_("AmneziaWG is installed"):_("Operation completed");return dom.content(u,n("div",{class:"dl-comp-status ok"},[v("check"),n("span",{},f)])),x([h()]),F(f,"success"),e.onDone?.(k),S}function Kl(t){return{https:[_("Install HTTPS for the portal?"),_("Installing HTTPS for the portal")],acme:[_("Install ACME certificates?"),_("Installing ACME certificates")],home:[_("Install the home-like link?"),_("Installing the home-like link")],awg:[_("Install AmneziaWG?"),_("Installing AmneziaWG")]}[t]}async function si(t,e,o,s){let[r,i]=Kl(e);return!await pe(r,o,_("Install"))||(await dn(t,{title:i}))?.state!=="done"?!1:(setTimeout(()=>s?.(),4e3),!0)}function Gn(t){return si("amneziawg:auto","awg",_("Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds."),t)}async function cn(t,e,o){return t==="awg"?Gn(o):e.length?si(`pkgs:${e.join(",")}`,t,m(_("%s from the OpenWrt feeds. Dawnline sets the rest up when they arrive."),e.join(", ")),o):!0}async function ri(t,e){if(t==="awg")return Gn(e);let o=await q(()=>N.updatesStatus());return o?cn(t,o.needs?.[t]??[],e):!1}var Vl=()=>[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn",_("VPN & tunnels")],["other",_("Other")]],Yl={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function Yo(t){let e=n("b",{},oe(_("add its interface %s to their source interfaces yourself"),n("span",{class:"dl-mono"},t)));return[...oe(_("Off: internet traffic goes straight to the WAN, the fastest way. DNS still goes through this router. Proxies and filters here handle the tunnel only if you %s."),e)," ",n("span",{class:"dl-warn"},_("If the router’s DNS hands out proxy addresses, those sites won’t open without it."))]}function Jo(){return wt(_("Slower: every packet crosses the router twice. On a dual-core router expect up to a third less speed, and lost packets at full load."))}function ii(t,e,o){let s=t.id,r=e,i=n("div",{class:"dl-stack gap16"},n("section",{class:"dl-setsec"},n("div",{class:"dl-setsec-body"},n("p",{class:"dl-muted"},_("Loading interfaces…"))))),a,l=!0,d="",c=!0,p=!0,u="all",g=!1,M=Zr(r,s,o),x=new Set,h="",S=()=>JSON.stringify([p,l,l?"":d,c,[...x].sort()]),B=()=>a.detected.lan||a.saved.lan||"",P=()=>(l?a.detected.wan||a.saved.wan:d)||"",R=()=>new Map(a.devices.map(j=>[j.name,j])),w=()=>{let j=R();return[...c&&B()?[B()]:[],...[...x].filter(te=>te!==B())].filter(te=>te!==P()).map(te=>j.get(te)??{name:te,nets:[],missing:!0})},k=(j,Z)=>{a=j,Z&&(l=j.config.auto_wan,d=j.config.wan_device||j.detected.wan||j.saved.wan||"",c=j.config.auto_lan,p=j.config.lan_like,u=j.config.mesh??(j.config.device_mesh?"all":"off"),x=new Set(j.config.lan_devices),h=S()),Y()},y=async j=>{let Z=await N.interfaces(s).catch(te=>(F(te.message,"error"),null));Z&&k(Z,j)};function O(j){let Z=c&&j.name===B(),te=!!j.own||!!j.master||j.name===P()||Z;return Z||x.has(j.name)||!te&&(j.nets.length>0||!!j.missing)}function b(j){let Z=c&&j.name===B(),te=j.name===P(),me=!Z&&x.has(j.name),U=!(!!j.own||!!j.maste
Line truncated
|
|
||||||
`).map(e=>zt(e)).join(`
|
|
||||||
`);function qn(t,e,o,s){let r=t.by==="admin",i=zt(t.msg),a=n("div",{class:`dl-row dl-slog-row ${r?"dl-ev-by-admin":`dl-ev-by-system ${nd[t.level]??""}`}${t.detail?" has-detail":""}`},[r?n("span",{class:"dl-ev-tile",title:_("Done by you in LuCI")},v("admin")):n("span",{class:"dl-ev-tile sys",title:sd(t.level)},v(od[t.src]??"zap")),n("span",{class:"dl-row-main"},r?[...rd(t),t.note?n("span",{class:"dl-muted"},` · ${Xs(t.note)}`):"",t.detail?n("span",{class:`dl-slog-more${e?" open":""}`},v("chevron")):"",t.detail&&e?n("pre",{class:"dl-slog-detail"},ai(t.detail)):""]:[t.src==="awg"&&t.who&&t.who!=="AmneziaWG"?n("span",{class:"dl-ev-kind"},`${_("Server")} `):"",n("b",{class:"dl-sys-src",title:Qt(t.src)},t.who?t.src==="awg"?t.who:zt(t.who):Qt(t.src)),/^[:,]/.test(i)?"":" ",n("span",{class:"dl-muted"},i),t.detail?n("span",{class:`dl-slog-more${e?" open":""}`},v("chevron")):"",t.detail&&e?n("pre",{class:"dl-slog-detail"},ai(t.detail)):""]),n("span",{class:"dl-faint dl-nowrap",title:new Date(t.ts*1e3).toLocaleString(ie())},s)]);return t.detail&&a.addEventListener("click",l=>{l.target.closest("pre")||o()}),a}function li(t){let e=new Date(t*1e3),o=new Date,s=new Date;if(s.setDate(o.getDate()-1),e.toDateString()===o.toDateString())return _("Today");if(e.toDateString()===s.toDateString())return _("Yesterday");let r=e.toLocaleDateString(ie(),{weekday:"long",day:"numeric",month:"long"});return r.charAt(0).toLocaleUpperCase(ie())+r.slice(1)}var Ut=t=>Pt(t).toLocaleDateString(ie(),{day:"numeric",month:"short"}),pn=200,Wt=40;function di(t,e){let o=Math.max(1,...t.map(a=>Math.max(a[1],a[2]))),s=a=>t.map((l,d)=>`${e[d]*pn},${Wt-2-l[a]/o*(Wt-6)}`),r=s(2),i=s(1);return{area:`M${r.join(" L")} L${e[e.length-1]*pn},${Wt} L${e[0]*pn},${Wt}Z`,down:`M${r.join(" L")}`,up:`M${i.join(" L")}`}}var Kn=(t,e,o,s)=>n("div",{class:"dl-speed-col"},[n("span",{class:"dl-sub"},[n("span",{class:o},e),` ${t}`]),s]),ci=([t,e])=>[n("span",{},oe(_("Today %s"),n("b",{},se(t+e)))),n("span",{},[n("span",{class:"dl-dn"},"↓"),` ${se(e)} `,n("span",{class:"dl-up"},"↑"),` ${se(t)}`])];function pi(t,e,o,s=!1){let r=t.slice(-15),i=r[r.length-1],a=i&&e-i[0]<180,l=a?i[2]:0,d=a?i[1]:0,c;if(r.length>1&&!s){let u=di(r,r.map((g,M)=>M/(r.length-1)));c=kt(`<svg viewBox="0 0 ${pn} ${Wt}" preserveAspectRatio="none" class="dl-speed-chart" aria-hidden="true"><path d="${u.area}" class="area"/><path d="${u.down}" class="line"/><path d="${u.up}" class="line up"/></svg>`),we(c,()=>{let g=r[r.length-1];return[n("div",{class:"dl-tip-title"},new Date(g[0]*1e3).toLocaleTimeString(ie(),{hour:"2-digit",minute:"2-digit"})),n("div",{},`↓ ${We(g[2])} · ↑ ${We(g[1])}`)]})}else c=n("div",{class:"dl-speed-wait"},[n("i"),s?"":n("span",{},_("Collecting… 1 point a minute"))]);let p=u=>s?n("span",{class:"dl-speed-val off"},"—"):n("span",{class:"dl-speed-val"},We(u));return n("div",{class:"dl-bento-tile"},[n("div",{class:"dl-bento-head"},[n("span",{class:"dl-metric-label"},_("Speed now")),s?"":n("span",{class:"dl-sub"},_("last 15 min"))]),n("div",{class:"dl-speed-cols"},[Kn(_("Download","speed"),"↓","dl-dn",p(l)),Kn(_("Upload","speed"),"↑","dl-up",p(d))]),c,n("div",{class:"dl-speed-today"},ci(o))])}var Vn=class{constructor(){this.span=n("span",{class:"dl-sub"},_("last 2 min"));this.down=n("span",{class:"dl-speed-val"});this.up=n("span",{class:"dl-speed-val"});this.chart=kt(`<svg viewBox="0 0 ${pn} ${Wt}" preserveAspectRatio="none" class="dl-speed-chart" aria-hidden="true"><path class="area"/><path class="line"/><path class="line up"/></svg>`);this.wait=n("div",{class:"dl-speed-wait"});this.shown=this.wait;this.today=n("div",{class:"dl-speed-today"});this.el=n("div",{class:"dl-bento-tile"},[n("div",{class:"dl-bento-head"},[n("span",{class:"dl-metric-label"},_("Speed now")),this.span]),n("div",{class:"dl-speed-cols"},[Kn(_("Download","speed"),"↓","dl-dn",this.down),Kn(_("Upload","speed"),"↑","dl-up",this.up)]),this.wait,this.today])}update(e,o,s){let r=s||!!e.error;this.span.style.display=s?"none":"";for(let[l,d]of[[this.down,e.tx],[this.up,e.rx]])l.className=`dl-speed-val${r?" off":""}`,l.textContent=r?"—":We(d);let i=!r&&e.pts.length>1;if(i){let l=di(e.pts,e.xs),[d,c,p]=this.chart.querySelectorAll("path");d.setAttribute("d",l.area),c.setAttribute("d",l.down),p.setAttribute("d",l.up)}else dom.content(this.wait,[n("i"),s||e.early&&!e.error?"":n("span",{},e.error?m(_("Couldn't read the live speed: %s"),e.error):_("Collecting… 1 point a second"))]);let a=i?this.chart:this.wait;a!==this.shown&&(this.shown.replaceWith(a),this.shown=a),dom.content(this.today,ci(o))}};function Yn(t,e){let o=t.slice(-30),s=o.map(d=>d.rx+d.tx),r=Math.max(1,...s),i=s.reduce((d,c)=>d+c,0),a=s.reduce((d,c,p)=>c>s[d]?p:d,0),l=n("div",{class:"dl-bento-bars"},o.map((d,c)=>{let p=s[c],u=n("i",{class:c===o.length-1?"hi":"",style:`height:${Math.max(4,p/r*100)}%`}),g=n("span",{},[u]);return we(g,()=>[n("div",{class:"dl-tip-title"},c===o.length-1?`${_("Today")} · ${Ut(d.day)}`:Ut(d.day)),n("div",{},se(pLine truncated
|
|
||||||
`)){let d=l.trimEnd();if(i){/^```/.test(d.trim())?(e.push(n("pre",{},i.join(`
|
|
||||||
`))),i=null):i.push(l);continue}if(/^```/.test(d.trim())){a(),i=[];continue}let c=/^(#{1,6})\s+(.*)$/.exec(d),p=/^\s*[-*+]\s+(.*)$/.exec(d)??/^\s*\d+[.)]\s+(.*)$/.exec(d);c?(a(),e.push(n("h5",{},o(c[2])))):p?(r.length&&a(),s||(s=n("ul",{}),e.push(s)),s.appendChild(n("li",{},o(p[1])))):d.trim()?(s&&(s=null),r.push(d.trim())):a()}return i&&e.push(n("pre",{},i.join(`
|
|
||||||
`))),a(),e}function Si(t){let e=[],o=!1;for(let s of t.replace(/\r/g,"").split(`
|
|
||||||
`)){let r=/^#{1,6}\s+(.*)$/.exec(s);if(r){if(o=/^install\b/i.test(r[1].trim()),/^what.s new$/i.test(r[1].trim()))continue}else/^\*\*Full Changelog\*\*/.test(s)&&(o=!1);o||e.push(s)}return e.join(`
|
|
||||||
`).replace(/\n{3,}/g,`
|
|
||||||
|
|
||||||
`).trim()}async function mn(t,e,o,s){let r=n("div",{class:"dl-notes"},n("p",{class:"dl-muted dl-loading"},_("Loading release notes…"))),i=n("div",{class:"dl-op-head"}),a="";ae(o,[i,r],[H([v("copy")," ",_("Copy")],()=>xe(a,_("Release notes copied")))," ",de(_("Close"))],"wide");try{let l=await N.updatesNotes(t,e,s??"");a=Si(l.body||"");let d=Ei(l.url);dom.content(i,[l.published?n("span",{class:"dl-pill"},Ie(l.published)):"",l.prerelease?n("span",{class:"dl-pill warn"},_("Pre-release")):"",n("span",{class:"dl-spacer"}),d?n("a",{href:d,target:"_blank",rel:"noopener",class:"dl-linkbtn"},[_("On GitHub")," ",v("open")]):""]),dom.content(r,a.trim()?Ti(a):n("p",{class:"dl-muted"},_("This release has no notes.")))}catch(l){dom.content(r,n("p",{class:"dl-muted"},_e(l)))}}function hd(t){let e={"6h":_("checks every 6 h"),"12h":_("checks every 12 h"),"1d":_("checks daily"),"7d":_("checks weekly")};return e[t]??e["1d"]}var ns=t=>t?Ie(t):"";function fd(t){let e=/^(.{20,}?)(?:;\s|:\s)/.exec(t)?.[1];return e||(t.length<=90?t:`${t.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function $i(t,e){let o=t.st,s=o.policy,r=o.kept?.app,i=e?.update&&e.tag?e.tag:o.version,a=g=>()=>mn("app",g,m(_("What’s new in Dawnline %s"),g.replace(/^v/,""))),l=e?.tag&&(e.update||e.status==="latest")?gd(t,e.tag,e.update?o.version:""):null,d=e?.tag??i,c=s.check&&o.auto?.check?o.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[s.interval]??24)*3600:0,p=(g,M)=>n("div",{class:"dl-stack gap4"},[n("span",{class:"dl-metric-label"},g),n("span",{class:"dl-comp-side-v"},M)]),u=[{label:_("What’s new"),ic:"file",run:a(i)},{label:_("Open on GitHub"),ic:"globe",run:()=>window.open(`https://github.com/${o.repo}`,"_blank","noopener")},null,{label:m(_("Reinstall %s"),o.version),ic:"reset",warn:!0,run:()=>t.op("app:reinstall",_("Reinstalling Dawnline"),o.version)},r?{label:m(_("Roll back to %s"),r.version),ic:"archive",warn:!0,run:async()=>{await pe(m(_("Roll back to Dawnline %s?"),r.version),m(_("The copy kept on the router replaces %s. A backup of the settings is made first."),o.version),_("Roll back"))&&t.op("app:rollback",_("Rolling back Dawnline"),o.version)}}:null];return n("section",{class:"dl-panel flush dl-comp-hero"},[n("div",{class:"dl-comp-hero-main"},[n("div",{class:"dl-comp-hero-head"},[n("span",{class:"dl-group-ic"},v("sunrise")),n("b",{class:"dl-comp-name"},"Dawnline"),t.state("app",e,e?.latest??""),n("span",{class:"dl-spacer"}),t.round(()=>t.op("check:app",_("Checking Dawnline"),o.version),u,!0)]),n("div",{class:"dl-comp-verrow"},[n("div",{class:"dl-stack"},[n("div",{class:"dl-comp-big"},[o.version,e?.update?n("small",{},`→ ${e.latest}`):e?.status==="dev"&&e.latest?n("small",{class:"dl-faint"},m(_("release %s"),e.latest)):""]),n("span",{class:"dl-faint dl-comp-meta"},e?.error?"":e?.update?e.published?m(_("released %s"),ns(e.published)):"":e?.status==="dev"?_("ahead of the latest release"):e?[_("latest release"),e.published?m(_("released %s"),ns(e.published)):""].filter(Boolean).join(" · "):_("not checked yet"))])]),l?.items.length?n("div",{class:"dl-stack gap4"},[n("ul",{class:"dl-comp-bullets"},l.items.map(g=>n("li",{},g))),l.total>l.items.length?n("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:a(d)},G(l.total-l.items.length,"+%s more in What’s new","+%s more in What’s new")):""]):"",e?.error?n("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},e.error):"",e?.update?n("div",{class:"dl-comp-btns"},[H(_("Update now"),()=>t.op("app",_("Updating Dawnline"),o.version),"positive",{disabled:t.busy}),H(_("What’s new"),a(i))]):"",bd(t),vd(t)]),n("div",{class:"dl-comp-hero-side"},[p(_("Source"),[v("globe"),n("a",{href:`https://github.com/${o.repo}`,target:"_blank",rel:"noopener"},o.repo)]),p(_("Auto-update"),[s.auto?Se("ok",_("On")):Se("",_("Off")),n("span",{class:"dl-muted"},s.auto?s.mode==="immediate"?_("as soon as found"):m(s.interval==="7d"?_("weekly at %s"):_("daily at %s"),s.time):s.check?hd(s.interval):_("checks off"))]),p(_("Last check"),o.check?[ce(o.check.time,o.now),c>o.now?n("span",{class:"dl-faint"},`· ${m(_("next in %s"),st(c-o.now))}`):""]:[_("Never")]),p(_("Rollback"),r?[n("span",{class:"dl-mono"},r.version),n("span",{class:"dl-faint"},_("kept on flash"))]:[n("span",{class:"dl-muted"},s.keep?_("Kept after the next update"):_("Off"))])])])}function gd(t,e,o){if(t.notes.has(e))return t.notes.get(e)??null;t.notes.set(e,null);let s=r=>r.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,a)=>a??"").trim();return(async()=>{let i=((await N.updatesNotes("app",e,"").catch(()=>null))?.body??"").split(`
|
|
||||||
`).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);i.length||(i=(await N.updatesChanges(o,e).catch(()=>null))?.items??[]);let a={items:i.slice(0,3).map(l=>fd(s(l))),total:i.length};t.notes.set(e,a),a.items.length&&t.root.isConnected&&t.paint()})(),null}function Xn(t){return t==="ru"?_("Russian translation"):t}function vd(t){let e=(t.st.translations??[]).includes("ru"),o=be(e,Xn("ru"),r=>{t.op(r?"app:lang:ru":"app:nolang",r?_("Adding the Russian translation"):_("Removing the Russian translation"),t.st.version)});o.disabled=t.busy;let s=n("details",{class:"dl-params dl-comp-fold",open:t.langOpen?"open":null},[n("summary",{},[v("chevron"),n("span",{},_("Translation")),n("span",{class:"dl-sub"},e?_("Russian"):_("English only"))]),n("div",{class:"dl-params-body"},[n("div",{class:"dl-list"},[n("div",{class:"dl-row"},[n("span",{class:"dl-row-main dl-stack"},[n("b",{},Xn("ru")),n("span",{class:"dl-sub"},_("LuCI pages for Dawnline"))]),n("span",{class:"dl-comp-bact"},o)])])])]);return s.addEventListener("toggle",()=>t.langOpen=s.open),s}function bd(t){let e=n("div",{class:"dl-params-body"}),o=n("details",{class:"dl-params dl-comp-vers",open:t.versOpen?"open":null},[n("summary",{},[v("chevron"),n("span",{},_("Versions")),n("span",{class:"dl-sub"},_("install any release"))]),e]);return o.addEventListener("toggle",()=>{t.versOpen=o.open,t.versOpen&&eo(t,e)}),t.versOpen&&eo(t,e),o}async function eo(t,e){let o=ue("",{placeholder:_("Tag, e.g. 0.3.1"),class:"cbi-input-text dl-mono","aria-label":_("Release tag")}),s=p=>{if(p=p.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(p))return F(_("Enter a release tag like 0.3.1"),"warning");Pi(t,p)};o.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),s(o.value))});let r=n("div",{class:"dl-comp-tag"},[o,H(_("Install"),()=>s(o.value),"neutral",{disabled:t.busy})]),i=t.versPage,a=p=>{t.versPage=Math.max(1,t.versPage+p),eo(t,e)},l=p=>n("div",{class:"dl-comp-pager"},[n("button",{type:"button",class:"dl-linkbtn",disabled:i<=1?"disabled":null,click:()=>a(-1)},_("← Newer")),n("span",{class:"dl-faint"},m(_("Page %s"),i)),n("button",{type:"button",class:"dl-linkbtn",disabled:p?null:"disabled",click:()=>a(1)},_("Older →"))]),d=t.versCache.get(i);if(!d){dom.content(e,[r,n("p",{class:"dl-muted dl-loading"},_("Loading versions…"))]);try{d=(await N.updatesReleases(i)).releases}catch(p){if(i!==t.versPage||!e.isConnected)return;dom.content(e,[r,n("div",{class:"dl-row-actions"},[n("span",{class:"dl-muted"},m(_("Failed to load versions: %s"),_e(p))),H(_("Try again"),()=>eo(t,e))]),l(!1)]);return}if(t.versCache.set(i,d),i!==t.versPage||!e.isConnected)return}if(!d.length)return dom.content(e,[r,n("p",{class:"dl-muted"},i>1?_("No more versions."):_("No versions found.")),l(!1)]);let c=t.st.version;dom.content(e,[r,...d.map(p=>{let u=p.tag.replace(/^v/,"");return n("div",{class:"dl-comp-ver"},[n("span",{class:"dl-mono"},u),n("span",{class:"dl-sub"},ns(p.published)),p.prerelease?Se("warn",_("Pre-release")):"",n("span",{class:"dl-comp-ic"},Pe("file",_("What’s new"),()=>mn("app",p.tag,m(_("What’s new in Dawnline %s"),u)))),u===c?Se("ok",_("Installed")):H(_("Install"),()=>Pi(t,p.tag),"neutral",{disabled:t.busy})])}),l(d.length>=5)])}async function Pi(t,e){let o=e.replace(/^v/,"");o.localeCompare(t.st.version,void 0,{numeric:!0})<0&&!await pe(m(_("Install Dawnline %s?"),o),m(_("It is older than %s. A backup of the settings is made first; restore it from Settings if something looks wrong."),t.st.version),_("Install"))||t.op(`app@${e}`,m(_("Installing Dawnline %s"),o),t.st.version)}function Di(t,e){let o=t.st,s=o.kept?.amneziawg,r=e?.sources??{},i=Object.keys(r),a=e?.current??null,l=a?r[a]:void 0,d=!!e?.ru,c=o.needs?.awg??[],p=c.length?null:e?.installed??null,u=[];a&&p&&u.push({label:_("Reinstall this build"),warn:!0,ic:"reset",run:()=>t.op(`amneziawg:${a}${d?":ru":""}`,_("Reinstalling AmneziaWG"),p)}),s&&u.push({label:m(_("Roll back to %s"),s.version),ic:"archive",warn:!0,run:async()=>{await pe(m(_("Roll back AmneziaWG to %s?"),s.version),_("The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds."),_("Roll back"))&&t.op("amneziawg:rollback",_("Rolling back AmneziaWG"),p??void 0)}});let g=[e?.release?{label:_("What’s new"),ic:"file",run:()=>mn("amneziawg",e.release,m(_("What’s new in the %s build"),l?.label??"AmneziaWG"),a??"slava")}:null,{label:_("Open on GitHub"),ic:"globe",run:()=>window.open(`https://github.com/${l?.repo??"Slava-Shchipunov/awg-openwrt"}`,"_blank","noopener")},...u.length?[null,...u]:[]].filter((b,f,T)=>b!==null||f>0&&T[f-1]!==null),M=o.tunnels??[],x=M.length?M.length===1?m(_("Switching restarts the tunnel for a few seconds: %s. Devices keep their configurations."),M[0]):m(N_(M.length,"Switching restarts %s tunnel for a few seconds: %s. Devices keep their configurations.","Switching restarts %s tunnels for a few seconds: %s. Devices keep their configurations."),V(M.length),M.join(", ")):_("Switching takes a few
Line truncated
|
|
||||||
`)}r.push(p),l+=c-1}let a=H([v("more")],()=>Te(a,[{label:_("Export CSV"),icon:v("download"),run:()=>Xe(o,s,"csv",e.id)},{label:_("Export JSON"),icon:v("download"),run:()=>Xe(o,s,"json",e.id)},null,{label:m(_("Clear %s's activity"),e.name),icon:v("trash"),danger:!0,run:()=>dt(m(_("Clear %s's activity"),e.name),m(_("Removes events about %s and their devices."),e.name),{person:e.id},()=>t.refresh())}]),"neutral",{title:_("Export or clear"),class:"cbi-button cbi-button-neutral dl-icon-only"});return n("div",{class:"dl-panel flush"},[n("div",{class:"dl-panel-head pad"},[n("h3",{},_("Activity")),n("span",{class:"dl-sub"},s.length>10?m(_("latest 10 of %s"),V(s.length)):""),n("span",{class:"dl-spacer"}),a]),r.length?r:n("div",{class:"dl-row dl-muted"},_("Nothing yet."))])}var no=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.ticks=0;this.fullNext=!1}async fetch(e){let[o,s,r]=await Promise.all([N.status(30),e?N.events(2e3,this.id).catch(()=>null):Promise.resolve(null),e?N.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:o,ev:s?.events??null,use:r}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(e){this.take(e);let o=this.st.people.find(a=>a.id===this.id);if(!o)return n("div",{class:"dl-empty"},[n("h3",{},_("Person not found")),n("p",{},_("They may have been removed.")),n("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},_("Back to Servers"))]);this.p=o;for(let a of["crumbs","head","devices","traffic","places","activity","limits"])this.parts[a]=n("div",{});this.parts.devices.className="dl-person-devices";let s=n("div",{},[this.parts.crumbs,this.parts.head,n("div",{class:"dl-grid-person"},[n("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),n("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let r=new URLSearchParams(location.search),i=r.get("device")&&o.devices.find(a=>a.id===r.get("device"));return i?setTimeout(()=>Ye(this.p,i,this.deviceOpts()),50):r.get("add")&&setTimeout(()=>pt(this.p,this.deviceOpts()),50),this.poller=nt({fetch:a=>{let l=a||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(l)},every:15,live:!0,active:()=>s.isConnected,apply:(a,l)=>this.apply(a,l)}),s}take(e){this.st=e.st,e.ev&&(this.events=e.ev),e.use&&(this.series=e.use.person,this.devSeries=e.use.devices)}apply(e,o){this.take(e);let s=this.st.people.find(r=>r.id===this.id);if(!s){o||(location.href=jt(this.p?.server));return}this.p=s,this.paint(o),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(e,o){var i;this.poller?.claim();let s=await q(()=>N.personUpdate(this.p.id,e),o);if(!s)return!1;this.poller?.claim();let r=this.st.people.findIndex(a=>a.id===this.p.id);return(i=s.person).rate??(i.rate=this.p.rate),r>=0&&(this.st.people[r]=s.person),this.p=s.person,this.paint(),!0}get today(){return Ge(this.series.length?this.series:this.st.series)}get core(){return Ot(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,server:this.st.servers.find(e=>e.id===this.p.server),events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}crumbs(){let e=this.p;return n("nav",{class:"dl-crumbs","aria-label":_("Breadcrumb")},[n("a",{href:jt(e.server)},this.st.servers.find(o=>o.id===e.server)?.name??_("Servers")),n("span",{},"/"),n("a",{href:jt(e.server)},_("People")),n("span",{},"/"),n("span",{},e.name)])}paint(e=!1){Ne(this.parts.crumbs,this.crumbs(),e),Ne(this.parts.head,Ui(this),e),Ne(this.parts.traffic,Wi(this),e),Ne(this.parts.devices,Gi(this),e),Ne(this.parts.limits,Zi(this),e),this.paintPlaces(e),Ne(this.parts.activity,Xi(this),e)}paintPlaces(e=!1){let o=Qi(this);o&&Ne(this.parts.places,o,e&&!this.mapOpen)}};var Sd={ok:"check",warn:"alert",error:"x",skip:"pause"},oo=class{constructor(e,o,s,r){this.el=n("div",{});this.wdEl=n("div",{});this.checksEl=n("div",{class:"dl-panel"});this.recentEl=n("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=n("div",{});this.open=new Set;this.st=e,this.sl=o,this.events=s,this.toLog=r,dom.content(this.el,[this.summary,this.wdEl,n("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(o,s)}async run(e){let o=e?await Jn(e):await N.health().catch(()=>null);o&&(this.take(o),e==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(e){this.checks=e.checks,this.paintChecks(),this.paintLive(e,this.events)}paintChecks(){let e=this.checks;if(!e){dom.content(this.summary,""),dom.content(this.checksEl,[n("div",{class:"dl-panel-head"},[n("h3",{},_("Checks"))]),n("p",{class:"dl-muted dl-loading"},_("Running checks…"))]);return}let o=e.filter(a=>a.status==="error").length,s=e.filter(a=>a.status==="
Line truncated
|
|
||||||
`);function fa(){let t=document.createElement("style");return t.dataset.dawnline="1",t.textContent=Vd,t}function Lt(t){return()=>{let e=new t;return Object.assign({load:()=>e.load(),render:async s=>{let r=await e.render(s),i=document.createElement("div");return i.className="dl-root",i.append(fa(),r),i},addFooter(){return e.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var ux=Lt(un),mx=Lt(Ct),hx=Lt(un),fx=Lt(Qn),gx=Lt(no),vx=Lt(io),bx=Lt(to);function ga(t){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${t?`?tab=${t}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var xx=ga(""),wx=ga("log");return baseclass.extend({ activity: wx, diagnostics: vx, health: xx, overview: ux, people: mx, person: gx, server: hx, settings: fx, updates: bx });
|
|
||||||
@@ -24,6 +24,25 @@ import * as pkgs from 'dawnline.upd_pkgs';
|
|||||||
import * as i18n from 'dawnline.i18n';
|
import * as i18n from 'dawnline.i18n';
|
||||||
import { _, L_ } from 'dawnline.i18n';
|
import { _, L_ } from 'dawnline.i18n';
|
||||||
|
|
||||||
|
const USAGE = `Usage:
|
||||||
|
updater check [app|amneziawg|packages]
|
||||||
|
updater install app | app@<tag> | app:reinstall | app:rollback
|
||||||
|
updater install amneziawg[:auto|slava|grey[:ru]] | amneziawg:rollback
|
||||||
|
updater install pkgs:<name,…>
|
||||||
|
updater auto
|
||||||
|
`;
|
||||||
|
|
||||||
|
// No command, one it doesn't know, or an install of nothing: the usage and exit, before anything is read or
|
||||||
|
// written (no job for Components, no history, nothing in the service log). Asked for help: the same, on stdout.
|
||||||
|
if (index([ '-h', '--help', 'help' ], ARGV[0]) >= 0) {
|
||||||
|
print(USAGE);
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
if (index([ 'check', 'install', 'auto' ], ARGV[0]) < 0 || (ARGV[0] == 'install' && !length(ARGV[1] ?? ''))) {
|
||||||
|
warn(USAGE);
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
// The phases and errors of a job LuCI started are in the admin's language (rpc/updates.uc hands it over).
|
// The phases and errors of a job LuCI started are in the admin's language (rpc/updates.uc hands it over).
|
||||||
i18n.use(getenv('DAWNLINE_LANG'));
|
i18n.use(getenv('DAWNLINE_LANG'));
|
||||||
|
|
||||||
@@ -313,7 +332,7 @@ function main() {
|
|||||||
else if (job.action == 'auto')
|
else if (job.action == 'auto')
|
||||||
auto();
|
auto();
|
||||||
else
|
else
|
||||||
die('Usage: updater check [app|amneziawg|packages] | install <what> | auto');
|
die(USAGE);
|
||||||
job.state = 'done';
|
job.state = 'done';
|
||||||
phase(_('Finished'));
|
phase(_('Finished'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
Geist and Geist Mono are licensed under the SIL Open Font License, Version 1.1.
|
|
||||||
Copyright (c) 2023 Vercel, in collaboration with basement.studio.
|
|
||||||
https://github.com/vercel/geist-font/blob/main/OFL.txt
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><style>.t{fill:#0a0a0a}.g{fill:#fff}@media (prefers-color-scheme:dark){.t{fill:#fff}.g{fill:#0a0a0a}}</style><rect class="t" width="64" height="64" rx="16"/><path class="g" d="M14 38a18 18 0 0 1 36 0z"/><rect class="g" x="12" y="43" width="40" height="4" rx="2" opacity=".5"/></svg>
|
|
||||||
|
Before Width: | Height: | Size: 343 B |
@@ -1 +0,0 @@
|
|||||||
@font-face{font-family:Geist;src:url(geist-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2190-21FF,U+2212,U+2215}@font-face{font-family:Geist;src:url(geist-cyrillic-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:Geist Mono;src:url(geist-mono-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap}:root{color-scheme:dark;--bg: #080808;--raised: #121212;--field: #161616;--knob: #232323;--seg: rgba(237, 237, 237, .05);--seg-shadow: none;--line: rgba(255, 255, 255, .06);--text: #ededed;--text-2: #8c8c8a;--text-3: #4f4f4e;--accent: #4eafff;--accent-ink: #ffffff;--accent-soft: rgba(78, 175, 255, .13);--ok: #57d64b;--ok-soft: rgba(87, 214, 75, .14);--warn: #ff8a3d;--bad: #ff5c5c;--bad-soft: rgba(255, 92, 92, .13);--sel-bg: rgba(131, 209, 255, .25);--sel-fg: #64c6ff;--scrim: rgba(8, 8, 8, .8);--line-glass: rgba(255, 255, 255, .07);--pop-shadow: 0 18px 48px -14px rgba(0, 0, 0, .75);--sheet-shadow: 0 24px 64px -16px rgba(0, 0, 0, .6);--bar: rgba(237, 237, 237, .13);--toast: #232323;--toast-fg: #ededed;--qr-bg: #0a0a0a;--gi-a: rgba(255, 255, 255, .58);--gi-b: rgba(255, 255, 255, .14);--gi-rim: rgba(255, 255, 255, .5);--gi-edge: rgba(0, 0, 0, 0);--gi-detail: #ffffff;--t-grey-a: #cfcfcd;--t-grey-b: #5a5a59;--t-blue-a: #a6d9ff;--t-blue-b: #1d84e6;--t-green-a: #a8f29c;--t-green-b: #3aa32c;--t-red-a: #ffadad;--t-red-b: #dc3a3a;--t-orange-a: #ffc08f;--t-orange-b: #ec6a12;--font: Geist, -apple-system, system-ui, "Segoe UI", sans-serif;--mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;--r-sheet: 36px;--r-card: 28px;--r-row: 20px;--r-field: 16px;--r-tile: 12px;--ease-out: cubic-bezier(.23, 1, .32, 1);--gutter-l: max(16px, env(safe-area-inset-left, 0px));--gutter-r: max(16px, env(safe-area-inset-right, 0px))}@media(prefers-color-scheme:light){:root{color-scheme:light;--bg: #f2f2f1;--raised: #ffffff;--field: #f3f3f2;--knob: #e8e8e7;--seg: #ffffff;--seg-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 .5px rgba(0, 0, 0, .05);--line: rgba(0, 0, 0, .07);--text: #0b0b0b;--text-2: #6d6d6b;--text-3: #a6a6a4;--accent: #2b9dff;--accent-soft: rgba(43, 157, 255, .12);--ok: #33a328;--ok-soft: rgba(51, 163, 40, .12);--warn: #ee6a12;--bad: #e5484d;--bad-soft: rgba(229, 72, 77, .1);--sel-bg: rgba(78, 175, 255, .22);--sel-fg: #0a76cf;--scrim: rgba(236, 236, 235, .62);--line-glass: rgba(0, 0, 0, .07);--pop-shadow: 0 18px 44px -14px rgba(0, 0, 0, .2);--sheet-shadow: 0 24px 64px -18px rgba(0, 0, 0, .22);--bar: rgba(11, 11, 11, .11);--toast: #0b0b0b;--toast-fg: #f2f2f1;--qr-bg: #ffffff;--gi-a: rgba(250, 250, 249, .72);--gi-b: rgba(206, 206, 204, .5);--gi-rim: rgba(255, 255, 255, .9);--gi-edge: rgba(0, 0, 0, .11);--gi-detail: rgba(28, 28, 28, .72);--t-grey-a: #a9a9a7;--t-grey-b: #3d3d3c;--t-blue-a: #7cc4ff;--t-blue-b: #0a6fd6;--t-green-a: #82e070;--t-green-b: #2e8a22;--t-red-a: #ff9090;--t-red-b: #c92a2a}}*{box-sizing:border-box}html{-webkit-text-size-adjust:100%;scrollbar-gutter:stable;overflow-anchor:none}body{margin:0;background:var(--bg);color:var(--text);font:400 15px/22px var(--font);letter-spacing:-.011em;-webkit-font-smoothing:antialiased;min-height:100vh;min-height:100dvh;cursor:default}body.locked{overflow:hidden}input,textarea,.linkrow .mono,.conf{cursor:text}::selection{background:var(--sel-bg);color:var(--sel-fg)}button{font:inherit;color:inherit;letter-spacing:inherit;background:none;border:0;padding:0;margin:0;cursor:pointer;-webkit-tap-highlight-color:transparent}button:disabled{cursor:default}a{color:inherit;text-decoration:none}:focus{outline:none}:focus-visible{outline:2px solid color-mix(in srgb,var(--accent) 65%,transparent);outline-offset:2px}[hidden]{display:none!important}.offscreen{position:fixed;left:-9999px;top:0;opacity:0}.mono{font-family:var(--mono);letter-spacing:0}.num{font-variant-numeric:tabular-nums}.ok-t{color:var(--ok)}.warn-t{color:var(--warn)}.bad-t{color:var(--bad)}.here-t{color:var(--accent)}.i{width:18px;height:18px;flex:none}.gi{width:24px;height:24px;flex:none;overflow:visible;--ta: var(--t-grey-a);--tb: var(--t-grey-b)}.gi.t-blue{--ta: var(--t-blue-a);--tb: var(--t-blue-b)}.gi.t-green{--ta: var(--t-green-a);--tb: var(--t-green-b)}.gi.t-red{--ta: var(--t-red-a);--tb: var(--t-red-b)}.gi.t-orange{--ta: var(--t-orange-a);--tb: var(--t-orange-b)}.gi .ta{stop-color:var(--ta)}.gi .tb{stop-color:var(--tb)}.gi .fa{stop-color:var(--gi-a)}.gi .fb{stop-color:var(--gi-b)}.gi .fc{stop-color:var(--ta);stop-opacity:.28}.gi .ge{stroke:var(--gi-edge)}.gi .gr{stroke:var(--gi-rim)}.gi .gd{stroke:var(--gi-detail)}.gi .gdf{color:var(--gi-detail)}.knob{width:32px;height:32px;border-radius:50%;background:var(--knob);color:var(--text);display:grid;place-items:center;flex:none;transition:transform .15s var(--ease-out),background-color .15s}.knob:hoveLine truncated
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
"use strict";(()=>{var Si=Object.create;var Oo=Object.defineProperty;var Ai=Object.getOwnPropertyDescriptor;var Hi=Object.getOwnPropertyNames;var Di=Object.getPrototypeOf,$i=Object.prototype.hasOwnProperty;var Pi=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Oi=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Hi(t))!$i.call(e,r)&&r!==n&&Oo(e,r,{get:()=>t[r],enumerable:!(o=Ai(t,r))||o.enumerable});return e};var Ri=(e,t,n)=>(n=e!=null?Si(Di(e)):{},Oi(t||!e||!e.__esModule?Oo(n,"default",{value:e,enumerable:!0}):n,e));var Lr=Pi((kr,Cr)=>{"use strict";var Er=(function(){var e=function(y,w){var p=236,u=17,l=y,v=n[w],h=null,d=0,L=null,M=[],H={},q=function(k,T){d=l*4+17,h=(function(E){for(var D=new Array(E),$=0;$<E;$+=1){D[$]=new Array(E);for(var I=0;I<E;I+=1)D[$][I]=null}return D})(d),R(0,0),R(d-7,0),R(0,d-7),U(),N(),oe(k,T),l>=7&&Z(k),L==null&&(L=nn(l,v,M)),de(L,T)},R=function(k,T){for(var E=-1;E<=7;E+=1)if(!(k+E<=-1||d<=k+E))for(var D=-1;D<=7;D+=1)T+D<=-1||d<=T+D||(0<=E&&E<=6&&(D==0||D==6)||0<=D&&D<=6&&(E==0||E==6)||2<=E&&E<=4&&2<=D&&D<=4?h[k+E][T+D]=!0:h[k+E][T+D]=!1)},W=function(){for(var k=0,T=0,E=0;E<8;E+=1){q(!0,E);var D=r.getLostPoint(H);(E==0||k>D)&&(k=D,T=E)}return T},N=function(){for(var k=8;k<d-8;k+=1)h[k][6]==null&&(h[k][6]=k%2==0);for(var T=8;T<d-8;T+=1)h[6][T]==null&&(h[6][T]=T%2==0)},U=function(){for(var k=r.getPatternPosition(l),T=0;T<k.length;T+=1)for(var E=0;E<k.length;E+=1){var D=k[T],$=k[E];if(h[D][$]==null)for(var I=-2;I<=2;I+=1)for(var B=-2;B<=2;B+=1)I==-2||I==2||B==-2||B==2||I==0&&B==0?h[D+I][$+B]=!0:h[D+I][$+B]=!1}},Z=function(k){for(var T=r.getBCHTypeNumber(l),E=0;E<18;E+=1){var D=!k&&(T>>E&1)==1;h[Math.floor(E/3)][E%3+d-8-3]=D}for(var E=0;E<18;E+=1){var D=!k&&(T>>E&1)==1;h[E%3+d-8-3][Math.floor(E/3)]=D}},oe=function(k,T){for(var E=v<<3|T,D=r.getBCHTypeInfo(E),$=0;$<15;$+=1){var I=!k&&(D>>$&1)==1;$<6?h[$][8]=I:$<8?h[$+1][8]=I:h[d-15+$][8]=I}for(var $=0;$<15;$+=1){var I=!k&&(D>>$&1)==1;$<8?h[8][d-$-1]=I:$<9?h[8][15-$-1+1]=I:h[8][15-$-1]=I}h[d-8][8]=!k},de=function(k,T){for(var E=-1,D=d-1,$=7,I=0,B=r.getMaskFunction(T),G=d-1;G>0;G-=2)for(G==6&&(G-=1);;){for(var X=0;X<2;X+=1)if(h[D][G-X]==null){var ne=!1;I<k.length&&(ne=(k[I]>>>$&1)==1);var Y=B(D,G-X);Y&&(ne=!ne),h[D][G-X]=ne,$-=1,$==-1&&(I+=1,$=7)}if(D+=E,D<0||d<=D){D-=E,E=-E;break}}},ke=function(k,T){for(var E=0,D=0,$=0,I=new Array(T.length),B=new Array(T.length),G=0;G<T.length;G+=1){var X=T[G].dataCount,ne=T[G].totalCount-X;D=Math.max(D,X),$=Math.max($,ne),I[G]=new Array(X);for(var Y=0;Y<I[G].length;Y+=1)I[G][Y]=255&k.getBuffer()[Y+E];E+=X;var fe=r.getErrorCorrectPolynomial(ne),ce=i(I[G],fe.getLength()-1),Do=ce.mod(fe);B[G]=new Array(fe.getLength()-1);for(var Y=0;Y<B[G].length;Y+=1){var $o=Y+Do.getLength()-B[G].length;B[G][Y]=$o>=0?Do.getAt($o):0}}for(var Po=0,Y=0;Y<T.length;Y+=1)Po+=T[Y].totalCount;for(var Qn=new Array(Po),on=0,Y=0;Y<D;Y+=1)for(var G=0;G<T.length;G+=1)Y<I[G].length&&(Qn[on]=I[G][Y],on+=1);for(var Y=0;Y<$;Y+=1)for(var G=0;G<T.length;G+=1)Y<B[G].length&&(Qn[on]=B[G][Y],on+=1);return Qn},nn=function(k,T,E){for(var D=c.getRSBlocks(k,T),$=m(),I=0;I<E.length;I+=1){var B=E[I];$.put(B.getMode(),4),$.put(B.getLength(),r.getLengthInBits(B.getMode(),k)),B.write($)}for(var G=0,I=0;I<D.length;I+=1)G+=D[I].dataCount;if($.getLengthInBits()>G*8)throw"code length overflow. ("+$.getLengthInBits()+">"+G*8+")";for($.getLengthInBits()+4<=G*8&&$.put(0,4);$.getLengthInBits()%8!=0;)$.putBit(!1);for(;!($.getLengthInBits()>=G*8||($.put(p,8),$.getLengthInBits()>=G*8));)$.put(u,8);return ke($,D)};H.addData=function(k,T){T=T||"Byte";var E=null;switch(T){case"Numeric":E=f(k);break;case"Alphanumeric":E=C(k);break;case"Byte":E=g(k);break;case"Kanji":E=b(k);break;default:throw"mode:"+T}M.push(E),L=null},H.isDark=function(k,T){if(k<0||d<=k||T<0||d<=T)throw k+","+T;return h[k][T]},H.getModuleCount=function(){return d},H.make=function(){if(l<1){for(var k=1;k<40;k++){for(var T=c.getRSBlocks(k,v),E=m(),D=0;D<M.length;D++){var $=M[D];E.put($.getMode(),4),E.put($.getLength(),r.getLengthInBits($.getMode(),k)),$.write(E)}for(var I=0,D=0;D<T.length;D++)I+=T[D].dataCount;if(E.getLengthInBits()<=I*8)break}l=k}q(!1,W())},H.createTableTag=function(k,T){k=k||2,T=typeof T=="undefined"?k*4:T;var E="";E+='<table style="',E+=" border-width: 0px; border-style: none;",E+=" border-collapse: collapse;",E+=" padding: 0px; margin: "+T+"px;",E+='">',E+="<tbody>";for(var D=0;D<H.getModuleCount();D+=1){E+="<tr>";for(var $=0;$<H.getModuleCount();$+=1)E+='<td style="',E+=" border-width: 0px; border-style: none;",E+=" border-collapse: collapse;",E+=" padding: 0px; margin: 0px;",E+=" width: "+k+"px;",E+=" height: "+k+"px;",E+=" background-color: ",E+=H.isDark(D,$)?"#000000":"#ffffff",E+=";",E+='"/>';E+="</tr>"}return E+="</tbody>",E+="</table>",E},H.createSvgTag=function(k,T,E,D){var $={};typeof arguments[0]=="object"&&($=arguments[0],k=$.cellSize,T=$.margin,E=$.alt,D=$.title),k=k||2,T=typeof T=="undefined"?k*4:T,E=typeof E=="string"?{text:E}:E||{Line truncated
|
|
||||||
`}return E%2&&k>0?ce.substring(0,ce.length-E-1)+Array(E+1).join("▀"):ce.substring(0,ce.length-1)};return H.createASCII=function(k,T){if(k=k||1,k<2)return et(T);k-=1,T=typeof T=="undefined"?k*2:T;var E=H.getModuleCount()*k+T*2,D=T,$=E-T,I,B,G,X,ne=Array(k+1).join("██"),Y=Array(k+1).join(" "),fe="",ce="";for(I=0;I<E;I+=1){for(G=Math.floor((I-D)/k),ce="",B=0;B<E;B+=1)X=1,D<=B&&B<$&&D<=I&&I<$&&H.isDark(G,Math.floor((B-D)/k))&&(X=0),ce+=X?ne:Y;for(G=0;G<k;G+=1)fe+=ce+`
|
|
||||||
`}return fe.substring(0,fe.length-1)},H.renderTo2dContext=function(k,T){T=T||2;for(var E=H.getModuleCount(),D=0;D<E;D++)for(var $=0;$<E;$++)k.fillStyle=H.isDark(D,$)?"black":"white",k.fillRect(D*T,$*T,T,T)},H};e.stringToBytesFuncs={default:function(y){for(var w=[],p=0;p<y.length;p+=1){var u=y.charCodeAt(p);w.push(u&255)}return w}},e.stringToBytes=e.stringToBytesFuncs.default,e.createStringToBytes=function(y,w){var p=(function(){for(var l=P(y),v=function(){var N=l.read();if(N==-1)throw"eof";return N},h=0,d={};;){var L=l.read();if(L==-1)break;var M=v(),H=v(),q=v(),R=String.fromCharCode(L<<8|M),W=H<<8|q;d[R]=W,h+=1}if(h!=w)throw h+" != "+w;return d})(),u=63;return function(l){for(var v=[],h=0;h<l.length;h+=1){var d=l.charCodeAt(h);if(d<128)v.push(d);else{var L=p[l.charAt(h)];typeof L=="number"?(L&255)==L?v.push(L):(v.push(L>>>8),v.push(L&255)):v.push(u)}}return v}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},o={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r=(function(){var y=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],w=1335,p=7973,u=21522,l={},v=function(h){for(var d=0;h!=0;)d+=1,h>>>=1;return d};return l.getBCHTypeInfo=function(h){for(var d=h<<10;v(d)-v(w)>=0;)d^=w<<v(d)-v(w);return(h<<10|d)^u},l.getBCHTypeNumber=function(h){for(var d=h<<12;v(d)-v(p)>=0;)d^=p<<v(d)-v(p);return h<<12|d},l.getPatternPosition=function(h){return y[h-1]},l.getMaskFunction=function(h){switch(h){case o.PATTERN000:return function(d,L){return(d+L)%2==0};case o.PATTERN001:return function(d,L){return d%2==0};case o.PATTERN010:return function(d,L){return L%3==0};case o.PATTERN011:return function(d,L){return(d+L)%3==0};case o.PATTERN100:return function(d,L){return(Math.floor(d/2)+Math.floor(L/3))%2==0};case o.PATTERN101:return function(d,L){return d*L%2+d*L%3==0};case o.PATTERN110:return function(d,L){return(d*L%2+d*L%3)%2==0};case o.PATTERN111:return function(d,L){return(d*L%3+(d+L)%2)%2==0};default:throw"bad maskPattern:"+h}},l.getErrorCorrectPolynomial=function(h){for(var d=i([1],0),L=0;L<h;L+=1)d=d.multiply(i([1,s.gexp(L)],0));return d},l.getLengthInBits=function(h,d){if(1<=d&&d<10)switch(h){case t.MODE_NUMBER:return 10;case t.MODE_ALPHA_NUM:return 9;case t.MODE_8BIT_BYTE:return 8;case t.MODE_KANJI:return 8;default:throw"mode:"+h}else if(d<27)switch(h){case t.MODE_NUMBER:return 12;case t.MODE_ALPHA_NUM:return 11;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 10;default:throw"mode:"+h}else if(d<41)switch(h){case t.MODE_NUMBER:return 14;case t.MODE_ALPHA_NUM:return 13;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 12;default:throw"mode:"+h}else throw"type:"+d},l.getLostPoint=function(h){for(var d=h.getModuleCount(),L=0,M=0;M<d;M+=1)for(var H=0;H<d;H+=1){for(var q=0,R=h.isDark(M,H),W=-1;W<=1;W+=1)if(!(M+W<0||d<=M+W))for(var N=-1;N<=1;N+=1)H+N<0||d<=H+N||W==0&&N==0||R==h.isDark(M+W,H+N)&&(q+=1);q>5&&(L+=3+q-5)}for(var M=0;M<d-1;M+=1)for(var H=0;H<d-1;H+=1){var U=0;h.isDark(M,H)&&(U+=1),h.isDark(M+1,H)&&(U+=1),h.isDark(M,H+1)&&(U+=1),h.isDark(M+1,H+1)&&(U+=1),(U==0||U==4)&&(L+=3)}for(var M=0;M<d;M+=1)for(var H=0;H<d-6;H+=1)h.isDark(M,H)&&!h.isDark(M,H+1)&&h.isDark(M,H+2)&&h.isDark(M,H+3)&&h.isDark(M,H+4)&&!h.isDark(M,H+5)&&h.isDark(M,H+6)&&(L+=40);for(var H=0;H<d;H+=1)for(var M=0;M<d-6;M+=1)h.isDark(M,H)&&!h.isDark(M+1,H)&&h.isDark(M+2,H)&&h.isDark(M+3,H)&&h.isDark(M+4,H)&&!h.isDark(M+5,H)&&h.isDark(M+6,H)&&(L+=40);for(var Z=0,H=0;H<d;H+=1)for(var M=0;M<d;M+=1)h.isDark(M,H)&&(Z+=1);var oe=Math.abs(100*Z/d/d-50)/5;return L+=oe*10,L},l})(),s=(function(){for(var y=new Array(256),w=new Array(256),p=0;p<8;p+=1)y[p]=1<<p;for(var p=8;p<256;p+=1)y[p]=y[p-4]^y[p-5]^y[p-6]^y[p-8];for(var p=0;p<255;p+=1)w[y[p]]=p;var u={};return u.glog=function(l){if(l<1)throw"glog("+l+")";return w[l]},u.gexp=function(l){for(;l<0;)l+=255;for(;l>=256;)l-=255;return y[l]},u})();function i(y,w){if(typeof y.length=="undefined")throw y.length+"/"+w;var p=(function(){for(var l=0;l<y.length&&y[l]==0;)l+=1;for(var v=new Array(y.length-l+w),h=0;h<y.length-l;h+=1)v[h]=y[h+l];return v})(),u={};return u.getAt=function(l){return p[l]},u.getLength=function(){return p.length},u.multiply=function(l){for(var v=new Array(u.getLength()+l.getLength()-1),h=0;h<u.getLength();h+=1)for(var d=0;d<l.getLength();d+=1)v[h+d]^=s.gexp(s.glog(u.getAt(h))+s.glog(l.getAt(d)));return i(v,0)},u.mod=function(l){if(u.ge
Line truncated
|
|
||||||
`),hostName:s,mtu:n.mtu,persistent_keep_alive:n.persistent_keep_alive,port:Number(n.port),psk_key:n.psk_key,server_pub_key:n.server_pub_key},c={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(i),port:String(n.port),protocol_version:o.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:s};return n.dns[0]&&(c.dns1=n.dns[0],c.dns2=n.dns[1]||n.dns[0]),c}function Fa(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function Ga(e){let t=globalThis;if(typeof t.CompressionStream=="undefined")return null;try{let n=new t.Blob([e]).stream().pipeThrough(new t.CompressionStream("deflate")),o=new Uint8Array(await new t.Response(n).arrayBuffer()),r=new Uint8Array(4+o.length);return new DataView(r.buffer).setUint32(0,e.length,!1),r.set(o,4),r}catch{return null}}async function wo(e,t,n=!0){let o=new TextEncoder().encode(JSON.stringify(Wa(e,t))),r=n?await Ga(o):null;return`vpn://${Fa(r!=null?r:o)}`}var ks=e=>e.replace(/^vpn:\/\//,"");var Cs=["height","marginTop","marginBottom","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"],qa={opacity:0,filter:"blur(2px)"};function Ls(e,t,n){let o=e.getAnimations();O(e,t,n),o.forEach(r=>r.cancel())}var Ka=new Set(["offset","computedOffset","easing","composite"]),Va=e=>e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`);function Dt(...e){let t=[],n=[],o=new Set;for(let s of e)for(let i=s;i&&!o.has(i);i=i.parentElement)if(o.add(i),!(!(i instanceof HTMLElement)||i.classList.contains("closing")))for(let c of i.getAnimations()){let m=c.playState==="running"&&c.effect instanceof KeyframeEffect?c.effect.getKeyframes():[],f=m[m.length-1];if(f&&("width"in f||"maxWidth"in f)&&n.push({a:c,t:c.currentTime}),!(f!=null&&f.height)||f.height==="0px")continue;let C=getComputedStyle(i),g={},b={};for(let x of Object.keys(f))Ka.has(x)||(g[x]=C.getPropertyValue(Va(x)),b[x]=f[x]);t.push({el:i,a:c,t:c.currentTime,cur:g,to:b})}if(!t.length)return;[...t,...n].forEach(s=>s.a.cancel());let r=t.map(s=>getComputedStyle(s.el).height);for(let s of n)s.a.play(),s.a.currentTime=s.t;t.forEach((s,i)=>{s.a.play(),Math.abs(parseFloat(r[i])-parseFloat(String(s.to.height)))<.5?s.a.currentTime=s.t:s.a.effect.setKeyframes([s.cur,{...s.to,height:r[i]}])})}function ze(e,t={}){let n=a("div",{class:`acc${t.inset?" inset":""}`}),o=e.map((g,b)=>{var w;let x=g.body.filter(p=>!!p),S=!x.length,P=[g.icon,a("span",{class:"acc-title"},a("span",{class:"t"},g.title),(w=g.tag)!=null?w:null),g.val?a("span",{class:`acc-val${g.valHide?" hide-open":""}`},g.val):null],F=b===t.open&&!S,A=S?a("div",{class:"acc-head"},...P):a("button",{type:"button",class:"acc-head","aria-expanded":String(F),onclick:()=>C(y)},...P,z("chevron","i acc-chev")),y=a("div",{class:`acc-row${S?" still":""}${F?" open":""}`},A,a("div",{class:"acc-body"},...x));return n.appendChild(y),y}),r=g=>g.querySelector(".acc-body"),s=()=>o.forEach((g,b)=>{let x=g.classList.contains("open");g.classList.toggle("rt",b===0||x||o[b-1].classList.contains("open")),g.classList.toggle("rb",b===o.length-1||x||o[b+1].classList.contains("open"))}),i=g=>{let b=getComputedStyle(g),x={};for(let S of Cs)x[S]=S==="height"?`${g.getBoundingClientRect().height}px`:b[S];return x},c=()=>o.forEach(g=>{var b;return(b=g.querySelector("button.acc-head"))==null?void 0:b.setAttribute("aria-expanded",String(g.classList.contains("open")))}),m=g=>g.classList.contains("open")||g.classList.contains("closing"),f=g=>{if(!m(g))return qa;let b=getComputedStyle(r(g));return{opacity:b.opacity,filter:b.filter==="none"?"blur(0px)":b.filter}};function C(g){var w,p;let b=o.map(i),x=o.map(f),S=(w=t.hold)==null?void 0:w.call(t);o.forEach(u=>u.getAnimations().forEach(l=>l.cancel()));let P=!g.classList.contains("open"),F=o.filter(u=>m(u)&&!(u===g&&P));o.forEach(u=>{u.classList.remove("closing"),u!==g&&u.classList.remove("open")}),g.classList.toggle("open",P),P&&g.classList.add("opened"),s();let A=Lt(),y=o.map(i);if(S==null||S(),Dt(n.parentElement),o.forEach((u,l)=>{let v=()=>{u.classList.remove("closing"),u.classList.contains("open")||u.classList.remove("opened")};if(!Cs.some(h=>b[l][h]!==y[l][h]))return v();F.includes(u)&&u.classList.add("closing"),O(u,[b[l],y[l]],{duration:Le.duration,easing:Le.easing}).onfinish=v}),F.forEach(u=>{let l=x[o.indexOf(u)];Ls(r(u),[l,{opacity:0,filter:"blur(2px)"}],{duration:160*Number(l.opacity),easing:J,fill:"forwards"})}),P){let u=x[o.indexOf(g)];Ls(r(g),[u,{opacity:1,filter:"blur(0px)"}],{duration:300*(1-Number(u.opacity)),easing:"cubic-bezier(0,0,.58,1)"})}Tt(A),c(),(p=t.onToggle)==null||p.call(t,o.indexOf(g),P,!1)}return s(),{el:n,openIndex:()=>o.findIndex(g=>g.classList.contains("open")),setOpen(g){o.forEach((b,x)=>{[b,r(b)].forEach(P=>P.getAnimations().forEach(F=>F.cancel()));let S=x===g&&!b.classList.contains("still");b.classList.toggle(
Line truncated
|
|
||||||
`).flatMap((g,b)=>b?[`
|
|
||||||
`,Hs(g)]:[Hs(g)])),o=!!st(e.filename,e.conf),r=z("key"),s=z("x"),i=a("span",{},_("Show key")),c=a("button",{type:"button",class:"btn soft sm",onclick:()=>{t=!t,te(i,t?_("Hide key"):_("Show key")),n.querySelectorAll(".secret").forEach(g=>Wn(g,t,Ss)),n.querySelectorAll(".mask").forEach(g=>Wn(g,!t,Ss)),Wn(r,!t,As),Wn(s,t,As)}},Is(r,s),i),m=a("button",{type:"button",class:"btn soft sm",onclick:g=>be(e.conf,_("Configuration copied"),g.currentTarget)},z("copy"),a("span",{class:"lbl"},_("Copy"))),f=a("div",{class:"filecard"},a("div",{class:"fc-row"},a("span",{class:"filecard-ic"},".conf"),a("span",{class:"t"},a("span",{class:"mono"},e.filename),a("span",{},_("For computers and routers")))),a("button",{type:"button",class:"btn accent sm block",onclick:()=>Gt(e.filename,e.conf)},z(o?"open":"download"),a("span",{},o?_("Share file"):_("Download")))),C=ze([{icon:ee("file"),title:_("Configuration"),body:[a("div",{class:"confbar"},c,m),n]}],{inset:!0});return a("div",{class:"step-box"},f,C.el)}function Fs(e){let t=a("span",{class:"osm-p"},he[e]),n=Ur(Rt(e,"ios"),Rt(e,"android"));return{el:a("span",{class:"scanline"},a("span",{},...ut(_("In %s:"),t)),n.el),set(o){te(t,he[o],void 0,{whole:!0}),n.set(Rt(o,"ios"),Rt(o,"android"))}}}function Gs(e){let t=a("span",{class:"tt"}),n=a("span",{class:"tt-m"}),o=a("span",{class:"hp-tip","aria-hidden":"true"},t,n),r=a("button",{type:"button",class:"hp-b",onclick:()=>Gt(e().file,e().text)},z("download")),s=a("button",{type:"button",class:"hp-b"},z("copy")),i=a("div",{class:"hpill",role:"group","aria-label":_("The connection"),"data-key":"conn"},r,s,o),c=null,m=0,f=0,C=l=>{var v;return l===s&&s.classList.contains("done")?_("Copied"):(v=l.getAttribute("aria-label"))!=null?v:""},g=(l,v)=>{n.textContent=v;let h=n.offsetWidth+20;return Math.min(l.offsetLeft+l.offsetWidth/2,i.offsetWidth+46-h/2)},b=l=>`translateX(${l}px) translateX(-50%)`,x=()=>{let l=getComputedStyle(o);return{opacity:l.opacity,filter:l.filter==="none"?"blur(0px)":l.filter,transform:l.transform}},S=(l,v)=>{let h=o.getAnimations();O(o,l,v),h.forEach(d=>d.cancel())},P=l=>{let v=x();o.style.transform=b(l),S([v,{opacity:1,filter:"blur(0px)",transform:b(l)}],{duration:K.duration,easing:K.easing})},F=l=>te(t,l),A=l=>{if(clearTimeout(m),c===l&&o.classList.contains("on"))return;if(c=l,o.classList.contains("on")||+getComputedStyle(o).opacity>0){let h=C(l);return o.classList.add("on"),P(g(l,h)),F(h)}let v=()=>{let h=C(l);ae(t,h);let d=g(l,h);o.style.transform=b(d),o.classList.add("on"),S([{opacity:0,transform:`${b(d)} translateY(-3px) scale(.96)`,filter:"blur(3px)"},{opacity:1,transform:b(d),filter:"blur(0px)"}],{duration:220,easing:Q})};performance.now()<f?v():m=window.setTimeout(v,420)},y=()=>{if(clearTimeout(m),c=null,!o.classList.contains("on"))return;f=performance.now()+500;let l=x();o.classList.remove("on"),S([l,{...l,opacity:0}],{duration:120,easing:"ease-out"})};for(let l of[r,s])l.addEventListener("pointerenter",v=>{v.pointerType==="mouse"&&A(l)}),l.addEventListener("focus",()=>{l.matches(":focus-visible")&&A(l)}),l.addEventListener("blur",v=>{i.contains(v.relatedTarget)||y()});i.addEventListener("pointerleave",y);let w=l=>{let v=z(l);s.querySelector("svg").replaceWith(v),O(v,[{opacity:0,transform:"scale(.6)",filter:"blur(3px)"},{opacity:1,transform:"none",filter:"none"}],{duration:Te.duration,easing:Te.easing})},p=()=>{if(c!==s||!o.classList.contains("on"))return;let l=C(s);P(g(s,l)),F(l)},u=0;return s.addEventListener("click",()=>{let l=e();be(l.text,l.msg),clearTimeout(u),s.classList.contains("done")||(s.classList.add("done"),w("check"),p()),u=window.setTimeout(()=>{s.classList.remove("done"),w("copy"),p()},1600)}),{el:i,sync(){let l=e().app;r.setAttribute("aria-label",V(_("Download %s config"),l)),s.setAttribute("aria-label",V(_("Copy %s config"),l))}}}function qs(e,t){var n,o,r;return e?((n=e.setup)==null?void 0:n.state)==="trying"?"trying":e.handshake<=t?"waiting":((o=e.setup)==null?void 0:o.state)==="flowing"?"connected":((r=e.setup)==null?void 0:r.state)==="nodata"?"nodata":"waiting":"waiting"}function ja(e,t){switch(e){case"trying":return[_("Unable to complete the handshake"),_("Your network may be blocking the connection.")];case"connected":return[V(_("%s connected"),t.name),""];case"nodata":return[_("Handshake complete, but no data"),_("This device is using an outdated configuration.")];case"waiting":return[_("Waiting for the connection"),""]}}var Ks={waiting:"",trying:"trying",connected:"done",nodata:"nodata"};function Us(e){let t=a("b",{},_("Waiting for the connection")),n=a("span",{class:"ws",hidden:!0}),o=a("span",{class:"t"},t,n),r=a("div",{class:"way-text"},o),s=a("span",{class:"way-track"},a("span",{class:"way-glow"},a("span",{class:"run"},a("i")),a("span",{class:"knock"},a("i"))),a("span",{class:"way-fill"}),a("span",{class:"way-break"},a("i"))),i=a("div",{class:"way",role:"status","aria-live":"polite"},a("div",{class:"way-row"},a("span",{class:"way-end"},z(e.kind)),s,a("span",{class:"way-end home"},z("se
Line truncated
|
|
||||||
@@ -9,7 +9,7 @@ import { serve } from 'dawnline.portal';
|
|||||||
|
|
||||||
let env = {};
|
let env = {};
|
||||||
for (let k in [ 'REQUEST_METHOD', 'REQUEST_URI', 'REMOTE_ADDR', 'HTTPS', 'CONTENT_LENGTH', 'CONTENT_TYPE',
|
for (let k in [ 'REQUEST_METHOD', 'REQUEST_URI', 'REMOTE_ADDR', 'HTTPS', 'CONTENT_LENGTH', 'CONTENT_TYPE',
|
||||||
'HTTP_HOST', 'HTTP_ORIGIN', 'HTTP_USER_AGENT', 'HTTP_ACCEPT', 'HTTP_ACCEPT_LANGUAGE',
|
'HTTP_HOST', 'HTTP_ORIGIN', 'HTTP_USER_AGENT', 'HTTP_ACCEPT', 'HTTP_ACCEPT_LANGUAGE', 'HTTP_ACCEPT_ENCODING',
|
||||||
// The visitor behind Cloudflare (believed only when REMOTE_ADDR is Cloudflare's).
|
// The visitor behind Cloudflare (believed only when REMOTE_ADDR is Cloudflare's).
|
||||||
'HTTP_CF_CONNECTING_IP' ])
|
'HTTP_CF_CONNECTING_IP' ])
|
||||||
env[k] = getenv(k);
|
env[k] = getenv(k);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Dawnline — the personal portal.
|
// Dawnline — the personal portal.
|
||||||
//
|
//
|
||||||
// GET /<code> the app shell
|
// GET /<code> the app shell
|
||||||
// GET /<code>/assets/<file> its script, styles and fonts
|
// GET /<code>/assets/<file> its script and styles (gzipped when the browser takes it)
|
||||||
// GET /<code>/api/state
|
// GET /<code>/api/state
|
||||||
// POST /<code>/api/devices { name, kind, public_key?, lan_bypass? }
|
// POST /<code>/api/devices { name, kind, public_key?, lan_bypass? }
|
||||||
// GET /<code>/api/devices/<id>/config
|
// GET /<code>/api/devices/<id>/config
|
||||||
@@ -45,7 +45,7 @@ import { _ } from 'dawnline.i18n';
|
|||||||
|
|
||||||
const RATE = `${RUN_DIR}/portal-rate.json`;
|
const RATE = `${RUN_DIR}/portal-rate.json`;
|
||||||
const ASSETS = '/usr/share/dawnline/portal/assets';
|
const ASSETS = '/usr/share/dawnline/portal/assets';
|
||||||
const TYPES = { js: 'text/javascript', css: 'text/css', svg: 'image/svg+xml', woff2: 'font/woff2', png: 'image/png' };
|
const TYPES = { js: 'text/javascript', css: 'text/css', png: 'image/png' };
|
||||||
const FAIL_LIMIT = 8;
|
const FAIL_LIMIT = 8;
|
||||||
const FAIL_WINDOW = 900;
|
const FAIL_WINDOW = 900;
|
||||||
// All Cloudflare visitors together (three-word codes can't be guessed anyway).
|
// All Cloudflare visitors together (three-word codes can't be guessed anyway).
|
||||||
@@ -263,24 +263,26 @@ function place(r) {
|
|||||||
|
|
||||||
/** The app shell; it reads the code from its own URL and sends it along. */
|
/** The app shell; it reads the code from its own URL and sends it along. */
|
||||||
function shell(r) {
|
function shell(r) {
|
||||||
// The build's time joins the version so every update busts the hour-long asset cache.
|
// The build's time joins the version: every update gives the assets new URLs, so they are cached for good.
|
||||||
let v = `?v=${VERSION}.${stat(`${ASSETS}/portal.js`)?.mtime ?? 0}`;
|
let v = `?v=${VERSION}.${stat(`${ASSETS}/portal.js`)?.mtime ?? 0}`;
|
||||||
let base = r.base, title = place(r);
|
let base = r.base, title = place(r);
|
||||||
|
// The icon goes in the page: a request of its own would start another CGI process.
|
||||||
|
let icon = readfile(`${ASSETS}/icon.svg`);
|
||||||
|
let favicon = icon ? `<link rel="icon" href="data:image/svg+xml;base64,${b64enc(icon)}" type="image/svg+xml">\n` : '';
|
||||||
headers(r, '200 OK', {
|
headers(r, '200 OK', {
|
||||||
'Content-Type': 'text/html; charset=utf-8',
|
'Content-Type': 'text/html; charset=utf-8',
|
||||||
'Content-Security-Policy': "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data: blob:; font-src 'self'; " +
|
'Content-Security-Policy': "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data: blob:; " +
|
||||||
"connect-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'",
|
"connect-src 'self'; base-uri 'none'; form-action 'self'; frame-ancestors 'none'",
|
||||||
});
|
});
|
||||||
r.io.write(`<!doctype html>
|
r.io.write(`<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
|
||||||
<meta name="color-scheme" content="light dark">
|
<meta name="color-scheme" content="light dark">
|
||||||
<meta name="robots" content="noindex, nofollow">
|
<meta name="robots" content="noindex, nofollow">
|
||||||
<title>${html_escape(title)}</title>
|
<title>${html_escape(title)}</title>
|
||||||
<link rel="icon" href="${base}/assets/icon.svg${v}" type="image/svg+xml">
|
${favicon}<link rel="stylesheet" href="${base}/assets/portal.css${v}">
|
||||||
<link rel="stylesheet" href="${base}/assets/portal.css${v}">
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app" data-base="${html_escape(base)}" data-title="${html_escape(title)}"></div>
|
<div id="app" data-base="${html_escape(base)}" data-title="${html_escape(title)}"></div>
|
||||||
@@ -291,13 +293,18 @@ function shell(r) {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Script, styles, icon and fonts (kept outside the web root). */
|
/** Script and styles (kept outside the web root); the shell's ?v= changes with every build, so they never go stale. */
|
||||||
function asset(r, name) {
|
function asset(r, name) {
|
||||||
let ext = match(name, /^[a-z0-9-]+\.(js|css|svg|woff2|png)$/)?.[1];
|
let ext = match(name, /^[a-z0-9-]+\.(js|css|png)$/)?.[1];
|
||||||
let data = ext ? readfile(`${ASSETS}/${name}`) : null;
|
// The build keeps a gzipped copy beside each: a third of the bytes for a browser that takes it.
|
||||||
|
let gz = ext && r.gzip ? readfile(`${ASSETS}/${name}.gz`) : null;
|
||||||
|
let data = gz ?? (ext ? readfile(`${ASSETS}/${name}`) : null);
|
||||||
if (data == null)
|
if (data == null)
|
||||||
not_found(r);
|
not_found(r);
|
||||||
headers(r, '200 OK', { 'Content-Type': TYPES[ext], 'Cache-Control': 'private, max-age=3600' });
|
let h = { 'Content-Type': TYPES[ext], 'Cache-Control': 'private, max-age=31536000, immutable', 'Vary': 'Accept-Encoding' };
|
||||||
|
if (gz != null)
|
||||||
|
h['Content-Encoding'] = 'gzip';
|
||||||
|
headers(r, '200 OK', h);
|
||||||
r.io.write(data);
|
r.io.write(data);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@@ -519,6 +526,7 @@ export function handle(io) {
|
|||||||
hsts: https && (match(host, /:([0-9]+)$/)?.[1] ?? '443') == '443',
|
hsts: https && (match(host, /:([0-9]+)$/)?.[1] ?? '443') == '443',
|
||||||
person: null,
|
person: null,
|
||||||
base: '',
|
base: '',
|
||||||
|
gzip: match(lc(header('accept-encoding') ?? ''), /(^|[ ,])gzip([ ;,]|$)/) != null,
|
||||||
};
|
};
|
||||||
let segs = filter(split(path, '/'), (s) => s != '');
|
let segs = filter(split(path, '/'), (s) => s != '');
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
|
import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs';
|
||||||
import { _ } from 'dawnline.i18n';
|
import { _ } from 'dawnline.i18n';
|
||||||
|
|
||||||
export const VERSION = '0.14.0';
|
export const VERSION = '0.16.0';
|
||||||
/** GitHub repository with Dawnline releases (updates and the installer). */
|
/** GitHub repository with Dawnline releases (updates and the installer). */
|
||||||
export const REPO = 'tickcount/luci-app-dawnline';
|
export const REPO = 'tickcount/luci-app-dawnline';
|
||||||
export const RUN_DIR = '/var/run/dawnline';
|
export const RUN_DIR = '/var/run/dawnline';
|
||||||
|
|||||||
@@ -16,4 +16,4 @@ Read with `code-standards.md` and, for anything visible, `ui-design.md` and `i18
|
|||||||
|
|
||||||
## Checks
|
## Checks
|
||||||
|
|
||||||
- In `web/`: `npm run format:check`, `npm run typecheck`, `npm run i18n:check`, `npm test`, `npm run build`; the rebuilt bundles under `package/` and the catalogs are committed (CI fails otherwise).
|
- In `web/`: `npm run format:check`, `npm run typecheck`, `npm run lint`, `npm run knip`, `npm run i18n:check`, `npm test`, `npm run build`; the catalogs are committed, the bundles under `package/` are git-ignored (CI builds them before packaging).
|
||||||
@@ -17,6 +17,11 @@ APK_SDK="${APK_SDK:-itdoginfo/openwrt-sdk-apk:25.12.3}"
|
|||||||
grep -q "^export const VERSION = '$VERSION';" "$APP/root/usr/share/ucode/dawnline/util.uc" || { echo "util.uc VERSION != $VERSION" >&2; exit 1; }
|
grep -q "^export const VERSION = '$VERSION';" "$APP/root/usr/share/ucode/dawnline/util.uc" || { echo "util.uc VERSION != $VERSION" >&2; exit 1; }
|
||||||
grep -q "\"version\": \"$VERSION\"" "$ROOT/web/package.json" || { echo "web/package.json version != $VERSION" >&2; exit 1; }
|
grep -q "\"version\": \"$VERSION\"" "$ROOT/web/package.json" || { echo "web/package.json version != $VERSION" >&2; exit 1; }
|
||||||
|
|
||||||
|
# The web bundles are not committed: web/ builds them (npm run build).
|
||||||
|
for f in htdocs/luci-static/resources/dawnline/app.js root/usr/share/dawnline/portal/assets/portal.js root/usr/share/dawnline/portal/assets/portal.css; do
|
||||||
|
[ -f "$APP/$f" ] || { echo "$APP/$f is missing: run 'npm run build' in web/" >&2; exit 1; }
|
||||||
|
done
|
||||||
|
|
||||||
mkdir -p "$OUT"
|
mkdir -p "$OUT"
|
||||||
build() {
|
build() {
|
||||||
local type="$1" sdk="$2" tag="dawnline-build:$1"
|
local type="$1" sdk="$2" tag="dawnline-build:$1"
|
||||||
|
|||||||
@@ -18,6 +18,10 @@ grep -q "PKG_VERSION:=$VERSION\$" "$APP/Makefile" || { echo "Makefile PKG_VERSIO
|
|||||||
grep -q "\"version\": \"$VERSION\"" "$ROOT/web/package.json" || { echo "web/package.json version != $VERSION" >&2; exit 1; }
|
grep -q "\"version\": \"$VERSION\"" "$ROOT/web/package.json" || { echo "web/package.json version != $VERSION" >&2; exit 1; }
|
||||||
|
|
||||||
[ "${SKIP_WEB:-0}" = 1 ] || (cd "$ROOT/web" && npm run --silent ci)
|
[ "${SKIP_WEB:-0}" = 1 ] || (cd "$ROOT/web" && npm run --silent ci)
|
||||||
|
# With SKIP_WEB=1 the bundles come from an earlier build (they are not committed).
|
||||||
|
for f in htdocs/luci-static/resources/dawnline/app.js root/usr/share/dawnline/portal/assets/portal.js root/usr/share/dawnline/portal/assets/portal.css; do
|
||||||
|
[ -f "$APP/$f" ] || { echo "$APP/$f is missing: run 'npm run build' in web/" >&2; exit 1; }
|
||||||
|
done
|
||||||
|
|
||||||
mkdir -p "$STAGE/www" "$OUT"
|
mkdir -p "$STAGE/www" "$OUT"
|
||||||
cp -R "$APP/root/." "$STAGE/"
|
cp -R "$APP/root/." "$STAGE/"
|
||||||
|
|||||||
@@ -133,13 +133,14 @@ const prelude = (lang, db) => `(() => {
|
|||||||
});
|
});
|
||||||
addEventListener('DOMContentLoaded', () => {
|
addEventListener('DOMContentLoaded', () => {
|
||||||
const s = document.createElement('style');
|
const s = document.createElement('style');
|
||||||
// The demo's chip and GitHub pill go, and the path takes the row again, as on a router's page.
|
// The demo's chip, GitHub knob and set-up state switch go, and the path takes the row again, as on a router's
|
||||||
s.textContent = '.dm-chip, .dm-gh { display: none !important; } .cr-path { flex: 1 !important; }';
|
// page.
|
||||||
|
s.textContent = '.dm-chip, .dm-gh, .dm-way { display: none !important; } .cr-path { flex: 1 !important; }';
|
||||||
document.head.append(s);
|
document.head.append(s);
|
||||||
});
|
});
|
||||||
})()`;
|
})()`;
|
||||||
|
|
||||||
const TYPES = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.svg': 'image/svg+xml', '.woff2': 'font/woff2' };
|
const TYPES = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.svg': 'image/svg+xml' };
|
||||||
|
|
||||||
/** Answer the page's requests from the demo build: its page for the personal link, its files by name. */
|
/** Answer the page's requests from the demo build: its page for the personal link, its files by name. */
|
||||||
async function serve(page) {
|
async function serve(page) {
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import tempfile
|
|||||||
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
|
||||||
RAW = os.path.join(ROOT, 'docs', 'screenshots', 'raw')
|
RAW = os.path.join(ROOT, 'docs', 'screenshots', 'raw')
|
||||||
OUT = os.path.join(ROOT, 'docs', 'screenshots')
|
OUT = os.path.join(ROOT, 'docs', 'screenshots')
|
||||||
FONT = os.path.join(ROOT, 'package', 'luci-app-dawnline', 'root', 'usr', 'share', 'dawnline', 'portal', 'assets',
|
|
||||||
'geist-latin-wght-normal.woff2')
|
|
||||||
|
|
||||||
SHOTS = ['overview', 'people', 'person', 'portal', 'overview-ru', 'people-ru', 'person-ru', 'portal-ru']
|
SHOTS = ['overview', 'people', 'person', 'portal', 'overview-ru', 'people-ru', 'person-ru', 'portal-ru']
|
||||||
# name -> the steps in front of its page, in order (raw captures). The portal's come from its demo
|
# name -> the steps in front of its page, in order (raw captures). The portal's come from its demo
|
||||||
@@ -47,7 +45,6 @@ CANDIDATES = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
TEMPLATE = """<!doctype html><html><head><meta charset="utf-8"><style>
|
TEMPLATE = """<!doctype html><html><head><meta charset="utf-8"><style>
|
||||||
@font-face{{font-family:Geist;src:url('file://{font}') format('woff2');font-weight:100 900}}
|
|
||||||
html,body{{margin:0;width:{w}px;height:{h}px;overflow:hidden}}
|
html,body{{margin:0;width:{w}px;height:{h}px;overflow:hidden}}
|
||||||
body{{position:relative;background:#080808}}
|
body{{position:relative;background:#080808}}
|
||||||
.panel{{position:absolute;left:{px}px;top:{py}px;width:{pw}px;height:{ph}px;
|
.panel{{position:absolute;left:{px}px;top:{py}px;width:{pw}px;height:{ph}px;
|
||||||
@@ -56,7 +53,7 @@ body{{position:relative;background:#080808}}
|
|||||||
box-shadow:0 0 0 1px rgba(255,255,255,.04)}}
|
box-shadow:0 0 0 1px rgba(255,255,255,.04)}}
|
||||||
.sheet{{position:absolute;display:block;filter:drop-shadow(0 24px 48px rgba(0,0,0,.6))}}
|
.sheet{{position:absolute;display:block;filter:drop-shadow(0 24px 48px rgba(0,0,0,.6))}}
|
||||||
.n{{position:absolute;width:34px;height:34px;border-radius:50%;display:grid;place-items:center;
|
.n{{position:absolute;width:34px;height:34px;border-radius:50%;display:grid;place-items:center;
|
||||||
font:600 16px Geist,sans-serif;color:#ededed;background:#232323;
|
font:600 16px system-ui,-apple-system,sans-serif;color:#ededed;background:#232323;
|
||||||
box-shadow:0 0 0 1px rgba(255,255,255,.12),0 6px 16px rgba(0,0,0,.5)}}
|
box-shadow:0 0 0 1px rgba(255,255,255,.12),0 6px 16px rgba(0,0,0,.5)}}
|
||||||
</style></head><body><div class="panel"></div><img class="page" src="file://{src}">{steps}</body></html>"""
|
</style></head><body><div class="panel"></div><img class="page" src="file://{src}">{steps}</body></html>"""
|
||||||
|
|
||||||
@@ -113,7 +110,7 @@ def main():
|
|||||||
html = os.path.join(tmp, f'{name}.html')
|
html = os.path.join(tmp, f'{name}.html')
|
||||||
with open(html, 'w', encoding='utf-8') as f:
|
with open(html, 'w', encoding='utf-8') as f:
|
||||||
f.write(TEMPLATE.format(w=w, h=h, x=x, y=y, iw=iw, ih=ih, px=x - INSET, py=y - INSET, pw=iw + 2 * INSET,
|
f.write(TEMPLATE.format(w=w, h=h, x=x, y=y, iw=iw, ih=ih, px=x - INSET, py=y - INSET, pw=iw + 2 * INSET,
|
||||||
ph=ih + 2 * INSET, src=src, font=FONT, steps=steps))
|
ph=ih + 2 * INSET, src=src, steps=steps))
|
||||||
out = os.path.join(OUT, f'{name}.png')
|
out = os.path.join(OUT, f'{name}.png')
|
||||||
subprocess.run([browser, '--headless=new', '--disable-gpu', '--hide-scrollbars', '--allow-file-access-from-files',
|
subprocess.run([browser, '--headless=new', '--disable-gpu', '--hide-scrollbars', '--allow-file-access-from-files',
|
||||||
f'--force-device-scale-factor={SCALE}', f'--window-size={w},{h}', f'--screenshot={out}', f'file://{html}'],
|
f'--force-device-scale-factor={SCALE}', f'--window-size={w},{h}', f'--screenshot={out}', f'file://{html}'],
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
// usr/libexec/dawnline/updater: a call without a command it knows prints the usage and changes nothing (no job for
|
||||||
|
// Components, no history, no "update failed" in the service log).
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
|
const REPO = `${sourcepath(0, true)}/../..`;
|
||||||
|
const UPDATER = `${REPO}/package/luci-app-dawnline/root/usr/libexec/dawnline/updater`;
|
||||||
|
const MODULES = `${REPO}/package/luci-app-dawnline/root/usr/share/ucode/*.uc`;
|
||||||
|
const JOB = '/var/run/dawnline/update-job.json';
|
||||||
|
|
||||||
|
/** The updater run with `args`: { code, out } (stdout and stderr together). */
|
||||||
|
function updater(args) {
|
||||||
|
let p = fs.popen(`ucode -L '${MODULES}' '${UPDATER}' ${args} 2>&1; echo "exit=$?"`, 'r');
|
||||||
|
let out = p.read('all') ?? '';
|
||||||
|
p.close();
|
||||||
|
let m = match(out, /exit=([0-9]+)\s*$/);
|
||||||
|
return { code: m ? +m[1] : -1, out: replace(out, /exit=[0-9]+\s*$/, '') };
|
||||||
|
}
|
||||||
|
|
||||||
|
test('without a command it knows: the usage, nothing written', () => {
|
||||||
|
for (let args in [ '', 'frobnicate', 'install', "install ''" ]) {
|
||||||
|
fs.unlink(JOB);
|
||||||
|
let r = updater(args);
|
||||||
|
eq(r.code, 2, `exit code for "${args}"`);
|
||||||
|
ok(index(r.out, 'Usage:') == 0, `usage for "${args}"`);
|
||||||
|
ok(index(r.out, 'updater install app | app@<tag>') > 0, `the commands for "${args}"`);
|
||||||
|
ok(!fs.access(JOB), `no job for "${args}"`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test('asked for help: the usage, exit 0', () => {
|
||||||
|
for (let args in [ '-h', '--help', 'help' ]) {
|
||||||
|
let r = updater(args);
|
||||||
|
eq(r.code, 0, `exit code for "${args}"`);
|
||||||
|
ok(index(r.out, 'Usage:') == 0, `usage for "${args}"`);
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
coverage/
|
coverage/
|
||||||
package-lock.json
|
package-lock.json
|
||||||
src/portal/fonts/
|
|
||||||
src/admin/styles/*.css
|
src/admin/styles/*.css
|
||||||
dist/
|
dist/
|
||||||
@@ -31,7 +31,9 @@ import fs from 'node:fs';
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import * as prettier from 'prettier';
|
import * as prettier from 'prettier';
|
||||||
import ts from 'typescript';
|
import * as ts from 'typescript/unstable/ast';
|
||||||
|
import { createVirtualFileSystem } from 'typescript/unstable/fs';
|
||||||
|
import { API } from 'typescript/unstable/sync';
|
||||||
import { keyOf, parsePo, pluralForms, translated, writePo, type Entry, type Po } from './po.ts';
|
import { keyOf, parsePo, pluralForms, translated, writePo, type Entry, type Po } from './po.ts';
|
||||||
|
|
||||||
const WEB = path.resolve(import.meta.dirname, '..');
|
const WEB = path.resolve(import.meta.dirname, '..');
|
||||||
@@ -149,14 +151,39 @@ class Errors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isFunctionLike(n: ts.Node): boolean {
|
function isFunctionLike(n: ts.Node): boolean {
|
||||||
return ts.isFunctionLike(n) || ts.isPropertyDeclaration(n) || ts.isClassStaticBlockDeclaration(n);
|
return ts.isFunctionLikeDeclaration(n) || ts.isPropertyDeclaration(n) || ts.isClassStaticBlockDeclaration(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The syntax trees of the files, parsed in one run by TypeScript 7 (its JS API
|
||||||
|
* drives the native compiler, tsgo). They go to it as a virtual project, ucode
|
||||||
|
* as JavaScript: nothing else is read, no import followed, no type checked.
|
||||||
|
*/
|
||||||
|
function parseAll(files: string[]): Map<string, ts.SourceFile> {
|
||||||
|
const name = (f: string) => (f.endsWith('.ts') ? f : `${f}.js`);
|
||||||
|
const config = '/dawnline-i18n/tsconfig.json';
|
||||||
|
const vfs: Record<string, string> = {
|
||||||
|
[config]: JSON.stringify({ compilerOptions: { allowJs: true, noLib: true, noResolve: true, types: [] }, files: files.map(name) }),
|
||||||
|
};
|
||||||
|
for (const f of files) vfs[name(f)] = fs.readFileSync(f, 'utf8');
|
||||||
|
const api = new API({ cwd: WEB, fs: createVirtualFileSystem(vfs) });
|
||||||
|
try {
|
||||||
|
const program = api.updateSnapshot({ openProjects: [config] }).getProject(config)?.program;
|
||||||
|
if (!program) throw new Error('TypeScript did not open the virtual project');
|
||||||
|
return new Map(
|
||||||
|
files.map((f) => {
|
||||||
|
const sf = program.getSourceFile(name(f));
|
||||||
|
if (!sf) throw new Error(`TypeScript did not parse ${rel(f)}`);
|
||||||
|
return [f, sf];
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
} finally {
|
||||||
|
api.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Every translation call in one file. */
|
/** Every translation call in one file. */
|
||||||
function scan(file: string, lazy: boolean, logs: boolean, errors: Errors, out: Found[]) {
|
function scan(file: string, sf: ts.SourceFile, lazy: boolean, logs: boolean, errors: Errors, out: Found[]) {
|
||||||
const text = fs.readFileSync(file, 'utf8');
|
|
||||||
const kind = file.endsWith('.ts') ? ts.ScriptKind.TS : ts.ScriptKind.JS;
|
|
||||||
const sf = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, kind);
|
|
||||||
const wrapper = WRAPPERS.has(file);
|
const wrapper = WRAPPERS.has(file);
|
||||||
const visit = (node: ts.Node) => {
|
const visit = (node: ts.Node) => {
|
||||||
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && CALLS[node.expression.text] && !wrapper) {
|
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && CALLS[node.expression.text] && !wrapper) {
|
||||||
@@ -201,7 +228,7 @@ function scan(file: string, lazy: boolean, logs: boolean, errors: Errors, out: F
|
|||||||
out.push(e);
|
out.push(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ts.forEachChild(node, visit);
|
node.forEachChild(visit);
|
||||||
};
|
};
|
||||||
visit(sf);
|
visit(sf);
|
||||||
}
|
}
|
||||||
@@ -213,9 +240,9 @@ function scanMenu(file: string, out: Found[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** One catalog's strings, deduplicated and sorted (by code unit: the same order on every machine). */
|
/** One catalog's strings, deduplicated and sorted (by code unit: the same order on every machine). */
|
||||||
function collect(spec: CatalogSpec, errors: Errors): Entry[] {
|
function collect(spec: CatalogSpec, trees: Map<string, ts.SourceFile>, errors: Errors): Entry[] {
|
||||||
const found: Found[] = [];
|
const found: Found[] = [];
|
||||||
for (const f of spec.sources()) scan(f, spec.lazy(f), !!spec.logs, errors, found);
|
for (const f of spec.sources()) scan(f, trees.get(f)!, spec.lazy(f), !!spec.logs, errors, found);
|
||||||
for (const f of spec.menus?.() ?? []) scanMenu(f, found);
|
for (const f of spec.menus?.() ?? []) scanMenu(f, found);
|
||||||
const byKey = new Map<string, Found>();
|
const byKey = new Map<string, Found>();
|
||||||
for (const e of found) {
|
for (const e of found) {
|
||||||
@@ -316,7 +343,8 @@ async function main() {
|
|||||||
}
|
}
|
||||||
const usedDrafts = new Set<string>();
|
const usedDrafts = new Set<string>();
|
||||||
|
|
||||||
const collected = CATALOGS.map((spec) => ({ spec, entries: collect(spec, errors) }));
|
const trees = parseAll([...new Set(CATALOGS.flatMap((spec) => spec.sources()))]);
|
||||||
|
const collected = CATALOGS.map((spec) => ({ spec, entries: collect(spec, trees, errors) }));
|
||||||
const only = opt.only.map((f) => rel(path.resolve(f)));
|
const only = opt.only.map((f) => rel(path.resolve(f)));
|
||||||
const under = (r: string) => only.some((o) => r === o || r.startsWith(`${o}/`));
|
const under = (r: string) => only.some((o) => r === o || r.startsWith(`${o}/`));
|
||||||
// Linting some files: the problems of those (other files may be half-way through a change).
|
// Linting some files: the problems of those (other files may be half-way through a change).
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dawnline-web",
|
"name": "dawnline-web",
|
||||||
"version": "0.14.0",
|
"version": "0.16.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -12,18 +12,27 @@
|
|||||||
"test": "vitest run",
|
"test": "vitest run",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
"format:check": "prettier --check .",
|
"format:check": "prettier --check .",
|
||||||
"ci": "npm run format:check && npm run typecheck && npm run i18n:check && npm run test && npm run build",
|
"lint": "oxlint --deny-warnings",
|
||||||
|
"knip": "knip",
|
||||||
|
"ci": "npm run format:check && npm run typecheck && npm run lint && npm run knip && npm run i18n:check && npm run test && npm run build",
|
||||||
"i18n": "node i18n/extract.ts",
|
"i18n": "node i18n/extract.ts",
|
||||||
"i18n:check": "node i18n/extract.ts --check"
|
"i18n:check": "node i18n/extract.ts --check"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"qrcode-generator": "1.4.4"
|
"qrcode-generator": "2.0.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "22.20.5",
|
"@types/node": "26.6.5",
|
||||||
"prettier": "3.6.2",
|
"esbuild": "0.28.2",
|
||||||
"tsup": "8.5.0",
|
"knip": "6.43.0",
|
||||||
"typescript": "5.9.3",
|
"oxlint": "1.89.0",
|
||||||
"vitest": "3.2.4"
|
"prettier": "3.9.10",
|
||||||
|
"tsup": "9.0.0",
|
||||||
|
"typescript": "7.0.2",
|
||||||
|
"vitest": "5.0.5"
|
||||||
|
},
|
||||||
|
"allowScripts": {
|
||||||
|
"esbuild@0.28.2": true,
|
||||||
|
"fsevents@2.3.3": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ import { fmt, plural } from '../shared/i18n';
|
|||||||
type Service = Status['services'][number];
|
type Service = Status['services'][number];
|
||||||
|
|
||||||
/** Circle colours; the circle stores an index. */
|
/** Circle colours; the circle stores an index. */
|
||||||
export const CIRCLE_COLORS = ['#3a83f7', '#a78bfa', '#f472b6', '#f59e0b', '#10b981', '#22d3ee', '#ef4444', '#84cc16'];
|
const CIRCLE_COLORS = ['#3a83f7', '#a78bfa', '#f472b6', '#f59e0b', '#10b981', '#22d3ee', '#ef4444', '#84cc16'];
|
||||||
|
|
||||||
export const circleDot = (c: Circle | undefined) =>
|
export const circleDot = (c: Circle | undefined) =>
|
||||||
E('i', { class: 'dl-circle-dot', style: `background:${CIRCLE_COLORS[c?.color ?? 0] ?? CIRCLE_COLORS[0]}` });
|
E('i', { class: 'dl-circle-dot', style: `background:${CIRCLE_COLORS[c?.color ?? 0] ?? CIRCLE_COLORS[0]}` });
|
||||||
@@ -26,7 +26,7 @@ export const homeAccess = (p: Person) => p.access === 'both' || (p.access === 'l
|
|||||||
|
|
||||||
/* ---------- Home services ---------- */
|
/* ---------- Home services ---------- */
|
||||||
|
|
||||||
export function serviceDialog(sv: Service | null, prefill: Partial<Service>, onSaved: () => unknown) {
|
function serviceDialog(sv: Service | null, prefill: Partial<Service>, onSaved: () => unknown) {
|
||||||
const name = input(sv?.name ?? prefill.name ?? '', { placeholder: _('NAS') });
|
const name = input(sv?.name ?? prefill.name ?? '', { placeholder: _('NAS') });
|
||||||
const addr = input(sv?.address ?? prefill.address ?? '', { placeholder: '192.168.1.10', class: 'cbi-input-text dl-mono' });
|
const addr = input(sv?.address ?? prefill.address ?? '', { placeholder: '192.168.1.10', class: 'cbi-input-text dl-mono' });
|
||||||
const ports = input((sv?.ports ?? prefill.ports ?? []).join(', '), {
|
const ports = input((sv?.ports ?? prefill.ports ?? []).join(', '), {
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ export interface LogsInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The path that makes tunnel clients' internet traffic enter from the LAN. */
|
/** The path that makes tunnel clients' internet traffic enter from the LAN. */
|
||||||
export interface LikeHome {
|
interface LikeHome {
|
||||||
active: boolean;
|
active: boolean;
|
||||||
dev?: string;
|
dev?: string;
|
||||||
address?: string;
|
address?: string;
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ export function plainWg(cfg: AwgConfig): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** File / key / QR switcher for a client configuration; opens on the file unless asked otherwise. */
|
/** File / key / QR switcher for a client configuration; opens on the file unless asked otherwise. */
|
||||||
export async function connectBlock(cfg: AwgConfig, initial: 'file' | 'key' | 'qr' = 'file'): Promise<HTMLElement> {
|
async function connectBlock(cfg: AwgConfig, initial: 'file' | 'key' | 'qr' = 'file'): Promise<HTMLElement> {
|
||||||
if (!cfg.has_private_key)
|
if (!cfg.has_private_key)
|
||||||
return E(
|
return E(
|
||||||
'div',
|
'div',
|
||||||
@@ -297,7 +297,7 @@ async function applyDisguise(ctx: CoreCtx, srv: Server, m: Method, same: boolean
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Server → AmneziaWG: listening port, what goes into every configuration, disguise, tunnel. */
|
/** Server → AmneziaWG: listening port, what goes into every configuration, disguise, tunnel. */
|
||||||
export function settingsCard(ctx: CoreCtx, srv: Server): HTMLElement {
|
function settingsCard(ctx: CoreCtx, srv: Server): HTMLElement {
|
||||||
const st: Status = ctx.st;
|
const st: Status = ctx.st;
|
||||||
const port = input(String(srv.port), { inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' });
|
const port = input(String(srv.port), { inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' });
|
||||||
const mtu = input(srv.mtu ? String(srv.mtu) : '', {
|
const mtu = input(srv.mtu ? String(srv.mtu) : '', {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import type { Server } from '../../shared/types';
|
|||||||
import type { Core } from './common';
|
import type { Core } from './common';
|
||||||
import { awg } from './awg';
|
import { awg } from './awg';
|
||||||
|
|
||||||
export type { Core, CoreCtx } from './common';
|
export type { Core } from './common';
|
||||||
|
|
||||||
const CORES: Record<string, Core> = { awg };
|
const CORES: Record<string, Core> = { awg };
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { fmt } from '../shared/i18n';
|
|||||||
|
|
||||||
export type Method = 'balanced' | 'max' | 'off';
|
export type Method = 'balanced' | 'max' | 'off';
|
||||||
/** The router features a method may need (the boolean ones of AwgCaps). */
|
/** The router features a method may need (the boolean ones of AwgCaps). */
|
||||||
export type AwgNeed = 'v2' | 'v3';
|
type AwgNeed = 'v2' | 'v3';
|
||||||
|
|
||||||
export interface MethodInfo {
|
export interface MethodInfo {
|
||||||
id: Method;
|
id: Method;
|
||||||
@@ -26,7 +26,7 @@ export interface MethodInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The methods in picker order, in the page's language. */
|
/** The methods in picker order, in the page's language. */
|
||||||
export function methods(): MethodInfo[] {
|
function methods(): MethodInfo[] {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
id: 'off',
|
id: 'off',
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ async function toPng(svg: string): Promise<Blob> {
|
|||||||
type Invitee = Pick<Person, 'id' | 'name'> & { link?: string | null; links?: string[] };
|
type Invitee = Pick<Person, 'id' | 'name'> & { link?: string | null; links?: string[] };
|
||||||
|
|
||||||
/** The personal link and its other addresses (person_links); null while the portal is off. */
|
/** The personal link and its other addresses (person_links); null while the portal is off. */
|
||||||
export async function personLinks(id: string): Promise<{ link: string; links: string[] } | null> {
|
async function personLinks(id: string): Promise<{ link: string; links: string[] } | null> {
|
||||||
const r = await attempt(() => api.personLinks(id));
|
const r = await attempt(() => api.personLinks(id));
|
||||||
if (!r) return null;
|
if (!r) return null;
|
||||||
if (!r.link) {
|
if (!r.link) {
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ export interface MapData {
|
|||||||
* The latest point per device inside the time window: per device and city on a
|
* The latest point per device inside the time window: per device and city on a
|
||||||
* person's page, per city in a device's window.
|
* person's page, per city in a device's window.
|
||||||
*/
|
*/
|
||||||
export function visiblePoints(data: MapData, range: Range): GeoPoint[] {
|
function visiblePoints(data: MapData, range: Range): GeoPoint[] {
|
||||||
const best = new Map<string, GeoPoint>();
|
const best = new Map<string, GeoPoint>();
|
||||||
for (const p of data.geo.points) {
|
for (const p of data.geo.points) {
|
||||||
if (data.person && p.person !== data.person) continue;
|
if (data.person && p.person !== data.person) continue;
|
||||||
@@ -1233,7 +1233,7 @@ function face(slot: { el: HTMLElement; at: [number, number]; who?: string; where
|
|||||||
* when `quiet`: a redraw), gone ones leave the row at once and shrink away where they were, the
|
* when `quiet`: a redraw), gone ones leave the row at once and shrink away where they were, the
|
||||||
* "+N" is one element whose number changes, and the plate's width follows smoothly.
|
* "+N" is one element whose number changes, and the plate's width follows smoothly.
|
||||||
*/
|
*/
|
||||||
export function fillFaces(
|
function fillFaces(
|
||||||
box: HTMLElement,
|
box: HTMLElement,
|
||||||
faces: Face[],
|
faces: Face[],
|
||||||
on: { click: (f: Face, b: HTMLElement) => void; hover: (f: Face | null) => void },
|
on: { click: (f: Face, b: HTMLElement) => void; hover: (f: Face | null) => void },
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ export function portalPortHelp(port: number, taken: PortHold[], ipLinks: boolean
|
|||||||
export const chars = (s: string): number => Array.from(s).length;
|
export const chars = (s: string): number => Array.from(s).length;
|
||||||
|
|
||||||
const NAME_MAX = 48;
|
const NAME_MAX = 48;
|
||||||
|
// oxlint-disable-next-line no-control-regex -- control characters are what it refuses
|
||||||
const BAD_NAME = /[<>"\\\u0000-\u001f\u007f]/;
|
const BAD_NAME = /[<>"\\\u0000-\u001f\u007f]/;
|
||||||
|
|
||||||
/** "Up to 48 characters (50 now).": a name over its limit. */
|
/** "Up to 48 characters (50 now).": a name over its limit. */
|
||||||
@@ -147,7 +148,7 @@ export function isIpv4(s: string): boolean {
|
|||||||
return !!m && m.slice(1).every((x) => Number(x) <= 255);
|
return !!m && m.slice(1).every((x) => Number(x) <= 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isIpv6(s: string): boolean {
|
function isIpv6(s: string): boolean {
|
||||||
return /^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/.test(s) && !/:::/.test(s);
|
return /^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$/.test(s) && !/:::/.test(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,7 +162,7 @@ export function hostHelp(s: string, port?: number, empty: string | null = null):
|
|||||||
if (!t) return empty != null ? { text: empty, bad: false } : { text: _('Enter a hostname or IP address.'), bad: true };
|
if (!t) return empty != null ? { text: empty, bad: false } : { text: _('Enter a hostname or IP address.'), bad: true };
|
||||||
if (/^[a-z]+:\/\//i.test(t)) return { text: _('Leave out https:// - just the name.'), bad: true };
|
if (/^[a-z]+:\/\//i.test(t)) return { text: _('Leave out https:// - just the name.'), bad: true };
|
||||||
if (/\/.*/.test(t)) return { text: _('Just the name, without a path.'), bad: true };
|
if (/\/.*/.test(t)) return { text: _('Just the name, without a path.'), bad: true };
|
||||||
if (/^[^:\[]+:\d+$/.test(t)) return { text: _('Just the name, without a port (the port is on AmneziaWG).'), bad: true };
|
if (/^[^:[]+:\d+$/.test(t)) return { text: _('Just the name, without a port (the port is on AmneziaWG).'), bad: true };
|
||||||
if (/\s/.test(t)) return { text: _('A hostname has no spaces.'), bad: true };
|
if (/\s/.test(t)) return { text: _('A hostname has no spaces.'), bad: true };
|
||||||
if (t.length > 253 || !(HOSTNAME.test(t) || isIpv4(t) || isIpv6(t))) return { text: _('Use a hostname or an IP address.'), bad: true };
|
if (t.length > 253 || !(HOSTNAME.test(t) || isIpv4(t) || isIpv6(t))) return { text: _('Use a hostname or an IP address.'), bad: true };
|
||||||
const shown = isIpv6(t) ? `[${t}]` : t;
|
const shown = isIpv6(t) ? `[${t}]` : t;
|
||||||
|
|||||||
@@ -226,22 +226,21 @@ export class PeoplePage {
|
|||||||
render(stAll: Status): Promise<Node> {
|
render(stAll: Status): Promise<Node> {
|
||||||
const st = this.scope(stAll);
|
const st = this.scope(stAll);
|
||||||
this.st = st;
|
this.st = st;
|
||||||
const page = this;
|
|
||||||
const sort = E(
|
const sort = E(
|
||||||
'select',
|
'select',
|
||||||
{
|
{
|
||||||
class: 'dl-select',
|
class: 'dl-select',
|
||||||
'aria-label': _('Sort'),
|
'aria-label': _('Sort'),
|
||||||
change: (ev: Event) => {
|
change: (ev: Event) => {
|
||||||
page.sort = (ev.target as HTMLSelectElement).value as SortBy;
|
this.sort = (ev.target as HTMLSelectElement).value as SortBy;
|
||||||
remember('dl.people.sort', page.sort);
|
remember('dl.people.sort', this.sort);
|
||||||
page.decorate();
|
this.decorate();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
E('option', { value: 'seen', selected: page.sort === 'seen' ? 'selected' : null }, _('Last seen', 'sort')),
|
E('option', { value: 'seen', selected: this.sort === 'seen' ? 'selected' : null }, _('Last seen', 'sort')),
|
||||||
E('option', { value: 'name', selected: page.sort === 'name' ? 'selected' : null }, _('Name', 'sort')),
|
E('option', { value: 'name', selected: this.sort === 'name' ? 'selected' : null }, _('Name', 'sort')),
|
||||||
E('option', { value: 'usage', selected: page.sort === 'usage' ? 'selected' : null }, _('Usage', 'sort')),
|
E('option', { value: 'usage', selected: this.sort === 'usage' ? 'selected' : null }, _('Usage', 'sort')),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
// Find, once the list is long enough to need it; "/" focuses it.
|
// Find, once the list is long enough to need it; "/" focuses it.
|
||||||
@@ -252,8 +251,8 @@ export class PeoplePage {
|
|||||||
'aria-label': _('Find a person or device'),
|
'aria-label': _('Find a person or device'),
|
||||||
hidden: st.people.length > 8 ? null : 'hidden',
|
hidden: st.people.length > 8 ? null : 'hidden',
|
||||||
input: (ev: Event) => {
|
input: (ev: Event) => {
|
||||||
page.query = (ev.target as HTMLInputElement).value.trim().toLowerCase();
|
this.query = (ev.target as HTMLInputElement).value.trim().toLowerCase();
|
||||||
page.decorate();
|
this.decorate();
|
||||||
},
|
},
|
||||||
}) as HTMLInputElement;
|
}) as HTMLInputElement;
|
||||||
const onSlash = (ev: KeyboardEvent) => {
|
const onSlash = (ev: KeyboardEvent) => {
|
||||||
@@ -266,14 +265,14 @@ export class PeoplePage {
|
|||||||
document.addEventListener('keydown', onSlash);
|
document.addEventListener('keydown', onSlash);
|
||||||
onNavigate(() => document.removeEventListener('keydown', onSlash));
|
onNavigate(() => document.removeEventListener('keydown', onSlash));
|
||||||
const wrap = E('div', { class: 'dl-root' }, [
|
const wrap = E('div', { class: 'dl-root' }, [
|
||||||
page.serverId
|
this.serverId
|
||||||
? ''
|
? ''
|
||||||
: E('div', { class: 'dl-pagehead' }, [
|
: E('div', { class: 'dl-pagehead' }, [
|
||||||
E('div', { class: 'dl-stack' }, [
|
E('div', { class: 'dl-stack' }, [
|
||||||
E('h2', { class: 'dl-h1' }, _('People')),
|
E('h2', { class: 'dl-h1' }, _('People')),
|
||||||
E('span', { class: 'dl-muted dl-people-count' }, this.countText()),
|
E('span', { class: 'dl-muted dl-people-count' }, this.countText()),
|
||||||
]),
|
]),
|
||||||
st.servers.length ? button([icon('plus'), ` ${_('Add person')}`], () => page.openCreate(), 'add') : '',
|
st.servers.length ? button([icon('plus'), ` ${_('Add person')}`], () => this.openCreate(), 'add') : '',
|
||||||
]),
|
]),
|
||||||
st.servers.length
|
st.servers.length
|
||||||
? ''
|
? ''
|
||||||
@@ -291,7 +290,7 @@ export class PeoplePage {
|
|||||||
E('div', { class: 'dl-toolbar-end' }, [
|
E('div', { class: 'dl-toolbar-end' }, [
|
||||||
find,
|
find,
|
||||||
sort,
|
sort,
|
||||||
page.serverId ? button([icon('plus'), ` ${_('Add person')}`], () => page.openCreate(), 'add') : '',
|
this.serverId ? button([icon('plus'), ` ${_('Add person')}`], () => this.openCreate(), 'add') : '',
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
this.list,
|
this.list,
|
||||||
@@ -303,13 +302,13 @@ export class PeoplePage {
|
|||||||
fetch: () => api.status(30),
|
fetch: () => api.status(30),
|
||||||
every: 30,
|
every: 30,
|
||||||
live: true,
|
live: true,
|
||||||
active: () => !!page.el?.isConnected,
|
active: () => !!this.el?.isConnected,
|
||||||
apply: (st, quiet) => page.take(st, quiet),
|
apply: (st, quiet) => this.take(st, quiet),
|
||||||
});
|
});
|
||||||
// ?add=1 opens Add person once, not again on every server's People tab.
|
// ?add=1 opens Add person once, not again on every server's People tab.
|
||||||
if (!addOpened && new URLSearchParams(location.search).get('add')) {
|
if (!addOpened && new URLSearchParams(location.search).get('add')) {
|
||||||
addOpened = true;
|
addOpened = true;
|
||||||
setTimeout(() => page.openCreate(), 100);
|
setTimeout(() => this.openCreate(), 100);
|
||||||
}
|
}
|
||||||
return Promise.resolve(wrap);
|
return Promise.resolve(wrap);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ export function msAt(st: Stay[], steps: Step[], t: number): number {
|
|||||||
return step.start + step.ms * Math.min(0.999, Math.max(0, (t - s.from) / Math.max(1, s.to - s.from)));
|
return step.start + step.ms * Math.min(0.999, Math.max(0, (t - s.from) / Math.max(1, s.to - s.from)));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ease = (x: number) => (x <= 0 ? 0 : x >= 1 ? 1 : x < 0.5 ? 2 * x * x : 1 - (-2 * x + 2) ** 2 / 2);
|
const ease = (x: number) => (x <= 0 ? 0 : x >= 1 ? 1 : x < 0.5 ? 2 * x * x : 1 - (-2 * x + 2) ** 2 / 2);
|
||||||
|
|
||||||
/** The shimmer's middle (a share of the arc) `q` into a move: it enters before the place it leaves and runs out past the next. */
|
/** The shimmer's middle (a share of the arc) `q` into a move: it enters before the place it leaves and runs out past the next. */
|
||||||
export function bandMiddle(q: number): number {
|
export function bandMiddle(q: number): number {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const LOST_AFTER = 3;
|
|||||||
* Request tickets: an answer is shown only if nothing newer was shown before
|
* Request tickets: an answer is shown only if nothing newer was shown before
|
||||||
* it. `claim()` invalidates everything in flight (an edit's own answer wins).
|
* it. `claim()` invalidates everything in flight (an edit's own answer wins).
|
||||||
*/
|
*/
|
||||||
export class Sequence {
|
class Sequence {
|
||||||
private n = 0;
|
private n = 0;
|
||||||
private shown = 0;
|
private shown = 0;
|
||||||
next(): number {
|
next(): number {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import settings from './settings.css';
|
|||||||
import components from './components.css';
|
import components from './components.css';
|
||||||
import access from './access.css';
|
import access from './access.css';
|
||||||
|
|
||||||
export const CSS = [
|
const CSS = [
|
||||||
base,
|
base,
|
||||||
people,
|
people,
|
||||||
controls,
|
controls,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function pill(tone: string, text: string, title?: string): HTMLElement {
|
|||||||
return E('span', { class: `dl-pill ${tone}`, title: title ?? null }, text);
|
return E('span', { class: `dl-pill ${tone}`, title: title ?? null }, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stateTone(p: Person): string {
|
function stateTone(p: Person): string {
|
||||||
if (p.state === 'active') return 'ok';
|
if (p.state === 'active') return 'ok';
|
||||||
if (p.state === 'quota' || p.state === 'expired') return 'bad';
|
if (p.state === 'quota' || p.state === 'expired') return 'bad';
|
||||||
return 'warn';
|
return 'warn';
|
||||||
|
|||||||
@@ -107,12 +107,6 @@ export function chipToggle(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Mark a chip toggle on or off in place. */
|
|
||||||
export function setChip(b: HTMLElement, on: boolean) {
|
|
||||||
b.classList.toggle('on', on);
|
|
||||||
b.setAttribute('aria-pressed', on ? 'true' : 'false');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Single choice as LuCI's select (a ListValue's widget); the choice is `.value`.
|
* Single choice as LuCI's select (a ListValue's widget); the choice is `.value`.
|
||||||
* Unknown values get an option of their own, so nothing is lost on save.
|
* Unknown values get an option of their own, so nothing is lost on save.
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ type OpenMenu = HTMLElement & { dlAnchor?: HTMLElement; dlClose?: () => void };
|
|||||||
export function dropdown(anchor: HTMLElement, items: (MenuItem | null)[]) {
|
export function dropdown(anchor: HTMLElement, items: (MenuItem | null)[]) {
|
||||||
const prev = document.querySelector('.dl-dd') as OpenMenu | null;
|
const prev = document.querySelector('.dl-dd') as OpenMenu | null;
|
||||||
if (prev) {
|
if (prev) {
|
||||||
prev.dlClose ? prev.dlClose() : prev.remove();
|
if (prev.dlClose) prev.dlClose();
|
||||||
|
else prev.remove();
|
||||||
if (prev.dlAnchor === anchor) return;
|
if (prev.dlAnchor === anchor) return;
|
||||||
}
|
}
|
||||||
const menu: OpenMenu = E(
|
const menu: OpenMenu = E(
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ let floating: HTMLElement | null = null;
|
|||||||
let anchor: HTMLElement | null = null;
|
let anchor: HTMLElement | null = null;
|
||||||
let watch = 0;
|
let watch = 0;
|
||||||
|
|
||||||
export function hideTip() {
|
function hideTip() {
|
||||||
if (floating) floating.style.display = 'none';
|
if (floating) floating.style.display = 'none';
|
||||||
anchor = null;
|
anchor = null;
|
||||||
clearInterval(watch);
|
clearInterval(watch);
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export function markdown(src: string): Node[] {
|
|||||||
const parts: (Node | string)[] = [];
|
const parts: (Node | string)[] = [];
|
||||||
const re = /(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g;
|
const re = /(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g;
|
||||||
let last = 0;
|
let last = 0;
|
||||||
for (let m: RegExpExecArray | null; (m = re.exec(s)); ) {
|
for (let m: RegExpExecArray | null; (m = re.exec(s));) {
|
||||||
if (m.index > last) parts.push(s.slice(last, m.index));
|
if (m.index > last) parts.push(s.slice(last, m.index));
|
||||||
if (m[1]) parts.push(E('code', {}, m[1].slice(1, -1)));
|
if (m[1]) parts.push(E('code', {}, m[1].slice(1, -1)));
|
||||||
else if (m[2]) parts.push(E('b', {}, m[2].slice(2, -2)));
|
else if (m[2]) parts.push(E('b', {}, m[2].slice(2, -2)));
|
||||||
@@ -38,13 +38,13 @@ export function markdown(src: string): Node[] {
|
|||||||
for (const raw of src.replace(/\r/g, '').split('\n')) {
|
for (const raw of src.replace(/\r/g, '').split('\n')) {
|
||||||
const line = raw.trimEnd();
|
const line = raw.trimEnd();
|
||||||
if (fence) {
|
if (fence) {
|
||||||
if (/^```/.test(line.trim())) {
|
if (line.trim().startsWith('```')) {
|
||||||
out.push(E('pre', {}, fence.join('\n')));
|
out.push(E('pre', {}, fence.join('\n')));
|
||||||
fence = null;
|
fence = null;
|
||||||
} else fence.push(raw);
|
} else fence.push(raw);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (/^```/.test(line.trim())) {
|
if (line.trim().startsWith('```')) {
|
||||||
flush();
|
flush();
|
||||||
fence = [];
|
fence = [];
|
||||||
continue;
|
continue;
|
||||||
@@ -84,7 +84,7 @@ export function forRouter(md: string): string {
|
|||||||
if (h) {
|
if (h) {
|
||||||
skip = /^install\b/i.test(h[1].trim());
|
skip = /^install\b/i.test(h[1].trim());
|
||||||
if (/^what.s new$/i.test(h[1].trim())) continue;
|
if (/^what.s new$/i.test(h[1].trim())) continue;
|
||||||
} else if (/^\*\*Full Changelog\*\*/.test(line)) skip = false;
|
} else if (line.startsWith('**Full Changelog**')) skip = false;
|
||||||
if (!skip) out.push(line);
|
if (!skip) out.push(line);
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import { addDays, parseDay } from '../shared/format';
|
import { addDays, parseDay } from '../shared/format';
|
||||||
|
|
||||||
export type CellKind = 'past' | 'today' | 'left' | 'end' | 'after';
|
type CellKind = 'past' | 'today' | 'left' | 'end' | 'after';
|
||||||
export interface Cell {
|
export interface Cell {
|
||||||
day: string;
|
day: string;
|
||||||
kind: CellKind;
|
kind: CellKind;
|
||||||
|
|||||||
@@ -1,44 +1,71 @@
|
|||||||
// What the demo adds to the breadcrumb: the scenario chip right after the path,
|
// What the demo adds to the page: "Demo" (it opens the scenarios) and a link to
|
||||||
// and a GitHub pill just before the page's language picker (none over a card
|
// GitHub, one split pill. Wide, the pill stands in the breadcrumb just before the
|
||||||
// alone, which has no picker either). On a phone the pill would crowd out the names, so it
|
// page's language. On a phone the breadcrumb has no room for it, so it is a dock
|
||||||
// gives way to a button in the scenario drawer (demo.css). The portal redraws
|
// of its own at the bottom right, in <body>, outside the page: the page's
|
||||||
// the breadcrumb with the page and knows nothing of either, so both go back in
|
// entrance and a scenario's swap move the page with a transform and a filter,
|
||||||
// place after each redraw; a language change makes both again in it.
|
// which would carry a fixed child along and leave its glass undrawn until they
|
||||||
|
// end. Over a card alone (no language) only the chip, right after the place, and
|
||||||
|
// no dock. The portal redraws the breadcrumb with the page and says when
|
||||||
|
// (onCrumbs), so the pill goes back in place after each redraw; a language
|
||||||
|
// change makes all of it again in it.
|
||||||
|
|
||||||
import { h, ic } from '../dom';
|
import { h, ic } from '../dom';
|
||||||
import { onLang } from '../i18n';
|
import { onLang } from '../i18n';
|
||||||
|
import { EASE_OUT, play } from '../motion';
|
||||||
|
import { onCrumbs } from '../page/frame';
|
||||||
import { REPO } from './data';
|
import { REPO } from './data';
|
||||||
import { scenarioChip } from './picker';
|
import { scenarioPicker } from './picker';
|
||||||
import type { DemoRouter } from './router';
|
import type { DemoRouter } from './router';
|
||||||
|
|
||||||
export function mountCrumbs(router: DemoRouter) {
|
export function mountCrumbs(router: DemoRouter) {
|
||||||
const app = document.getElementById('app')!;
|
const app = document.getElementById('app')!;
|
||||||
|
const open = scenarioPicker(router);
|
||||||
|
const demo = (cls: string) =>
|
||||||
|
h('button', { type: 'button', class: cls, 'aria-haspopup': 'dialog', onclick: open }, h('span', {}, _('Demo')), ic('chevron', 'i'));
|
||||||
|
const github = (cls: string) =>
|
||||||
|
h('a', { class: cls, href: REPO, target: '_blank', rel: 'noopener', 'aria-label': _('Dawnline on GitHub') }, ic('github'));
|
||||||
const make = () => ({
|
const make = () => ({
|
||||||
chip: scenarioChip(router),
|
chip: demo('dm-chip'),
|
||||||
gh: h(
|
gh: github('dm-gh'),
|
||||||
'a',
|
dock: h('div', { class: 'dm-dock' }, demo('dm-dock-demo'), github('dm-dock-gh')),
|
||||||
{ class: 'dm-gh', href: REPO, target: '_blank', rel: 'noopener', 'aria-label': _('Dawnline on GitHub') },
|
|
||||||
ic('github'),
|
|
||||||
h('span', {}, 'GitHub'),
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
let { chip, gh } = make();
|
let { chip, gh, dock } = make();
|
||||||
// Our own insertions call this again: by then both are in place and nothing moves.
|
let first = true;
|
||||||
const keep = () => {
|
const keep = () => {
|
||||||
const crumbs = app.querySelector('.crumbs');
|
const crumbs = app.querySelector('.crumbs');
|
||||||
const path = crumbs?.querySelector('.cr-path');
|
const path = crumbs?.querySelector('.cr-path');
|
||||||
if (!crumbs || !path) return;
|
if (!crumbs || !path) return;
|
||||||
if (path.nextElementSibling !== chip) path.after(chip);
|
|
||||||
const lang = crumbs.querySelector('.cr-lang');
|
const lang = crumbs.querySelector('.cr-lang');
|
||||||
if (lang && lang.previousElementSibling !== gh) lang.before(gh);
|
chip.classList.toggle('split', !!lang);
|
||||||
|
if (!lang) {
|
||||||
|
gh.remove();
|
||||||
|
dock.remove();
|
||||||
|
if (path.nextElementSibling !== chip) path.after(chip);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (lang.previousElementSibling !== gh || gh.previousElementSibling !== chip) lang.before(chip, gh);
|
||||||
|
if (dock.isConnected) return;
|
||||||
|
document.body.append(dock);
|
||||||
|
// It rises from under the screen's edge (with the page's first wave, the first time), on a transform alone:
|
||||||
|
// Safari leaves a backdrop blur undrawn while the element's opacity is animating, and it would pop in at the end.
|
||||||
|
play(dock, [{ transform: 'translateY(calc(100% + 64px))' }, { transform: 'none' }], {
|
||||||
|
duration: 620,
|
||||||
|
delay: first ? 260 : 0,
|
||||||
|
easing: EASE_OUT,
|
||||||
|
fill: 'backwards',
|
||||||
|
});
|
||||||
|
first = false;
|
||||||
};
|
};
|
||||||
new MutationObserver(keep).observe(app, { childList: true, subtree: true });
|
// Each time the page draws its breadcrumb again (a repaint, the language changed).
|
||||||
|
onCrumbs(keep);
|
||||||
keep();
|
keep();
|
||||||
// The page has redrawn its breadcrumb in the new language by now (main.ts listens first).
|
// The page has redrawn its breadcrumb in the new language by now (main.ts listens first).
|
||||||
onLang(() => {
|
onLang(() => {
|
||||||
|
const was = dock;
|
||||||
chip.remove();
|
chip.remove();
|
||||||
gh.remove();
|
gh.remove();
|
||||||
({ chip, gh } = make());
|
({ chip, gh, dock } = make());
|
||||||
|
if (was.isConnected) was.replaceWith(dock);
|
||||||
keep();
|
keep();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
import type { State } from '../state';
|
import type { State } from '../state';
|
||||||
import type { Device, Kind, Pair, Person } from '../../shared/types';
|
import type { Device, Kind, Pair, Person } from '../../shared/types';
|
||||||
|
|
||||||
export const GB = 2 ** 30;
|
const GB = 2 ** 30;
|
||||||
const HOUR = 3600;
|
const HOUR = 3600;
|
||||||
const DAY = 86400;
|
const DAY = 86400;
|
||||||
|
|
||||||
@@ -94,14 +94,14 @@ export function seedDevices(s: ScenarioId, t: number, id: () => string): DemoDev
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The person's state in the scenario: the four the admin's limits stop them in, else active. */
|
/** The person's state in the scenario: the four the admin's limits stop them in, else active. */
|
||||||
export function personState(s: ScenarioId): Person['state'] {
|
function personState(s: ScenarioId): Person['state'] {
|
||||||
return s === 'quota' || s === 'hours' || s === 'paused' || s === 'expired' ? s : 'active';
|
return s === 'quota' || s === 'hours' || s === 'paused' || s === 'expired' ? s : 'active';
|
||||||
}
|
}
|
||||||
export const locked = (s: ScenarioId) => s === 'paused' || s === 'expired';
|
const locked = (s: ScenarioId) => s === 'paused' || s === 'expired';
|
||||||
export const deviceLimit = (s: ScenarioId) => (s === 'full' ? 3 : 4);
|
export const deviceLimit = (s: ScenarioId) => (s === 'full' ? 3 : 4);
|
||||||
|
|
||||||
/** The local day (YYYY-MM-DD) of a time: in the demo, the visitor's clock is the router's. */
|
/** The local day (YYYY-MM-DD) of a time: in the demo, the visitor's clock is the router's. */
|
||||||
export function isoDay(t: number): string {
|
function isoDay(t: number): string {
|
||||||
const d = new Date(t * 1000);
|
const d = new Date(t * 1000);
|
||||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
/* The portal demo's stylesheet: the portal's own, then the demo's pieces in its tokens — the "Demo"
|
/* The portal demo's stylesheet: the portal's own, then the demo's pieces in its tokens — "Demo" and GitHub as
|
||||||
chip after the breadcrumb's path, the GitHub pill beside the page's QR knob, the scenario
|
one split pill before the page's language (on a phone a dock at the bottom), the scenario rows in the drawer,
|
||||||
rows in the drawer, and the set-up state switch beside the set-up sheet's ×. */
|
and the set-up state switch beside the set-up sheet's ×. */
|
||||||
@import '../styles/index.css';
|
@import '../styles/index.css';
|
||||||
|
|
||||||
/* The path keeps its width so the chip sits right after it; the page's QR stays at the end. */
|
/* "Demo" and GitHub, one split pill just before the page's language: as high as the knobs beside it, the halves
|
||||||
.cr-path {
|
2px apart, their inner corners 4px (the outer ones half the height: 999px would scale every radius of a half
|
||||||
flex: 0 1 auto;
|
down to nothing). Over a card alone the chip stands by itself after the place, 26px and round. */
|
||||||
}
|
|
||||||
.dm-chip {
|
.dm-chip {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
height: 26px;
|
height: 26px;
|
||||||
padding: 0 8px 0 10px;
|
padding: 0 8px 0 10px;
|
||||||
margin-right: auto;
|
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
background: var(--accent-soft);
|
background: var(--accent-soft);
|
||||||
color: var(--accent);
|
color: var(--accent);
|
||||||
@@ -24,57 +22,117 @@
|
|||||||
transform 150ms var(--ease-out),
|
transform 150ms var(--ease-out),
|
||||||
background-color 150ms;
|
background-color 150ms;
|
||||||
}
|
}
|
||||||
.dm-chip:hover {
|
.dm-chip.split {
|
||||||
background: color-mix(in srgb, var(--accent) 20%, transparent);
|
height: 32px;
|
||||||
}
|
padding: 0 10px 0 14px;
|
||||||
.dm-chip:active {
|
border-radius: 16px 4px 4px 16px;
|
||||||
transform: scale(0.94);
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
.dm-chip .i {
|
.dm-chip .i {
|
||||||
width: 14px;
|
width: 14px;
|
||||||
height: 14px;
|
height: 14px;
|
||||||
transform: rotate(90deg);
|
transform: rotate(90deg);
|
||||||
}
|
}
|
||||||
/* A card alone (paused): the breadcrumb is centred, the chip with it. */
|
|
||||||
.page.single .dm-chip {
|
|
||||||
margin-right: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* GitHub: a pill of the QR knob's height and fill, just before it. On a phone it would crowd out the
|
|
||||||
names (the server's and the person's): there it is a button in the drawer instead. */
|
|
||||||
.dm-gh {
|
.dm-gh {
|
||||||
display: inline-flex;
|
display: inline-grid;
|
||||||
align-items: center;
|
place-items: center;
|
||||||
gap: 6px;
|
width: 38px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
padding: 0 12px 0 10px;
|
margin-left: -8px;
|
||||||
border-radius: 999px;
|
padding-right: 2px;
|
||||||
background: var(--knob);
|
border-radius: 4px 16px 16px 4px;
|
||||||
color: var(--text);
|
background: var(--accent-soft);
|
||||||
font-size: 14px;
|
color: var(--accent);
|
||||||
font-weight: 500;
|
|
||||||
letter-spacing: -0.01em;
|
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
flex: none;
|
flex: none;
|
||||||
transition:
|
transition:
|
||||||
transform 150ms var(--ease-out),
|
transform 150ms var(--ease-out),
|
||||||
background-color 150ms;
|
background-color 150ms;
|
||||||
}
|
}
|
||||||
.dm-gh:hover {
|
|
||||||
background: color-mix(in srgb, var(--knob), var(--text) 6%);
|
|
||||||
}
|
|
||||||
.dm-gh:active {
|
|
||||||
transform: scale(0.94);
|
|
||||||
}
|
|
||||||
.dm-gh .i {
|
.dm-gh .i {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
@media (max-width: 479px) {
|
/* Pointed at with a mouse only: a tap would leave it lit. */
|
||||||
|
@media (hover: hover) {
|
||||||
|
.dm-chip:hover,
|
||||||
|
.dm-gh:hover {
|
||||||
|
background: color-mix(in srgb, var(--accent) 20%, transparent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.dm-chip:active,
|
||||||
|
.dm-gh:active {
|
||||||
|
transform: scale(0.94);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* On a phone the breadcrumb has no room for the pill: it is the dock instead (crumbs.ts), in <body> at the bottom
|
||||||
|
right, over the bottom fade and under the sheets; glass, 36px, the halves as in the breadcrumb. */
|
||||||
|
@media (max-width: 559px) {
|
||||||
|
.dm-chip.split,
|
||||||
.dm-gh {
|
.dm-gh {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.dm-dock {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 40;
|
||||||
|
right: max(16px, env(safe-area-inset-right, 0px));
|
||||||
|
bottom: calc(20px + env(safe-area-inset-bottom, 0px));
|
||||||
|
display: flex;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
@media (min-width: 560px) {
|
||||||
|
.dm-dock {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.dm-dock > * {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 36px;
|
||||||
|
color: var(--accent);
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
text-decoration: none;
|
||||||
|
background: var(--glass-bg);
|
||||||
|
-webkit-backdrop-filter: blur(28px) saturate(1.8);
|
||||||
|
backdrop-filter: blur(28px) saturate(1.8);
|
||||||
|
box-shadow:
|
||||||
|
inset 0 0 0 1px var(--glass-edge),
|
||||||
|
var(--glass-shadow);
|
||||||
|
transition: transform 150ms var(--ease-out);
|
||||||
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
}
|
||||||
|
.dm-dock-demo {
|
||||||
|
gap: 4px;
|
||||||
|
padding: 0 10px 0 14px;
|
||||||
|
border-radius: 18px 5px 5px 18px;
|
||||||
|
}
|
||||||
|
.dm-dock-demo .i {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
transform: rotate(-90deg);
|
||||||
|
}
|
||||||
|
.dm-dock-gh {
|
||||||
|
width: 40px;
|
||||||
|
border-radius: 5px 18px 18px 5px;
|
||||||
|
}
|
||||||
|
.dm-dock-gh .i {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
}
|
||||||
|
/* A film over the glass, never in place of it. */
|
||||||
|
@media (hover: hover) {
|
||||||
|
.dm-dock > *:hover {
|
||||||
|
background:
|
||||||
|
linear-gradient(color-mix(in srgb, var(--text) 7%, transparent), color-mix(in srgb, var(--text) 7%, transparent)), var(--glass-bg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.dm-dock > *:active {
|
||||||
|
transform: scale(0.94);
|
||||||
|
}
|
||||||
|
|
||||||
/* The drawer: groups of rows that touch, one step lighter than the sheet, the current one in the accent. */
|
/* The drawer: groups of rows that touch, one step lighter than the sheet, the current one in the accent. */
|
||||||
.dm-group {
|
.dm-group {
|
||||||
@@ -136,7 +194,7 @@
|
|||||||
flex: none;
|
flex: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The drawer's foot: Start over, and on a phone GitHub beside it. */
|
/* The drawer's foot: Start over. */
|
||||||
.dm-foot {
|
.dm-foot {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
@@ -144,12 +202,6 @@
|
|||||||
.dm-foot .btn {
|
.dm-foot .btn {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
@media (min-width: 480px) {
|
|
||||||
.dm-gh-alt {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The set-up state switch: a pill beside ×, gliding into its place when the device arrives. */
|
/* The set-up state switch: a pill beside ×, gliding into its place when the device arrives. */
|
||||||
.dm-way {
|
.dm-way {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -179,18 +231,8 @@
|
|||||||
.dm-way[aria-expanded='true'] {
|
.dm-way[aria-expanded='true'] {
|
||||||
background: color-mix(in srgb, var(--knob), var(--text) 10%);
|
background: color-mix(in srgb, var(--knob), var(--text) 10%);
|
||||||
}
|
}
|
||||||
.dm-way .i {
|
|
||||||
width: 14px;
|
|
||||||
height: 14px;
|
|
||||||
color: var(--text-2);
|
|
||||||
transform: rotate(90deg);
|
|
||||||
transition: transform 240ms var(--ease-out);
|
|
||||||
}
|
|
||||||
.dm-way[aria-expanded='true'] .i {
|
|
||||||
transform: rotate(-90deg);
|
|
||||||
}
|
|
||||||
.dm-way .dot,
|
.dm-way .dot,
|
||||||
.dm-way-pop .dot {
|
.pp-pop .dot {
|
||||||
width: 7px;
|
width: 7px;
|
||||||
height: 7px;
|
height: 7px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
@@ -200,103 +242,21 @@
|
|||||||
opacity 150ms;
|
opacity 150ms;
|
||||||
}
|
}
|
||||||
.dm-way .dot.warn,
|
.dm-way .dot.warn,
|
||||||
.dm-way-pop .dot.warn {
|
.pp-pop .dot.warn {
|
||||||
background: var(--warn);
|
background: var(--warn);
|
||||||
}
|
}
|
||||||
.dm-way .dot.ok,
|
.dm-way .dot.ok,
|
||||||
.dm-way-pop .dot.ok {
|
.pp-pop .dot.ok {
|
||||||
background: var(--ok);
|
background: var(--ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Its popup: segments in one pill frame, a step above the sheet each (white on grey in light), a tail down
|
/* The set-up state's dots in the shared popup (styles/pick.css): faint, full on the one picked or pointed at. */
|
||||||
to the pill, and a dark, softly blurred halo behind that fades out around it. */
|
.pp-pop .dot {
|
||||||
.dm-way-pop {
|
|
||||||
--frame: color-mix(in srgb, var(--field), var(--knob) 55%);
|
|
||||||
--seg: color-mix(in srgb, var(--knob), var(--text) 2%);
|
|
||||||
--seg-hover: color-mix(in srgb, var(--knob), var(--text) 6%);
|
|
||||||
position: fixed;
|
|
||||||
z-index: 60;
|
|
||||||
display: flex;
|
|
||||||
gap: 3px;
|
|
||||||
padding: 3px;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: var(--frame);
|
|
||||||
box-shadow: var(--pop-shadow);
|
|
||||||
}
|
|
||||||
.dm-way-pop::before {
|
|
||||||
content: '';
|
|
||||||
position: absolute;
|
|
||||||
bottom: -5px;
|
|
||||||
left: var(--tail, 50%);
|
|
||||||
width: 12px;
|
|
||||||
height: 12px;
|
|
||||||
margin-left: -6px;
|
|
||||||
border-radius: 0 0 3px 0;
|
|
||||||
background: var(--frame);
|
|
||||||
transform: rotate(45deg);
|
|
||||||
}
|
|
||||||
.dm-way-pop button {
|
|
||||||
position: relative;
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 6px;
|
|
||||||
height: 34px;
|
|
||||||
padding: 0 10px;
|
|
||||||
border-radius: 10px;
|
|
||||||
background: var(--seg);
|
|
||||||
color: color-mix(in srgb, var(--text-2), var(--text-3) 35%);
|
|
||||||
font-size: 12.5px;
|
|
||||||
font-weight: 500;
|
|
||||||
white-space: nowrap;
|
|
||||||
transition:
|
|
||||||
color 150ms,
|
|
||||||
background-color 150ms,
|
|
||||||
transform 150ms var(--ease-out);
|
|
||||||
}
|
|
||||||
/* The ends follow the frame: half the segment's height (a larger radius would shrink every corner). */
|
|
||||||
.dm-way-pop button:first-of-type {
|
|
||||||
border-radius: 17px 10px 10px 17px;
|
|
||||||
padding-left: 13px;
|
|
||||||
}
|
|
||||||
.dm-way-pop button:last-of-type {
|
|
||||||
border-radius: 10px 17px 17px 10px;
|
|
||||||
padding-right: 13px;
|
|
||||||
}
|
|
||||||
.dm-way-pop button:hover {
|
|
||||||
color: color-mix(in srgb, var(--text-2), var(--text) 45%);
|
|
||||||
background: var(--seg-hover);
|
|
||||||
}
|
|
||||||
.dm-way-pop button:active {
|
|
||||||
transform: scale(0.96);
|
|
||||||
}
|
|
||||||
.dm-way-pop button[aria-checked='true'] {
|
|
||||||
color: var(--text);
|
|
||||||
}
|
|
||||||
.dm-way-pop .dot {
|
|
||||||
background: currentColor;
|
background: currentColor;
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
.dm-way-pop button[aria-checked='true'] .dot,
|
.pp-pop button[aria-checked='true'] .dot,
|
||||||
.dm-way-pop button:hover .dot {
|
.pp-pop button:hover .dot,
|
||||||
|
.pp-pop button.hot .dot {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
.dm-way-halo {
|
|
||||||
position: fixed;
|
|
||||||
z-index: 59;
|
|
||||||
pointer-events: none;
|
|
||||||
background: radial-gradient(closest-side, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.35) 55%, transparent);
|
|
||||||
-webkit-backdrop-filter: blur(3px);
|
|
||||||
backdrop-filter: blur(3px);
|
|
||||||
-webkit-mask-image: radial-gradient(closest-side, #000 60%, transparent 92%);
|
|
||||||
mask-image: radial-gradient(closest-side, #000 60%, transparent 92%);
|
|
||||||
}
|
|
||||||
@media (prefers-color-scheme: light) {
|
|
||||||
.dm-way-pop {
|
|
||||||
--frame: var(--knob);
|
|
||||||
--seg: var(--raised);
|
|
||||||
--seg-hover: color-mix(in srgb, var(--raised), var(--text) 4%);
|
|
||||||
}
|
|
||||||
.dm-way-halo {
|
|
||||||
background: radial-gradient(closest-side, rgba(0, 0, 0, 0.14), rgba(0, 0, 0, 0.07) 55%, transparent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,7 +26,7 @@ msgstr ""
|
|||||||
msgid "Dawnline on GitHub"
|
msgid "Dawnline on GitHub"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/portal/demo/picker.ts
|
#: web/src/portal/demo/crumbs.ts
|
||||||
msgid "Demo"
|
msgid "Demo"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ msgstr "Авто"
|
|||||||
msgid "Dawnline on GitHub"
|
msgid "Dawnline on GitHub"
|
||||||
msgstr "Dawnline на GitHub"
|
msgstr "Dawnline на GitHub"
|
||||||
|
|
||||||
#: web/src/portal/demo/picker.ts
|
#: web/src/portal/demo/crumbs.ts
|
||||||
msgid "Demo"
|
msgid "Demo"
|
||||||
msgstr "Демо"
|
msgstr "Демо"
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover" />
|
||||||
<meta name="color-scheme" content="light dark" />
|
<meta name="color-scheme" content="light dark" />
|
||||||
<meta
|
<meta
|
||||||
name="description"
|
name="description"
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
// The demo's scenario picker: the "Demo" chip, opening a drawer with the
|
// The demo's scenario picker: a drawer with the scenarios in groups (glass
|
||||||
// scenarios in groups (glass icon, name, what the page shows) and "Start over".
|
// icon, name, what the page shows) and "Start over". Picking one swaps the page
|
||||||
// Picking one swaps the page in place. Built only from the portal's own parts
|
// in place. Built only from the portal's own parts (sheet, glass icons, toast,
|
||||||
// (sheet, glass icons, toast, motion); where the chip sits is crumbs.ts. On a
|
// motion); the "Demo" buttons that open it, and where they sit, are crumbs.ts.
|
||||||
// phone the drawer's foot also links to GitHub, the breadcrumb having no room.
|
|
||||||
|
|
||||||
import { h, ic } from '../dom';
|
import { h, ic } from '../dom';
|
||||||
import { call } from '../api';
|
import { call } from '../api';
|
||||||
@@ -11,7 +10,7 @@ import { closeSheet, head, onSheetEntry, openSheet, sub, type View } from '../ui
|
|||||||
import { glass, type Tone } from '../ui/glass';
|
import { glass, type Tone } from '../ui/glass';
|
||||||
import { toast } from '../ui/feedback';
|
import { toast } from '../ui/feedback';
|
||||||
import { EASE_OUT, play } from '../motion';
|
import { EASE_OUT, play } from '../motion';
|
||||||
import { REPO, groups, type Scenario, type ScenarioId } from './data';
|
import { groups, type Scenario, type ScenarioId } from './data';
|
||||||
import type { DemoRouter } from './router';
|
import type { DemoRouter } from './router';
|
||||||
|
|
||||||
/** Each scenario's glass icon and tone (the glass set is smaller than the line icons). */
|
/** Each scenario's glass icon and tone (the glass set is smaller than the line icons). */
|
||||||
@@ -28,8 +27,8 @@ const LOOK: Record<ScenarioId, [string, Tone]> = {
|
|||||||
full: ['phone', 'grey'],
|
full: ['phone', 'grey'],
|
||||||
};
|
};
|
||||||
|
|
||||||
/** The chip that opens the scenarios. */
|
/** What opens the scenarios' drawer. */
|
||||||
export function scenarioChip(router: DemoRouter): HTMLElement {
|
export function scenarioPicker(router: DemoRouter): () => void {
|
||||||
const app = document.getElementById('app')!;
|
const app = document.getElementById('app')!;
|
||||||
|
|
||||||
/** Swap the page in place: it dims away and comes back drawn from the scenario, the link saying which. */
|
/** Swap the page in place: it dims away and comes back drawn from the scenario, the link saying which. */
|
||||||
@@ -44,14 +43,16 @@ export function scenarioChip(router: DemoRouter): HTMLElement {
|
|||||||
else mark();
|
else mark();
|
||||||
closeSheet();
|
closeSheet();
|
||||||
router.use(s);
|
router.use(s);
|
||||||
const out = play(app, [{ opacity: 1 }, { opacity: 0, filter: 'blur(4px)' }], { duration: 160, easing: EASE_OUT, fill: 'forwards' });
|
// The page, not #app: a filter or a transform on #app would carry its fixed edge fades along until it ends.
|
||||||
|
const page = app.querySelector<HTMLElement>('.page') ?? app;
|
||||||
|
const out = play(page, [{ opacity: 1 }, { opacity: 0, filter: 'blur(4px)' }], { duration: 160, easing: EASE_OUT, fill: 'forwards' });
|
||||||
const st = await call<State>('state');
|
const st = await call<State>('state');
|
||||||
await out.finished;
|
await out.finished;
|
||||||
setState(st);
|
setState(st);
|
||||||
repaint();
|
repaint();
|
||||||
out.cancel();
|
out.cancel();
|
||||||
play(
|
play(
|
||||||
app,
|
page,
|
||||||
[
|
[
|
||||||
{ opacity: 0, filter: 'blur(4px)', transform: 'translateY(6px)' },
|
{ opacity: 0, filter: 'blur(4px)', transform: 'translateY(6px)' },
|
||||||
{ opacity: 1, filter: 'none', transform: 'none' },
|
{ opacity: 1, filter: 'none', transform: 'none' },
|
||||||
@@ -94,16 +95,10 @@ export function scenarioChip(router: DemoRouter): HTMLElement {
|
|||||||
ic('reset'),
|
ic('reset'),
|
||||||
h('span', {}, _('Start over')),
|
h('span', {}, _('Start over')),
|
||||||
),
|
),
|
||||||
h('a', { class: 'btn soft dm-gh-alt', href: REPO, target: '_blank', rel: 'noopener' }, ic('github'), h('span', {}, 'GitHub')),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return { el, label: _('Try a scenario') };
|
return { el, label: _('Try a scenario') };
|
||||||
}
|
}
|
||||||
|
|
||||||
return h(
|
return () => openSheet(scenarios);
|
||||||
'button',
|
|
||||||
{ type: 'button', class: 'dm-chip', 'aria-haspopup': 'dialog', onclick: () => openSheet(scenarios) },
|
|
||||||
h('span', {}, _('Demo')),
|
|
||||||
ic('chevron', 'i'),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ export interface RouterOpts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** A settings sheet waits for the first connection: it comes this long after the settings are shown. */
|
/** A settings sheet waits for the first connection: it comes this long after the settings are shown. */
|
||||||
export const CONNECT_AFTER = [6, 9];
|
const CONNECT_AFTER = [6, 9];
|
||||||
|
|
||||||
class Refusal {
|
class Refusal {
|
||||||
constructor(
|
constructor(
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
// The demo's set-up state switch: a pill beside the set-up sheet's ×, so a visitor can see each state the way
|
// The demo's set-up state switch: a pill beside the set-up sheet's ×, so a visitor can see each state the way
|
||||||
// shows (waiting, knocks that never finish, no data, connected) without a device. Its popup is a row of segments
|
// shows (waiting, knocks that never finish, no data, connected) without a device: a pick pill (ui/pick.ts), its
|
||||||
// in one pill frame, above the pill with a tail pointing at it and a dark halo behind. Only on the set-up view:
|
// popup above it. Only on the set-up view:
|
||||||
// another view in the same sheet (a question, a device's page) fades it out. Picking holds the device in that
|
// another view in the same sheet (a question, a device's page) fades it out. Picking holds the device in that
|
||||||
// state on the demo's router and polls at once; Auto is the demo's own timing.
|
// state on the demo's router and polls at once; Auto is the demo's own timing, and where each opening starts.
|
||||||
|
|
||||||
import { h, ic } from '../dom';
|
import { h } from '../dom';
|
||||||
import { EASE_IN, EASE_OUT, POP, play } from '../motion';
|
import { EASE_IN, SMOOTH, play } from '../motion';
|
||||||
import { morphText, setText } from '../ui/morph';
|
|
||||||
import { pollNow } from '../flows/wait';
|
import { pollNow } from '../flows/wait';
|
||||||
|
import { pickPill, type PickPill } from '../ui/pick';
|
||||||
|
import { onSheetChange } from '../ui/sheet';
|
||||||
import type { DemoWay } from './data';
|
import type { DemoWay } from './data';
|
||||||
import type { DemoRouter } from './router';
|
import type { DemoRouter } from './router';
|
||||||
|
|
||||||
@@ -21,11 +22,6 @@ const PICKS: [Pick, () => string, Tone][] = [
|
|||||||
['nodata', () => _('No data'), 'warn'],
|
['nodata', () => _('No data'), 'warn'],
|
||||||
['connected', () => _('Online'), 'ok'],
|
['connected', () => _('Online'), 'ok'],
|
||||||
];
|
];
|
||||||
const pick = (p: Pick) => PICKS.find((x) => x[0] === p)!;
|
|
||||||
|
|
||||||
/** The gap between the pill and the popup above it, and how far the halo reaches out (up, sideways, down). */
|
|
||||||
const GAP = 18;
|
|
||||||
const HALO = { x: 64, up: 48, down: 14 };
|
|
||||||
|
|
||||||
/** Gone from where it stands, so one leaving while it still comes in turns back from there. */
|
/** Gone from where it stands, so one leaving while it still comes in turns back from there. */
|
||||||
function leave(el: Element, frames: Keyframe, ms: number) {
|
function leave(el: Element, frames: Keyframe, ms: number) {
|
||||||
@@ -49,102 +45,27 @@ function leave(el: Element, frames: Keyframe, ms: number) {
|
|||||||
export function mountWayPick(router: DemoRouter) {
|
export function mountWayPick(router: DemoRouter) {
|
||||||
/** What each device's pill says: what was picked here, else what the router holds it in. */
|
/** What each device's pill says: what was picked here, else what the router holds it in. */
|
||||||
const shown = new Map<string, Pick>();
|
const shown = new Map<string, Pick>();
|
||||||
let pop: HTMLElement | null = null;
|
/** The pill on the sheet now. */
|
||||||
let halo: HTMLElement | null = null;
|
let live: PickPill<Pick> | null = null;
|
||||||
let anchor: HTMLElement | null = null;
|
|
||||||
|
|
||||||
function closePop() {
|
|
||||||
if (!pop) return;
|
|
||||||
leave(pop, { transform: 'scale(.96)', filter: 'blur(3px)' }, 120);
|
|
||||||
if (halo) leave(halo, {}, 160);
|
|
||||||
anchor?.setAttribute('aria-expanded', 'false');
|
|
||||||
pop = halo = anchor = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function openPop(pill: HTMLElement, id: string, paint: () => void) {
|
|
||||||
const now = shown.get(id) ?? router.wayOf(id);
|
|
||||||
const m = h(
|
|
||||||
'div',
|
|
||||||
{ class: 'dm-way-pop', role: 'menu' },
|
|
||||||
...PICKS.map(([p, label, tone]) =>
|
|
||||||
h(
|
|
||||||
'button',
|
|
||||||
{
|
|
||||||
type: 'button',
|
|
||||||
role: 'menuitemradio',
|
|
||||||
'aria-checked': String(p === now),
|
|
||||||
onclick: () => {
|
|
||||||
closePop();
|
|
||||||
shown.set(id, p);
|
|
||||||
router.holdWay(id, p);
|
|
||||||
paint();
|
|
||||||
pollNow();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
h('span', { class: `dot ${tone}` }),
|
|
||||||
label(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
document.body.append(m);
|
|
||||||
// Centred over the pill, inside the sheet where it fits (else the screen), the tail on the pill's middle.
|
|
||||||
const r = pill.getBoundingClientRect();
|
|
||||||
const box = pill.closest('.sheet')?.getBoundingClientRect() ?? { left: 0, right: innerWidth };
|
|
||||||
const w = m.offsetWidth;
|
|
||||||
const mid = r.left + r.width / 2;
|
|
||||||
const lo = Math.max(12, box.left + 10);
|
|
||||||
const hi = Math.min(innerWidth - 12, box.right - 10);
|
|
||||||
const left = Math.max(lo, Math.min(mid - w / 2, hi - w));
|
|
||||||
const top = r.top - GAP - m.offsetHeight;
|
|
||||||
Object.assign(m.style, { left: `${left}px`, top: `${top}px`, transformOrigin: `${mid - left}px bottom` });
|
|
||||||
m.style.setProperty('--tail', `${mid - left}px`);
|
|
||||||
// The halo reaches up and out but stops short of the pill, which stays sharp.
|
|
||||||
const sc = h('div', { class: 'dm-way-halo' });
|
|
||||||
Object.assign(sc.style, {
|
|
||||||
left: `${left - HALO.x}px`,
|
|
||||||
top: `${top - HALO.up}px`,
|
|
||||||
width: `${w + HALO.x * 2}px`,
|
|
||||||
height: `${m.offsetHeight + HALO.up + HALO.down}px`,
|
|
||||||
});
|
|
||||||
m.before(sc);
|
|
||||||
play(sc, [{ opacity: 0 }, { opacity: 1 }], { duration: 220, easing: EASE_OUT });
|
|
||||||
play(
|
|
||||||
m,
|
|
||||||
[
|
|
||||||
{ opacity: 0, transform: 'scale(.9)', filter: 'blur(4px)' },
|
|
||||||
{ opacity: 1, transform: 'none', filter: 'none' },
|
|
||||||
],
|
|
||||||
{ duration: POP.duration, easing: POP.easing },
|
|
||||||
);
|
|
||||||
pop = m;
|
|
||||||
halo = sc;
|
|
||||||
anchor = pill;
|
|
||||||
pill.setAttribute('aria-expanded', 'true');
|
|
||||||
}
|
|
||||||
|
|
||||||
function makePill(id: string): HTMLElement {
|
function makePill(id: string): HTMLElement {
|
||||||
const dot = h('span', { class: 'dot' });
|
live = pickPill<Pick>({
|
||||||
const lbl = h('span', {});
|
cls: 'dm-way',
|
||||||
const pill = h(
|
label: () => _('Set-up state'),
|
||||||
'button',
|
options: PICKS.map(([value, label, tone]) => ({ value, label, lead: () => h('span', { class: `dot ${tone}` }) })),
|
||||||
{ type: 'button', class: 'dm-way', 'aria-haspopup': 'menu', 'aria-expanded': 'false', 'aria-label': _('Set-up state') },
|
value: shown.get(id) ?? router.wayOf(id),
|
||||||
dot,
|
pick: (p) => {
|
||||||
lbl,
|
shown.set(id, p);
|
||||||
ic('chevron', 'i'),
|
router.holdWay(id, p);
|
||||||
);
|
pollNow();
|
||||||
const paint = (morph = true) => {
|
// Its width glides with its words (SMOOTH): the title makes room for where it ends.
|
||||||
const [, label, tone] = pick(shown.get(id) ?? router.wayOf(id));
|
setTimeout(place, SMOOTH.duration + 40);
|
||||||
dot.className = `dot ${tone}`;
|
},
|
||||||
if (morph) morphText(lbl, label());
|
});
|
||||||
else setText(lbl, label());
|
return live.el;
|
||||||
};
|
|
||||||
paint(false);
|
|
||||||
pill.addEventListener('click', () => (anchor === pill ? closePop() : (closePop(), openPop(pill, id, () => paint()))));
|
|
||||||
return pill;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function place() {
|
function place() {
|
||||||
if (anchor && !anchor.isConnected) closePop();
|
|
||||||
const sheet = document.querySelector<HTMLElement>('.sheet-root.open .sheet');
|
const sheet = document.querySelector<HTMLElement>('.sheet-root.open .sheet');
|
||||||
const id = router.settingUp();
|
const id = router.settingUp();
|
||||||
const setup = !!sheet && !!id && !!sheet.querySelector('.way') && !sheet.classList.contains('asks');
|
const setup = !!sheet && !!id && !!sheet.querySelector('.way') && !sheet.classList.contains('asks');
|
||||||
@@ -152,12 +73,18 @@ export function mountWayPick(router: DemoRouter) {
|
|||||||
if (setup && el.parentElement === sheet && el.dataset.id === id) return;
|
if (setup && el.parentElement === sheet && el.dataset.id === id) return;
|
||||||
el.classList.add('gone');
|
el.classList.add('gone');
|
||||||
el.parentElement?.querySelectorAll<HTMLElement>('.vhead').forEach((hd) => (hd.style.paddingRight = ''));
|
el.parentElement?.querySelectorAll<HTMLElement>('.vhead').forEach((hd) => (hd.style.paddingRight = ''));
|
||||||
if (anchor === el) closePop();
|
if (live?.el === el) {
|
||||||
|
live.close();
|
||||||
|
live = null;
|
||||||
|
}
|
||||||
leave(el, { transform: 'scale(.9)', filter: 'blur(3px)' }, 160);
|
leave(el, { transform: 'scale(.9)', filter: 'blur(3px)' }, 160);
|
||||||
});
|
});
|
||||||
if (!sheet || !setup || !id) return;
|
if (!sheet || !setup || !id) return;
|
||||||
let pill = sheet.querySelector<HTMLElement>('.dm-way:not(.gone)');
|
let pill = sheet.querySelector<HTMLElement>('.dm-way:not(.gone)');
|
||||||
if (!pill) {
|
if (!pill) {
|
||||||
|
// A set-up opened anew starts from the default: the demo's own timing, nothing held from the last time.
|
||||||
|
shown.delete(id);
|
||||||
|
if (router.wayOf(id) !== 'auto') router.holdWay(id, 'auto');
|
||||||
pill = makePill(id);
|
pill = makePill(id);
|
||||||
pill.dataset.id = id;
|
pill.dataset.id = id;
|
||||||
sheet.append(pill);
|
sheet.append(pill);
|
||||||
@@ -179,22 +106,6 @@ export function mountWayPick(router: DemoRouter) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new MutationObserver(place).observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['class'] });
|
// The sheet says when it changes (a view shown, the device arrived, the sheet gone): nothing to watch.
|
||||||
document.addEventListener('pointerdown', (e) => {
|
onSheetChange(place);
|
||||||
const t = e.target as Element;
|
|
||||||
if (pop && !pop.contains(t) && !anchor?.contains(t)) closePop();
|
|
||||||
});
|
|
||||||
// Escape takes the popup only, not the sheet under it.
|
|
||||||
document.addEventListener(
|
|
||||||
'keydown',
|
|
||||||
(e) => {
|
|
||||||
if (!pop || e.key !== 'Escape') return;
|
|
||||||
e.stopPropagation();
|
|
||||||
closePop();
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
// A wheel or a swipe closes it; the sheet's own scroll as it settles does not.
|
|
||||||
for (const ev of ['wheel', 'touchmove'])
|
|
||||||
addEventListener(ev, (e) => pop && !pop.contains(e.target as Node) && closePop(), { passive: true, capture: true });
|
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ const modelReady: Promise<string> = (async () => {
|
|||||||
const m = ((await uad.getHighEntropyValues(['model'])).model ?? '').trim();
|
const m = ((await uad.getHighEntropyValues(['model'])).model ?? '').trim();
|
||||||
if (!m || m === 'K') return '';
|
if (!m || m === 'K') return '';
|
||||||
const g = GALAXY.find(([re]) => re.test(m));
|
const g = GALAXY.find(([re]) => re.test(m));
|
||||||
MODEL = g ? `${g[1]} (${m})` : /^SM-/.test(m) ? `Galaxy ${m}` : m;
|
MODEL = g ? `${g[1]} (${m})` : m.startsWith('SM-') ? `Galaxy ${m}` : m;
|
||||||
} catch {
|
} catch {
|
||||||
/* not offered */
|
/* not offered */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,76 @@
|
|||||||
// This page on another device: from the breadcrumb, its link as a code for a
|
// This page on another device: a dropdown from the breadcrumb's QR knob (ui/drop.ts: placed, coming and going and
|
||||||
// phone's camera, and the link itself to copy or share.
|
// shut as every dropdown is), the page's link as a code for a phone's camera, and under it Copy link (it says
|
||||||
|
// Copied for a moment) and Share where the system has it.
|
||||||
|
|
||||||
import { h } from '../dom';
|
import { h, ic } from '../dom';
|
||||||
import { pageUrl } from '../state';
|
import { placeName, pageUrl } from '../state';
|
||||||
import { linkRow, qrBox } from '../ui/codes';
|
import { qrBox } from '../ui/codes';
|
||||||
import { head, openSheet, sub } from '../ui/sheet';
|
import { appear, closeDrop, EDGE, GAP, opened, vanish } from '../ui/drop';
|
||||||
|
import { copy } from '../ui/feedback';
|
||||||
|
|
||||||
export function showPageCode() {
|
/** The card open now, to shut at once when its knob goes with the breadcrumb. */
|
||||||
openSheet(() => {
|
let open: ((now?: boolean) => void) | null = null;
|
||||||
const url = pageUrl();
|
|
||||||
const el = h(
|
export const closePageCode = (now = false) => open?.(now);
|
||||||
|
|
||||||
|
export function showPageCode(knob: HTMLElement) {
|
||||||
|
if (knob.getAttribute('aria-expanded') === 'true') return closeDrop();
|
||||||
|
const url = pageUrl();
|
||||||
|
const share = typeof navigator.share === 'function';
|
||||||
|
const card = h(
|
||||||
|
'div',
|
||||||
|
{ class: 'pc-card drop', role: 'dialog', 'aria-label': _('Open on another device') },
|
||||||
|
qrBox(url, true),
|
||||||
|
h(
|
||||||
'div',
|
'div',
|
||||||
{ class: 'view' },
|
{ class: 'pc-row' },
|
||||||
head(_('Open on another device')),
|
h(
|
||||||
sub(_('Point its camera at the code: this page opens there.')),
|
'button',
|
||||||
qrBox(url, true),
|
{
|
||||||
linkRow(url),
|
type: 'button',
|
||||||
);
|
class: 'pc-copy',
|
||||||
return { el, label: _('Open on another device') };
|
'aria-label': _('Copy the link'),
|
||||||
|
onclick: (e: Event) => copy(url, _('Link copied'), e.currentTarget),
|
||||||
|
},
|
||||||
|
ic('link'),
|
||||||
|
h('span', { class: 'lbl' }, _('Copy link')),
|
||||||
|
),
|
||||||
|
share
|
||||||
|
? h(
|
||||||
|
'button',
|
||||||
|
{
|
||||||
|
type: 'button',
|
||||||
|
class: 'knob',
|
||||||
|
'aria-label': _('Share the link'),
|
||||||
|
onclick: () => navigator.share({ url, title: placeName() }).catch(() => undefined),
|
||||||
|
},
|
||||||
|
ic('share'),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
document.body.append(card);
|
||||||
|
// Under the knob where it fits, else over it; centred on it inside the screen's edge, growing from its side.
|
||||||
|
const r = knob.getBoundingClientRect();
|
||||||
|
const w = card.offsetWidth;
|
||||||
|
const ht = card.offsetHeight;
|
||||||
|
const mid = r.left + r.width / 2;
|
||||||
|
const left = Math.max(EDGE, Math.min(mid - w / 2, innerWidth - EDGE - w));
|
||||||
|
const below = r.bottom + GAP + ht <= innerHeight - EDGE || r.top - GAP - ht < EDGE;
|
||||||
|
const top = below ? r.bottom + GAP : r.top - GAP - ht;
|
||||||
|
Object.assign(card.style, {
|
||||||
|
left: `${left + scrollX}px`,
|
||||||
|
top: `${top + scrollY}px`,
|
||||||
|
transformOrigin: `${mid - left}px ${below ? 0 : ht}px`,
|
||||||
});
|
});
|
||||||
|
appear(card);
|
||||||
|
const release = opened(card, knob, close);
|
||||||
|
open = close;
|
||||||
|
|
||||||
|
function close(instant = false) {
|
||||||
|
if (!release()) return;
|
||||||
|
if (open === close) open = null;
|
||||||
|
if (instant) card.remove();
|
||||||
|
else vanish(card);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
// Renaming a device where its name stands on the card: a click on the name (or Rename in its ⋯ menu) turns it
|
// Renaming a device where its name stands on the card: a click on the name (or Rename in its ⋯ menu) turns it
|
||||||
// into its own input, in the name's font and place, with nothing around it but the field's caret and selection
|
// into its own input, in the name's font and place, with nothing around it but the field's caret and selection
|
||||||
// (ui/caret.ts), the name selected. The status line under it says how to finish. Return saves: the words shimmer
|
// (ui/caret.ts), the name selected. The status line under it blurs across to how to finish. Return saves: the words
|
||||||
// while the router answers (ui/shimmer.ts), settle, and the card is drawn again with the new name, its status
|
// shimmer while the router answers (ui/shimmer.ts), settle, and the card is drawn again with the new name, its
|
||||||
// morphing back from the hint. Esc or a click away puts the name it had back, whatever was typed. What the router
|
// status blurring back from the hint. Esc or a click away puts the name it had back, whatever was typed. What the
|
||||||
// won't take never gets in (shared/name-guard.ts): the words shake and the status line says why in red; the
|
// router won't take never gets in (shared/name-guard.ts): the words shake and the status line says why in red; the
|
||||||
// router's own refusals (a name taken) say so the same way.
|
// router's own refusals (a name taken) say so the same way.
|
||||||
|
|
||||||
import type { Device } from '../../shared/types';
|
import type { Device } from '../../shared/types';
|
||||||
@@ -13,22 +13,25 @@ import { call } from '../api';
|
|||||||
import { h } from '../dom';
|
import { h } from '../dom';
|
||||||
import { repaint, setState, state, type State } from '../state';
|
import { repaint, setState, state, type State } from '../state';
|
||||||
import { smoothCaret } from '../ui/caret';
|
import { smoothCaret } from '../ui/caret';
|
||||||
import { morphText } from '../ui/morph';
|
import { morphText, textOf } from '../ui/morph';
|
||||||
import { shimmer } from '../ui/shimmer';
|
import { shimmer } from '../ui/shimmer';
|
||||||
|
|
||||||
/** The status line's colours (page/devices.ts), and the red of a refusal. */
|
/** The status line's colours (page/devices.ts), and the red of a refusal. */
|
||||||
const TONES = ['ok-t', 'warn-t', 'here-t', 'bad-t'];
|
const TONES = ['ok-t', 'warn-t', 'here-t', 'bad-t'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The status line says something else in another tone: its words morph and the colour turns from the one it
|
* The status line says something else in another tone: the hint or a refusal stands in for the status, so the
|
||||||
* had, as a repaint's status does. Only the tone classes change hands: a morph under way keeps its own.
|
* words blur across whole (not letter by letter) and the colour turns from the one it had. Marked `data-whole`
|
||||||
|
* meanwhile: the repaint after a save brings the status back the same way. Only the tone classes change hands: a
|
||||||
|
* morph under way keeps its own.
|
||||||
*/
|
*/
|
||||||
function say(stat: HTMLElement, text: string, tone: string, title = text) {
|
function say(stat: HTMLElement, text: string, tone: string, title = text) {
|
||||||
const color = getComputedStyle(stat).color;
|
const color = getComputedStyle(stat).color;
|
||||||
for (const t of TONES) stat.classList.toggle(t, t === tone);
|
for (const t of TONES) stat.classList.toggle(t, t === tone);
|
||||||
// The line is one line: a long reason (the router's own) reads in full on hover.
|
// The line is one line: a long reason (the router's own) reads in full on hover.
|
||||||
stat.title = title;
|
stat.title = title;
|
||||||
morphText(stat, text, undefined, { color });
|
stat.dataset.whole = '';
|
||||||
|
morphText(stat, text, undefined, { color, whole: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,7 +57,8 @@ export function renameOnCard(d: Device, card: HTMLElement) {
|
|||||||
const name = card.querySelector<HTMLElement>('.dev-name');
|
const name = card.querySelector<HTMLElement>('.dev-name');
|
||||||
const stat = card.querySelector<HTMLElement>('.dev-stat');
|
const stat = card.querySelector<HTMLElement>('.dev-stat');
|
||||||
if (!name || !stat) return;
|
if (!name || !stat) return;
|
||||||
const was = { text: stat.textContent ?? '', tone: TONES.find((t) => stat.classList.contains(t)) ?? '', title: stat.title };
|
// What it says, not what shows: still morphing (a rename just let go), it holds both its old and new letters.
|
||||||
|
const was = { text: textOf(stat), tone: TONES.find((t) => stat.classList.contains(t)) ?? '', title: stat.title };
|
||||||
// How to finish, where a keyboard says it; on a touch screen its Done key saves.
|
// How to finish, where a keyboard says it; on a touch screen its Done key saves.
|
||||||
const hint = matchMedia('(pointer: fine)').matches ? _('Return to save, Esc to cancel') : '';
|
const hint = matchMedia('(pointer: fine)').matches ? _('Return to save, Esc to cancel') : '';
|
||||||
|
|
||||||
@@ -100,9 +104,12 @@ export function renameOnCard(d: Device, card: HTMLElement) {
|
|||||||
if (saved) name.textContent = saved;
|
if (saved) name.textContent = saved;
|
||||||
name.hidden = false;
|
name.hidden = false;
|
||||||
form.remove();
|
form.remove();
|
||||||
// Saved: the hint stays for the repaint, which morphs it into the status (words and colour) as it does any
|
// Saved: the hint stays for the repaint, which blurs it into the status (words and colour). Let go: it turns
|
||||||
// status that changed. Let go: it turns back here.
|
// back here, and is the status again (a repaint morphs it letter by letter).
|
||||||
if (!saved) say(stat, was.text, was.tone, was.title);
|
if (!saved) {
|
||||||
|
say(stat, was.text, was.tone, was.title);
|
||||||
|
delete stat.dataset.whole;
|
||||||
|
}
|
||||||
if (!back) return;
|
if (!back) return;
|
||||||
// After a save the card is drawn again: the name is found anew then.
|
// After a save the card is drawn again: the name is found anew then.
|
||||||
if (saved)
|
if (saved)
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export interface SetupCtx {
|
|||||||
* A badge: the mark in a tile, two lines, a chevron (an action) or the open
|
* A badge: the mark in a tile, two lines, a chevron (an action) or the open
|
||||||
* mark (a store page, in a new tab). `primary`: the one thing to tap in step 2.
|
* mark (a store page, in a new tab). `primary`: the one thing to tap in step 2.
|
||||||
*/
|
*/
|
||||||
export function badge(
|
function badge(
|
||||||
st: { href?: string; top: string; main: string; mark: string; onclick?: (ev: Event) => void },
|
st: { href?: string; top: string; main: string; mark: string; onclick?: (ev: Event) => void },
|
||||||
primary = false,
|
primary = false,
|
||||||
): HTMLElement {
|
): HTMLElement {
|
||||||
@@ -335,7 +335,7 @@ export interface ConnPill {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Beside ×: the connection itself, to download or copy, where the sheet offers
|
* On its row, beside the chevron: the connection itself, to download or copy, where the sheet offers
|
||||||
* neither (a phone or a tablet set up from elsewhere). One tooltip for both
|
* neither (a phone or a tablet set up from elsewhere). One tooltip for both
|
||||||
* keys, under them: the first waits a beat; once one is up the next comes at
|
* keys, under them: the first waits a beat; once one is up the next comes at
|
||||||
* once and the tooltip glides across (by Tab too, and back to a key while it
|
* once and the tooltip glides across (by Tab too, and back to a key while it
|
||||||
@@ -354,11 +354,11 @@ export function connPill(get: () => { text: string; msg: string; file: string; a
|
|||||||
let tipT = 0;
|
let tipT = 0;
|
||||||
let warmUntil = 0;
|
let warmUntil = 0;
|
||||||
const words = (b: HTMLElement) => (b === cp && cp.classList.contains('done') ? _('Copied') : (b.getAttribute('aria-label') ?? ''));
|
const words = (b: HTMLElement) => (b === cp && cp.classList.contains('done') ? _('Copied') : (b.getAttribute('aria-label') ?? ''));
|
||||||
// Centred under its key, but never past the sheet's edge (× and its margin to the right).
|
// Centred under its key, but never past its row's edge (the chevron and the row's inset to the right).
|
||||||
const centre = (b: HTMLElement, t: string) => {
|
const centre = (b: HTMLElement, t: string) => {
|
||||||
tm.textContent = t;
|
tm.textContent = t;
|
||||||
const w = tm.offsetWidth + 20;
|
const w = tm.offsetWidth + 20;
|
||||||
return Math.min(b.offsetLeft + b.offsetWidth / 2, el.offsetWidth + 46 - w / 2);
|
return Math.min(b.offsetLeft + b.offsetWidth / 2, el.offsetWidth + 30 - w / 2);
|
||||||
};
|
};
|
||||||
const at = (x: number) => `translateX(${x}px) translateX(-50%)`;
|
const at = (x: number) => `translateX(${x}px) translateX(-50%)`;
|
||||||
/** Where the tooltip stands now: mid-fade and mid-glide included. */
|
/** Where the tooltip stands now: mid-fade and mid-glide included. */
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
// computer, or another device added from a phone, its link or the connection
|
// computer, or another device added from a phone, its link or the connection
|
||||||
// to send there. Which app and where it comes from follow the
|
// to send there. Which app and where it comes from follow the
|
||||||
// server's disguise and the platform (setup.ts). The wait for the first
|
// server's disguise and the platform (setup.ts). The wait for the first
|
||||||
// connection sits on top the whole time (wait.ts); on the device itself and for
|
// connection sits on top the whole time (wait.ts); once the device is heard
|
||||||
// a router the steps regroup under it as it goes (can't finish, no data).
|
// from (can't finish, no data, connected) what is under it folds away.
|
||||||
|
|
||||||
import type { ClientConfig, Device } from '../../shared/types';
|
import type { ClientConfig, Device } from '../../shared/types';
|
||||||
import { fmt } from '../../shared/i18n';
|
import { fmt } from '../../shared/i18n';
|
||||||
@@ -17,7 +17,7 @@ import { h, put } from '../dom';
|
|||||||
import { SMOOTH, play } from '../motion';
|
import { SMOOTH, play } from '../motion';
|
||||||
import { APP_NAME, appsFor, deviceNoun, inWebview, keyFileName, sameDevice, setupLink, type AppId } from '../setup';
|
import { APP_NAME, appsFor, deviceNoun, inWebview, keyFileName, sameDevice, setupLink, type AppId } from '../setup';
|
||||||
import { pageUrl, platform, preset, repaint } from '../state';
|
import { pageUrl, platform, preset, repaint } from '../state';
|
||||||
import { accordion, regrow, type Accordion } from '../ui/accordion';
|
import { accordion, regrow } from '../ui/accordion';
|
||||||
import { codeRow, linkRow, type CodeRow } from '../ui/codes';
|
import { codeRow, linkRow, type CodeRow } from '../ui/codes';
|
||||||
import { once, toast } from '../ui/feedback';
|
import { once, toast } from '../ui/feedback';
|
||||||
import { glass } from '../ui/glass';
|
import { glass } from '../ui/glass';
|
||||||
@@ -39,7 +39,6 @@ import {
|
|||||||
storeBlock,
|
storeBlock,
|
||||||
type SetupCtx,
|
type SetupCtx,
|
||||||
} from './setup-parts';
|
} from './setup-parts';
|
||||||
import type { WayState } from '../way';
|
|
||||||
import { follow, waitWay, watchFirstConnection } from './wait';
|
import { follow, waitWay, watchFirstConnection } from './wait';
|
||||||
|
|
||||||
async function getConfig(d: Device): Promise<ClientConfig | null> {
|
async function getConfig(d: Device): Promise<ClientConfig | null> {
|
||||||
@@ -114,69 +113,9 @@ function foldBlock(el: HTMLElement, fold: boolean, instant: boolean) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The first control in `el` that can take focus now (shown, not disabled). */
|
|
||||||
const firstControl = (el: Element | null | undefined) =>
|
|
||||||
[...(el?.querySelectorAll<HTMLElement>('button:not([disabled]), a[href], input:not([disabled])') ?? [])].find(
|
|
||||||
(x) => x.getClientRects().length > 0,
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The steps on the device itself or for a router, as the way goes (way.ts); the
|
|
||||||
* layouts set up from elsewhere have rows, no steps. Waiting: the steps as
|
|
||||||
* built (connected is never asked: what shows folds shut as it is, wait.ts
|
|
||||||
* follow). Can't finish: the network is the likely cause, so they fold
|
|
||||||
* into one closed row, "Set it up again". No data: only what fixes it, open in
|
|
||||||
* one row, "Add the connection again" ("Import the configuration again" for a
|
|
||||||
* router): the connection step without its number and title. A router that
|
|
||||||
* knocks has AmneziaWG on it already, so its row holds that step alone in both.
|
|
||||||
* What sits on field inside the row steps up one (accordion.css). "Not on the X
|
|
||||||
* right now?" (`round`, on the device itself) goes in both: the device is in
|
|
||||||
* hand. Focus inside what moves (a badge just used) stays in the sheet: on that
|
|
||||||
* control where it still shows, else on the first one of what holds the steps
|
|
||||||
* now. Returns whether anything changed.
|
|
||||||
*/
|
|
||||||
function regroup(body: HTMLElement, steps: HTMLElement, round: Accordion | null, router: boolean): (st: WayState) => boolean {
|
|
||||||
const [s1, s2] = [...steps.children].slice(-2) as HTMLElement[];
|
|
||||||
const gap = steps.querySelector<HTMLElement>(':scope > .steps-gap');
|
|
||||||
const head2 = [...s2.querySelectorAll<HTMLElement>(':scope > .step-n, :scope > .step-b > .step-t')];
|
|
||||||
let look: 'steps' | 'again' | 'conn' = 'steps';
|
|
||||||
let row: HTMLElement | null = null;
|
|
||||||
return (st) => {
|
|
||||||
const next = st === 'trying' ? 'again' : st === 'nodata' ? 'conn' : 'steps';
|
|
||||||
if (next === look) return false;
|
|
||||||
look = next;
|
|
||||||
// Moving a focused control out of the page and back drops its focus (to the page under the sheet).
|
|
||||||
const had = document.activeElement;
|
|
||||||
const inside = had instanceof HTMLElement && (steps.contains(had) || !!round?.el.contains(had) || !!row?.contains(had));
|
|
||||||
row?.remove();
|
|
||||||
row = null;
|
|
||||||
// The steps show whole wherever they go: opened, the way round folds them away.
|
|
||||||
round?.setOpen(-1);
|
|
||||||
if (round) round.el.hidden = next !== 'steps';
|
|
||||||
const alone = next === 'conn' || (next === 'again' && router);
|
|
||||||
for (const e of [gap, s1, ...head2]) if (e) e.hidden = alone;
|
|
||||||
if (next === 'steps') body.append(steps);
|
|
||||||
else {
|
|
||||||
const title = next === 'again' ? _('Set it up again') : router ? _('Import the configuration again') : _('Add the connection again');
|
|
||||||
row = accordion([{ icon: glass('refresh', 'blue'), title, body: [steps] }], { inset: true, open: next === 'conn' ? 0 : -1 }).el;
|
|
||||||
body.append(row);
|
|
||||||
}
|
|
||||||
if (inside) {
|
|
||||||
const to =
|
|
||||||
had.isConnected && had.getClientRects().length
|
|
||||||
? had
|
|
||||||
: next === 'again'
|
|
||||||
? row?.querySelector<HTMLElement>('.acc-head')
|
|
||||||
: firstControl(alone ? s2 : steps);
|
|
||||||
to?.focus({ preventScroll: true });
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
type Layout = 'same' | 'router' | 'away' | 'pc-away';
|
type Layout = 'same' | 'router' | 'away' | 'pc-away';
|
||||||
|
|
||||||
export function setupView(d: Device, cfg: ClientConfig, key: string, here = false): View {
|
function setupView(d: Device, cfg: ClientConfig, key: string, here = false): View {
|
||||||
const pf = platform();
|
const pf = platform();
|
||||||
const apps = appsFor(preset());
|
const apps = appsFor(preset());
|
||||||
const handheld = d.kind === 'phone' || d.kind === 'tablet';
|
const handheld = d.kind === 'phone' || d.kind === 'tablet';
|
||||||
@@ -280,52 +219,50 @@ export function setupView(d: Device, cfg: ClientConfig, key: string, here = fals
|
|||||||
: h('p', { class: 'desc' }, fmt(_('Open this link on the %s to set it up there.'), thereOn)),
|
: h('p', { class: 'desc' }, fmt(_('Open this link on the %s to set it up there.'), thereOn)),
|
||||||
linkRow(linkThere),
|
linkRow(linkThere),
|
||||||
];
|
];
|
||||||
const step1 = () => step('1', title1, [picker(), getBox]);
|
const inSteps = layout === 'same' || layout === 'router';
|
||||||
const step2 = () => step('2', router ? _('Import the configuration') : _('Add the connection'), [addBox]);
|
// The connection, one element: its picker (none in step 2: step 1's is there) and its layout's box.
|
||||||
|
const pickEl = inSteps ? null : picker();
|
||||||
|
const pick = pickEl ? h('div', { class: 'conn-pick' }, pickEl) : null;
|
||||||
|
const box = layout === 'away' ? codeBox : layout === 'pc-away' ? sendBox : addBox;
|
||||||
|
const conn = h('div', { class: 'conn' }, pick, box);
|
||||||
|
|
||||||
const body = h('div', { class: 'setup' });
|
const body = h('div', { class: 'setup' });
|
||||||
if (inWebview(navigator.userAgent))
|
if (inWebview(navigator.userAgent))
|
||||||
body.appendChild(
|
body.appendChild(
|
||||||
notice('warn', 'shield', null, _('Open this page in Safari or Chrome: the store opens from here, but the app handoff does not.')),
|
notice('warn', 'shield', null, _('Open this page in Safari or Chrome: the store opens from here, but the app handoff does not.')),
|
||||||
);
|
);
|
||||||
let shape: (st: WayState) => boolean = () => false;
|
const steps = () =>
|
||||||
|
h(
|
||||||
|
'div',
|
||||||
|
{ class: 'steps-wrap' },
|
||||||
|
layout === 'same' ? h('div', { class: 'steps-gap' }) : null,
|
||||||
|
step('1', title1, [picker(), getBox]),
|
||||||
|
step('2', router ? _('Import the configuration') : _('Add the connection'), [conn]),
|
||||||
|
);
|
||||||
|
/** The link to the device and the connection beside it, as rows (`open`: the one open as it starts). */
|
||||||
|
const rows = (icon: string, title: string, open: number, aside: Node | null = null) =>
|
||||||
|
accordion(
|
||||||
|
[
|
||||||
|
{ icon: glass('link'), title: fmt(_('Open your link on the %s'), thereOn), body: linkBody() },
|
||||||
|
{ icon: glass(icon), title, body: [conn], aside },
|
||||||
|
],
|
||||||
|
{ inset: true, open },
|
||||||
|
).el;
|
||||||
if (layout === 'same') {
|
if (layout === 'same') {
|
||||||
// Opened, the way round folds the steps away: the device is not in hand.
|
// Opened, the way round folds the steps away: the device is not in hand.
|
||||||
const steps = h('div', { class: 'steps-wrap' }, h('div', { class: 'steps-gap' }), step1(), step2());
|
const s = steps();
|
||||||
const round = accordion([{ icon: glass('link'), title: fmt(_('Not on the %s right now?'), thereOn), body: linkBody() }], {
|
const round = accordion([{ icon: glass('link'), title: fmt(_('Not on the %s right now?'), thereOn), body: linkBody() }], {
|
||||||
inset: true,
|
inset: true,
|
||||||
onToggle: (_i, open, instant) => foldBlock(steps, open, instant),
|
onToggle: (_i, open, instant) => foldBlock(s, open, instant),
|
||||||
});
|
});
|
||||||
body.append(round.el, steps);
|
body.append(round.el, s);
|
||||||
shape = regroup(body, steps, round, false);
|
} else if (layout === 'router') body.append(steps());
|
||||||
} else if (layout === 'router') {
|
|
||||||
const steps = h('div', { class: 'steps-wrap' }, step1(), step2());
|
|
||||||
body.append(steps);
|
|
||||||
shape = regroup(body, steps, null, true);
|
|
||||||
}
|
|
||||||
// A phone or a tablet set up from here: its link as a code, or the connection as a code for an app it has.
|
// A phone or a tablet set up from here: its link as a code, or the connection as a code for an app it has.
|
||||||
else if (layout === 'away')
|
// The connection's download and copy sit on its own row, while it is open.
|
||||||
body.appendChild(
|
else if (layout === 'away') body.append(rows('app', _('Add the connection'), 1, pill?.el ?? null));
|
||||||
accordion(
|
|
||||||
[
|
|
||||||
{ icon: glass('link'), title: fmt(_('Open your link on the %s'), thereOn), body: linkBody() },
|
|
||||||
{ icon: glass('app'), title: _('Already has the app'), body: [picker(), codeBox] },
|
|
||||||
],
|
|
||||||
{ inset: true, open: 1 },
|
|
||||||
).el,
|
|
||||||
);
|
|
||||||
// A computer set up from somewhere else, or something else (a TV, a box, a NAS) set up from a phone: its system is
|
// A computer set up from somewhere else, or something else (a TV, a box, a NAS) set up from a phone: its system is
|
||||||
// not known here, so the link goes there and the page there does both steps.
|
// not known here, so the link goes there and the page there does both steps.
|
||||||
else
|
else body.append(rows('key', _('Copy or save the connection'), 0));
|
||||||
body.appendChild(
|
|
||||||
accordion(
|
|
||||||
[
|
|
||||||
{ icon: glass('link'), title: fmt(_('Open your link on the %s'), thereOn), body: linkBody() },
|
|
||||||
{ icon: glass('key'), title: _('Copy or save the connection'), body: [picker(), sendBox] },
|
|
||||||
],
|
|
||||||
{ inset: true, open: 0 },
|
|
||||||
).el,
|
|
||||||
);
|
|
||||||
|
|
||||||
const subline = sub(
|
const subline = sub(
|
||||||
layout === 'same'
|
layout === 'same'
|
||||||
@@ -335,12 +272,12 @@ export function setupView(d: Device, cfg: ClientConfig, key: string, here = fals
|
|||||||
: fmt(_('The app goes on the %s.'), there),
|
: fmt(_('The app goes on the %s.'), there),
|
||||||
);
|
);
|
||||||
const way = waitWay(d);
|
const way = waitWay(d);
|
||||||
const wait = follow(d, way, { sub: subline, rest: body, shape });
|
const wait = follow(d, way, { sub: subline, rest: body });
|
||||||
onLeave(watchFirstConnection(d, wait.seen, wait.gaveUp));
|
onLeave(watchFirstConnection(d, wait.seen, wait.gaveUp));
|
||||||
// Closed before the device connected: the page shows what the polls brought.
|
// Closed before the device connected: the page shows what the polls brought.
|
||||||
onClosed(() => repaint());
|
onClosed(() => repaint());
|
||||||
|
|
||||||
const title = fmt(_('Set up %s'), d.name);
|
const title = fmt(_('Set up %s'), d.name);
|
||||||
const el = h('div', { class: 'view' }, head(title, { acts: !!pill }), subline, way.el, body);
|
const el = h('div', { class: 'view' }, head(title), subline, way.el, body);
|
||||||
return { el, label: title, acts: pill?.el ?? null };
|
return { el, label: title };
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,9 @@
|
|||||||
// the sheet around it keeping pace. Connected, the way fills green and its line
|
// the sheet around it keeping pace. Connected, the way fills green and its line
|
||||||
// morphs into "<device> connected", × and the sheet's buttons step away,
|
// morphs into "<device> connected", × and the sheet's buttons step away,
|
||||||
// everything under the way folds shut and the sheet closes by itself onto the
|
// everything under the way folds shut and the sheet closes by itself onto the
|
||||||
// page; any other state undoes that. What sits under the way in each state is
|
// page. Can't finish and no data fold what is under the way the same and keep
|
||||||
// the view's (setup-view.ts hands it over as `Around`).
|
// the sheet; waiting again unfolds it. What sits under the way is the view's
|
||||||
|
// (setup-view.ts hands it over as `Around`).
|
||||||
|
|
||||||
import type { Device } from '../../shared/types';
|
import type { Device } from '../../shared/types';
|
||||||
import { fmt } from '../../shared/i18n';
|
import { fmt } from '../../shared/i18n';
|
||||||
@@ -13,7 +14,7 @@ import { gone, call } from '../api';
|
|||||||
import { h, ic } from '../dom';
|
import { h, ic } from '../dom';
|
||||||
import { EASE_IN, EASE_OUT, calm, play } from '../motion';
|
import { EASE_IN, EASE_OUT, calm, play } from '../motion';
|
||||||
import { now, repaint, setState, type State } from '../state';
|
import { now, repaint, setState, type State } from '../state';
|
||||||
import { menuOpen } from '../ui/menu';
|
import { dropOpen } from '../ui/drop';
|
||||||
import { morphText, setText, textOf } from '../ui/morph';
|
import { morphText, setText, textOf } from '../ui/morph';
|
||||||
import { closeSheet, onClosed, scrollTop, settle, showing } from '../ui/sheet';
|
import { closeSheet, onClosed, scrollTop, settle, showing } from '../ui/sheet';
|
||||||
import { wayState, type WayState } from '../way';
|
import { wayState, type WayState } from '../way';
|
||||||
@@ -34,7 +35,7 @@ function lines(st: WayState, d: Device): [string, string] {
|
|||||||
case 'connected':
|
case 'connected':
|
||||||
return [fmt(_('%s connected'), d.name), ''];
|
return [fmt(_('%s connected'), d.name), ''];
|
||||||
case 'nodata':
|
case 'nodata':
|
||||||
return [_('Handshake complete, but no data'), _('This device is using an outdated configuration.')];
|
return [_('Handshake complete, but no data'), _('The router drops its traffic: the address does not match.')];
|
||||||
case 'waiting':
|
case 'waiting':
|
||||||
return [_('Waiting for the connection'), ''];
|
return [_('Waiting for the connection'), ''];
|
||||||
}
|
}
|
||||||
@@ -185,7 +186,7 @@ function catchUp(id: string, tries = 4) {
|
|||||||
try {
|
try {
|
||||||
const st = await call<State>('state');
|
const st = await call<State>('state');
|
||||||
setState(st);
|
setState(st);
|
||||||
if (!menuOpen()) repaint();
|
if (!dropOpen()) repaint();
|
||||||
if (!st.person.devices.find((x) => x.id === id)?.online && tries > 1) catchUp(id, tries - 1);
|
if (!st.person.devices.find((x) => x.id === id)?.online && tries > 1) catchUp(id, tries - 1);
|
||||||
} catch {
|
} catch {
|
||||||
/* a hiccup: the page keeps the last answer, as on load */
|
/* a hiccup: the page keeps the last answer, as on load */
|
||||||
@@ -274,8 +275,6 @@ export interface Around {
|
|||||||
sub: HTMLElement;
|
sub: HTMLElement;
|
||||||
/** Everything under the way. */
|
/** Everything under the way. */
|
||||||
rest: HTMLElement;
|
rest: HTMLElement;
|
||||||
/** Give what is under the way its shape for this state, at once (the glide is here); false: nothing changed. */
|
|
||||||
shape(st: WayState): boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Blocks folded away, held at nothing until they come back. */
|
/** Blocks folded away, held at nothing until they come back. */
|
||||||
@@ -337,28 +336,6 @@ function gap(way: HTMLElement, away: boolean) {
|
|||||||
play(way, [{ marginBottom: from }, { marginBottom: to }], { duration: 520, easing: EASE_OUT, fill: away ? 'forwards' : 'none' });
|
play(way, [{ marginBottom: from }, { marginBottom: to }], { duration: 520, easing: EASE_OUT, fill: away ? 'forwards' : 'none' });
|
||||||
}
|
}
|
||||||
|
|
||||||
/** What is under the way takes another shape: it glides to its new height, and what came in blurs in. */
|
|
||||||
function reshape(a: Around, st: WayState) {
|
|
||||||
const rest = a.rest;
|
|
||||||
// From where it stands on screen (a glide under way included) to its new height.
|
|
||||||
const h0 = rest.getBoundingClientRect().height;
|
|
||||||
if (!a.shape(st)) return;
|
|
||||||
rest.getAnimations().forEach((x) => x.cancel());
|
|
||||||
const h1 = rest.getBoundingClientRect().height;
|
|
||||||
rest.style.overflow = 'hidden';
|
|
||||||
play(rest, [{ height: `${h0}px` }, { height: `${h1}px` }], { duration: 420, easing: EASE_OUT }).onfinish = () => {
|
|
||||||
rest.style.overflow = '';
|
|
||||||
};
|
|
||||||
play(
|
|
||||||
rest,
|
|
||||||
[
|
|
||||||
{ opacity: 0.4, filter: 'blur(2px)' },
|
|
||||||
{ opacity: 1, filter: 'none' },
|
|
||||||
],
|
|
||||||
{ duration: 320, easing: EASE_OUT },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** What the sheet does as the wait goes on (follow). */
|
/** What the sheet does as the wait goes on (follow). */
|
||||||
export interface Following {
|
export interface Following {
|
||||||
/** A new state of the way. */
|
/** A new state of the way. */
|
||||||
@@ -371,14 +348,23 @@ export interface Following {
|
|||||||
* The sheet keeps pace with the way. Connected: × and the buttons beside it
|
* The sheet keeps pace with the way. Connected: × and the buttons beside it
|
||||||
* step away, the sheet goes back up to the way if it was scrolled, everything
|
* step away, the sheet goes back up to the way if it was scrolled, everything
|
||||||
* under the way folds shut with the way's gap to it, and after two seconds to
|
* under the way folds shut with the way's gap to it, and after two seconds to
|
||||||
* read it the sheet closes by itself onto the page, the card ringing green. Any
|
* read it the sheet closes by itself onto the page, the card ringing green.
|
||||||
* other state undoes that (× comes back, what folded unfolds) and gives what is
|
* Can't finish or no data: what is under the way folds shut the same, at once,
|
||||||
* under the way its shape. The subtitle says what setting up takes, so it shows
|
* and the sheet stays (adding the connection again would not help: the way
|
||||||
* only while waiting: once the device is heard from, or the wait gives up, it
|
* says what would). Waiting again undoes that (× comes back, what folded
|
||||||
* folds away, the way then right under the head.
|
* unfolds). The subtitle says what setting up takes, so it shows only while
|
||||||
|
* waiting: once the device is heard from, or the wait gives up, it folds away,
|
||||||
|
* the way then right under the head.
|
||||||
*/
|
*/
|
||||||
export function follow(d: Device, way: Way, a: Around): Following {
|
export function follow(d: Device, way: Way, a: Around): Following {
|
||||||
|
/** What is under the way is folded shut, the way's gap to it with it. */
|
||||||
let shut = false;
|
let shut = false;
|
||||||
|
const shutRest = (away: boolean) => {
|
||||||
|
if (shut === away) return;
|
||||||
|
shut = away;
|
||||||
|
fold(a.rest, away, 520);
|
||||||
|
gap(way.el, away);
|
||||||
|
};
|
||||||
let timers: number[] = [];
|
let timers: number[] = [];
|
||||||
const later = (ms: number, f: () => void) => timers.push(window.setTimeout(f, ms));
|
const later = (ms: number, f: () => void) => timers.push(window.setTimeout(f, ms));
|
||||||
const seen = (st: WayState) => {
|
const seen = (st: WayState) => {
|
||||||
@@ -391,9 +377,7 @@ export function follow(d: Device, way: Way, a: Around): Following {
|
|||||||
scrollTop();
|
scrollTop();
|
||||||
later(400, () => {
|
later(400, () => {
|
||||||
if (!showing(way.el)) return;
|
if (!showing(way.el)) return;
|
||||||
shut = true;
|
shutRest(true);
|
||||||
fold(a.rest, true, 520);
|
|
||||||
gap(way.el, true);
|
|
||||||
// Reading time, not motion: the same with less motion.
|
// Reading time, not motion: the same with less motion.
|
||||||
later(2400, () => {
|
later(2400, () => {
|
||||||
// Only this sheet: not one the visitor went on to.
|
// Only this sheet: not one the visitor went on to.
|
||||||
@@ -404,12 +388,7 @@ export function follow(d: Device, way: Way, a: Around): Following {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!shut) return reshape(a, st);
|
shutRest(st !== 'waiting');
|
||||||
// Folded while it was connected: it unfolds straight into its new shape.
|
|
||||||
shut = false;
|
|
||||||
a.shape(st);
|
|
||||||
fold(a.rest, false, 520);
|
|
||||||
gap(way.el, false);
|
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
seen,
|
seen,
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
Geist and Geist Mono are licensed under the SIL Open Font License, Version 1.1.
|
|
||||||
Copyright (c) 2023 Vercel, in collaboration with basement.studio.
|
|
||||||
https://github.com/vercel/geist-font/blob/main/OFL.txt
|
|
||||||
@@ -230,10 +230,6 @@ msgstr ""
|
|||||||
msgid "Add the connection"
|
msgid "Add the connection"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/portal/flows/setup-view.ts
|
|
||||||
msgid "Add the connection again"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: web/src/portal/page/devices.ts
|
#: web/src/portal/page/devices.ts
|
||||||
msgid "Add this device"
|
msgid "Add this device"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -255,10 +251,6 @@ msgstr ""
|
|||||||
msgid "Address copied"
|
msgid "Address copied"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/portal/flows/setup-view.ts
|
|
||||||
msgid "Already has the app"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/devices.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/devices.uc
|
||||||
msgid "AmneziaWG is not installed (%s): install it in Dawnline → Components."
|
msgid "AmneziaWG is not installed (%s): install it in Dawnline → Components."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -378,6 +370,10 @@ msgstr ""
|
|||||||
msgid "Copy IP address"
|
msgid "Copy IP address"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/portal/flows/page-code.ts
|
||||||
|
msgid "Copy link"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/portal/page/devices.ts
|
#: web/src/portal/page/devices.ts
|
||||||
msgid "Copy local address"
|
msgid "Copy local address"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -399,6 +395,7 @@ msgctxt "in a sentence"
|
|||||||
msgid "Copy the key"
|
msgid "Copy the key"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/portal/flows/page-code.ts
|
||||||
#: web/src/portal/ui/codes.ts
|
#: web/src/portal/ui/codes.ts
|
||||||
msgid "Copy the link"
|
msgid "Copy the link"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -677,10 +674,6 @@ msgstr ""
|
|||||||
msgid "Import the configuration"
|
msgid "Import the configuration"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/portal/flows/setup-view.ts
|
|
||||||
msgid "Import the configuration again"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: web/src/portal/setup.ts
|
#: web/src/portal/setup.ts
|
||||||
msgctxt "WireGuard app"
|
msgctxt "WireGuard app"
|
||||||
msgid "Import tunnel(s) from file…"
|
msgid "Import tunnel(s) from file…"
|
||||||
@@ -790,6 +783,7 @@ msgstr ""
|
|||||||
msgid "Last connected %s"
|
msgid "Last connected %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/portal/flows/page-code.ts
|
||||||
#: web/src/portal/ui/codes.ts
|
#: web/src/portal/ui/codes.ts
|
||||||
msgid "Link copied"
|
msgid "Link copied"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1037,10 +1031,6 @@ msgstr ""
|
|||||||
msgid "Point its camera at the code: the link opens there."
|
msgid "Point its camera at the code: the link opens there."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/portal/flows/page-code.ts
|
|
||||||
msgid "Point its camera at the code: this page opens there."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: web/src/portal/flows/add.ts
|
#: web/src/portal/flows/add.ts
|
||||||
msgid "Point its camera at the code: your page opens there with this device ready to add."
|
msgid "Point its camera at the code: your page opens there with this device ready to add."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1149,10 +1139,6 @@ msgstr ""
|
|||||||
msgid "Server is turned off"
|
msgid "Server is turned off"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/portal/flows/setup-view.ts
|
|
||||||
msgid "Set it up again"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: web/src/portal/flows/setup-view.ts
|
#: web/src/portal/flows/setup-view.ts
|
||||||
#: web/src/portal/page/devices.ts
|
#: web/src/portal/page/devices.ts
|
||||||
msgid "Set up %s"
|
msgid "Set up %s"
|
||||||
@@ -1182,6 +1168,7 @@ msgstr ""
|
|||||||
msgid "Share the file"
|
msgid "Share the file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/portal/flows/page-code.ts
|
||||||
#: web/src/portal/ui/codes.ts
|
#: web/src/portal/ui/codes.ts
|
||||||
msgid "Share the link"
|
msgid "Share the link"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1274,6 +1261,11 @@ msgstr ""
|
|||||||
msgid "The router can’t use what it sends: reconnect it."
|
msgid "The router can’t use what it sends: reconnect it."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: web/src/portal/flows/wait.ts
|
||||||
|
#: web/src/portal/page/devices.ts
|
||||||
|
msgid "The router drops its traffic: the address does not match."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/portal/flows/setup-parts.ts
|
#: web/src/portal/flows/setup-parts.ts
|
||||||
msgid "Then come back here and tap"
|
msgid "Then come back here and tap"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1290,10 +1282,6 @@ msgstr ""
|
|||||||
msgid "This device"
|
msgid "This device"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: web/src/portal/flows/wait.ts
|
|
||||||
msgid "This device is using an outdated configuration."
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
||||||
msgid "This key is already in use."
|
msgid "This key is already in use."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -235,10 +235,6 @@ msgstr "Добавить с самого устройства"
|
|||||||
msgid "Add the connection"
|
msgid "Add the connection"
|
||||||
msgstr "Добавьте подключение"
|
msgstr "Добавьте подключение"
|
||||||
|
|
||||||
#: web/src/portal/flows/setup-view.ts
|
|
||||||
msgid "Add the connection again"
|
|
||||||
msgstr "Добавить заново"
|
|
||||||
|
|
||||||
#: web/src/portal/page/devices.ts
|
#: web/src/portal/page/devices.ts
|
||||||
msgid "Add this device"
|
msgid "Add this device"
|
||||||
msgstr "Добавить это устройство"
|
msgstr "Добавить это устройство"
|
||||||
@@ -260,10 +256,6 @@ msgstr "Сейчас добавить устройство нельзя: VPN-с
|
|||||||
msgid "Address copied"
|
msgid "Address copied"
|
||||||
msgstr "Адрес скопирован"
|
msgstr "Адрес скопирован"
|
||||||
|
|
||||||
#: web/src/portal/flows/setup-view.ts
|
|
||||||
msgid "Already has the app"
|
|
||||||
msgstr "Приложение уже установлено"
|
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/devices.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/devices.uc
|
||||||
msgid "AmneziaWG is not installed (%s): install it in Dawnline → Components."
|
msgid "AmneziaWG is not installed (%s): install it in Dawnline → Components."
|
||||||
msgstr "AmneziaWG не установлен (%s): установите его в Dawnline → Компоненты."
|
msgstr "AmneziaWG не установлен (%s): установите его в Dawnline → Компоненты."
|
||||||
@@ -383,6 +375,10 @@ msgstr "Скопировать конфигурацию %s"
|
|||||||
msgid "Copy IP address"
|
msgid "Copy IP address"
|
||||||
msgstr "Скопировать IP-адрес"
|
msgstr "Скопировать IP-адрес"
|
||||||
|
|
||||||
|
#: web/src/portal/flows/page-code.ts
|
||||||
|
msgid "Copy link"
|
||||||
|
msgstr "Скопировать ссылку"
|
||||||
|
|
||||||
#: web/src/portal/page/devices.ts
|
#: web/src/portal/page/devices.ts
|
||||||
msgid "Copy local address"
|
msgid "Copy local address"
|
||||||
msgstr "Скопировать локальный адрес"
|
msgstr "Скопировать локальный адрес"
|
||||||
@@ -404,6 +400,7 @@ msgctxt "in a sentence"
|
|||||||
msgid "Copy the key"
|
msgid "Copy the key"
|
||||||
msgstr "Скопируйте ключ"
|
msgstr "Скопируйте ключ"
|
||||||
|
|
||||||
|
#: web/src/portal/flows/page-code.ts
|
||||||
#: web/src/portal/ui/codes.ts
|
#: web/src/portal/ui/codes.ts
|
||||||
msgid "Copy the link"
|
msgid "Copy the link"
|
||||||
msgstr "Скопировать ссылку"
|
msgstr "Скопировать ссылку"
|
||||||
@@ -682,10 +679,6 @@ msgstr "Импорт из файла или архива"
|
|||||||
msgid "Import the configuration"
|
msgid "Import the configuration"
|
||||||
msgstr "Импортируйте конфигурацию"
|
msgstr "Импортируйте конфигурацию"
|
||||||
|
|
||||||
#: web/src/portal/flows/setup-view.ts
|
|
||||||
msgid "Import the configuration again"
|
|
||||||
msgstr "Импортировать заново"
|
|
||||||
|
|
||||||
#: web/src/portal/setup.ts
|
#: web/src/portal/setup.ts
|
||||||
msgctxt "WireGuard app"
|
msgctxt "WireGuard app"
|
||||||
msgid "Import tunnel(s) from file…"
|
msgid "Import tunnel(s) from file…"
|
||||||
@@ -795,6 +788,7 @@ msgstr "За 7 дней"
|
|||||||
msgid "Last connected %s"
|
msgid "Last connected %s"
|
||||||
msgstr "В сети %s"
|
msgstr "В сети %s"
|
||||||
|
|
||||||
|
#: web/src/portal/flows/page-code.ts
|
||||||
#: web/src/portal/ui/codes.ts
|
#: web/src/portal/ui/codes.ts
|
||||||
msgid "Link copied"
|
msgid "Link copied"
|
||||||
msgstr "Ссылка скопирована"
|
msgstr "Ссылка скопирована"
|
||||||
@@ -1042,10 +1036,6 @@ msgstr "Выберите файл и подключитесь"
|
|||||||
msgid "Point its camera at the code: the link opens there."
|
msgid "Point its camera at the code: the link opens there."
|
||||||
msgstr "Наведите камеру устройства на код - ссылка откроется на нём."
|
msgstr "Наведите камеру устройства на код - ссылка откроется на нём."
|
||||||
|
|
||||||
#: web/src/portal/flows/page-code.ts
|
|
||||||
msgid "Point its camera at the code: this page opens there."
|
|
||||||
msgstr "Наведите камеру устройства на код - там откроется эта страница."
|
|
||||||
|
|
||||||
#: web/src/portal/flows/add.ts
|
#: web/src/portal/flows/add.ts
|
||||||
msgid "Point its camera at the code: your page opens there with this device ready to add."
|
msgid "Point its camera at the code: your page opens there with this device ready to add."
|
||||||
msgstr "Наведите камеру устройства на код - там откроется ваша страница, и его можно будет сразу добавить."
|
msgstr "Наведите камеру устройства на код - там откроется ваша страница, и его можно будет сразу добавить."
|
||||||
@@ -1154,10 +1144,6 @@ msgstr "Сервер выключен"
|
|||||||
msgid "Server is turned off"
|
msgid "Server is turned off"
|
||||||
msgstr "Сервер выключен"
|
msgstr "Сервер выключен"
|
||||||
|
|
||||||
#: web/src/portal/flows/setup-view.ts
|
|
||||||
msgid "Set it up again"
|
|
||||||
msgstr "Настроить заново"
|
|
||||||
|
|
||||||
#: web/src/portal/flows/setup-view.ts
|
#: web/src/portal/flows/setup-view.ts
|
||||||
#: web/src/portal/page/devices.ts
|
#: web/src/portal/page/devices.ts
|
||||||
msgid "Set up %s"
|
msgid "Set up %s"
|
||||||
@@ -1187,6 +1173,7 @@ msgstr "Поделиться файлом"
|
|||||||
msgid "Share the file"
|
msgid "Share the file"
|
||||||
msgstr "Поделиться файлом"
|
msgstr "Поделиться файлом"
|
||||||
|
|
||||||
|
#: web/src/portal/flows/page-code.ts
|
||||||
#: web/src/portal/ui/codes.ts
|
#: web/src/portal/ui/codes.ts
|
||||||
msgid "Share the link"
|
msgid "Share the link"
|
||||||
msgstr "Поделиться ссылкой"
|
msgstr "Поделиться ссылкой"
|
||||||
@@ -1279,6 +1266,11 @@ msgstr "У человека нет сервера."
|
|||||||
msgid "The router can’t use what it sends: reconnect it."
|
msgid "The router can’t use what it sends: reconnect it."
|
||||||
msgstr "Роутер не принимает то, что отправляет устройство: переподключите его."
|
msgstr "Роутер не принимает то, что отправляет устройство: переподключите его."
|
||||||
|
|
||||||
|
#: web/src/portal/flows/wait.ts
|
||||||
|
#: web/src/portal/page/devices.ts
|
||||||
|
msgid "The router drops its traffic: the address does not match."
|
||||||
|
msgstr "Роутер отбрасывает его трафик: адрес не совпадает."
|
||||||
|
|
||||||
#: web/src/portal/flows/setup-parts.ts
|
#: web/src/portal/flows/setup-parts.ts
|
||||||
msgid "Then come back here and tap"
|
msgid "Then come back here and tap"
|
||||||
msgstr "Затем вернитесь сюда и нажмите"
|
msgstr "Затем вернитесь сюда и нажмите"
|
||||||
@@ -1295,10 +1287,6 @@ msgstr "Это подключение стоит на двух устройст
|
|||||||
msgid "This device"
|
msgid "This device"
|
||||||
msgstr "Это устройство"
|
msgstr "Это устройство"
|
||||||
|
|
||||||
#: web/src/portal/flows/wait.ts
|
|
||||||
msgid "This device is using an outdated configuration."
|
|
||||||
msgstr "На этом устройстве устаревшая конфигурация."
|
|
||||||
|
|
||||||
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
#: package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc
|
||||||
msgid "This key is already in use."
|
msgid "This key is already in use."
|
||||||
msgstr "Этот ключ уже используется."
|
msgstr "Этот ключ уже используется."
|
||||||
|
|||||||
@@ -18,9 +18,11 @@ import { fillNotice, stateNotice } from './page/notices';
|
|||||||
import { devicesNow, devicesSection, fillDevices } from './page/devices';
|
import { devicesNow, devicesSection, fillDevices } from './page/devices';
|
||||||
import { accessSection, fillAccess } from './page/access';
|
import { accessSection, fillAccess } from './page/access';
|
||||||
import { glass, type Tone } from './ui/glass';
|
import { glass, type Tone } from './ui/glass';
|
||||||
import { closeMenu, menuOpen } from './ui/menu';
|
import { closeDrop, dropOpen } from './ui/drop';
|
||||||
import { closeSheet, sheetOpen } from './ui/sheet';
|
import { closeSheet, sheetOpen } from './ui/sheet';
|
||||||
import { renaming } from './flows/rename';
|
import { renaming } from './flows/rename';
|
||||||
|
import { keepPressFootprint } from './ui/press';
|
||||||
|
import { pageSelection } from './ui/selection';
|
||||||
import { startAdd } from './flows/add';
|
import { startAdd } from './flows/add';
|
||||||
import { openSetup } from './flows/setup-view';
|
import { openSetup } from './flows/setup-view';
|
||||||
|
|
||||||
@@ -191,7 +193,7 @@ async function refresh() {
|
|||||||
try {
|
try {
|
||||||
setState(await call<State>('state'));
|
setState(await call<State>('state'));
|
||||||
// Not under an open sheet or menu, nor a name being edited on its card.
|
// Not under an open sheet or menu, nor a name being edited on its card.
|
||||||
if (!sheetOpen() && !menuOpen() && !renaming()) render();
|
if (!sheetOpen() && !dropOpen() && !renaming()) render();
|
||||||
openFromLink();
|
openFromLink();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (gone(e)) linkGone();
|
if (gone(e)) linkGone();
|
||||||
@@ -202,15 +204,31 @@ async function refresh() {
|
|||||||
|
|
||||||
// Another language: everything is drawn again in it, the sections too (their headings are text).
|
// Another language: everything is drawn again in it, the sections too (their headings are text).
|
||||||
onLang(() => {
|
onLang(() => {
|
||||||
closeMenu(true);
|
closeDrop(true);
|
||||||
parts = null;
|
parts = null;
|
||||||
redraw();
|
redraw();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// A press that shrinks a control under the pointer still lands on it (ui/press.ts).
|
||||||
|
keepPressFootprint();
|
||||||
|
|
||||||
|
// The page's own text selection where text can be selected, as the fields draw theirs (ui/selection.ts).
|
||||||
|
pageSelection();
|
||||||
|
|
||||||
|
// The focus ring only while the keyboard moves focus (base.css .kbd): on from Tab or an arrow, off at a press.
|
||||||
|
const KEYS = new Set(['Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight']);
|
||||||
|
document.addEventListener('keydown', (e) => KEYS.has(e.key) && document.documentElement.classList.add('kbd'), true);
|
||||||
|
document.addEventListener('pointerdown', () => document.documentElement.classList.remove('kbd'), true);
|
||||||
|
|
||||||
|
// The page keeps its scale, as an app does: Safari on iOS zooms on a pinch whatever the viewport says, its own
|
||||||
|
// gesture events are the only way to stop it (the viewport and touch-action take care of the rest).
|
||||||
|
for (const ev of ['gesturestart', 'gesturechange', 'gestureend'])
|
||||||
|
document.addEventListener(ev, (e) => e.preventDefault(), { passive: false });
|
||||||
|
|
||||||
// What the keyboard does never animates.
|
// What the keyboard does never animates.
|
||||||
document.addEventListener('keydown', (e) => {
|
document.addEventListener('keydown', (e) => {
|
||||||
if (e.key !== 'Escape') return;
|
if (e.key !== 'Escape') return;
|
||||||
if (menuOpen()) closeMenu(true);
|
if (dropOpen()) closeDrop(true);
|
||||||
else if (sheetOpen()) closeSheet(true);
|
else if (sheetOpen()) closeSheet(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,25 @@
|
|||||||
// BOUNCY is the skiper103 accordion (about 11% overshoot), SMOOTH the skiper21
|
// BOUNCY is the skiper103 accordion (about 11% overshoot), SMOOTH the skiper21
|
||||||
// tab pill (critically damped). Reduced motion keeps fades and drops travel.
|
// tab pill (critically damped). Reduced motion keeps fades and drops travel.
|
||||||
|
|
||||||
|
/** Asked once and kept (it answers as the setting changes): play() asks on every animation. */
|
||||||
|
const REDUCE = typeof matchMedia === 'function' ? matchMedia('(prefers-reduced-motion: reduce)') : null;
|
||||||
|
|
||||||
/** The visitor asked for less motion: fades only, nothing travels. */
|
/** The visitor asked for less motion: fades only, nothing travels. */
|
||||||
export const calm = (): boolean => typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
export const calm = (): boolean => !!REDUCE?.matches;
|
||||||
|
|
||||||
|
/** Past this many px² a blur is a large layer's, drawn anew on every frame: it fades without. */
|
||||||
|
const BIG_BLUR = 30_000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A large element's frames without their blur (a fold, an accordion's body, a sheet): opacity, movement and size
|
||||||
|
* go on as they were. Letters, icons and small things keep theirs.
|
||||||
|
*/
|
||||||
|
function lean(el: Element, frames: Keyframe[]): Keyframe[] {
|
||||||
|
if (!frames.some((f) => 'filter' in f)) return frames;
|
||||||
|
const r = el.getBoundingClientRect();
|
||||||
|
if (r.width * r.height < BIG_BLUR) return frames;
|
||||||
|
return frames.map(({ filter: _f, ...f }) => f);
|
||||||
|
}
|
||||||
|
|
||||||
export interface Spring {
|
export interface Spring {
|
||||||
/** Until it settles within 0.15% of the end. */
|
/** Until it settles within 0.15% of the end. */
|
||||||
@@ -38,25 +55,32 @@ export function spring(k: number, c: number, m = 1): Spring {
|
|||||||
let end = 0;
|
let end = 0;
|
||||||
for (let t = 0; t < 3; t += 0.004) if (Math.abs(1 - x(t)) > 0.0015) end = t;
|
for (let t = 0; t < 3; t += 0.004) if (Math.abs(1 - x(t)) > 0.0015) end = t;
|
||||||
end += 0.004;
|
end += 0.004;
|
||||||
|
// Cut where it is within 0.15% of the end, the spring still has that much to go: on a large travel (a row
|
||||||
|
// folding 500 px) a step of a pixel in the last frame. What is left is spread over the way instead, most of
|
||||||
|
// it near the end, so the curve arrives at 1 exactly and smoothly; overshoot and timing stay as they are.
|
||||||
|
const rest = 1 - x(end);
|
||||||
|
const y = (t: number) => x(t) + rest * (t / end) ** 3;
|
||||||
const pts: number[] = [];
|
const pts: number[] = [];
|
||||||
for (let i = 0; i <= 64; i++) pts.push(+x((end * i) / 64).toFixed(4));
|
for (let i = 0; i <= 64; i++) pts.push(+y((end * i) / 64).toFixed(4));
|
||||||
pts[64] = 1;
|
pts[64] = 1;
|
||||||
const duration = Math.round(end * 1000);
|
const duration = Math.round(end * 1000);
|
||||||
return { duration, easing: `linear(${pts.join(', ')})`, at: (ms) => (ms >= duration ? 1 : x(ms / 1000)) };
|
return { duration, easing: `linear(${pts.join(', ')})`, at: (ms) => (ms >= duration ? 1 : y(ms / 1000)) };
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The accordion, the toast, a card that pops in. */
|
/** The accordion, the toast, a card that pops in. */
|
||||||
export const BOUNCY = spring(300, 20);
|
export const BOUNCY = spring(300, 20);
|
||||||
/** Pills, widths and heights: no overshoot. */
|
/** Pills, widths and heights: no overshoot. */
|
||||||
export const SMOOTH = spring(300, 35);
|
export const SMOOTH = spring(300, 35);
|
||||||
/** Small things that pop: a check, a menu. */
|
/** Small things that pop: a check, a mark turning in. */
|
||||||
export const POP = spring(520, 24);
|
export const POP = spring(520, 24);
|
||||||
/** The leading edge of a stretching pill: faster than SMOOTH, no overshoot. */
|
/** The leading edge of a stretching pill: faster than SMOOTH, no overshoot. */
|
||||||
export const LEAD = spring(520, 46);
|
export const LEAD = spring(520, 46);
|
||||||
/** A dialog on a computer and the accordions: the menu's pop made softer (about 4% over, 90% there at ~140 ms). */
|
/** The dropdowns, a dialog on a computer and the accordions: POP made softer (about 4% over, 90% there at ~140 ms). */
|
||||||
export const SOFT = spring(380, 28);
|
export const SOFT = spring(380, 28);
|
||||||
/** What follows the pointer (a menu's highlight): there in about 130 ms, no overshoot. */
|
/** What follows the pointer (a menu's highlight): there in about 130 ms, no overshoot. */
|
||||||
export const QUICK = spring(900, 60);
|
const QUICK = spring(900, 60);
|
||||||
|
/** A highlight gliding from row to row: quick, with a touch of give (about 2% over). */
|
||||||
|
const GLIDE = spring(640, 40);
|
||||||
|
|
||||||
export const EASE_OUT = 'cubic-bezier(0.23, 1, 0.32, 1)';
|
export const EASE_OUT = 'cubic-bezier(0.23, 1, 0.32, 1)';
|
||||||
export const EASE_IN = 'cubic-bezier(0.55, 0, 1, 0.45)';
|
export const EASE_IN = 'cubic-bezier(0.55, 0, 1, 0.45)';
|
||||||
@@ -72,6 +96,8 @@ export function publishSprings(root: HTMLElement) {
|
|||||||
root.style.setProperty('--spring-soft-dur', `${SOFT.duration}ms`);
|
root.style.setProperty('--spring-soft-dur', `${SOFT.duration}ms`);
|
||||||
root.style.setProperty('--spring-quick', QUICK.easing);
|
root.style.setProperty('--spring-quick', QUICK.easing);
|
||||||
root.style.setProperty('--spring-quick-dur', `${QUICK.duration}ms`);
|
root.style.setProperty('--spring-quick-dur', `${QUICK.duration}ms`);
|
||||||
|
root.style.setProperty('--spring-glide', GLIDE.easing);
|
||||||
|
root.style.setProperty('--spring-glide-dur', `${GLIDE.duration}ms`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,7 +105,7 @@ export function publishSprings(root: HTMLElement) {
|
|||||||
* its fade (short); one that only moves or resizes jumps to its end.
|
* its fade (short); one that only moves or resizes jumps to its end.
|
||||||
*/
|
*/
|
||||||
export function play(el: Element, frames: Keyframe[], o: KeyframeAnimationOptions): Animation {
|
export function play(el: Element, frames: Keyframe[], o: KeyframeAnimationOptions): Animation {
|
||||||
if (!calm()) return el.animate(frames, o);
|
if (!calm()) return el.animate(lean(el, frames), o);
|
||||||
if (frames.some((f) => 'opacity' in f))
|
if (frames.some((f) => 'opacity' in f))
|
||||||
return el.animate(
|
return el.animate(
|
||||||
frames.map((f) => ('opacity' in f ? { opacity: f.opacity } : {})),
|
frames.map((f) => ('opacity' in f ? { opacity: f.opacity } : {})),
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ function hoursBar(hours: string, tzOffset: number | undefined): HTMLElement | nu
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The access accordion for this state; `open`: the row to keep open (a repaint), else the data. */
|
/** The access accordion for this state; `open`: the row to keep open (a repaint), else the data. */
|
||||||
export function accessAccordion(st: State, open = 1): Accordion {
|
function accessAccordion(st: State, open = 1): Accordion {
|
||||||
const p = st.person;
|
const p = st.person;
|
||||||
const used = p.quota_used || p.month[0] + p.month[1];
|
const used = p.quota_used || p.month[0] + p.month[1];
|
||||||
const pct = p.quota_limit ? Math.min(100, (used / p.quota_limit) * 100) : 0;
|
const pct = p.quota_limit ? Math.min(100, (used / p.quota_limit) * 100) : 0;
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ function statusOf(d: Device, p: Person): [string, string, string?] {
|
|||||||
// "connected", so say here why nothing works.
|
// "connected", so say here why nothing works.
|
||||||
if (d.online && p.state === 'quota') return ['warn-t', _('Connected, no data left')];
|
if (d.online && p.state === 'quota') return ['warn-t', _('Connected, no data left')];
|
||||||
if (d.online && p.state === 'hours') return ['warn-t', _('Connected, outside your hours')];
|
if (d.online && p.state === 'hours') return ['warn-t', _('Connected, outside your hours')];
|
||||||
|
// Connected, and what it sends is dropped: the set-up sheet's no data, right away (the router's watcher names it
|
||||||
|
// only once it held 3 minutes), so a sheet closed on it doesn't leave the card saying Connected.
|
||||||
|
if (d.online && d.setup?.state === 'nodata')
|
||||||
|
return ['warn-t', _('Connected, but no data'), _('The router drops its traffic: the address does not match.')];
|
||||||
if (d.link) return ['warn-t', ...linkWords(d.link.state)];
|
if (d.link) return ['warn-t', ...linkWords(d.link.state)];
|
||||||
if (d.online) return ['ok-t', _('Connected')];
|
if (d.online) return ['ok-t', _('Connected')];
|
||||||
if (!d.handshake) return ['warn-t', _('Not set up yet')];
|
if (!d.handshake) return ['warn-t', _('Not set up yet')];
|
||||||
@@ -93,8 +97,10 @@ function menuItems(d: Device, st: State): (MenuItem | null)[] {
|
|||||||
// How devices at home reach it: only where the router actually lets them through.
|
// How devices at home reach it: only where the router actually lets them through.
|
||||||
...(reachableFromHome(st.person, d)
|
...(reachableFromHome(st.person, d)
|
||||||
? [
|
? [
|
||||||
{ label: _('Copy IP address'), icon: 'copy', run: () => copy(d.address, _('IP address copied')) },
|
{ label: _('Copy IP address'), icon: 'copy', sub: d.address, run: () => copy(d.address, _('IP address copied')) },
|
||||||
...(d.hostname ? [{ label: _('Copy local address'), icon: 'home', run: () => copy(d.hostname, _('Address copied')) }] : []),
|
...(d.hostname
|
||||||
|
? [{ label: _('Copy local address'), icon: 'home', sub: d.hostname, run: () => copy(d.hostname, _('Address copied')) }]
|
||||||
|
: []),
|
||||||
null,
|
null,
|
||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
@@ -171,7 +177,7 @@ function card(d: Device, st: State): HTMLElement {
|
|||||||
},
|
},
|
||||||
ic('more'),
|
ic('more'),
|
||||||
);
|
);
|
||||||
more?.addEventListener('click', () => openMenu(more, items));
|
more?.addEventListener('click', () => openMenu(more, items, d.name));
|
||||||
return h(
|
return h(
|
||||||
'article',
|
'article',
|
||||||
{ class: `dev${here ? ' is-here' : ''}${d.disabled ? ' off' : ''}`, 'data-id': d.id },
|
{ class: `dev${here ? ' is-here' : ''}${d.disabled ? ' off' : ''}`, 'data-id': d.id },
|
||||||
@@ -258,19 +264,16 @@ export function devicesSection(): HTMLElement {
|
|||||||
/**
|
/**
|
||||||
* A card whose width jumps (the grid changed its columns: a window across 560 or 960 px, a phone turned)
|
* A card whose width jumps (the grid changed its columns: a window across 560 or 960 px, a phone turned)
|
||||||
* takes its new shape with the layout, at once: gliding there from the old one, its numbers would not fit
|
* takes its new shape with the layout, at once: gliding there from the old one, its numbers would not fit
|
||||||
* for a moment and wrap. A threshold crossed while the window is resized a little at a time still glides
|
* for a moment and wrap. The columns change only there (devices.css, page.css), so those two crossings are what
|
||||||
* (devices.css). The class goes on before the frame is painted, so the glide that began never shows.
|
* it listens for; a window resized between them still glides. The class goes on before the frame is painted, so
|
||||||
|
* the glide that began never shows.
|
||||||
*/
|
*/
|
||||||
function snapOnJump(grid: HTMLElement) {
|
function snapOnJump(grid: HTMLElement) {
|
||||||
let was = 0;
|
const snap = () => {
|
||||||
new ResizeObserver(() => {
|
grid.classList.add('snap');
|
||||||
const w = grid.querySelector('.dev')?.getBoundingClientRect().width ?? 0;
|
requestAnimationFrame(() => requestAnimationFrame(() => grid.classList.remove('snap')));
|
||||||
if (Math.abs(w - was) > 16) {
|
};
|
||||||
grid.classList.add('snap');
|
for (const q of ['(min-width: 560px)', '(min-width: 960px)']) matchMedia(q).addEventListener('change', snap);
|
||||||
requestAnimationFrame(() => requestAnimationFrame(() => grid.classList.remove('snap')));
|
|
||||||
}
|
|
||||||
was = w;
|
|
||||||
}).observe(grid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The green ring of a device that just connected (its animation's id, to find it again on a repaint). */
|
/** The green ring of a device that just connected (its animation's id, to find it again on a repaint). */
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
import { h, ic, markup } from '../dom';
|
import { h, ic, markup } from '../dom';
|
||||||
import { EASE_OUT, SOFT, play } from '../motion';
|
import { EASE_OUT, SOFT, play } from '../motion';
|
||||||
import { placeName, state } from '../state';
|
import { placeName, state } from '../state';
|
||||||
import { showPageCode } from '../flows/page-code';
|
import { closePageCode, showPageCode } from '../flows/page-code';
|
||||||
import { openMenu } from '../ui/menu';
|
import { pickPill, type PickPill } from '../ui/pick';
|
||||||
import { LANGS, lang, setLang } from '../i18n';
|
import { LANGS, lang, setLang } from '../i18n';
|
||||||
|
|
||||||
// The sun rises from behind the horizon once, on the visit's first paint.
|
// The sun rises from behind the horizon once, on the visit's first paint.
|
||||||
@@ -70,44 +70,71 @@ export function single(on: boolean) {
|
|||||||
pageEl?.classList.toggle('single', on);
|
pageEl?.classList.toggle('single', on);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The language: its code and a chevron; the menu lists the languages by their own names. */
|
// Each language's flag, a disc (styles/pick.css): the Union Jack for English, the tricolour for Russian.
|
||||||
|
const FLAGS: Record<string, string> = {
|
||||||
|
en:
|
||||||
|
'<svg viewBox="15 0 30 30" aria-hidden="true"><path fill="#012169" d="M0 0h60v30H0z"/>' +
|
||||||
|
'<path stroke="#fff" stroke-width="6" d="M0 0l60 30M60 0L0 30"/><path stroke="#c8102e" stroke-width="2" d="M0 0l60 30M60 0L0 30"/>' +
|
||||||
|
'<path stroke="#fff" stroke-width="10" d="M30 0v30M0 15h60"/><path stroke="#c8102e" stroke-width="6" d="M30 0v30M0 15h60"/></svg>',
|
||||||
|
ru:
|
||||||
|
'<svg viewBox="0 0 30 30" aria-hidden="true"><path fill="#fff" d="M0 0h30v10H0z"/><path fill="#0039a6" d="M0 10h30v10H0z"/>' +
|
||||||
|
'<path fill="#d52b1e" d="M0 20h30v10H0z"/></svg>',
|
||||||
|
};
|
||||||
|
const flag = (code: string) => h('span', { class: 'flag' }, FLAGS[code] ? markup(FLAGS[code]) : null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The language: its flag, its code and a chevron; the popup under it lists the languages by their own names. One
|
||||||
|
* pill for the visit, put back each time the breadcrumb is drawn, so a pick morphs its code after the page redraws.
|
||||||
|
*/
|
||||||
|
let langPill: PickPill<string> | null = null;
|
||||||
function langPicker(): HTMLElement {
|
function langPicker(): HTMLElement {
|
||||||
const b = h(
|
langPill ??= pickPill({
|
||||||
'button',
|
cls: 'cr-lang',
|
||||||
{ type: 'button', class: 'cr-lang', 'aria-label': _('Language'), 'aria-haspopup': 'menu', 'aria-expanded': 'false' },
|
label: () => _('Language'),
|
||||||
h('span', {}, lang().toUpperCase()),
|
options: LANGS.map((l) => ({ value: l.code, label: () => l.name, lead: () => flag(l.code) })),
|
||||||
ic('chevron', 'i cr-down'),
|
value: lang(),
|
||||||
);
|
short: (c) => c.toUpperCase(),
|
||||||
b.addEventListener('click', () =>
|
prefer: 'below',
|
||||||
openMenu(
|
pick: (c) => setLang(c),
|
||||||
b,
|
});
|
||||||
LANGS.map((l) => ({ label: l.name, checked: l.code === lang(), run: () => l.code !== lang() && setLang(l.code) })),
|
langPill.show(lang());
|
||||||
),
|
return langPill.el;
|
||||||
);
|
|
||||||
return b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The breadcrumb: the place, then the person (none when the link stopped
|
* This page's code for another device: one knob for the visit, as the language's pill, so a card open from it
|
||||||
* working); at its end, the language and this page's code for another
|
* (flows/page-code.ts) stays where it is as the page redraws.
|
||||||
* device, on the page itself only (not over a card: paused, link gone,
|
|
||||||
* nothing loaded).
|
|
||||||
*/
|
*/
|
||||||
|
let qr: HTMLElement | null = null;
|
||||||
|
function qrKnob(): HTMLElement {
|
||||||
|
qr ??= h(
|
||||||
|
'button',
|
||||||
|
{ type: 'button', class: 'knob cr-qr', 'aria-haspopup': 'dialog', 'aria-expanded': 'false', onclick: () => showPageCode(qr!) },
|
||||||
|
ic('qr'),
|
||||||
|
);
|
||||||
|
qr.setAttribute('aria-label', _('Open on another device'));
|
||||||
|
return qr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The breadcrumb: the place alone (the page is the person's own, so not their
|
||||||
|
* name); at its end, the language and this page's code for another device, on
|
||||||
|
* the page itself only (not over a card: paused, link gone, nothing loaded).
|
||||||
|
*/
|
||||||
|
/** Who is told the breadcrumb was drawn again (the demo adds its chip and GitHub link to it: demo/crumbs.ts). */
|
||||||
|
const drawnCrumbs: (() => void)[] = [];
|
||||||
|
export const onCrumbs = (fn: () => void) => void drawnCrumbs.push(fn);
|
||||||
|
|
||||||
export function crumbs(gone = false, card = false) {
|
export function crumbs(gone = false, card = false) {
|
||||||
if (!crumbsEl) return;
|
if (!crumbsEl) return;
|
||||||
const p = gone ? null : state()?.person;
|
const p = gone ? null : state()?.person;
|
||||||
const place = h('span', { class: p ? '' : 'cur', 'aria-current': p ? null : 'page' }, placeName());
|
|
||||||
crumbsEl.replaceChildren(
|
crumbsEl.replaceChildren(
|
||||||
h('span', { class: 'cr-mark' }, markup(LOGO)),
|
h('span', { class: 'cr-mark' }, markup(LOGO)),
|
||||||
h(
|
h('nav', { class: 'cr-path', 'aria-label': _('Breadcrumb') }, h('span', { class: 'cur', 'aria-current': 'page' }, placeName())),
|
||||||
'nav',
|
|
||||||
{ class: 'cr-path', 'aria-label': _('Breadcrumb') },
|
|
||||||
place,
|
|
||||||
p ? [ic('chevron'), h('span', { class: 'cur', 'aria-current': 'page' }, p.name)] : null,
|
|
||||||
),
|
|
||||||
...(card ? [] : [langPicker()]),
|
...(card ? [] : [langPicker()]),
|
||||||
...(p && !card
|
...(p && !card ? [qrKnob()] : []),
|
||||||
? [h('button', { type: 'button', class: 'knob cr-qr', 'aria-label': _('Open on another device'), onclick: showPageCode }, ic('qr'))]
|
|
||||||
: []),
|
|
||||||
);
|
);
|
||||||
|
// No knob to fold back into: the card goes with it.
|
||||||
|
if (!qr?.isConnected) closePageCode(true);
|
||||||
|
drawnCrumbs.forEach((f) => f());
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ export function notice(tone: Tone, icon: string, title: string | null, sub: stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The admin's hours as the visitor reads them: "08:00–22:00 your time" (or the router's, said so). */
|
/** The admin's hours as the visitor reads them: "08:00–22:00 your time" (or the router's, said so). */
|
||||||
export function hoursText(hours: string): string {
|
function hoursText(hours: string): string {
|
||||||
const hw = hoursFor(hours, state()?.tz_offset, -new Date().getTimezoneOffset());
|
const hw = hoursFor(hours, state()?.tz_offset, -new Date().getTimezoneOffset());
|
||||||
if (!hw) return fmt(_('%s (router time)'), hours.replace('-', '–'));
|
if (!hw) return fmt(_('%s (router time)'), hours.replace('-', '–'));
|
||||||
const span = `${clockOf(hw.from)}–${clockOf(hw.to)}`;
|
const span = `${clockOf(hw.from)}–${clockOf(hw.to)}`;
|
||||||
@@ -52,7 +52,7 @@ export function stateNotice(p: Person): [string, string, string] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The page's notice, or null when nothing stands in the way. */
|
/** The page's notice, or null when nothing stands in the way. */
|
||||||
export function pageNotice(p: Person): HTMLElement | null {
|
function pageNotice(p: Person): HTMLElement | null {
|
||||||
if (p.state !== 'active') return notice(p.state === 'quota' || p.state === 'expired' ? 'bad' : 'warn', ...stateNotice(p));
|
if (p.state !== 'active') return notice(p.state === 'quota' || p.state === 'expired' ? 'bad' : 'warn', ...stateNotice(p));
|
||||||
const left = daysLeft(p.expires, today());
|
const left = daysLeft(p.expires, today());
|
||||||
return endsSoon(p, left)
|
return endsSoon(p, left)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export function appsFor(preset: Preset): AppChoice[] {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Mark = 'appstore' | 'googleplay' | 'windows' | 'apple' | 'linux' | 'openwrt' | 'github' | 'site';
|
type Mark = 'appstore' | 'googleplay' | 'windows' | 'apple' | 'linux' | 'openwrt' | 'github' | 'site';
|
||||||
|
|
||||||
export interface Store {
|
export interface Store {
|
||||||
href: string;
|
href: string;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ export const now = () => current?.now ?? Date.now() / 1000;
|
|||||||
/** The platform this page is open on (iPad on Safari says Mac; touch points tell). */
|
/** The platform this page is open on (iPad on Safari says Mac; touch points tell). */
|
||||||
export const platform = (): Platform => platformOf(navigator.userAgent, navigator.maxTouchPoints);
|
export const platform = (): Platform => platformOf(navigator.userAgent, navigator.maxTouchPoints);
|
||||||
/** The server's disguise is off: plain WireGuard, so any WireGuard app connects. */
|
/** The server's disguise is off: plain WireGuard, so any WireGuard app connects. */
|
||||||
export const plainWg = () => current?.server.awg_disguise === false;
|
const plainWg = () => current?.server.awg_disguise === false;
|
||||||
/** The server's disguise generation, for which apps and versions connect. */
|
/** The server's disguise generation, for which apps and versions connect. */
|
||||||
export const preset = (): Preset => current?.server.preset ?? (plainWg() ? 'off' : 'max');
|
export const preset = (): Preset => current?.server.preset ?? (plainWg() ? 'off' : 'max');
|
||||||
/** The secure twin when this page is plain HTTP, else null. */
|
/** The secure twin when this page is plain HTTP, else null. */
|
||||||
|
|||||||
@@ -24,10 +24,11 @@
|
|||||||
.acc-row.open {
|
.acc-row.open {
|
||||||
margin-block: 10px;
|
margin-block: 10px;
|
||||||
}
|
}
|
||||||
.acc-row.open:first-child {
|
/* The first and last rows that show (ui/accordion.ts: a row stepped out leaves none of its gap). */
|
||||||
|
.acc-row.open.first {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
.acc-row.open:last-child {
|
.acc-row.open.last {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
.acc-row:not(.open):not(.still):hover {
|
.acc-row:not(.open):not(.still):hover {
|
||||||
@@ -90,6 +91,39 @@
|
|||||||
transform: translateX(8px);
|
transform: translateX(8px);
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
/* Actions on what an open row holds (ui/accordion.ts aside): beside the chevron, over the head's end, coming
|
||||||
|
in as the row opens and going as it shuts; the title keeps clear of them meanwhile (--aside-w: their width
|
||||||
|
and a gap). */
|
||||||
|
.acc-row.has-aside {
|
||||||
|
position: relative;
|
||||||
|
--aside-w: 72px;
|
||||||
|
}
|
||||||
|
.acc-aside {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
right: 40px;
|
||||||
|
height: 52px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
transition:
|
||||||
|
opacity 200ms var(--ease-out),
|
||||||
|
filter 200ms var(--ease-out),
|
||||||
|
transform 200ms var(--ease-out);
|
||||||
|
}
|
||||||
|
.acc-row:not(.open) > .acc-aside {
|
||||||
|
opacity: 0;
|
||||||
|
filter: blur(4px);
|
||||||
|
transform: translateX(8px);
|
||||||
|
pointer-events: none;
|
||||||
|
visibility: hidden;
|
||||||
|
transition-property: opacity, filter, transform, visibility;
|
||||||
|
}
|
||||||
|
.acc-row.has-aside > .acc-head > .acc-title {
|
||||||
|
transition: padding-right 200ms var(--ease-out);
|
||||||
|
}
|
||||||
|
.acc-row.has-aside.open > .acc-head > .acc-title {
|
||||||
|
padding-right: var(--aside-w);
|
||||||
|
}
|
||||||
.acc-chev {
|
.acc-chev {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ html {
|
|||||||
(main.ts), so the browser would hold "Your devices" still while an access row opens or folds, and pull a page
|
(main.ts), so the browser would hold "Your devices" still while an access row opens or folds, and pull a page
|
||||||
scrolled less than the fold to the very top. A row grows and folds in place; a repaint glides what moves. */
|
scrolled less than the fold to the very top. A row grows and folds in place; a repaint glides what moves. */
|
||||||
overflow-anchor: none;
|
overflow-anchor: none;
|
||||||
|
/* An app's page, not a document's: a double tap doesn't zoom (the viewport keeps its scale, main.ts stops
|
||||||
|
Safari's pinch). Taps answer at once, with no wait for a second one. */
|
||||||
|
touch-action: manipulation;
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -22,18 +25,23 @@ body {
|
|||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
min-height: 100dvh;
|
min-height: 100dvh;
|
||||||
/* An app, not a document: the arrow over text. Controls set the hand; what is typed or copied by
|
/* An app, not a document: the arrow over text, and no selecting it (a title, a label, a value is not text to
|
||||||
hand (fields, the link, the configuration) keeps the I-beam. */
|
copy). Controls set the hand; what is typed or copied by hand (fields, the mono text: the link, hostnames, a
|
||||||
|
file's name; the configuration) can be selected, with the I-beam. */
|
||||||
cursor: default;
|
cursor: default;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
body.locked {
|
body.locked {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
input,
|
input,
|
||||||
textarea,
|
textarea,
|
||||||
.linkrow .mono,
|
.mono,
|
||||||
.conf {
|
.conf {
|
||||||
cursor: text;
|
cursor: text;
|
||||||
|
-webkit-user-select: text;
|
||||||
|
user-select: text;
|
||||||
}
|
}
|
||||||
::selection {
|
::selection {
|
||||||
background: var(--sel-bg);
|
background: var(--sel-bg);
|
||||||
@@ -60,7 +68,9 @@ a {
|
|||||||
:focus {
|
:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
:focus-visible {
|
/* The focus ring only while the keyboard is moving focus (main.ts sets .kbd on Tab or an arrow and drops it on a
|
||||||
|
press): focus a script moves, or one left after a click, shows nothing. */
|
||||||
|
.kbd :focus-visible {
|
||||||
outline: 2px solid color-mix(in srgb, var(--accent) 65%, transparent);
|
outline: 2px solid color-mix(in srgb, var(--accent) 65%, transparent);
|
||||||
outline-offset: 2px;
|
outline-offset: 2px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,9 @@
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
.btn.red:hover {
|
||||||
|
background: color-mix(in srgb, var(--bad) 82%, transparent);
|
||||||
|
}
|
||||||
/* Waiting for the router: the button keeps its size, its content blurs away and an orb comes up in
|
/* Waiting for the router: the button keeps its size, its content blurs away and an orb comes up in
|
||||||
its place (ui/busy.ts runs the change). The orb is B4 Converge from aicss.dev's Orbs, at its own
|
its place (ui/busy.ts runs the change). The orb is B4 Converge from aicss.dev's Orbs, at its own
|
||||||
28px stage and twice its speed: one circle walks a triangle, sharp at each corner and smaller,
|
28px stage and twice its speed: one circle walks a triangle, sharp at each corner and smaller,
|
||||||
@@ -216,6 +219,10 @@
|
|||||||
color: var(--text);
|
color: var(--text);
|
||||||
letter-spacing: -0.012em;
|
letter-spacing: -0.012em;
|
||||||
}
|
}
|
||||||
|
/* The system's caret where the field draws none (a touch screen, ui/caret.ts): the accent, as the drawn one. */
|
||||||
|
.field input {
|
||||||
|
caret-color: var(--accent);
|
||||||
|
}
|
||||||
.field input::placeholder {
|
.field input::placeholder {
|
||||||
color: var(--text-3);
|
color: var(--text-3);
|
||||||
}
|
}
|
||||||
@@ -337,7 +344,8 @@
|
|||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity 140ms linear;
|
transition: opacity 140ms linear;
|
||||||
}
|
}
|
||||||
.caret-hd::after {
|
.caret-hd::after,
|
||||||
|
.tsel-hd::after {
|
||||||
content: '';
|
content: '';
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
@@ -347,16 +355,59 @@
|
|||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: var(--accent);
|
background: var(--accent);
|
||||||
}
|
}
|
||||||
.caret-hd.s::after {
|
.caret-hd.s::after,
|
||||||
|
.tsel-hd.s::after {
|
||||||
top: -7px;
|
top: -7px;
|
||||||
}
|
}
|
||||||
.caret-hd.e::after {
|
.caret-hd.e::after,
|
||||||
|
.tsel-hd.e::after {
|
||||||
bottom: -7px;
|
bottom: -7px;
|
||||||
}
|
}
|
||||||
.field.selecting .caret-sel,
|
.field.selecting .caret-sel,
|
||||||
.field.selecting .caret-hd {
|
.field.selecting .caret-hd {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
/* The page's own selection (ui/selection.ts), as the fields', where text can be selected (base.css), with a mouse
|
||||||
|
or trackpad: the native one is see-through, the text keeping its colour (currentcolor), and ours is drawn over it,
|
||||||
|
one band per line and a handle at each end. A band lies over the text, so it blends: in dark the screen lifts the
|
||||||
|
ground to the accent wash and leaves the words as they are, in light the multiply. Each band and handle is fixed
|
||||||
|
in <body> on its own: a box around them would make them blend with nothing but each other. */
|
||||||
|
.own-tsel .mono::selection,
|
||||||
|
.own-tsel .mono *::selection,
|
||||||
|
.own-tsel .conf::selection,
|
||||||
|
.own-tsel .conf *::selection {
|
||||||
|
background: transparent;
|
||||||
|
color: currentcolor;
|
||||||
|
}
|
||||||
|
.tsel-band,
|
||||||
|
.tsel-hd {
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 140ms linear;
|
||||||
|
}
|
||||||
|
.tsel-band {
|
||||||
|
border-radius: 4px;
|
||||||
|
background: color-mix(in srgb, var(--accent) 26%, var(--bg));
|
||||||
|
mix-blend-mode: screen;
|
||||||
|
will-change: transform;
|
||||||
|
}
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
.tsel-band {
|
||||||
|
mix-blend-mode: multiply;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.tsel-hd {
|
||||||
|
width: 2px;
|
||||||
|
border-radius: 1px;
|
||||||
|
background: var(--accent);
|
||||||
|
}
|
||||||
|
.tsel-band.on,
|
||||||
|
.tsel-hd.on {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Words on their way to the router (ui/shimmer.ts): the input's own are hidden under a copy that dims and lets a
|
/* Words on their way to the router (ui/shimmer.ts): the input's own are hidden under a copy that dims and lets a
|
||||||
light band sweep across it, the band the words' colour over a muted base; the caret steps aside meanwhile. */
|
light band sweep across it, the band the words' colour over a muted base; the caret steps aside meanwhile. */
|
||||||
@@ -433,6 +484,16 @@
|
|||||||
.appseg .seg-b.on {
|
.appseg .seg-b.on {
|
||||||
flex: 1 1 56px;
|
flex: 1 1 56px;
|
||||||
}
|
}
|
||||||
|
/* At rest the pill stands on its item (ui/seg.ts sets --i of --n): the track's 4 px edge and the items before it
|
||||||
|
(each --b wide) on the left, the items after it on the right; the picked item takes what is left, so does the
|
||||||
|
pill, whatever the sheet's width. A pick moves it with its own left and right, then hands back. */
|
||||||
|
.appseg {
|
||||||
|
--b: 56px;
|
||||||
|
}
|
||||||
|
.appseg .seg-pill {
|
||||||
|
left: calc(4px + var(--i, 0) * var(--b));
|
||||||
|
right: calc(4px + (var(--n, 1) - 1 - var(--i, 0)) * var(--b));
|
||||||
|
}
|
||||||
.appseg .seg-b .i {
|
.appseg .seg-b .i {
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
@@ -454,6 +515,9 @@
|
|||||||
container-type: inline-size;
|
container-type: inline-size;
|
||||||
}
|
}
|
||||||
@container (max-width: 300px) {
|
@container (max-width: 300px) {
|
||||||
|
.appseg {
|
||||||
|
--b: 44px;
|
||||||
|
}
|
||||||
.appseg .seg-b {
|
.appseg .seg-b {
|
||||||
flex-basis: 44px;
|
flex-basis: 44px;
|
||||||
padding: 0 12px;
|
padding: 0 12px;
|
||||||
@@ -501,7 +565,7 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.kind:hover .kind-tile,
|
.kind:hover .kind-tile,
|
||||||
.kind:focus-visible .kind-tile {
|
.kbd .kind:focus-visible .kind-tile {
|
||||||
background: var(--knob);
|
background: var(--knob);
|
||||||
}
|
}
|
||||||
.kind:active .kind-tile {
|
.kind:active .kind-tile {
|
||||||
@@ -510,7 +574,7 @@
|
|||||||
.kind:focus-visible {
|
.kind:focus-visible {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
.kind:focus-visible .kind-lbl,
|
.kbd .kind:focus-visible .kind-lbl,
|
||||||
.kind.on {
|
.kind.on {
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@
|
|||||||
background: color-mix(in srgb, var(--raised), var(--text) 6%);
|
background: color-mix(in srgb, var(--raised), var(--text) 6%);
|
||||||
}
|
}
|
||||||
/* Not when an edit gave focus back to it (flows/rename.ts): only reached with Tab. */
|
/* Not when an edit gave focus back to it (flows/rename.ts): only reached with Tab. */
|
||||||
.dev-name.can-edit:focus-visible:not(.quiet) {
|
.kbd .dev-name.can-edit:focus-visible:not(.quiet) {
|
||||||
box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent);
|
box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 60%, transparent);
|
||||||
}
|
}
|
||||||
.field.inline,
|
.field.inline,
|
||||||
@@ -187,6 +187,14 @@
|
|||||||
.dev.add:hover {
|
.dev.add:hover {
|
||||||
background: color-mix(in srgb, var(--raised), var(--knob) 45%);
|
background: color-mix(in srgb, var(--raised), var(--knob) 45%);
|
||||||
}
|
}
|
||||||
|
/* On light the darker step would land on the page's own grey and the card would melt into it: a touch off white,
|
||||||
|
the words up to full colour. */
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
.dev.add:hover {
|
||||||
|
background: color-mix(in srgb, var(--raised), var(--text) 2.5%);
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
}
|
||||||
.dev.add:active {
|
.dev.add:active {
|
||||||
transform: scale(0.98);
|
transform: scale(0.98);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/* What every dropdown is made of (ui/drop.ts: the ⋯ menu, the pick pills' popups, the page's code): Liquid Glass
|
||||||
|
(tokens.css --glass-*), the page behind blurred and its colours lifted, a soft even edge, a soft shadow on light
|
||||||
|
only; over the page and a sheet alike. A dropdown cut to a shape of its own (a pick popup's tail) traces its edge
|
||||||
|
and casts its shadow itself. */
|
||||||
|
.drop {
|
||||||
|
z-index: 60;
|
||||||
|
background: var(--glass-bg);
|
||||||
|
-webkit-backdrop-filter: blur(28px) saturate(1.8);
|
||||||
|
backdrop-filter: blur(28px) saturate(1.8);
|
||||||
|
box-shadow:
|
||||||
|
inset 0 0 0 1px var(--glass-edge),
|
||||||
|
var(--glass-shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Their one highlight (ui/glide.ts): under the items' icons and words (they sit over it), solid, the same for every
|
||||||
|
item; it glides on GLIDE and presses in with what it is on. */
|
||||||
|
.drop-hl {
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
z-index: 2;
|
||||||
|
background: var(--glass-hl);
|
||||||
|
opacity: 0;
|
||||||
|
pointer-events: none;
|
||||||
|
transition:
|
||||||
|
opacity 160ms var(--ease-out),
|
||||||
|
scale 150ms var(--ease-out);
|
||||||
|
}
|
||||||
|
.drop-hl.moving {
|
||||||
|
transition:
|
||||||
|
opacity 160ms var(--ease-out),
|
||||||
|
scale 150ms var(--ease-out),
|
||||||
|
translate var(--spring-glide-dur, 400ms) var(--spring-glide, ease-out),
|
||||||
|
width var(--spring-glide-dur, 400ms) var(--spring-glide, ease-out),
|
||||||
|
height var(--spring-glide-dur, 400ms) var(--spring-glide, ease-out),
|
||||||
|
border-radius var(--spring-glide-dur, 400ms) var(--spring-glide, ease-out);
|
||||||
|
}
|
||||||
|
.drop-hl.down {
|
||||||
|
scale: 0.97;
|
||||||
|
}
|
||||||
@@ -12,3 +12,5 @@
|
|||||||
@import './sheet.css';
|
@import './sheet.css';
|
||||||
@import './setup.css';
|
@import './setup.css';
|
||||||
@import './menu-toast.css';
|
@import './menu-toast.css';
|
||||||
|
@import './drop.css';
|
||||||
|
@import './pick.css';
|
||||||
@@ -1,76 +1,108 @@
|
|||||||
/* The ⋯ menu (a highlight that glides after the pointer, tinted for Reconnect and Remove) and the
|
/* The ⋯ menu (ui/menu.ts): an iOS 26-style menu: Liquid Glass with a soft even edge, rows, thin lines
|
||||||
toast slot at the bottom. */
|
between groups. And the toast slot at the bottom. */
|
||||||
|
|
||||||
.menu {
|
/* On the dropdowns' glass (.drop, styles/drop.css). */
|
||||||
position: fixed;
|
.pop {
|
||||||
z-index: 60;
|
|
||||||
min-width: 224px;
|
|
||||||
padding: 6px;
|
|
||||||
border-radius: 20px;
|
|
||||||
background: var(--field);
|
|
||||||
box-shadow:
|
|
||||||
var(--pop-shadow),
|
|
||||||
inset 0 0 0 1px var(--line);
|
|
||||||
}
|
|
||||||
.menu-hl {
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 6px;
|
min-width: 210px;
|
||||||
right: 6px;
|
overflow: hidden;
|
||||||
top: 6px;
|
border-radius: 24px;
|
||||||
height: 40px;
|
|
||||||
border-radius: 14px;
|
|
||||||
background: var(--knob);
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 150ms var(--ease-out);
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
}
|
||||||
.menu-hl.moving {
|
/* The Figma's Menu made compact: 6 px top and bottom, the rows 6 px in. */
|
||||||
transition:
|
.pop-body {
|
||||||
opacity 150ms var(--ease-out),
|
|
||||||
transform var(--spring-quick-dur, 300ms) var(--spring-quick, ease-out),
|
|
||||||
background-color 150ms;
|
|
||||||
}
|
|
||||||
.menu-hl.bad {
|
|
||||||
background: var(--bad-soft);
|
|
||||||
}
|
|
||||||
.menu-hl.warn {
|
|
||||||
background: color-mix(in srgb, var(--warn) 13%, transparent);
|
|
||||||
}
|
|
||||||
.mi {
|
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 6px 0;
|
||||||
|
}
|
||||||
|
.pop-grp {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 0 6px;
|
||||||
|
}
|
||||||
|
/* A separator: 21 px high, its line 8 px further in than the rows. */
|
||||||
|
.pop-sep {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 12px;
|
height: 13px;
|
||||||
width: 100%;
|
padding: 0 16px;
|
||||||
height: 40px;
|
|
||||||
padding: 0 12px;
|
|
||||||
border-radius: 14px;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 500;
|
|
||||||
text-align: left;
|
|
||||||
}
|
}
|
||||||
.mi .i {
|
.pop-sep > span {
|
||||||
|
flex: 1;
|
||||||
|
height: 1px;
|
||||||
|
background: var(--glass-sep);
|
||||||
|
}
|
||||||
|
/* A row: 8 px above and below the words (34 high, 50 with a line under the label); the icon further in from the
|
||||||
|
row's rounded edge (14 px) than it is from the words (10 px), so it doesn't crowd the curve. */
|
||||||
|
.mi {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
width: 100%;
|
||||||
|
min-height: 34px;
|
||||||
|
padding: 0 12px 0 14px;
|
||||||
|
border-radius: 18px;
|
||||||
|
color: var(--glass-text);
|
||||||
|
text-align: left;
|
||||||
|
transition: transform 150ms var(--ease-out);
|
||||||
|
}
|
||||||
|
/* Whole rows over the highlight (they have no fill of their own): pressed, a row scales as one layer, and its
|
||||||
|
words must not drop under the highlight with it. */
|
||||||
|
.mi {
|
||||||
|
z-index: 3;
|
||||||
|
}
|
||||||
|
.mi:active {
|
||||||
|
transform: scale(0.97);
|
||||||
|
}
|
||||||
|
.kbd .mi:focus-visible {
|
||||||
|
outline: 2px solid var(--accent);
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
|
.mi > .i {
|
||||||
|
position: relative;
|
||||||
|
z-index: 3;
|
||||||
|
flex: none;
|
||||||
|
color: currentColor;
|
||||||
|
transition: scale var(--spring-glide-dur, 400ms) var(--spring-glide, ease-out);
|
||||||
|
}
|
||||||
|
.mi > .i {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
color: var(--text-2);
|
|
||||||
}
|
}
|
||||||
/* An option's check, kept in its place on the others so the names line up. */
|
.mi.hot > .i {
|
||||||
.mi .i.off {
|
scale: 1.08;
|
||||||
visibility: hidden;
|
|
||||||
}
|
}
|
||||||
.mi.warn,
|
.mi-b {
|
||||||
.mi.warn .i {
|
position: relative;
|
||||||
|
z-index: 3;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 1px;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 8px 0;
|
||||||
|
}
|
||||||
|
.mi-l {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 18px;
|
||||||
|
letter-spacing: -0.2px;
|
||||||
|
}
|
||||||
|
.mi-s {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
font-size: 11.5px;
|
||||||
|
line-height: 15px;
|
||||||
|
color: var(--glass-sub);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
.mi.warn {
|
||||||
color: var(--warn);
|
color: var(--warn);
|
||||||
}
|
}
|
||||||
.mi.bad,
|
.mi.bad {
|
||||||
.mi.bad .i {
|
color: var(--glass-bad);
|
||||||
color: var(--bad);
|
|
||||||
}
|
|
||||||
.menu-sep {
|
|
||||||
height: 1px;
|
|
||||||
margin: 6px 12px;
|
|
||||||
background: var(--line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* One toast at a time; a new one comes in over the leaving one. */
|
/* One toast at a time; a new one comes in over the leaving one. */
|
||||||
|
|||||||
@@ -3,6 +3,12 @@
|
|||||||
.mt {
|
.mt {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
/* While the words change (ui/morph.ts): nothing of them clipped, not even by a box that ends a long line in an
|
||||||
|
ellipsis; that comes back once they have changed. */
|
||||||
|
.mt-run {
|
||||||
|
overflow: visible !important;
|
||||||
|
text-overflow: clip !important;
|
||||||
|
}
|
||||||
.mt-ib {
|
.mt-ib {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|||||||
@@ -22,6 +22,13 @@
|
|||||||
-webkit-mask-image: linear-gradient(#000 0%, rgba(0, 0, 0, 0.88) 44%, transparent 100%);
|
-webkit-mask-image: linear-gradient(#000 0%, rgba(0, 0, 0, 0.88) 44%, transparent 100%);
|
||||||
mask-image: linear-gradient(#000 0%, rgba(0, 0, 0, 0.88) 44%, transparent 100%);
|
mask-image: linear-gradient(#000 0%, rgba(0, 0, 0, 0.88) 44%, transparent 100%);
|
||||||
}
|
}
|
||||||
|
/* On a phone the blur under it is drawn again on every frame of a scroll: the fade to the page's colour alone. */
|
||||||
|
@media (pointer: coarse) {
|
||||||
|
.edge-fade.top {
|
||||||
|
-webkit-backdrop-filter: none;
|
||||||
|
backdrop-filter: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
body.scrolled .edge-fade.top {
|
body.scrolled .edge-fade.top {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
@@ -31,8 +38,8 @@ body.scrolled .edge-fade.top {
|
|||||||
background: linear-gradient(to top in oklab, var(--bg) 0%, transparent 100%);
|
background: linear-gradient(to top in oklab, var(--bg) 0%, transparent 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The breadcrumb (iconiqui, measured): 32px high, the mark in a 32px box, 15px crumbs 6px apart
|
/* The breadcrumb (iconiqui, measured): 32px high, the mark in a 32px box, then the place, 15px and
|
||||||
with a 14px chevron, the current one brighter. The mark is one colour: the text's. */
|
bright (the one crumb: the page is the person's own). The mark is one colour: the text's. */
|
||||||
.crumbs {
|
.crumbs {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -77,18 +84,14 @@ body.scrolled .edge-fade.top {
|
|||||||
color: var(--text);
|
color: var(--text);
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
.cr-path .i {
|
/* The language (a pick pill, ui/pick.ts): as high as the QR knob beside it, its flag, its code and a chevron
|
||||||
width: 14px;
|
that turns up while the popup is open. */
|
||||||
height: 14px;
|
|
||||||
}
|
|
||||||
/* The language: a pill as high as the QR knob beside it, its code and a chevron that turns up while
|
|
||||||
the menu is open. */
|
|
||||||
.cr-lang {
|
.cr-lang {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
gap: 6px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
padding: 0 8px 0 12px;
|
padding: 0 8px 0 8px;
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
background: var(--knob);
|
background: var(--knob);
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
@@ -109,15 +112,8 @@ body.scrolled .edge-fade.top {
|
|||||||
.cr-lang[aria-expanded='true'] {
|
.cr-lang[aria-expanded='true'] {
|
||||||
background: color-mix(in srgb, var(--knob), var(--text) 10%);
|
background: color-mix(in srgb, var(--knob), var(--text) 10%);
|
||||||
}
|
}
|
||||||
.cr-down {
|
.cr-lang .pp-chev {
|
||||||
width: 14px;
|
margin-left: -2px;
|
||||||
height: 14px;
|
|
||||||
color: var(--text-2);
|
|
||||||
transform: rotate(90deg);
|
|
||||||
transition: transform 200ms var(--ease-out);
|
|
||||||
}
|
|
||||||
.cr-lang[aria-expanded='true'] .cr-down {
|
|
||||||
transform: rotate(-90deg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Phones: one column, access first. From 960px: devices left, access right and sticky. The foot
|
/* Phones: one column, access first. From 960px: devices left, access right and sticky. The foot
|
||||||
@@ -280,3 +276,73 @@ body.scrolled .edge-fade.top {
|
|||||||
color: var(--text-2);
|
color: var(--text-2);
|
||||||
text-wrap: balance;
|
text-wrap: balance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* This page's code for another device (flows/page-code.ts): a card grown out of the QR knob where it stands, on
|
||||||
|
the ⋯ menu's Liquid Glass; the code on top and under it Copy link and Share. */
|
||||||
|
.pc-card {
|
||||||
|
position: absolute;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 8px;
|
||||||
|
width: 244px;
|
||||||
|
padding: 10px;
|
||||||
|
/* The dropdowns' radius (the ⋯ menu's), on their glass (.drop). */
|
||||||
|
border-radius: 24px;
|
||||||
|
}
|
||||||
|
/* Concentric with the card: its radius less the 10 px around the code. */
|
||||||
|
.pc-card .qrbox.big {
|
||||||
|
width: 224px;
|
||||||
|
height: 224px;
|
||||||
|
border-radius: 14px;
|
||||||
|
}
|
||||||
|
.pc-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
.pc-row .knob {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
background: color-mix(in srgb, var(--glass-text) 6%, transparent);
|
||||||
|
color: var(--glass-text);
|
||||||
|
}
|
||||||
|
.pc-row .knob:hover {
|
||||||
|
background: color-mix(in srgb, var(--glass-text) 11%, transparent);
|
||||||
|
}
|
||||||
|
.pc-copy {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
height: 36px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 7px;
|
||||||
|
padding: 0 14px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: color-mix(in srgb, var(--glass-text) 6%, transparent);
|
||||||
|
color: var(--glass-text);
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
transition:
|
||||||
|
transform 150ms var(--ease-out),
|
||||||
|
background-color 150ms;
|
||||||
|
}
|
||||||
|
.pc-copy:hover {
|
||||||
|
background: color-mix(in srgb, var(--glass-text) 11%, transparent);
|
||||||
|
}
|
||||||
|
.pc-copy:active {
|
||||||
|
transform: scale(0.96);
|
||||||
|
}
|
||||||
|
.pc-copy .i {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
.pc-copy .lbl {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.pc-copy.copied {
|
||||||
|
color: var(--ok);
|
||||||
|
}
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
/* A pick pill (ui/pick.ts): the pill's own look is its class's (the language in the breadcrumb, the demo's
|
||||||
|
set-up state); here what every one shares: what it leads with, its chevron, and its popup. */
|
||||||
|
.pp {
|
||||||
|
touch-action: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
.pp-lead {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
/* The one it led with before, blurring away over the new one. */
|
||||||
|
.pp-lead > .pp-gone {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
}
|
||||||
|
.pp-lead[hidden] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
/* Turned by its own angle (ui/pick.ts), so shutting goes on round to down rather than back. */
|
||||||
|
.pp-chev {
|
||||||
|
width: 14px;
|
||||||
|
height: 14px;
|
||||||
|
flex: none;
|
||||||
|
color: var(--text-2);
|
||||||
|
rotate: 90deg;
|
||||||
|
transition: rotate 260ms var(--ease-out);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The popup: segments in one pill frame on Liquid Glass (tokens.css --glass-*), its tail one shape with it (a clip
|
||||||
|
path, ui/pick.ts) with a soft even edge traced round both.
|
||||||
|
The segments: clear on the glass as the menu's rows are; the dropdowns' highlight rests on the picked one (it is
|
||||||
|
what says which is picked) and glides to the one pointed at; the picked one and the one pointed at in full text
|
||||||
|
colour, the rest in the glass's subtitle colour. */
|
||||||
|
.pp-pop {
|
||||||
|
position: fixed;
|
||||||
|
display: flex;
|
||||||
|
gap: 3px;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
/* Its edge and shadow are its own (the clip path would cut the dropdowns' off): the ring and the shade. */
|
||||||
|
.pp-pop.drop {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
/* Room for the tail, towards the pill. */
|
||||||
|
.pp-pop.above {
|
||||||
|
padding-bottom: 9px;
|
||||||
|
}
|
||||||
|
.pp-pop.below {
|
||||||
|
padding-top: 9px;
|
||||||
|
}
|
||||||
|
.pp-shade {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 59;
|
||||||
|
border-radius: 999px;
|
||||||
|
pointer-events: none;
|
||||||
|
box-shadow: var(--glass-shadow);
|
||||||
|
}
|
||||||
|
.pp-ring {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
pointer-events: none;
|
||||||
|
fill: none;
|
||||||
|
stroke: var(--glass-edge);
|
||||||
|
stroke-width: 2;
|
||||||
|
}
|
||||||
|
.pp-pop button {
|
||||||
|
position: relative;
|
||||||
|
z-index: 3;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 7px;
|
||||||
|
height: 34px;
|
||||||
|
padding: 0 10px;
|
||||||
|
border-radius: 10px;
|
||||||
|
color: var(--glass-sub);
|
||||||
|
font-size: 12.5px;
|
||||||
|
font-weight: 500;
|
||||||
|
white-space: nowrap;
|
||||||
|
transition:
|
||||||
|
color 150ms,
|
||||||
|
background-color 150ms,
|
||||||
|
transform 150ms var(--ease-out);
|
||||||
|
}
|
||||||
|
/* The ends follow the frame: half the segment's height (a larger radius would shrink every corner). */
|
||||||
|
.pp-pop button:first-of-type {
|
||||||
|
border-radius: 17px 10px 10px 17px;
|
||||||
|
padding-left: 13px;
|
||||||
|
}
|
||||||
|
.pp-pop button:last-of-type {
|
||||||
|
border-radius: 10px 17px 17px 10px;
|
||||||
|
padding-right: 13px;
|
||||||
|
}
|
||||||
|
/* Under the pointer, or under a finger sliding over from the pill. */
|
||||||
|
/* Under the pointer, or under a finger sliding over from the pill: the dropdowns' highlight is under it
|
||||||
|
(ui/glide.ts); its words come up. */
|
||||||
|
.pp-pop button.hot {
|
||||||
|
color: var(--glass-text);
|
||||||
|
}
|
||||||
|
.pp-pop button:active {
|
||||||
|
transform: scale(0.96);
|
||||||
|
}
|
||||||
|
.pp-pop button[aria-checked='true'] {
|
||||||
|
color: var(--glass-text);
|
||||||
|
}
|
||||||
|
.kbd .pp-pop button:focus-visible {
|
||||||
|
outline: 2px solid var(--accent);
|
||||||
|
outline-offset: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A language's flag: a 16px disc with a hairline so a white stripe keeps its edge. */
|
||||||
|
.flag {
|
||||||
|
position: relative;
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
border-radius: 50%;
|
||||||
|
overflow: hidden;
|
||||||
|
flex: none;
|
||||||
|
}
|
||||||
|
.flag svg {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.flag::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
|
||||||
|
}
|
||||||
|
.pp-pop button:not([aria-checked='true']):not(.hot) .flag {
|
||||||
|
opacity: 0.7;
|
||||||
|
}
|
||||||
@@ -22,10 +22,6 @@
|
|||||||
.step + .step {
|
.step + .step {
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
/* No data: the connection step alone in its row (flows/setup-view.ts regroup). */
|
|
||||||
.step[hidden] + .step {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
.step-n {
|
.step-n {
|
||||||
width: 24px;
|
width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
@@ -55,6 +51,12 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
}
|
}
|
||||||
|
/* The connection (flows/setup-view.ts): its picker over its box, in step 2, a row or the again-row alike. */
|
||||||
|
.conn {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
/* The way, as on the old portal: one dotted line, three layers through the same dots (the dots, the
|
/* The way, as on the old portal: one dotted line, three layers through the same dots (the dots, the
|
||||||
light along them that runs and rests a beat, the green that fills them from the device); the
|
light along them that runs and rests a beat, the green that fills them from the device); the
|
||||||
@@ -387,9 +389,14 @@
|
|||||||
font: 12px/18px var(--mono);
|
font: 12px/18px var(--mono);
|
||||||
max-height: 16rem;
|
max-height: 16rem;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
scrollbar-width: none;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
color: var(--text-2);
|
color: var(--text-2);
|
||||||
}
|
}
|
||||||
|
/* It scrolls with no bar, as the sheet it sits in. */
|
||||||
|
.conf::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
.conf .k {
|
.conf .k {
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,12 @@
|
|||||||
.sheet-root.open {
|
.sheet-root.open {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
/* The dim alone, no blur behind it: a blur of the whole page would be drawn again on every frame the sheet and
|
||||||
|
the dim move, and the system's own sheets dim too. */
|
||||||
.scrim {
|
.scrim {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
background: var(--scrim);
|
background: var(--scrim);
|
||||||
-webkit-backdrop-filter: blur(8px);
|
|
||||||
backdrop-filter: blur(8px);
|
|
||||||
}
|
}
|
||||||
.sheet {
|
.sheet {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -68,11 +68,16 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
flex: none;
|
flex: none;
|
||||||
}
|
}
|
||||||
|
/* It scrolls with no bar: a bar would cut into the sheet's round corners and its glass. */
|
||||||
.sheet-scroll {
|
.sheet-scroll {
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
overscroll-behavior: contain;
|
overscroll-behavior: contain;
|
||||||
|
scrollbar-width: none;
|
||||||
|
}
|
||||||
|
.sheet-scroll::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
}
|
}
|
||||||
.view {
|
.view {
|
||||||
padding: 0 24px 24px;
|
padding: 0 24px 24px;
|
||||||
@@ -135,34 +140,31 @@
|
|||||||
top: 22px;
|
top: 22px;
|
||||||
right: 58px;
|
right: 58px;
|
||||||
}
|
}
|
||||||
|
/* The connection's download and copy, on its row beside the chevron: quiet icons in the chevron's grey, a knob
|
||||||
|
circle behind one under the pointer. */
|
||||||
.hpill {
|
.hpill {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 2px;
|
|
||||||
}
|
}
|
||||||
.hp-b {
|
.hp-b {
|
||||||
display: grid;
|
display: grid;
|
||||||
place-items: center;
|
place-items: center;
|
||||||
width: 38px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
background: var(--knob);
|
border-radius: 50%;
|
||||||
color: var(--text);
|
color: var(--text-2);
|
||||||
transition:
|
transition:
|
||||||
background-color 150ms,
|
background-color 150ms,
|
||||||
|
color 150ms,
|
||||||
transform 150ms var(--ease-out);
|
transform 150ms var(--ease-out);
|
||||||
}
|
}
|
||||||
.hp-b:first-of-type {
|
|
||||||
border-radius: 16px 6px 6px 16px;
|
|
||||||
}
|
|
||||||
.hp-b:last-of-type {
|
|
||||||
border-radius: 6px 16px 16px 6px;
|
|
||||||
}
|
|
||||||
.hp-b .i {
|
.hp-b .i {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
.hp-b:hover {
|
.hp-b:hover {
|
||||||
background: color-mix(in srgb, var(--knob), var(--text) 6%);
|
background: var(--knob);
|
||||||
|
color: var(--text);
|
||||||
}
|
}
|
||||||
.hp-b:active {
|
.hp-b:active {
|
||||||
transform: scale(0.94);
|
transform: scale(0.94);
|
||||||
|
|||||||
@@ -1,29 +1,7 @@
|
|||||||
/* The portal's fonts and tokens. Dark first (the skiper21 palette, measured), light by the system's
|
/* The portal's tokens. Dark first (the skiper21 palette, measured), light by the system's
|
||||||
choice. Surfaces step up in brightness (ground → raised → field → knob) instead of borders; the
|
choice. Surfaces step up in brightness (ground → raised → field → knob) instead of borders; the
|
||||||
accent is the one sky blue, colour otherwise only means state (ok green, warn orange, bad red). */
|
accent is the one sky blue, colour otherwise only means state (ok green, warn orange, bad red). */
|
||||||
|
|
||||||
@font-face {
|
|
||||||
font-family: Geist;
|
|
||||||
src: url(geist-latin-wght-normal.woff2) format('woff2');
|
|
||||||
font-weight: 100 900;
|
|
||||||
font-display: swap;
|
|
||||||
unicode-range:
|
|
||||||
U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-21FF, U+2212, U+2215;
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: Geist;
|
|
||||||
src: url(geist-cyrillic-wght-normal.woff2) format('woff2');
|
|
||||||
font-weight: 100 900;
|
|
||||||
font-display: swap;
|
|
||||||
unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: 'Geist Mono';
|
|
||||||
src: url(geist-mono-latin-wght-normal.woff2) format('woff2');
|
|
||||||
font-weight: 100 900;
|
|
||||||
font-display: swap;
|
|
||||||
}
|
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
color-scheme: dark;
|
color-scheme: dark;
|
||||||
--bg: #080808;
|
--bg: #080808;
|
||||||
@@ -39,14 +17,27 @@
|
|||||||
--accent: #4eafff;
|
--accent: #4eafff;
|
||||||
--accent-ink: #ffffff;
|
--accent-ink: #ffffff;
|
||||||
--accent-soft: rgba(78, 175, 255, 0.13);
|
--accent-soft: rgba(78, 175, 255, 0.13);
|
||||||
--ok: #57d64b;
|
--ok: #30d158;
|
||||||
--ok-soft: rgba(87, 214, 75, 0.14);
|
--ok-soft: rgba(48, 209, 88, 0.14);
|
||||||
--warn: #ff8a3d;
|
--warn: #ff8d28;
|
||||||
--bad: #ff5c5c;
|
--bad: #ff383c;
|
||||||
--bad-soft: rgba(255, 92, 92, 0.13);
|
--bad-soft: rgba(255, 56, 60, 0.13);
|
||||||
--sel-bg: rgba(131, 209, 255, 0.25);
|
--sel-bg: rgba(131, 209, 255, 0.25);
|
||||||
--sel-fg: #64c6ff;
|
--sel-fg: #64c6ff;
|
||||||
--scrim: rgba(8, 8, 8, 0.8);
|
--scrim: rgba(8, 8, 8, 0.8);
|
||||||
|
/* iOS 26's Liquid Glass, Regular (Apple's Figma kit), for what pops over the page (the ⋯ menu, the pick pills'
|
||||||
|
popups): black 60% with a white 6% film at 67%, blurred and its colours lifted; a soft even edge; its own
|
||||||
|
text, subtitle and destructive colours; separators a touch softer than the edge; a solid highlight. */
|
||||||
|
--glass-bg: linear-gradient(rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.04)), rgba(0, 0, 0, 0.4);
|
||||||
|
--glass-edge: rgba(255, 255, 255, 0.05);
|
||||||
|
--glass-sep: rgba(255, 255, 255, 0.04);
|
||||||
|
--glass-text: #f5f5f5;
|
||||||
|
--glass-sub: #8a8a8a;
|
||||||
|
--glass-bad: var(--bad);
|
||||||
|
--glass-hl: color-mix(in srgb, var(--raised), var(--text) 8%);
|
||||||
|
--glass-hover: color-mix(in srgb, var(--raised), var(--text) 5%);
|
||||||
|
/* No shadow on dark: the glass's edge sets it apart; on light a soft one. */
|
||||||
|
--glass-shadow: 0 0 0 transparent;
|
||||||
--line-glass: rgba(255, 255, 255, 0.07);
|
--line-glass: rgba(255, 255, 255, 0.07);
|
||||||
--pop-shadow: 0 18px 48px -14px rgba(0, 0, 0, 0.75);
|
--pop-shadow: 0 18px 48px -14px rgba(0, 0, 0, 0.75);
|
||||||
--sheet-shadow: 0 24px 64px -16px rgba(0, 0, 0, 0.6);
|
--sheet-shadow: 0 24px 64px -16px rgba(0, 0, 0, 0.6);
|
||||||
@@ -65,14 +56,16 @@
|
|||||||
--t-blue-a: #a6d9ff;
|
--t-blue-a: #a6d9ff;
|
||||||
--t-blue-b: #1d84e6;
|
--t-blue-b: #1d84e6;
|
||||||
--t-green-a: #a8f29c;
|
--t-green-a: #a8f29c;
|
||||||
--t-green-b: #3aa32c;
|
--t-green-b: #30d158;
|
||||||
--t-red-a: #ffadad;
|
--t-red-a: #ffadad;
|
||||||
--t-red-b: #dc3a3a;
|
--t-red-b: #ff383c;
|
||||||
--t-orange-a: #ffc08f;
|
--t-orange-a: #ffc08f;
|
||||||
--t-orange-b: #ec6a12;
|
--t-orange-b: #ff8d28;
|
||||||
|
|
||||||
--font: Geist, -apple-system, system-ui, 'Segoe UI', sans-serif;
|
/* Each system's own type, nothing downloaded: SF Pro on Apple, Segoe UI on Windows, Roboto on
|
||||||
--mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;
|
Android, the desktop's sans on Linux; SF Mono, Cascadia Mono or Consolas for code. */
|
||||||
|
--font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', Ubuntu, Cantarell, 'Helvetica Neue', Arial, sans-serif;
|
||||||
|
--mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, 'Cascadia Mono', Consolas, 'Liberation Mono', 'DejaVu Sans Mono', monospace;
|
||||||
--r-sheet: 36px;
|
--r-sheet: 36px;
|
||||||
--r-card: 28px;
|
--r-card: 28px;
|
||||||
--r-row: 20px;
|
--r-row: 20px;
|
||||||
@@ -98,14 +91,22 @@
|
|||||||
--text-3: #a6a6a4;
|
--text-3: #a6a6a4;
|
||||||
--accent: #2b9dff;
|
--accent: #2b9dff;
|
||||||
--accent-soft: rgba(43, 157, 255, 0.12);
|
--accent-soft: rgba(43, 157, 255, 0.12);
|
||||||
--ok: #33a328;
|
--ok: #30d158;
|
||||||
--ok-soft: rgba(51, 163, 40, 0.12);
|
--ok-soft: rgba(48, 209, 88, 0.12);
|
||||||
--warn: #ee6a12;
|
--warn: #ff8d28;
|
||||||
--bad: #e5484d;
|
--bad: #ff383c;
|
||||||
--bad-soft: rgba(229, 72, 77, 0.1);
|
--bad-soft: rgba(255, 56, 60, 0.1);
|
||||||
--sel-bg: rgba(78, 175, 255, 0.22);
|
--sel-bg: rgba(78, 175, 255, 0.22);
|
||||||
--sel-fg: #0a76cf;
|
--sel-fg: #0a76cf;
|
||||||
--scrim: rgba(236, 236, 235, 0.62);
|
--scrim: rgba(236, 236, 235, 0.62);
|
||||||
|
--glass-bg: rgba(245, 245, 245, 0.6);
|
||||||
|
--glass-edge: rgba(0, 0, 0, 0.04);
|
||||||
|
--glass-sep: rgba(0, 0, 0, 0.03);
|
||||||
|
--glass-text: #1a1a1a;
|
||||||
|
--glass-sub: #727272;
|
||||||
|
--glass-hl: color-mix(in srgb, var(--raised), var(--text) 11%);
|
||||||
|
--glass-hover: color-mix(in srgb, var(--raised), var(--text) 4%);
|
||||||
|
--glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
||||||
--line-glass: rgba(0, 0, 0, 0.07);
|
--line-glass: rgba(0, 0, 0, 0.07);
|
||||||
--pop-shadow: 0 18px 44px -14px rgba(0, 0, 0, 0.2);
|
--pop-shadow: 0 18px 44px -14px rgba(0, 0, 0, 0.2);
|
||||||
--sheet-shadow: 0 24px 64px -18px rgba(0, 0, 0, 0.22);
|
--sheet-shadow: 0 24px 64px -18px rgba(0, 0, 0, 0.22);
|
||||||
@@ -123,8 +124,8 @@
|
|||||||
--t-blue-a: #7cc4ff;
|
--t-blue-a: #7cc4ff;
|
||||||
--t-blue-b: #0a6fd6;
|
--t-blue-b: #0a6fd6;
|
||||||
--t-green-a: #82e070;
|
--t-green-a: #82e070;
|
||||||
--t-green-b: #2e8a22;
|
--t-green-b: #30d158;
|
||||||
--t-red-a: #ff9090;
|
--t-red-a: #ff9090;
|
||||||
--t-red-b: #c92a2a;
|
--t-red-b: #ff383c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,11 @@ export interface AccItem {
|
|||||||
val?: Node | null;
|
val?: Node | null;
|
||||||
/** The body shows the same numbers: the head drops them while open. */
|
/** The body shows the same numbers: the head drops them while open. */
|
||||||
valHide?: boolean;
|
valHide?: boolean;
|
||||||
|
/**
|
||||||
|
* Actions on what the row holds, beside the chevron while it is open (gone while it is shut). Beside the head,
|
||||||
|
* not in it: the head is a button itself.
|
||||||
|
*/
|
||||||
|
aside?: Node | null;
|
||||||
body: (Node | null | false | undefined)[];
|
body: (Node | null | false | undefined)[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,20 +144,28 @@ export function accordion(
|
|||||||
);
|
);
|
||||||
const r = h(
|
const r = h(
|
||||||
'div',
|
'div',
|
||||||
{ class: `acc-row${still ? ' still' : ''}${open ? ' open' : ''}` },
|
{ class: `acc-row${still ? ' still' : ''}${open ? ' open' : ''}${it.aside ? ' has-aside' : ''}` },
|
||||||
headEl,
|
headEl,
|
||||||
|
it.aside ? h('div', { class: 'acc-aside' }, it.aside) : null,
|
||||||
h('div', { class: 'acc-body' }, ...kids),
|
h('div', { class: 'acc-body' }, ...kids),
|
||||||
);
|
);
|
||||||
acc.appendChild(r);
|
acc.appendChild(r);
|
||||||
return r;
|
return r;
|
||||||
});
|
});
|
||||||
const bodyOf = (r: HTMLElement) => r.querySelector('.acc-body') as HTMLElement;
|
const bodyOf = (r: HTMLElement) => r.querySelector('.acc-body') as HTMLElement;
|
||||||
const corners = () =>
|
/** Corners and edges over the rows that show: a row stepped out (only()) leaves no gap or corner behind. */
|
||||||
rows.forEach((r, i) => {
|
const corners = () => {
|
||||||
|
const shown = rows.filter((r) => !r.hidden);
|
||||||
|
shown.forEach((r, i) => {
|
||||||
const op = r.classList.contains('open');
|
const op = r.classList.contains('open');
|
||||||
r.classList.toggle('rt', i === 0 || op || rows[i - 1].classList.contains('open'));
|
r.classList.toggle('rt', i === 0 || op || shown[i - 1].classList.contains('open'));
|
||||||
r.classList.toggle('rb', i === rows.length - 1 || op || rows[i + 1].classList.contains('open'));
|
r.classList.toggle('rb', i === shown.length - 1 || op || shown[i + 1].classList.contains('open'));
|
||||||
});
|
});
|
||||||
|
rows.forEach((r) => {
|
||||||
|
r.classList.toggle('first', r === shown[0]);
|
||||||
|
r.classList.toggle('last', r === shown[shown.length - 1]);
|
||||||
|
});
|
||||||
|
};
|
||||||
const read = (x: HTMLElement) => {
|
const read = (x: HTMLElement) => {
|
||||||
const cs = getComputedStyle(x);
|
const cs = getComputedStyle(x);
|
||||||
const out: Record<string, string> = {};
|
const out: Record<string, string> = {};
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ function now(el: Element): Keyframe {
|
|||||||
|
|
||||||
/** What gives way: the button's own elements (a bare word goes into a span first). */
|
/** What gives way: the button's own elements (a bare word goes into a span first). */
|
||||||
function content(btn: HTMLElement): Element[] {
|
function content(btn: HTMLElement): Element[] {
|
||||||
for (const n of [...btn.childNodes])
|
// A copy: childNodes is live and the loop replaces nodes in it.
|
||||||
|
for (const n of Array.from(btn.childNodes))
|
||||||
if (n.nodeType === Node.TEXT_NODE && n.textContent?.trim()) n.replaceWith(h('span', {}, n.textContent));
|
if (n.nodeType === Node.TEXT_NODE && n.textContent?.trim()) n.replaceWith(h('span', {}, n.textContent));
|
||||||
return [...btn.children].filter((c) => !c.classList.contains('orb'));
|
return [...btn.children].filter((c) => !c.classList.contains('orb'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,12 @@
|
|||||||
// and blinks as macOS draws it; a selection is an accent wash with a handle at
|
// and blinks as macOS draws it; a selection is an accent wash with a handle at
|
||||||
// each end, as iOS draws it, growing out of the caret and fading back into it.
|
// each end, as iOS draws it, growing out of the caret and fading back into it.
|
||||||
// The input stays the browser's own (typing, IME, its native selection, made
|
// The input stays the browser's own (typing, IME, its native selection, made
|
||||||
// see-through): this only draws over it. On a touch screen the system draws its
|
// see-through): this only draws over it. With a mouse or trackpad only: on a
|
||||||
// own selection and handles, so ours stays off and the caret steps aside while
|
// touch screen the system's caret stays (in the accent), with its own selection
|
||||||
// one shows. The look is in styles/controls.css; like the rest of the page this
|
// and handles. iOS doesn't tell a page reliably where its caret went (a tap in
|
||||||
// writes styles through `el.style` only (the CSP drops style attributes).
|
// the words, a press-and-drag): a drawn one would wait for the first key. The
|
||||||
|
// look is in styles/controls.css; like the rest of the page this writes styles
|
||||||
|
// through `el.style` only (the CSP drops style attributes).
|
||||||
//
|
//
|
||||||
// Places come from a hidden mirror with the input's own font: the width of the
|
// Places come from a hidden mirror with the input's own font: the width of the
|
||||||
// text up to a position, less how far the input has scrolled. The pure parts
|
// text up to a position, less how far the input has scrolled. The pure parts
|
||||||
@@ -23,7 +25,7 @@ export interface Glide {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** The frame the glide is tuned to, in ms. */
|
/** The frame the glide is tuned to, in ms. */
|
||||||
const FRAME = 16.67;
|
export const FRAME = 16.67;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move a glide on by `frames` frames (after bencho.dev's one-time code, a softer pull: per frame
|
* Move a glide on by `frames` frames (after bencho.dev's one-time code, a softer pull: per frame
|
||||||
@@ -87,15 +89,15 @@ export function places(f: FieldText, measure: (text: string) => number): Places
|
|||||||
const FONT = ['fontFamily', 'fontSize', 'fontWeight', 'letterSpacing', 'fontFeatureSettings', 'fontVariationSettings'] as const;
|
const FONT = ['fontFamily', 'fontSize', 'fontWeight', 'letterSpacing', 'fontFeatureSettings', 'fontVariationSettings'] as const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Give the input of `field` (a `.field`) the glide caret and, with a fine pointer, the selection.
|
* Give the input of `field` (a `.field`) the glide caret and the selection, with a mouse or trackpad.
|
||||||
* Call it once, as the field is built (it measures only once the field is on the page).
|
* Call it once, as the field is built (it measures only once the field is on the page).
|
||||||
*/
|
*/
|
||||||
export function smoothCaret(field: HTMLElement) {
|
export function smoothCaret(field: HTMLElement) {
|
||||||
const input = field.querySelector('input');
|
const input = field.querySelector('input');
|
||||||
if (!input) return;
|
if (!input) return;
|
||||||
const fine = matchMedia('(pointer: fine)').matches;
|
// A touch screen: the system's caret (controls.css gives it the accent).
|
||||||
field.classList.add('own-caret');
|
if (!matchMedia('(pointer: fine)').matches) return;
|
||||||
if (fine) field.classList.add('own-sel');
|
field.classList.add('own-caret', 'own-sel');
|
||||||
const wash = h('span', { class: 'caret-sel' });
|
const wash = h('span', { class: 'caret-sel' });
|
||||||
const h0 = h('span', { class: 'caret-hd s' });
|
const h0 = h('span', { class: 'caret-hd s' });
|
||||||
const h1 = h('span', { class: 'caret-hd e' });
|
const h1 = h('span', { class: 'caret-hd e' });
|
||||||
@@ -187,7 +189,7 @@ export function smoothCaret(field: HTMLElement) {
|
|||||||
all.forEach((g) => jump(g, p.start));
|
all.forEach((g) => jump(g, p.start));
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
if (p.range && fine) {
|
if (p.range) {
|
||||||
// Selecting: the wash grows out of where the caret is, and the caret steps aside. A wash still fading from
|
// Selecting: the wash grows out of where the caret is, and the caret steps aside. A wash still fading from
|
||||||
// the last selection turns back instead and glides from its old ends to the new ones.
|
// the last selection turns back instead and glides from its old ends to the new ones.
|
||||||
if (!selecting) {
|
if (!selecting) {
|
||||||
@@ -204,10 +206,6 @@ export function smoothCaret(field: HTMLElement) {
|
|||||||
cur.t = p.caret;
|
cur.t = p.caret;
|
||||||
field.classList.add('selecting');
|
field.classList.add('selecting');
|
||||||
caret.classList.remove('on', 'blink');
|
caret.classList.remove('on', 'blink');
|
||||||
} else if (p.range) {
|
|
||||||
// A touch screen: the system's own selection shows.
|
|
||||||
caret.classList.remove('on', 'blink');
|
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
// Collapsed: the wash fades where it stands, and its ends join the caret once it is gone.
|
// Collapsed: the wash fades where it stands, and its ends join the caret once it is gone.
|
||||||
// A click puts the caret where it was clicked at once, as macOS does; typing and the arrows glide.
|
// A click puts the caret where it was clicked at once, as macOS does; typing and the arrows glide.
|
||||||
|
|||||||
@@ -0,0 +1,84 @@
|
|||||||
|
// What every dropdown shares (the ⋯ menu, the pick pills' popups, the page's code): its look (.drop,
|
||||||
|
// styles/drop.css: Liquid Glass, a soft even edge, a soft shadow on light only), one open at a time, the same gap to
|
||||||
|
// its button and margin to the screen's edge, the same way in (a spring out of where it grows from) and out (back
|
||||||
|
// towards it, from where it stands), and the same ways to shut it: a press outside it and its button, Escape (the
|
||||||
|
// sheet under it stays; focus goes back to the button), a resize (at once). Each lays out and fills its own.
|
||||||
|
|
||||||
|
import { EASE_IN, SOFT, play } from '../motion';
|
||||||
|
|
||||||
|
/** From its button, and from the screen's edge. */
|
||||||
|
export const GAP = 8;
|
||||||
|
export const EDGE = 12;
|
||||||
|
|
||||||
|
let current: ((now?: boolean) => void) | null = null;
|
||||||
|
|
||||||
|
/** A dropdown is open (the page holds its repaints meanwhile). */
|
||||||
|
export const dropOpen = () => !!current;
|
||||||
|
|
||||||
|
/** Shut the one open (`now`: at once: a sheet opening, the page drawn again in another language). */
|
||||||
|
export function closeDrop(now = false) {
|
||||||
|
current?.(now);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Where an element stands now, mid-motion included. */
|
||||||
|
function standing(el: Element): Keyframe {
|
||||||
|
const s = getComputedStyle(el);
|
||||||
|
return { opacity: s.opacity, transform: s.transform, filter: s.filter === 'none' ? 'blur(0px)' : s.filter };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** In: a soft spring out of its transform origin (a little over, no wobble). */
|
||||||
|
export function appear(el: Element) {
|
||||||
|
play(
|
||||||
|
el,
|
||||||
|
[
|
||||||
|
{ opacity: 0, transform: 'scale(.5)', filter: 'blur(6px)' },
|
||||||
|
{ opacity: 1, transform: 'none', filter: 'blur(0px)' },
|
||||||
|
],
|
||||||
|
{ duration: SOFT.duration, easing: SOFT.easing },
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Out: back towards its origin from where it stands, then gone. */
|
||||||
|
export function vanish(el: Element) {
|
||||||
|
const from = standing(el);
|
||||||
|
el.getAnimations().forEach((a) => a.cancel());
|
||||||
|
play(el, [from, { opacity: 0, transform: 'scale(.7)', filter: 'blur(4px)' }], {
|
||||||
|
duration: 110,
|
||||||
|
easing: EASE_IN,
|
||||||
|
fill: 'forwards',
|
||||||
|
}).onfinish = () => el.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Open `panel` for `button`: another one open shuts at once, and the ways to shut this one are listened for.
|
||||||
|
* `shut(now)` does the closing itself; what this returns is to be called first thing in it (it lets go of the
|
||||||
|
* listeners, says the button is shut, and is false when the dropdown was shut already).
|
||||||
|
*/
|
||||||
|
export function opened(panel: Element, button: HTMLElement, shut: (now?: boolean) => void): () => boolean {
|
||||||
|
if (current) current(true);
|
||||||
|
const outside = (e: PointerEvent) => {
|
||||||
|
const t = e.target as Node;
|
||||||
|
if (!panel.contains(t) && !button.contains(t)) shut();
|
||||||
|
};
|
||||||
|
const esc = (e: KeyboardEvent) => {
|
||||||
|
if (e.key !== 'Escape') return;
|
||||||
|
e.stopPropagation();
|
||||||
|
shut();
|
||||||
|
button.focus({ preventScroll: true });
|
||||||
|
};
|
||||||
|
const resized = () => shut(true);
|
||||||
|
document.addEventListener('pointerdown', outside, true);
|
||||||
|
document.addEventListener('keydown', esc, true);
|
||||||
|
addEventListener('resize', resized);
|
||||||
|
button.setAttribute('aria-expanded', 'true');
|
||||||
|
current = shut;
|
||||||
|
return () => {
|
||||||
|
if (current !== shut) return false;
|
||||||
|
current = null;
|
||||||
|
document.removeEventListener('pointerdown', outside, true);
|
||||||
|
document.removeEventListener('keydown', esc, true);
|
||||||
|
removeEventListener('resize', resized);
|
||||||
|
button.setAttribute('aria-expanded', 'false');
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -51,7 +51,7 @@ export function toast(msg: string, bad = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** An icon that changes in place: the new one (by name, or one to put back) pops in where the old one stood. */
|
/** An icon that changes in place: the new one (by name, or one to put back) pops in where the old one stood. */
|
||||||
export function swapIcon(icon: Element, to: string | Element): Element {
|
function swapIcon(icon: Element, to: string | Element): Element {
|
||||||
const next = typeof to === 'string' ? ic(to, icon.getAttribute('class') ?? 'i') : to;
|
const next = typeof to === 'string' ? ic(to, icon.getAttribute('class') ?? 'i') : to;
|
||||||
icon.replaceWith(next);
|
icon.replaceWith(next);
|
||||||
play(
|
play(
|
||||||
|
|||||||