From 7ff784e702015658a8bbe93616958dd433a66774 Mon Sep 17 00:00:00 2001 From: wener Date: Sat, 27 Apr 2024 17:31:56 +0800 Subject: [PATCH] update --- notes/culture/game/baccarat.md | 56 +++ notes/db/search/search-awesome.md | 1 + notes/dev/design/design-form-service.md | 26 +- notes/dev/format/format-date.md | 8 + notes/dev/format/har.md | 7 + notes/dev/format/zlib.md | 46 +++ notes/devops/kubernetes/distro/k3s/k3s-faq.md | 1 + notes/os/linux/fs/zfs/zfs-faq.md | 36 +- notes/os/linux/network/arp.md | 26 ++ notes/os/linux/network/ifupdown-ng.md | 23 ++ notes/platform/google/drive.md | 3 +- notes/service/dns/dns-awesome.md | 4 + notes/service/download/transmission.md | 75 +++- notes/service/forge/github/github-copilot.md | 1 + notes/service/torrent/torrent-awesome.md | 16 + notes/service/workflow/bull.md | 9 + notes/service/workflow/cadence.md | 2 +- notes/service/workflow/conductor.md | 12 + notes/service/workflow/pg-boss.md | 11 + notes/service/workflow/temporal/README.md | 3 +- .../service/workflow/temporal/temporalite.md | 3 +- .../{web/dev => service/workflow}/trigger.md | 4 +- notes/web/browser/browserless.md | 3 +- notes/web/browser/chrome/chrome-awesome.md | 34 ++ notes/web/browser/chrome/chrome-cli.md | 116 ++++++ notes/web/browser/chrome/chrome-headless.md | 50 --- notes/web/design/components.md | 11 + notes/web/design/design-awesome.md | 3 +- notes/web/framework/knex.md | 13 +- notes/web/nodejs/graphile-worker.md | 1 + notes/web/nodejs/mikro-orm.md | 6 +- notes/web/nodejs/nodejs-awesome.md | 6 +- notes/web/react/react-awesome.md | 6 +- notes/web/react/react-router.md | 363 +++++++++++++++++- notes/web/react/tanstack-router.md | 21 + notes/web/script/js/js-awesome.md | 2 + 36 files changed, 914 insertions(+), 94 deletions(-) create mode 100644 notes/dev/format/format-date.md create mode 100644 notes/dev/format/zlib.md create mode 100644 notes/os/linux/network/arp.md create mode 100644 notes/service/workflow/bull.md create mode 100644 notes/service/workflow/conductor.md create mode 100644 notes/service/workflow/pg-boss.md rename notes/{web/dev => service/workflow}/trigger.md (89%) create mode 100644 notes/web/browser/chrome/chrome-cli.md create mode 100644 notes/web/design/components.md create mode 100644 notes/web/react/tanstack-router.md diff --git a/notes/culture/game/baccarat.md b/notes/culture/game/baccarat.md index 95af9a76d24..3b1f951b6b1 100644 --- a/notes/culture/game/baccarat.md +++ b/notes/culture/game/baccarat.md @@ -13,3 +13,59 @@ tags: - 大桌 - 14人参与 - 限红 + +| en | for | +| ----------- | ---- | +| player | 闲家 | +| banker | 庄家 | +| tie | 和局 | +| player pair | 闲对 | +| banker pair | 庄对 | +| big | 大 | +| small | 小 | +| big pair | 大对 | +| small pair | 小对 | + +**胜负规则** + +1. 闲家和庄家的牌点数相加,以个位数为准 +1. 谁最接近9点即为胜方 +1. 相同点数即和局 + +**游戏规则** + +1. 8副牌,每副52张,共416张 - 一靴牌 +1. 闲家和庄家各发两张牌 +1. 如第一轮未分出胜负需再按"牌例"发第二轮的牌,每方最多再发1张牌 +1. 牌面为0至6将依照补牌规则多发一张牌 +1. 没有任何一手牌获得超过三张牌 +1. Ace 为 1 点 +1. J, Q, K, 10 为 0 点 +1. 一靴牌 + - 第21局+,不得投注 大小 + - 第26局+,不得投注 超和 + - 第46局+,不得投注 庄龙宝、闲龙宝、完美对子、任意对子、庄对、闲对 + - 第51局+,不得投注 闲例牌/庄例牌 + +**投注项目** + +| bet | rate | +| -------- | ---- | +| 闲家 |1 +| 庄家 |0.95 +| 和局 |8 +| 闲对 |11 +| 庄对 |11 +| 大 |0.5 +| 小 |1.5 +| 任意对子 |5 +| 完美对子 |25 +| 闲例牌 |4 +| 庄例牌 |4 +超和 N| + +- 大小 - 4张牌为小,5张牌或6张牌为大 +- 完美对子 - 庄或闲的前两张牌的牌面,必须同花同色同数字或同英文字母 +- 例牌 - 庄或闲的前两张牌点数总和为8或9点并胜出 +- 超和 - 指庄和闲为和局时,押中和局点数 +- 超级六 - 庄家点数为 6 而且赢闲家 diff --git a/notes/db/search/search-awesome.md b/notes/db/search/search-awesome.md index 852f9fa0927..3a37135a4ad 100644 --- a/notes/db/search/search-awesome.md +++ b/notes/db/search/search-awesome.md @@ -19,6 +19,7 @@ tags: - AGPLv3, Rust - Like Elasticsearch, but highly reliable & cost-efficient for log management. - [lnx-search/lnx](https://github.com/lnx-search/lnx) + - MIT, Rust - [valeriansaliou/sonic](https://github.com/valeriansaliou/sonic) - MPL-2.0, Rust - schema-less search backend diff --git a/notes/dev/design/design-form-service.md b/notes/dev/design/design-form-service.md index c939cadc8a4..9307c096bd3 100644 --- a/notes/dev/design/design-form-service.md +++ b/notes/dev/design/design-form-service.md @@ -17,6 +17,8 @@ title: Design Form Service - 只关系结果 - 能提交验证数据 - 能显示页面 +- 确定校验和验证框架逻辑 +- 动态后段 + 前端 Builder - 逻辑 - 复杂、高级表单通常存在内部关联逻辑 @@ -25,14 +27,30 @@ title: Design Form Service - 参考 - 字段设计 - https://github.com/gitana/alpaca/tree/master/src/js/fields + - generate interactive HTML5 forms for web and mobile applications - FormBuilder - https://github.com/formio/formio.js/blob/master/src/builders/Builders.js -# 参考实现 +# 参考实现 {#reference} + +- [matheins/dorf](https://github.com/matheins/dorf) + - AGPLv3, TS, React, PG, Drizzle, NextJS + - form builder +- [formbricks/formbricks](https://github.com/formbricks/formbricks) + - AGPLv3, TS + - Survey Platform + - snoopforms -> formbricks +- [Ryczko/FormsLab](https://github.com/Ryczko/FormsLab) + - MIT, TS, MongoDB, React, Prisma, NextJS + - Form builder for anonymous surveys, polls, and collecting feedback + +## heyform + +- [heyform](https://github.com/heyform/heyform) ## ohmyform -- ~~[ohmyform/ohmyform](https://github.com/ohmyform/ohmyform)~~ +- [ohmyform](https://github.com/ohmyform/ohmyform) - AGPL, TS, typeorm - entities - form @@ -59,8 +77,8 @@ title: Design Form Service ## formio -- [formio/formio](https://github.com/formio/formio) - - OSL-3.0, JS +- [formio](https://github.com/formio/formio) + - MIT, JS - mongoose - https://github.com/formio/formio/blob/master/src/models/models.js - Models diff --git a/notes/dev/format/format-date.md b/notes/dev/format/format-date.md new file mode 100644 index 00000000000..593ef45261b --- /dev/null +++ b/notes/dev/format/format-date.md @@ -0,0 +1,8 @@ +--- +title: Date Format +--- + +# Date format + +- https://en.wikipedia.org/wiki/List_of_date_formats_by_country +- mdn [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat) diff --git a/notes/dev/format/har.md b/notes/dev/format/har.md index 0534d49ee2b..15235044553 100644 --- a/notes/dev/format/har.md +++ b/notes/dev/format/har.md @@ -27,7 +27,14 @@ title: HTTP Archive format - OWASP ZAP - k6 - 记录 HTTP 请求 - http://www.softwareishard.com/blog/har-adopters/ +- Chrome + - 支持导入 - Chrome62+ + - 支持导出 + - https://developer.chrome.com/docs/devtools/network/reference + - [chrome.devtools.network](https://developer.chrome.com/docs/extensions/reference/api/devtools/network) - 参考 + - https://gitgrimbo.github.io/harviewer/master/ + - [janodvarko/harviewer](https://github.com/janodvarko/harviewer) - https://toolbox.googleapps.com/apps/har_analyzer/ - 不会显示 _initiator, _webSocketMessages - _resourceType=websocket diff --git a/notes/dev/format/zlib.md b/notes/dev/format/zlib.md new file mode 100644 index 00000000000..b9082e4b58e --- /dev/null +++ b/notes/dev/format/zlib.md @@ -0,0 +1,46 @@ +--- +tags: + - Compression + - RFC +--- + +# zlib + +- https://www.rfc-editor.org/rfc/rfc1950 + +**Header** + +| L | ZLIB | GZIP | Notes | +| --- | ----- | ----- | ------------------- | +| 1 | 78 01 | 1F 8B | No Compression/low | +| 2 | 78 5E | 1F 8B | Fast Compression | +| 3 | 78 5E | 1F 8B | +| 4 | 78 5E | 1F 8B | +| 5 | 78 5E | 1F 8B | +| 6 | 78 9C | 1F 8B | Default Compression | +| 7 | 78 DA | 1F 8B | Best Compression | +| 8 | 78 DA | 1F 8B | +| 9 | 78 DA | 1F 8B | + +- CMF -Compression Method and flags + +``` +bits 0 to 3 CM Compression method +bits 4 to 7 CINFO Compression info +``` + +- CM = 8 + - Deflate + - window size up to 32K + - used by gzip and PNG + - CINFO - base-2 logarithm of the LZ77 window size, minus eight + - CINFO=7 indicates a 32K window size + - 因此大多前缀都是 78 +- CM = 15 + - reserved + +``` +bits 0 to 4 FCHECK (check bits for CMF and FLG) +bit 5 FDICT (preset dictionary) +bits 6 to 7 FLEVEL (compression level) +``` diff --git a/notes/devops/kubernetes/distro/k3s/k3s-faq.md b/notes/devops/kubernetes/distro/k3s/k3s-faq.md index 6f81dff1789..526d82e09d5 100644 --- a/notes/devops/kubernetes/distro/k3s/k3s-faq.md +++ b/notes/devops/kubernetes/distro/k3s/k3s-faq.md @@ -496,3 +496,4 @@ iptables -L | wc -l -c ``` - https://github.com/k3s-io/k3s/issues/294 + diff --git a/notes/os/linux/fs/zfs/zfs-faq.md b/notes/os/linux/fs/zfs/zfs-faq.md index c073f7a077d..6e8697249f1 100644 --- a/notes/os/linux/fs/zfs/zfs-faq.md +++ b/notes/os/linux/fs/zfs/zfs-faq.md @@ -11,6 +11,7 @@ tags: - renameat2/overlayfs ZFS v2.2+ - [zfs_rename: support RENAME\_ flags](https://github.com/openzfs/zfs/commit/dbf6108b4df92341eea40d0b41792ac16eabc514) - feature zilsaxattr +- 不要用 `/dev/z0`, 用 `/dev/zvol/data/db` - zd0 可能会变 ::: @@ -90,12 +91,6 @@ du --apparent-size -h . 尝试关闭 atime -## cannot create '/data/db': pool must be upgraded to set this property or value - -```bash -sudo zpool upgrade -a -``` - ## 计算使用空间 - compressratio - 压缩率 @@ -386,7 +381,6 @@ mount -o remount,rw /data/docker - cache 异常后导致 zvol 被重新挂载为 ro - clear cache 的 error 后还是无法挂载,因为 fs 损坏 - ```ansi EXT4-fs warning (device zd0): ext4_end_bio:343: I/O error 3 writing to inode 5767264 starting block 14909936) Buffer I/O error on device zd0, logical block 14909936 @@ -530,16 +524,20 @@ device_rebuild (read-only compatible) Support for sequential mirror/dRAID device rebuilds zstd_compress zstd compression algorithm support. -draid - Support for distributed spare RAID -zilsaxattr (read-only compatible) - Support for xattr=sa extended attribute logging in ZIL. -head_errlog - Support for per-dataset on-disk error logs. -blake3 - BLAKE3 hash algorithm. -block_cloning (read-only compatible) - Support for block cloning via Block Reference Table. -vdev_zaps_v2 - Support for root vdev ZAP. +``` + +| flag | ver | for | +| ------------: | ---- | ------------------------------------- | +| zstd_compress | v2.1 | zstd 压缩算法 | +| draid | v2.1 | 支持分布式备用 RAID | +| zilsaxattr | v2.2 | ZIL 支持 xattr=sa 扩展属性日志 | +| head_errlog | v2.2 | per-dataset on-disk error logs | +| blake3 | v2.2 | BLAKE3 哈希算法 | +| block_cloning | v2.2 | 通过 Block Reference Table 支持块克隆 | +| vdev_zaps_v2 | v2.2 | 支持 root vdev ZAP | + +## cannot create '/data/db': pool must be upgraded to set this property or value + +```bash +sudo zpool upgrade -a ``` diff --git a/notes/os/linux/network/arp.md b/notes/os/linux/network/arp.md new file mode 100644 index 00000000000..79ab678a505 --- /dev/null +++ b/notes/os/linux/network/arp.md @@ -0,0 +1,26 @@ +--- +title: ARP +--- + +# ARP + +- arpd + - 管理 ARP 缓存 - 避免在网络上因为频繁的 ARP 广播请求而导致的性能问题 + - 网络优化 + - 安全 - 检测和防御 ARP 欺骗攻击 +- 参考 + - [royhills/arp-scan](https://github.com/royhills/arp-scan) + +```bash +# 所有 hosts +arp -a + +# /etc/arp-scan/mac-vendor.txt +# /usr/share/arp-scan/ieee-oui.txt +# arp-fingerprint arp-scan get-iab get-oui +apk add arp-scan + +# IP -> MAC +sudo arp-scan 192.168.1.1 +sudo arp-scan 192.168.1.0/24 +``` diff --git a/notes/os/linux/network/ifupdown-ng.md b/notes/os/linux/network/ifupdown-ng.md index a125b6d9a9c..6bdea78f3e1 100644 --- a/notes/os/linux/network/ifupdown-ng.md +++ b/notes/os/linux/network/ifupdown-ng.md @@ -70,6 +70,29 @@ title: ifupdown-ng - bond-arp-validate - bond-arp-all-targets +## interfaces + +| Syntax | Description | +| ------------------------------ | ------------------------------------ | +| **address** _address_ | 配置 IP 地址,自动补充适当的子网掩码 | +| **netmask** _netmask_ | 设置后备子网掩码 | +| **point-to-point** _address_ | 设置点对点网络配置的对端 IP 地址 | +| **gateway** _address_ | 设置默认网关地址 | +| **link-type** _link-type_ | 定义接口的链路类型 | +| **veth-peer-name** _peer-name_ | 指定 veth 对端接口的名称 | +| **alias** _alias_ | 设置接口别名 | +| **requires** _interfaces_... | 定义启动前需先启动的接口 | +| **inherit** _object_ | 接口继承其它配置对象的设置 | +| **use** _executor_ | 指定使用的执行器 | +| **pre-down** _command_ | 在接口关闭前执行的命令 | +| **down** _command_ | 关闭接口时执行的命令 | +| **post-down** _command_ | 接口关闭后执行的命令 | +| **pre-up** _command_ | 在接口启动前执行的命令 | +| **up** _command_ | 启动接口时执行的命令 | +| **post-up** _command_ | 接口启动后执行的命令 | + +- https://github.com/ifupdown-ng/ifupdown-ng/blob/main/doc/interfaces.scd + ## executor - wifi - AlpineLinux 3.15+ diff --git a/notes/platform/google/drive.md b/notes/platform/google/drive.md index be19a6b9848..a48f56e048a 100644 --- a/notes/platform/google/drive.md +++ b/notes/platform/google/drive.md @@ -1,10 +1,11 @@ --- title: 谷歌云端硬盘 +tags: + - Drive --- # 谷歌云端硬盘 - - [可存储在 Google 云端硬盘中的文件](https://support.google.com/drive/answer/37603?hl=zh-Hans) - Word - 50 MB diff --git a/notes/service/dns/dns-awesome.md b/notes/service/dns/dns-awesome.md index 057df04463a..21b9cb6a243 100644 --- a/notes/service/dns/dns-awesome.md +++ b/notes/service/dns/dns-awesome.md @@ -334,3 +334,7 @@ bard.google.com - https://github.com/gfwlist/gfwlist - [中华人民共和国被封锁网站列表](https://zh.wikipedia.org/wiki/中华人民共和国被封锁网站列表) - https://github.com/paulmillr/encrypted-dns + +## CDN + +- ghcr.io -> pkg-containers.githubusercontent.com diff --git a/notes/service/download/transmission.md b/notes/service/download/transmission.md index 7e2a2785bed..7d1f3b09e48 100644 --- a/notes/service/download/transmission.md +++ b/notes/service/download/transmission.md @@ -26,7 +26,7 @@ title: transmission :::tip -- 不支持 bt2 [transmission/transmission#1339](https://github.com/transmission/transmission/issues/1339) +- ~~不支持 bt2 [transmission/transmission#1339](https://github.com/transmission/transmission/issues/1339)~~ - 不支持 WebRTC [#47](https://github.com/transmission/transmission/issues/47) ::: @@ -41,8 +41,81 @@ transmission-daemon -d # 前台启动 # http://localhost:9091 transmission-daemon -f + +apk add transmission-daemon +mkdir -p /transmission/config +chmod -R 1777 /transmission + +/usr/bin/transmission-daemon --foreground --config-dir /transmission/config + +# https://hub.docker.com/r/linuxserver/transmission +docker run -d \ + --name=transmission \ + -e PUID=1000 \ + -e PGID=1000 \ + -e TZ=Etc/UTC \ + -e TRANSMISSION_WEB_HOME= `#optional` \ + -e USER= `#optional` \ + -e PASS= `#optional` \ + -e WHITELIST= `#optional` \ + -e PEERPORT= `#optional` \ + -e HOST_WHITELIST= `#optional` \ + -p 9091:9091 \ + -p 51413:51413 \ + -p 51413:51413/udp \ + -v $PWD/config:/config \ + -v $PWD/downloads:/downloads \ + -v $PWD/watch:/watch \ + --restart unless-stopped \ + linuxserver/transmission:latest ``` +## deamon + +- TRANSMISSION_HOME + - ~/.config/transmission-daemon +- https://linux.die.net/man/1/transmission-daemon + +| Option | Default Value | Description | +| -------------------------------- | ------------- | ------------------------------------------------------ | +| `-a, --allowed x.x.x.x,...` | `127.0.0.1` | IP 白名单,可以使用 `*` | +| `-b, --blocklist` | | 启用对等方黑名单 | +| `-B, --no-blocklist` | | 禁用对等方黑名单 | +| `-c directory` | | 监控新 .torrent 文件的目录 | +| `-C` | | 不监控新 .torrent 文件 | +| `-f, --foreground` | | 在前台运行并打印错误信息 | +| `-g, --config-dir directory` | | 配置文件目录 | +| `-er, --encryption-required` | | 加密所有对等连接 | +| `-ep, --encryption-preferred` | | 优先加密的对等连接 | +| `-et, --encryption-tolerated` | | 容忍未加密的对等连接 | +| `-gsr, --global-seedratio ratio` | | 所有种子,除非被单个种子设置覆盖,应种到特定比率 | +| `-GSR, --no-global-seedratio` | | 所有种子,除非被单个种子设置覆盖,无视比率种子 | +| `-h, --help` | | 显示命令行选项描述 | +| `--incomplete-dir dir` | | 将新种子内容存储在指定目录,直到下载完成 | +| `--no-incomplete-dir` | | 不在不同目录存储未完成的种子 | +| `-i, --bind-address-ipv4` | `0.0.0.0` | 用于IPv4 BitTorrent 连接的监听地址 | +| `-I, --bind-address-ipv6` | `::` | 用于IPv6 BitTorrent 连接的监听地址 | +| `-r, --rpc-bind-address` | `0.0.0.0` | 用于RPC连接的监听地址 | +| `--paused` | | 启动时暂停所有种子 | +| `-L, --peerlimit-global limit` | `240` | 全局对等方限制,适用于默认设置不合适的嵌入式系统 | +| `-l, --peerlimit-torrent limit` | `60` | 每个种子的对等方限制,适用于默认设置不合适的嵌入式系统 | +| `-m, --portmap` | | 启用通过 NAT-PMP 或 UPnP 的端口映射 | +| `-M, --no-portmap` | | 禁用端口映射 | +| `-o, --dht` | | 启用分布式哈希表 (DHT) | +| `-O, --no-dht` | | 禁用分布式哈希表 (DHT) | +| `-p, --port port` | `9091` | 用于RPC请求的端口 | +| `-P, --peerport port` | `51413` | 用于接收来电的端口 | +| `-t, --auth` | | 要求客户端身份验证 | +| `-T, --no-auth` | | 不要求客户端身份验证 | +| `-u, --username username` | | 用于客户端身份验证的用户名 | +| `-v, --password password` | | 用于客户端身份验证的密码 | +| `-V, --version` | | 显示版本号并退出 | +| `-w, --download-dir` | | 下载数据存储位置 | +| `-e, --logfile` | | 日志文件存储位置 | +| `--log-error` | | 显示错误信息 | +| `--log-info` | | 显示错误和信息消息 | +| `--log-debug` | | 显示错误、信息和调试消息 | + ## conf | what | where | diff --git a/notes/service/forge/github/github-copilot.md b/notes/service/forge/github/github-copilot.md index edf1ef902bb..e602c3d58fb 100644 --- a/notes/service/forge/github/github-copilot.md +++ b/notes/service/forge/github/github-copilot.md @@ -42,6 +42,7 @@ curl https://copilot-proxy.githubusercontent.com/_ping ## Reverse +- https://docs.github.com/en/copilot/configuring-github-copilot/configuring-github-copilot-in-your-environment - https://github.com/search?q=GH_COPILOT_TOKEN&type=code - https://news.ycombinator.com/item?id=34032872 - https://thakkarparth007.github.io/copilot-explorer/posts/copilot-internals.html diff --git a/notes/service/torrent/torrent-awesome.md b/notes/service/torrent/torrent-awesome.md index 591684f5807..9967740d718 100644 --- a/notes/service/torrent/torrent-awesome.md +++ b/notes/service/torrent/torrent-awesome.md @@ -6,7 +6,19 @@ tags: # Torrent +- Client + - [deluge-torrent/deluge](https://github.com/deluge-torrent/deluge) + - GPLv3, Python + - aria2c + - qBittorrent + - qBittorrent-nox + - [Transmission](https://github.com/transmission/transmission) + - GPLv2, C++ + - rTorrent + ruTorrent + - [webtorrent](https://github.com/webtorrent/webtorrent) + - [webtorrent/bittorrent-tracker](https://github.com/webtorrent/bittorrent-tracker) - [atomashpolskiy/bt](https://github.com/atomashpolskiy/bt) + - Apache-2.0, Java - [HN](https://news.ycombinator.com/item?id=14911372) - Java BitTorrent library with DHT, magnet links, encryption and more - [mafintosh/peerflix](https://github.com/mafintosh/peerflix) @@ -41,6 +53,10 @@ tags: - [anacrolix/torrent](https://github.com/anacrolix/torrent) - [xgfone/bt](https://github.com/xgfone/bt) - [xgfone/bttools](https://github.com/xgfone/bttools) +- [arvidn/libtorrent](https://github.com/arvidn/libtorrent) + + + ## Torrent file diff --git a/notes/service/workflow/bull.md b/notes/service/workflow/bull.md new file mode 100644 index 00000000000..29223ab3aec --- /dev/null +++ b/notes/service/workflow/bull.md @@ -0,0 +1,9 @@ +--- +tags: + - NodeJS +--- + +# bull + +- [OptimalBits/bull](https://github.com/OptimalBits/bull) + - MIT, JS, Redis diff --git a/notes/service/workflow/cadence.md b/notes/service/workflow/cadence.md index 9d42c68428a..7262a2017b0 100644 --- a/notes/service/workflow/cadence.md +++ b/notes/service/workflow/cadence.md @@ -201,7 +201,7 @@ docker run --rm -it \ --name cadence ubercadence/server ``` -# 概念 +# 概念 {#concept} - Domain - 域划分 - 多租户的租户 - 作为 TaskList 和 Workflow 的命名空间 diff --git a/notes/service/workflow/conductor.md b/notes/service/workflow/conductor.md new file mode 100644 index 00000000000..b11dfcca72f --- /dev/null +++ b/notes/service/workflow/conductor.md @@ -0,0 +1,12 @@ +--- +title: conductor +--- + +# conductor + +- [conductor-oss/conductor](https://github.com/conductor-oss/conductor) + - Apache-2.0, Java, gRPC + - Cassandra, MySQL, PostgreSQL, Elasticsearch + - from Netflix +- https://docs.conductor-oss.org/devguide/running/docker.html +- https://github.com/conductor-oss/conductor/blob/main/docker/docker-compose-postgres.yaml diff --git a/notes/service/workflow/pg-boss.md b/notes/service/workflow/pg-boss.md new file mode 100644 index 00000000000..d1eefac6de3 --- /dev/null +++ b/notes/service/workflow/pg-boss.md @@ -0,0 +1,11 @@ +--- +title: pg-boss +--- + +# pg-boss + +- [timgit/pg-boss](https://github.com/timgit/pg-boss) + - MIT, JS + - PostgreSQL SKIP LOCKED + - Queueing jobs in Node.js using PostgreSQL like a boss +- ⚠️ 非常简洁轻量 diff --git a/notes/service/workflow/temporal/README.md b/notes/service/workflow/temporal/README.md index 10eabcc90ce..7a7e6b00177 100644 --- a/notes/service/workflow/temporal/README.md +++ b/notes/service/workflow/temporal/README.md @@ -5,6 +5,7 @@ title: temporal # temporal - [temporalio/temporal](https://github.com/temporalio/temporal) + - MIT, Go - cadence fork, 包含原始团队人员 - Persistence - Cassandra, PostgreSQL, MySQL - Workflow search - Elasticsearch v6.8+ - 高级搜索 @@ -288,7 +289,7 @@ clusterMetadata: ## Bootstrap - install schema - - https://github.com/temporalio/temporal/blob/v1.4.2/Makefile#L367-L383 + - https://github.com/temporalio/temporal/blob/v1.22.7/Makefile#L384-L404 - docker 启动 - [docker/auto-setup.sh](https://github.com/temporalio/temporal/blob/master/docker/auto-setup.sh) - [docker/entrypoint.sh](https://github.com/temporalio/temporal/blob/master/docker/entrypoint.sh) diff --git a/notes/service/workflow/temporal/temporalite.md b/notes/service/workflow/temporal/temporalite.md index daa55a56fc4..443b96fcfae 100644 --- a/notes/service/workflow/temporal/temporalite.md +++ b/notes/service/workflow/temporal/temporalite.md @@ -4,7 +4,8 @@ title: temporalite # temporalite -- [temporalio/temporalite](https://github.com/temporalio/temporalite) +- ~~[temporalio/temporalite](https://github.com/temporalio/temporalite)~~ + - 废弃: 使用 Temporal CLI dev server - [Temporal](./temporal.md) runs as a single process - 支持 SQLite diff --git a/notes/web/dev/trigger.md b/notes/service/workflow/trigger.md similarity index 89% rename from notes/web/dev/trigger.md rename to notes/service/workflow/trigger.md index 2b091f36e92..f7d38d5a9b6 100644 --- a/notes/web/dev/trigger.md +++ b/notes/service/workflow/trigger.md @@ -8,13 +8,13 @@ title: Trigger - 目前是 PUSH 的模式,因此推荐在 serverless 环境中使用 - 支持 PULL 模式/long-running server [#244](https://github.com/triggerdotdev/trigger.dev/issues/244) + - WIP https://trigger.dev/blog/v3-developer-preview-launch/ ::: - [triggerdotdev/trigger.dev](https://github.com/triggerdotdev/trigger.dev) - Apache-2.0, TS - - 技术栈 postgres, prisma, react, codemirror, headlessui, heroicons, radix-ui, lucide-react, prismjs, framer - - remix + - 技术栈 postgres, prisma, react, codemirror, headlessui, heroicons, radix-ui, lucide-react, prismjs, framer, remix - [graphile/worker](https://github.com/graphile/worker) - 监控 [highlight](https://github.com/highlight/highlight) - Apache-2.0+EE, TS, Go diff --git a/notes/web/browser/browserless.md b/notes/web/browser/browserless.md index d7c83c226c0..5762a157312 100644 --- a/notes/web/browser/browserless.md +++ b/notes/web/browser/browserless.md @@ -13,6 +13,8 @@ TOKEN=$(openssl rand -hex 16) echo TOKEN=$TOKEN docker run -p 3000:3000 \ -e "CONCURRENT=10" \ + -e DATA_DIR=/data/browser \ + -e DOWNLOAD_DIR=/data/download \ -e "TOKEN=$TOKEN" \ --name browserless ghcr.io/browserless/chromium ``` @@ -45,7 +47,6 @@ docker run -p 3000:3000 \ | FAILED_HEALTH_URL | ```js -const puppeteer = require('puppeteer-core'); import puppeteer from 'puppeteer-core'; const browser = await puppeteer.connect({ diff --git a/notes/web/browser/chrome/chrome-awesome.md b/notes/web/browser/chrome/chrome-awesome.md index 7d5ca8bdb1f..b5d206b60fc 100644 --- a/notes/web/browser/chrome/chrome-awesome.md +++ b/notes/web/browser/chrome/chrome-awesome.md @@ -5,6 +5,40 @@ tags: # Chrome Awesome + +- [ChromeDevTools/awesome-chrome-devtools](https://github.com/ChromeDevTools/awesome-chrome-devtools) +- [Chrome Flags for Tooling](https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md) +- https://chromedevtools.github.io/devtools-protocol/ +- https://github.com/GoogleChrome/chrome-launcher/blob/master/docs/chrome-flags-for-tools.md +- https://niek.github.io/chrome-features/ +- [blink features](https://source.chromium.org/chromium/chromium/src/+/master:out/Debug/gen/third_party/blink/renderer/platform/runtime_enabled_features.cc;l=1559;drc=170473ad887b7990079f1f996b126548569c5902) +- [RuntimeEnabledFeatures](https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/platform/RuntimeEnabledFeatures.md) + +## Awesome + +- [puppeteer](https://github.com/puppeteer/puppeteer) + - Apache-2.0, TS + - Chrome 团队支持 +- [microsoft/playwright](https://github.com/microsoft/playwright) + - 支持 多浏览器 - Chromium, Firefox, WebKit + - patch Firefox, WebKit 实现 +- Golang + - [chromedp/chromedp](https://github.com/chromedp/chromedp) + - [chromedp/examples](https://github.com/chromedp/examples) + - [sensepost/gowitness](https://github.com/sensepost/gowitness) + +## WebDriver + +- [W3C WebDriver](https://w3c.github.io/webdriver/webdriver-spec.html) + - 控制浏览器 +- [electron/chromedriver](https://github.com/electron/chromedriver) + - 下载 [ChromeDriver](https://sites.google.com/chromium.org/driver/) + - https://chromedriver.chromium.org/ + - https://chromedriver.storage.googleapis.com/index.html +- webdriver + - Python `from selenium import webdriver` + + ## Chromium - https://chromiumdash.appspot.com/ diff --git a/notes/web/browser/chrome/chrome-cli.md b/notes/web/browser/chrome/chrome-cli.md new file mode 100644 index 00000000000..b7ff75dc211 --- /dev/null +++ b/notes/web/browser/chrome/chrome-cli.md @@ -0,0 +1,116 @@ +--- +tags: + - Command +--- + +# Chrome CLI + +:::tip + +- Proxy 只能配置全局,不可以按页面配置 + - [puppeteer#678](https://github.com/puppeteer/puppeteer/issues/678) + - Context 可以配置代理 https://pptr.dev/next/api/puppeteer.browsercontextoptions/ +- 不支持 PAC +- [puppeteer#540](https://github.com/puppeteer/puppeteer/issues/540) + - 多个 cert 会出现选择 + +::: + +- devtools-ws-url + - --remote-debugging-port=9222 + - /json +- flags + - --user-data-dir=$DIR + - --blink-settings=imagesEnabled=false +- DevToolsActivePort + - 第一行为端口 + - 第二行为 路径 `/devtools/browser/UUID` +- Crashpad -> Chromium 的崩溃报告系统 +- https://www.chromium.org/developers/design-documents/network-settings/ + - --proxy-server=127.0.0.1:7890 +- [List of Chromium Command Line Switches](https://peter.sh/experiments/chromium-command-line-switches/) + +| flag | for | +| ---------------------------------------------------- | ---------------------- | +| --headless=[new] | +| --no-sandbox | +| --disable-extensions | +| --remote-debugging-port=PORT | 开启远程调试 | +| --user-data-dir=PATH | +| --disable-background-timer-throttling | 禁用后台任务的时间限制 | +| --mute-audio | 静音所有音频输出 | +| --disable-popup-blocking | +| --enable-automation | +| --ozone-platform=headless | 图形系统模式 | +| --use-angle=swiftshader-webgl | 使用 ANGLE 渲染器 | +| --disable-gpu-compositing | 禁用 GPU 合成 | +| --disable-dev-shm-usage | 禁用 /dev/shm 使用 | +| --enable-crash-reporter | 启用崩溃报告 | +| --force-color-profile=srgb | 强制颜色配置 | +| --allow-pre-commit-input | +| --disable-background-networking | +| --disable-backgrounding-occluded-windows | +| --disable-breakpad | +| --disable-client-side-phishing-detection | +| --disable-component-extensions-with-background-pages | +| --disable-component-update | +| --disable-default-apps | +| --disable-hang-monitor | +| --disable-infobars | +| --disable-field-trial-config | +| --disable-ipc-flooding-protection | +| --disable-prompt-on-repost | +| --disable-renderer-backgrounding | +| --disable-search-engine-choice-screen | +| --disable-sync | +| --export-tagged-pdf | +| --generate-pdf-document-outline | +| --metrics-recording-only | +| --no-first-run | +| --password-store=basic | +| --use-mock-keychain | +| --disable-features=FEATURES | +| --enable-featuresFEATURES | +| --hide-scrollbars | +| --auto-open-devtools-for-tabs | + +- `--remote-debugging-port=0` + - 随机端口 + +| features | for | +| ------------------------------------ | --- | +| Translate | +| AcceptCHFrame | +| MediaRouter | +| OptimizationHints | +| ProcessPerSiteUpToMainFrameThreshold | +| NetworkServiceInProcess2 | + +| --type | for | +| ---------------- | ----------------------------------------------------------------------------------------------------------- | +| browser | 主进程 - 管理用户界面和浏览器的核心功能,如地址栏、书签、后台选项卡等。 | +| zygote | 在 Linux 系统中,zygote 进程作为模板进程,用于快速生成新的浏览器进程,提高进程创建的效率。 | +| gpu-process | GPU 进程 - 硬件加速渲染 | +| utility | 工具进程 - 执行特定的后台任务,如网络服务、存储管理等 | +| renderer | 渲染进程 - 负责渲染网页。每个标签页一般都有自己的渲染进程,这样即使一个标签页崩溃,也不会影响到其他标签页。 | +| crashpad-handler | Crashpad 崩溃处理程序 | + +- about:blank + +**browserless** + +``` +--allow-pre-commit-input --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection +--disable-component-extensions-with-background-pages --disable-component-update --disable-default-apps +--disable-dev-shm-usage --disable-extensions +--disable-field-trial-config --disable-hang-monitor --disable-infobars --disable-ipc-flooding-protection +--disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding +--disable-search-engine-choice-screen --disable-sync --enable-automation --export-tagged-pdf +--generate-pdf-document-outline --force-color-profile=srgb --metrics-recording-only --no-first-run +--password-store=basic --use-mock-keychain --disable-features=Translate,AcceptCHFrame,MediaRouter,OptimizationHints,ProcessPerSiteUpToMainFrameThreshold +--enable-features=NetworkServiceInProcess2 --headless=new --hide-scrollbars --mute-audio about:blank --remote-debugging-port=42017 --no-sandbox --user-data-dir=/data/browser/browserless-data-dir-UUID +``` + +**puppeteer** + +- https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/node/ChromeLauncher.ts diff --git a/notes/web/browser/chrome/chrome-headless.md b/notes/web/browser/chrome/chrome-headless.md index c1fdb75e91d..3e03a253855 100644 --- a/notes/web/browser/chrome/chrome-headless.md +++ b/notes/web/browser/chrome/chrome-headless.md @@ -4,21 +4,6 @@ title: Headless # Chrome Headless -- [ChromeDevTools/awesome-chrome-devtools](https://github.com/ChromeDevTools/awesome-chrome-devtools) -- [Chrome Flags for Tooling](https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md) -- https://chromedevtools.github.io/devtools-protocol/ -- devtools-ws-url - - --remote-debugging-port=9222 - - /json -- flags - - --user-data-dir=$DIR - - --blink-settings=imagesEnabled=false -- https://github.com/GoogleChrome/chrome-launcher/blob/master/docs/chrome-flags-for-tools.md -- https://niek.github.io/chrome-features/ -- [blink features](https://source.chromium.org/chromium/chromium/src/+/master:out/Debug/gen/third_party/blink/renderer/platform/runtime_enabled_features.cc;l=1559;drc=170473ad887b7990079f1f996b126548569c5902) -- [RuntimeEnabledFeatures](https://chromium.googlesource.com/chromium/src/+/master/third_party/blink/renderer/platform/RuntimeEnabledFeatures.md) -- https://www.chromium.org/developers/design-documents/network-settings/ - - --proxy-server=127.0.0.1:7890 - DevToolsActivePort - 第一行为端口 - 第二行为 路径 `/devtools/browser/UUID` @@ -35,41 +20,6 @@ curl http://localhost:9222/json --disable-blink-features=SomeOldFeature ``` -:::tip - -- Proxy 只能配置全局,不可以按页面配置 - - [puppeteer#678](https://github.com/puppeteer/puppeteer/issues/678) - - Context 可以配置代理 https://pptr.dev/next/api/puppeteer.browsercontextoptions/ -- 不支持 PAC -- [puppeteer#540](https://github.com/puppeteer/puppeteer/issues/540) - - 多个 cert 会出现选择 - -::: - -## Awesome - -- [puppeteer](https://github.com/puppeteer/puppeteer) - - Apache-2.0, TS - - Chrome 团队支持 -- [microsoft/playwright](https://github.com/microsoft/playwright) - - 支持 多浏览器 - Chromium, Firefox, WebKit - - patch Firefox, WebKit 实现 -- Golang - - [chromedp/chromedp](https://github.com/chromedp/chromedp) - - [chromedp/examples](https://github.com/chromedp/examples) - - [sensepost/gowitness](https://github.com/sensepost/gowitness) - -## WebDriver - -- [W3C WebDriver](https://w3c.github.io/webdriver/webdriver-spec.html) - - 控制浏览器 -- [electron/chromedriver](https://github.com/electron/chromedriver) - - 下载 [ChromeDriver](https://sites.google.com/chromium.org/driver/) - - https://chromedriver.chromium.org/ - - https://chromedriver.storage.googleapis.com/index.html -- webdriver - - Python `from selenium import webdriver` - # FAQ ## playwright vs puppeteer diff --git a/notes/web/design/components.md b/notes/web/design/components.md new file mode 100644 index 00000000000..1305144880b --- /dev/null +++ b/notes/web/design/components.md @@ -0,0 +1,11 @@ +--- +title: Components +--- + +# Components + +## Chip + +允许用户从多个项目中进行单个或多个选择的组件。 + +- https://designsystem.line.me/LDSG/components/inputs/chip-en diff --git a/notes/web/design/design-awesome.md b/notes/web/design/design-awesome.md index 5d586a66a89..37ee8fbbc75 100644 --- a/notes/web/design/design-awesome.md +++ b/notes/web/design/design-awesome.md @@ -76,8 +76,9 @@ tags: - https://design.aliyun.com/ -## Reference +## Components +- [Components](./components.md) - https://storybook.js.org/blog/component-encyclopedia/ - 组件大典 - https://designvault.io/ diff --git a/notes/web/framework/knex.md b/notes/web/framework/knex.md index 4acdd5dd7d7..229890d294c 100644 --- a/notes/web/framework/knex.md +++ b/notes/web/framework/knex.md @@ -51,10 +51,21 @@ const pool = new Pool({ // rejected with the error. If this is false (the default) then // create is retried until acquireTimeoutMillis milliseconds has // passed. - propagateCreateError: false + propagateCreateError: false, }); ``` +```ts +const db = knex({ + client: 'better-sqlite3', + connection: { + filename: 'test.sqlite3', + }, + useNullAsDefault: true, +}); +db.raw('PRAGMA journal_mode = WAL'); +``` + # FAQ ## raw in diff --git a/notes/web/nodejs/graphile-worker.md b/notes/web/nodejs/graphile-worker.md index 2bd7cbb93d1..c79f43b481c 100644 --- a/notes/web/nodejs/graphile-worker.md +++ b/notes/web/nodejs/graphile-worker.md @@ -5,6 +5,7 @@ title: graphile-worker # graphile-worker - [graphile/worker](https://github.com/graphile/worker) + - MIT, TS - 支持 cron - PostgreSQL - LISTEN/NOTIFY diff --git a/notes/web/nodejs/mikro-orm.md b/notes/web/nodejs/mikro-orm.md index fb6c92e09b7..eafb8fe9785 100644 --- a/notes/web/nodejs/mikro-orm.md +++ b/notes/web/nodejs/mikro-orm.md @@ -68,9 +68,9 @@ import type { PostgreSqlDriver } from '@mikro-orm/postgresql'; // or any other d import { EntityManager } from '@mikro-orm/postgresql'; const orm = await MikroORM.init({ - // 自动发现 - entities: ['./dist/entities'], // path to our JS entities (dist), relative to `baseDir` - entitiesTs: ['./src/entities'], // path to our TS entities (src), relative to `baseDir` + // 自动发现 - 不推荐 + // entities: ['./dist/entities'], // path to our JS entities (dist), relative to `baseDir` + // entitiesTs: ['./src/entities'], // path to our TS entities (src), relative to `baseDir` // entities: ['./dist/app/**/entities'], // entitiesTs: ['./src/app/**/entities'], // entities: ['./dist/app/**/entities/*.entity.js'], diff --git a/notes/web/nodejs/nodejs-awesome.md b/notes/web/nodejs/nodejs-awesome.md index 5bc860a5f18..3d6db84d35c 100644 --- a/notes/web/nodejs/nodejs-awesome.md +++ b/notes/web/nodejs/nodejs-awesome.md @@ -174,14 +174,16 @@ export N_PREFIX=$HOME/n - node-cron - cron - [graphile-worker](./graphile-worker.md) + - MIT, TS - PostgreSQL LISTEN/NOTIFY - - [timgit/pg-boss](https://github.com/timgit/pg-boss) + - [timgit/pg-boss](./pg-boss.md) - MIT, JS - PostgreSQL SKIP LOCKED - Queueing jobs in Node.js using PostgreSQL like a boss - [breejs/bree](https://github.com/breejs/bree) + - MIT, JS - scheduler with worker threads - - [agenda/agenda](https://github.com/agenda/agenda) + - ~~[agenda/agenda](https://github.com/agenda/agenda)~~ - mongodb - 独立服务 - Lightweight job scheduling diff --git a/notes/web/react/react-awesome.md b/notes/web/react/react-awesome.md index fac5d83c080..4f92896cd2d 100644 --- a/notes/web/react/react-awesome.md +++ b/notes/web/react/react-awesome.md @@ -404,7 +404,7 @@ npm add date-fns lodash-es react-fast-compare - 提供了统一配置 route 的逻辑 - 很简单,可以作为参考 - matchRoutes - 匹配嵌套路由 - 返回匹配的 tree 路由数组 - renderRoutes - 渲染嵌套路由 - 递归 Switch, 遍历 Route -- [tannerlinsley/react-location](https://github.com/tannerlinsley/react-location) +- [@tanstack/react-router](./tanstack-router.md) - 参考/基于 React Router v6 - 内置 async import - 异步加载 element - 内置 async load - 异步加载 data/状态 - useMatch 返回 @@ -412,8 +412,10 @@ npm add date-fns lodash-es react-fast-compare - declarative API - [molefrog/wouter](https://github.com/molefrog/wouter) - 轻量实现 - 很实用 - 可以直接拷贝到项目修改使用 + - 可以不需要 context - 外部提供 location -- [reach/router](https://github.com/reach/router) + - minimalist-friendly ~2.1KB routing for React and Preact +- ~~[reach/router](https://github.com/reach/router)~~ - React Router v6 后 reach router 不再需要 - React Router 作者在 hook 出现后进行的尝试 - 目前 hook 能力已经合并回 react router v5 diff --git a/notes/web/react/react-router.md b/notes/web/react/react-router.md index c232ee8702e..ae3df5bc59f 100644 --- a/notes/web/react/react-router.md +++ b/notes/web/react/react-router.md @@ -1,19 +1,43 @@ --- -title: React Route +title: Remix Router +tags: + - Router --- -# React Route +# Remix Router - [remix-run/react-router](https://github.com/remix-run/react-router) - - 核心 [remix-run/history](https://github.com/remix-run/history) + - npm:react-router -> @remix-run/router + - ~~[remix-run/history](https://github.com/remix-run/history)~~ 合并到了 @remix-run/router + - 支持 ReactDOM 和 ReactNative + - 支持 MemoryRouter + - 支持 HashRouter 和 BrowserRouter + - 支持 Full-Stack + - 支持 Form + - remix 核心的路由逻辑也有 @remix/router 实现 + - 基于文件路由 + - 生成路由表 :::caution +- 因为同时兼容支持 ReactDOM、ReactNative、Remix Run - 因此牺牲了很多单个平台的高级特性 + - 现在(2024年)重心在 remix run - 因此主要在 ssr/Server Component 等数据服务相关部分 - 不能嵌套 Router - children 绝对路径需要包含 parent 前缀 - NavLink 使用 routerState 会每次 rerender - [react-router-dom/index.tsx#L427-L501](https://github.com/remix-run/react-router/blob/f722d7fda7a5aff1d90fdc2d8cf51f14f7870376/packages/react-router-dom/index.tsx#L427-L501) - useNavigate 会 rerender [#7634](https://github.com/remix-run/react-router/issues/7634) +- 无法获取到 history - 除非自己做上下文 + - `useContext(UNSAFE_NavigationContext).navigator as History` + - unsafe 方式获取 history + - createHashRouter 和 createBrowserRouter 都无法自己传递 history + - history 只能做一次 listen - 因此拿到了意义也不大 + - v6.4+ +- useSearchParams 会导致任意参数变化都会 rerender - 无法只监听一个参数 + - 只能尝试通过 history 重新封装 + - https://github.com/remix-run/react-router/discussions/9851 +- 没有过多暴露 low-level 接口 + - 导致部分特殊功能不好实现 ::: @@ -21,7 +45,6 @@ title: React Route npm add react-router-dom ``` - - Path - `*` - 处理 NotFound - `:handle` @@ -67,6 +90,334 @@ npm add react-router-dom - staticSegmentValue=10 - `/user` - rankRouteBranches - matchRouteBranch +- Context + - DataRouterContext + - DataRouterStateContext - `Router['state']` + - LocationContext + - NavigationContext + - RouteContext + - RouteErrorContext +- createMemoryRouter + - -> createRouter+createMemoryHistory +- https://github.com/remix-run/react-router/blob/main/packages/react-router/index.ts + +```ts +interface DataRouterContextObject extends Omit { + router: Router; + staticContext?: StaticHandlerContext; +} + +interface NavigationContextObject { + basename: string; + navigator: Navigator; + static: boolean; + future: { + v7_relativeSplatPath: boolean; + }; +} + +interface RouteContextObject { + outlet: React.ReactElement | null; + matches: RouteMatch[]; + isDataRoute: boolean; +} +``` + +## @remix-run/router + +- history + Router +- https://github.com/remix-run/react-router/blob/main/packages/router/router.ts + +## Router + +```ts +/** + * A Router instance manages all navigation and data loading/mutations + */ +export interface Router { + /** + * @internal + * PRIVATE - DO NOT USE + * + * Return the basename for the router + */ + get basename(): RouterInit['basename']; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Return the future config for the router + */ + get future(): FutureConfig; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Return the current state of the router + */ + get state(): RouterState; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Return the routes for this router instance + */ + get routes(): AgnosticDataRouteObject[]; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Return the window associated with the router + */ + get window(): RouterInit['window']; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Initialize the router, including adding history listeners and kicking off + * initial data fetches. Returns a function to cleanup listeners and abort + * any in-progress loads + */ + initialize(): Router; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Subscribe to router.state updates + * + * @param fn function to call with the new state + */ + subscribe(fn: RouterSubscriber): () => void; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Enable scroll restoration behavior in the router + * + * @param savedScrollPositions Object that will manage positions, in case + * it's being restored from sessionStorage + * @param getScrollPosition Function to get the active Y scroll position + * @param getKey Function to get the key to use for restoration + */ + enableScrollRestoration( + savedScrollPositions: Record, + getScrollPosition: GetScrollPositionFunction, + getKey?: GetScrollRestorationKeyFunction, + ): () => void; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Navigate forward/backward in the history stack + * @param to Delta to move in the history stack + */ + navigate(to: number): Promise; + + /** + * Navigate to the given path + * @param to Path to navigate to + * @param opts Navigation options (method, submission, etc.) + */ + navigate(to: To | null, opts?: RouterNavigateOptions): Promise; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Trigger a fetcher load/submission + * + * @param key Fetcher key + * @param routeId Route that owns the fetcher + * @param href href to fetch + * @param opts Fetcher options, (method, submission, etc.) + */ + fetch(key: string, routeId: string, href: string | null, opts?: RouterFetchOptions): void; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Trigger a revalidation of all current route loaders and fetcher loads + */ + revalidate(): void; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Utility function to create an href for the given location + * @param location + */ + createHref(location: Location | URL): string; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Utility function to URL encode a destination path according to the internal + * history implementation + * @param to + */ + encodeLocation(to: To): Path; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Get/create a fetcher for the given key + * @param key + */ + getFetcher(key: string): Fetcher; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Delete the fetcher for a given key + * @param key + */ + deleteFetcher(key: string): void; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Cleanup listeners and abort any in-progress loads + */ + dispose(): void; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Get a navigation blocker + * @param key The identifier for the blocker + * @param fn The blocker function implementation + */ + getBlocker(key: string, fn: BlockerFunction): Blocker; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Delete a navigation blocker + * @param key The identifier for the blocker + */ + deleteBlocker(key: string): void; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * HMR needs to pass in-flight route updates to React Router + * TODO: Replace this with granular route update APIs (addRoute, updateRoute, deleteRoute) + */ + _internalSetRoutes(routes: AgnosticRouteObject[]): void; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Internal fetch AbortControllers accessed by unit tests + */ + _internalFetchControllers: Map; + + /** + * @internal + * PRIVATE - DO NOT USE + * + * Internal pending DeferredData instances accessed by unit tests + */ + _internalActiveDeferreds: Map; +} +``` + +## RouterState + +```ts +/** + * State maintained internally by the router. During a navigation, all states + * reflect the the "old" location unless otherwise noted. + */ +export interface RouterState { + /** + * The action of the most recent navigation + */ + historyAction: HistoryAction; + + /** + * The current location reflected by the router + */ + location: Location; + + /** + * The current set of route matches + */ + matches: AgnosticDataRouteMatch[]; + + /** + * Tracks whether we've completed our initial data load + */ + initialized: boolean; + + /** + * Current scroll position we should start at for a new view + * - number -> scroll position to restore to + * - false -> do not restore scroll at all (used during submissions) + * - null -> don't have a saved position, scroll to hash or top of page + */ + restoreScrollPosition: number | false | null; + + /** + * Indicate whether this navigation should skip resetting the scroll position + * if we are unable to restore the scroll position + */ + preventScrollReset: boolean; + + /** + * Tracks the state of the current navigation + */ + navigation: Navigation; + + /** + * Tracks any in-progress revalidations + */ + revalidation: RevalidationState; + + /** + * Data from the loaders for the current matches + */ + loaderData: RouteData; + + /** + * Data from the action for the current matches + */ + actionData: RouteData | null; + + /** + * Errors caught from loaders for the current matches + */ + errors: RouteData | null; + + /** + * Map of current fetchers + */ + fetchers: Map; + + /** + * Map of current blockers + */ + blockers: Map; +} +``` # Version @@ -124,3 +475,7 @@ npm add react-router-dom ## Switch vs Route `` 只渲染一个路由. 而 `` 会渲染所有匹配的路由。 + +## A history only accepts one active listener + +- v6 的 History 只能被 router 监听 diff --git a/notes/web/react/tanstack-router.md b/notes/web/react/tanstack-router.md new file mode 100644 index 00000000000..9b450e3cded --- /dev/null +++ b/notes/web/react/tanstack-router.md @@ -0,0 +1,21 @@ +--- +tags: + - Router +--- + +# @tanstack/react-router + +:::caution + +- File Based router 优先 + - 对代码构建不友好 +- 全局强类型 - 构建路由很吃力 + +::: + +- [tanstack/router](https://github.com/tanstack/router) + - [@tanstack/react-router](https://www.npmjs.com/package/@tanstack/react-router) + - @tanstack/history + - @tanstack/react-store -> use-sync-external-store, @tanstack/store +- 参考 + - [vs. React Router DOM & NextJS](https://tanstack.com/router/latest/docs/framework/react/comparison) diff --git a/notes/web/script/js/js-awesome.md b/notes/web/script/js/js-awesome.md index c0ce589c2eb..f0e71dd3581 100644 --- a/notes/web/script/js/js-awesome.md +++ b/notes/web/script/js/js-awesome.md @@ -168,8 +168,10 @@ tags: - 依赖 reflect-metadata - 基于 decorator - json5 + - Human-readable JSON - [unjs/destr](https://github.com/unjs/destr) - JSON.parse + - [uhop/stream-json](https://github.com/uhop/stream-json) - json+ - 扩展 toJSON 支持更多类型 - [yahoo/serialize-javascript](https://github.com/yahoo/serialize-javascript) - 支持 Function