23 Commits

Author SHA1 Message Date
codex-bot 724f176228 Scale each petal arc directly with the continuity control 2026-12-06 04:16:34 +08:00
codex-bot 110fe7f12b Generate new ribbon marks from a configurable spherical field 2026-12-06 04:15:57 +08:00
Zayden-Jung a6d62b9f52 Merge pull request '按参考顺序重建十二款色带图形' (#40) from codex/brand into main
Deploy Rust Bedrock / deploy (push) Has been cancelled
Reviewed-on: #40
2026-12-05 20:11:28 +00:00
codex-bot 8c0957dc07 Fit and render the twelve reference views with adaptive gradient meshes 2026-12-06 04:04:39 +08:00
codex-bot 9fe64a7c89 Generate the twelve ribbon studies from analytic sphere intersections 2026-12-06 03:58:47 +08:00
codex-bot 831563f04e Reconstruct all twelve ribbon marks as individually exportable vectors 2026-12-06 03:52:54 +08:00
Zayden-Jung 2c47c39e52 Merge pull request '修正色带试稿的轮廓与遮挡' (#39) from codex/brand into main
Deploy Rust Bedrock / deploy (push) Has been cancelled
Reviewed-on: #39
2026-12-05 19:48:05 +00:00
codex-bot 35a14dbd4f Refine petal spacing and project continuous spherical ribbons 2026-12-06 03:47:24 +08:00
Zayden-Jung e36a7dc1dd Merge pull request '新增 Python 色带品牌图形试稿' (#38) from codex/brand into main
Deploy Rust Bedrock / deploy (push) Has been cancelled
Reviewed-on: #38
2026-12-05 19:46:04 +00:00
codex-bot 6b26e8698f Add a Python-generated ribbon mark study 2026-12-06 03:45:03 +08:00
Zayden-Jung 310e86905f Merge pull request '调轻 Home 导航侧栏图标' (#37) from codex/home into main
Reviewed-on: #37
2026-12-05 18:19:25 +00:00
codex-bot 42e0c89c44 Lighten Home navigation icon strokes 2026-12-06 02:17:30 +08:00
Zayden-Jung 131b74602c Merge pull request '按 Stitch 原稿还原 Home 并初始化三个前端工作区' (#36) from codex/home into main
Deploy Rust Bedrock / deploy (push) Has been cancelled
Reviewed-on: #36
2026-12-05 13:00:01 +00:00
codex-bot d21e866bc2 Restore Stitch Home and initialize three frontend workspaces 2026-12-05 20:44:18 +08:00
Zayden-Jung 9843afe0bc Merge pull request '将 Dashboard 源码纳入 Bedrock 并跳过其独立部署' (#35) from codex/dashboard into main
Deploy Rust Bedrock / deploy (push) Successful in 3m9s
Reviewed-on: #35
2026-12-05 11:59:41 +00:00
codex-bot 975e480578 Track Dashboard without deploying it 2026-12-05 19:57:23 +08:00
Zayden-Jung 5d9af01798 Merge pull request '补充 Bedrock Kubernetes 部署指南' (#34) from codex/backend-admin-architecture into main
Deploy Rust Bedrock / deploy (push) Successful in 15m46s
Reviewed-on: #34
2026-12-03 19:07:05 +00:00
codex-bot 4afc10f4cf Sync deployment guide with main and fix its build script link 2026-12-04 03:06:11 +08:00
Zayden-Jung 91afd0e04e Merge pull request '实现 Workspace 邀请策略与 Document 归属' (#31) from codex/document-model into main
Deploy Rust Bedrock / deploy (push) Successful in 20m57s
Reviewed-on: #31
2026-12-02 21:11:14 +00:00
codex-bot 0a74ef159b Model workspace invitation policies and document ownership 2026-12-02 15:39:26 +08:00
codex-bot 1d0b7d9765 Show Kubernetes and database manifest preparation in parallel 2026-12-01 00:54:50 +08:00
codex-bot 6640cf3b14 Clarify when to apply the PostgreSQL manifest 2026-12-01 00:48:51 +08:00
codex-bot 9f79d1e11c Document the Kubernetes deployment flow 2026-12-01 00:43:07 +08:00
79 changed files with 5827 additions and 561 deletions
+6
View File
@@ -3,6 +3,12 @@ name: Deploy Rust Bedrock
on: on:
push: push:
branches: [main] branches: [main]
paths-ignore:
- 'home/**'
- 'dashboard/**'
- 'repository/**'
- 'package.json'
- 'package-lock.json'
concurrency: concurrency:
group: bedrock-rust-deploy group: bedrock-rust-deploy
+2
View File
@@ -1,3 +1,5 @@
/target /target
/bedrock.sqlite3 /bedrock.sqlite3
/bedrock.sqlite3-* /bedrock.sqlite3-*
/node_modules/
Generated
+4 -253
View File
@@ -13,11 +13,9 @@ name = "admin_backend"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"axum", "axum",
"bedrock-rpc",
"clusters", "clusters",
"serde", "serde",
"subtle", "subtle",
"tokio",
] ]
[[package]] [[package]]
@@ -159,28 +157,12 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "base64"
version = "0.23.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
[[package]] [[package]]
name = "base64ct" name = "base64ct"
version = "1.8.3" version = "1.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06"
[[package]]
name = "bedrock-rpc"
version = "0.1.0"
dependencies = [
"axum",
"reqwest",
"serde_json",
"thiserror",
]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "2.13.2" version = "2.13.2"
@@ -248,12 +230,6 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
[[package]]
name = "cfg_aliases"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
[[package]] [[package]]
name = "chacha20" name = "chacha20"
version = "0.10.2" version = "0.10.2"
@@ -671,10 +647,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"js-sys",
"libc", "libc",
"wasi 0.11.1+wasi-snapshot-preview1", "wasi 0.11.1+wasi-snapshot-preview1",
"wasm-bindgen",
] ]
[[package]] [[package]]
@@ -828,23 +802,6 @@ dependencies = [
"pin-project-lite", "pin-project-lite",
"smallvec", "smallvec",
"tokio", "tokio",
"want",
]
[[package]]
name = "hyper-rustls"
version = "0.27.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53"
dependencies = [
"http",
"hyper",
"hyper-util",
"rustls",
"tokio",
"tokio-rustls",
"tower-service",
"webpki-roots 1.0.12",
] ]
[[package]] [[package]]
@@ -853,22 +810,13 @@ version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff" checksum = "ddc03d96684f9226b8a787cdb71488417b53ab5ea8fdb1dac946cb9431cc8bff"
dependencies = [ dependencies = [
"base64 0.23.1",
"bytes", "bytes",
"futures-channel",
"futures-util",
"http", "http",
"http-body", "http-body",
"httparse",
"hyper", "hyper",
"ipnet",
"libc",
"percent-encoding",
"pin-project-lite", "pin-project-lite",
"socket2 0.6.5",
"tokio", "tokio",
"tower-service", "tower-service",
"tracing",
] ]
[[package]] [[package]]
@@ -985,12 +933,6 @@ dependencies = [
"hashbrown 0.17.2", "hashbrown 0.17.2",
] ]
[[package]]
name = "ipnet"
version = "2.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "007d6e6b91097094791302ccc6cd0588e0700ddac5c6829035bcd71eff4dc433"
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.19" version = "1.0.19"
@@ -1079,12 +1021,6 @@ dependencies = [
"hashbrown 0.16.1", "hashbrown 0.16.1",
] ]
[[package]]
name = "lru-slab"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f"
[[package]] [[package]]
name = "matchit" name = "matchit"
version = "0.8.4" version = "0.8.4"
@@ -1178,7 +1114,7 @@ version = "0.35.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbb9f371618ce723f095c61fbcdc36e8936956d2b62832f9c7648689b338e052" checksum = "fbb9f371618ce723f095c61fbcdc36e8936956d2b62832f9c7648689b338e052"
dependencies = [ dependencies = [
"base64 0.22.1", "base64",
"bitflags", "bitflags",
"btoi", "btoi",
"byteorder", "byteorder",
@@ -1285,7 +1221,7 @@ version = "3.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be" checksum = "1d30c53c26bc5b31a98cd02d20f25a7c8567146caf63ed593a9d87b2775291be"
dependencies = [ dependencies = [
"base64 0.22.1", "base64",
"serde_core", "serde_core",
] ]
@@ -1332,7 +1268,7 @@ version = "0.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08808e3c483c46e999108051c78334f473d5adb59d78bb80a1268c7e6aa6c514" checksum = "08808e3c483c46e999108051c78334f473d5adb59d78bb80a1268c7e6aa6c514"
dependencies = [ dependencies = [
"base64 0.22.1", "base64",
"byteorder", "byteorder",
"bytes", "bytes",
"fallible-iterator 0.2.0", "fallible-iterator 0.2.0",
@@ -1382,62 +1318,6 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "quinn"
version = "0.11.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4051e23e9185c255a7e33ef59cdbca87a22d359052eecd22fc6b901fb37d9d11"
dependencies = [
"bytes",
"cfg_aliases",
"pin-project-lite",
"quinn-proto",
"quinn-udp",
"rustc-hash",
"rustls",
"socket2 0.6.5",
"thiserror",
"tokio",
"tracing",
"web-time",
]
[[package]]
name = "quinn-proto"
version = "0.11.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e750cca55fe4f0439a15d0bb529da9651e79993e8e72c61a899a36d462befbe"
dependencies = [
"bytes",
"getrandom 0.4.3",
"lru-slab",
"rand 0.10.4",
"rand_pcg",
"ring",
"rustc-hash",
"rustls",
"rustls-pki-types",
"slab",
"thiserror",
"tinyvec",
"tracing",
"web-time",
]
[[package]]
name = "quinn-udp"
version = "0.5.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016"
dependencies = [
"cfg_aliases",
"libc",
"once_cell",
"socket2 0.6.5",
"tracing",
"windows-sys 0.61.2",
]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.47" version = "1.0.47"
@@ -1505,15 +1385,6 @@ version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"
[[package]]
name = "rand_pcg"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb95882a1e14462c69aea9984bb261293ccfe6022ef8de0eda18bd5afb0052df"
dependencies = [
"rand_core 0.10.1",
]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.5.18" version = "0.5.18"
@@ -1552,44 +1423,6 @@ version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6" checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6"
[[package]]
name = "reqwest"
version = "0.12.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147"
dependencies = [
"base64 0.22.1",
"bytes",
"futures-core",
"http",
"http-body",
"http-body-util",
"hyper",
"hyper-rustls",
"hyper-util",
"js-sys",
"log",
"percent-encoding",
"pin-project-lite",
"quinn",
"rustls",
"rustls-pki-types",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
"tokio",
"tokio-rustls",
"tower",
"tower-http",
"tower-service",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"webpki-roots 1.0.12",
]
[[package]] [[package]]
name = "ring" name = "ring"
version = "0.17.14" version = "0.17.14"
@@ -1618,12 +1451,6 @@ dependencies = [
"smallvec", "smallvec",
] ]
[[package]]
name = "rustc-hash"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "1.1.6" version = "1.1.6"
@@ -1666,7 +1493,6 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb" checksum = "102f35f7de7b06d8c61f1cff6592f5253e0dea431c74867aad5dfd70f44663fb"
dependencies = [ dependencies = [
"web-time",
"zeroize", "zeroize",
] ]
@@ -1687,12 +1513,6 @@ version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
[[package]]
name = "ryu"
version = "1.0.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
[[package]] [[package]]
name = "saturating" name = "saturating"
version = "0.1.0" version = "0.1.0"
@@ -1722,7 +1542,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "969cde0349344dbbf58b5f9badbfb8f806db13969364eb8007c057ef687007d9" checksum = "969cde0349344dbbf58b5f9badbfb8f806db13969364eb8007c057ef687007d9"
dependencies = [ dependencies = [
"annotate-snippets", "annotate-snippets",
"base64 0.22.1", "base64",
"encoding_rs_io", "encoding_rs_io",
"granit-parser", "granit-parser",
"nohash-hasher", "nohash-hasher",
@@ -1785,18 +1605,6 @@ dependencies = [
"serde_core", "serde_core",
] ]
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
dependencies = [
"form_urlencoded",
"itoa",
"ryu",
"serde",
]
[[package]] [[package]]
name = "sha1" name = "sha1"
version = "0.10.7" version = "0.10.7"
@@ -1956,9 +1764,6 @@ name = "sync_wrapper"
version = "1.0.2" version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
dependencies = [
"futures-core",
]
[[package]] [[package]]
name = "synstructure" name = "synstructure"
@@ -2198,24 +2003,6 @@ dependencies = [
"tower-service", "tower-service",
] ]
[[package]]
name = "tower-http"
version = "0.6.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840"
dependencies = [
"bitflags",
"bytes",
"futures-util",
"http",
"http-body",
"pin-project-lite",
"tower",
"tower-layer",
"tower-service",
"url",
]
[[package]] [[package]]
name = "tower-layer" name = "tower-layer"
version = "0.3.3" version = "0.3.3"
@@ -2259,12 +2046,6 @@ dependencies = [
"once_cell", "once_cell",
] ]
[[package]]
name = "try-lock"
version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]] [[package]]
name = "twox-hash" name = "twox-hash"
version = "2.1.5" version = "2.1.5"
@@ -2365,15 +2146,6 @@ version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "want"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec4cdd0dd910afe868b7ef477227d8d538b46b3075031afee8a9f2acb0a2ed0b"
dependencies = [
"try-lock",
]
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.11.1+wasi-snapshot-preview1" version = "0.11.1+wasi-snapshot-preview1"
@@ -2419,17 +2191,6 @@ dependencies = [
"wasm-bindgen-shared", "wasm-bindgen-shared",
] ]
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.80"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e14e0327cb5368ad60ccb22d04a9827a693c95a926d8d125e9fa39e0baec501"
dependencies = [
"js-sys",
"tokio",
"wasm-bindgen",
]
[[package]] [[package]]
name = "wasm-bindgen-macro" name = "wasm-bindgen-macro"
version = "0.2.130" version = "0.2.130"
@@ -2472,16 +2233,6 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "web-time"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]] [[package]]
name = "webpki-roots" name = "webpki-roots"
version = "0.26.11" version = "0.26.11"
+2 -21
View File
@@ -1,16 +1,4 @@
# Bedrock 集群 RPC 原型归档 # Bedrock storage
`codex/cluster-rpc-archive` 保存 Bedrock 早期的三个 Rust RPC 原型,供以后对照契约和传输实现。原型开发已暂停。Bedrock 的逻辑集群工作在 `codex/cluster-research` 的 `crates/clusters` 内继续。[研究分支 PR #33](https://gitea.entroia.com/Zayden-Jung/Bedrock/pulls/33)
| 原工作分支 | 值得查看的内容 | 完整版本 |
| --- | --- | --- |
| `codex/typed-service-bindings` | 同一份 Rust 声明生成 HTTP 客户端和 Axum 路由。部署状态查询接入管理监听器,集成测试覆盖鉴权和无效请求。归档分支默认展示这套源码。 | [`46b85a9`](https://gitea.entroia.com/Zayden-Jung/Bedrock/src/commit/46b85a9d474cafad1034b1d249c736cc8cfa2ce4) |
| `codex/typed-service-contracts` | 版本化服务名和稳定的方法编号驱动客户端与服务端分派。进程内测试和回环 TCP 示例展示同一契约如何适配不同传输。 | [`7a7ee45`](https://gitea.entroia.com/Zayden-Jung/Bedrock/src/commit/7a7ee457614461382e3a815a78617dd675dcc48e) |
| `codex/cluster-rpc` | 保存整理前的开发现场。HTTP 实现与方法编号版的示例、测试和依赖清单处于混用状态。此版本用于追溯中间改动。 | [`6a81ed9`](https://gitea.entroia.com/Zayden-Jung/Bedrock/src/commit/6a81ed95a177df9c1703009faadc4696e0454855) |
三个链接分别打开各自的源码树。这些提交都在本分支的合并历史中。原型中的 `crates/bedrock-rpc` 记录了当时单独分包的实验;后续实现可参考其中的契约和测试。以下为 HTTP 原型原有的项目说明。
## Bedrock storage
Bedrock stores JSON documents in SQLite, PostgreSQL or MySQL. Each backend has its own module in the `database` crate. SQLite is the default and creates `bedrock.sqlite3` in the current directory on first start. Bedrock stores JSON documents in SQLite, PostgreSQL or MySQL. Each backend has its own module in the `database` crate. SQLite is the default and creates `bedrock.sqlite3` in the current directory on first start.
@@ -20,13 +8,6 @@ Bedrock stores JSON documents in SQLite, PostgreSQL or MySQL. Each backend has i
Notion describes sharding online PostgreSQL block data by workspace and feeding a downstream S3 data lake from PostgreSQL changes. Bedrock supports named SQL roles and read replicas. The catalog can describe S3 buckets. Object I/O, workspace routing, and data-lake ingestion are future work. [Notion's PostgreSQL sharding](https://www.notion.com/blog/sharding-postgres-at-notion) · [Notion's data lake](https://www.notion.com/blog/building-and-scaling-notions-data-lake) Notion describes sharding online PostgreSQL block data by workspace and feeding a downstream S3 data lake from PostgreSQL changes. Bedrock supports named SQL roles and read replicas. The catalog can describe S3 buckets. Object I/O, workspace routing, and data-lake ingestion are future work. [Notion's PostgreSQL sharding](https://www.notion.com/blog/sharding-postgres-at-notion) · [Notion's data lake](https://www.notion.com/blog/building-and-scaling-notions-data-lake)
## Cluster service calls
[bedrock-rpc](crates/bedrock-rpc/README.md) generates typed clients, handlers,
and Axum routes from a shared Rust declaration. The first contract reads
deployment status via `POST /admin/v1/deployment/status` with JSON body `{}`
and the admin listener's existing bearer authentication.
## Web backend ## Web backend
Run the Axum service with `cargo run --locked -p backend`. One process owns Run the Axum service with `cargo run --locked -p backend`. One process owns
@@ -36,7 +17,7 @@ separate routers on the business and optional admin listeners.
| Listener | Setting and default | Routes | | Listener | Setting and default | Routes |
|---|---|---| |---|---|---|
| Business | `BEDROCK_BACKEND_LISTEN`, default `127.0.0.1:8080` | `GET /healthz`, `GET /readyz` | | Business | `BEDROCK_BACKEND_LISTEN`, default `127.0.0.1:8080` | `GET /healthz`, `GET /readyz` |
| Admin | `BEDROCK_ADMIN_LISTEN`, default `127.0.0.1:8081` when enabled | `GET /healthz`, `GET /readyz`, `GET /admin/v1/status`, `POST /admin/v1/deployment/status` | | Admin | `BEDROCK_ADMIN_LISTEN`, default `127.0.0.1:8081` when enabled | `GET /healthz`, `GET /readyz`, `GET /admin/v1/status` |
The business readiness probe checks access to the current deployment revision. The business readiness probe checks access to the current deployment revision.
Set `BEDROCK_ADMIN_TOKEN` from a private credential source to enable the admin Set `BEDROCK_ADMIN_TOKEN` from a private credential source to enable the admin
+115
View File
@@ -0,0 +1,115 @@
"""Draw all twelve reference marks, or export one with --mark 1..12."""
import argparse
import json
from math import cos, sin, pi, radians
from pathlib import Path
from generate import gradient, trefoil
DIRECTORY = Path(__file__).resolve().parent
NAMES = (
"Crossed horizontal bands", "Nested rings", "Vertical split", "Diagonal weave",
"Opposing caps", "Diagonal fold", "Three petals", "Horizontal belt",
"Stepped wrap", "Vertical weave", "Open wave", "Open helix",
)
def outline(points):
"""Blend adjacent contour segments into a closed cubic spline."""
commands = [f"M{points[0][0]},{points[0][1]}"]
for i, a in enumerate(points):
prev, b, after = (points[j % len(points)] for j in (i-1, i+1, i+2))
# Short handles preserve tight crossings and narrow gaps.
c = [a[k] + (b[k]-prev[k])*.10 for k in (0, 1)]
d = [b[k] - (after[k]-a[k])*.10 for k in (0, 1)]
commands.append(f"C{c[0]:.2f},{c[1]:.2f} {d[0]:.2f},{d[1]:.2f} {b[0]},{b[1]}")
return "".join(commands) + "Z"
def rings():
"""Project parallel latitude bands, keeping the lower pole in view."""
strips = []
palette = [("#ffddad", "#ffd5be"), ("#ffaf92", "#ffa38c"),
("#ffdab3", "#ffc4a6"), ("#ff927c", "#ffa58b"),
("#ffc392", "#ffe1ba")]
eye = radians(27)
for front in (False, True):
bands = [(-83, -59), (-52, -31), (-23, -2), (7, 24), (35, 47), (58, 74)]
for row in reversed(range(len(bands))):
low, high = bands[row]
points = []
for lat, steps in [(low, range(81)), (high, reversed(range(81)))]:
lat = radians(lat)
for j in steps:
lon = pi*(j/80 + int(not front))
x = cos(lat)*cos(lon)
y = sin(lat)*cos(eye) + cos(lat)*sin(lon)*sin(eye)
points.append(f"{50+45*x:.2f},{50-45*y:.2f}")
colors = palette[row % len(palette)] if front else ("#8f8498", "#a27085")
name = f"ring-{row}-{int(front)}"
strips.append(gradient(name, colors))
strips.append(f'<polygon points="{" ".join(points)}" fill="url(#{name})"/>')
return "".join(strips)
def belt():
paths = []
for i, (shape, colors) in enumerate([
("M20 19C27 3 69 2 79 18C82 25 17 25 20 19Z", ("#a9637b", "#783753")),
("M6 42C7 29 91 28 94 41L94 61C92 73 9 73 6 60Z", ("#88849a", "#c4d5d1")),
("M6 42C7 29 91 28 94 41C83 49 18 50 6 42Z", ("#64516e", "#93889c")),
("M6 60C14 52 84 54 94 61C91 72 10 73 6 60Z", ("#67516c", "#8c8194")),
("M19 79C24 72 73 72 80 78C72 99 32 101 19 79Z", ("#ff947f", "#ffcaab")),
]):
name = f"belt-{i}"
paths.extend([gradient(name, colors), f'<path d="{shape}" fill="url(#{name})"/>'])
return "".join(paths)
def symbol(index, layers):
if index == 1:
art = rings()
elif index == 6:
art = f'<g transform="translate(50 50) scale(.37)">{trefoil()}</g>'
elif index == 7:
art = belt()
else:
art = traced_faces(index, layers)
return f'<g id="mark-{index+1:02}"><title>{NAMES[index]}</title>{art}</g>'
def traced_faces(index, layers):
paths = []
for number, (left, right, loops) in enumerate(layers):
ident = f"g{index}-{number}"
paths.append(f'<linearGradient id="{ident}"><stop stop-color="{left}"/>'
f'<stop offset="1" stop-color="{right}"/></linearGradient>')
curves = "".join(outline(loop) for loop in loops)
paths.append(f'<path d="{curves}" fill="url(#{ident})" fill-rule="evenodd" '
f'stroke="url(#{ident})" stroke-width=".55" stroke-linejoin="round"/>')
return "".join(paths)
def draw(mark=None):
layers = json.loads((DIRECTORY / "contours.json").read_text())
if mark:
width = height = 100
shapes = [symbol(mark-1, layers.get(str(mark)))]
else:
width, height = 680, 460
shapes = []
for i in range(len(NAMES)):
x, y = 50 + i % 4 * 160, 32 + i // 4 * 148
shapes.append(f'<g transform="translate({x} {y})">{symbol(i, layers.get(str(i+1)))}</g>')
background = '' if mark else '<rect width="100%" height="100%" fill="#421743"/>'
return (f'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 {width} {height}" '
f'width="{width}" height="{height}">{background}' + "\n".join(shapes) + '</svg>\n')
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--mark", type=int, choices=range(1, 13))
parser.add_argument("--output", type=Path)
args = parser.parse_args()
target = args.output or DIRECTORY / (f"mark-{args.mark:02}.svg" if args.mark else "catalogue.svg")
target.write_text(draw(args.mark), encoding="utf-8")
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 112 KiB

+11
View File
@@ -0,0 +1,11 @@
{
"1": [["#fad3c5","#fbc1b3",[[[47.0,30.7],[49.8,30.4],[53.8,31.1],[80.2,37.2],[90.4,36.5],[90.9,38.0],[90.4,39.0],[83.7,38.4],[77.7,39.4],[50.7,46.0],[47.2,45.8],[31.7,41.5],[20.9,39.5],[12.1,40.0],[8.5,41.9],[7.3,41.2],[7.6,37.9],[9.6,33.9],[14.5,36.7],[16.9,36.7],[34.1,34.1]]]],["#b9a3ad","#ae94a3",[[[47.0,64.5],[50.0,64.0],[55.0,64.8],[68.3,68.9],[83.4,71.6],[71.8,72.9],[50.2,78.7],[26.7,73.3],[17.8,73.6],[14.1,75.6],[12.8,74.4],[10.0,68.3],[10.0,67.6],[10.6,67.6],[15.4,70.3],[24.4,69.8]],[[87.5,70.9],[86.9,73.1],[86.7,71.6]]]],["#f8cdbb","#fac49c",[[[43.5,6.3],[54.7,5.8],[63.3,7.6],[74.3,13.0],[79.4,17.1],[80.7,19.3],[80.7,20.6],[78.9,21.9],[73.3,22.1],[60.3,19.9],[31.2,13.0],[29.2,12.0],[30.6,10.8],[37.9,7.6]]]],["#8a8797","#786e86",[[[74.9,40.0],[86.0,39.5],[91.4,41.2],[94.0,44.4],[93.4,50.3],[90.4,53.2],[84.9,54.7],[68.1,51.7],[55.3,48.2],[52.3,46.3],[53.5,45.3],[58.8,43.7]]]],["#8c8799","#8c879b",[[[77.2,57.5],[80.2,57.0],[87.9,57.5],[92.0,60.3],[92.4,63.3],[90.9,67.6],[87.5,70.1],[84.9,73.4],[75.1,72.9],[74.8,72.6],[75.7,72.3],[81.4,72.1],[83.4,71.4],[68.3,68.9],[54.0,64.6],[52.5,63.6],[52.7,62.8],[54.0,62.1],[65.9,59.0]]]],["#f78876","#f58778",[[[12.1,40.0],[20.9,39.5],[26.9,40.5],[44.7,44.9],[46.3,46.2],[42.4,48.2],[30.7,51.7],[18.6,53.5],[9.8,53.0],[6.6,50.3],[6.1,44.4],[6.8,42.7]]]],["#9f5e74","#8f4f6a",[[[12.0,54.0],[15.1,53.5],[17.1,54.2],[14.0,54.7]],[[10.0,57.6],[12.8,57.0],[20.9,57.0],[49.7,63.5],[34.1,67.8],[22.1,69.8],[16.3,69.8],[12.5,68.9],[9.5,67.1],[8.1,65.1],[7.6,60.8],[8.1,59.3]]]],["#f5877a","#f4897a",[[[75.9,22.6],[78.4,22.4],[86.9,27.1],[89.7,31.2],[90.7,34.4],[90.2,35.9],[84.9,37.2],[80.2,37.2],[55.5,31.7],[52.3,30.1],[54.3,28.7],[74.9,24.1]],[[90.9,37.9],[92.4,39.5],[91.5,40.9],[90.7,40.7]],[[81.7,38.9],[84.9,38.4],[86.9,39.0],[83.7,39.5]]]],["#431b45","#4c173f",[[[47.0,17.9],[49.8,17.6],[53.8,18.3],[72.9,22.4],[74.4,23.4],[72.3,24.6],[52.7,29.4],[48.3,29.6],[31.7,25.2],[23.8,23.9],[22.3,22.9],[23.4,22.3],[27.9,22.1],[39.7,19.9]]]],["#b2bfc3","#a5acb0",[[[17.9,24.9],[24.4,24.4],[30.4,25.4],[45.7,28.7],[47.5,29.9],[43.4,31.7],[34.1,34.1],[14.5,36.7],[12.1,35.5],[10.5,33.7],[10.5,30.2],[14.0,26.7]]]],["#8c8697","#8d8598",[[[16.9,73.9],[19.8,73.3],[26.7,73.3],[31.7,74.1],[44.5,77.6],[46.5,78.9],[45.2,80.1],[39.9,81.7],[27.9,83.7],[22.8,83.1],[19.6,81.6],[15.9,78.2],[15.4,75.9]]]],["#91849a","#8e8596",[[[27.7,12.6],[40.0,14.6],[45.3,16.3],[46.5,17.3],[43.5,19.1],[27.9,22.1],[22.1,22.1],[19.6,21.1],[19.1,19.9],[20.6,17.1],[24.1,14.0]]]],["#f4b798","#f6c4a6",[[[63.3,86.5],[69.8,86.0],[72.1,86.9],[72.3,87.7],[70.8,89.4],[63.5,92.5],[54.3,91.0],[52.3,89.7],[55.3,87.9]]]],["#b2b9c1","#a7a2a9",[[[27.9,86.9],[30.2,86.0],[38.4,87.2],[43.4,88.0],[46.5,89.7],[44.7,91.2],[36.5,92.5],[29.1,89.5],[27.6,87.9]]]],["#f6d3d3","#fdcebb",[[[48.2,90.0],[52.7,90.4],[57.3,91.5],[59.1,92.7],[57.6,93.7],[54.7,94.2],[45.3,94.2],[42.4,93.7],[40.9,92.7],[42.7,91.5]]]]],
"3": [["#fcd5be","#fce4cf",[[[34.1,7.6],[34.9,7.8],[35.0,8.6],[33.7,14.0],[33.7,25.6],[39.2,51.5],[38.9,55.1],[34.7,69.6],[33.1,80.7],[33.6,86.2],[34.9,90.4],[34.6,91.2],[27.9,88.4],[23.3,84.7],[27.7,84.7],[30.2,83.7],[31.2,81.2],[30.6,76.4],[26.7,68.6],[14.5,49.8],[15.0,47.5],[20.8,40.5],[26.6,31.2],[30.9,21.6],[31.4,18.6],[30.7,15.8],[29.1,14.0],[26.2,13.5],[25.6,12.5],[27.9,10.5]]]],["#b4a9b4","#b493a2",[[[66.1,8.0],[67.8,7.8],[71.8,9.6],[75.9,12.5],[76.9,14.0],[73.3,14.0],[69.8,15.1],[68.9,16.6],[69.3,20.3],[70.8,24.6],[84.9,47.2],[82.6,54.7],[75.6,65.1],[69.3,78.6],[69.3,83.1],[70.3,84.4],[74.3,86.9],[66.9,91.0],[66.1,90.9],[65.8,89.9],[67.4,83.7],[67.4,76.7],[61.6,47.7],[67.4,19.8],[67.4,15.1],[65.8,9.0]]]],["#8d8098","#8d798b",[[[57.6,6.5],[62.8,6.3],[65.0,7.5],[66.9,12.1],[67.4,15.1],[67.4,19.8],[65.4,30.6],[63.3,40.0],[61.1,45.0],[57.8,32.9],[54.7,16.3],[55.3,10.0]],[[69.9,15.1],[70.9,15.4],[71.6,16.8],[71.6,18.3],[70.3,17.8],[71.6,25.2],[70.4,23.8],[68.9,18.3],[68.9,16.6]],[[61.1,51.3],[62.1,51.8],[63.1,54.3],[65.3,63.8],[67.4,76.7],[67.4,83.7],[65.3,90.9],[63.5,92.5],[60.5,93.0],[57.6,92.4],[55.8,90.7],[54.7,86.0],[54.7,80.2],[57.8,62.5]],[[71.3,74.6],[72.1,76.7],[72.1,81.4],[71.3,83.7],[70.3,84.1],[68.9,82.2],[68.9,80.6]]]],["#f7937d","#f9ad86",[[[24.8,14.3],[27.7,13.6],[29.7,14.5],[31.4,18.6],[30.9,21.6],[26.6,31.2],[23.1,37.0],[17.8,44.5],[14.5,48.2],[13.1,48.7],[6.3,43.7],[7.6,35.5],[12.8,24.4],[18.3,17.1]]]],["#99778a","#a06a81",[[[85.0,47.2],[86.7,48.2],[89.2,51.5],[94.5,54.8],[93.5,62.1],[89.4,71.9],[85.2,78.2],[80.1,83.6],[76.4,85.5],[73.6,85.4],[72.1,82.6],[72.6,71.4],[75.6,65.1],[82.6,54.7]]]],["#7b7186","#93949e",[[[13.0,50.8],[15.4,52.0],[27.6,70.1],[31.2,80.4],[30.7,83.1],[29.6,84.2],[27.7,84.7],[23.3,84.4],[19.4,82.9],[12.8,74.4],[9.6,68.3],[7.6,63.3],[6.1,55.8],[8.6,52.8]]]],["#784f6d","#6e2b56",[[[78.2,14.6],[80.1,15.3],[83.2,17.9],[88.4,25.6],[92.5,36.4],[93.2,43.9],[88.0,48.7],[86.7,48.2],[83.4,44.5],[76.7,34.9],[71.6,23.8],[72.1,14.8],[73.4,14.1]]]],["#a7b1b4","#b2bcc2",[[[36.9,6.6],[40.7,5.8],[44.2,7.0],[45.7,10.1],[46.5,15.1],[42.2,39.9],[40.2,47.2],[39.2,48.7],[38.0,46.8],[33.7,25.6],[34.2,11.0],[35.2,8.5]]]],["#f9c294","#fbca9c",[[[39.2,55.8],[39.9,55.8],[41.0,57.8],[45.3,79.1],[45.3,84.9],[44.0,89.5],[44.4,90.7],[43.4,91.9],[40.9,92.7],[37.5,92.5],[35.5,91.2],[34.1,88.0],[33.1,83.2],[35.5,65.8],[37.9,57.6]]]]],
"4": [["#beb6ba","#c0aab1",[[[44.9,26.2],[48.7,26.9],[61.0,36.7],[75.6,54.7],[79.9,62.0],[81.9,66.9],[82.6,73.3],[82.1,75.1],[80.9,76.2],[77.9,76.7],[72.9,75.9],[60.5,70.9],[55.3,65.6],[51.7,63.5],[49.8,59.5],[44.9,52.8],[30.7,42.5],[29.9,40.9],[30.2,39.5],[32.2,36.9],[39.2,29.9]]]],["#fde5c9","#fdc9b0",[[[11.0,47.0],[14.0,46.5],[17.9,47.2],[25.4,51.3],[26.7,55.8],[28.7,58.5],[35.9,66.4],[45.5,75.4],[46.2,77.9],[45.3,80.7],[43.9,82.6],[36.5,85.4],[31.6,84.7],[27.4,81.9],[23.3,77.9],[20.1,77.9],[20.1,79.9],[25.2,85.2],[33.6,91.2],[28.2,89.2],[20.6,84.1],[14.8,78.2],[12.0,74.1],[7.6,64.5],[5.8,57.0],[7.1,50.2],[8.6,48.2]],[[47.5,85.7],[47.8,86.0],[46.7,86.5]]]],["#f9beb0","#fbb3a3",[[[52.0,9.0],[54.7,8.1],[57.6,8.6],[64.0,11.6],[74.8,19.4],[81.7,26.4],[88.4,36.0],[91.4,42.4],[91.7,45.2],[90.4,48.5],[88.0,49.7],[86.4,49.7],[84.2,48.3],[74.8,35.7],[65.4,26.4],[50.5,15.8],[49.5,13.1],[50.3,10.8]]]],["#927e91","#9d7083",[[[49.8,16.1],[53.3,17.6],[65.4,26.4],[74.8,35.7],[81.2,44.4],[83.4,48.0],[83.9,50.2],[79.7,49.3],[66.9,43.5],[57.0,32.6],[51.5,22.9],[49.7,17.8]],[[71.6,49.0],[73.1,50.2],[73.3,51.5],[71.8,50.3]],[[67.8,49.8],[68.8,50.0],[68.6,50.5],[67.4,50.5]]]],["#aebdc0","#c7c4c6",[[[22.6,17.9],[26.7,17.4],[31.7,18.3],[36.9,20.1],[38.4,21.4],[37.9,22.8],[31.1,28.7],[24.1,37.7],[22.4,36.9],[20.6,34.1],[18.4,33.1],[15.6,35.7],[14.8,30.6],[15.1,22.9],[18.6,19.8]]]],["#83798d","#807789",[[[60.3,71.9],[62.0,71.8],[72.9,75.9],[80.1,76.9],[81.6,77.7],[81.9,79.6],[79.6,83.1],[76.6,84.7],[69.4,85.2],[66.6,84.6],[63.8,82.7],[60.1,73.6]],[[61.2,88.1],[60.2,89.1],[60.2,88.1]]]],["#f3ad87","#f19a89",[[[49.2,74.6],[50.8,75.9],[51.8,78.4],[52.2,81.2],[51.5,82.9],[49.7,84.6],[40.5,88.2],[39.5,89.4],[40.7,90.7],[46.3,93.4],[44.2,94.2],[36.9,93.4],[29.7,89.5],[28.6,87.7],[25.2,85.2],[19.8,79.4],[20.4,77.7],[23.3,77.9],[30.1,83.9],[33.2,85.4],[36.5,85.4],[49.8,80.1],[50.5,78.2],[48.5,75.4]]]],["#f4b591","#f9a993",[[[24.3,49.8],[27.7,51.3],[33.1,55.3],[43.4,64.8],[47.8,70.8],[50.5,78.2],[49.8,80.1],[48.3,80.9],[45.7,80.9],[47.0,74.6],[44.4,74.3],[35.9,66.4],[26.7,55.8],[26.2,53.0]]]],["#9e99a2","#a2a4b6",[[[53.2,81.4],[55.0,81.1],[62.1,84.1],[75.4,85.7],[70.8,89.4],[64.6,92.5],[57.0,94.2],[53.7,94.0],[52.3,93.2],[54.0,87.7]],[[61.2,88.1],[60.2,88.1],[60.2,89.1]]]],["#9e7f90","#a6747d",[[[59.6,8.6],[63.5,8.6],[70.9,11.6],[77.1,15.9],[84.1,22.9],[89.2,30.6],[92.4,39.0],[92.4,41.7],[90.9,40.5],[89.4,37.4],[81.7,26.4],[74.8,19.4],[66.1,13.0],[59.6,9.3]]]],["#b1b6bc","#abadb7",[[[17.3,33.6],[18.4,33.1],[20.6,34.1],[21.6,36.2],[21.3,37.2],[19.3,37.7],[17.8,36.9],[16.6,34.9]],[[15.6,38.2],[22.3,49.0],[17.9,47.2],[14.0,46.5],[9.3,47.7],[6.3,50.8],[5.8,44.2],[6.6,41.5],[8.3,39.7],[14.3,37.9]]]],["#f38b82","#e58c89",[[[92.4,44.5],[93.9,53.2],[92.2,63.1],[90.4,67.3],[89.7,66.1],[88.9,58.8],[85.7,51.8],[86.2,50.7],[90.4,48.5]]]],["#e0817e","#f28881",[[[41.2,7.5],[50.0,7.0],[52.0,7.5],[52.2,8.3],[49.5,12.3],[47.3,13.6],[31.6,10.8],[35.5,8.8]]]],["#ffd9c4","#f4d0c4",[[[52.5,83.7],[53.8,84.6],[54.0,87.7],[52.5,92.0],[51.3,93.2],[48.2,93.7],[41.5,91.0],[40.5,90.0],[41.7,88.2],[48.7,85.9]]]],["#8f5872","#975f71",[[[78.9,59.1],[83.6,59.5],[85.0,60.3],[85.9,61.8],[84.1,72.4],[83.2,74.1],[81.9,66.9]],[[88.9,60.8],[89.5,62.8],[89.5,67.4],[88.4,72.1],[86.9,73.3]]]],["#dbe2ea","#d8e6e9",[[[14.1,25.6],[15.1,32.6],[14.6,35.5],[13.0,37.4],[7.8,39.5],[7.6,37.9],[9.5,32.7],[12.8,26.7]]]]],
"5": [["#fbc1b2","#fbd4c8",[[[49.3,70.3],[52.8,70.4],[66.9,74.9],[76.7,76.7],[80.2,76.7],[86.5,75.2],[87.7,75.9],[80.6,85.2],[73.1,90.5],[63.3,94.7],[53.5,96.5],[46.5,96.5],[37.9,94.7],[31.2,92.0],[23.3,86.4],[25.7,83.1],[24.3,80.2],[25.4,78.9],[28.6,78.4],[30.2,79.2],[33.9,75.7]]]],["#aa93a1","#bdaeb4",[[[43.5,4.0],[54.7,3.5],[61.3,5.1],[59.6,10.3],[59.3,14.0],[60.0,26.6],[51.7,29.6],[46.2,29.4],[31.2,23.4],[28.4,20.4],[27.9,18.4],[29.2,15.9],[29.1,14.6],[30.2,13.3],[30.1,10.0],[30.7,8.6],[34.4,6.5]]]],["#786b83","#878394",[[[28.4,10.3],[29.7,11.0],[30.2,12.8],[27.9,18.4],[29.4,21.8],[31.2,23.4],[45.3,29.1],[46.7,30.7],[45.0,32.2],[40.0,34.2],[29.6,37.7],[20.1,39.9],[15.4,40.4],[10.1,38.7],[9.0,37.5],[8.1,34.9],[8.6,31.9],[11.5,25.4],[19.1,15.6],[25.7,10.6]]]],["#8f4c69","#9f5f77",[[[77.2,22.6],[84.6,23.6],[90.7,27.1],[92.5,30.7],[93.0,33.7],[91.7,38.2],[88.4,39.5],[81.4,39.5],[76.4,38.7],[57.6,33.1],[53.5,31.4],[52.3,30.1],[53.3,28.9],[61.1,26.2]]]],["#a2a9b0","#b1bfc1",[[[81.9,59.8],[84.9,59.3],[89.0,59.8],[90.7,60.5],[92.4,62.3],[93.0,65.1],[92.5,68.1],[89.5,73.8],[88.0,75.1],[80.2,76.7],[76.7,76.7],[58.8,72.6],[54.8,70.8],[53.7,69.4],[54.3,68.3],[64.5,64.5]]]],["#f78775","#f78778",[[[11.1,61.1],[18.6,60.5],[29.4,62.5],[44.4,67.3],[46.3,68.8],[46.5,70.4],[39.0,73.9],[30.6,75.9],[25.6,76.7],[16.8,76.2],[12.8,73.6],[10.5,72.9],[8.6,69.3],[8.5,64.3],[9.6,62.0]]]],["#c3b7bc","#d1c8ca",[[[61.3,6.6],[64.6,6.3],[75.4,10.6],[85.2,19.4],[88.2,23.4],[88.7,25.6],[84.6,23.6],[77.4,22.4],[61.0,25.1],[59.8,23.9],[59.3,22.1],[59.3,14.0],[60.3,7.6]]]],["#f7a99e","#f9b5a5",[[[12.1,73.6],[16.8,76.2],[25.6,76.7],[30.9,76.1],[31.6,77.2],[24.8,79.4],[24.3,80.2],[26.9,84.7],[24.9,85.2],[20.9,83.6],[19.8,83.9],[18.4,82.7],[12.6,75.7]]]],["#7b3a58","#792f46",[[[13.1,59.8],[16.3,59.3],[18.3,60.0],[15.1,60.5]],[[8.3,62.6],[8.5,64.3],[7.5,65.9],[7.3,64.3]]]],["#fda89a","#d0aeaf",[[[47.4,69.1],[48.4,70.0],[47.4,70.0]]]]],
"6": [["#fcca96","#f9ac87",[[[17.6,18.4],[15.3,22.3],[13.1,29.4],[14.0,33.7],[16.6,35.7],[19.8,36.0],[23.8,35.4],[39.5,29.1],[56.1,32.2],[68.9,35.7],[72.9,37.2],[73.3,38.7],[70.8,40.5],[58.6,44.7],[41.0,49.2],[29.1,51.2],[17.4,51.2],[13.5,50.5],[7.3,47.3],[5.8,45.3],[4.7,40.7],[5.3,36.7],[9.3,27.9],[13.6,21.8]]]],["#f88775","#f78777",[[[72.6,50.5],[80.2,50.0],[85.2,50.8],[89.5,52.3],[92.2,54.3],[94.2,57.0],[95.0,61.3],[93.7,66.9],[90.2,73.9],[87.7,75.6],[86.5,75.2],[86.7,69.1],[85.4,66.9],[83.2,65.6],[80.2,65.1],[77.2,65.6],[68.9,68.9],[64.0,72.1],[60.1,72.4],[27.4,64.5],[25.4,62.8],[27.4,61.1],[46.0,55.3],[60.3,52.2]]]],["#fbbeb0","#fdb8a8",[[[20.3,63.3],[24.9,63.5],[40.2,67.9],[58.3,71.9],[60.5,72.9],[60.8,73.9],[47.0,87.7],[45.8,88.5],[44.0,88.5],[24.1,77.1],[17.1,74.8],[12.5,75.7],[11.0,75.1],[8.1,70.9],[6.6,66.9],[7.1,65.8],[16.8,64.5]]]],["#fddac3","#fdddcf",[[[54.0,12.5],[56.8,13.0],[70.9,22.1],[79.7,26.1],[83.6,26.6],[88.0,25.4],[90.4,28.2],[93.2,36.2],[88.4,36.0],[74.8,38.9],[72.4,36.9],[68.9,35.7],[38.5,28.4],[38.9,27.2],[42.2,24.8]]]],["#9b7488","#a16c81",[[[63.1,73.1],[65.4,72.9],[72.1,74.4],[80.2,74.4],[85.9,72.9],[86.5,75.2],[88.4,75.6],[88.5,76.4],[85.2,81.7],[80.6,86.4],[74.4,90.7],[63.1,95.7],[58.1,96.5],[55.0,96.2],[47.2,91.2],[46.5,90.2],[46.7,88.5],[55.5,78.7]]]],["#81788d","#8f8e9d",[[[38.9,5.1],[45.0,5.0],[54.0,10.8],[50.3,16.6],[43.4,23.6],[37.5,27.9],[36.2,28.2],[24.4,26.7],[17.1,27.6],[15.0,26.9],[14.3,24.8],[15.3,22.3],[20.3,14.5],[29.4,8.5]]]],["#f28975","#f5867b",[[[14.6,75.1],[19.1,75.1],[24.1,77.1],[40.5,86.2],[44.4,89.4],[46.3,95.8],[37.9,94.7],[29.4,91.5],[23.3,88.4],[15.9,82.9],[11.5,76.7]]]],["#f8a386","#f59480",[[[52.7,5.1],[62.0,6.6],[72.1,10.5],[80.6,15.9],[86.4,21.8],[87.2,22.9],[87.2,24.8],[86.2,25.7],[82.7,26.6],[79.7,26.1],[70.9,22.1],[56.1,12.5]]]],["#4c1740","#4e1745",[[[77.2,65.6],[80.2,65.1],[84.1,65.9],[86.4,68.3],[86.5,71.4],[84.9,73.3],[80.2,74.4],[72.1,74.4],[67.1,73.6],[65.3,72.6],[65.6,71.4],[69.9,68.8]],[[91.0,73.4],[91.5,75.2],[89.9,77.2],[89.5,75.6]]]],["#47193c","#461844",[[[10.6,23.3],[10.8,24.8],[9.0,27.7],[8.5,25.9],[9.6,23.6]],[[19.1,27.2],[24.4,26.7],[33.6,28.1],[34.9,28.9],[27.9,33.7],[23.8,35.4],[19.8,36.0],[16.6,35.7],[14.0,33.7],[13.3,32.1],[13.5,29.7],[14.8,28.6]]]],["#bab9b5","#c0bbc6",[[[92.4,36.7],[93.9,37.5],[94.7,39.5],[94.2,40.7],[92.7,41.5],[83.2,40.0],[81.2,38.4],[83.4,36.9],[88.4,36.0]]]],["#8f7c95","#94828c",[[[6.1,60.3],[15.6,61.1],[18.6,63.0],[16.8,64.5],[12.8,65.1],[7.3,64.8],[5.3,63.3],[5.3,61.1]]]],["#9d4a5a","#a0505d",[[[66.6,50.5],[68.6,50.0],[70.6,50.7],[68.6,51.2]]]]],
"9": [["#fbb3a5","#fcc8ba",[[[7.6,43.2],[8.6,42.9],[20.9,45.3],[31.4,46.5],[56.6,46.8],[58.3,47.5],[60.6,49.8],[61.6,53.5],[61.1,57.6],[59.8,59.8],[57.8,61.3],[52.3,62.8],[20.9,62.8],[13.5,61.3],[12.5,61.6],[13.0,62.6],[17.3,65.4],[11.6,69.8],[7.6,61.0],[7.0,57.0],[7.0,45.3]]]],["#9fa5ad","#adbabe",[[[60.8,34.7],[62.5,34.2],[64.3,34.9],[71.3,40.4],[88.4,47.7],[91.0,49.7],[93.0,52.3],[93.2,56.0],[89.4,59.1],[80.4,61.8],[74.4,62.8],[59.3,63.0],[58.6,62.3],[61.1,57.6],[61.6,54.7],[60.5,48.7],[61.5,47.5],[65.3,46.7],[67.6,45.3],[58.8,41.2],[58.6,37.7]]]],["#878294","#969aa6",[[[22.1,15.0],[21.3,16.6],[19.6,17.6]],[[28.2,19.3],[42.5,23.8],[65.3,27.7],[64.0,34.2],[61.3,34.4],[59.8,35.4],[58.6,37.7],[58.8,41.2],[61.6,42.7],[61.5,43.2],[58.5,43.9],[54.7,42.5],[48.7,42.0],[35.5,38.9],[31.7,37.2],[30.7,35.7],[31.2,30.4],[30.1,28.1],[27.7,25.7],[26.4,22.4],[26.7,20.3]],[[65.4,44.7],[67.8,45.3],[66.1,45.5]]]],["#80768c","#90919e",[[[19.9,65.9],[35.5,70.3],[48.2,72.8],[49.2,73.8],[50.2,80.2],[49.8,83.1],[48.7,83.7],[51.8,85.4],[58.6,86.4],[59.1,87.4],[55.8,88.4],[51.5,88.0],[47.0,85.9],[46.0,82.9],[41.9,84.9],[34.4,84.6],[34.6,83.1],[33.9,82.4],[27.4,80.7],[17.8,76.4],[13.6,73.6],[11.5,70.8],[16.3,67.4]],[[24.2,84.2],[25.1,85.1],[24.2,85.1]]]],["#fad5c5","#fcdfd2",[[[65.8,28.6],[81.6,30.1],[87.0,29.4],[90.2,30.7],[93.5,39.0],[94.2,43.0],[93.7,52.0],[86.9,46.8],[71.3,40.4],[67.1,37.5],[65.1,34.9],[64.3,32.2],[64.6,29.7]]]],["#ffdcca","#fce4c8",[[[35.4,7.5],[47.7,7.0],[56.3,8.8],[60.3,10.6],[61.8,12.6],[61.8,15.6],[60.8,16.6],[58.1,17.4],[34.9,17.4],[24.4,15.4],[24.3,14.6],[25.7,13.0]]]],["#fbd7c8","#ffe8d4",[[[58.6,75.2],[60.6,74.8],[66.3,75.6],[82.9,75.1],[84.1,75.6],[84.4,76.6],[82.9,79.4],[75.4,85.9],[71.8,88.0],[67.6,89.0],[56.6,81.7],[56.3,78.4],[57.0,76.7]]]],["#7b7086","#807d8f",[[[16.3,20.8],[16.6,22.6],[22.9,20.6],[25.7,21.1],[27.7,25.7],[30.1,28.1],[31.2,30.4],[31.1,33.9],[30.2,36.0],[27.6,36.4],[22.4,34.6],[18.6,32.6],[14.8,29.4],[13.8,28.1],[13.5,25.1],[15.0,21.9]]]],["#999ca8","#a3a4b2",[[[50.5,74.4],[52.7,74.1],[55.8,75.2],[55.5,78.6],[56.6,81.7],[64.3,86.9],[65.4,89.4],[65.0,90.5],[61.8,92.0],[55.8,93.0],[44.5,92.5],[51.5,88.7],[57.8,88.0],[59.3,87.0],[58.0,86.2],[51.0,85.0],[49.8,83.2],[48.7,82.7],[50.2,80.4],[49.3,77.1]]]],["#ed8986","#ef8980",[[[8.3,41.4],[10.5,40.7],[22.1,40.7],[51.5,45.0],[53.2,46.0],[51.2,46.5],[31.4,46.5],[11.0,43.7],[8.6,42.5]],[[6.3,45.7],[7.0,47.7],[6.5,53.2],[5.8,51.2]]]],["#f4af9e","#f6d7bc",[[[26.7,84.6],[29.1,83.7],[45.7,85.7],[48.2,86.7],[49.3,88.4],[48.5,90.4],[46.2,91.5],[39.5,91.9],[35.5,91.2],[31.4,89.5],[27.2,86.7],[26.4,85.5]]]],["#978691","#857c93",[[[58.5,6.3],[60.1,6.1],[66.6,7.8],[69.8,9.3],[73.6,12.5],[74.1,14.0],[73.6,15.4],[72.4,16.6],[68.9,17.8],[64.0,18.6],[59.6,18.1],[62.1,15.6],[62.3,13.3],[61.0,11.1],[57.5,9.1]]]],["#eb9089","#b191a2",[[[14.1,62.3],[15.9,62.0],[20.9,62.8],[52.3,62.8],[56.1,62.3],[57.1,62.8],[54.7,64.0],[27.9,64.0],[18.8,65.4],[15.1,64.0]],[[15.4,66.9],[16.1,66.9],[15.6,67.9],[13.6,68.6]]]],["#eda09c","#f3b9a0",[[[63.3,71.4],[66.3,70.9],[75.6,72.1],[80.6,72.9],[82.6,74.3],[79.1,75.6],[66.3,75.6],[60.5,74.4],[61.0,72.6]]]],["#edb7b2","#c5a5a9",[[[22.4,16.1],[34.9,17.4],[54.7,17.4],[56.6,18.1],[54.7,18.6],[31.4,18.6],[26.7,19.1],[20.1,21.3],[17.4,21.3],[18.3,19.8],[20.8,19.1],[20.9,17.1]]]],["#f08f8a","#e48a8e",[[[68.1,26.2],[70.9,25.6],[76.7,25.6],[86.5,27.4],[89.7,29.2],[81.6,30.1],[72.1,29.1],[67.8,27.9],[67.4,26.9]]]]],
"10": [["#fbc2b4","#fccec0",[[[43.2,5.3],[45.3,4.7],[56.6,5.1],[52.2,9.1],[51.2,12.8],[51.2,16.3],[53.0,24.9],[55.3,33.1],[61.5,49.0],[61.0,52.8],[54.2,71.6],[52.3,80.2],[52.3,87.2],[53.3,90.9],[57.8,93.5],[55.8,94.2],[45.3,94.2],[43.2,93.4],[46.8,89.9],[48.3,85.5],[46.0,71.4],[38.7,50.8],[39.2,46.2],[45.8,27.2],[47.7,17.4],[47.2,11.0]]]],["#f79880","#fbc59a",[[[88.2,26.6],[89.5,27.9],[93.5,39.0],[95.2,49.0],[93.4,60.8],[89.5,70.9],[86.0,76.7],[81.7,81.7],[78.1,83.2],[76.2,81.9],[75.6,79.1],[76.4,69.4],[78.6,61.1],[87.7,35.4]]]],["#9fa8ad","#aebcc1",[[[58.3,5.5],[64.0,7.0],[67.8,10.1],[70.3,14.6],[70.9,18.6],[69.1,30.7],[62.3,48.5],[59.6,43.9],[55.3,33.1],[51.2,16.3],[51.2,12.8],[52.2,9.1],[54.5,6.8]]]],["#786f85","#8b8795",[[[37.5,51.3],[38.7,52.0],[46.0,71.4],[48.3,83.1],[48.2,86.5],[46.8,89.9],[43.9,92.7],[41.5,93.5],[39.0,93.5],[32.9,90.4],[30.6,86.9],[29.1,81.4],[29.1,77.9],[30.9,68.1]]]],["#f68876","#f78776",[[[62.0,51.3],[63.1,52.0],[70.3,71.6],[70.9,82.6],[69.8,87.2],[67.8,89.9],[65.1,91.9],[61.8,93.2],[57.8,93.4],[54.5,92.0],[53.3,90.9],[52.3,87.2],[52.3,80.2],[54.2,71.6],[57.6,61.1]]]],["#f88776","#f78776",[[[40.9,5.5],[42.9,6.0],[46.5,9.3],[47.7,14.0],[47.7,17.4],[45.8,27.2],[43.5,34.2],[39.7,43.2],[37.9,44.4],[36.4,42.7],[31.9,32.1],[28.7,23.6],[28.1,18.8],[30.2,11.6],[32.2,9.0],[34.9,7.0]]]],["#fed3ad","#f9a787",[[[16.5,21.4],[16.5,22.3],[15.6,22.3]],[[14.6,24.1],[16.6,27.6],[17.9,34.6],[19.1,30.6],[19.4,30.9],[20.6,39.2],[13.3,61.0],[11.3,70.3],[10.6,70.9],[9.3,69.8],[5.6,59.5],[4.7,53.5],[4.7,44.2],[6.5,35.5],[8.1,31.4],[12.1,24.9]],[[21.4,28.2],[22.1,30.2],[21.6,34.6],[20.9,32.6]]]],["#995673","#88425d",[[[76.4,15.9],[78.6,15.6],[82.9,18.3],[88.5,25.6],[87.7,35.4],[84.1,45.7],[83.1,46.7],[81.2,45.5],[76.4,30.6],[74.6,20.8],[74.9,17.9]]]],["#88445e","#722652",[[[16.9,52.5],[18.1,52.8],[19.3,55.1],[23.3,72.1],[23.3,80.6],[20.8,82.1],[18.4,81.6],[13.5,77.2],[11.6,73.8],[11.3,71.4],[12.5,63.6],[16.1,53.3]]]],["#f6a181","#f08e7d",[[[20.4,15.8],[23.1,16.4],[24.3,20.8],[22.9,29.6],[22.6,29.9],[21.4,28.2],[20.4,34.6],[19.1,30.6],[17.9,34.6],[15.9,25.9],[16.3,21.8],[14.1,22.4],[14.0,21.8],[15.9,19.8],[17.9,19.6],[18.6,17.1]]]],["#e88281","#e99e91",[[[30.2,27.6],[30.9,29.9],[30.1,29.2]],[[33.1,36.4],[34.1,36.9],[36.4,42.7],[38.4,45.3],[38.9,47.3],[38.0,48.7],[35.2,43.9],[33.2,38.9]]]]],
"11": [["#fcc19c","#f9937e",[[[79.6,26.1],[85.7,25.9],[87.9,27.2],[89.2,29.4],[92.4,36.7],[93.2,40.5],[94.2,46.5],[93.7,53.2],[87.7,49.5],[80.2,48.8],[71.6,50.7],[61.0,55.1],[53.8,57.3],[48.8,58.1],[36.0,58.1],[25.2,56.1],[17.3,53.7],[9.3,50.0],[7.3,48.5],[6.1,46.2],[6.3,44.7],[8.0,43.5],[15.8,47.0],[19.8,47.7],[31.4,47.7],[40.0,45.8],[58.1,38.4],[68.6,31.4]]]],["#baa4ae","#ac91a2",[[[16.1,76.6],[21.6,79.6],[31.4,81.4],[46.0,79.7],[65.1,81.4],[75.9,79.4],[81.7,77.4],[82.7,77.7],[82.9,78.6],[81.7,80.6],[73.3,87.2],[67.1,90.4],[62.0,92.2],[48.8,94.2],[38.0,92.2],[29.4,89.2],[19.4,81.7],[16.3,77.9]]]],["#7f3557","#6f204c",[[[77.2,49.3],[83.7,48.8],[87.7,49.5],[91.5,51.5],[93.0,53.5],[93.5,55.5],[87.2,61.6],[78.4,65.6],[74.4,66.3],[66.3,66.3],[56.5,64.5],[45.7,60.1],[44.4,59.0],[57.5,56.3],[71.6,50.7]]]],["#9d5a73","#8e4766",[[[17.9,35.4],[29.1,34.9],[55.5,39.0],[43.5,44.7],[31.4,47.7],[19.8,47.7],[15.8,47.0],[8.6,43.7],[6.6,41.7],[6.8,40.5],[9.1,38.2],[12.3,36.7]]]],["#fcdcc1","#fedbc7",[[[41.2,6.3],[55.8,5.8],[60.8,6.6],[65.9,8.5],[72.1,11.6],[73.4,13.0],[66.9,13.5],[53.0,19.3],[50.3,19.4],[44.7,18.1],[27.9,11.8],[34.1,8.5]]]],["#8c8799","#8d8598",[[[14.6,72.8],[17.4,72.1],[24.4,72.1],[29.4,72.9],[36.5,75.1],[44.0,78.1],[45.3,79.2],[44.0,80.1],[34.9,81.4],[25.4,80.4],[19.9,78.9],[14.0,75.2],[13.8,73.6]]]],["#793259","#6c2350",[[[71.4,72.6],[74.4,72.1],[82.7,72.4],[85.0,73.4],[85.5,75.1],[84.7,76.6],[83.2,77.2],[75.9,79.4],[65.1,81.4],[53.7,80.1],[52.2,79.1],[54.3,77.6]]]],["#f4a58f","#f09086",[[[73.1,12.5],[76.4,14.3],[77.4,16.4],[76.6,18.4],[72.6,20.3],[68.6,20.9],[57.0,20.9],[54.5,19.8],[56.1,17.8],[63.5,14.6]]]],["#7a6a84","#8c8294",[[[26.6,12.6],[33.1,13.5],[43.9,17.8],[46.5,19.9],[44.2,20.9],[31.4,20.9],[27.4,20.3],[23.4,18.4],[22.4,16.3],[23.1,14.1]]]]],
"12": [["#f78776","#f58878",[[[60.8,17.9],[64.0,17.4],[76.9,19.6],[83.7,22.1],[88.4,27.9],[89.2,30.6],[88.5,33.9],[84.9,37.2],[78.7,39.2],[51.2,36.0],[46.8,34.9],[46.8,34.2],[48.5,33.4],[77.2,27.2],[79.2,25.6],[78.2,24.1],[62.3,19.1]],[[40.0,35.4],[42.7,35.2],[63.6,43.7],[57.3,45.7],[47.3,47.3],[19.3,54.2],[15.9,55.5],[13.8,57.3],[10.1,55.0],[7.0,51.2],[6.8,47.5],[13.0,43.2],[25.1,39.0]]]],["#471646","#441845",[[[61.0,44.7],[64.0,44.2],[68.1,44.7],[81.7,49.7],[82.7,51.2],[80.6,52.7],[72.4,55.0],[33.7,64.0],[30.4,63.3],[29.9,61.0],[26.1,60.0],[21.8,60.8],[16.3,58.1],[15.1,56.8],[15.9,55.5],[22.9,53.2]],[[20.1,65.6],[22.8,65.6],[24.3,66.8],[21.8,66.6]]]],["#aaa7b0","#adbbc0",[[[78.2,40.2],[86.5,41.4],[90.4,43.0],[93.5,46.2],[87.0,51.2],[87.2,52.3],[91.4,56.3],[92.2,58.3],[91.5,60.1],[86.9,63.6],[78.4,66.8],[70.1,68.9],[57.3,70.6],[43.0,63.1],[43.0,62.5],[44.4,61.8],[51.7,61.3],[55.3,58.8],[81.4,52.3],[82.7,51.2],[81.7,49.7],[66.6,43.7],[68.3,42.7]]]],["#786d84","#8d8b9b",[[[46.8,61.0],[50.0,60.5],[52.0,61.1],[48.8,61.6]],[[39.9,62.3],[53.7,68.4],[55.5,70.1],[55.6,71.4],[31.1,76.4],[21.4,79.2],[21.1,80.4],[26.2,82.7],[26.4,83.2],[25.4,83.6],[20.1,82.2],[16.6,79.9],[15.1,77.9],[14.5,74.6],[15.9,71.8],[23.9,67.3],[24.8,65.6],[32.4,66.1],[33.4,65.8],[32.9,64.5]]]],["#a2667a","#8c4764",[[[12.1,26.7],[13.1,26.1],[20.6,26.1],[22.9,26.7],[23.1,28.1],[19.3,29.7],[18.6,30.9],[22.1,33.7],[27.6,36.4],[28.7,37.9],[22.3,39.9],[20.3,38.7],[13.6,37.5],[10.3,36.2],[9.1,35.0],[8.8,32.9],[10.8,28.2]]]],["#995b76","#914a60",[[[43.4,81.9],[45.2,81.6],[49.7,84.1],[58.6,86.7],[60.1,87.9],[45.3,90.7],[38.0,91.5],[35.9,90.9],[35.4,89.7],[36.0,88.4],[43.9,84.6],[44.4,83.7]],[[56.0,82.1],[59.3,81.4],[64.3,82.2],[65.9,83.2],[64.3,84.1],[60.1,84.1],[56.5,83.1]],[[61.8,91.5],[62.8,92.0],[61.5,92.9],[57.3,92.5]]]],["#965572","#8e4e6c",[[[33.6,10.1],[33.9,10.5],[33.1,11.0],[29.2,12.6],[29.4,14.8],[33.6,16.4],[39.4,16.9],[40.5,19.9],[34.7,24.3],[20.9,24.4],[18.9,23.9],[20.6,22.8],[20.1,20.9],[26.2,18.4],[26.2,17.6],[24.1,15.8],[25.1,13.5],[29.6,11.0]]]],["#ffcba9","#f1ad95",[[[6.3,51.5],[7.5,51.8],[10.1,55.0],[14.3,57.8],[32.7,65.0],[33.4,65.8],[31.4,66.3],[22.1,65.1],[12.1,63.5],[9.6,62.5],[6.5,58.6],[5.8,54.7]]]],["#ffb3a2","#fcc9be",[[[45.5,35.5],[64.0,37.2],[75.1,38.9],[76.6,39.9],[70.3,42.4],[64.0,43.0],[61.0,42.5],[46.7,37.0]]]],["#f4b2aa","#ee9290",[[[49.2,83.1],[52.3,82.6],[65.4,84.6],[69.4,86.4],[69.8,88.7],[67.4,90.7],[64.3,91.4],[64.0,89.7],[62.8,88.4],[50.5,84.4],[49.2,83.7]]]],["#d8ecea","#d9d6e7",[[[92.2,47.5],[93.2,47.8],[94.0,50.2],[93.4,55.0],[92.2,56.8],[87.7,53.0],[87.0,51.7],[87.5,50.3]]]],["#7b6585","#806489",[[[49.3,6.3],[51.2,6.8],[48.0,8.5],[38.2,10.3],[35.9,9.3],[37.4,8.3]],[[29.1,12.6],[31.2,15.6],[29.4,14.8]]]]]
}
+28
View File
@@ -0,0 +1,28 @@
# 色带生成器
此目录可以独立使用。Python 依赖为 NumPy 和 Pillow。运行以下命令生成一枚五圈的窄带螺旋:
```sh
python3 generate.py --layout spiral --faces 5 --width .35 --continuity .94 --twist 38 --tilt -20 --palette '#ff967e' '#f9d2b0' '#b5c5c5' --background '#461646' --size 512 --output spiral.png
```
| 参数 | 含义 |
| --- | --- |
| `--layout` | `rings` 为球面纬带,`spiral` 为绕球的一条螺旋,`petals` 为绕中心分布的瓣 |
| `--faces` | 1 至 16,分别表示纬带数、螺旋圈数或瓣数;投影后可见的色块还受遮挡影响 |
| `--continuity` | 0 至 1,沿带长保留的范围。0 为纯背景,1 取消沿长度方向的裁切 |
| `--width` | 大于 0 且不超过 1,控制纬带及螺旋的相对宽度,或花瓣从外缘向内延伸的深度 |
| `--twist` | 扭转角度,正负改变形变方向 |
| `--tilt` | 整枚图形在画面内的旋转角度 |
| `--palette` | 一个或多个十六进制基色。环与瓣依序循环使用,螺旋沿带长平滑换色 |
| `--background` | 背景色,也参与背面色的计算 |
`--size` 控制单枚图像的像素尺寸,`--output` 指定 PNG 输出路径。相同参数可重复得到相同图形。
```sh
python3 generate.py --study --size 124 --output study.png
```
参数对照图前三行分别只改面数(2、3、4、6)、连续性(0.28、0.52、0.76、1)、扭转角(−55°、−15°、25°、65°)。第四行依次展示纬带、螺旋、四瓣及三瓣组合。
每个像素沿视线与单位球壳相交两次。生成器在两个交点分别计算色带的覆盖情况,再根据基色、面内渐变和背景色绘制正面、背面与重叠部分。图形完全由参数生成。
+183
View File
@@ -0,0 +1,183 @@
"""Generate ribbon fields with NumPy and Pillow. Run --help for the design controls."""
import argparse
from dataclasses import dataclass, replace
from pathlib import Path
import numpy as np
from PIL import Image, ImageColor
HERE = Path(__file__).resolve().parent
@dataclass(frozen=True)
class Design:
layout: str = "spiral"
faces: int = 4
continuity: float = .88
width: float = .46
twist: float = 24
tilt: float = -14
palette: tuple = ("#ff967e", "#f9d2b0", "#b5c5c5")
background: str = "#461646"
def rgb(code):
if len(code) != 7 or not code.startswith("#"):
raise ValueError("colours must use #RRGGBB")
return np.array(ImageColor.getrgb(code), dtype=float)
def check(d):
if d.layout not in ("rings", "spiral", "petals"):
raise ValueError("layout must be rings, spiral or petals")
if not 1 <= d.faces <= 16:
raise ValueError("faces must be 1..16")
if not 0 <= d.continuity <= 1 or not 0 < d.width <= 1:
raise ValueError("continuity must be 0..1 and width must be greater than 0 and at most 1")
if not np.isfinite([d.twist, d.tilt]).all():
raise ValueError("angles must be finite")
if not d.palette:
raise ValueError("supply at least one base colour")
def mix(a, b, weight):
return a + (b-a)*weight
def coverage(along, continuity):
"""Angular half-length of a round-ended arc; 1 closes the whole loop."""
if continuity == 1:
return np.ones_like(along)
distance = np.abs((along + np.pi) % (2*np.pi) - np.pi) / np.pi
shoulder = min(.12, continuity)
inside = np.clip((continuity-distance)/max(shoulder, 1e-8), 0, 1)
return np.sqrt(inside*(2-inside))
def face(d, x, y, z, palette):
angle = np.deg2rad(d.twist)
if d.layout == "petals":
# Radial sectors on the shell. Opposite depths shear the two sides
# of each petal in opposite directions and create the crossing.
frequency = d.faces/(2*np.pi)
turn = np.arctan2(x, y)
radius = np.hypot(x,y)
best = np.full_like(x,-np.inf)
index = np.zeros_like(x,dtype=int)
along = np.zeros_like(x)
for sector in range(d.faces):
orientation = sector/frequency
delta = (turn-orientation+np.pi)%(2*np.pi)-np.pi
# Scale each cap with angular spacing so higher face counts
# still leave a legible opening between neighbouring lobes.
half_span = min(np.pi/2, np.pi/d.faces)
depth = (1-np.cos(half_span))*d.width
local = np.clip(delta/max(d.continuity,1e-8), -np.pi, np.pi)
folded = radius*(np.cos(local)+np.sin(angle)*1.45*z*np.sin(local))
score = folded-1+depth
active = score > best
index = np.where(active,sector,index)
along = np.where(active,np.sin(delta),along)
best = np.maximum(best,score)
visible = (best > 0) & (d.continuity > 0)
else:
# Rotate latitude circles by a longitude-dependent angle. This
# deformation stays on the unit sphere for either sign of depth.
bend = angle*x
v = y*np.cos(bend) + z*np.sin(bend)
w = z*np.cos(bend) - y*np.sin(bend)
longitude = np.arctan2(w, x)
latitude = np.arcsin(np.clip(v,-1,1))/np.pi+.5
phase = latitude*d.faces-.5
if d.layout == "spiral":
phase -= longitude/(2*np.pi)
index = np.floor(phase+.5).astype(int)
along = np.sin(longitude)
# Spiral sectors use a periodic cut at the same meridian every turn.
# Separate rings can stagger their cuts without a seam.
offset = 0 if d.layout == "spiral" else index*2.39996
taper = coverage(longitude+offset, d.continuity)
visible = (np.abs(phase-index) < .5*d.width*taper) & (taper > 0)
if d.layout == "spiral":
# Vary pigment continuously with latitude, including across the seam
# where the spiral's integer winding number changes.
pigment = latitude*d.faces
band = np.floor(pigment).astype(int)
f = pigment-band
f = f*f*(3-2*f)
color = mix(palette[band%len(palette)], palette[(band+1)%len(palette)], f[...,None])
else:
color = palette[index%len(palette)]
glow = np.clip(.09-.13*x+.12*y+.09*along, 0, .42)
return visible, mix(color, 255., glow[...,None])
def render(d, size=256):
check(d)
if not 16 <= size <= 2048:
raise ValueError("size must be 16..2048")
palette = np.array([rgb(c) for c in d.palette])
bg = rgb(d.background)
axis = (np.arange(size*3)+.5) * 2.16/(size*3)-1.08
output = np.empty((size,size,3), dtype=np.uint8)
roll = np.deg2rad(d.tilt)
for start in range(0,size,16):
stop = min(start+16,size)
xx, yy = np.meshgrid(axis,-axis[start*3:stop*3])
x = xx*np.cos(roll) - yy*np.sin(roll)
y = xx*np.sin(roll) + yy*np.cos(roll)
radius2 = x*x+y*y
z = np.sqrt(np.maximum(0,1-radius2))
front, ink = face(d,x,y,z,palette)
back, reverse = face(d,x,y,-z,palette)
# Back faces receive less light. The same base pigments determine
# the rear and overlap colours even when the palette is changed.
rear = mix(bg,reverse,.44)
both = mix(ink,reverse,.24)
both = mix(both,255.,(.06+.18*z)[...,None])
paint = np.where(front[...,None],np.where(back[...,None],both,ink),rear)
paint = np.where(((front|back)&(radius2<=1))[...,None],paint,bg)
block = paint.reshape(stop-start,3,size,3,3).mean(axis=(1,3))
output[start:stop] = np.rint(block).astype(np.uint8)
return Image.fromarray(output)
def study(d, size):
# The first three rows isolate one control; the last shows layout examples.
rows = [("faces",(2,3,4,6)), ("continuity",(.28,.52,.76,1)),
("twist",(-55,-15,25,65)), ("layout",("rings","spiral","petals","petals"))]
gap = max(6, size//6)
cell = size+gap
canvas = Image.new("RGB",(4*cell+gap,4*cell+gap),d.background)
for row,(key,values) in enumerate(rows):
for col,value in enumerate(values):
variant = replace(d,**{key:value})
if row==3 and col==3:
variant = replace(variant,faces=3, width=.65, twist=38, tilt=0, continuity=1)
canvas.paste(render(variant,size),(gap+col*cell,gap+row*cell))
return canvas
if __name__ == "__main__":
defaults = Design()
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--layout", choices=("rings","spiral","petals"), default=defaults.layout)
parser.add_argument("--faces",type=int,default=defaults.faces,help="rings, spiral turns or petals (1..16)")
parser.add_argument("--continuity",type=float,default=defaults.continuity,help="arc coverage (0..1)")
parser.add_argument("--width",type=float,default=defaults.width,help="fraction of spacing filled (0..1]")
parser.add_argument("--twist",type=float,default=defaults.twist,help="spherical deformation in degrees")
parser.add_argument("--tilt",type=float,default=defaults.tilt,help="image-plane rotation in degrees")
parser.add_argument("--palette",nargs="+",default=defaults.palette,help="one or more #RRGGBB colours")
parser.add_argument("--background",default=defaults.background,help="#RRGGBB")
parser.add_argument("--size",type=int,default=256)
parser.add_argument("--output",required=True,type=Path)
parser.add_argument("--study",action="store_true",help="render a 4 by 4 parameter comparison")
args = parser.parse_args()
design = Design(**{key:getattr(args,key) for key in Design.__dataclass_fields__})
try:
if not 16 <= args.size <= 2048:
raise ValueError("size must be 16..2048")
img = study(design,args.size) if args.study else render(design,args.size)
except ValueError as error:
parser.error(str(error))
img.save(args.output)
Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

+82
View File
@@ -0,0 +1,82 @@
"""Render a ribbon study as editable SVG, using only the standard library."""
from math import cos, sin, pi
from pathlib import Path
BACKGROUND = "#431744"
# Coordinates are relative to the centre of the reference mark.
CAP = "M-91 -78 C-67 -111 -34 -121 0 -121 C33 -121 70 -107 90 -80 C105 -59 82 -52 63 -53 C37 -52 14 -63 0 -74 C-23 -58 -47 -52 -69 -53 C-91 -53 -100 -63 -91 -78Z"
LEFT = "M-91 -78 C-58 -107 -28 -99 0 -74 C-23 -58 -47 -52 -69 -53 C-91 -53 -100 -63 -91 -78Z"
RIGHT = "M0 -74 C37 -104 65 -98 90 -80 C105 -59 82 -52 63 -53 C37 -52 14 -63 0 -74Z"
def gradient(name, colors):
stops = ''.join(f'<stop offset="{i/(len(colors)-1):.2f}" stop-color="{color}"/>'
for i, color in enumerate(colors))
return f'<linearGradient id="{name}" x2="100%" y2="24%">{stops}</linearGradient>'
def trefoil():
layers = []
palettes = [
("#d6c9c6", "#917687", "#a35c78", "#874969", "#99909d", "#766d82"),
("#ffe0bf", "#ffc0a2", "#8e8e9b", "#726d84", "#ffb295", "#ff8c76"),
("#ffb390", "#ff917c", "#ff9983", "#ff846f", "#b57184", "#8c506f"),
]
for index, colors in enumerate(palettes):
parts = []
for face, outline in enumerate((CAP, LEFT, RIGHT)):
name = f"petal-{index}-{face}"
parts.append(gradient(name, colors[2*face:2*face+2]))
parts.append(f'<path fill="url(#{name})" d="{outline}"/>')
layers.append(f'<g transform="rotate({120*index})">{"".join(parts)}</g>')
return ''.join(layers)
def coil(turns, width, pitch, tilt, prefix):
"""Project a spherical helix. Draw its far half-turns before its near ones."""
palettes = [
[("#7b566f", "#aa7889"), ("#a4b4bb", "#79748c"), ("#834764", "#b77987")],
[("#ffa58a", "#ff8876"), ("#ffdebb", "#f2b9a8"), ("#c2d6d0", "#a39daa")],
]
layers = [[], []]
for half in range(2 * turns):
near = half % 2
start = half*pi
name = f"{prefix}-{half}"
def point(t, side):
u = t / (2*pi*turns)
lat = -pi/2 + pi*u + side*width*pi/(2*turns)*sin(pi*u)**.55
lat += pitch*sin(t)*cos(lat) + .12*sin(2*t)*cos(lat)
return f"{100*cos(lat)*cos(t):.2f},{-100*sin(lat):.2f}"
# Follow the actual circular limb between both edges at each turn.
points = [point(start + pi*j/80, -1) for j in range(81)]
points += [point(start + pi, -1+j/8) for j in range(1,17)]
points += [point(start + pi*j/80, 1) for j in reversed(range(80))]
points += [point(start, 1-j/8) for j in range(1,17)]
layers[near].append(gradient(name, palettes[near][(half//2)%3]))
opacity = .90 if near else .84
layers[near].append(f'<polygon opacity="{opacity}" points="{" ".join(points)}" fill="url(#{name})"/>')
return f'<g transform="rotate({tilt})">{"".join(layers[0]+layers[1])}</g>'
def place(shape, x, y, scale):
return f'<g transform="translate({x} {y}) scale({scale})">{shape}</g>'
def draw():
marks = [place(trefoil(), 214, 238, 1.20)]
for index, (x, y, turns, width, pitch, tilt) in enumerate([
(502, 88, 2, .77, .45, -14), (673, 88, 3, .91, .40, 46),
(502, 239, 4, .85, .21, 4), (673, 239, 4, .46, .10, -10),
(502, 391, 3, .65, .39, -12), (673, 391, 3, .82, .21, 82),
]):
marks.append(place(coil(turns, width, pitch, tilt, f"s{index}"), x, y, .48))
return ('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 480" width="800" height="480">'
f'<title>Bedrock ribbon studies</title><rect width="800" height="480" fill="{BACKGROUND}"/>'
+ ''.join(marks) + '</svg>\n')
if __name__ == "__main__":
Path(__file__).with_name("preview.svg").write_text(draw(), encoding="utf-8")
+116
View File
@@ -0,0 +1,116 @@
"""Fit a gradient mesh to the 750 x 1500 reference sheet. Requires NumPy and Pillow."""
import argparse
import json
from pathlib import Path
import numpy as np
from PIL import Image
from render import HERE, render
# Centre, half-width of square, transpose to cut across vertical ribbons.
CROPS = [(459,255,40,1), (300,1108,40,1), (451,1108,41,0), (609,128,40,1),
(148,1245,42,1), (459,128,41,1), (221,256,122,0), (604,1245,41,1),
(148,1383,41,1), (609,382,41,0), (459,382,41,1), (609,255,41,1)]
def simplify(values, tolerance):
"""Indices of knots in a piecewise linear approximation with bounded error."""
keep = [0, len(values)-1]
pending = [(0, len(values)-1)]
while pending:
a, b = pending.pop()
if b-a < 2:
continue
t = np.arange(1, b-a)[:, None]/(b-a)
error = np.max(np.abs(values[a+1:b] - (values[a]+t*(values[b]-values[a]))), axis=1)
split = int(np.argmax(error))
if error[split] > tolerance:
mid = a+1+split
keep.append(mid)
pending.extend([(a,mid), (mid,b)])
return sorted(keep)
def align(a, b, spacing):
"""Monotone matching along two cross-sections, penalising stretch and drift."""
n = len(a)
pos = np.arange(n)
displacement = np.abs(pos[:, None]-pos)
cost = (np.mean(np.abs(a[:, None]-b), axis=2) + .5*displacement
+ 5*np.maximum(displacement-2*spacing, 0))
total = np.full((n+1, n+1), np.inf)
total[0,0] = 0
# All entries on one antidiagonal can be updated together.
for k in range(2, 2*n+1):
x = np.arange(max(1,k-n), min(n,k-1)+1)
y = k-x
total[x,y] = cost[x-1,y-1]+np.minimum(total[x-1,y-1],
1.8+np.minimum(total[x-1,y],total[x,y-1]))
x = y = n
path = []
while x and y:
path.append((x-1,y-1))
step = np.argmin([total[x-1,y-1], total[x-1,y]+1.8, total[x,y-1]+1.8])
x -= int(step != 2)
y -= int(step != 1)
points = np.array(path[::-1])
return points[simplify(points, .8)].tolist()
def fit(rgb, transpose):
data = (rgb.swapaxes(0,1) if transpose else rgb).astype(float)
n = len(data)
sample = np.arange(n)
sections, matches = {}, {}
def profile(y):
if y not in sections:
knots = simplify(data[y], 5)
sections[y] = np.column_stack((sample[knots], data[y,knots])).astype(int).tolist()
return sections[y]
def match(a,b):
if (a,b) not in matches:
matches[a,b] = align(data[a],data[b],b-a)
return matches[a,b]
def build(cuts):
return dict(span=n, transpose=bool(transpose), cuts=cuts, sections=[profile(y) for y in cuts],
correspondence=[match(a,b) for a,b in zip(cuts,cuts[1:])])
cuts = sorted({0,n-1,*range(0,n,max(6,n//10))})
for _ in range(5):
model = build(cuts)
view = np.asarray(render(model, n))
if transpose:
view = view.swapaxes(0,1)
delta = np.mean(np.abs(view-data),axis=2)
# Include a high percentile so a narrow tip cannot disappear in the mean.
errors = delta.mean(axis=1) + .35*np.percentile(delta,95,axis=1)
additions = []
for a,b in zip(cuts,cuts[1:]):
if b-a<2:
continue
y = a+1+int(np.argmax(errors[a+1:b]))
if errors[y] > (10 if b-a <= 3 else 5):
additions.append(y)
if not additions:
break
cuts = sorted(cuts+additions)
return build(cuts)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("reference", type=Path)
args = parser.parse_args()
photo = Image.open(args.reference).convert("RGB")
if photo.size != (750,1500):
parser.error("Expected the original 750 x 1500 reference sheet")
models = []
for cx,cy,r,transpose in CROPS:
crop = np.asarray(photo.crop((cx-r,cy-r,cx+r,cy+r)))
models.append(fit(crop, transpose))
(HERE/"marks.json").write_text("[\n"+",\n".join(json.dumps(model,separators=(",",":"))
for model in models)+"\n]\n")
File diff suppressed because one or more lines are too long
Binary file not shown.

After

Width:  |  Height:  |  Size: 253 KiB

@@ -0,0 +1,56 @@
"""Render fitted ribbon cross-sections. Requires NumPy and Pillow."""
import argparse
import json
from pathlib import Path
import numpy as np
from PIL import Image
HERE = Path(__file__).resolve().parent
def section(section_data, v):
knots = np.array(section_data, dtype=float)
return np.stack([np.interp(v, knots[:, 0], channel) for channel in knots[:, 1:].T], axis=-1)
def render(model, size):
"""Interpolate geometry first, then interpolate the colours on each face."""
n = model["span"]
axis = (np.arange(size) + .5) * n / size - .5
out = np.empty((size, size, 3), dtype=np.uint8)
cuts = np.array(model["cuts"])
for row, y in enumerate(axis):
i = np.clip(np.searchsorted(cuts, y, side="right")-1, 0, len(cuts)-2)
t = np.clip((y-cuts[i])/(cuts[i+1]-cuts[i]), 0, 1)
a, b = np.array(model["correspondence"][i]).T
middle = (1-t)*a + t*b
u = np.interp(axis, middle, a)
v = np.interp(axis, middle, b)
colors = (1-t)*section(model["sections"][i], u) + t*section(model["sections"][i+1], v)
out[row] = np.clip(np.rint(colors), 0, 255)
if model["transpose"]:
out = np.swapaxes(out, 0, 1)
return Image.fromarray(out)
def sheet(models, size):
gap = size//3
canvas = Image.new("RGB", (4*(size+gap)+gap, 3*(size+gap)+gap), (70, 22, 70))
for i, model in enumerate(models):
canvas.paste(render(model, size), (gap+i%4*(size+gap), gap+i//4*(size+gap)))
return canvas
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--mark", type=int, choices=range(1, 13))
parser.add_argument("--size", type=int, default=128, help="pixels per mark")
parser.add_argument("--output", type=Path)
args = parser.parse_args()
if args.size < 1:
parser.error("--size must be positive")
models = json.loads((HERE/"marks.json").read_text())
image = render(models[args.mark-1], args.size) if args.mark else sheet(models, args.size)
target = args.output or HERE/(f"mark-{args.mark:02}.png" if args.mark else "preview.png")
image.save(target)
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 102 KiB

+417
View File
@@ -0,0 +1,417 @@
[
{
"mode": "bands",
"angles": [
0,
0,
19.7,
0
],
"bands": [
[
-0.95,
0.1905
],
[
-0.458,
0.35
],
[
0.2795,
0.3775
],
[
0.4815,
0.4985
],
[
0.87,
0.24
]
],
"inks": {
"0/1": "#eeb798",
"0/2": "#8a8396",
"0/3": "#ea8176",
"0/4": "#bc8780",
"0/5": "#826d7d",
"1/0": "#9f9fad",
"1/1": "#dbb6ad",
"2/0": "#874564",
"2/2": "#ac92a1",
"3/0": "#82798c",
"3/3": "#f3c2b6",
"3/4": "#aeb2b7",
"4/0": "#694f6e",
"4/3": "#f08679",
"4/4": "#56274a",
"4/5": "#8a8398",
"5/0": "#e7a990",
"5/4": "#f8bd93",
"5/5": "#f4cbb7"
}
},
{
"mode": "bands",
"angles": [
-1.791,
-32.186,
0.07,
-2.839
],
"bands": [
[
-1.0594,
0.4096
],
[
-0.731,
0.3594
],
[
-0.3312,
0.2787
],
[
0.1514,
0.2592
],
[
0.6196,
0.2753
],
[
1.0483,
0.4561
]
],
"inks": {
"0/3": "#784e69",
"0/4": "#8b6172",
"0/5": "#7b4861",
"0/6": "#693b58",
"1/0": "#efb092",
"1/2": "#ddaaa6",
"1/3": "#eab8a3",
"2/0": "#da7e77",
"2/2": "#713b53",
"2/3": "#d18e8c",
"2/4": "#e9a59b",
"3/0": "#e7a28a",
"3/3": "#966776",
"3/4": "#f6c4a7",
"3/5": "#f6bfa2",
"4/0": "#e88881",
"4/4": "#ae6671",
"4/5": "#e98a82",
"4/6": "#f1988c",
"5/0": "#cc938c",
"5/5": "#b57a7f",
"5/6": "#d79a8f"
}
},
{
"mode": "bands",
"angles": [
89.303,
14.637,
-1.031,
11.417
],
"bands": [
[
-0.5511,
0.5986
],
[
0.5624,
0.5718
]
],
"inks": {
"0/1": "#8b7c92",
"0/2": "#af7b7e",
"1/0": "#7f4366",
"1/1": "#9c798e",
"2/0": "#dac4b1",
"2/2": "#dcb6a7"
}
},
{
"mode": "bands",
"angles": [
-44.684,
26.855,
-1.6,
2.652
],
"bands": [
[
-0.8871,
0.3778
],
[
-0.2958,
0.4983
],
[
0.5552,
0.665
]
],
"inks": {
"0/1": "#f0b093",
"0/2": "#91909e",
"0/3": "#dca4a1",
"1/1": "#f9c09b",
"2/0": "#9ca0ab",
"2/1": "#f7ceb7",
"2/2": "#b6bcc6",
"3/0": "#794c69",
"3/2": "#b2a2ac",
"3/3": "#e69c95"
}
},
{
"mode": "bands",
"angles": [
0,
0,
24.3,
0
],
"bands": [
[
-0.69,
0.57
],
[
0.7285,
0.57
]
],
"inks": {
"0/1": "#a7afb5",
"0/2": "#80778c",
"1/0": "#ef8275",
"1/1": "#f9c7ba",
"2/0": "#94536e",
"2/2": "#b6a4ad"
}
},
{
"mode": "bands",
"angles": [
24.617,
21.92,
15.227,
4.721
],
"bands": [
[
-0.3092,
0.9832
],
[
0.6666,
0.569
]
],
"inks": {
"0/1": "#6f3d5c",
"0/2": "#868495",
"1/0": "#946176",
"1/1": "#ea9187",
"2/0": "#e4af94",
"2/1": "#f6ba9f",
"2/2": "#997b80"
}
},
{
"angles": [
0,
0,
0,
0
],
"bands": [],
"mode": "petals",
"inks": {
"0/1": "#9a556e",
"1/0": "#81798d",
"1/1": "#b8a5b0",
"0/2": "#ff9b81",
"2/0": "#837d91",
"2/2": "#ffd5b5",
"0/3": "#a55f72",
"3/0": "#ff8771",
"3/3": "#ffa188"
}
},
{
"mode": "bands",
"angles": [
-0.899,
9.985,
-3.206,
-0.452
],
"bands": [
[
-0.8721,
0.2916
],
[
0.0183,
0.5875
],
[
0.9273,
0.3999
]
],
"inks": {
"0/1": "#f68b79",
"0/2": "#9294a2",
"1/1": "#eda58f",
"2/0": "#90909f",
"2/2": "#b9c5ca",
"3/0": "#833c60",
"3/3": "#a1506f"
}
},
{
"mode": "bands",
"angles": [
7.565,
23.002,
-9.66,
12.642
],
"bands": [
[
-1.0253,
0.7238
],
[
-0.0246,
0.9293
],
[
0.8626,
0.5551
]
],
"inks": {
"0/1": "#dcbeb2",
"0/2": "#bb8d90",
"1/1": "#beadb0",
"2/0": "#5e3458",
"2/1": "#9c8791",
"2/2": "#d2b0ad",
"3/0": "#5a375a",
"3/2": "#765e78",
"3/3": "#d9bdb1"
}
},
{
"mode": "bands",
"angles": [
90.42,
1.38,
26.293,
2.256
],
"bands": [
[
-0.9005,
0.3924
],
[
0.0113,
0.5277
],
[
0.9205,
0.3849
]
],
"inks": {
"0/1": "#8f4b68",
"0/2": "#f38778",
"0/3": "#793057",
"1/0": "#f29c83",
"1/1": "#e1a78e",
"2/0": "#9897a3",
"2/2": "#f6c4b7",
"3/0": "#f39d82",
"3/3": "#edb79a"
}
},
{
"mode": "bands",
"angles": [
-8.06,
11.533,
19.651,
12.902
],
"bands": [
[
-0.8357,
0.371
],
[
0.0753,
0.4804
],
[
0.8661,
0.3363
]
],
"inks": {
"0/1": "#8d5b78",
"0/2": "#f29c85",
"0/3": "#998994",
"1/0": "#867e94",
"1/1": "#ad95a4",
"2/0": "#62224d",
"2/2": "#c4827f",
"3/0": "#864255",
"3/3": "#f7c8b2"
}
},
{
"mode": "spiral",
"angles": [
8,
3,
0,
0
],
"bands": [
[
0.12,
0.38
]
],
"inks": {
"1/0": "#ff967e",
"2/0": "#a8babb",
"3/0": "#a26d86",
"0/1": "#7c526f",
"0/2": "#98586e",
"0/3": "#714561",
"1/1": "#ffb58d",
"1/2": "#ffb58d",
"1/3": "#ffb58d",
"2/1": "#bfd2c9",
"2/2": "#bfd2c9",
"2/3": "#bfd2c9",
"3/1": "#ac8497",
"3/2": "#ac8497",
"3/3": "#ac8497"
}
}
]
Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

+93
View File
@@ -0,0 +1,93 @@
"""Procedural ribbon shells. Run with --turn 20 to rotate every shell in depth."""
import argparse
import json
from math import asin, atan2, cos, pi, radians, sin, sqrt
from pathlib import Path
import struct
import zlib
BG = (68, 23, 68)
STYLE_FILE = Path(__file__).with_name("shell-styles.json")
def make_shader(style, turn):
roll, pitch, linear, quadratic = style["angles"]
cr, sr = cos(radians(roll)), sin(radians(roll))
cp, sp = cos(radians(pitch)), sin(radians(pitch))
ct, st = cos(radians(turn)), sin(radians(turn))
bands = style["bands"]
palette = {tuple(map(int, pair.split("/"))): tuple(bytes.fromhex(ink[1:]))
for pair, ink in style["inks"].items()}
mode = style["mode"]
def band_at(u, v, w):
if mode == "petals":
for index, (a, b) in enumerate(((0, 1), (.8660254, -.5), (-.8660254, -.5)), 1):
radial, tangent = a*u+b*v, b*u-a*v
if radial + .72*w*tangent > .725:
return index
return 0
if mode == "spiral":
phase, width = bands[0]
cycle = 3*(.5+asin(max(-1, min(1, v)))/pi) - atan2(w,u)/(2*pi) + phase
return 1+round(cycle)%3 if abs(cycle-round(cycle)) < width/2 else 0
angle = radians(linear*u + quadratic*(2*u*u-1))
height = v*cos(angle) + w*sin(angle)
for index, (centre, width) in enumerate(bands, 1):
if abs(height-centre) <= width/2:
return index
return 0
def face(x, y, z):
depth = st*x+ct*z
return band_at(ct*x-st*z, cp*y+sp*depth, cp*depth-sp*y)
def pixel(x, y):
d = 1-x*x-y*y
if d <= 0:
return BG
z = sqrt(d)
u, v = cr*x+sr*y, cr*y-sr*x
front, back = face(u,v,z), face(u,v,-z)
if not (front or back):
return BG
# Each pair of visible faces defines one ink mixture. New angles can
# reveal pairs absent from the reference view.
color = palette.get((front, back))
if color is None:
ink = palette.get((front, 0), palette.get((front, front), BG))
rear = palette.get((0, back), palette.get((back, back), BG))
color = tuple((f+r)/2 for f,r in zip(ink,rear)) if front and back else (ink if front else rear)
light = 1+.045*(-x+y)/2
return tuple(min(255,round(k*light)) for k in color)
return pixel
def sheet(turn, size=118, samples=3):
gap = size//3
width, height = 4*(size+gap)+gap, 3*(size+gap)+gap
pixels = bytearray(bytes(BG)*width*height)
for i, style in enumerate(json.loads(STYLE_FILE.read_text())):
shade = make_shader(style, turn)
left, top = gap+(i%4)*(size+gap), gap+(i//4)*(size+gap)
for row in range(size):
for col in range(size):
colors = [shade(2*(col+(a+.5)/samples)/size-1,
1-2*(row+(b+.5)/samples)/size)
for a in range(samples) for b in range(samples)]
start = 3*((top+row)*width+left+col)
pixels[start:start+3] = bytes(round(sum(c)/len(colors)) for c in zip(*colors))
def chunk(kind, data):
return (struct.pack(">I", len(data))+kind+data+
struct.pack(">I", zlib.crc32(kind+data)))
scanlines = b"".join(b"\0"+pixels[i:i+3*width] for i in range(0,len(pixels),3*width))
return (b"\x89PNG\r\n\x1a\n"+chunk(b"IHDR", struct.pack(">2I5B",width,height,8,2,0,0,0))+
chunk(b"IDAT",zlib.compress(scanlines,9))+chunk(b"IEND",b""))
if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--turn", type=float, default=0)
parser.add_argument("--output", type=Path, default=Path(__file__).with_suffix(".png"))
options = parser.parse_args()
options.output.write_bytes(sheet(options.turn))
-4
View File
@@ -6,10 +6,6 @@ rust-version.workspace = true
[dependencies] [dependencies]
axum.workspace = true axum.workspace = true
bedrock-rpc = { path = "../bedrock-rpc" }
clusters.workspace = true clusters.workspace = true
serde.workspace = true serde.workspace = true
subtle.workspace = true subtle.workspace = true
[dev-dependencies]
tokio = { workspace = true, features = ["net"] }
+27 -29
View File
@@ -1,5 +1,3 @@
pub mod rpc;
use std::{io, sync::Arc}; use std::{io, sync::Arc};
use axum::{ use axum::{
@@ -11,7 +9,7 @@ use axum::{
routing::get, routing::get,
}; };
use clusters::{DOCUMENTS, ResolvedDeployment, SqlDriver}; use clusters::{DOCUMENTS, ResolvedDeployment, SqlDriver};
use rpc::DeploymentStatus; use serde::Serialize;
use subtle::ConstantTimeEq; use subtle::ConstantTimeEq;
#[derive(Clone)] #[derive(Clone)]
@@ -22,24 +20,26 @@ struct AdminState {
read_only: bool, read_only: bool,
} }
impl AdminState { #[derive(Serialize)]
fn status(&self) -> DeploymentStatus { struct DeploymentStatus<'a> {
let config = &self.config; deployment: &'a str,
DeploymentStatus { config_version: Option<&'a str>,
deployment: config.deployment.clone(), storage_driver: &'static str,
config_version: self read_only: bool,
.config_version
.clone()
.or_else(|| Some(config.config_version.clone())),
storage_driver: self.storage_driver.to_owned(),
read_only: self.read_only,
}
}
} }
impl rpc::Service for AdminState { impl AdminState {
async fn status(&self, _: rpc::StatusRequest) -> Result<DeploymentStatus, StatusCode> { fn status(&self) -> DeploymentStatus<'_> {
Ok(self.status()) let config = &self.config;
DeploymentStatus {
deployment: &config.deployment,
config_version: self
.config_version
.as_deref()
.or(Some(&config.config_version)),
storage_driver: self.storage_driver,
read_only: self.read_only,
}
} }
} }
@@ -71,16 +71,8 @@ pub fn router(
}; };
let read_only = settings.read_only; let read_only = settings.read_only;
let state = AdminState {
config,
config_version,
storage_driver,
read_only,
};
let admin = Router::new() let admin = Router::new()
.route("/admin/v1/status", get(deployment_status)) .route("/status", get(deployment_status))
.with_state(state.clone())
.merge(rpc::router(state))
.route_layer(middleware::from_fn_with_state( .route_layer(middleware::from_fn_with_state(
Arc::<str>::from(token), Arc::<str>::from(token),
require_admin, require_admin,
@@ -88,7 +80,13 @@ pub fn router(
Ok(Router::new() Ok(Router::new()
.route("/healthz", get(|| async { StatusCode::NO_CONTENT })) .route("/healthz", get(|| async { StatusCode::NO_CONTENT }))
.route("/readyz", get(|| async { StatusCode::NO_CONTENT })) .route("/readyz", get(|| async { StatusCode::NO_CONTENT }))
.merge(admin)) .nest("/admin/v1", admin)
.with_state(AdminState {
config,
config_version,
storage_driver,
read_only,
}))
} }
async fn deployment_status(State(state): State<AdminState>) -> Response { async fn deployment_status(State(state): State<AdminState>) -> Response {
-19
View File
@@ -1,19 +0,0 @@
//! Shared wire contract for querying the Bedrock instance serving the request.
use serde::{Deserialize, Serialize};
#[derive(Deserialize, Serialize)]
pub struct StatusRequest {}
#[derive(Deserialize, Serialize)]
pub struct DeploymentStatus {
pub deployment: String,
pub config_version: Option<String>,
pub storage_driver: String,
pub read_only: bool,
}
bedrock_rpc::service! {
"/admin/v1/deployment" {
fn status(StatusRequest) -> DeploymentStatus;
}
}
-45
View File
@@ -1,45 +0,0 @@
use std::{sync::Arc, time::Duration};
use admin_backend::rpc::{Client, StatusRequest};
use axum::http::{HeaderMap, HeaderValue, StatusCode, header};
use bedrock_rpc::{Error, HttpTransport, Transport};
use clusters::DeploymentConfig;
#[tokio::test]
async fn status_rpc_uses_the_admin_listener_and_its_authentication() {
let config = DeploymentConfig::default().resolve().unwrap();
let app =
admin_backend::router(Arc::new(config), Some("release-7".into()), "test".into()).unwrap();
let listener = tokio::net::TcpListener::bind(("127.0.0.1", 0))
.await
.unwrap();
let origin = format!("http://{}", listener.local_addr().unwrap());
let server = tokio::spawn(async move { axum::serve(listener, app).await.unwrap() });
let peer = |headers| HttpTransport::new(&origin, Duration::from_secs(3), headers).unwrap();
let anonymous = Client(peer(HeaderMap::new()));
assert!(matches!(
anonymous.status(&StatusRequest {}).await,
Err(Error::Status(StatusCode::UNAUTHORIZED))
));
let mut headers = HeaderMap::new();
headers.insert(
header::AUTHORIZATION,
HeaderValue::from_static("Bearer test"),
);
let client = Client(peer(headers));
let status = client.status(&StatusRequest {}).await.unwrap();
assert_eq!(status.config_version.as_deref(), Some("release-7"));
assert_eq!(status.deployment, "default");
let malformed = client
.0
.post("/admin/v1/deployment/status", b"{".to_vec())
.await;
assert!(matches!(
malformed,
Err(Error::Status(StatusCode::BAD_REQUEST))
));
server.abort();
}
-11
View File
@@ -1,11 +0,0 @@
[package]
name = "bedrock-rpc"
version = "0.1.0"
edition.workspace = true
rust-version.workspace = true
[dependencies]
axum.workspace = true
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] }
serde_json.workspace = true
thiserror.workspace = true
-45
View File
@@ -1,45 +0,0 @@
# Bedrock RPC
每个服务用一个 Rust 模块发布契约。编译时,`service!` 将前缀、方法名、请求类型和响应类型展开成三个入口。调用方使用 `Client<T>`,服务实现 `Service`,启动代码将 `router(service)` 合入 Axum。Rust 会检查调用参数、返回类型和处理方法是否齐全。跨版本节点的兼容性仍取决于线上的 JSON 格式和路径。
```rust
mod replica {
bedrock_rpc::service! {
"/replica/v1" {
fn revision(()) -> u64;
}
}
}
struct Replica { applied_revision: u64 }
impl replica::Service for Replica {
async fn revision(&self, _: ()) -> Result<u64, bedrock_rpc::axum::http::StatusCode> {
Ok(self.applied_revision)
}
}
```
此方法通过 POST /replica/v1/revision 发送 JSON null。成功时返回 HTTP 200 和一个 JSON 整数。handler 可返回 HTTP 错误状态;调用方可以分别处理远端状态、网络失败和 JSON 解码失败。
## 目标集群与传输
发送方为目标创建一个可复用的 HttpTransport,传入 origin、每次请求的超时和请求头。集群内 origin 可指向服务 DNS,跨集群时指向已配置的 HTTPS 网关。网关需将契约路径转发至目标服务。服务发现、凭据分发和网关策略由部署方负责。发送凭据时应使用 HTTPS 或由服务网格保护的连接。自有传输可以实现 Transport::post,按路径传送 JSON 字节并返回响应。
```rust
use std::time::Duration;
use admin_backend::rpc::{Client, StatusRequest};
use bedrock_rpc::{HeaderMap, HttpTransport};
async fn config_version(origin: &str, headers: HeaderMap)
-> Result<Option<String>, bedrock_rpc::Error>
{
let peer = HttpTransport::new(origin, Duration::from_secs(3), headers)?;
let status = Client(peer).status(&StatusRequest {}).await?;
Ok(status.config_version)
}
```
Bedrock 已在管理监听器挂载 [deployment 契约](../admin_backend/src/rpc.rs)。调用方通过 headers 传入现有 Bearer 令牌。请求使用与 GET /admin/v1/status 相同的状态来源及鉴权中间件。
## 协议演进
首版支持一次请求返回一次响应。服务路径和方法名是协议标识,双方共享可由 Serde 编解码的 DTO。兼容扩展可添加新方法或带默认值的可选字段;旧节点收到未知路径返回 404。已有字段类型、方法名或语义需要改变时,发布新的版本前缀并在滚动升级期间并行提供两个版本。调用超时后,服务端可能已经执行操作,写入方法需要业务定义幂等语义。
-130
View File
@@ -1,130 +0,0 @@
//! Compile-time bindings for unary Bedrock service contracts.
use std::{future::Future, time::Duration};
use axum::http::StatusCode;
pub use reqwest::header::HeaderMap;
#[doc(hidden)]
pub use axum;
#[doc(hidden)]
pub use serde_json;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("invalid RPC origin (expected an HTTP(S) origin without a path or credentials)")]
Origin,
#[error("RPC transport error")]
Network(#[from] reqwest::Error),
#[error("application transport failed")]
Transport(#[source] Box<dyn std::error::Error + Send + Sync>),
#[error("RPC peer returned HTTP {0}")]
Status(StatusCode),
#[error("RPC body exceeds the size limit")]
TooLarge,
#[error("invalid RPC JSON")]
Json(#[from] serde_json::Error),
}
/// Same limit for encoded requests and successful replies (2 MiB).
pub const MAX_BODY: usize = 2 * 1024 * 1024;
/// Implement to route a call through an application-owned connection.
pub trait Transport: Sync {
fn post(
&self,
path: &'static str,
json: Vec<u8>,
) -> impl Future<Output = Result<Vec<u8>, Error>> + Send;
}
/// Reuses pooled connections to a single configured peer.
pub struct HttpTransport {
origin: reqwest::Url,
client: reqwest::Client,
}
impl HttpTransport {
pub fn new(origin: &str, timeout: Duration, headers: HeaderMap) -> Result<Self, Error> {
let origin = reqwest::Url::parse(origin).map_err(|_| Error::Origin)?;
if !matches!(origin.scheme(), "https" | "http")
|| origin.host_str().is_none()
|| !origin.username().is_empty()
|| origin.password().is_some()
|| origin.path() != "/"
|| origin.query().is_some()
|| origin.fragment().is_some()
{
return Err(Error::Origin);
}
let client = reqwest::Client::builder()
.timeout(timeout)
.redirect(reqwest::redirect::Policy::none())
.default_headers(headers)
.build()?;
Ok(Self { origin, client })
}
}
impl Transport for HttpTransport {
async fn post(&self, path: &'static str, json: Vec<u8>) -> Result<Vec<u8>, Error> {
if json.len() > MAX_BODY {
return Err(Error::TooLarge);
}
let mut url = self.origin.clone();
url.set_path(path);
let mut response = self
.client
.post(url)
.header(reqwest::header::CONTENT_TYPE, "application/json")
.body(json)
.send()
.await?;
if response.status() != StatusCode::OK {
return Err(Error::Status(response.status()));
}
let mut bytes = Vec::new();
while let Some(chunk) = response.chunk().await? {
if chunk.len() > MAX_BODY - bytes.len() {
return Err(Error::TooLarge);
}
bytes.extend_from_slice(&chunk);
}
Ok(bytes)
}
}
/// Declare once inside a contract module. The service prefix and method names
/// are part of the wire protocol. See the crate README for evolution rules.
#[macro_export]
macro_rules! service {
($prefix:literal { $(fn $method:ident($input:ty) -> $output:ty;)+ }) => {
pub trait Service: Send + Sync + 'static {
$(fn $method(&self, request: $input) -> impl ::std::future::Future<
Output = Result<$output, $crate::axum::http::StatusCode>
> + Send;)+
}
pub struct Client<T>(pub T);
impl<T: $crate::Transport> Client<T> {
$(pub async fn $method(&self, request: &$input) -> Result<$output, $crate::Error> {
let bytes = $crate::serde_json::to_vec(request)?;
let reply = self.0.post(concat!($prefix, "/", stringify!($method)), bytes).await?;
Ok($crate::serde_json::from_slice(&reply)?)
})+
}
pub fn router<S: Service>(service: S) -> $crate::axum::Router {
use $crate::axum::{Json, Router, extract::State, routing::post};
use ::std::sync::Arc;
Router::new()
$(.route(concat!($prefix, "/", stringify!($method)), post(
|State(service): State<Arc<S>>, Json(request): Json<$input>| async move {
service.$method(request).await.map(Json)
}
)))+
.with_state(Arc::new(service))
}
};
}
+4 -1
View File
@@ -16,4 +16,7 @@ pub use organization::{Organization, OrganizationId, OrganizationMembership, Org
pub use rich_text::{Inline, RichText}; pub use rich_text::{Inline, RichText};
pub use tree::{DocumentTree, TreeError}; pub use tree::{DocumentTree, TreeError};
pub use user::{User, UserId}; pub use user::{User, UserId};
pub use workspace::{Workspace, WorkspaceId}; pub use workspace::{
Workspace, WorkspaceAccess, WorkspaceAccessError, WorkspaceId, WorkspaceInvitation,
WorkspaceMembership, WorkspaceRole,
};
+15
View File
@@ -2,6 +2,7 @@ use super::contextualize::Contextualize;
use super::{ use super::{
id::{IdError, validate_id}, id::{IdError, validate_id},
user::UserId, user::UserId,
workspace::{Workspace, WorkspaceAccess, WorkspaceAccessError, WorkspaceId},
}; };
#[derive(Clone, Debug, Eq, Hash, PartialEq)] #[derive(Clone, Debug, Eq, Hash, PartialEq)]
@@ -42,6 +43,20 @@ pub struct OrganizationMembership {
pub role: OrganizationRole, pub role: OrganizationRole,
} }
impl Organization {
pub fn create_workspace(&self, id: WorkspaceId, name: impl Into<String>) -> Workspace {
Workspace::owned_by(id, name, self.id.clone())
}
pub fn set_workspace_access(
&self,
workspace: &mut Workspace,
access: WorkspaceAccess,
) -> Result<(), WorkspaceAccessError> {
workspace.set_organization_access(&self.id, access)
}
}
impl Contextualize for Organization { impl Contextualize for Organization {
fn render_context(&self) -> String { fn render_context(&self) -> String {
format!("Organization: {}", self.name) format!("Organization: {}", self.name)
+184 -3
View File
@@ -1,7 +1,12 @@
use thiserror::Error;
use super::contextualize::Contextualize; use super::contextualize::Contextualize;
use super::{ use super::{
Document,
id::{IdError, validate_id}, id::{IdError, validate_id},
organization::OrganizationId, organization::{OrganizationId, OrganizationMembership},
tree::{DocumentTree, TreeError},
user::UserId,
}; };
#[derive(Clone, Debug, Eq, Hash, PartialEq)] #[derive(Clone, Debug, Eq, Hash, PartialEq)]
@@ -21,12 +26,188 @@ impl WorkspaceId {
} }
} }
/// A workspace belongs to one organization and contains documents. #[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum WorkspaceRole {
Owner,
Admin,
Editor,
Viewer,
}
/// Controls which roles can be granted to people outside the owning organization.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub enum WorkspaceAccess {
#[default]
MembersOnly,
ExternalViewers,
ExternalEditors,
}
impl WorkspaceAccess {
fn allows_external(self, role: WorkspaceRole) -> bool {
matches!(
(self, role),
(
Self::ExternalViewers | Self::ExternalEditors,
WorkspaceRole::Viewer
) | (Self::ExternalEditors, WorkspaceRole::Editor)
)
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
struct OrganizationWorkspace {
id: OrganizationId,
access: WorkspaceAccess,
}
/// A workspace contains documents and may be owned by an organization.
#[derive(Clone, Debug, Eq, PartialEq)] #[derive(Clone, Debug, Eq, PartialEq)]
pub struct Workspace { pub struct Workspace {
pub id: WorkspaceId, pub id: WorkspaceId,
pub organization_id: OrganizationId,
pub name: String, pub name: String,
organization: Option<OrganizationWorkspace>,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct WorkspaceInvitation {
workspace_id: WorkspaceId,
invitee: UserId,
role: WorkspaceRole,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct WorkspaceMembership {
pub workspace_id: WorkspaceId,
pub user_id: UserId,
pub role: WorkspaceRole,
}
#[derive(Debug, Error, Eq, PartialEq)]
pub enum WorkspaceAccessError {
#[error("the workspace does not belong to this organization")]
OrganizationMismatch,
#[error("the workspace access policy does not allow this role for the invitee")]
RoleNotAllowed,
#[error("the invitation is for a different workspace or user")]
InvitationMismatch,
}
impl Workspace {
pub fn independent(id: WorkspaceId, name: impl Into<String>) -> Self {
Self {
id,
name: name.into(),
organization: None,
}
}
pub(super) fn owned_by(
id: WorkspaceId,
name: impl Into<String>,
organization_id: OrganizationId,
) -> Self {
Self {
id,
name: name.into(),
organization: Some(OrganizationWorkspace {
id: organization_id,
access: WorkspaceAccess::default(),
}),
}
}
pub fn organization_id(&self) -> Option<&OrganizationId> {
self.organization
.as_ref()
.map(|organization| &organization.id)
}
pub fn organization_access(&self) -> Option<WorkspaceAccess> {
self.organization
.as_ref()
.map(|organization| organization.access)
}
pub(super) fn set_organization_access(
&mut self,
organization_id: &OrganizationId,
access: WorkspaceAccess,
) -> Result<(), WorkspaceAccessError> {
let organization = self
.organization
.as_mut()
.filter(|organization| &organization.id == organization_id)
.ok_or(WorkspaceAccessError::OrganizationMismatch)?;
organization.access = access;
Ok(())
}
/// Evaluates the invitee against the current policy. The caller supplies the
/// invitee's current membership in the owning organization, if any.
pub fn invite(
&self,
invitee: UserId,
role: WorkspaceRole,
organization_membership: Option<&OrganizationMembership>,
) -> Result<WorkspaceInvitation, WorkspaceAccessError> {
self.check_access(&invitee, role, organization_membership)?;
Ok(WorkspaceInvitation {
workspace_id: self.id.clone(),
invitee,
role,
})
}
/// Rechecks policy and membership so a pending invitation cannot preserve
/// privileges after either has changed.
pub fn accept_invitation(
&self,
user: &UserId,
invitation: &WorkspaceInvitation,
organization_membership: Option<&OrganizationMembership>,
) -> Result<WorkspaceMembership, WorkspaceAccessError> {
if invitation.workspace_id != self.id || &invitation.invitee != user {
return Err(WorkspaceAccessError::InvitationMismatch);
}
self.check_access(user, invitation.role, organization_membership)?;
Ok(WorkspaceMembership {
workspace_id: self.id.clone(),
user_id: user.clone(),
role: invitation.role,
})
}
/// Assembles an ordered tree of document nodes in this workspace.
pub fn document_tree(
&self,
root: Document,
descendants: impl IntoIterator<Item = Document>,
) -> Result<DocumentTree, TreeError> {
if root.key.workspace != self.id {
return Err(TreeError::WorkspaceMismatch);
}
DocumentTree::new(root, descendants)
}
fn check_access(
&self,
user: &UserId,
role: WorkspaceRole,
membership: Option<&OrganizationMembership>,
) -> Result<(), WorkspaceAccessError> {
let Some(organization) = &self.organization else {
return Ok(());
};
let internal = membership.is_some_and(|membership| {
membership.organization_id == organization.id && &membership.user_id == user
});
if internal || organization.access.allows_external(role) {
Ok(())
} else {
Err(WorkspaceAccessError::RoleNotAllowed)
}
}
} }
impl Contextualize for Workspace { impl Contextualize for Workspace {
+174
View File
@@ -0,0 +1,174 @@
use documents::{
Document, DocumentContent, DocumentId, DocumentKey, Organization, OrganizationId,
OrganizationMembership, OrganizationRole, TreeError, UserId, Workspace, WorkspaceAccess,
WorkspaceAccessError, WorkspaceId, WorkspaceRole,
};
fn organization(id: &str) -> Organization {
Organization {
id: OrganizationId::new(id).unwrap(),
name: id.into(),
}
}
fn member(organization: &Organization, user: &UserId) -> OrganizationMembership {
OrganizationMembership {
organization_id: organization.id.clone(),
user_id: user.clone(),
role: OrganizationRole::Member,
}
}
fn workspace_id(value: &str) -> WorkspaceId {
WorkspaceId::new(value).unwrap()
}
#[test]
fn organization_controls_the_roles_available_to_external_users() {
use WorkspaceAccess::{ExternalEditors, ExternalViewers, MembersOnly};
use WorkspaceRole::{Admin, Editor, Owner, Viewer};
let organization = organization("org");
let mut workspace = organization.create_workspace(workspace_id("workspace"), "Workspace");
let outside = UserId::new("outside").unwrap();
let inside = UserId::new("inside").unwrap();
let membership = member(&organization, &inside);
assert_eq!(workspace.organization_id(), Some(&organization.id));
assert_eq!(workspace.organization_access(), Some(MembersOnly));
for (policy, allowed) in [
(MembersOnly, &[][..]),
(ExternalViewers, &[Viewer][..]),
(ExternalEditors, &[Viewer, Editor][..]),
] {
organization
.set_workspace_access(&mut workspace, policy)
.unwrap();
for role in [Owner, Admin, Editor, Viewer] {
let invitation = workspace.invite(outside.clone(), role, None);
if allowed.contains(&role) {
let membership = workspace
.accept_invitation(&outside, &invitation.unwrap(), None)
.unwrap();
assert_eq!(membership.user_id, outside);
assert_eq!(membership.workspace_id, workspace.id);
assert_eq!(membership.role, role);
} else {
assert_eq!(invitation, Err(WorkspaceAccessError::RoleNotAllowed));
}
assert!(
workspace
.invite(inside.clone(), role, Some(&membership))
.is_ok()
);
}
}
}
#[test]
fn acceptance_checks_the_invite_target_and_current_policy() {
let owner = organization("owner");
let other = organization("other");
let mut workspace = owner.create_workspace(workspace_id("workspace"), "Workspace");
let independent = Workspace::independent(workspace_id("personal"), "Personal");
let outsider = UserId::new("outside").unwrap();
let insider = UserId::new("inside").unwrap();
let inside_membership = member(&owner, &insider);
let other_membership = member(&other, &outsider);
for membership in [&inside_membership, &other_membership] {
assert_eq!(
workspace.invite(outsider.clone(), WorkspaceRole::Admin, Some(membership)),
Err(WorkspaceAccessError::RoleNotAllowed)
);
}
let invitation = workspace
.invite(
insider.clone(),
WorkspaceRole::Admin,
Some(&inside_membership),
)
.unwrap();
assert_eq!(
workspace.accept_invitation(&insider, &invitation, None),
Err(WorkspaceAccessError::RoleNotAllowed)
);
assert_eq!(
independent.accept_invitation(&insider, &invitation, Some(&inside_membership)),
Err(WorkspaceAccessError::InvitationMismatch)
);
assert_eq!(
workspace.accept_invitation(&outsider, &invitation, None),
Err(WorkspaceAccessError::InvitationMismatch)
);
assert_eq!(independent.organization_id(), None);
assert!(
independent
.invite(outsider.clone(), WorkspaceRole::Editor, None)
.is_ok()
);
assert_eq!(
other.set_workspace_access(&mut workspace, WorkspaceAccess::ExternalEditors),
Err(WorkspaceAccessError::OrganizationMismatch)
);
owner
.set_workspace_access(&mut workspace, WorkspaceAccess::ExternalEditors)
.unwrap();
let external = workspace
.invite(outsider.clone(), WorkspaceRole::Editor, None)
.unwrap();
owner
.set_workspace_access(&mut workspace, WorkspaceAccess::ExternalViewers)
.unwrap();
assert_eq!(
workspace.accept_invitation(&outsider, &external, None),
Err(WorkspaceAccessError::RoleNotAllowed)
);
}
#[test]
fn workspace_contains_nested_documents_of_different_kinds() {
let workspace = Workspace::independent(workspace_id("workspace"), "Workspace");
let key = |id: &str| DocumentKey {
workspace: workspace.id.clone(),
document: DocumentId::new(id).unwrap(),
};
let page = Document::new(
key("page"),
DocumentContent::Page {
title: "Page".into(),
},
);
let mut child_page = Document::new(
key("subpage"),
DocumentContent::Page {
title: "Nested".into(),
},
);
child_page.parent_id = Some(page.key.document.clone());
let mut code = Document::new(
key("code"),
DocumentContent::Code {
language: "rust".into(),
source: "fn main() {}".into(),
},
);
code.parent_id = Some(child_page.key.document.clone());
let tree = workspace
.document_tree(page.clone(), [code, child_page])
.unwrap();
assert_eq!(
tree.nodes()
.map(|(depth, document)| (depth, document.key.document.as_str()))
.collect::<Vec<_>>(),
[(0, "page"), (1, "subpage"), (2, "code")]
);
let other = Workspace::independent(workspace_id("other"), "Other");
assert!(matches!(
other.document_tree(page, []),
Err(TreeError::WorkspaceMismatch)
));
}
+8
View File
@@ -0,0 +1,8 @@
/node_modules/
/.next/
/out/
/coverage/
*.tsbuildinfo
next-env.d.ts
.env*
.DS_Store
+8
View File
@@ -0,0 +1,8 @@
import type { Metadata } from "next";
import type { ReactNode } from "react";
export const metadata: Metadata = { title: "Dashboard" };
export default function RootLayout({ children }: { children: ReactNode }) {
return <html lang="zh-CN"><body>{children}</body></html>;
}
+3
View File
@@ -0,0 +1,3 @@
export default function Page() {
return <main><h1>Dashboard</h1></main>;
}
+8
View File
@@ -0,0 +1,8 @@
import type { NextConfig } from "next";
const config: NextConfig = {
agentRules: false,
devIndicators: false,
};
export default config;
+20
View File
@@ -0,0 +1,20 @@
{
"name": "@bedrock/dashboard",
"private": true,
"scripts": {
"dev": "next dev --hostname 127.0.0.1 --port 3001",
"build": "next build",
"start": "next start --hostname 127.0.0.1 --port 3001"
},
"dependencies": {
"next": "16.4.6",
"react": "19.3.1",
"react-dom": "19.3.1"
},
"devDependencies": {
"@types/node": "22.20.7",
"@types/react": "19.3.0",
"@types/react-dom": "19.3.0",
"typescript": "5.9.3"
}
}
+41
View File
@@ -0,0 +1,41 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"isolatedModules": true,
"jsx": "react-jsx",
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": [
"./*"
]
},
"allowJs": true,
"incremental": true,
"resolveJsonModule": true
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
View File
View File
+59
View File
@@ -0,0 +1,59 @@
# Bedrock Kubernetes 部署路线
建集群、构建 Bedrock 镜像、编写部署清单可以并行。集群内 PostgreSQL 的清单在目标集群和命名空间就绪后提交。数据库可连接、Bedrock 镜像和运行配置就绪后,再初始化 Bedrock 存储。
```mermaid
flowchart TD
start["准备首次部署"]
subgraph infra ["准备 Kubernetes 集群"]
mode{"如何建集群"}
servers["自建:开云服务器,安装容器运行时和 Kubernetes 组件"]
controlPlane["kubeadm init 初始化控制平面"]
workers["kubeadm join 加入工作节点,安装 Pod 网络插件"]
managed["托管:创建 Kubernetes 集群和节点池"]
nodesReady["取得部署用 kubeconfig,确认节点 Ready"]
mode -->|"自建"| servers --> controlPlane --> workers --> nodesReady
mode -->|"托管"| managed --> nodesReady
end
subgraph image ["构建并发布镜像"]
compile["构建 runner 检出代码,编译 Rust 发布版"]
package["把 Bedrock 二进制打包进运行时镜像"]
push["用 Git SHA 标记镜像并推送到镜像仓库"]
compile --> package --> push
end
subgraph config ["准备部署清单和运行配置"]
database{"PostgreSQL 在哪里运行"}
inCluster["集群内:编写 PostgreSQL 部署清单,声明工作负载、持久卷和 Service"]
external["集群外:取得数据库端点并配置网络访问"]
app["编写 Bedrock Deployment、Service 和运行配置"]
secrets["准备数据库 Secret,私有镜像仓库按需配置拉取权限"]
database -->|"集群内"| inCluster --> app
database -->|"集群外"| external --> app
app --> secrets
end
start --> mode
start --> compile
start --> database
nodesReady --> target["确认目标集群和命名空间"]
target -->|"集群内 PostgreSQL"| applyDatabase["kubectl apply 提交 PostgreSQL 清单"]
inCluster -->|"清单已写好"| applyDatabase
applyDatabase --> dbReady["从目标集群确认 PostgreSQL 可连接"]
target -->|"集群外 PostgreSQL"| dbReady
external -->|"端点已配置"| dbReady
push --> appReady["确认 Bedrock 镜像版本和运行配置"]
secrets --> appReady
dbReady --> init["首次部署时运行 Bedrock 存储初始化"]
appReady --> init
init --> apply["kubectl apply 将 Bedrock 清单提交给 API Server"]
apply --> schedule["集群调度 Pod,工作节点拉取镜像并启动 Bedrock"]
schedule --> verify["检查 rollout、Pod 就绪状态和接口连通性"]
```
- **现有构建入口**。[Gitea 发布构建脚本](../../deploy/gitea/build-release.sh) 在构建容器里编译 Rust,并产出 `target/bedrock-release/bedrock`。上图的镜像打包、镜像推送和 Kubernetes 发布是迁移时要接上的步骤。
- **数据库清单**。编写 YAML 可以与建集群并行。提交清单前先拿到 kubeconfig,确认目标集群、命名空间和节点均已就绪。
- **首次初始化**。可以用同一份 Bedrock 镜像运行一次性 Kubernetes Job,等它成功完成再启动应用。集群内的数据库通过 Service 地址连接,集群外的数据库通过其端点连接。
- **日常发布**。沿用已有集群,在 runner 编译并推送新镜像,更新 Deployment 的镜像引用,提交清单并检查滚动发布结果。
View File
View File
+8
View File
@@ -0,0 +1,8 @@
/node_modules/
/.next/
/out/
/coverage/
*.tsbuildinfo
next-env.d.ts
.env*
.DS_Store
+132
View File
@@ -0,0 +1,132 @@
/* latin-ext */
@font-face {
font-family: 'Instrument Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url(/stitch/instrument-sans-1.woff2) format('woff2');
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Instrument Sans';
font-style: normal;
font-weight: 400;
font-stretch: 100%;
font-display: swap;
src: url(/stitch/instrument-sans-2.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
font-family: 'Instrument Sans';
font-style: normal;
font-weight: 500;
font-stretch: 100%;
font-display: swap;
src: url(/stitch/instrument-sans-1.woff2) format('woff2');
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Instrument Sans';
font-style: normal;
font-weight: 500;
font-stretch: 100%;
font-display: swap;
src: url(/stitch/instrument-sans-2.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
font-family: 'Instrument Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url(/stitch/instrument-sans-1.woff2) format('woff2');
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Instrument Sans';
font-style: normal;
font-weight: 600;
font-stretch: 100%;
font-display: swap;
src: url(/stitch/instrument-sans-2.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
font-family: 'Instrument Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url(/stitch/instrument-sans-1.woff2) format('woff2');
unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Instrument Sans';
font-style: normal;
font-weight: 700;
font-stretch: 100%;
font-display: swap;
src: url(/stitch/instrument-sans-2.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* fallback */
@font-face {
font-family: 'Material Symbols Outlined';
font-style: normal;
font-weight: 100 700;
font-display: block;
src: url(/stitch/material-symbols-1.woff2) format('woff2');
}
.material-symbols-outlined {
font-family: 'Material Symbols Outlined';
font-weight: normal;
font-style: normal;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-webkit-font-feature-settings: 'liga';
-webkit-font-smoothing: antialiased;
}
@tailwind base;
@tailwind components;
@tailwind utilities;
.material-symbols-outlined.home-rail-icon {
font-weight: 300;
font-variation-settings: 'FILL' 0;
}
.nav-item[aria-current="page"] .home-rail-icon {
font-weight: 360;
}
.material-symbols-outlined, .material-symbols-rounded, .material-symbols-sharp, .material-icons {
display: inline-block;
width: 1em;
height: 1em;
line-height: 1 !important;
box-sizing: content-box;
overflow: hidden;
white-space: nowrap;
direction: ltr;
vertical-align: middle;
}
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }
+13
View File
@@ -0,0 +1,13 @@
import type { Metadata } from "next";
import type { ReactNode } from "react";
import "./globals.css";
export const metadata: Metadata = { title: "X × 小红书 动态交互版" };
export default function RootLayout({ children }: { children: ReactNode }) {
return (
<html lang="zh-CN" className="h-full">
<body className="min-h-full flex flex-col bg-light-surface text-light-on-surface font-body antialiased">{children}</body>
</html>
);
}
+6
View File
@@ -0,0 +1,6 @@
import { HomeDesign } from "@/components/home-design";
import { HomeInteractions } from "@/components/home-interactions";
export default function Page() {
return <><HomeDesign /><HomeInteractions /></>;
}
+704
View File
@@ -0,0 +1,704 @@
export function HomeDesign() {
return (
<>
<div className="flex-1 min-h-screen w-full flex bg-light-surface">
{/* Left Navigation Rail (X Design: Full on xl, Icon-Only on sm..lg, Hidden on mobile) */}
<aside className="hidden sm:flex sm:flex-col sm:justify-between sm:items-center xl:items-stretch w-20 xl:w-60 shrink-0 px-gutter-sm xl:px-gutter-md py-gutter-md self-stretch bg-light-surface">
<div className="sticky top-gutter-md flex flex-col items-center xl:items-stretch gap-gutter-xs">
<button type="button" data-nav="home" aria-label="X Home" className="nav-switch inline-flex items-center justify-center w-12 h-12 rounded-full hover:bg-light-surface-container transition-colors duration-state-change">
<svg viewBox="0 0 24 24" className="w-7 h-7 fill-current text-light-on-surface" aria-hidden="true">
<path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"></path>
</svg>
</button>
<nav aria-label="Primary navigation" className="flex flex-col items-center xl:items-stretch gap-gutter-xs">
<button type="button" data-nav="home" aria-current="page" className="nav-switch nav-item inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-title text-title-lg transition-colors duration-state-change text-left">
<span className="material-symbols-outlined home-rail-icon text-headline-lg" aria-hidden="true">home</span>
<span className="hidden xl:inline">Home</span>
</button>
<a href="#explore" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
<span className="material-symbols-outlined home-rail-icon text-headline-lg" aria-hidden="true">search</span>
<span className="hidden xl:inline">Explore</span>
</a>
<a href="#notifications" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
<span className="relative inline-flex">
<span className="material-symbols-outlined home-rail-icon text-headline-lg" aria-hidden="true">notifications</span>
<span className="absolute -top-1 -right-1 inline-flex items-center justify-center w-4 h-4 rounded-full bg-light-tertiary text-light-on-tertiary font-label text-label-sm">2</span>
</span>
<span className="hidden xl:inline">Notifications</span>
</a>
<a href="#follow" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
<span className="material-symbols-outlined home-rail-icon text-headline-lg" aria-hidden="true">person_add</span>
<span className="hidden xl:inline">Follow</span>
</a>
<a href="#chat" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
<span className="material-symbols-outlined home-rail-icon text-headline-lg" aria-hidden="true">mail</span>
<span className="hidden xl:inline">Chat</span>
</a>
<a href="#grok" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
<span className="material-symbols-outlined text-headline-lg" aria-hidden="true">blur_on</span>
<span className="hidden xl:inline">Grok</span>
</a>
<a href="#bookmarks" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
<span className="material-symbols-outlined home-rail-icon text-headline-lg" aria-hidden="true">bookmark_border</span>
<span className="hidden xl:inline">Bookmarks</span>
</a>
<a href="#creator-studio" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
<span className="material-symbols-outlined home-rail-icon text-headline-lg" aria-hidden="true">science</span>
<span className="hidden xl:inline">Creator Studio</span>
</a>
<a href="#premium" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change">
<span className="material-symbols-outlined home-rail-icon text-headline-lg" aria-hidden="true">verified</span>
<span className="hidden xl:inline">Premium</span>
</a>
<button type="button" data-nav="profile" className="nav-switch nav-item inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change text-left">
<span className="material-symbols-outlined home-rail-icon text-headline-lg" aria-hidden="true">person_outline</span>
<span className="hidden xl:inline">Profile</span>
</button>
<button type="button" className="inline-flex items-center justify-center xl:justify-start gap-gutter-lg p-2.5 xl:px-gutter-md xl:py-2.5 rounded-full hover:bg-light-surface-container text-light-on-surface font-body text-title-lg transition-colors duration-state-change text-left">
<span className="material-symbols-outlined home-rail-icon text-headline-lg" aria-hidden="true">pending</span>
<span className="hidden xl:inline">More</span>
</button>
</nav>
<div className="pt-gutter-md xl:pr-gutter-md">
<button type="button" aria-label="Post" className="w-11 h-11 xl:w-full xl:h-auto xl:py-3 xl:px-gutter-xl rounded-full bg-light-primary text-light-on-primary font-label text-label-lg hover:opacity-90 transition-opacity duration-state-change inline-flex items-center justify-center">
<span className="material-symbols-outlined home-rail-icon text-headline-md xl:hidden" aria-hidden="true">edit</span>
<span className="hidden xl:inline">Post</span>
</button>
</div>
</div>
<button type="button" data-nav="profile" className="nav-switch flex items-center justify-center xl:justify-between gap-gutter-sm p-2 xl:p-gutter-md rounded-full hover:bg-light-surface-container bg-light-surface transition-colors duration-state-change text-left">
<div className="flex items-center gap-gutter-md min-w-0">
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-10 h-10 rounded-full object-cover shrink-0" />
<div className="hidden xl:flex flex-col min-w-0">
<span className="font-title text-title-md text-light-on-surface truncate">有点AI思</span>
<span className="font-body text-body-sm text-light-on-surface-variant truncate">@you_dian_ai</span>
</div>
</div>
<span className="hidden xl:inline material-symbols-outlined home-rail-icon text-title-lg text-light-on-surface-variant shrink-0" aria-hidden="true">more_horiz</span>
</button>
</aside>
{/* Center Column: Dynamic Switchable Views (Home Feed <-> User Profile) */}
<main className="flex-1 min-w-0 border-x border-light-outline-variant min-h-screen flex flex-col">
{/* VIEW 1: HOME FEED */}
<div id="view-home" className="flex flex-col">
{/* Sticky Top Feed Tabs & Channel Strip + Column Switcher */}
<header className="sticky top-0 z-20 bg-light-surface/95 border-b border-light-outline-variant">
<div role="tablist" aria-label="Timeline feed" className="grid grid-cols-2 border-b border-light-outline-variant">
<button role="tab" data-feed="for-you" aria-selected="true" className="feed-tab relative py-gutter-md flex items-center justify-center font-title text-title-md text-light-on-surface hover:bg-light-surface-container-low transition-colors duration-state-change">
<span>For you</span>
<span className="tab-indicator absolute bottom-0 w-16 h-1 rounded-full bg-x-blue"></span>
</button>
<button role="tab" data-feed="following" aria-selected="false" className="feed-tab relative py-gutter-md flex items-center justify-center font-title text-title-md text-light-on-surface-variant hover:bg-light-surface-container-low transition-colors duration-state-change">
<span>Following</span>
<span className="tab-indicator hidden absolute bottom-0 w-20 h-1 rounded-full bg-x-blue"></span>
</button>
</div>
{/* Xiaohongshu Channel Filter Pills */}
<div role="tablist" aria-label="内容频道" className="flex items-center gap-gutter-sm px-gutter-lg py-gutter-sm overflow-x-auto no-scrollbar">
<button role="tab" data-category="all" aria-selected="true" className="channel-pill px-gutter-md py-1 rounded-full bg-light-primary text-light-on-primary font-label text-label-md whitespace-nowrap">
<span>推荐</span>
</button>
<button role="tab" data-category="旅行" aria-selected="false" className="channel-pill px-gutter-md py-1 rounded-full bg-light-surface-container text-light-on-surface-variant hover:text-light-on-surface font-label text-label-md whitespace-nowrap">
<span>旅行</span>
</button>
<button role="tab" data-category="游戏" aria-selected="false" className="channel-pill px-gutter-md py-1 rounded-full bg-light-surface-container text-light-on-surface-variant hover:text-light-on-surface font-label text-label-md whitespace-nowrap">
<span>游戏</span>
</button>
<button role="tab" data-category="视频" aria-selected="false" className="channel-pill px-gutter-md py-1 rounded-full bg-light-surface-container text-light-on-surface-variant hover:text-light-on-surface font-label text-label-md whitespace-nowrap">
<span>视频</span>
</button>
<button role="tab" data-category="职场" aria-selected="false" className="channel-pill px-gutter-md py-1 rounded-full bg-light-surface-container text-light-on-surface-variant hover:text-light-on-surface font-label text-label-md whitespace-nowrap">
<span>职场</span>
</button>
<button role="tab" data-category="情感" aria-selected="false" className="channel-pill px-gutter-md py-1 rounded-full bg-light-surface-container text-light-on-surface-variant hover:text-light-on-surface font-label text-label-md whitespace-nowrap">
<span>情感</span>
</button>
</div>
</header>
{/* Responsive Waterfall Grid (2-col on mobile/tablet, 3-col on lg+) */}
<div id="home-note-feed" className="p-gutter-sm sm:p-gutter-md columns-2 lg:columns-3 gap-gutter-md space-y-gutter-md">
<article data-category="游戏" data-following="true" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
<img src="/stitch/fish-game.jpg" alt="彩色手绘小鱼游戏封面" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-body text-body-md text-light-on-surface truncate">这游戏能卖80万美元</h3>
<div className="flex items-center justify-between">
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
<img src="/stitch/bbg-avatar.jpg" alt="BBGame" className="w-4 h-4 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">BBGame</span>
</button>
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="483" aria-label="点赞">
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
<span className="font-body text-body-sm tabular-nums like-count">483</span>
</button>
</div>
</div>
</article>
<article data-category="视频" data-following="true" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
<img src="/stitch/rainy-harbor.jpg" alt="雨夜海港小镇体素场景" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
<span className="absolute top-gutter-sm right-gutter-sm inline-flex items-center justify-center w-6 h-6 rounded-full bg-light-primary/70 text-light-on-primary">
<span className="material-symbols-outlined text-body-md" style={{ fontVariationSettings: "'FILL' 1" }} aria-hidden="true">play_arrow</span>
</span>
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-body text-body-md text-light-on-surface truncate">雨夜海港太治愈</h3>
<div className="flex items-center justify-between">
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
<img src="/stitch/rainy-harbor.jpg" alt="像素造梦师" className="w-4 h-4 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">像素造梦师</span>
</button>
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="1284" aria-label="点赞">
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
<span className="font-body text-body-sm tabular-nums like-count">1284</span>
</button>
</div>
</div>
</article>
<article data-category="情感" data-following="false" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
<img src="/stitch/golden-retriever.jpg" alt="家里新来的小金毛" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-body text-body-md text-light-on-surface truncate">小金毛太粘人啦</h3>
<div className="flex items-center justify-between">
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
<img src="/stitch/golden-retriever.jpg" alt="单棱镜" className="w-4 h-4 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">单棱镜</span>
</button>
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="1520" aria-label="点赞">
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
<span className="font-body text-body-sm tabular-nums like-count">1520</span>
</button>
</div>
</div>
</article>
<article data-category="旅行" data-following="true" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
<img src="/stitch/chengdu.jpg" alt="成都环形城市航拍图" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
<div className="absolute inset-0 bg-light-primary/65 flex flex-col items-center justify-center p-gutter-sm">
<span className="font-headline text-title-lg text-light-on-primary">成都</span>
<span className="font-title text-title-md text-light-on-primary">巨大的“圈”</span>
</div>
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-body text-body-md text-light-on-surface truncate">成都到底有几个圈?</h3>
<div className="flex items-center justify-between">
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
<img src="/stitch/chengdu.jpg" alt="西游兔" className="w-4 h-4 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">西游兔</span>
</button>
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="3936" aria-label="点赞">
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
<span className="font-body text-body-sm tabular-nums like-count">3936</span>
</button>
</div>
</div>
</article>
<article data-category="游戏" data-following="true" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
<img src="/stitch/dungeon.jpg" alt="街机厅的玩家和游戏屏幕" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-body text-body-md text-light-on-surface truncate">独立游戏一周目实录</h3>
<div className="flex items-center justify-between">
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
<img src="/stitch/chengdu.jpg" alt="阿宅玩游戏" className="w-4 h-4 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">阿宅玩游戏</span>
</button>
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="742" aria-label="点赞">
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
<span className="font-body text-body-sm tabular-nums like-count">742</span>
</button>
</div>
</div>
</article>
<article data-category="职场" data-following="true" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant p-gutter-sm flex flex-col gap-gutter-xs">
<span className="font-title text-title-md text-light-on-surface">AI编程助手</span>
<img src="/stitch/ai-tools.jpg" alt="桌面上的笔记本电脑" className="w-full h-auto rounded-sm object-cover" />
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-body text-body-md text-light-on-surface truncate">AI助手实测对比</h3>
<div className="flex items-center justify-between">
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-4 h-4 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">有点AI思</span>
</button>
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="612" aria-label="点赞">
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
<span className="font-body text-body-sm tabular-nums like-count">612</span>
</button>
</div>
</div>
</article>
<article data-category="旅行" data-following="false" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
<img src="/stitch/skyline.jpg" alt="夜色雾气中的城市天际线" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-body text-body-md text-light-on-surface truncate">夜幕降临的城市天际线</h3>
<div className="flex items-center justify-between">
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
<img src="/stitch/rainy-harbor.jpg" alt="Wingman" className="w-4 h-4 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">Wingman</span>
</button>
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="528" aria-label="点赞">
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
<span className="font-body text-body-sm tabular-nums like-count">528</span>
</button>
</div>
</div>
</article>
<article data-category="职场" data-following="true" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
<img src="/stitch/workspace.jpg" alt="光线照进写字台" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-body text-body-md text-light-on-surface truncate">午后光影工作台灵感</h3>
<div className="flex items-center justify-between">
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-4 h-4 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">有点AI思</span>
</button>
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="true" data-count="842" aria-label="点赞">
<span className="material-symbols-outlined text-body-md like-icon text-light-error" style={{ fontVariationSettings: "'FILL' 1" }} aria-hidden="true">favorite</span>
<span className="font-body text-body-sm tabular-nums like-count">842</span>
</button>
</div>
</div>
</article>
<article data-category="旅行" data-following="false" className="note-card break-inside-avoid flex flex-col gap-gutter-xs group cursor-pointer">
<div className="relative overflow-hidden rounded-md bg-light-surface-container-low border border-light-outline-variant">
<img src="/stitch/film-walk.jpg" alt="街头漫步摄影" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-body text-body-md text-light-on-surface truncate">城市街头胶片漫步</h3>
<div className="flex items-center justify-between">
<button type="button" data-nav="profile" className="nav-switch flex items-center gap-gutter-xs min-w-0 hover:underline">
<img src="/stitch/chengdu.jpg" alt="胶片日志" className="w-4 h-4 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">胶片日志</span>
</button>
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="946" aria-label="点赞">
<span className="material-symbols-outlined text-body-md like-icon" aria-hidden="true">favorite_border</span>
<span className="font-body text-body-sm tabular-nums like-count">946</span>
</button>
</div>
</div>
</article>
</div>
</div>
{/* VIEW 2: USER PROFILE */}
<div id="view-profile" className="hidden flex-col">
{/* Sticky Top Profile Bar (Back Arrow returns to Home) */}
<header className="sticky top-0 z-20 bg-light-surface/95 border-b border-light-outline-variant px-gutter-lg py-gutter-sm flex items-center justify-between gap-gutter-md">
<div className="flex items-center gap-gutter-lg min-w-0">
<button type="button" data-nav="home" aria-label="返回首页" className="nav-switch inline-flex items-center justify-center w-9 h-9 rounded-full hover:bg-light-surface-container text-light-on-surface transition-colors duration-state-change shrink-0">
<span className="material-symbols-outlined text-headline-md" aria-hidden="true">arrow_back</span>
</button>
<div className="flex flex-col min-w-0">
<div className="flex items-center gap-gutter-xs">
<h1 className="font-headline text-headline-md text-light-on-surface truncate">有点AI思</h1>
<span className="material-symbols-outlined text-title-lg text-x-blue shrink-0" style={{ fontVariationSettings: "'FILL' 1" }} aria-label="已认证">verified</span>
</div>
<span className="font-body text-body-sm text-light-on-surface-variant tabular-nums">128 篇笔记</span>
</div>
</div>
<div className="flex items-center gap-gutter-xs shrink-0">
<button type="button" aria-label="搜索TA的笔记" className="inline-flex items-center justify-center w-9 h-9 rounded-full hover:bg-light-surface-container text-light-on-surface transition-colors duration-state-change">
<span className="material-symbols-outlined text-headline-md" aria-hidden="true">search</span>
</button>
<button type="button" aria-label="Grok 总结主页" className="inline-flex items-center justify-center w-9 h-9 rounded-full hover:bg-light-surface-container text-light-on-surface transition-colors duration-state-change">
<span className="material-symbols-outlined text-headline-md" aria-hidden="true">blur_on</span>
</button>
</div>
</header>
{/* Cover Banner & Overlapping Avatar + Actions */}
<section aria-label="个人资料头部">
<div className="h-48 w-full overflow-hidden bg-light-surface-container">
<img src="/stitch/profile-banner.jpg" alt="个人主页背景封面" className="w-full h-full object-cover" />
</div>
<div className="px-gutter-lg pb-gutter-md flex flex-col gap-gutter-md">
<div className="flex items-end justify-between gap-gutter-md">
<div className="-mt-14 w-28 h-28 rounded-full border-4 border-light-surface overflow-hidden bg-light-surface shrink-0">
<img src="/stitch/profile-avatar.jpg" alt="有点AI思头像" className="w-full h-full object-cover" />
</div>
<div className="relative flex items-center gap-gutter-sm pt-gutter-sm">
<button id="profile-more-btn" type="button" aria-label="更多选项" aria-expanded="false" aria-haspopup="menu" className="inline-flex items-center justify-center w-9 h-9 rounded-full border border-light-outline bg-light-surface hover:bg-light-surface-container text-light-on-surface transition-colors duration-state-change">
<span className="material-symbols-outlined text-title-lg" aria-hidden="true">more_horiz</span>
</button>
<div id="profile-more-menu" role="menu" className="hidden absolute right-0 top-12 z-30 w-60 rounded-lg bg-light-surface border border-light-outline-variant shadow-lg py-gutter-xs">
<button id="open-about-btn" type="button" role="menuitem" className="w-full px-gutter-lg py-2.5 flex items-center gap-gutter-md text-left hover:bg-light-surface-container-low text-light-on-surface font-title text-title-md">
<span className="material-symbols-outlined text-title-lg text-light-on-surface" aria-hidden="true">info</span>
<span>About this account</span>
</button>
<button type="button" role="menuitem" className="w-full px-gutter-lg py-2.5 flex items-center gap-gutter-md text-left hover:bg-light-surface-container-low text-light-on-surface font-title text-title-md">
<span className="material-symbols-outlined text-title-lg text-light-on-surface" aria-hidden="true">chat_bubble_outline</span>
<span>View Topics</span>
</button>
<button type="button" role="menuitem" className="w-full px-gutter-lg py-2.5 flex items-center gap-gutter-md text-left hover:bg-light-surface-container-low text-light-on-surface font-title text-title-md">
<span className="material-symbols-outlined text-title-lg text-light-on-surface" aria-hidden="true">link</span>
<span>Copy link to profile</span>
</button>
</div>
<button type="button" aria-label="发送私信" className="inline-flex items-center justify-center w-9 h-9 rounded-full border border-light-outline bg-light-surface hover:bg-light-surface-container text-light-on-surface transition-colors duration-state-change">
<span className="material-symbols-outlined text-title-lg" aria-hidden="true">mail</span>
</button>
<button type="button" aria-label="开启更新提醒" className="inline-flex items-center justify-center w-9 h-9 rounded-full border border-light-outline bg-light-surface hover:bg-light-surface-container text-light-on-surface transition-colors duration-state-change">
<span className="material-symbols-outlined text-title-lg" aria-hidden="true">notifications_none</span>
</button>
<button id="profile-follow-btn" type="button" data-following="false" className="px-gutter-lg py-2 rounded-full bg-light-primary text-light-on-primary font-label text-label-md hover:opacity-90 transition-opacity duration-state-change whitespace-nowrap">
<span>Follow</span>
</button>
</div>
</div>
<div className="flex flex-col gap-gutter-sm">
<div className="flex flex-col gap-gutter-xs">
<div className="flex items-center gap-gutter-xs">
<h2 className="font-headline text-headline-lg text-light-on-surface">有点AI思</h2>
<span className="material-symbols-outlined text-title-lg text-x-blue" style={{ fontVariationSettings: "'FILL' 1" }} aria-label="已认证">verified</span>
</div>
<div className="flex flex-wrap items-center gap-gutter-sm font-body text-body-sm text-light-on-surface-variant">
<span>@you_dian_ai</span>
<span aria-hidden="true">·</span>
<span className="tabular-nums">小红书号:18665824520</span>
<span aria-hidden="true">·</span>
<span>IP属地:四川</span>
</div>
</div>
<p className="font-body text-body-md text-light-on-surface max-w-prose text-pretty">
Software is eating the world, AI is eating software. 分享 AI 产品拆解、独立开发实验与数字生活灵感。
</p>
<div className="flex flex-wrap items-center gap-gutter-lg font-body text-body-sm text-light-on-surface-variant">
<span className="inline-flex items-center gap-gutter-xs">
<span className="material-symbols-outlined text-title-md" aria-hidden="true">location_on</span>
<span>成都 · 四川</span>
</span>
<button id="joined-date-btn" type="button" className="inline-flex items-center gap-gutter-xs hover:underline text-light-on-surface-variant">
<span className="material-symbols-outlined text-title-md" aria-hidden="true">calendar_month</span>
<span>Joined April 2022</span>
<span className="material-symbols-outlined text-title-md" aria-hidden="true">chevron_right</span>
</button>
</div>
<div className="flex flex-wrap items-center gap-gutter-lg pt-gutter-xs">
<span className="inline-flex items-baseline gap-gutter-xs">
<span className="font-title text-title-md text-light-on-surface tabular-nums">10</span>
<span className="font-body text-body-sm text-light-on-surface-variant">关注</span>
</span>
<span className="inline-flex items-baseline gap-gutter-xs">
<span className="font-title text-title-md text-light-on-surface tabular-nums">87</span>
<span className="font-body text-body-sm text-light-on-surface-variant">粉丝</span>
</span>
<span className="inline-flex items-baseline gap-gutter-xs">
<span className="font-title text-title-md text-light-on-surface tabular-nums">2,987</span>
<span className="font-body text-body-sm text-light-on-surface-variant">获赞与收藏</span>
</span>
</div>
</div>
</div>
</section>
{/* Profile Content Tabs */}
<div role="tablist" aria-label="个人主页内容分类" className="grid grid-cols-4 border-b border-light-outline-variant bg-light-surface sticky top-14 z-10">
<button role="tab" data-tab="notes" aria-selected="true" className="profile-tab relative py-gutter-md flex items-center justify-center font-title text-title-md text-light-on-surface hover:bg-light-surface-container-low transition-colors duration-state-change">
<span>笔记</span>
<span className="tab-indicator absolute bottom-0 w-12 h-1 rounded-full bg-x-blue"></span>
</button>
<button role="tab" data-tab="saved" aria-selected="false" className="profile-tab relative py-gutter-md flex items-center justify-center font-title text-title-md text-light-on-surface-variant hover:bg-light-surface-container-low transition-colors duration-state-change">
<span>收藏</span>
<span className="tab-indicator hidden absolute bottom-0 w-12 h-1 rounded-full bg-x-blue"></span>
</button>
<button role="tab" data-tab="likes" aria-selected="false" className="profile-tab relative py-gutter-md flex items-center justify-center font-title text-title-md text-light-on-surface-variant hover:bg-light-surface-container-low transition-colors duration-state-change">
<span>点赞</span>
<span className="tab-indicator hidden absolute bottom-0 w-12 h-1 rounded-full bg-x-blue"></span>
</button>
<button role="tab" data-tab="history" aria-selected="false" className="profile-tab relative py-gutter-md flex items-center justify-center font-title text-title-md text-light-on-surface-variant hover:bg-light-surface-container-low transition-colors duration-state-change">
<span>浏览记录</span>
<span className="tab-indicator hidden absolute bottom-0 w-16 h-1 rounded-full bg-x-blue"></span>
</button>
</div>
{/* Profile Panel: 笔记 */}
<section id="panel-notes" role="tabpanel" className="p-gutter-lg columns-2 lg:columns-3 gap-gutter-md space-y-gutter-md">
<article className="break-inside-avoid flex flex-col gap-gutter-sm group cursor-pointer">
<div className="relative overflow-hidden rounded-lg bg-light-surface-container-low border border-light-outline-variant">
<img src="/stitch/workspace.jpg" alt="彩色玻璃光影桌面" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
<span className="absolute top-gutter-sm left-gutter-sm px-gutter-sm py-0.5 rounded-full bg-light-primary/75 text-light-on-primary font-label text-label-sm">置顶</span>
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-title text-title-md text-light-on-surface truncate">午后光影里的工作台灵感</h3>
<div className="flex items-center justify-between pt-gutter-xs">
<div className="flex items-center gap-gutter-xs min-w-0">
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-5 h-5 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">有点AI思</span>
</div>
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-error shrink-0" data-liked="true" data-count="842" aria-label="点赞">
<span className="material-symbols-outlined text-title-md like-icon" style={{ fontVariationSettings: "'FILL' 1" }} aria-hidden="true">favorite</span>
<span className="font-body text-body-sm tabular-nums like-count">842</span>
</button>
</div>
</div>
</article>
<article className="break-inside-avoid flex flex-col gap-gutter-sm group cursor-pointer">
<div className="relative overflow-hidden rounded-lg bg-light-surface-container-low border border-light-outline-variant p-gutter-md flex flex-col gap-gutter-sm">
<span className="font-title text-title-md text-light-on-surface">AI 编程助手实测对比</span>
<img src="/stitch/ai-tools.jpg" alt="AI 编程助手实测插画" className="w-full h-auto rounded-md object-cover" />
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-title text-title-md text-light-on-surface truncate">2026 个人开发者工作流</h3>
<div className="flex items-center justify-between pt-gutter-xs">
<div className="flex items-center gap-gutter-xs min-w-0">
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-5 h-5 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">有点AI思</span>
</div>
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="615" aria-label="点赞">
<span className="material-symbols-outlined text-title-md like-icon" aria-hidden="true">favorite_border</span>
<span className="font-body text-body-sm tabular-nums like-count">615</span>
</button>
</div>
</div>
</article>
<article className="break-inside-avoid flex flex-col gap-gutter-sm group cursor-pointer">
<div className="relative overflow-hidden rounded-lg bg-light-surface-container-low border border-light-outline-variant">
<img src="/stitch/rainy-harbor.jpg" alt="雨夜海港小镇体素场景" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
<span className="absolute top-gutter-sm right-gutter-sm inline-flex items-center justify-center w-6 h-6 rounded-full bg-light-primary/70 text-light-on-primary">
<span className="material-symbols-outlined text-body-md" style={{ fontVariationSettings: "'FILL' 1" }} aria-hidden="true">play_arrow</span>
</span>
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-title text-title-md text-light-on-surface truncate">用体素引擎做海港微缩模型</h3>
<div className="flex items-center justify-between pt-gutter-xs">
<div className="flex items-center gap-gutter-xs min-w-0">
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-5 h-5 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">有点AI思</span>
</div>
<button type="button" className="like-btn inline-flex items-center gap-gutter-xs text-light-on-surface-variant hover:text-light-error shrink-0" data-liked="false" data-count="429" aria-label="点赞">
<span className="material-symbols-outlined text-title-md like-icon" aria-hidden="true">favorite_border</span>
<span className="font-body text-body-sm tabular-nums like-count">429</span>
</button>
</div>
</div>
</article>
</section>
{/* Profile Panel: 收藏 */}
<section id="panel-saved" role="tabpanel" className="hidden p-gutter-lg columns-2 lg:columns-3 gap-gutter-md space-y-gutter-md">
<article className="break-inside-avoid flex flex-col gap-gutter-sm group cursor-pointer">
<div className="relative overflow-hidden rounded-lg bg-light-surface-container-low border border-light-outline-variant">
<img src="/stitch/stairs.jpg" alt="建筑楼梯光影摄影" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-title text-title-md text-light-on-surface truncate">极简楼梯光影构图参考</h3>
<div className="flex items-center justify-between pt-gutter-xs">
<div className="flex items-center gap-gutter-xs min-w-0">
<img src="/stitch/rainy-harbor.jpg" alt="建筑笔记" className="w-5 h-5 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">建筑笔记</span>
</div>
<span className="font-body text-body-sm text-light-on-surface-variant tabular-nums">1.2K</span>
</div>
</div>
</article>
</section>
{/* Profile Panel: 点赞 */}
<section id="panel-likes" role="tabpanel" className="hidden p-gutter-lg columns-2 lg:columns-3 gap-gutter-md space-y-gutter-md">
<article className="break-inside-avoid flex flex-col gap-gutter-sm group cursor-pointer">
<div className="relative overflow-hidden rounded-lg bg-light-surface-container-low border border-light-outline-variant">
<img src="/stitch/golden-retriever.jpg" alt="小金毛日常" className="w-full h-auto object-cover group-hover:scale-105 transition-transform duration-state-change" />
</div>
<div className="px-gutter-xs flex flex-col gap-gutter-xs">
<h3 className="font-title text-title-md text-light-on-surface truncate">家里新来的小金毛太粘人</h3>
<div className="flex items-center justify-between pt-gutter-xs">
<div className="flex items-center gap-gutter-xs min-w-0">
<img src="/stitch/golden-retriever.jpg" alt="单棱镜" className="w-5 h-5 rounded-full object-cover shrink-0" />
<span className="font-body text-body-sm text-light-on-surface-variant truncate">单棱镜</span>
</div>
<span className="font-body text-body-sm text-light-error tabular-nums">1,520</span>
</div>
</div>
</article>
</section>
{/* Profile Panel: 浏览记录 */}
<section id="panel-history" role="tabpanel" className="hidden p-gutter-lg flex flex-col items-center justify-center gap-gutter-sm py-section text-center">
<span className="material-symbols-outlined text-headline-lg text-light-on-surface-variant" aria-hidden="true">history</span>
<p className="font-title text-title-md text-light-on-surface">仅自己可见</p>
<p className="font-body text-body-sm text-light-on-surface-variant max-w-prose">近期浏览的笔记记录会保存在这里,方便随时回看。</p>
</section>
</div>
</main>
{/* Right Discovery Sidebar (X Design: Visible md+, Hidden below 768px) */}
<aside className="hidden md:flex md:flex-col md:justify-between gap-gutter-lg w-72 xl:w-80 shrink-0 px-gutter-lg xl:px-gutter-xl py-gutter-md self-stretch">
<div className="flex flex-col gap-gutter-lg">
<div className="sticky top-0 pt-gutter-xs pb-gutter-xs bg-light-surface z-10">
<form role="search" className="flex items-center gap-gutter-sm px-gutter-lg py-2.5 rounded-full bg-light-surface border border-light-outline focus-within:border-light-tertiary">
<span className="material-symbols-outlined text-title-lg text-light-on-surface-variant" aria-hidden="true">search</span>
<input type="search" aria-label="Search X" placeholder="Search" className="w-full bg-transparent border-none p-0 font-body text-body-md text-light-on-surface placeholder:text-light-on-surface-variant focus:ring-0" />
</form>
</div>
<section aria-label="Subscribe to Premium" className="rounded-lg border border-light-outline-variant p-gutter-lg flex flex-col gap-gutter-sm bg-light-surface">
<div className="flex items-center justify-between gap-gutter-xs">
<h2 className="font-headline text-title-lg text-light-on-surface whitespace-nowrap">Subscribe to Premium</h2>
<span className="px-gutter-sm py-0.5 rounded-full bg-light-primary-container text-light-on-primary-container font-label text-label-sm whitespace-nowrap shrink-0">50% off</span>
</div>
<p className="font-body text-body-md text-light-on-surface">Get rid of ads, see your analytics, boost your replies and unlock 20+ features.</p>
<div className="pt-gutter-xs">
<button type="button" className="px-gutter-lg py-2 rounded-full bg-light-tertiary text-light-on-tertiary font-label text-label-lg hover:opacity-90">
<span>Subscribe</span>
</button>
</div>
</section>
<section aria-label="You might like" className="rounded-lg border border-light-outline-variant p-gutter-lg flex flex-col gap-gutter-md bg-light-surface">
<h2 className="font-headline text-headline-md text-light-on-surface">You might like</h2>
<div className="flex items-center justify-between gap-gutter-sm">
<div className="flex items-center gap-gutter-md min-w-0">
<img src="/stitch/bbg-avatar.jpg" alt="Low Quality Memes" className="w-10 h-10 rounded-full object-cover shrink-0" />
<div className="flex flex-col min-w-0">
<span className="font-title text-title-md text-light-on-surface truncate">Low Quality Memes</span>
<span className="font-body text-body-sm text-light-on-surface-variant truncate">@ipostlqmemes</span>
</div>
</div>
<button type="button" className="follow-btn px-gutter-lg py-1.5 rounded-full bg-light-primary text-light-on-primary font-label text-label-md shrink-0" data-following="false">
<span>Follow</span>
</button>
</div>
<div className="flex items-center justify-between gap-gutter-sm">
<div className="flex items-center gap-gutter-md min-w-0">
<img src="/stitch/ai-tools.jpg" alt="极客小分队" className="w-10 h-10 rounded-full object-cover shrink-0" />
<div className="flex flex-col min-w-0">
<span className="font-title text-title-md text-light-on-surface truncate">极客小分队</span>
<span className="font-body text-body-sm text-light-on-surface-variant truncate">@geek_squad_cn</span>
</div>
</div>
<button type="button" className="follow-btn px-gutter-lg py-1.5 rounded-full bg-light-primary text-light-on-primary font-label text-label-md shrink-0" data-following="false">
<span>Follow</span>
</button>
</div>
<a href="#show-more-people" className="font-body text-body-md text-light-tertiary hover:underline">Show more</a>
</section>
<section aria-label="What&#x27;s happening" className="rounded-lg border border-light-outline-variant p-gutter-lg flex flex-col gap-gutter-md bg-light-surface">
<h2 className="font-headline text-headline-md text-light-on-surface">What&#39;s happening</h2>
<div className="flex flex-col gap-gutter-md">
<div className="flex flex-col">
<span className="font-body text-body-sm text-light-on-surface-variant">Technology · Trending</span>
<span className="font-title text-title-md text-light-on-surface">#AICoding2026</span>
</div>
<div className="flex flex-col">
<span className="font-body text-body-sm text-light-on-surface-variant">Design · Trending</span>
<span className="font-title text-title-md text-light-on-surface">小红书瀑布流</span>
</div>
<a href="#show-more" className="font-body text-body-md text-light-tertiary hover:underline">Show more</a>
</div>
</section>
</div>
<footer className="pt-gutter-md pb-gutter-sm flex flex-wrap gap-x-gutter-md gap-y-gutter-xs font-body text-body-sm text-light-on-surface-variant">
<a href="#terms" className="hover:underline">Terms of Service</a>
<a href="#privacy" className="hover:underline">Privacy Policy</a>
<a href="#cookies" className="hover:underline">Cookie Policy</a>
<span>© 2026 X Corp.</span>
</footer>
</aside>
</div>
{/* About This Account Modal */}
<div id="about-modal" role="dialog" aria-modal="true" aria-labelledby="about-modal-title" className="hidden fixed inset-0 z-40 bg-light-primary/50 flex items-center justify-center p-gutter-lg">
<div className="w-full max-w-md rounded-xl bg-light-surface border border-light-outline-variant shadow-xl p-gutter-xl flex flex-col gap-gutter-lg">
<div className="flex items-center justify-between">
<h2 id="about-modal-title" className="font-headline text-headline-md text-light-on-surface">About this account</h2>
<button id="close-about-btn" type="button" aria-label="关闭弹窗" className="inline-flex items-center justify-center w-8 h-8 rounded-full hover:bg-light-surface-container text-light-on-surface">
<span className="material-symbols-outlined text-title-lg" aria-hidden="true">close</span>
</button>
</div>
<div className="flex items-center gap-gutter-md">
<img src="/stitch/profile-avatar.jpg" alt="有点AI思" className="w-12 h-12 rounded-full object-cover shrink-0" />
<div className="flex flex-col">
<span className="font-title text-title-lg text-light-on-surface">有点AI思</span>
<span className="font-body text-body-sm text-light-on-surface-variant">@you_dian_ai · 小红书号 18665824520</span>
</div>
</div>
<div className="flex flex-col gap-gutter-md border-t border-light-outline-variant pt-gutter-md">
<div className="flex items-center gap-gutter-md">
<span className="material-symbols-outlined text-title-lg text-light-on-surface-variant" aria-hidden="true">calendar_month</span>
<div className="flex flex-col">
<span className="font-title text-title-md text-light-on-surface">Date joined</span>
<span className="font-body text-body-sm text-light-on-surface-variant">April 2022</span>
</div>
</div>
<div className="flex items-center gap-gutter-md">
<span className="material-symbols-outlined text-title-lg text-light-on-surface-variant" aria-hidden="true">public</span>
<div className="flex flex-col">
<span className="font-title text-title-md text-light-on-surface">Account based in</span>
<span className="font-body text-body-sm text-light-on-surface-variant">Sichuan, China (IP属地:四川)</span>
</div>
</div>
<div className="flex items-center gap-gutter-md">
<span className="material-symbols-outlined text-title-lg text-x-blue" style={{ fontVariationSettings: "'FILL' 1" }} aria-hidden="true">verified</span>
<div className="flex flex-col">
<span className="font-title text-title-md text-light-on-surface">Verified</span>
<span className="font-body text-body-sm text-light-on-surface-variant">Subscribed since March 2024</span>
</div>
</div>
</div>
</div>
</div>
{/* Floating Bottom-Right Dock */}
<div className="hidden md:flex fixed bottom-gutter-lg right-gutter-lg z-30 flex-col gap-gutter-sm">
<button type="button" aria-label="Open Grok" className="inline-flex items-center justify-center w-11 h-11 rounded-md bg-light-surface border border-light-outline shadow-sm text-light-on-surface hover:bg-light-surface-container-low">
<span className="material-symbols-outlined text-headline-md" aria-hidden="true">blur_on</span>
</button>
<button type="button" aria-label="Open Messages" className="inline-flex items-center justify-center w-11 h-11 rounded-md bg-light-surface border border-light-outline shadow-sm text-light-on-surface hover:bg-light-surface-container-low">
<span className="material-symbols-outlined text-headline-md" aria-hidden="true">mail</span>
</button>
</div>
</>
);
}
+154
View File
@@ -0,0 +1,154 @@
"use client";
import { useEffect } from "react";
function selectTab(button: HTMLElement, selector: string) {
document.querySelectorAll<HTMLElement>(selector).forEach((tab) => {
const active = tab === button;
tab.setAttribute("aria-selected", String(active));
tab.classList.toggle("text-light-on-surface", active);
tab.classList.toggle("text-light-on-surface-variant", !active);
tab.querySelector(".tab-indicator")?.classList.toggle("hidden", !active);
});
}
export function HomeInteractions() {
useEffect(() => {
const byId = (id: string) => document.getElementById(id);
const home = byId("view-home");
const profile = byId("view-profile");
const menu = byId("profile-more-menu");
const menuButton = byId("profile-more-btn");
const dialog = byId("about-modal");
let feed = "for-you";
let category = "all";
function switchView(view: string) {
const homeActive = view === "home";
home?.classList.toggle("hidden", !homeActive);
home?.classList.toggle("flex", homeActive);
profile?.classList.toggle("hidden", homeActive);
profile?.classList.toggle("flex", !homeActive);
document.querySelectorAll<HTMLElement>(".nav-item").forEach((item) => {
const active = item.dataset.nav === view;
if (active) item.setAttribute("aria-current", "page");
else item.removeAttribute("aria-current");
item.classList.toggle("font-title", active);
item.classList.toggle("font-body", !active);
});
window.scrollTo({ top: 0, behavior: "smooth" });
}
function updateCards() {
document.querySelectorAll<HTMLElement>("#home-note-feed .note-card").forEach((card) => {
const categoryMatches = category === "all" || card.dataset.category === category;
const feedMatches = feed === "for-you" || card.dataset.following === "true";
card.style.display = categoryMatches && feedMatches ? "" : "none";
});
}
function changeChannel(button: HTMLElement) {
category = button.dataset.category ?? "all";
document.querySelectorAll(".channel-pill").forEach((pill) => {
const active = pill === button;
pill.setAttribute("aria-selected", String(active));
pill.classList.toggle("bg-light-primary", active);
pill.classList.toggle("text-light-on-primary", active);
pill.classList.toggle("bg-light-surface-container", !active);
pill.classList.toggle("text-light-on-surface-variant", !active);
});
updateCards();
}
function toggleFollow(button: HTMLElement) {
const following = button.dataset.following !== "true";
button.dataset.following = String(following);
for (const name of ["border", "border-light-outline", "bg-light-surface", "text-light-on-surface"]) {
button.classList.toggle(name, following);
}
for (const name of ["bg-light-primary", "text-light-on-primary"]) {
button.classList.toggle(name, !following);
}
const label = button.querySelector("span");
if (label) label.textContent = following ? "Following" : "Follow";
}
function toggleLike(button: HTMLElement) {
const liked = button.dataset.liked !== "true";
const count = Math.max(0, Number(button.dataset.count ?? "0") + (liked ? 1 : -1));
button.dataset.liked = String(liked);
button.dataset.count = String(count);
button.setAttribute("aria-pressed", String(liked));
button.classList.toggle("text-light-error", liked);
button.classList.toggle("text-light-on-surface-variant", !liked);
const icon = button.querySelector<HTMLElement>(".like-icon");
if (icon) {
icon.textContent = liked ? "favorite" : "favorite_border";
icon.style.fontVariationSettings = liked ? "'FILL' 1" : "'FILL' 0";
}
const countLabel = button.querySelector(".like-count");
if (countLabel) countLabel.textContent = String(count);
}
function setMenu(open: boolean) {
menu?.classList.toggle("hidden", !open);
menuButton?.setAttribute("aria-expanded", String(open));
}
function handleClick(event: MouseEvent) {
const target = event.target;
if (!(target instanceof Element)) return;
const button = target.closest<HTMLElement>("button");
if (button === menuButton && menu) {
setMenu(menu.classList.contains("hidden"));
return;
}
if (!menu?.contains(target)) setMenu(false);
if (target === dialog || button?.id === "close-about-btn") {
dialog?.classList.add("hidden");
return;
}
if (!button) return;
if (button.matches(".nav-switch") && button.dataset.nav) {
switchView(button.dataset.nav);
} else if (button.matches(".feed-tab")) {
feed = button.dataset.feed ?? "for-you";
selectTab(button, ".feed-tab");
updateCards();
} else if (button.matches(".channel-pill")) {
changeChannel(button);
} else if (button.matches(".profile-tab")) {
selectTab(button, ".profile-tab");
for (const panel of ["notes", "saved", "likes", "history"]) {
byId("panel-" + panel)?.classList.toggle("hidden", panel !== button.dataset.tab);
}
} else if (button.id === "profile-follow-btn") {
toggleFollow(button);
} else if (button.matches(".like-btn")) {
toggleLike(button);
} else if (button.id === "open-about-btn" || button.id === "joined-date-btn") {
setMenu(false);
dialog?.classList.remove("hidden");
}
}
function handleKey(event: KeyboardEvent) {
if (event.key === "Escape") {
setMenu(false);
dialog?.classList.add("hidden");
}
}
document.addEventListener("click", handleClick);
document.addEventListener("keydown", handleKey);
return () => {
document.removeEventListener("click", handleClick);
document.removeEventListener("keydown", handleKey);
};
}, []);
return null;
}
+8
View File
@@ -0,0 +1,8 @@
import type { NextConfig } from "next";
const config: NextConfig = {
agentRules: false,
devIndicators: false,
};
export default config;
+25
View File
@@ -0,0 +1,25 @@
{
"name": "@bedrock/home",
"private": true,
"scripts": {
"dev": "next dev --hostname 127.0.0.1 --port 3000",
"build": "next build",
"start": "next start --hostname 127.0.0.1 --port 3000"
},
"dependencies": {
"next": "16.4.6",
"react": "19.3.1",
"react-dom": "19.3.1"
},
"devDependencies": {
"@types/node": "22.20.7",
"@types/react": "19.3.0",
"@types/react-dom": "19.3.0",
"typescript": "5.9.3",
"@tailwindcss/container-queries": "0.1.1",
"@tailwindcss/forms": "0.5.10",
"autoprefixer": "10.4.21",
"postcss": "8.5.34",
"tailwindcss": "3.4.17"
}
}
+6
View File
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
+12
View File
@@ -0,0 +1,12 @@
Five original design images were embedded in the shared Stitch screen.
The following Unsplash photos are sample content used under the Unsplash License
https://unsplash.com/license
golden-retriever.jpg https://unsplash.com/photos/brown-dog-m07bsa3nG_4
dungeon.jpg https://unsplash.com/photos/a-group-of-people-playing-video-games-in-a-room-TobedMw621U
ai-tools.jpg https://unsplash.com/photos/a-laptop-computer-sitting-on-top-of-a-desk-ysZnFnexwRE
skyline.jpg https://unsplash.com/photos/a-view-of-a-city-at-night-from-the-top-of-a-building-xuNtZ_hEAhY
workspace.jpg https://unsplash.com/s/photos/writers-desk
film-walk.jpg https://unsplash.com/photos/a-group-of-people-walking-across-a-cross-walk-yCFKOJ5-F6U
profile-banner.jpg https://unsplash.com/photos/a-view-of-a-city-with-mountains-in-the-background-mxWViyBwOBM
stairs.jpg https://unsplash.com/photos/shadow-and-sunlight-cast-upon-a-concrete-staircase-xDV6YuFBkAo
Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.
Binary file not shown.
@@ -0,0 +1,93 @@
Copyright 2022 The Instrument Sans Project Authors (https://github.com/Instrument/instrument-sans)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.
@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

+93
View File
@@ -0,0 +1,93 @@
const forms = require("@tailwindcss/forms");
const containerQueries = require("@tailwindcss/container-queries");
module.exports = {
content: { relative: true, files: ["./app/**/*.tsx", "./components/**/*.{ts,tsx}"] },
plugins: [forms, containerQueries],
...{
darkMode: 'class',
theme: {
extend: {
colors: {
'x-blue': '#1D9BF0',
'x-blue-dark': '#0B7BC1',
'light-primary': '#0F1419',
'light-on-primary': '#FFFFFF',
'light-primary-container': '#E8F5FD',
'light-on-primary-container': '#0A74B7',
'light-secondary': '#536471',
'light-on-secondary': '#FFFFFF',
'light-secondary-container': '#EFF3F4',
'light-on-secondary-container': '#0F1419',
'light-tertiary': '#0B7BC1',
'light-on-tertiary': '#FFFFFF',
'light-error': '#F4212E',
'light-on-error': '#131313',
'light-background': '#FFFFFF',
'light-on-background': '#0F1419',
'light-surface': '#FFFFFF',
'light-surface-container-low': '#F7F9F9',
'light-surface-container': '#EFF3F4',
'light-surface-container-high': '#E7E9EA',
'light-on-surface': '#0F1419',
'light-on-surface-variant': '#536471',
'light-outline': '#CFD9DE',
'light-outline-variant': '#EFF3F4',
'dark-primary': '#EFF3F4',
'dark-on-primary': '#0F1419',
'dark-surface': '#000000',
'dark-surface-container-low': '#16181C',
'dark-surface-container': '#202327',
'dark-on-surface': '#E7E9EA',
'dark-on-surface-variant': '#71767B',
'dark-outline': '#2F3336',
'dark-outline-variant': '#2F3336',
},
borderRadius: {
'sm': '6px',
'DEFAULT': '10px',
'md': '12px',
'lg': '16px',
'xl': '20px',
'full': '9999px',
},
spacing: {
'gutter-xs': '4px',
'gutter-sm': '8px',
'gutter-md': '12px',
'gutter-lg': '16px',
'gutter-xl': '24px',
'section': '32px',
'page-margin': '16px',
},
fontFamily: {
'headline': ['"Instrument Sans"', 'sans-serif'],
'title': ['"Instrument Sans"', 'sans-serif'],
'body': ['"Instrument Sans"', 'sans-serif'],
'label': ['"Instrument Sans"', 'sans-serif'],
},
fontSize: {
'headline-lg': ['22px', { lineHeight: '28px', letterSpacing: '-0.2px', fontWeight: '700' }],
'headline-md': ['20px', { lineHeight: '24px', letterSpacing: '-0.1px', fontWeight: '700' }],
'title-lg': ['17px', { lineHeight: '22px', letterSpacing: '0px', fontWeight: '600' }],
'title-md': ['15px', { lineHeight: '20px', letterSpacing: '0px', fontWeight: '600' }],
'body-lg': ['19px', { lineHeight: '24px', letterSpacing: '0px', fontWeight: '400' }],
'body-md': ['15px', { lineHeight: '20px', letterSpacing: '0px', fontWeight: '400' }],
'body-sm': ['13px', { lineHeight: '16px', letterSpacing: '0px', fontWeight: '400' }],
'label-lg': ['15px', { lineHeight: '20px', letterSpacing: '0px', fontWeight: '700' }],
'label-md': ['13px', { lineHeight: '16px', letterSpacing: '0px', fontWeight: '500' }],
'label-sm': ['12px', { lineHeight: '14px', letterSpacing: '0px', fontWeight: '600' }],
},
transitionDuration: {
'state-change': '120ms',
},
transitionDelay: {
'state-change': '0ms',
},
transitionTimingFunction: {
'state-change': 'ease-out',
},
},
},
},
};
+41
View File
@@ -0,0 +1,41 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"isolatedModules": true,
"jsx": "react-jsx",
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": [
"./*"
]
},
"allowJs": true,
"incremental": true,
"resolveJsonModule": true
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}
+2537
View File
File diff suppressed because it is too large Load Diff
+12
View File
@@ -0,0 +1,12 @@
{
"name": "bedrock-web-workspaces",
"private": true,
"engines": {
"node": ">=22"
},
"workspaces": [
"home",
"dashboard",
"repository"
]
}
+8
View File
@@ -0,0 +1,8 @@
/node_modules/
/.next/
/out/
/coverage/
*.tsbuildinfo
next-env.d.ts
.env*
.DS_Store
+8
View File
@@ -0,0 +1,8 @@
import type { Metadata } from "next";
import type { ReactNode } from "react";
export const metadata: Metadata = { title: "Repository" };
export default function RootLayout({ children }: { children: ReactNode }) {
return <html lang="zh-CN"><body>{children}</body></html>;
}
+3
View File
@@ -0,0 +1,3 @@
export default function Page() {
return <main><h1>Repository</h1></main>;
}
+8
View File
@@ -0,0 +1,8 @@
import type { NextConfig } from "next";
const config: NextConfig = {
agentRules: false,
devIndicators: false,
};
export default config;
+20
View File
@@ -0,0 +1,20 @@
{
"name": "@bedrock/repository",
"private": true,
"scripts": {
"dev": "next dev --hostname 127.0.0.1 --port 3002",
"build": "next build",
"start": "next start --hostname 127.0.0.1 --port 3002"
},
"dependencies": {
"next": "16.4.6",
"react": "19.3.1",
"react-dom": "19.3.1"
},
"devDependencies": {
"@types/node": "22.20.7",
"@types/react": "19.3.0",
"@types/react-dom": "19.3.0",
"typescript": "5.9.3"
}
}
+41
View File
@@ -0,0 +1,41 @@
{
"compilerOptions": {
"target": "ES2017",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"isolatedModules": true,
"jsx": "react-jsx",
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": [
"./*"
]
},
"allowJs": true,
"incremental": true,
"resolveJsonModule": true
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
],
"exclude": [
"node_modules"
]
}