Merge remote-tracking branch 'origin/feat/channel-prototype' into refactor/claude-review

This commit is contained in:
AAA committed 2026-11-29 20:02:51 +08:00
commit bbfc116aaa
30 files changed
+382 -121

No files matched your search

+35 -4
View File
@@ -1,11 +1,42 @@
# Codex → Claude
Reviewed queue: `d75328e1`. `2ee97233` integrates the source-selection, local
audio, room submission and device-lifetime fixes. Please merge it before editing
their owners. Session remains with me for the reviewed following-record change.
The source-picker and room forms are available for your Escape/Back work.
Reviewed queue: `d75328e1`. Please merge through `531afeea`. `2ee97233` integrates
source selection, local audio, room submission and device lifetimes. `531afeea`
takes the reviewed following record and the other accepted client reductions.
Session, the source-picker and room forms are available for your next review.
A finding count is a review inventory, not a product completion rate.
The receiving preference now waits for media readiness and room acknowledgement.
Initial subscription still completes on acknowledgement. In the error-player
replacement path, the pending action waits for readiness; the HLS fixture now
drives its loader concurrently and checks the typed rejection. The complete Web
run had 2,680 passes and that single stale-fixture timeout; after correcting its
event ordering, all 772 combined Session/HLS checks pass. Both TypeScript projects,
the production bundle and its single-entry manifest pass. Final desktop, phone
and launcher rendering checks retain the controls and theme. The combined diff
removes 842 net lines, chiefly unused copy and duplicated presentation owners.
`531afeea` includes `6d761dc2`, `ff134eaf`, `6b471663`, `6975f712`, `25f32d98`,
`2f920bbd`, `8cb8f43e`, `407e2ca1`, the following-record commits with the readiness
correction, and the single HTML/bootstrap entry. It also fixes empty Markdown
links and mention-marker collisions, and shares package names between packaging
and release validation so a relabelled descriptor is refused before signing.
`214da1af` integrates the shared Rust/Browser cipher fixture. The new Rust reader
was compiled and run, and production Browser send/receive passed with the shared
packets and a state its parser accepts.
The Native MPD projection is now integrated too. It generates only selected
clear-VOD playback structure with opaque resource and representation references.
Source comments, informational metadata and events do not reach the viewer.
Required features outside the existing selected audio/video model are reported
unsupported, rather than silently removed. Shaka 5.3.6 loaded all four original
and projected fixtures in Chrome; selected resources, byte ranges, segment times
and five-period continuity were compared. The canonical bundle check and all
nine MPD Cargo tests pass with the actual library rebuilt. This establishes
manifest parsing and resource equivalence; no new site-specific decode result
is claimed. Generated bundles must retain the repository's LF policy when a
temporary standalone test source has no `.gitattributes`.
## Latest Integration
The address form is reachable from candidate selection and private preview
@@ -1,13 +0,0 @@
import { resolve } from "node:path";
import { defineConfig, mergeConfig } from "vite";
import base from "../../vite.config.ts";
export default mergeConfig(base, defineConfig({
root: resolve(import.meta.dirname, "web"),
publicDir: resolve(import.meta.dirname, "../../public"),
build: {
manifest: "vite-manifest.json",
outDir: resolve(import.meta.dirname, "../../build/channel-web"),
emptyOutDir: true,
},
}));
-21
View File
@@ -1,21 +0,0 @@
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#171a20" media="(prefers-color-scheme: dark)" />
<meta name="theme-color" content="#f4f3ef" media="(prefers-color-scheme: light)" />
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
<title>Piik</title>
<script>
var theme;
try { theme = localStorage.getItem("piik:ui-theme"); } catch (e) {}
document.documentElement.dataset.theme = theme === "light" || theme === "dark"
? theme : matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
</script>
</head>
<body>
<div id="root"></div>
<script type="module" src="./main.tsx"></script>
</body>
</html>
-1
View File
@@ -1 +0,0 @@
import "../../../src/client/main";
+3 -1
View File
@@ -1,4 +1,4 @@
# Native MPD resources
# Native MPD resources
This crate resolves explicitly selected tracks from an immutable, clear static
MPD. The approved page owns the input and opaque choice IDs. Public
@@ -17,6 +17,8 @@ and stack budgets. The App currently supplies a 64 MiB heap and 1 MiB stack
engineering budget; these are not DASH requirements. Encoded fragment limits
and 64 KiB read windows belong to the shared media-resource owner.
Viewer manifests contain the selected clear VOD tracks, playback timing and admitted media, initialization and index resources. Required descriptors outside the supported audio/video presentation return an unsupported-manifest result.
From the repository root:
```sh
+81 -18
View File
@@ -281,22 +281,85 @@ globalThis.serializeMpd = (xml, uri, indicesJson, bindingsJson) => {
if (!children(adaptation, "Representation").length)
period.removeChild(adaptation);
}
for (const period of children(d.root, "Period"))
for (const name of [
"BaseURL",
"SegmentBase",
"SegmentTemplate",
"SegmentList",
])
for (const n of children(period, name)) period.removeChild(n);
for (const name of [
"BaseURL",
"Location",
"UTCTiming",
"ContentSteering",
"PatchLocation",
"Metrics",
])
for (const n of children(d.root, name)) d.root.removeChild(n);
return new XMLSerializer().serializeToString(d.root);
const ns = "urn:mpeg:dash:schema:mpd:2011";
const output = d.root.ownerDocument.implementation.createDocument(ns, "MPD", null);
const fields = {
MPD: "mediaPresentationDuration minBufferTime",
Period: "start duration",
AdaptationSet: "contentType mimeType codecs width height frameRate audioSamplingRate lang",
Representation: "mimeType codecs bandwidth width height frameRate audioSamplingRate",
SegmentBase: "indexRange indexRangeExact timescale presentationTimeOffset",
SegmentList: "timescale presentationTimeOffset startNumber duration",
Initialization: "sourceURL range",
SegmentURL: "media mediaRange",
S: "t d r",
};
const structure = {
MPD: ["Period"],
Period: ["AdaptationSet"],
AdaptationSet: ["Representation"],
Representation: ["BaseURL", "SegmentBase", "SegmentList"],
SegmentBase: ["Initialization"],
SegmentList: ["Initialization", "SegmentTimeline", "SegmentURL"],
SegmentTimeline: ["S"],
};
const logicalIds = new Map();
function project(source, dest) {
const name = dest.localName;
for (const prop of children(source, "EssentialProperty")) {
const scheme = prop.getAttribute("schemeIdUri");
const node = output.createElementNS(ns, "EssentialProperty");
node.setAttribute("schemeIdUri", scheme);
if (["urn:mpeg:mpegB:cicp:TransferCharacteristics",
"urn:mpeg:mpegB:cicp:ColourPrimaries",
"urn:mpeg:mpegB:cicp:MatrixCoefficients"].includes(scheme)) {
const value = Number(prop.getAttribute("value"));
if (!Number.isSafeInteger(value)) throw Error("unsupported_mpd");
node.setAttribute("value", String(value));
} else if (scheme !== "urn:mpeg:dash:ssr:2023") {
throw Error("unsupported_mpd");
}
dest.appendChild(node);
}
if (name === "AdaptationSet" || name === "Representation") {
for (const channel of children(source, "AudioChannelConfiguration")) {
const scheme = channel.getAttribute("schemeIdUri");
const value = channel.getAttribute("value");
let normalized;
if (scheme === "urn:mpeg:dash:outputChannelPositionList:2012") {
normalized = String(value.trim().split(/ +/).length);
} else if (["urn:mpeg:dash:23003:3:audio_channel_configuration:2011",
"urn:dts:dash:audio_channel_configuration:2012",
"urn:mpeg:mpegB:cicp:ChannelConfiguration"].includes(scheme)) {
normalized = parseInt(value, 10).toString(10);
} else if (["tag:dolby.com,2015:dash:audio_channel_configuration:2015",
"tag:dolby.com,2014:dash:audio_channel_configuration:2011",
"urn:dolby:dash:audio_channel_configuration:2011"].includes(scheme)) {
normalized = parseInt(value, 16).toString(16);
} else continue;
if (normalized === "NaN") continue;
const node = output.createElementNS(ns, "AudioChannelConfiguration");
node.setAttribute("schemeIdUri", scheme === "urn:mpeg:dash:outputChannelPositionList:2012"
? "urn:mpeg:dash:23003:3:audio_channel_configuration:2011" : scheme);
node.setAttribute("value", normalized);
dest.appendChild(node);
}
}
for (const field of fields[name]?.split(" ") || [])
if (source.hasAttribute(field)) dest.setAttribute(field, source.getAttribute(field));
if (name === "Representation") {
const id = source.getAttribute("id");
if (!logicalIds.has(id)) logicalIds.set(id, String(logicalIds.size + 1));
dest.setAttribute("id", logicalIds.get(id));
}
if (name === "BaseURL") dest.textContent = source.textContent;
for (const childName of structure[name] || [])
for (const child of children(source, childName)) {
const node = output.createElementNS(ns, childName);
dest.appendChild(node);
project(child, node);
}
}
project(d.root, output.documentElement);
return new XMLSerializer().serializeToString(output.documentElement);
};
+4 -4
View File
@@ -1,8 +1,8 @@
(()=>{var Lu=Object.create;var Nt=Object.defineProperty;var Uu=Object.getOwnPropertyDescriptor;var qu=Object.getOwnPropertyNames;var Mu=Object.getPrototypeOf,Pu=Object.prototype.hasOwnProperty;var K=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(u){throw t=0,u}};var ku=(e,t,u,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of qu(t))!Pu.call(e,n)&&n!==u&&Nt(e,n,{get:()=>t[n],enumerable:!(r=Uu(t,n))||r.enumerable});return e};var De=(e,t,u)=>(u=e!=null?Lu(Mu(e)):{},ku(t||!e||!e.__esModule?Nt(u,"default",{value:e,enumerable:!0}):u,e));var Oe=K((mn,Tt)=>{var he;typeof window<"u"?he=window:typeof global<"u"?he=global:typeof self<"u"?he=self:he={};Tt.exports=he});var ue=K($=>{"use strict";function zu(e,t,u){if(u===void 0&&(u=Array.prototype),e&&typeof u.find=="function")return u.find.call(e,t);for(var r=0;r<e.length;r++)if(Object.prototype.hasOwnProperty.call(e,r)){var n=e[r];if(t.call(void 0,n,r,e))return n}}function Ke(e,t){return t===void 0&&(t=Object),t&&typeof t.freeze=="function"?t.freeze(e):e}function Hu(e,t){if(e===null||typeof e!="object")throw new TypeError("target is not an object");for(var u in t)Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u]);return e}var wt=Ke({HTML:"text/html",isHTML:function(e){return e===wt.HTML},XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),Bt=Ke({HTML:"http://www.w3.org/1999/xhtml",isHTML:function(e){return e===Bt.HTML},SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"}),xe=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,Qe=new RegExp("[\\-\\.0-9"+xe.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),Xu=new RegExp("^"+xe.source+Qe.source+"*(?::"+xe.source+Qe.source+"*)?$");$.assign=Hu;$.find=zu;$.freeze=Ke;$.MIME_TYPE=wt;$.NAMESPACE=Bt;$.nameStartChar=xe;$.nameChar=Qe;$.tagNamePattern=Xu});var pt=K(J=>{var et=ue(),X=et.find,Ae=et.NAMESPACE,re=et.tagNamePattern;function ju(e){return e!==""}function $u(e){return e?e.split(/[\t\n\f\r ]+/).filter(ju):[]}function Yu(e,t){return e.hasOwnProperty(t)||(e[t]=!0),e}function It(e){if(!e)return[];var t=$u(e);return Object.keys(t.reduce(Yu,{}))}function Wu(e){return function(t){return e&&e.indexOf(t)!==-1}}function ve(e,t){for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&(t[u]=e[u])}function k(e,t){var u=e.prototype;if(!(u instanceof t)){let n=function(){};var r=n;n.prototype=t.prototype,n=new n,ve(u,n),e.prototype=u=n}u.constructor!=e&&(typeof e!="function"&&console.error("unknown Class:"+e),u.constructor=e)}var V={},z=V.ELEMENT_NODE=1,ne=V.ATTRIBUTE_NODE=2,ge=V.TEXT_NODE=3,qt=V.CDATA_SECTION_NODE=4,Mt=V.ENTITY_REFERENCE_NODE=5,Zu=V.ENTITY_NODE=6,tt=V.PROCESSING_INSTRUCTION_NODE=7,ut=V.COMMENT_NODE=8,Pt=V.DOCUMENT_NODE=9,kt=V.DOCUMENT_TYPE_NODE=10,Y=V.DOCUMENT_FRAGMENT_NODE=11,Ju=V.NOTATION_NODE=12,L={},x={},An=L.INDEX_SIZE_ERR=(x[1]="Index size error",1),En=L.DOMSTRING_SIZE_ERR=(x[2]="DOMString size error",2),P=L.HIERARCHY_REQUEST_ERR=(x[3]="Hierarchy request error",3),vn=L.WRONG_DOCUMENT_ERR=(x[4]="Wrong document",4),Rt=L.INVALID_CHARACTER_ERR=(x[5]="Invalid character",5),bn=L.NO_DATA_ALLOWED_ERR=(x[6]="No data allowed",6),Cn=L.NO_MODIFICATION_ALLOWED_ERR=(x[7]="No modification allowed",7),Vt=L.NOT_FOUND_ERR=(x[8]="Not found",8),Nn=L.NOT_SUPPORTED_ERR=(x[9]="Not supported",9),Ot=L.INUSE_ATTRIBUTE_ERR=(x[10]="Attribute in use",10),H=L.INVALID_STATE_ERR=(x[11]="Invalid state",11),Tn=L.SYNTAX_ERR=(x[12]="Syntax error",12),Sn=L.INVALID_MODIFICATION_ERR=(x[13]="Invalid modification",13),yn=L.NAMESPACE_ERR=(x[14]="Invalid namespace",14),wn=L.INVALID_ACCESS_ERR=(x[15]="Invalid access",15);function E(e,t){if(t instanceof Error)var u=t;else u=this,Error.call(this,x[e]),this.message=x[e],Error.captureStackTrace&&Error.captureStackTrace(this,E);return u.code=e,t&&(this.message=this.message+": "+t),u}E.prototype=Error.prototype;ve(L,E);function W(){}W.prototype={length:0,item:function(e){return e>=0&&e<this.length?this[e]:null},toString:function(e,t,u){for(var r=!!u&&!!u.requireWellFormed,n=[],o=0;o<this.length;o++)lt(this[o],n,e,t,null,r);return n.join("")},filter:function(e){return Array.prototype.filter.call(this,e)},indexOf:function(e){return Array.prototype.indexOf.call(this,e)}};function ie(e,t){this._node=e,this._refresh=t,rt(this)}function rt(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!==t){var u=e._refresh(e._node);if(eu(e,"length",u.length),!e.$$length||u.length<e.$$length)for(var r=u.length;r in e;r++)Object.prototype.hasOwnProperty.call(e,r)&&delete e[r];ve(u,e),e._inc=t}}ie.prototype.item=function(e){return rt(this),this[e]||null};k(ie,W);function Le(){this._nameIndex=Object.create(null)}function Gt(e,t){for(var u=e.length;u--;)if(e[u]===t)return u}function Qu(e,t){e._nameIndex[t.nodeName]=t}function zt(e,t){e._nLine truncated
`,nexist:"\u2204",nexists:"\u2204",Nfr:"\u{1D511}",nfr:"\u{1D52B}",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",nGt:"\u226B\u20D2",ngt:"\u226F",ngtr:"\u226F",nGtv:"\u226B\u0338",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",NJcy:"\u040A",njcy:"\u045A",nlArr:"\u21CD",nlarr:"\u219A",nldr:"\u2025",nlE:"\u2266\u0338",nle:"\u2270",nLeftarrow:"\u21CD",nleftarrow:"\u219A",nLeftrightarrow:"\u21CE",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nLt:"\u226A\u20D2",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",nopf:"\u{1D55F}",Not:"\u2AEC",not:"\xAC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nRightarrow:"\u21CF",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",Nscr:"\u{1D4A9}",nscr:"\u{1D4C3}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",Ntilde:"\xD1",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",Nu:"\u039D",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nVDash:"\u22AF",nVdash:"\u22AE",nvDash:"\u22AD",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwArr:"\u21D6",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",Oacute:"\xD3",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",Ocirc:"\xD4",ocirc:"\xF4",Ocy:"\u041E",ocy:"\u043E",odash:"\u229D",Odblac:"\u0150",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",OElig:"\u0152",oelig:"\u0153",ofcir:"\u29BF",Ofr:"\u{1D512}",ofr:"\u{1D52C}",ogon:"\u02DB",Ograve:"\xD2",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",Omacr:"\u014C",omacr:"\u014D",Omega:"\u03A9",omega:"\u03C9",Omicron:"\u039F",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",Oopf:"\u{1D546}",oopf:"\u{1D560}",opar:"\u29B7",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",operp:"\u29B9",oplus:"\u2295",Or:"\u2A54",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oS:"\u24C8",Oscr:"\u{1D4AA}",oscr:"\u2134",Oslash:"\xD8",oslash:"\xF8",osol:"\u2298",Otilde:"\xD5",otilde:"\xF5",Otimes:"\u2A37",otimes:"\u2297",otimesas:"\u2A36",Ouml:"\xD6",ouml:"\xF6",ovbar:"\u233D",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4 Line truncated
(()=>{var Lu=Object.create;var Tt=Object.defineProperty;var Uu=Object.getOwnPropertyDescriptor;var qu=Object.getOwnPropertyNames;var Mu=Object.getPrototypeOf,Pu=Object.prototype.hasOwnProperty;var re=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(u){throw t=0,u}};var ku=(e,t,u,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of qu(t))!Pu.call(e,n)&&n!==u&&Tt(e,n,{get:()=>t[n],enumerable:!(r=Uu(t,n))||r.enumerable});return e};var Ae=(e,t,u)=>(u=e!=null?Lu(Mu(e)):{},ku(t||!e||!e.__esModule?Tt(u,"default",{value:e,enumerable:!0}):u,e));var xe=re((mn,St)=>{var Ee;typeof window<"u"?Ee=window:typeof global<"u"?Ee=global:typeof self<"u"?Ee=self:Ee={};St.exports=Ee});var oe=re(Z=>{"use strict";function zu(e,t,u){if(u===void 0&&(u=Array.prototype),e&&typeof u.find=="function")return u.find.call(e,t);for(var r=0;r<e.length;r++)if(Object.prototype.hasOwnProperty.call(e,r)){var n=e[r];if(t.call(void 0,n,r,e))return n}}function tt(e,t){return t===void 0&&(t=Object),t&&typeof t.freeze=="function"?t.freeze(e):e}function Hu(e,t){if(e===null||typeof e!="object")throw new TypeError("target is not an object");for(var u in t)Object.prototype.hasOwnProperty.call(t,u)&&(e[u]=t[u]);return e}var Bt=tt({HTML:"text/html",isHTML:function(e){return e===Bt.HTML},XML_APPLICATION:"application/xml",XML_TEXT:"text/xml",XML_XHTML_APPLICATION:"application/xhtml+xml",XML_SVG_IMAGE:"image/svg+xml"}),It=tt({HTML:"http://www.w3.org/1999/xhtml",isHTML:function(e){return e===It.HTML},SVG:"http://www.w3.org/2000/svg",XML:"http://www.w3.org/XML/1998/namespace",XMLNS:"http://www.w3.org/2000/xmlns/"}),Ue=/[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,et=new RegExp("[\\-\\.0-9"+Ue.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]"),Xu=new RegExp("^"+Ue.source+et.source+"*(?::"+Ue.source+et.source+"*)?$");Z.assign=Hu;Z.find=zu;Z.freeze=tt;Z.MIME_TYPE=Bt;Z.NAMESPACE=It;Z.nameStartChar=Ue;Z.nameChar=et;Z.tagNamePattern=Xu});var mt=re(ee=>{var ut=oe(),Y=ut.find,be=ut.NAMESPACE,ae=ut.tagNamePattern;function ju(e){return e!==""}function $u(e){return e?e.split(/[\t\n\f\r ]+/).filter(ju):[]}function Yu(e,t){return e.hasOwnProperty(t)||(e[t]=!0),e}function Rt(e){if(!e)return[];var t=$u(e);return Object.keys(t.reduce(Yu,{}))}function Wu(e){return function(t){return e&&e.indexOf(t)!==-1}}function Ne(e,t){for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&(t[u]=e[u])}function G(e,t){var u=e.prototype;if(!(u instanceof t)){let n=function(){};var r=n;n.prototype=t.prototype,n=new n,Ne(u,n),e.prototype=u=n}u.constructor!=e&&(typeof e!="function"&&console.error("unknown Class:"+e),u.constructor=e)}var z={},H=z.ELEMENT_NODE=1,se=z.ATTRIBUTE_NODE=2,ve=z.TEXT_NODE=3,Mt=z.CDATA_SECTION_NODE=4,Pt=z.ENTITY_REFERENCE_NODE=5,Zu=z.ENTITY_NODE=6,rt=z.PROCESSING_INSTRUCTION_NODE=7,nt=z.COMMENT_NODE=8,kt=z.DOCUMENT_NODE=9,Vt=z.DOCUMENT_TYPE_NODE=10,J=z.DOCUMENT_FRAGMENT_NODE=11,Ju=z.NOTATION_NODE=12,q={},x={},An=q.INDEX_SIZE_ERR=(x[1]="Index size error",1),En=q.DOMSTRING_SIZE_ERR=(x[2]="DOMString size error",2),V=q.HIERARCHY_REQUEST_ERR=(x[3]="Hierarchy request error",3),vn=q.WRONG_DOCUMENT_ERR=(x[4]="Wrong document",4),Ot=q.INVALID_CHARACTER_ERR=(x[5]="Invalid character",5),bn=q.NO_DATA_ALLOWED_ERR=(x[6]="No data allowed",6),Cn=q.NO_MODIFICATION_ALLOWED_ERR=(x[7]="No modification allowed",7),Gt=q.NOT_FOUND_ERR=(x[8]="Not found",8),Nn=q.NOT_SUPPORTED_ERR=(x[9]="Not supported",9),Ft=q.INUSE_ATTRIBUTE_ERR=(x[10]="Attribute in use",10),j=q.INVALID_STATE_ERR=(x[11]="Invalid state",11),Tn=q.SYNTAX_ERR=(x[12]="Syntax error",12),Sn=q.INVALID_MODIFICATION_ERR=(x[13]="Invalid modification",13),yn=q.NAMESPACE_ERR=(x[14]="Invalid namespace",14),wn=q.INVALID_ACCESS_ERR=(x[15]="Invalid access",15);function S(e,t){if(t instanceof Error)var u=t;else u=this,Error.call(this,x[e]),this.message=x[e],Error.captureStackTrace&&Error.captureStackTrace(this,S);return u.code=e,t&&(this.message=this.message+": "+t),u}S.prototype=Error.prototype;Ne(q,S);function Q(){}Q.prototype={length:0,item:function(e){return e>=0&&e<this.length?this[e]:null},toString:function(e,t,u){for(var r=!!u&&!!u.requireWellFormed,n=[],o=0;o<this.length;o++)ft(this[o],n,e,t,null,r);return n.join("")},filter:function(e){return Array.prototype.filter.call(this,e)},indexOf:function(e){return Array.prototype.indexOf.call(this,e)}};function ce(e,t){this._node=e,this._refresh=t,it(this)}function it(e){var t=e._node._inc||e._node.ownerDocument._inc;if(e._inc!==t){var u=e._refresh(e._node);if(tu(e,"length",u.length),!e.$$length||u.length<e.$$length)for(var r=u.length;r in e;r++)Object.prototype.hasOwnProperty.call(e,r)&&delete e[r];Ne(u,e),e._inc=t}}ce.prototype.item=function(e){return it(this),this[e]||null};G(ce,Q);function Me(){this._nameIndex=Object.create(null)}function zt(e,t){for(var u=e.length;u--;)if(e[u]===t)return u}function Qu(e,t){e._nameIndex[t.nodeName]=t}function Ht(e,t)Line truncated
`,nexist:"\u2204",nexists:"\u2204",Nfr:"\u{1D511}",nfr:"\u{1D52B}",ngE:"\u2267\u0338",nge:"\u2271",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",nGt:"\u226B\u20D2",ngt:"\u226F",ngtr:"\u226F",nGtv:"\u226B\u0338",nhArr:"\u21CE",nharr:"\u21AE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",NJcy:"\u040A",njcy:"\u045A",nlArr:"\u21CD",nlarr:"\u219A",nldr:"\u2025",nlE:"\u2266\u0338",nle:"\u2270",nLeftarrow:"\u21CD",nleftarrow:"\u219A",nLeftrightarrow:"\u21CE",nleftrightarrow:"\u21AE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nLt:"\u226A\u20D2",nlt:"\u226E",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",Nopf:"\u2115",nopf:"\u{1D55F}",Not:"\u2AEC",not:"\xAC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrArr:"\u21CF",nrarr:"\u219B",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nRightarrow:"\u21CF",nrightarrow:"\u219B",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",Nscr:"\u{1D4A9}",nscr:"\u{1D4C3}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsubE:"\u2AC5\u0338",nsube:"\u2288",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupE:"\u2AC6\u0338",nsupe:"\u2289",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",Ntilde:"\xD1",ntilde:"\xF1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",Nu:"\u039D",nu:"\u03BD",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nVDash:"\u22AF",nVdash:"\u22AE",nvDash:"\u22AD",nvdash:"\u22AC",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwArr:"\u21D6",nwarr:"\u2196",nwarrow:"\u2196",nwnear:"\u2927",Oacute:"\xD3",oacute:"\xF3",oast:"\u229B",ocir:"\u229A",Ocirc:"\xD4",ocirc:"\xF4",Ocy:"\u041E",ocy:"\u043E",odash:"\u229D",Odblac:"\u0150",odblac:"\u0151",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",OElig:"\u0152",oelig:"\u0153",ofcir:"\u29BF",Ofr:"\u{1D512}",ofr:"\u{1D52C}",ogon:"\u02DB",Ograve:"\xD2",ograve:"\xF2",ogt:"\u29C1",ohbar:"\u29B5",ohm:"\u03A9",oint:"\u222E",olarr:"\u21BA",olcir:"\u29BE",olcross:"\u29BB",oline:"\u203E",olt:"\u29C0",Omacr:"\u014C",omacr:"\u014D",Omega:"\u03A9",omega:"\u03C9",Omicron:"\u039F",omicron:"\u03BF",omid:"\u29B6",ominus:"\u2296",Oopf:"\u{1D546}",oopf:"\u{1D560}",opar:"\u29B7",OpenCurlyDoubleQuote:"\u201C",OpenCurlyQuote:"\u2018",operp:"\u29B9",oplus:"\u2295",Or:"\u2A54",or:"\u2228",orarr:"\u21BB",ord:"\u2A5D",order:"\u2134",orderof:"\u2134",ordf:"\xAA",ordm:"\xBA",origof:"\u22B6",oror:"\u2A56",orslope:"\u2A57",orv:"\u2A5B",oS:"\u24C8",Oscr:"\u{1D4AA}",oscr:"\u2134",Oslash:"\xD8",oslash:"\xF8",osol:"\u2298",Otilde:"\xD5",otilde:"\xF5",Otimes:"\u2A37",otimes:"\u2297",otimesas:"\u2A36",Ouml:"\xD6",ouml:"\xF6",ovbar:"\u233D",OverBar:"\u203E",OverBrace:"\u23DE",OverBracket:"\u23B4 Line truncated
`).replace(/[\r\u0085\u2028]/g,`
`)}function mu(e){this.options=e||{locator:{}}}mu.prototype.parseFromString=function(e,t){var u=this.options,r=new Ar,n=u.domBuilder||new we,o=u.errorHandler,i=u.locator,s=u.xmlns||{},a=/\/x?html?$/.test(t),c=a?su.HTML_ENTITIES:su.XML_ENTITIES;i&&n.setDocumentLocator(i),r.errorHandler=Er(o,n,i),r.domBuilder=u.domBuilder||n,a&&(s[""]=cu.HTML),s.xml=s.xml||cu.XML;var l=u.normalizeLineEndings||fu;return e&&typeof e=="string"?r.parse(l(e),s,c):r.errorHandler.error("invalid doc source"),n.doc};function Er(e,t,u){if(!e){if(t instanceof we)return t;e=t}var r={},n=e instanceof Function;u=u||{};function o(i){var s=e[i];!s&&n&&(s=e.length==2?function(a){e(i,a)}:e),r[i]=s&&function(a){s("[xmldom "+i+"] "+a+dt(u))}||function(){}}return o("warning"),o("error"),o("fatalError"),r}function we(){this.cdata=!1}function pe(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}we.prototype={startDocument:function(){this.doc=new hr().createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,u,r){var n=this.doc,o=n.createElementNS(e,u||t),i=r.length;ze(this,o),this.currentElement=o,this.locator&&pe(this.locator,o);for(var s=0;s<i;s++){var e=r.getURI(s),a=r.getValue(s),u=r.getQName(s),c=n.createAttributeNS(e,u);this.locator&&pe(r.getLocator(s),c),c.value=c.nodeValue=a,o.setAttributeNode(c)}},endElement:function(e,t,u){var r=this.currentElement,n=r.tagName;this.currentElement=r.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var u=this.doc.createProcessingInstruction(e,t);this.locator&&pe(this.locator,u),ze(this,u)},ignorableWhitespace:function(e,t,u){},characters:function(e,t,u){if(e=lu.apply(this,arguments),e){if(this.cdata)var r=this.doc.createCDATASection(e);else var r=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(r):/^\s*$/.test(e)&&this.doc.appendChild(r),this.locator&&pe(this.locator,r)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,u){e=lu.apply(this,arguments);var r=this.doc.createComment(e);this.locator&&pe(this.locator,r),ze(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,u){var r=this.doc.implementation;if(r&&r.createDocumentType){var n=r.createDocumentType(e,t,u);this.locator&&pe(this.locator,n),ze(this,n),this.doc.doctype=n}},warning:function(e){console.warn("[xmldom warning] "+e,dt(this.locator))},error:function(e){console.error("[xmldom error] "+e,dt(this.locator))},fatalError:function(e){throw new gr(e,this.locator)}};function dt(e){if(e)return`
@`+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function lu(e,t,u){return typeof e=="string"?e.substr(t,u):e.length>=t+u||t?new java.lang.String(e,t,u)+"":e}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){we.prototype[e]=function(){return null}});function ze(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}He.__DOMHandler=we;He.normalizeLineEndings=fu;He.DOMParser=mu});var Dt=K(Xe=>{var Du=pt();Xe.DOMImplementation=Du.DOMImplementation;Xe.XMLSerializer=Du.XMLSerializer;Xe.DOMParser=du().DOMParser});var te=De(Oe()),St="https://example.com",Vu=function(t,u){if(/^[a-z]+:/i.test(u))return u;/^data:/.test(t)&&(t=te.default.location&&te.default.location.href||"");var r=/^\/\//.test(t),n=!te.default.location&&!/\/\//i.test(t);t=new te.default.URL(t,te.default.location||St);var o=new URL(u,t);return n?o.href.slice(St.length):r?o.href.slice(o.protocol.length):o.href},Fe=Vu;var M=De(Oe());var yt=function(t,u,r){u.forEach(function(n){for(var o in t.mediaGroups[n])for(var i in t.mediaGroups[n][o]){var s=t.mediaGroups[n][o][i];r(s,n,o,i)}})};var Ze=De(Oe()),Gu=function(t){return Ze.default.atob?Ze.default.atob(t):Buffer.from(t,"base64").toString("binary")};function Je(e){for(var t=Gu(e),u=new Uint8Array(t.length),r=0;r<t.length;r++)u[r]=t.charCodeAt(r);return u}var Nu=De(Dt());var hu=e=>!!e&&typeof e=="object",_=(...e)=>e.reduce((t,u)=>(typeof u!="object"||Object.keys(u).forEach(r=>{Array.isArray(t[r])&&Array.isArray(u[r])?t[r]=t[r].concat(u[r]):hu(t[r])&&hu(u[r])?t[r]=_(t[r],u[r]):t[r]=u[r]}),t),{}),Tu=e=>Object.keys(e).map(t=>e[t]),vr=(e,t)=>{let u=[];for(let r=e;r<t;r++)u.push(r);return u},me=e=>e.reduce((t,u)=>t.concat(u),[]),Su=e=>{if(!e.length)return[];let t=[];for(let u=0;u<e.length;u++)t.push(e[u]);return t},br=(e,t)=>e.reduce((u,r,n)=>(r[t]&&u.push(n),u),[]),Cr=(e,t)=>Tu(e.reduce((u,r)=>(r.forEach(n=>{u[t(n)]=n}),u),{})),Be={INVALID_NUMBER_OF_PERIOD:"INVALID_NUMBER_OF_PERIOD",INVALID_NUMBER_OF_CONTENT_STEERING:"INVALID_NUMBER_OF_CONTENT_STEERING",DASH_EMPTY_MANIFEST:"DASH_EMPTY_MANIFEST",DASH_INVALID_XML:"DASH_INVALID_XML",NO_BASE_URL:"NO_BASE_URL",MISSING_SEGMENT_INFORMATION:"MISSING_SEGMENT_INFORMATION",SEGMENT_TIME_UNSPECIFIED:"SEGMENT_TIME_UNSPECIFIED",UNSUPPORTED_UTC_TIMING_SCHEME:"UNSUPPORTED_UTC_TIMING_SCHEME"},Ie=({baseUrl:e="",source:t="",range:u="",indexRange:r=""})=>{let n={uri:t,resolvedUri:Fe(e||"",t)};if(u||r){let i=(u||r).split("-"),s=M.default.BigInt?M.default.BigInt(i[0]):parseInt(i[0],10),a=M.default.BigInt?M.default.BigInt(i[1]):parseInt(i[1],10);s<Number.MAX_SAFE_INTEGER&&typeof s=="bigint"&&(s=Number(s)),a<Number.MAX_SAFE_INTEGER&&typeof a=="bigint"&&(a=Number(a));let c;typeof a=="bigint"||typeof s=="bigint"?c=M.default.BigInt(a)-M.default.BigInt(s)+M.default.BigInt(1):c=a-s+1,typeof c=="bigint"&&c<Number.MAX_SAFE_INTEGER&&(c=Number(c)),n.byterange={length:c,offset:s}}return n},Nr=e=>{let t;return typeof e.offset=="bigint"||typeof e.length=="bigint"?t=M.default.BigInt(e.offset)+M.default.BigInt(e.length)-M.default.BigInt(1):t=e.offset+e.length-1,`${e.offset}-${t}`},gu=e=>(e&&typeof e!="number"&&(e=parseInt(e,10)),isNaN(e)?null:e),Tr={static(e){let{duration:t,timescale:u=1,sourceDuration:r,periodDuration:n}=e,o=gu(e.endNumber),i=t/u;return typeof o=="number"?{start:0,end:o}:typeof n=="number"?{start:0,end:n/i}:{start:0,end:r/i}},dynamic(e){let{NOW:t,clientOffset:u,availabilityStartTime:r,timescale:n=1,duration:o,periodStart:i=0,minimumUpdatePeriod:s=0,timeShiftBufferDepth:a=1/0}=e,c=gu(e.endNumber),l=(t+u)/1e3,p=r+i,h=l+s-p,m=Math.ceil(h*n/o),f=Math.floor((l-p-a)*n/o),D=Math.floor((l-p)*n/o);return{start:Math.max(0,f),end:typeof c=="number"?c:Math.min(m,D)}}},Sr=e=>t=>{let{duration:u,timescale:r=1,periodStart:n,startNumber:o=1}=e;return{number:o+t,duration:u/r,timeline:n,time:t*u}},gt=e=>{let{type:t,duration:u,timescale:r=1,periodDuration:n,sourceDuration:o}=e,{start:i,end:s}=Tr[t](e),a=vr(i,s).map(Sr(e));if(t==="static"){let c=a.length-1,l=typeof n=="number"?n:o;a[c].duration=l-u/r*c}return a},yu=e=>{let{baseUrl:t,initialization:u={},sourceDuration:r,indexRange:n="",periodStart:o,presentationTime:i,number:s=0,duration:a}=e;if(!t)throw new Error(Be.NO_BASE_URL);let c=Ie({baseUrl:t,source:u.sourceURL,range:u.range}),l=Ie({baseUrl:t,source:t,indexRange:n});if(l.map=c,a){let p=gt(e);p.length&&(l.duration=p[0].duration,l.timeline=p[0].timeline)}else r&&(l.duration=r,l.timeline=o);return l.presentationTime=i||o,l.number=s,[l]},yr=(e,t,u)=>{let r=e.sidx.map?e.sidx.map:null,n=e.sidx.duration,o=e.timeline||0,i=e.sidx.byterange,s=i.offset+i.length,a=t.timescale,c=t.references.filter(D=>D.referenceType!==1),l=[],p=e.endList?"static":"dynamic",d=e.sidx.timeline,h=d,m=e.mediaSequence||0,f;typeof t.firstOffset=="bigint"?f=M.default.BigInt(s)+t.firstOffset:f=s+t.firstOffset;for(let D=0;D<c.length;D++){let N=t.references[D Line truncated
`)}function du(e){this.options=e||{locator:{}}}du.prototype.parseFromString=function(e,t){var u=this.options,r=new Ar,n=u.domBuilder||new Re,o=u.errorHandler,i=u.locator,s=u.xmlns||{},a=/\/x?html?$/.test(t),c=a?cu.HTML_ENTITIES:cu.XML_ENTITIES;i&&n.setDocumentLocator(i),r.errorHandler=Er(o,n,i),r.domBuilder=u.domBuilder||n,a&&(s[""]=lu.HTML),s.xml=s.xml||lu.XML;var l=u.normalizeLineEndings||mu;return e&&typeof e=="string"?r.parse(l(e),s,c):r.errorHandler.error("invalid doc source"),n.doc};function Er(e,t,u){if(!e){if(t instanceof Re)return t;e=t}var r={},n=e instanceof Function;u=u||{};function o(i){var s=e[i];!s&&n&&(s=e.length==2?function(a){e(i,a)}:e),r[i]=s&&function(a){s("[xmldom "+i+"] "+a+ht(u))}||function(){}}return o("warning"),o("error"),o("fatalError"),r}function Re(){this.cdata=!1}function De(e,t){t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber}Re.prototype={startDocument:function(){this.doc=new hr().createDocument(null,null,null),this.locator&&(this.doc.documentURI=this.locator.systemId)},startElement:function(e,t,u,r){var n=this.doc,o=n.createElementNS(e,u||t),i=r.length;je(this,o),this.currentElement=o,this.locator&&De(this.locator,o);for(var s=0;s<i;s++){var e=r.getURI(s),a=r.getValue(s),u=r.getQName(s),c=n.createAttributeNS(e,u);this.locator&&De(r.getLocator(s),c),c.value=c.nodeValue=a,o.setAttributeNode(c)}},endElement:function(e,t,u){var r=this.currentElement,n=r.tagName;this.currentElement=r.parentNode},startPrefixMapping:function(e,t){},endPrefixMapping:function(e){},processingInstruction:function(e,t){var u=this.doc.createProcessingInstruction(e,t);this.locator&&De(this.locator,u),je(this,u)},ignorableWhitespace:function(e,t,u){},characters:function(e,t,u){if(e=pu.apply(this,arguments),e){if(this.cdata)var r=this.doc.createCDATASection(e);else var r=this.doc.createTextNode(e);this.currentElement?this.currentElement.appendChild(r):/^\s*$/.test(e)&&this.doc.appendChild(r),this.locator&&De(this.locator,r)}},skippedEntity:function(e){},endDocument:function(){this.doc.normalize()},setDocumentLocator:function(e){(this.locator=e)&&(e.lineNumber=0)},comment:function(e,t,u){e=pu.apply(this,arguments);var r=this.doc.createComment(e);this.locator&&De(this.locator,r),je(this,r)},startCDATA:function(){this.cdata=!0},endCDATA:function(){this.cdata=!1},startDTD:function(e,t,u){var r=this.doc.implementation;if(r&&r.createDocumentType){var n=r.createDocumentType(e,t,u);this.locator&&De(this.locator,n),je(this,n),this.doc.doctype=n}},warning:function(e){console.warn("[xmldom warning] "+e,ht(this.locator))},error:function(e){console.error("[xmldom error] "+e,ht(this.locator))},fatalError:function(e){throw new gr(e,this.locator)}};function ht(e){if(e)return`
@`+(e.systemId||"")+"#[line:"+e.lineNumber+",col:"+e.columnNumber+"]"}function pu(e,t,u){return typeof e=="string"?e.substr(t,u):e.length>=t+u||t?new java.lang.String(e,t,u)+"":e}"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(e){Re.prototype[e]=function(){return null}});function je(e,t){e.currentElement?e.currentElement.appendChild(t):e.doc.appendChild(t)}$e.__DOMHandler=Re;$e.normalizeLineEndings=mu;$e.DOMParser=du});var gt=re(Ye=>{var hu=mt();Ye.DOMImplementation=hu.DOMImplementation;Ye.XMLSerializer=hu.XMLSerializer;Ye.DOMParser=Du().DOMParser});var ie=Ae(xe()),yt="https://example.com",Vu=function(t,u){if(/^[a-z]+:/i.test(u))return u;/^data:/.test(t)&&(t=ie.default.location&&ie.default.location.href||"");var r=/^\/\//.test(t),n=!ie.default.location&&!/\/\//i.test(t);t=new ie.default.URL(t,ie.default.location||yt);var o=new URL(u,t);return n?o.href.slice(yt.length):r?o.href.slice(o.protocol.length):o.href},Le=Vu;var k=Ae(xe());var wt=function(t,u,r){u.forEach(function(n){for(var o in t.mediaGroups[n])for(var i in t.mediaGroups[n][o]){var s=t.mediaGroups[n][o][i];r(s,n,o,i)}})};var Qe=Ae(xe()),Gu=function(t){return Qe.default.atob?Qe.default.atob(t):Buffer.from(t,"base64").toString("binary")};function Ke(e){for(var t=Gu(e),u=new Uint8Array(t.length),r=0;r<t.length;r++)u[r]=t.charCodeAt(r);return u}var Tu=Ae(gt());var gu=e=>!!e&&typeof e=="object",L=(...e)=>e.reduce((t,u)=>(typeof u!="object"||Object.keys(u).forEach(r=>{Array.isArray(t[r])&&Array.isArray(u[r])?t[r]=t[r].concat(u[r]):gu(t[r])&&gu(u[r])?t[r]=L(t[r],u[r]):t[r]=u[r]}),t),{}),Su=e=>Object.keys(e).map(t=>e[t]),vr=(e,t)=>{let u=[];for(let r=e;r<t;r++)u.push(r);return u},ge=e=>e.reduce((t,u)=>t.concat(u),[]),yu=e=>{if(!e.length)return[];let t=[];for(let u=0;u<e.length;u++)t.push(e[u]);return t},br=(e,t)=>e.reduce((u,r,n)=>(r[t]&&u.push(n),u),[]),Cr=(e,t)=>Su(e.reduce((u,r)=>(r.forEach(n=>{u[t(n)]=n}),u),{})),Oe={INVALID_NUMBER_OF_PERIOD:"INVALID_NUMBER_OF_PERIOD",INVALID_NUMBER_OF_CONTENT_STEERING:"INVALID_NUMBER_OF_CONTENT_STEERING",DASH_EMPTY_MANIFEST:"DASH_EMPTY_MANIFEST",DASH_INVALID_XML:"DASH_INVALID_XML",NO_BASE_URL:"NO_BASE_URL",MISSING_SEGMENT_INFORMATION:"MISSING_SEGMENT_INFORMATION",SEGMENT_TIME_UNSPECIFIED:"SEGMENT_TIME_UNSPECIFIED",UNSUPPORTED_UTC_TIMING_SCHEME:"UNSUPPORTED_UTC_TIMING_SCHEME"},Fe=({baseUrl:e="",source:t="",range:u="",indexRange:r=""})=>{let n={uri:t,resolvedUri:Le(e||"",t)};if(u||r){let i=(u||r).split("-"),s=k.default.BigInt?k.default.BigInt(i[0]):parseInt(i[0],10),a=k.default.BigInt?k.default.BigInt(i[1]):parseInt(i[1],10);s<Number.MAX_SAFE_INTEGER&&typeof s=="bigint"&&(s=Number(s)),a<Number.MAX_SAFE_INTEGER&&typeof a=="bigint"&&(a=Number(a));let c;typeof a=="bigint"||typeof s=="bigint"?c=k.default.BigInt(a)-k.default.BigInt(s)+k.default.BigInt(1):c=a-s+1,typeof c=="bigint"&&c<Number.MAX_SAFE_INTEGER&&(c=Number(c)),n.byterange={length:c,offset:s}}return n},Nr=e=>{let t;return typeof e.offset=="bigint"||typeof e.length=="bigint"?t=k.default.BigInt(e.offset)+k.default.BigInt(e.length)-k.default.BigInt(1):t=e.offset+e.length-1,`${e.offset}-${t}`},Au=e=>(e&&typeof e!="number"&&(e=parseInt(e,10)),isNaN(e)?null:e),Tr={static(e){let{duration:t,timescale:u=1,sourceDuration:r,periodDuration:n}=e,o=Au(e.endNumber),i=t/u;return typeof o=="number"?{start:0,end:o}:typeof n=="number"?{start:0,end:n/i}:{start:0,end:r/i}},dynamic(e){let{NOW:t,clientOffset:u,availabilityStartTime:r,timescale:n=1,duration:o,periodStart:i=0,minimumUpdatePeriod:s=0,timeShiftBufferDepth:a=1/0}=e,c=Au(e.endNumber),l=(t+u)/1e3,p=r+i,d=l+s-p,h=Math.ceil(d*n/o),D=Math.floor((l-p-a)*n/o),g=Math.floor((l-p)*n/o);return{start:Math.max(0,D),end:typeof c=="number"?c:Math.min(h,g)}}},Sr=e=>t=>{let{duration:u,timescale:r=1,periodStart:n,startNumber:o=1}=e;return{number:o+t,duration:u/r,timeline:n,time:t*u}},Et=e=>{let{type:t,duration:u,timescale:r=1,periodDuration:n,sourceDuration:o}=e,{start:i,end:s}=Tr[t](e),a=vr(i,s).map(Sr(e));if(t==="static"){let c=a.length-1,l=typeof n=="number"?n:o;a[c].duration=l-u/r*c}return a},wu=e=>{let{baseUrl:t,initialization:u={},sourceDuration:r,indexRange:n="",periodStart:o,presentationTime:i,number:s=0,duration:a}=e;if(!t)throw new Error(Oe.NO_BASE_URL);let c=Fe({baseUrl:t,source:u.sourceURL,range:u.range}),l=Fe({baseUrl:t,source:t,indexRange:n});if(l.map=c,a){let p=Et(e);p.length&&(l.duration=p[0].duration,l.timeline=p[0].timeline)}else r&&(l.duration=r,l.timeline=o);return l.presentationTime=i||o,l.number=s,[l]},yr=(e,t,u)=>{let r=e.sidx.map?e.sidx.map:null,n=e.sidx.duration,o=e.timeline||0,i=e.sidx.byterange,s=i.offset+i.length,a=t.timescale,c=t.references.filter(g=>g.referenceType!==1),l=[],p=e.endList?"static":"dynamic",f=e.sidx.timeline,d=f,h=e.mediaSequence||0,D;typeof t.firstOffset=="bigint"?D=k.default.BigInt(s)+t.firstOffset:D=s+t.firstOffset;for(let g=0;g<c.length;g++){let O=t.references[ Line truncated
/*! Bundled license information:
mpd-parser/dist/mpd-parser.es.js:
+28
View File
@@ -170,3 +170,31 @@ fn static_mpd_without_a_complete_track_is_unsupported() {
);
assert_eq!(result.err().unwrap().to_string(), "watch_mpd_unsupported");
}
#[test]
fn viewer_manifest_projects_playback_metadata() {
let fixture = include_str!("../fixtures/clear-multiperiod.mpd");
let serialize = |extra: &str| {
let xml = fixture.replacen("<Period ", &format!("{extra}<Period "), 1);
assert_ne!(xml, fixture);
let doc = MpdSnapshot::inspect(Uuid::new_v4(), xml, base(), limits(), Arc::new(|| false))?;
let ids = [doc.choices()[0].id];
let tracks = doc.resolve_selected(&ids)?;
let mapping = tracks
.iter()
.flat_map(ResolvedTrack::resources)
.map(|r| (r.url.clone(), Uuid::new_v4()))
.collect();
doc.serialize_selected(&ids, &mapping)
};
let output = serialize(r#"<!--fixture-note--><ProgramInformation><Title>fixture-title</Title></ProgramInformation><EventStream schemeIdUri="urn:fixture:event"/><ext:Annotation xmlns:ext="urn:fixture:ext">fixture-extension</ext:Annotation>"#).unwrap();
for marker in [
"fixture-note",
"fixture-title",
"urn:fixture:event",
"fixture-extension",
] {
assert!(!output.contains(marker));
}
assert!(serialize(r#"<EssentialProperty schemeIdUri="urn:fixture:unsupported"/>"#).is_err());
}
+7 -3
View File
@@ -1186,12 +1186,16 @@ fn browser_webcrypto_vector_authenticates_direction_epoch_and_sequence() {
// key=00..1f, nonce=20..2b, seq=1, direction=0, ASCII simple UUID epoch.
let secret = std::array::from_fn(|i| i as u8);
let flow = Uuid::parse_str("0123456789abcdef0123456789abcdef").unwrap();
let packet = "AAAAAAAAAAEgISIjJCUmJygpKiupGNIJHP04NDgPO6CiOol+MAJ012RUZOuDGCEWCIGW";
let fixture: serde_json::Value = serde_json::from_str(include_str!(
"../../../../tests/fixtures/input-cipher.json"
)).unwrap();
let packet = fixture["packet"].as_str().unwrap();
let ready = serde_json::to_vec(&fixture["state"]).unwrap();
let mut cipher = Cipher::new(&secret);
assert!(cipher.open(packet, Uuid::new_v4()).is_err());
assert_eq!(cipher.open(packet, flow).unwrap(), br#"{"type":"sync"}"#);
assert!(cipher.open(packet, flow).is_err());
let state = cipher.seal(br#"{"state":"ready"}"#, flow).unwrap();
let state = cipher.seal(&ready, flow).unwrap();
let bytes = STANDARD.decode(&state).unwrap();
let plain = Aes256Gcm::new((&secret).into())
.decrypt(
@@ -1202,7 +1206,7 @@ fn browser_webcrypto_vector_authenticates_direction_epoch_and_sequence() {
},
)
.unwrap();
assert_eq!(plain, br#"{"state":"ready"}"#);
assert_eq!(plain, ready);
assert!(
Cipher::new(&secret).open(&state, flow).is_err(),
"reflected reply is not controller input"
+4
View File
@@ -91,6 +91,10 @@ export const APP_PACKAGE_TARGETS = [
},
];
export function appArtifactName(targetId) {
return targetId === ANDROID_APP_PACKAGE_TARGET.id ? ANDROID_APP_PACKAGE_TARGET.artifact : `piik-app-${targetId}.zip`;
}
export function appPackageTarget(id) {
return APP_PACKAGE_TARGETS.find((target) => target.id === id) ?? null;
}
+1 -1
View File
@@ -28,7 +28,7 @@ export function buildChannelWeb(root, { version, revision, cargoTarget }) {
writeChannelWebLicenseNotices(root, join(root, 'public', 'third-party-licenses.txt'));
for (const args of [
[join(root, 'prototype', 'channel-browser', 'build.mjs')],
[join(root, 'node_modules', 'vite', 'bin', 'vite.js'), 'build', '--config', 'prototype/channel-browser/web.vite.config.ts'],
[join(root, 'node_modules', 'vite', 'bin', 'vite.js'), 'build'],
]) {
const result = spawnSync(process.execPath, args, { cwd: root, env, stdio: 'inherit', windowsHide: true });
if (result.error) throw result.error;
+2 -2
View File
@@ -17,7 +17,7 @@ import { pipeline } from "node:stream/promises";
import { fileURLToPath } from "node:url";
import { parseArgs } from "node:util";
import { appPackageTarget, CLOUDFLARED_VERSION } from "./app-package-targets.mjs";
import { appArtifactName, appPackageTarget, CLOUDFLARED_VERSION } from "./app-package-targets.mjs";
import { createZip, extractZip, tarExecutable } from "./archive-tool.mjs";
import { assertBuildInputRetained, assertCleanRevision, resetBuildWorkspace } from "./build-workspace.mjs";
import { buildVersion } from "./release-version.mjs";
@@ -122,7 +122,7 @@ try {
mkdirSync(outputRoot, { recursive: false, mode: 0o700 });
outputOwned = true;
const archiveName = `piik-app-${target.id}.zip`;
const archiveName = appArtifactName(target.id);
const archive = join(outputRoot, archiveName);
createZip(packageRoot, archive);
const extractedRoot = join(temporaryRoot, "extracted");
+3 -7
View File
@@ -19,7 +19,7 @@ import { writeServerLicenseNotices } from "./package-licenses.mjs";
import { createZip, extractZip, tarExecutable } from "./archive-tool.mjs";
import { assertBuildInputRetained, assertCleanRevision, resetBuildWorkspace } from "./build-workspace.mjs";
import { buildVersion } from "./release-version.mjs";
import { SERVER_PACKAGE_TARGETS } from "./server-package-targets.mjs";
import { SERVER_PACKAGE_TARGETS, serverReleaseNames } from "./server-package-targets.mjs";
import { sha256, fileRecords, compareFileRecords } from "./package-files.mjs";
import { copyChannelWeb } from "./channel-web-artifact.mjs";
import { buildChannelWeb } from "./build-channel-web.mjs";
@@ -180,11 +180,7 @@ try {
const paths = runtimePaths(target);
const records = recordsFor(runtimeRoot, paths);
const stem = `piik-${releaseId}${target.suffix}`;
const manifestName = `${stem}.manifest.tsv`;
const archiveKind = target.goos === "windows" ? "zip" : "tar.gz";
const artifactName = `${stem}-runtime.${archiveKind}`;
const descriptorName = `${stem}.release.json`;
const { manifest: manifestName, artifact: artifactName, descriptor: descriptorName } = serverReleaseNames(target, revision);
mkdirSync(outputRoot, { recursive: false, mode: 0o700 });
outputOwned = true;
const manifestPath = join(outputRoot, manifestName);
@@ -196,7 +192,7 @@ try {
"ascii",
);
if (archiveKind === "zip") {
if (target.goos === "windows") {
createZip(runtimeRoot, artifactPath);
mkdirSync(verifyRoot);
extractZip(artifactPath, verifyRoot);
+8 -4
View File
@@ -2,8 +2,8 @@ import { createHash, createPublicKey, verify } from "node:crypto";
import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { basename, join, resolve } from "node:path";
import { isDeepStrictEqual } from "node:util";
import { APP_PACKAGE_TARGETS, ANDROID_APP_PACKAGE_TARGET } from "./app-package-targets.mjs";
import { SERVER_PACKAGE_TARGETS } from "./server-package-targets.mjs";
import { appArtifactName, APP_PACKAGE_TARGETS, ANDROID_APP_PACKAGE_TARGET } from "./app-package-targets.mjs";
import { SERVER_PACKAGE_TARGETS, serverReleaseNames } from "./server-package-targets.mjs";
export function updateIndex(release) {
return { schema: 1, version: release.version, revision: release.revision,
@@ -109,15 +109,19 @@ export function readReleaseArtifacts(directory, version, revision, { publicKey =
const target = descriptor.target ?? "server";
if (targets.has(target)) throw new Error(`Duplicate release target: ${target}`);
targets.add(target);
const serverTarget = SERVER_PACKAGE_TARGETS.find(candidate => candidate.id === target);
const serverNames = serverTarget && serverReleaseNames(serverTarget, revision);
if (descriptor.artifact !== (serverNames?.artifact ?? appArtifactName(target))) {
throw new Error(`Release artifact name mismatch: ${target}`);
}
const archive = asset(descriptor.artifact);
if (archive.sha256 !== descriptor.artifactSha256) {
throw new Error(`Release artifact checksum mismatch: ${name}`);
}
packages.push(archive);
packagesByTarget.set(target, archive);
const serverTarget = SERVER_PACKAGE_TARGETS.find(candidate => candidate.id === target);
if (serverTarget) {
if (asset(descriptor.manifest).sha256 !== descriptor.manifestSha256) {
if (descriptor.manifest !== serverNames.manifest || asset(descriptor.manifest).sha256 !== descriptor.manifestSha256) {
throw new Error("Server manifest checksum mismatch");
}
servers.push({ ...archive, arch: serverTarget.goarch, goos: serverTarget.goos });
+6
View File
@@ -6,3 +6,9 @@ export const SERVER_PACKAGE_TARGETS = [
{ id: "server-linux-arm64", goos: "linux", goarch: "arm64", rustTarget: "aarch64-unknown-linux-musl", suffix: "-linux-arm64" },
{ id: "server-windows-amd64", goos: "windows", goarch: "amd64", rustTarget: "x86_64-pc-windows-msvc", suffix: "-windows-amd64" },
];
export function serverReleaseNames(target, revision) {
const stem = `piik-${revision.slice(0, 7)}${target.suffix}`;
const extension = target.goos === "windows" ? "zip" : "tar.gz";
return { artifact: `${stem}-runtime.${extension}`, manifest: `${stem}.manifest.tsv`, descriptor: `${stem}.release.json` };
}
@@ -33,7 +33,9 @@ export function ChannelMessageContent({ message, users, selfUserId }: {
// Markdown also decodes entities; neither raw nor decoded text may forge a reference.
const decoded = markdown.utils.unescapeAll(message.text);
let marker = "\uE000";
while ([message.text, decoded].some(text => text.includes(marker) || text.toLowerCase().includes(encodeURI(marker).toLowerCase()))) marker += "\uE000";
while ([message.text, decoded].some(text => text.includes(marker) || text.toLowerCase().includes(encodeURI(marker).toLowerCase()))) {
marker = String.fromCharCode(marker.charCodeAt(0) + 1);
}
const mentions = message.mentions ?? [];
const references = mentions.map((mention, index) => ({ mention, marker: `${marker}${index}${marker}`,
text: message.text.slice(mention.start, mention.end) }));
@@ -67,13 +69,15 @@ export function ChannelMessageContent({ message, users, selfUserId }: {
else if (token.type === "fence" || token.type === "code_block") result.push(<CodeBlock key={key} text={restore(token.content)} />);
else if (token.type === "softbreak" || token.type === "hardbreak") result.push(<br key={key} />);
else if (token.nesting === 1) {
const contentStart = index;
const inner = children();
if (token.tag === "a") {
const href = references.reduce((href, reference) => href.split(encodeURI(reference.marker)).join(encodeURI(reference.text)),
restore(String(token.attrGet("href") ?? "")));
const hasLabel = tokens.slice(contentStart, index - 1).some(token => token.content.trim());
// Chat links never navigate within the app or execute another URL scheme.
result.push(isExternalLink(href)
? <a key={key} href={href} target="_blank" rel="noopener noreferrer">{inner}</a> : <Fragment key={key}>{inner}</Fragment>);
? <a key={key} href={href} target="_blank" rel="noopener noreferrer">{hasLabel ? inner : href}</a> : <Fragment key={key}>{inner}</Fragment>);
} else if (tags.has(token.tag)) result.push(createElement(token.tag, { key,
...(token.tag === "ol" && token.attrGet("start") ? { start: Number(token.attrGet("start")) } : {}) }, inner));
else result.push(<Fragment key={key}>{inner}</Fragment>);
+26 -11
View File
@@ -36,7 +36,7 @@ import { AppPage, ChannelApp, RoomSettingsRejected, discoverChannelAppHealth, ty
import { nativeVideoCodecSchema, type NativeCaptureTarget, type EncodingExecution, type NativePageMpdSelection, type NativePageMpdCatalog } from "../native/wire";
import type { RemoteControlMode } from "../remote-control/protocol";
import { readRoomPreferences, saveRoomPreferences, subscribeRoomPreferences, type RoomPreferences } from "../lib/room-preferences";
import { CHANNEL_EVENT_BYTES, MAX_NAME_UNITS, MAX_RELAY_CAPACITY, PROFILE_PAGE_SIZE } from "../../shared/core-limits";
import { CHANNEL_EVENT_BYTES, MAX_RELAY_CAPACITY, PROFILE_PAGE_SIZE } from "../../shared/core-limits";
import type { MicrophoneInput } from "../media/microphone-input";
import { VoiceParticipation } from "./voice-participation";
import { debugEvent, debugOperation, debugSample, registerDebugCollector } from "../lib/debug";
@@ -130,7 +130,7 @@ function captureSource(track: MediaStreamTrack | undefined, camera = false): Scr
|| /^(?:current-)?web-contents-media-stream:\/\/[A-F0-9]{32}$/.test(label))) return { kind: "screen", name: null };
let name = "";
for (const character of label) {
if (name.length + character.length > MAX_NAME_UNITS) break;
if (name.length + character.length > 64) break;
name += character;
}
return { kind: camera ? "camera" : "screen", name: name || null };
@@ -3198,8 +3198,7 @@ export class ChannelSession {
const activity = this.view.state?.watchActivities.find(value => value.id === id);
if (!activity || !(await this.watchRoutesOf(activity)).includes(mode)) throw new Error("watch_source_unavailable");
}
await this.joinWatchRoute(id, mode);
this.preferRoute(id, mode);
await this.joinWatchRoute(id, mode, true);
return;
}
const activity = this.view.state?.watchActivities.find(value => value.id === id);
@@ -3213,9 +3212,15 @@ export class ChannelSession {
const player = this.watchPlayer(id);
if (player) void this.followWatchFailure(id, player);
});
private async joinWatchRoute(id: string, mode: WatchMode): Promise<void> {
private async joinWatchRoute(id: string, mode: WatchMode, manual = false): Promise<void> {
const current = this.watchPlayer(id);
if (current?.mode === mode && !current.error && current.presentation.kind !== "external") return;
if (current?.mode === mode && !current.error && current.presentation.kind !== "external") {
if (manual) {
await current.ready();
if (this.watchPlayer(id) === current) this.preferRoute(id, mode);
}
return;
}
const activity = this.view.state?.watchActivities.find(value => value.id === id);
if (!activity) throw new Error("watch_unavailable");
if (mode === "peer") {
@@ -3223,21 +3228,21 @@ export class ChannelSession {
if (!source) throw new Error("watch_source_unavailable");
await this.joinWatchMedia(id, createResourceWatchMedia(source, (resourceId, offset, length, signal) =>
this.watchBytes.read(activity.roomId, id, source, resourceId, offset, length, signal),
{ hlsDeadlineOwner: "reader", timeline: activity.playback.timeline }), mode);
{ hlsDeadlineOwner: "reader", timeline: activity.playback.timeline }), mode, manual);
return;
}
const url = activity.source.kind === "media" ? activity.source.url : activity.source.mediaUrl;
if (url) {
await this.joinWatchMedia(id, new HTMLVideoMedia(url, activity.source.kind === "media" ? directWatchFormat(new URL(url)) : undefined, activity.playback.timeline));
await this.joinWatchMedia(id, new HTMLVideoMedia(url, activity.source.kind === "media" ? directWatchFormat(new URL(url)) : undefined, activity.playback.timeline), mode, manual);
return;
}
const embed = sharedWatchEmbed(activity.source);
if (!embed) throw new Error(originalWatchURL(activity.source) ? "watch_page_required" : "watch_source_unavailable");
if (!canWatchInBrowser(activity.source, current)) throw new Error("watch_media_unsupported");
await this.joinWatchMedia(id, embed.provider === "youtube"
? new YouTubeMedia(embed.id, undefined, true) : new PeerTubeMedia(embed.id, true));
? new YouTubeMedia(embed.id, undefined, true) : new PeerTubeMedia(embed.id, true), mode, manual);
}
private async joinWatchMedia(id: string, media: WatchMedia, mode: WatchMode = "direct"): Promise<void> {
private async joinWatchMedia(id: string, media: WatchMedia, mode: WatchMode, manual: boolean): Promise<void> {
const activity = this.view.state?.watchActivities.find(value => value.id === id);
if (!activity) { media.close(); throw new Error("watch_unavailable"); }
const previous = this.watchPlayer(id);
@@ -3261,6 +3266,7 @@ export class ChannelSession {
player.mode = mode;
if (previous.mode === mode) player.inheritClock(previous);
stage.useWatch(id, player);
if (manual) this.preferRoute(id, mode);
player.update(current.playback);
this.patch({});
if (embedded) await media.waitForPresentation?.(player.signal).catch(() => {});
@@ -3277,7 +3283,8 @@ export class ChannelSession {
this.stage(player.roomId).useWatch(id, player);
player.update(activity.playback);
this.patch({});
void player.ready().catch(error => {
const ready = player.ready();
void ready.catch(error => {
if (!player.signal.aborted && this.watchPlayer(id) === player) {
player.error = error instanceof Error ? error.message : "watch_media_failed";
this.patch({});
@@ -3292,6 +3299,14 @@ export class ChannelSession {
this.patch({});
}
this.browseRooms();
if (manual) {
const intent = this.intents.get(id);
const selected = ready.then(() => {
if (this.intents.get(id) === intent && this.watchPlayer(id) === player && !player.error) this.preferRoute(id, mode);
});
if (previous) await selected;
else void selected.catch(() => {});
}
}
catch (error) {
if (!player.signal.aborted && this.watchPlayer(id) === player) this.retireWatchPlayer(id);
+2 -1
View File
@@ -28,7 +28,8 @@ vi.mock("node:child_process", async (original) => ({
return { status: 0, stdout: "", stderr: "" };
},
}));
vi.mock("../scripts/app-package-targets.mjs", () => ({
vi.mock("../scripts/app-package-targets.mjs", async (original) => ({
...await original<typeof import("../scripts/app-package-targets.mjs")>(),
CLOUDFLARED_VERSION: "fixture",
appPackageTarget: () => ({
id: "fixture", nodePlatform: process.platform, nodeArch: process.arch,
@@ -449,8 +449,10 @@ test.each(["local", "host"] as const)("clearing the %s cache retires its complet
removeEntry.mockRejectedValueOnce(new DOMException("busy", "NoModificationAllowedError"));
await expect(clear()).rejects.toThrow("busy");
expect(command).toHaveBeenCalledWith({ type: "file_receive", ...key, enabled: false });
const afterFailure = command.mock.calls.length;
removeEntry.mockClear();
await clear();
expect(command.mock.calls.slice(afterFailure)).toContainEqual([{ type: "file_receive", ...key, enabled: false }]);
expect(command).toHaveBeenCalledWith({ type: "file_offer", ...key, sha256: attachment.sha256, available: false });
expect(removeEntry).toHaveBeenCalledExactlyOnceWith(getFileHandle.mock.calls[0][0]);
expect(files.originalAvailability(key, attachment, false)).toBeUndefined();
@@ -1,5 +1,5 @@
import { expect, test, vi } from "vitest";
import { act, createElement } from "react";
import { act, createElement, useLayoutEffect } from "react";
import { createRoot } from "react-dom/client";
import { renderToStaticMarkup } from "react-dom/server";
import { ChannelConversation as ConversationView } from "../src/client/channel/components/ChannelConversation";
@@ -64,8 +64,10 @@ test("profile pages retry the failed cursor and retire a pending read when the q
let reply!: (page: ProfilePage) => void, reject!: (reason: Error) => void;
const read = vi.fn<Parameters<typeof useProfileDirectory>[0]>(() => new Promise((resolve, fail) => { reply = resolve; reject = fail; }));
let directory!: ReturnType<typeof useProfileDirectory>;
const committed = vi.fn();
function Reader({ query, known }: { query: { query?: string } | null; known?: { id: string }[] }) {
directory = useProfileDirectory(read, query, known);
useLayoutEffect(() => { committed(directory); });
return null;
}
const render = (query: { query?: string } | null, known?: { id: string }[]) => act(() => root.render(createElement(Reader, { query, known })));
@@ -108,7 +110,9 @@ test("profile pages retry the failed cursor and retire a pending read when the q
await load();
const closing = read.mock.lastCall!;
expect(closing[0]).toStrictEqual({ query: "ab", after: "ab" });
committed.mockClear();
await render(null);
expect(committed.mock.calls[0]?.[0]).toMatchObject({ ids: [], next: undefined, loading: false, failed: false });
expect(closing[1]?.aborted).toBe(true);
await act(() => reject(new Error("aborted")));
await load();
+13
View File
@@ -82,3 +82,16 @@ test("leading blank lines and indented code preserve literal mentions and invita
expect(html).not.toContain('<mark');
expect(html).not.toContain('<a ');
});
test.each(["[]", "![ ]"])("empty Markdown labels expose the safe destination as readable link text (%s)", label => {
const href = "https://example.test/room.png";
const html = render(label + "(" + href + ")");
expect(html).toContain('rel="noopener noreferrer">' + href + "</a>");
expect(html).not.toContain("<img");
});
test("a literal private-use character immediately before a confirmed mention keeps both", () => {
const text = "\uE000@Bo";
const html = render(text, [{ userId: "bo", start: 1, end: 4 }]);
expect(html).toContain('\uE000<mark class="c3-message-mention is-self" title="Bo">@Bo</mark>');
});
+35
View File
@@ -14302,6 +14302,8 @@ test.each(['withdrawn', 'replaced', 'activity', 'direct viewer'] as const)('watc
const direct = socket.sent.findLast(command => command.type === 'join_watch')!;
expect(direct).toMatchObject({ id: activity.id, mode: 'direct' });
socket.receive({ type: 'reply', roomId: 'first', requestId: direct.requestId, result: { type: 'watch_ready', serverTime: 1100 } });
video.readyState = 4;
video.dispatchEvent(new Event("loadeddata"));
await switching;
expect(session.getSnapshot().watchPlayers.get(activity.id)?.signal.aborted).toBe(false);
}
@@ -19109,3 +19111,36 @@ test.each(["cancel", "refusal"] as const)("a private borrowed-page preview prese
expect(session.getSnapshot().watchPlayers.get(String(old.id))).toBe(oldPlayer);
} finally { session.close(); }
});
test("a replacement inherits the confirmed peer while direct media is pending after acknowledgement", async () => {
const { session, socket } = await setup(1000, false);
let readyState = 2;
vi.stubGlobal("document", { createElement: () => Object.assign(new WatchTestVideo(), { readyState }) });
vi.spyOn(watchMedia, "canReceivePeerWatch").mockReturnValue(true);
vi.spyOn(watchMedia, "createResourceWatchMedia").mockImplementation(() => new HTMLVideoMedia("https://media.test/peer.mp4"));
const base = session.getSnapshot().state!;
const source = { id: "before", roomId: "first", sessionId: "publisher", userId: "other", viewerSessionIds: [],
source: { kind: "media", url: "https://media.test/direct.mp4" },
byteSource: { sessionId: crypto.randomUUID(), resourceId: crypto.randomUUID(), format: "file" },
playback: { timeline: "media", position: 0, paused: true, rate: 1, anchorTime: 1000 } };
const reply = (id: string, mode: string) => {
const join = socket.sent.findLast(c => c.type === "join_watch")!;
expect(join).toMatchObject({ id, mode });
socket.receive({ type: "reply", roomId: "first", requestId: join.requestId, result: { type: "watch_ready", serverTime: 1000 } });
};
try {
socket.receive({ type: "state", state: { ...base, watchActivities: [source] } });
const joining = session.joinWatch(source.id, "peer");
reply(source.id, "peer");
await joining;
socket.receive({ type: "state", state: { ...base, watchActivities: [source], watchSubscriptions: [{ id: source.id, mode: "peer" }] } });
session.getSnapshot().watchPlayers.get(source.id)!.error = "watch_media_failed";
readyState = 0;
const switching = session.joinWatch(source.id, "direct").catch(() => {});
reply(source.id, "direct");
await new Promise(resolve => setTimeout(resolve, 0));
const next = { ...source, id: "after", predecessor: { kind: "watch", id: source.id } };
socket.receive({ type: "state", state: { ...base, watchActivities: [next] } });
await vi.waitFor(() => expect(socket.sent.findLast(c => c.type === "join_watch")).toMatchObject({ id: next.id, mode: "peer" }));
await switching;
} finally { session.close(); vi.unstubAllGlobals(); }
});
+37 -4
View File
@@ -7,9 +7,7 @@ function track(kind: "audio" | "video"): MediaStreamTrack {
return { kind, readyState: "live", clone: () => track(kind), stop: vi.fn() } as unknown as MediaStreamTrack;
}
// A refused offer names the senders it carried and no others. The screen goes on with what it had while its
// picture is live, and fails as a whole, releasing every sender once, when no picture is left.
test.each([["no picture", false], ["a live picture and its sound", true]] as const)("a refused offer leaves a screen that had %s", async (_, establishedPicture) => {
function setup() {
vi.stubGlobal("MediaStream", class {
readonly id = crypto.randomUUID();
constructor(private tracks: MediaStreamTrack[] = []) {}
@@ -18,7 +16,7 @@ test.each([["no picture", false], ["a live picture and its sound", true]] as con
removeTrack(track: MediaStreamTrack) { this.tracks = this.tracks.filter(current => current !== track); }
});
const add = vi.fn((track: MediaStreamTrack, init: RTCRtpTransceiverInit) => ({
sender: { track, stream: init.streams![0], getParameters: () => ({ encodings: [] }) },
sender: { track, setStreams() {}, async replaceTrack(next: MediaStreamTrack) { this.track = next; }, stream: init.streams![0], getParameters: () => ({ encodings: [] }) },
receiver: { track: { kind: track.kind } }, currentDirection: "sendrecv",
}));
vi.stubGlobal("RTCPeerConnection", class extends EventTarget {
@@ -38,6 +36,13 @@ test.each([["no picture", false], ["a live picture and its sound", true]] as con
const send = vi.fn(), failed = vi.fn(), outgoingFailed = vi.fn();
const warning = vi.spyOn(console, "warn").mockImplementation(() => {});
const transport = new ChannelTransport({ polite: true, iceServers: [], send, receive() {}, connected() {}, roomData() {}, failed, outgoingFailed });
return { add, send, failed, outgoingFailed, warning, transport };
}
// A refused offer names the senders it carried and no others. The screen goes on with what it had while its
// picture is live, and fails as a whole, releasing every sender once, when no picture is left.
test.each([["no picture", false], ["a live picture and its sound", true]] as const)("a refused offer leaves a screen that had %s", async (_, establishedPicture) => {
const { add, send, failed, outgoingFailed, warning, transport } = setup();
const picture = track("video"), audio = track("audio");
const source = new MediaStream(establishedPicture ? [picture, audio] : [audio]);
const outputs = new Map([["screen", { kind: "screen" as const, stream: source }]]);
@@ -62,3 +67,31 @@ test.each([["no picture", false], ["a live picture and its sound", true]] as con
expect(transport.setOutgoing(new Map())).toBe(establishedPicture);
} finally { transport.close(); }
});
test.each(["attach", "rebind"] as const)("a refused companion %s preserves the picture and other sound", async failure => {
const { add, transport, outgoingFailed } = setup();
const picture = track("video"), rejected = track("audio"), sibling = track("audio");
const source = new MediaStream([picture]);
const publish = (id: string) => transport.setOutgoing(new Map([[id, { kind: "screen", stream: source }]]));
try {
if (failure === "rebind") {
source.removeTrack(picture);
source.addTrack(rejected);
source.addTrack(sibling);
publish("old");
transport.setOutgoing(new Map());
vi.spyOn(add.mock.results[0].value.sender, "replaceTrack").mockRejectedValueOnce(new Error("slot refused"));
source.addTrack(picture);
publish("screen");
} else {
publish("screen");
source.addTrack(rejected);
add.mockImplementationOnce(() => { throw new Error("attach refused"); });
publish("screen");
}
const wrapper = add.mock.calls[0][1].streams![0];
await vi.waitFor(() => expect(wrapper.getTracks()).toEqual(failure === "rebind" ? [sibling, picture] : [picture]));
if (failure === "rebind") expect(add.mock.results[1].value.sender.track).toBe(sibling);
expect(outgoingFailed).not.toHaveBeenCalled();
} finally { transport.close(); }
});
+9
View File
@@ -0,0 +1,9 @@
{
"packet": "AAAAAAAAAAEgISIjJCUmJygpKiupGNIJHP04NDgPO6CiOol+MAJ012RUZOuDGCEWCIGW",
"reply": "AAAAAAAAAAEOsCyXfyNd0rGAA3xGFvNKMkMtmMlc3xc/yShAT4vT8fQZHkUWXDqmlN0tpY4/SVyfMR357YR2X/INLu/ObL1v/1G9DQBjGR+BS+p4WWwH",
"state": {
"platform": "windows",
"mode": "ask",
"state": "ready"
}
}
+7 -7
View File
@@ -1,3 +1,4 @@
import { serverReleaseNames, SERVER_PACKAGE_TARGETS } from "../scripts/server-package-targets.mjs";
import { createHash, generateKeyPairSync } from "node:crypto";
import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
@@ -26,16 +27,15 @@ const keys = generateKeyPairSync("ed25519");
const publicHex = Buffer.from(keys.publicKey.export({ format: "jwk" }).x!, "base64url").toString("hex");
const pem = keys.privateKey.export({ format: "pem", type: "pkcs8" }).toString();
for (const target of ["server", "server-linux-arm64", "server-windows-amd64", "windows-amd64", "linux-amd64", "linux-arm64", "darwin-arm64", "darwin-amd64", "android-universal"]) {
const server = target.startsWith("server");
// The Windows Server package ships a ZIP; the Linux Server packages keep tar.gz.
const archive = target === "android-universal" ? "apk" : target === "server-windows-amd64" ? "zip" : server ? "tar.gz" : "zip";
const artifact = `${target}.${archive}`;
const serverTarget = SERVER_PACKAGE_TARGETS.find(candidate => candidate.id === target);
const server = serverTarget && serverReleaseNames(serverTarget, revision);
const artifact = server?.artifact ?? `piik-app-${target}.${target === "android-universal" ? "apk" : "zip"}`;
writeFileSync(join(directory, artifact), target);
writeFileSync(join(directory, `${target}.release.json`), JSON.stringify({
schema: 2, version, revision, artifact, artifactSha256: hash(target),
target, ...(server ? { manifest: `${target}.manifest.tsv`, manifestSha256: hash("manifest") } : {}),
target, ...(server ? { manifest: server.manifest, manifestSha256: hash("manifest") } : {}),
}));
if (server) writeFileSync(join(directory, `${target}.manifest.tsv`), "manifest");
if (server) writeFileSync(join(directory, server.manifest), "manifest");
else writeFileSync(join(directory, `${artifact}.sha256`), `${hash(target)} ${artifact}\n`);
}
afterAll(() => rmSync(directory, { recursive: true, force: true }));
@@ -432,7 +432,7 @@ describe("publisher recovery", () => {
let draftBody = "";
const initial = await publish([], "absent", "upload", body => { draftBody = body; });
expect(initial.failure).toBe("GitHub upload failed");
const names = ["windows-amd64.zip", "windows-amd64.release.json", "windows-amd64.zip.sha256"];
const names = ["piik-app-windows-amd64.zip", "windows-amd64.release.json", "piik-app-windows-amd64.zip.sha256"];
const original = names.map(name => readFileSync(join(directory, name)));
const oldDigest = hash(original[0]!);
const newBytes = Buffer.from("rebuilt Windows archive at the same source SHA");
+8 -7
View File
@@ -1,3 +1,4 @@
import { serverReleaseNames, SERVER_PACKAGE_TARGETS } from "../scripts/server-package-targets.mjs";
import { execFileSync, spawnSync } from "node:child_process";
import { createHash } from "node:crypto";
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
@@ -284,14 +285,14 @@ describe("release automation", () => {
const run = () => spawnSync(process.execPath, [publisher, root, version, revision, "--dry-run"], { encoding: "utf8" });
try {
for (const target of ["server", "server-linux-arm64", "server-windows-amd64", "windows-amd64", "linux-amd64", "linux-arm64", "darwin-arm64", "darwin-amd64", "android-universal"]) {
const server = target.startsWith("server");
const archive = target === "android-universal" ? "apk" : target === "server-windows-amd64" ? "zip" : server ? "tar.gz" : "zip";
const artifact = `${target}.${archive}`;
const serverTarget = SERVER_PACKAGE_TARGETS.find(candidate => candidate.id === target);
const server = serverTarget && serverReleaseNames(serverTarget, revision);
const artifact = server?.artifact ?? `piik-app-${target}.${target === "android-universal" ? "apk" : "zip"}`;
writeFileSync(join(root, artifact), target);
const descriptor = { schema: 2, version, revision, artifact, artifactSha256: sha(target),
target, ...(server ? { manifest: `${target}.manifest.tsv`, manifestSha256: sha("manifest") } : {}) };
target, ...(server ? { manifest: server.manifest, manifestSha256: sha("manifest") } : {}) };
writeFileSync(join(root, `${target}.release.json`), JSON.stringify(descriptor));
if (server) writeFileSync(join(root, `${target}.manifest.tsv`), "manifest");
if (server) writeFileSync(join(root, server.manifest), "manifest");
else writeFileSync(join(root, `${artifact}.sha256`), `${sha(target)} ${artifact}\n`);
}
const complete = run();
@@ -303,7 +304,7 @@ describe("release automation", () => {
rmSync(androidDescriptor);
expect(run().stderr).toContain("every registered Server and App target");
writeFileSync(androidDescriptor, androidMetadata);
const checksum = join(root, "windows-amd64.zip.sha256");
const checksum = join(root, "piik-app-windows-amd64.zip.sha256");
const originalChecksum = readFileSync(checksum, "utf8");
writeFileSync(checksum, "wrong checksum");
expect(run().stderr).toContain("App checksum file mismatch");
@@ -313,7 +314,7 @@ describe("release automation", () => {
writeFileSync(path, JSON.stringify({ ...JSON.parse(original), revision: "b".repeat(40) }));
expect(run().stderr).toContain("Release identity mismatch");
writeFileSync(path, original);
writeFileSync(join(root, "windows-amd64.zip"), "changed bytes");
writeFileSync(join(root, "piik-app-windows-amd64.zip"), "changed bytes");
expect(run().stderr).toContain("checksum mismatch");
} finally { rmSync(root, { recursive: true, force: true }); }
});
+19 -6
View File
@@ -6,7 +6,7 @@ import { join } from "node:path";
import { fileURLToPath } from "node:url";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { APP_PACKAGE_TARGETS, ANDROID_APP_PACKAGE_TARGET } from "../scripts/app-package-targets.mjs";
import { SERVER_PACKAGE_TARGETS } from "../scripts/server-package-targets.mjs";
import { serverReleaseNames, SERVER_PACKAGE_TARGETS } from "../scripts/server-package-targets.mjs";
import { readReleaseArtifacts } from "../scripts/release-artifacts.mjs";
import { signUpdateIndex } from "../scripts/release-update-index.mjs";
@@ -24,14 +24,15 @@ beforeEach(() => {
vi.stubEnv("PIIK_UPDATE_PUBLIC_KEY", publicHex);
root = mkdtempSync(join(tmpdir(), "piik-update-index-"));
for (const target of [...SERVER_PACKAGE_TARGETS, ...APP_PACKAGE_TARGETS, ANDROID_APP_PACKAGE_TARGET]) {
const server = SERVER_PACKAGE_TARGETS.some(candidate => candidate.id === target.id);
const artifact = `${target.id}.${target.id === "android-universal" ? "apk" : "zip"}`;
const serverTarget = SERVER_PACKAGE_TARGETS.find(candidate => candidate.id === target.id);
const server = serverTarget && serverReleaseNames(serverTarget, revision);
const artifact = server?.artifact ?? `piik-app-${target.id}.${target.id === "android-universal" ? "apk" : "zip"}`;
writeFileSync(join(root, artifact), target.id);
writeFileSync(join(root, `${target.id}.release.json`), JSON.stringify({
schema: 2, version, revision, target: target.id, artifact, artifactSha256: sha(target.id),
...(server ? { manifest: `${target.id}.manifest.tsv`, manifestSha256: sha("manifest") } : {}),
...(server ? { manifest: server.manifest, manifestSha256: sha("manifest") } : {}),
}));
if (server) writeFileSync(join(root, `${target.id}.manifest.tsv`), "manifest");
if (server) writeFileSync(join(root, server.manifest), "manifest");
else writeFileSync(join(root, `${artifact}.sha256`), `${sha(target.id)} ${artifact}\n`);
}
});
@@ -72,6 +73,18 @@ describe("signed update index", () => {
expect(() => readReleaseArtifacts(root, version, revision, options)).toThrow("must both be present");
});
it.each([["windows-amd64", "linux-amd64"], ["server", "server-linux-arm64"]])(
"refuses to sign a %s descriptor relabelled as %s", (first, second) => {
for (const [actual, claimed] of [[first, second], [second, first]] as const) {
const path = join(root, `${actual}.release.json`);
const descriptor = JSON.parse(readFileSync(path, "utf8"));
writeFileSync(path, JSON.stringify({ ...descriptor, target: claimed }));
}
expect(() => run()).toThrow("Release artifact name mismatch");
expect(existsSync(join(root, "signed"))).toBe(false);
},
);
it("refuses unsigned updater publication", () => {
const result = dryRun("");
expect(result.status).toBe(1);
@@ -135,7 +148,7 @@ describe("signed update index", () => {
rmSync(descriptor);
expect(() => run()).toThrow("every registered Server and App target");
writeFileSync(descriptor, original);
writeFileSync(join(root, "windows-amd64.zip"), "changed bytes");
writeFileSync(join(root, "piik-app-windows-amd64.zip"), "changed bytes");
expect(() => run()).toThrow("checksum mismatch");
expect(existsSync(join(root, "signed"))).toBe(false);
});
+26
View File
@@ -1,3 +1,4 @@
import fixture from "./fixtures/input-cipher.json";
import { expect, it, vi } from "vitest";
import { RemoteInputSession } from "../src/client/remote-control/input-session";
import { picturePoint, rotatePicturePoint, rotatePictureDelta, type VideoRotation } from "../src/client/media/video-geometry";
@@ -544,3 +545,28 @@ it.each([
const point = picturePoint(video, inside.x, inside.y);
expect(point?.x).toBeCloseTo(.2); expect(point?.y).toBeCloseTo(.5);
});
it("exchanges sync and ready packets with the Native input cipher", async () => {
const epoch = "0123456789abcdef0123456789abcdef";
const secret = "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f";
const sent = vi.fn();
const channel = new EncryptedInput({ endpointId: "a".repeat(32), secret }, { sent: 0n }, sent, epoch);
const nonce = vi.spyOn(crypto, "getRandomValues").mockImplementationOnce(bytes => {
(bytes as Uint8Array).set(Array.from({ length: 12 }, (_, i) => 32 + i));
return bytes;
});
try {
channel.send('{"type":"sync"}');
await vi.waitFor(() => expect(sent).toHaveBeenCalledWith({
id: "a".repeat(32), epoch, data: fixture.packet,
}));
} finally {
nonce.mockRestore();
}
const message = new Promise<string>(resolve => {
channel.addEventListener("message", event => resolve((event as MessageEvent<string>).data), { once: true });
});
// Captured from Native Cipher::seal with the same synthetic key and epoch.
channel.receive(fixture.reply);
expect(remoteInputStateSchema.parse(JSON.parse(await message))).toMatchObject(fixture.state);
});
+4 -3
View File
@@ -125,11 +125,11 @@ test("actual Session explicit peer command retains the admitted root and reader
stage.useWatch(activity.id, old);
Object.assign(session, { view: { ...view, state: { watchActivities: [activity], publications: [], channel: { rooms: [] } } }, watchBytes: { read }, request });
try {
await session.joinWatch(activity.id, "peer");
expect(commands).toEqual([{ type: "join_watch", roomId: activity.roomId, id: activity.id, mode: "peer" }]);
const joining = expect(session.joinWatch(activity.id, "peer")).rejects.toThrow("watch_source_unavailable");
const hls = await attached;
await expect.poll(() => commands).toEqual([{ type: "join_watch", roomId: activity.roomId, id: activity.id, mode: "peer" }]);
const player = session.getSnapshot().watchPlayers.get(activity.id)!;
expect(player.mode).toBe("peer");expect(player).not.toBe(old);
const hls = await attached;
const Loader = hls.config.loader,loader = new Loader(hls.config),failed=vi.fn();
loader.load({ url: `https://watch-media.invalid/${root.resourceId}`, responseType: "arraybuffer", type: LoaderContextType.MANIFEST }, { loadPolicy: { maxTimeToFirstByteMs: 1000, maxLoadTimeMs: 1000 } } as never,
{ onError: failed, onSuccess: vi.fn(), onTimeout: vi.fn() } as never);
@@ -140,6 +140,7 @@ test("actual Session explicit peer command retains the admitted root and reader
hls.trigger(Hls.Events.ERROR, { fatal: true, type: Hls.ErrorTypes.NETWORK_ERROR,
details: Hls.ErrorDetails.FRAG_LOAD_ERROR, response: failed.mock.calls[0][0] } as never);
await expect.poll(() => player.error).toBe("watch_source_unavailable");
await joining;
loader.destroy();
expect(activity.byteSource).toBe(root);
expect(old.error).toBe("watch_media_unavailable");
+1
View File
@@ -39,6 +39,7 @@ export default defineConfig({
// Local build output includes Browser profiles, not application entries.
optimizeDeps: { entries: ["index.html", "site/**/*.html"] },
build: {
manifest: "vite-manifest.json",
outDir: "build/channel-web",
emptyOutDir: true,
},