Piik now has one public presentation and a coordinated App/Server release path. This phase unifies the room UI, rewrites the bilingual README and guides, adds a static website with an inline product film, and prepares matching GitHub/Gitee packages and update links. The film uses the current homepage and shared product controls on one seekable timeline. Runtime fixes preserve presentation when the App opens a room, normalize Site origins, and keep capture and media-recovery status in the television indicator. New visits use Chinese for a Chinese system language and English otherwise; explicit language and visual-mode choices remain available. An optional site passphrase controls site entry, while room authorization remains enforced. GitHub is the release authority. Gitee mirrors verified packages and provides update metadata when GitHub is unavailable. Reviewed PR release notes become the GitHub Release description. The separate public demo uses P2P only, with HTTPS and STUN verified. Validation: 756 Web tests, TypeScript and production build; Go core tests, formatting, vet and available target builds; bounded Windows capture and App/Site interoperability; browser film checks, audible playback and narrow layouts; anonymous Gitee Windows-package download, checksum and launcher/update-link checks. Public demo acceptance covers authenticated WebSocket signaling, synthetic P2P video and room cleanup on one network. macOS/Linux physical capture and the wider device/network/endurance matrix remain explicitly deferred. Publication builds every package from the merged source SHA. The repository is public, main protection is active, and Pages is configured for piik.tv. CI/publisher and Pages deployment records own publication results. ## Release notes ### 中文 Piik 是免费开源的屏幕共享工具。开个房间,发出邀请,最多 20 位朋友就能用浏览器加入观看。 - 使用浏览器或 Piik App 分享游戏、窗口和整个屏幕。 - 优先建立直连;自托管站点可开启媒体转发作为备用线路。 - Piik App 支持本地房间、临时公网邀请和已有站点。 - Piik Server 内置网页界面、房间管理和连接服务,方便自行部署。 - 提供中英文界面与使用指南,以及 GitHub、Gitee 两条下载线路。 [官网](https://piik.tv) · [在线体验](https://demo.piik.tv) · [使用指南](https://github.com/TNTcraftHIM/Piik/blob/main/docs/guide/getting-started.zh-CN.md) · [自行部署](https://github.com/TNTcraftHIM/Piik/blob/main/docs/operations/self-hosting.zh-CN.md) · [Gitee 下载](https://gitee.com/TNTcraftHIM/Piik/releases) Windows App 和桌面浏览器是本次主要验证的平台。macOS 和 Linux 尚未经过实机测试,欢迎有设备的朋友测试并反馈。演示站和 App 公网邀请使用 P2P,受限网络下可能无法连接;自托管站点可开启媒体转发。 ### English Piik is free, open-source screen sharing for you and up to 20 viewers. Start a room, send an invitation, and your friends can join in a browser. - Share games, windows or a whole screen from your browser or Piik App. - Direct connections come first, with optional media forwarding on self-hosted sites. - Piik App supports local rooms, temporary public invitations and existing sites. - Piik Server includes the web interface, rooms and connection services for self-hosting. - English and Chinese interfaces and guides are available, with GitHub and Gitee downloads. [Website](https://piik.tv) · [Online demo](https://demo.piik.tv) · [User guide](https://github.com/TNTcraftHIM/Piik/blob/main/docs/guide/getting-started.md) · [Self-hosting](https://github.com/TNTcraftHIM/Piik/blob/main/docs/operations/self-hosting.md) · [Gitee downloads](https://gitee.com/TNTcraftHIM/Piik/releases) Windows App and desktop browsers are the primary validated paths. macOS and Linux have not yet been tested on physical devices; testing and feedback are welcome. The demo and App public invitations rely on P2P and may not connect on restrictive networks. Self-hosted sites can enable media forwarding.
154 lines
3.8 KiB
Go
154 lines
3.8 KiB
Go
// Package ordered provides an insertion-ordered map with live iteration.
|
|
// Wire-visible participant order, candidate ordering, round-robin state and
|
|
// deletion during iteration depend on those semantics.
|
|
package ordered
|
|
|
|
import "iter"
|
|
|
|
type entry[K comparable, V any] struct {
|
|
key K
|
|
value V
|
|
deleted bool
|
|
}
|
|
|
|
// Map keeps keys in first-insertion order. Set on an existing key keeps its
|
|
// position; MoveToBack removes and reinserts it at the end. Iteration is live:
|
|
// an entry deleted before it is visited is skipped and an entry appended
|
|
// during iteration is visited.
|
|
// The zero value is ready to use.
|
|
type Map[K comparable, V any] struct {
|
|
entries []entry[K, V]
|
|
index map[K]int
|
|
deleted int
|
|
iterating int
|
|
}
|
|
|
|
// Len reports the number of live entries.
|
|
func (m *Map[K, V]) Len() int { return len(m.index) }
|
|
|
|
// Get returns the value for key and whether it is present.
|
|
func (m *Map[K, V]) Get(key K) (V, bool) {
|
|
if position, ok := m.index[key]; ok {
|
|
return m.entries[position].value, true
|
|
}
|
|
var zero V
|
|
return zero, false
|
|
}
|
|
|
|
// Has reports whether key is present.
|
|
func (m *Map[K, V]) Has(key K) bool {
|
|
_, ok := m.index[key]
|
|
return ok
|
|
}
|
|
|
|
// Set stores value under key, keeping the existing position when the key is
|
|
// already present and appending otherwise.
|
|
func (m *Map[K, V]) Set(key K, value V) {
|
|
if position, ok := m.index[key]; ok {
|
|
m.entries[position].value = value
|
|
return
|
|
}
|
|
if m.index == nil {
|
|
m.index = make(map[K]int)
|
|
}
|
|
m.index[key] = len(m.entries)
|
|
m.entries = append(m.entries, entry[K, V]{key: key, value: value})
|
|
}
|
|
|
|
// MoveToBack re-inserts key at the end, as JavaScript `map.delete(k);
|
|
// map.set(k, v)` does. It is a plain Set when the key is absent.
|
|
func (m *Map[K, V]) MoveToBack(key K, value V) {
|
|
m.Delete(key)
|
|
m.Set(key, value)
|
|
}
|
|
|
|
// Delete removes key and reports whether it was present.
|
|
func (m *Map[K, V]) Delete(key K) bool {
|
|
position, ok := m.index[key]
|
|
if !ok {
|
|
return false
|
|
}
|
|
delete(m.index, key)
|
|
var zero V
|
|
m.entries[position].value = zero
|
|
m.entries[position].deleted = true
|
|
m.deleted++
|
|
m.compact()
|
|
return true
|
|
}
|
|
|
|
// Clear removes every entry. Dropping the index before compacting is safe
|
|
// because every entry is now a tombstone, so compact writes no index entry.
|
|
func (m *Map[K, V]) Clear() {
|
|
for position := range m.entries {
|
|
if !m.entries[position].deleted {
|
|
var zero V
|
|
m.entries[position].value = zero
|
|
m.entries[position].deleted = true
|
|
m.deleted++
|
|
}
|
|
}
|
|
m.index = nil
|
|
m.compact()
|
|
}
|
|
|
|
// Keys returns a snapshot of the live keys in order.
|
|
func (m *Map[K, V]) Keys() []K {
|
|
keys := make([]K, 0, len(m.index))
|
|
for _, current := range m.entries {
|
|
if !current.deleted {
|
|
keys = append(keys, current.key)
|
|
}
|
|
}
|
|
return keys
|
|
}
|
|
|
|
// Values returns a snapshot of the live values in order.
|
|
func (m *Map[K, V]) Values() []V {
|
|
values := make([]V, 0, len(m.index))
|
|
for _, current := range m.entries {
|
|
if !current.deleted {
|
|
values = append(values, current.value)
|
|
}
|
|
}
|
|
return values
|
|
}
|
|
|
|
// All iterates live entries in order with JavaScript Map semantics. Mutating
|
|
// the map inside the loop is allowed.
|
|
func (m *Map[K, V]) All() iter.Seq2[K, V] {
|
|
return func(yield func(K, V) bool) {
|
|
m.iterating++
|
|
defer func() {
|
|
m.iterating--
|
|
m.compact()
|
|
}()
|
|
for position := 0; position < len(m.entries); position++ {
|
|
current := m.entries[position]
|
|
if current.deleted {
|
|
continue
|
|
}
|
|
if !yield(current.key, current.value) {
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// compact drops tombstones once they dominate, but never while an iteration
|
|
// is walking the entry slice.
|
|
func (m *Map[K, V]) compact() {
|
|
if m.iterating > 0 || m.deleted == 0 || m.deleted*2 < len(m.entries) {
|
|
return
|
|
}
|
|
live := make([]entry[K, V], 0, len(m.index))
|
|
for _, current := range m.entries {
|
|
if !current.deleted {
|
|
m.index[current.key] = len(live)
|
|
live = append(live, current)
|
|
}
|
|
}
|
|
m.entries = live
|
|
m.deleted = 0
|
|
}
|