@4players/odin-common 9.1.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,28 +7,55 @@
7
7
  A collection of commonly used type definitions and schemas across ODIN web
8
8
  projects.
9
9
 
10
+ ## Entrypoints
11
+
12
+ The package is split into three entrypoints:
13
+
14
+ ### `@4players/odin-common`
15
+
16
+ Lightweight utilities with no heavy dependencies. Includes logging, a `Result` type, video
17
+ codec helpers, async primitives (sleep, task queues, promise racing), base64/byte array encoding,
18
+ UUID generation, environment detection, type guards, URL helpers and the backend plugin API types.
19
+
20
+ ```ts
21
+ import { Logger, LogFilter } from '@4players/odin-common';
22
+ ```
23
+
24
+ ### `@4players/odin-common/api`
25
+
26
+ Zod-based schemas for the ODIN Voice protocol (rooms, peers, media, tokens, channels)
27
+ and RPC command/notification definitions. Importing from this entrypoint will pull in Zod.
28
+
29
+ ```ts
30
+ import { TokenClaims, TokenClaimsSchema } from '@4players/odin-common/api';
31
+ ```
32
+
33
+ ### `@4players/odin-common/zod`
34
+
35
+ Re-exports the Zod library for consumers that need to create their own schemas without
36
+ adding a separate Zod dependency.
37
+
38
+ ```ts
39
+ import { zod } from '@4players/odin-common/zod';
40
+ ```
41
+
10
42
  ## Troubleshooting
11
43
 
12
- Contact us through the listed methods below to receive answers to your questions
13
- and learn more about ODIN.
44
+ Contact us through the listed methods below to receive answers to your questions and learn more about ODIN.
14
45
 
15
46
  ### Discord
16
47
 
17
- Join our official Discord server to chat with us directly and become a part of
18
- the 4Players ODIN community.
48
+ Join our official Discord server to chat with us directly and become a part of the 4Players ODIN community.
19
49
 
20
50
  [![Join us on Discord](https://www.4players.io/images/join_discord.png)](https://4np.de/discord)
21
51
 
22
52
  ### Twitter
23
53
 
24
- Have a quick question? Tweet us at
25
- [@ODIN4Players](https://twitter.com/ODIN4Players) and we’ll help you resolve any
26
- issues.
54
+ Have a quick question? Tweet us at [@ODIN4Players](https://twitter.com/ODIN4Players) and we’ll help you resolve any issues.
27
55
 
28
56
  ### Email
29
57
 
30
- Don’t use Discord or Twitter? Send us an [email](mailto:odin@4players.io) and
31
- we’ll get back to you as soon as possible.
58
+ Don’t use Discord or Twitter? Send us an [email](mailto:odin@4players.io) and we’ll get back to you as soon as possible.
32
59
 
33
60
  [npm-badge-url]: https://www.npmjs.com/package/@4players/odin-common
34
61
  [license-url]: https://github.com/4Players/odin-sdk-web/blob/master/LICENSE
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ export type RpcValue = Uint8Array | string | number | boolean | null | RpcValue[] | {
3
+ [key: string]: RpcValue;
4
+ };
5
+ export type RpcSchema = z.ZodType<RpcValue, unknown>;
6
+ export declare const ByteArraySchema: any;
7
+ export type ByteArray = z.infer<typeof ByteArraySchema>;
8
+ declare const LiteralSchema: any;
9
+ type Literal = z.infer<typeof LiteralSchema>;
10
+ export type JsonValue = Literal | {
11
+ [key: string]: JsonValue;
12
+ } | JsonValue[];
13
+ export declare const JsonSchema: z.ZodType<JsonValue>;
14
+ export declare const MessagePackRpcSchema: any;
15
+ export type MessagePackRpc = z.infer<typeof MessagePackRpcSchema>;
16
+ export {};
package/cjs/mod.js CHANGED
@@ -1 +1 @@
1
- var ke=Object.create;var M=Object.defineProperty;var Re=Object.getOwnPropertyDescriptor;var Pe=Object.getOwnPropertyNames;var Te=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var Ae=(e,t)=>{for(var n in t)M(e,n,{get:t[n],enumerable:!0})},ee=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let m of Pe(t))!Ce.call(e,m)&&m!==n&&M(e,m,{get:()=>t[m],enumerable:!(s=Re(t,m))||s.enumerable});return e};var T=(e,t,n)=>(n=e!=null?ke(Te(e)):{},ee(t||!e||!e.__esModule?M(n,"default",{value:e,enumerable:!0}):n,e)),Le=e=>ee(M({},"__esModule",{value:!0}),e);var Mt={};Ae(Mt,{APM_DEFAULTS:()=>wt,Backend:()=>ye,ByteArraySchema:()=>b,CONNECTION_STATS_INITIAL:()=>Ct,ChannelSet:()=>N,ChannelSetSchema:()=>q,ConsoleSink:()=>J,Formatter:()=>ge,GLOBAL_LOGGER:()=>P,JITTER_STATS_INITIAL:()=>At,JsonSchema:()=>C,LogFilter:()=>F,LogLevel:()=>Q,LogSymbols:()=>fe,Logger:()=>k,MainCommandsRpc:()=>Ue,MainNotificationSchema:()=>Ie,MainNotificationsRpc:()=>Be,MediaAudioPropertiesSchema:()=>ne,MediaIdSchema:()=>S,MediaPropertiesSchema:()=>j,MediaSchema:()=>U,MediaVideoPropertiesSchema:()=>oe,MessagePackRpcSchema:()=>Me,MessageReceivedSchema:()=>O,MinDBFS:()=>Cr,PeerIdSchema:()=>x,PeerPositionSchema:()=>L,PeerSchema:()=>_,PeerUpdateSchema:()=>I,RoomCommandsRpc:()=>_e,RoomNotificationSchema:()=>Ne,RoomNotificationsRpc:()=>Oe,RoomV1:()=>z,RoomV2:()=>ae,Selector:()=>H,Strand:()=>Z,TokenAudienceSchema:()=>te,TokenClaimsSchema:()=>je,TokenSubjectSchema:()=>re,VAD_DEFAULTS:()=>Lt,VideoCodec:()=>$,WebRtcUpdateSchema:()=>R,abortableSleep:()=>Qe,assert:()=>w,debug:()=>Pt,error:()=>zt,extendUrl:()=>rt,fail:()=>G,failure:()=>h,find:()=>qe,fromBase64:()=>De,fromBase64Url:()=>Fe,fromBytes:()=>Ve,generateUUID:()=>ot,info:()=>Rt,isAudioCapable:()=>Ge,isBlinkBrowser:()=>pe,isElectronBrowser:()=>He,isFailure:()=>mt,isFirefoxBrowser:()=>Ze,isFunction:()=>st,isNull:()=>pt,isNumber:()=>ct,isObject:()=>ut,isProperty:()=>at,isSafariBrowser:()=>Ye,isSharedArrayBufferCapable:()=>$e,isString:()=>dt,isSuccess:()=>ft,isUndefined:()=>lt,log:()=>Tt,nextTick:()=>et,normalizeUrl:()=>tt,oneOrMany:()=>A,sleep:()=>Xe,success:()=>y,toBytes:()=>Je,toRaw:()=>Ke,tryParseLogFilter:()=>St,unwrap:()=>Ee,unwrapOr:()=>E,validateUUID:()=>it,warn:()=>kt});module.exports=Le(Mt);var d=require("zod"),b=d.z.custom(e=>e instanceof Uint8Array),we=d.z.union([d.z.string(),d.z.number(),d.z.boolean(),d.z.null()]),C=d.z.lazy(()=>d.z.union([we,d.z.array(C),d.z.record(d.z.string(),C)])),Me=d.z.union([d.z.tuple([d.z.literal(0),d.z.number(),d.z.string(),d.z.unknown()]),d.z.tuple([d.z.literal(1),d.z.number(),d.z.nullable(d.z.string()),d.z.unknown()]),d.z.tuple([d.z.literal(2),d.z.string(),d.z.unknown()])]);var c=require("zod"),te=c.z.enum(["sfu","gateway"]),re=c.z.enum(["connect","roomclose","roomupdate","roombanclient","roomsendmessage"]),je=c.z.object({uid:c.z.string(),cid:c.z.optional(c.z.string()),rid:A(c.z.string()).refine(e=>e.length>=1,{message:"missing rid"}),nsp:c.z.optional(c.z.string()),adr:c.z.optional(c.z.string()),aud:c.z.optional(A(te)),sub:c.z.optional(A(re)),exp:c.z.optional(c.z.number()),nbf:c.z.optional(c.z.number()),ups:c.z.optional(c.z.string()),tgs:c.z.optional(A(c.z.string())),tsp:c.z.optional(c.z.number()),internal:c.z.optional(c.z.object({server:c.z.optional(c.z.string())}))});function A(e){return c.z.union([e.transform(t=>[t]),c.z.array(e)])}var r=T(require("zod"));var u=T(require("zod")),S=u.number(),ne=u.object({kind:u.optional(u.literal("audio")),uid:u.optional(u.string()),customType:u.optional(u.string())}),oe=u.object({kind:u.optional(u.literal("video")),codec:u.optional(u.string()),uid:u.optional(u.string()),customType:u.optional(u.string()),id:u.optional(u.string())}),j=u.union([ne,oe]),U=u.object({id:S,properties:j,paused:u.boolean()});var l=T(require("zod"));var x=l.number(),L=l.union([l.tuple([l.number(),l.number(),l.number()]),l.tuple([l.number(),l.number()])]),_=l.object({id:x,user_id:l.string(),user_data:b,medias:l.array(U)}),I=l.discriminatedUnion("kind",[l.object({kind:l.literal("UserDataChanged"),peer_id:x,user_data:b}),l.object({kind:l.literal("MediaStarted"),peer_id:x,media:U}),l.object({kind:l.literal("MediaStopped"),peer_id:x,media_id:S})]);var ie=T(require("zod")),N=class e{constructor(t=BigInt(0)){this.value=t}from(...t){let n=t.reduce((s,m)=>s|B(m),BigInt(0));return new e(n)}contains(t){return(this.value&B(t))!==BigInt(0)}insert(t){this.value|=B(t)}remove(t){this.value&=~B(t)}[Symbol.iterator](){let t=-1,n=new e(this.value);return{next(){for(;t<63;)if(t+=1,n.contains(t))return{value:t,done:!1};return{value:void 0,done:!0}}}}},q=ie.bigint().transform(e=>new N(e));function B(e){return BigInt(1)<<BigInt(e)}var z;(p=>(p.RoomIdSchema=r.string(),p.RoomSchema=r.object({id:p.RoomIdSchema,customer:r.string(),user_data:b,peers:r.array(_)}),p.RoomUpdateSchema=r.discriminatedUnion("kind",[r.object({kind:r.literal("Joined"),room:p.RoomSchema,media_ids:r.array(S),own_peer_id:x}),r.object({kind:r.literal("Left"),reason:r.enum(["RoomClosing","ServerClosing","PeerKicked"])}),r.object({kind:r.literal("UserDataChanged"),user_data:r.optional(b)}),r.object({kind:r.literal("PeerJoined"),peer:_}),r.object({kind:r.literal("PeerLeft"),peer_id:x})]),p.RoomUpdatesSchema=r.object({updates:r.array(p.RoomUpdateSchema)}),p.RoomStatusSchema=r.enum(["Joining","Joined","Closed"]),p.RoomStatusChangedSchema=r.object({status:p.RoomStatusSchema,message:r.optional(r.string())})))(z||={});var ae;(i=>(i.ParametersSchema=r.record(r.string(),C),i.PeerProperties=r.object({user_data:b.optional(),tags:r.array(r.string()).optional(),audio_parameters:i.ParametersSchema.optional(),video_parameters:i.ParametersSchema.optional()}),i.PingSchema=r.object({Ping:r.object({id:r.number()})}),i.ChangeSelfSchema=r.object({ChangeSelf:i.PeerProperties.omit({tags:!0})}),i.SetAudioMaskSchema=r.object({SetAudioMask:r.object({peer_id:r.number(),mask:q})}),i.SendMessageSchema=r.object({SendMessage:r.object({peer_ids:r.number().array().default([]),message:b})}),i.CallSchema=i.PingSchema.or(i.ChangeSelfSchema).or(i.SetAudioMaskSchema).or(i.SendMessageSchema),i.PongSchema=r.object({Pong:r.object({id:r.number()})}),i.JoinedSchema=r.object({Joined:r.object({own_peer_id:r.number(),room_id:r.string(),customer:r.string()})}),i.LeftSchema=r.object({Left:r.object({reason:r.enum(["room_closing","server_closing","peer_kicked"])})}),i.PeerJoinedSchema=r.object({PeerJoined:i.PeerProperties.extend({peer_id:r.number(),user_id:r.string()})}),i.PeerLeftSchema=r.object({PeerLeft:r.object({peer_id:r.number()})}),i.PeerChangedSchema=r.object({PeerChanged:i.PeerProperties.extend({peer_id:r.number()})}),i.NewReconnectTokenSchema=r.object({NewReconnectToken:r.object({token:r.string()})}),i.MessageReceivedSchema=r.object({MessageReceived:r.object({sender_peer_id:r.number(),message:b})}),i.ErrorSchema=r.object({Error:r.object({message:b})}),i.EventSchema=i.PongSchema.or(i.JoinedSchema).or(i.LeftSchema).or(i.PeerJoinedSchema).or(i.PeerLeftSchema).or(i.PeerChangedSchema).or(i.NewReconnectTokenSchema).or(i.MessageReceivedSchema).or(i.ErrorSchema)))(ae||={});var se=require("zod");var O=se.z.object({sender_peer_id:x,message:b});var a=T(require("zod"));var R=a.discriminatedUnion("kind",[a.object({kind:a.literal("Sdp"),type:a.enum(["Answer","Offer"]),sdp:a.string(),media_map:a.array(a.tuple([S,a.string()]))}),a.object({kind:a.literal("Trickle"),candidate:a.string(),spd_mid:a.optional(a.string()),spd_mline_index:a.optional(a.number()),username_fragment:a.optional(a.union([a.string(),a.null()]))}),a.object({kind:a.literal("TrickleFinished")})]);var o=require("zod");var Ue={Hello:{request:o.z.object({stream:o.z.literal("main")}),response:o.z.null()},JoinRoom:{request:o.z.object({token:o.z.string(),room_id:z.RoomIdSchema,user_data:b,position:L}),response:o.z.object({peer_id:x,stream_id:o.z.optional(o.z.number()),token:o.z.optional(o.z.string())})},WebRtcUpdate:{request:R,response:o.z.null()},RequestReconnectToken:{request:o.z.object({peer_id:o.z.optional(x)}),response:o.z.string()},Ping:{request:o.z.object({}),response:o.z.null()}},_e={Hello:{request:o.z.object({stream:o.z.literal("room"),token:o.z.string(),room_id:o.z.string(),user_data:b,position:L}),response:o.z.null()},UpdatePeer:{request:o.z.object({user_data:b}),response:o.z.null()},StartMedia:{request:o.z.object({media_id:S,properties:j}),response:o.z.null()},StopMedia:{request:o.z.object({media_id:S}),response:o.z.null()},PauseMedia:{request:o.z.object({media_id:S}),response:o.z.null()},ResumeMedia:{request:o.z.object({media_id:S}),response:o.z.null()},SetPeerPosition:{request:o.z.object({position:L}),response:o.z.null()},SendMessage:{request:o.z.object({target_peer_ids:o.z.optional(o.z.array(x)),message:b}),response:o.z.null()}};var v=require("zod");var Ie=v.z.object({name:v.z.literal("WebRtcUpdate"),properties:R}),Be={WebRtcUpdate:R},Ne=v.z.union([v.z.object({name:v.z.literal("RoomStatusChanged"),properties:z.RoomStatusChangedSchema}),v.z.object({name:v.z.literal("RoomUpdated"),properties:z.RoomUpdatesSchema}),v.z.object({name:v.z.literal("PeerUpdated"),properties:I}),v.z.object({name:v.z.literal("MessageReceived"),properties:O})]),Oe={RoomStatusChanged:z.RoomStatusChangedSchema,RoomUpdated:z.RoomUpdatesSchema,PeerUpdated:I,MessageReceived:O};function w(e,t){e||G(t)}function G(e){throw new Error(e)}function y(e){return{type:"Success",value:e}}function h(e){return{type:"Failure",reason:e}}function Ee(e){return e.type==="Failure"&&G(e.reason),e.value}function E(e,t){return e.type==="Success"?e.value:t}function De(e){try{let t=atob(e),n=Uint8Array.from(t,m=>m.codePointAt(0)),s=new TextDecoder("utf8");return y(s.decode(n))}catch(t){return h(String(t))}}function Fe(e){try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")),n=Uint8Array.from(t,m=>m.codePointAt(0)),s=new TextDecoder("utf8");return y(s.decode(n))}catch(t){return h(String(t))}}function Je(e){try{w(e!==void 0,"undefined cannot be converted to byte array"),w(e!==null,"null cannot be converted to byte array");let t=JSON.stringify(e),n=new TextEncoder;return y(n.encode(t))}catch(t){return h(String(t))}}function Ve(e){try{w(e.length>0,"empty byte array cannot be converted to value");let t=new TextDecoder().decode(e),n=JSON.parse(t);return y(n)}catch(t){return h(String(t))}}var We=["VP8","VP9","AV1","H264"],$=class{constructor(t){this.codec=t}channels=0;clockRate=9e4;isValid(){return We.includes(this.codec)}isSupported(){if(typeof RTCRtpReceiver>"u"||typeof RTCRtpReceiver.getCapabilities>"u")return null;let t=E(this.getMimeType(),"").toLowerCase(),n=new Set(E(this.getSdpFmtpLine(),"").split(";").map(s=>s.trim().toLowerCase()));return RTCRtpReceiver.getCapabilities("video")?.codecs?.find(s=>{let m=s.mimeType.toLowerCase(),f=new Set((s.sdpFmtpLine??"").split(";").map(p=>p.trim().toLowerCase()));if(t!==m||n.size!==f.size)return!1;for(let p of n)if(!f.has(p))return!1;return!0})??null}getPayloadType(){switch(this.codec){case"VP8":return y(96);case"VP9":return y(98);case"AV1":return y(41);case"H264":return y(102);default:return h("invalid video codec")}}getMimeType(){switch(this.codec){case"VP8":return y("video/VP8");case"VP9":return y("video/VP9");case"AV1":return y("video/AV1");case"H264":return y("video/H264");default:return h("invalid video codec")}}getSdpFmtpLine(){switch(this.codec){case"VP8":return y("");case"VP9":return y("profile-id=2");case"AV1":return y("level-idx=5;profile=0;tier=0");case"H264":return y("level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f");default:return h("invalid video codec")}}};function qe(e,t){for(let n of e)if(t(n))return n}function Ge(){return typeof AudioContext<"u"&&typeof Worker<"u"}function $e(){return typeof SharedArrayBuffer<"u"}function pe(){return/(apple)?webkit\/537\.36/i.test(globalThis.navigator.userAgent)}function He(){return/electron/i.test(globalThis.navigator.userAgent)}function Ze(){return/firefox|iceweasel|fxios/i.test(globalThis.navigator.userAgent)}function Ye(){return pe()?!1:/safari|applewebkit/i.test(globalThis.navigator.userAgent)}function Ke(e){return JSON.parse(JSON.stringify(e))}var H=class e{constructor(t){this._Generators=t;this._Futures=t.map(e.addIndex)}_Futures;async next(){let[t,n]=await Promise.race(this._Futures);return this._Futures[n]=e.addIndex(this._Generators[n],n),t}static async addIndex(t,n){return[await t(),n]}};function Xe(e,t){return e<=0?Promise.resolve(t):new Promise(n=>setTimeout(()=>n(t),e))}function Qe(e,t){return t.aborted?Promise.resolve("aborted"):new Promise(n=>{let s=()=>n("aborted");t.addEventListener("abort",s,{once:!0}),setTimeout(()=>{t.removeEventListener("abort",s),n(void 0)},e)})}function et(){return new Promise(e=>setTimeout(e,0))}var Z=class{_Tasks=[];_Running=!1;_Values;constructor(...t){this._Values=t}enqueue(t){return new Promise((n,s)=>{let m=async()=>{try{let f=await t(...this._Values);n(f)}catch(f){s(f)}};this._Tasks.push(m),this._Running||this.execute()})}async execute(){for(this._Running=!0;;){let t=this._Tasks.shift();if(t===void 0)break;await t()}this._Running=!1}};function tt(e){let t=e.trim();e.indexOf("://")===-1&&(t=`https://${t}`);try{return y(new URL(t))}catch(n){return h(String(n))}}function rt(e,t){let n=e.pathname;n.endsWith("/")===!1&&(n+="/");try{return y(new URL(n+t,e))}catch(s){return h(String(s))}}var nt=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function ot(){return crypto.randomUUID()}function it(e){return nt.test(e)}function at(e,t){return t in e}function st(e){return typeof e=="function"}function pt(e){return typeof e=="object"&&e===null}function ct(e){return typeof e=="number"}function ut(e){return typeof e=="object"}function dt(e){return typeof e=="string"}function lt(e){return typeof e>"u"}function mt(e){return e.type==="Failure"}function ft(e){return e.type==="Success"}var{Deno:ce}=globalThis,gt=typeof ce?.noColor=="boolean"?ce.noColor:!1,yt=!gt;function Y(e,t){return{open:`\x1B[${e.join(";")}m`,close:`\x1B[${t}m`,regexp:new RegExp(`\\x1b\\[${t}m`,"g")}}function K(e,t){return yt?`${t.open}${e.replace(t.regexp,t.open)}${t.close}`:e}function D(e){return K(e,Y([0],0))}function X(e){return K(e,Y([1],22))}function ue(e){return K(e,Y([2],22))}var Pr=new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");var F=(g=>(g[g.Nothing=0]="Nothing",g[g.CRITICAL=1]="CRITICAL",g[g.ERROR=2]="ERROR",g[g.WARN=3]="WARN",g[g.INFO=4]="INFO",g[g.DEBUG=5]="DEBUG",g[g.Everything=6]="Everything",g))(F||{}),xt=new Date,Q=(f=>(f[f.CRITICAL=1]="CRITICAL",f[f.ERROR=2]="ERROR",f[f.WARN=3]="WARN",f[f.INFO=4]="INFO",f[f.DEBUG=5]="DEBUG",f))(Q||{}),fe={1:"\u{1F4A5}",2:"\u{1F534}",3:"\u{1F7E1}",4:"\u{1F535}",5:"\u{1F7E3}"},ht={5:ue,4:D,3:D,2:X,1:X};function St(e){for(let t of Object.keys(F))if(isNaN(Number(t))!==!1&&t.localeCompare(e,void 0,{sensitivity:"accent"})===0)return F[t]}function vt({message:e}){return String(e)}function de(e){return JSON.stringify({timestamp:e.date.toISOString(),level:Q[e.level],message:e.message,extra:e.extra})}function le(e){function t(p,g){return[Math.floor(p/g),p%g]}function n(){let p,g=e.date.valueOf()-xt.valueOf();[g,p]=t(g,1e3);let[V,W]=t(g,60);return`${V.toString().padStart(4,"0")}:${W.toString().padStart(2,"0")}.${p.toString().padStart(4,"0")}`}function s(){return e.extra===void 0?"":"Deno"in globalThis?" "+Deno.inspect(e.extra,{compact:!1,colors:!0,trailingComma:!0}).trimStart():" "+JSON.stringify(e.extra)}let m=fe[e.level],f=e.logger.name!==void 0?`@${e.logger}`:"";return`${D(n())}${f} ${m} ${ht[e.level](String(e.message))}${s()}`}var ge={sparse:vt,json:de,pretty:le,default:"Deno"in globalThis&&Deno.stdout.isTerminal()?le:de},J=class{#e;#t;filter;constructor(t=ge.default,n=6,s=console){this.filter=n,this.#e=t,this.#t=s}handle(t){let n=this.#e(t);switch(t.level){case 2:this.#t.error(n);break;case 3:this.#t.warn(n);break;case 4:this.#t.info(n);break;case 5:this.#t.debug(n);break}}},k=class{#e;sinks;filter;get name(){return this.#e}constructor(t,n=void 0,s=[new J]){this.#e=n,this.sinks=s,this.filter=t}log(t,n,s=void 0){if(this.filter<t)return;let m=me;for(let f of this.sinks)f.filter<t||(m===me&&(m={date:new Date,level:t,logger:this,message:typeof n=="function"?n():n,extra:s}),f.handle(m))}error=this.log.bind(this,2);warn=this.log.bind(this,3);info=this.log.bind(this,4);debug=this.log.bind(this,5)},P=new k(4),zt=k.prototype.log.bind(P,2),kt=k.prototype.log.bind(P,3),Rt=k.prototype.log.bind(P,4),Pt=k.prototype.log.bind(P,5),Tt=k.prototype.log.bind(P),me=Symbol();var Cr=-758.596,ye;(t=>{let e;(p=>(p[p.InvalidPassword=-1]="InvalidPassword",p[p.Unknown=0]="Unknown",p[p.Unencrypted=1]="Unencrypted",p[p.Encrypted=2]="Encrypted"))(e=t.PeerCipherStatus||={})})(ye||={});var Ct={bytesSent:0,bytesReceived:0,packetsSent:0,packetsReceived:0,rtt:0,packetLoss:0},At={packetsBuffered:0,packetsSeen:0,packetsProcessed:0,packetsTooEarly:0,packetsTooLate:0,packetsDropped:0,packetsInvalid:0,packetsRepeated:0,packetsLost:0},Lt={voiceActivity:{attackThreshold:.9,releaseThreshold:.8},volumeGate:{attackThreshold:-30,releaseThreshold:-40}},wt={echoCanceller:!0,highPassFilter:!1,noiseSuppression:"Moderate",transientSuppressor:!1,gainController:!0};0&&(module.exports={APM_DEFAULTS,Backend,ByteArraySchema,CONNECTION_STATS_INITIAL,ChannelSet,ChannelSetSchema,ConsoleSink,Formatter,GLOBAL_LOGGER,JITTER_STATS_INITIAL,JsonSchema,LogFilter,LogLevel,LogSymbols,Logger,MainCommandsRpc,MainNotificationSchema,MainNotificationsRpc,MediaAudioPropertiesSchema,MediaIdSchema,MediaPropertiesSchema,MediaSchema,MediaVideoPropertiesSchema,MessagePackRpcSchema,MessageReceivedSchema,MinDBFS,PeerIdSchema,PeerPositionSchema,PeerSchema,PeerUpdateSchema,RoomCommandsRpc,RoomNotificationSchema,RoomNotificationsRpc,RoomV1,RoomV2,Selector,Strand,TokenAudienceSchema,TokenClaimsSchema,TokenSubjectSchema,VAD_DEFAULTS,VideoCodec,WebRtcUpdateSchema,abortableSleep,assert,debug,error,extendUrl,fail,failure,find,fromBase64,fromBase64Url,fromBytes,generateUUID,info,isAudioCapable,isBlinkBrowser,isElectronBrowser,isFailure,isFirefoxBrowser,isFunction,isNull,isNumber,isObject,isProperty,isSafariBrowser,isSharedArrayBufferCapable,isString,isSuccess,isUndefined,log,nextTick,normalizeUrl,oneOrMany,sleep,success,toBytes,toRaw,tryParseLogFilter,unwrap,unwrapOr,validateUUID,warn});
1
+ var x=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var j=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var r in t)x(e,r,{get:t[r],enumerable:!0})},$=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of M(t))!j.call(e,s)&&s!==r&&x(e,s,{get:()=>t[s],enumerable:!(n=N(t,s))||n.enumerable});return e};var G=e=>$(x({},"__esModule",{value:!0}),e);var Fe={};_(Fe,{APM_DEFAULTS:()=>H,Backend:()=>P,CONNECTION_STATS_INITIAL:()=>J,ConsoleSink:()=>g,Formatter:()=>B,GLOBAL_LOGGER:()=>l,InteractiveConsoleSink:()=>S,JITTER_STATS_INITIAL:()=>W,LogFilter:()=>y,LogLevel:()=>b,LogSymbols:()=>A,Logger:()=>p,MinDBFS:()=>Me,Selector:()=>R,Strand:()=>T,VAD_DEFAULTS:()=>z,VideoCodec:()=>h,abortableSleep:()=>ue,assert:()=>d,debug:()=>Be,error:()=>Ie,extendUrl:()=>le,fail:()=>v,failure:()=>c,find:()=>ee,fromBase64:()=>q,fromBase64Url:()=>Y,fromBytes:()=>K,generateUUID:()=>ge,info:()=>Ee,isAudioCapable:()=>te,isBlinkBrowser:()=>w,isElectronBrowser:()=>ne,isFailure:()=>Te,isFirefoxBrowser:()=>oe,isFunction:()=>ye,isNull:()=>be,isNumber:()=>xe,isObject:()=>ve,isProperty:()=>me,isSafariBrowser:()=>ie,isSharedArrayBufferCapable:()=>re,isString:()=>he,isSuccess:()=>ke,isUndefined:()=>Re,log:()=>Ue,nextTick:()=>ce,normalizeUrl:()=>pe,sleep:()=>ae,success:()=>o,toBytes:()=>X,toRaw:()=>se,tryParseLogFilter:()=>we,unwrap:()=>Z,unwrapOr:()=>f,validateUUID:()=>fe,warn:()=>De});module.exports=G(Fe);var Me=-758.596,P;(t=>{let e;(u=>(u[u.InvalidPassword=-1]="InvalidPassword",u[u.Unknown=0]="Unknown",u[u.Unencrypted=1]="Unencrypted",u[u.Encrypted=2]="Encrypted"))(e=t.PeerCipherStatus||={})})(P||={});var J={bytesSent:0,bytesReceived:0,packetsSent:0,packetsReceived:0,rtt:0,packetLoss:0},W={packetsBuffered:0,packetsSeen:0,packetsProcessed:0,packetsTooEarly:0,packetsTooLate:0,packetsDropped:0,packetsInvalid:0,packetsRepeated:0,packetsLost:0},z={voiceActivity:{attackThreshold:.9,releaseThreshold:.8},volumeGate:{attackThreshold:-30,releaseThreshold:-40}},H={echoCanceller:!0,highPassFilter:!1,noiseSuppression:"Moderate",transientSuppressor:!1,gainController:!0};function d(e,t){e||v(t)}function v(e){throw new Error(e)}function o(e){return{type:"Success",value:e}}function c(e){return{type:"Failure",reason:e}}function Z(e){return e.type==="Failure"&&v(e.reason),e.value}function f(e,t){return e.type==="Success"?e.value:t}function q(e){try{let t=atob(e),r=Uint8Array.from(t,s=>s.codePointAt(0)),n=new TextDecoder("utf8");return o(n.decode(r))}catch(t){return c(String(t))}}function Y(e){try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")),r=Uint8Array.from(t,s=>s.codePointAt(0)),n=new TextDecoder("utf8");return o(n.decode(r))}catch(t){return c(String(t))}}function X(e){try{d(e!==void 0,"undefined cannot be converted to byte array"),d(e!==null,"null cannot be converted to byte array");let t=JSON.stringify(e),r=new TextEncoder;return o(r.encode(t))}catch(t){return c(String(t))}}function K(e){try{d(e.length>0,"empty byte array cannot be converted to value");let t=new TextDecoder().decode(e),r=JSON.parse(t);return o(r)}catch(t){return c(String(t))}}var Q=["VP8","VP9","AV1","H264"],h=class{constructor(t){this.codec=t}channels=0;clockRate=9e4;isValid(){return Q.includes(this.codec)}isSupported(){if(typeof RTCRtpReceiver>"u"||typeof RTCRtpReceiver.getCapabilities>"u")return null;let t=f(this.getMimeType(),"").toLowerCase(),r=new Set(f(this.getSdpFmtpLine(),"").split(";").map(n=>n.trim().toLowerCase()));return RTCRtpReceiver.getCapabilities("video")?.codecs?.find(n=>{let s=n.mimeType.toLowerCase(),i=new Set((n.sdpFmtpLine??"").split(";").map(u=>u.trim().toLowerCase()));if(t!==s||r.size!==i.size)return!1;for(let u of r)if(!i.has(u))return!1;return!0})??null}getPayloadType(){switch(this.codec){case"VP8":return o(96);case"VP9":return o(98);case"AV1":return o(41);case"H264":return o(102);default:return c("invalid video codec")}}getMimeType(){switch(this.codec){case"VP8":return o("video/VP8");case"VP9":return o("video/VP9");case"AV1":return o("video/AV1");case"H264":return o("video/H264");default:return c("invalid video codec")}}getSdpFmtpLine(){switch(this.codec){case"VP8":return o("");case"VP9":return o("profile-id=2");case"AV1":return o("level-idx=5;profile=0;tier=0");case"H264":return o("level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f");default:return c("invalid video codec")}}};function ee(e,t){for(let r of e)if(t(r))return r}function te(){return typeof AudioContext<"u"&&typeof Worker<"u"}function re(){return typeof SharedArrayBuffer<"u"}function w(){return/(apple)?webkit\/537\.36/i.test(globalThis.navigator.userAgent)}function ne(){return/electron/i.test(globalThis.navigator.userAgent)}function oe(){return/firefox|iceweasel|fxios/i.test(globalThis.navigator.userAgent)}function ie(){return w()?!1:/safari|applewebkit/i.test(globalThis.navigator.userAgent)}function se(e){return JSON.parse(JSON.stringify(e))}var R=class e{constructor(t){this._Generators=t;this._Futures=t.map(e.addIndex)}_Futures;async next(){let[t,r]=await Promise.race(this._Futures);return this._Futures[r]=e.addIndex(this._Generators[r],r),t}static async addIndex(t,r){return[await t(),r]}};function ae(e,t){return e<=0?Promise.resolve(t):new Promise(r=>setTimeout(()=>r(t),e))}function ue(e,t){return t.aborted?Promise.resolve("aborted"):new Promise(r=>{let n=()=>r("aborted");t.addEventListener("abort",n,{once:!0}),setTimeout(()=>{t.removeEventListener("abort",n),r(void 0)},e)})}function ce(){return new Promise(e=>setTimeout(e,0))}var T=class{_Tasks=[];_Running=!1;_Values;constructor(...t){this._Values=t}enqueue(t){return new Promise((r,n)=>{let s=async()=>{try{let i=await t(...this._Values);r(i)}catch(i){n(i)}};this._Tasks.push(s),this._Running||this.execute()})}async execute(){for(this._Running=!0;;){let t=this._Tasks.shift();if(t===void 0)break;await t()}this._Running=!1}};function pe(e){let t=e.trim();e.indexOf("://")===-1&&(t=`https://${t}`);try{return o(new URL(t))}catch(r){return c(String(r))}}function le(e,t){let r=e.pathname;r.endsWith("/")===!1&&(r+="/");try{return o(new URL(r+t,e))}catch(n){return c(String(n))}}var de=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function ge(){return crypto.randomUUID()}function fe(e){return de.test(e)}function me(e,t){return t in e}function ye(e){return typeof e=="function"}function be(e){return typeof e=="object"&&e===null}function xe(e){return typeof e=="number"}function ve(e){return typeof e=="object"}function he(e){return typeof e=="string"}function Re(e){return typeof e>"u"}function Te(e){return e.type==="Failure"}function ke(e){return e.type==="Success"}var{Deno:V}=globalThis,Ce=typeof V?.noColor=="boolean"?V.noColor:!1,Le=!Ce;function k(e,t){return{open:`\x1B[${e.join(";")}m`,close:`\x1B[${t}m`,regexp:new RegExp(`\\x1b\\[${t}m`,"g")}}function C(e,t){return Le?`${t.open}${e.replace(t.regexp,t.open)}${t.close}`:e}function m(e){return C(e,k([0],0))}function L(e){return C(e,k([1],22))}function O(e){return C(e,k([2],22))}var ot=new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");var y=(a=>(a[a.Nothing=0]="Nothing",a[a.CRITICAL=1]="CRITICAL",a[a.ERROR=2]="ERROR",a[a.WARN=3]="WARN",a[a.INFO=4]="INFO",a[a.DEBUG=5]="DEBUG",a[a.Everything=6]="Everything",a))(y||{}),Ae=new Date,b=(i=>(i[i.CRITICAL=1]="CRITICAL",i[i.ERROR=2]="ERROR",i[i.WARN=3]="WARN",i[i.INFO=4]="INFO",i[i.DEBUG=5]="DEBUG",i))(b||{}),A={1:"\u{1F4A5}",2:"\u{1F534}",3:"\u{1F7E1}",4:"\u{1F535}",5:"\u{1F7E3}"},Pe={5:O,4:m,3:m,2:L,1:L};function we(e){for(let t of Object.keys(y))if(isNaN(Number(t))!==!1&&t.localeCompare(e,void 0,{sensitivity:"accent"})===0)return y[t]}function Ve({message:e}){return String(e)}function I(e){return JSON.stringify({timestamp:e.date.toISOString(),level:b[e.level],message:e.message,extra:e.extra})}function D(e){function t(u,a){return[Math.floor(u/a),u%a]}function r(){let u,a=e.date.valueOf()-Ae.valueOf();[a,u]=t(a,1e3);let[U,F]=t(a,60);return`${U.toString().padStart(4,"0")}:${F.toString().padStart(2,"0")}.${u.toString().padStart(4,"0")}`}function n(){return e.extra===void 0?"":"Deno"in globalThis?" "+Deno.inspect(e.extra,{compact:!1,colors:!0,trailingComma:!0}).trimStart():" "+JSON.stringify(e.extra)}let s=A[e.level],i=e.logger.name!==void 0?`@${e.logger}`:"";return`${m(r())}${i} ${s} ${Pe[e.level](String(e.message))}${n()}`}function Oe(e){let t=`[${e.date.toISOString()}]`,r=`[${b[e.level]}]`,n=e.logger.name!==void 0?`[${e.logger.name}] `:"",s=A[e.level];return`${t} ${s} ${r.padEnd(7," ")} ${n}${e.message}`}var B={sparse:Ve,json:I,pretty:D,structured:Oe,default:"Deno"in globalThis&&Deno.stdout.isTerminal()?D:I},g=class{formatter;consoleObject;filter;constructor(t=B.default,r=6,n=console){this.filter=r,this.formatter=t,this.consoleObject=n}handle(t){let r=this.formatter(t);switch(t.level){case 2:this.consoleObject.error(r);break;case 3:this.consoleObject.warn(r);break;case 4:this.consoleObject.info(r);break;case 5:this.consoleObject.debug(r);break}}},S=class extends g{handle(t){let r=this.formatter(t),n=t.extra!==void 0?[r,t.extra]:[r];switch(t.level){case 1:case 2:this.consoleObject.error(...n);break;case 3:this.consoleObject.warn(...n);break;case 4:this.consoleObject.info(...n);break;case 5:this.consoleObject.debug(...n);break}}},p=class{#e;sinks;filter;get name(){return this.#e}constructor(t,r=void 0,n=[new g]){this.#e=r,this.sinks=n,this.filter=t}log(t,r,n=void 0){if(this.filter<t)return;let s=E;for(let i of this.sinks)i.filter<t||(s===E&&(s={date:new Date,level:t,logger:this,message:typeof r=="function"?r():r,extra:n}),i.handle(s))}error=this.log.bind(this,2);warn=this.log.bind(this,3);info=this.log.bind(this,4);debug=this.log.bind(this,5)},l=new p(4),Ie=p.prototype.log.bind(l,2),De=p.prototype.log.bind(l,3),Ee=p.prototype.log.bind(l,4),Be=p.prototype.log.bind(l,5),Ue=p.prototype.log.bind(l),E=Symbol();0&&(module.exports={APM_DEFAULTS,Backend,CONNECTION_STATS_INITIAL,ConsoleSink,Formatter,GLOBAL_LOGGER,InteractiveConsoleSink,JITTER_STATS_INITIAL,LogFilter,LogLevel,LogSymbols,Logger,MinDBFS,Selector,Strand,VAD_DEFAULTS,VideoCodec,abortableSleep,assert,debug,error,extendUrl,fail,failure,find,fromBase64,fromBase64Url,fromBytes,generateUUID,info,isAudioCapable,isBlinkBrowser,isElectronBrowser,isFailure,isFirefoxBrowser,isFunction,isNull,isNumber,isObject,isProperty,isSafariBrowser,isSharedArrayBufferCapable,isString,isSuccess,isUndefined,log,nextTick,normalizeUrl,sleep,success,toBytes,toRaw,tryParseLogFilter,unwrap,unwrapOr,validateUUID,warn});
package/esm/mod.js CHANGED
@@ -1 +1 @@
1
- import{z as d}from"zod";var b=d.custom(e=>e instanceof Uint8Array),ue=d.union([d.string(),d.number(),d.boolean(),d.null()]),T=d.lazy(()=>d.union([ue,d.array(T),d.record(d.string(),T)])),Me=d.union([d.tuple([d.literal(0),d.number(),d.string(),d.unknown()]),d.tuple([d.literal(1),d.number(),d.nullable(d.string()),d.unknown()]),d.tuple([d.literal(2),d.string(),d.unknown()])]);import{z as p}from"zod";var de=p.enum(["sfu","gateway"]),le=p.enum(["connect","roomclose","roomupdate","roombanclient","roomsendmessage"]),_e=p.object({uid:p.string(),cid:p.optional(p.string()),rid:C(p.string()).refine(e=>e.length>=1,{message:"missing rid"}),nsp:p.optional(p.string()),adr:p.optional(p.string()),aud:p.optional(C(de)),sub:p.optional(C(le)),exp:p.optional(p.number()),nbf:p.optional(p.number()),ups:p.optional(p.string()),tgs:p.optional(C(p.string())),tsp:p.optional(p.number()),internal:p.optional(p.object({server:p.optional(p.string())}))});function C(e){return p.union([e.transform(t=>[t]),p.array(e)])}import*as r from"zod";import*as c from"zod";var S=c.number(),me=c.object({kind:c.optional(c.literal("audio")),uid:c.optional(c.string()),customType:c.optional(c.string())}),fe=c.object({kind:c.optional(c.literal("video")),codec:c.optional(c.string()),uid:c.optional(c.string()),customType:c.optional(c.string()),id:c.optional(c.string())}),_=c.union([me,fe]),I=c.object({id:S,properties:_,paused:c.boolean()});import*as l from"zod";var x=l.number(),A=l.union([l.tuple([l.number(),l.number(),l.number()]),l.tuple([l.number(),l.number()])]),B=l.object({id:x,user_id:l.string(),user_data:b,medias:l.array(I)}),N=l.discriminatedUnion("kind",[l.object({kind:l.literal("UserDataChanged"),peer_id:x,user_data:b}),l.object({kind:l.literal("MediaStarted"),peer_id:x,media:I}),l.object({kind:l.literal("MediaStopped"),peer_id:x,media_id:S})]);import*as G from"zod";var O=class e{constructor(t=BigInt(0)){this.value=t}from(...t){let n=t.reduce((u,y)=>u|L(y),BigInt(0));return new e(n)}contains(t){return(this.value&L(t))!==BigInt(0)}insert(t){this.value|=L(t)}remove(t){this.value&=~L(t)}[Symbol.iterator](){let t=-1,n=new e(this.value);return{next(){for(;t<63;)if(t+=1,n.contains(t))return{value:t,done:!1};return{value:void 0,done:!0}}}}},$=G.bigint().transform(e=>new O(e));function L(e){return BigInt(1)<<BigInt(e)}var z;(s=>(s.RoomIdSchema=r.string(),s.RoomSchema=r.object({id:s.RoomIdSchema,customer:r.string(),user_data:b,peers:r.array(B)}),s.RoomUpdateSchema=r.discriminatedUnion("kind",[r.object({kind:r.literal("Joined"),room:s.RoomSchema,media_ids:r.array(S),own_peer_id:x}),r.object({kind:r.literal("Left"),reason:r.enum(["RoomClosing","ServerClosing","PeerKicked"])}),r.object({kind:r.literal("UserDataChanged"),user_data:r.optional(b)}),r.object({kind:r.literal("PeerJoined"),peer:B}),r.object({kind:r.literal("PeerLeft"),peer_id:x})]),s.RoomUpdatesSchema=r.object({updates:r.array(s.RoomUpdateSchema)}),s.RoomStatusSchema=r.enum(["Joining","Joined","Closed"]),s.RoomStatusChangedSchema=r.object({status:s.RoomStatusSchema,message:r.optional(r.string())})))(z||={});var ge;(i=>(i.ParametersSchema=r.record(r.string(),T),i.PeerProperties=r.object({user_data:b.optional(),tags:r.array(r.string()).optional(),audio_parameters:i.ParametersSchema.optional(),video_parameters:i.ParametersSchema.optional()}),i.PingSchema=r.object({Ping:r.object({id:r.number()})}),i.ChangeSelfSchema=r.object({ChangeSelf:i.PeerProperties.omit({tags:!0})}),i.SetAudioMaskSchema=r.object({SetAudioMask:r.object({peer_id:r.number(),mask:$})}),i.SendMessageSchema=r.object({SendMessage:r.object({peer_ids:r.number().array().default([]),message:b})}),i.CallSchema=i.PingSchema.or(i.ChangeSelfSchema).or(i.SetAudioMaskSchema).or(i.SendMessageSchema),i.PongSchema=r.object({Pong:r.object({id:r.number()})}),i.JoinedSchema=r.object({Joined:r.object({own_peer_id:r.number(),room_id:r.string(),customer:r.string()})}),i.LeftSchema=r.object({Left:r.object({reason:r.enum(["room_closing","server_closing","peer_kicked"])})}),i.PeerJoinedSchema=r.object({PeerJoined:i.PeerProperties.extend({peer_id:r.number(),user_id:r.string()})}),i.PeerLeftSchema=r.object({PeerLeft:r.object({peer_id:r.number()})}),i.PeerChangedSchema=r.object({PeerChanged:i.PeerProperties.extend({peer_id:r.number()})}),i.NewReconnectTokenSchema=r.object({NewReconnectToken:r.object({token:r.string()})}),i.MessageReceivedSchema=r.object({MessageReceived:r.object({sender_peer_id:r.number(),message:b})}),i.ErrorSchema=r.object({Error:r.object({message:b})}),i.EventSchema=i.PongSchema.or(i.JoinedSchema).or(i.LeftSchema).or(i.PeerJoinedSchema).or(i.PeerLeftSchema).or(i.PeerChangedSchema).or(i.NewReconnectTokenSchema).or(i.MessageReceivedSchema).or(i.ErrorSchema)))(ge||={});import{z as ye}from"zod";var E=ye.object({sender_peer_id:x,message:b});import*as a from"zod";var R=a.discriminatedUnion("kind",[a.object({kind:a.literal("Sdp"),type:a.enum(["Answer","Offer"]),sdp:a.string(),media_map:a.array(a.tuple([S,a.string()]))}),a.object({kind:a.literal("Trickle"),candidate:a.string(),spd_mid:a.optional(a.string()),spd_mline_index:a.optional(a.number()),username_fragment:a.optional(a.union([a.string(),a.null()]))}),a.object({kind:a.literal("TrickleFinished")})]);import{z as o}from"zod";var ot={Hello:{request:o.object({stream:o.literal("main")}),response:o.null()},JoinRoom:{request:o.object({token:o.string(),room_id:z.RoomIdSchema,user_data:b,position:A}),response:o.object({peer_id:x,stream_id:o.optional(o.number()),token:o.optional(o.string())})},WebRtcUpdate:{request:R,response:o.null()},RequestReconnectToken:{request:o.object({peer_id:o.optional(x)}),response:o.string()},Ping:{request:o.object({}),response:o.null()}},it={Hello:{request:o.object({stream:o.literal("room"),token:o.string(),room_id:o.string(),user_data:b,position:A}),response:o.null()},UpdatePeer:{request:o.object({user_data:b}),response:o.null()},StartMedia:{request:o.object({media_id:S,properties:_}),response:o.null()},StopMedia:{request:o.object({media_id:S}),response:o.null()},PauseMedia:{request:o.object({media_id:S}),response:o.null()},ResumeMedia:{request:o.object({media_id:S}),response:o.null()},SetPeerPosition:{request:o.object({position:A}),response:o.null()},SendMessage:{request:o.object({target_peer_ids:o.optional(o.array(x)),message:b}),response:o.null()}};import{z as v}from"zod";var lt=v.object({name:v.literal("WebRtcUpdate"),properties:R}),mt={WebRtcUpdate:R},ft=v.union([v.object({name:v.literal("RoomStatusChanged"),properties:z.RoomStatusChangedSchema}),v.object({name:v.literal("RoomUpdated"),properties:z.RoomUpdatesSchema}),v.object({name:v.literal("PeerUpdated"),properties:N}),v.object({name:v.literal("MessageReceived"),properties:E})]),gt={RoomStatusChanged:z.RoomStatusChangedSchema,RoomUpdated:z.RoomUpdatesSchema,PeerUpdated:N,MessageReceived:E};function w(e,t){e||H(t)}function H(e){throw new Error(e)}function g(e){return{type:"Success",value:e}}function h(e){return{type:"Failure",reason:e}}function bt(e){return e.type==="Failure"&&H(e.reason),e.value}function D(e,t){return e.type==="Success"?e.value:t}function St(e){try{let t=atob(e),n=Uint8Array.from(t,y=>y.codePointAt(0)),u=new TextDecoder("utf8");return g(u.decode(n))}catch(t){return h(String(t))}}function vt(e){try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")),n=Uint8Array.from(t,y=>y.codePointAt(0)),u=new TextDecoder("utf8");return g(u.decode(n))}catch(t){return h(String(t))}}function Rt(e){try{w(e!==void 0,"undefined cannot be converted to byte array"),w(e!==null,"null cannot be converted to byte array");let t=JSON.stringify(e),n=new TextEncoder;return g(n.encode(t))}catch(t){return h(String(t))}}function Pt(e){try{w(e.length>0,"empty byte array cannot be converted to value");let t=new TextDecoder().decode(e),n=JSON.parse(t);return g(n)}catch(t){return h(String(t))}}var be=["VP8","VP9","AV1","H264"],Z=class{constructor(t){this.codec=t}channels=0;clockRate=9e4;isValid(){return be.includes(this.codec)}isSupported(){if(typeof RTCRtpReceiver>"u"||typeof RTCRtpReceiver.getCapabilities>"u")return null;let t=D(this.getMimeType(),"").toLowerCase(),n=new Set(D(this.getSdpFmtpLine(),"").split(";").map(u=>u.trim().toLowerCase()));return RTCRtpReceiver.getCapabilities("video")?.codecs?.find(u=>{let y=u.mimeType.toLowerCase(),m=new Set((u.sdpFmtpLine??"").split(";").map(s=>s.trim().toLowerCase()));if(t!==y||n.size!==m.size)return!1;for(let s of n)if(!m.has(s))return!1;return!0})??null}getPayloadType(){switch(this.codec){case"VP8":return g(96);case"VP9":return g(98);case"AV1":return g(41);case"H264":return g(102);default:return h("invalid video codec")}}getMimeType(){switch(this.codec){case"VP8":return g("video/VP8");case"VP9":return g("video/VP9");case"AV1":return g("video/AV1");case"H264":return g("video/H264");default:return h("invalid video codec")}}getSdpFmtpLine(){switch(this.codec){case"VP8":return g("");case"VP9":return g("profile-id=2");case"AV1":return g("level-idx=5;profile=0;tier=0");case"H264":return g("level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f");default:return h("invalid video codec")}}};function Lt(e,t){for(let n of e)if(t(n))return n}function Mt(){return typeof AudioContext<"u"&&typeof Worker<"u"}function jt(){return typeof SharedArrayBuffer<"u"}function xe(){return/(apple)?webkit\/537\.36/i.test(globalThis.navigator.userAgent)}function Ut(){return/electron/i.test(globalThis.navigator.userAgent)}function _t(){return/firefox|iceweasel|fxios/i.test(globalThis.navigator.userAgent)}function It(){return xe()?!1:/safari|applewebkit/i.test(globalThis.navigator.userAgent)}function Nt(e){return JSON.parse(JSON.stringify(e))}var Y=class e{constructor(t){this._Generators=t;this._Futures=t.map(e.addIndex)}_Futures;async next(){let[t,n]=await Promise.race(this._Futures);return this._Futures[n]=e.addIndex(this._Generators[n],n),t}static async addIndex(t,n){return[await t(),n]}};function Dt(e,t){return e<=0?Promise.resolve(t):new Promise(n=>setTimeout(()=>n(t),e))}function Ft(e,t){return t.aborted?Promise.resolve("aborted"):new Promise(n=>{let u=()=>n("aborted");t.addEventListener("abort",u,{once:!0}),setTimeout(()=>{t.removeEventListener("abort",u),n(void 0)},e)})}function Jt(){return new Promise(e=>setTimeout(e,0))}var K=class{_Tasks=[];_Running=!1;_Values;constructor(...t){this._Values=t}enqueue(t){return new Promise((n,u)=>{let y=async()=>{try{let m=await t(...this._Values);n(m)}catch(m){u(m)}};this._Tasks.push(y),this._Running||this.execute()})}async execute(){for(this._Running=!0;;){let t=this._Tasks.shift();if(t===void 0)break;await t()}this._Running=!1}};function Gt(e){let t=e.trim();e.indexOf("://")===-1&&(t=`https://${t}`);try{return g(new URL(t))}catch(n){return h(String(n))}}function $t(e,t){let n=e.pathname;n.endsWith("/")===!1&&(n+="/");try{return g(new URL(n+t,e))}catch(u){return h(String(u))}}var he=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Zt(){return crypto.randomUUID()}function Yt(e){return he.test(e)}function Xt(e,t){return t in e}function Qt(e){return typeof e=="function"}function er(e){return typeof e=="object"&&e===null}function tr(e){return typeof e=="number"}function rr(e){return typeof e=="object"}function nr(e){return typeof e=="string"}function or(e){return typeof e>"u"}function ir(e){return e.type==="Failure"}function ar(e){return e.type==="Success"}var{Deno:X}=globalThis,Se=typeof X?.noColor=="boolean"?X.noColor:!1,ve=!Se;function F(e,t){return{open:`\x1B[${e.join(";")}m`,close:`\x1B[${t}m`,regexp:new RegExp(`\\x1b\\[${t}m`,"g")}}function J(e,t){return ve?`${t.open}${e.replace(t.regexp,t.open)}${t.close}`:e}function M(e){return J(e,F([0],0))}function V(e){return J(e,F([1],22))}function Q(e){return J(e,F([2],22))}var pr=new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");var W=(f=>(f[f.Nothing=0]="Nothing",f[f.CRITICAL=1]="CRITICAL",f[f.ERROR=2]="ERROR",f[f.WARN=3]="WARN",f[f.INFO=4]="INFO",f[f.DEBUG=5]="DEBUG",f[f.Everything=6]="Everything",f))(W||{}),ke=new Date,ne=(m=>(m[m.CRITICAL=1]="CRITICAL",m[m.ERROR=2]="ERROR",m[m.WARN=3]="WARN",m[m.INFO=4]="INFO",m[m.DEBUG=5]="DEBUG",m))(ne||{}),Re={1:"\u{1F4A5}",2:"\u{1F534}",3:"\u{1F7E1}",4:"\u{1F535}",5:"\u{1F7E3}"},Pe={5:Q,4:M,3:M,2:V,1:V};function cr(e){for(let t of Object.keys(W))if(isNaN(Number(t))!==!1&&t.localeCompare(e,void 0,{sensitivity:"accent"})===0)return W[t]}function Te({message:e}){return String(e)}function ee(e){return JSON.stringify({timestamp:e.date.toISOString(),level:ne[e.level],message:e.message,extra:e.extra})}function te(e){function t(s,f){return[Math.floor(s/f),s%f]}function n(){let s,f=e.date.valueOf()-ke.valueOf();[f,s]=t(f,1e3);let[j,U]=t(f,60);return`${j.toString().padStart(4,"0")}:${U.toString().padStart(2,"0")}.${s.toString().padStart(4,"0")}`}function u(){return e.extra===void 0?"":"Deno"in globalThis?" "+Deno.inspect(e.extra,{compact:!1,colors:!0,trailingComma:!0}).trimStart():" "+JSON.stringify(e.extra)}let y=Re[e.level],m=e.logger.name!==void 0?`@${e.logger}`:"";return`${M(n())}${m} ${y} ${Pe[e.level](String(e.message))}${u()}`}var Ce={sparse:Te,json:ee,pretty:te,default:"Deno"in globalThis&&Deno.stdout.isTerminal()?te:ee},q=class{#e;#t;filter;constructor(t=Ce.default,n=6,u=console){this.filter=n,this.#e=t,this.#t=u}handle(t){let n=this.#e(t);switch(t.level){case 2:this.#t.error(n);break;case 3:this.#t.warn(n);break;case 4:this.#t.info(n);break;case 5:this.#t.debug(n);break}}},k=class{#e;sinks;filter;get name(){return this.#e}constructor(t,n=void 0,u=[new q]){this.#e=n,this.sinks=u,this.filter=t}log(t,n,u=void 0){if(this.filter<t)return;let y=re;for(let m of this.sinks)m.filter<t||(y===re&&(y={date:new Date,level:t,logger:this,message:typeof n=="function"?n():n,extra:u}),m.handle(y))}error=this.log.bind(this,2);warn=this.log.bind(this,3);info=this.log.bind(this,4);debug=this.log.bind(this,5)},P=new k(4),ur=k.prototype.log.bind(P,2),dr=k.prototype.log.bind(P,3),lr=k.prototype.log.bind(P,4),mr=k.prototype.log.bind(P,5),fr=k.prototype.log.bind(P),re=Symbol();var yr=-758.596,Ae;(t=>{let e;(s=>(s[s.InvalidPassword=-1]="InvalidPassword",s[s.Unknown=0]="Unknown",s[s.Unencrypted=1]="Unencrypted",s[s.Encrypted=2]="Encrypted"))(e=t.PeerCipherStatus||={})})(Ae||={});var br={bytesSent:0,bytesReceived:0,packetsSent:0,packetsReceived:0,rtt:0,packetLoss:0},xr={packetsBuffered:0,packetsSeen:0,packetsProcessed:0,packetsTooEarly:0,packetsTooLate:0,packetsDropped:0,packetsInvalid:0,packetsRepeated:0,packetsLost:0},hr={voiceActivity:{attackThreshold:.9,releaseThreshold:.8},volumeGate:{attackThreshold:-30,releaseThreshold:-40}},Sr={echoCanceller:!0,highPassFilter:!1,noiseSuppression:"Moderate",transientSuppressor:!1,gainController:!0};export{Sr as APM_DEFAULTS,Ae as Backend,b as ByteArraySchema,br as CONNECTION_STATS_INITIAL,O as ChannelSet,$ as ChannelSetSchema,q as ConsoleSink,Ce as Formatter,P as GLOBAL_LOGGER,xr as JITTER_STATS_INITIAL,T as JsonSchema,W as LogFilter,ne as LogLevel,Re as LogSymbols,k as Logger,ot as MainCommandsRpc,lt as MainNotificationSchema,mt as MainNotificationsRpc,me as MediaAudioPropertiesSchema,S as MediaIdSchema,_ as MediaPropertiesSchema,I as MediaSchema,fe as MediaVideoPropertiesSchema,Me as MessagePackRpcSchema,E as MessageReceivedSchema,yr as MinDBFS,x as PeerIdSchema,A as PeerPositionSchema,B as PeerSchema,N as PeerUpdateSchema,it as RoomCommandsRpc,ft as RoomNotificationSchema,gt as RoomNotificationsRpc,z as RoomV1,ge as RoomV2,Y as Selector,K as Strand,de as TokenAudienceSchema,_e as TokenClaimsSchema,le as TokenSubjectSchema,hr as VAD_DEFAULTS,Z as VideoCodec,R as WebRtcUpdateSchema,Ft as abortableSleep,w as assert,mr as debug,ur as error,$t as extendUrl,H as fail,h as failure,Lt as find,St as fromBase64,vt as fromBase64Url,Pt as fromBytes,Zt as generateUUID,lr as info,Mt as isAudioCapable,xe as isBlinkBrowser,Ut as isElectronBrowser,ir as isFailure,_t as isFirefoxBrowser,Qt as isFunction,er as isNull,tr as isNumber,rr as isObject,Xt as isProperty,It as isSafariBrowser,jt as isSharedArrayBufferCapable,nr as isString,ar as isSuccess,or as isUndefined,fr as log,Jt as nextTick,Gt as normalizeUrl,C as oneOrMany,Dt as sleep,g as success,Rt as toBytes,Nt as toRaw,cr as tryParseLogFilter,bt as unwrap,D as unwrapOr,Yt as validateUUID,dr as warn};
1
+ var z=-758.596,E;(t=>{let e;(a=>(a[a.InvalidPassword=-1]="InvalidPassword",a[a.Unknown=0]="Unknown",a[a.Unencrypted=1]="Unencrypted",a[a.Encrypted=2]="Encrypted"))(e=t.PeerCipherStatus||={})})(E||={});var H={bytesSent:0,bytesReceived:0,packetsSent:0,packetsReceived:0,rtt:0,packetLoss:0},Z={packetsBuffered:0,packetsSeen:0,packetsProcessed:0,packetsTooEarly:0,packetsTooLate:0,packetsDropped:0,packetsInvalid:0,packetsRepeated:0,packetsLost:0},q={voiceActivity:{attackThreshold:.9,releaseThreshold:.8},volumeGate:{attackThreshold:-30,releaseThreshold:-40}},Y={echoCanceller:!0,highPassFilter:!1,noiseSuppression:"Moderate",transientSuppressor:!1,gainController:!0};function d(e,t){e||R(t)}function R(e){throw new Error(e)}function i(e){return{type:"Success",value:e}}function c(e){return{type:"Failure",reason:e}}function K(e){return e.type==="Failure"&&R(e.reason),e.value}function m(e,t){return e.type==="Success"?e.value:t}function te(e){try{let t=atob(e),r=Uint8Array.from(t,u=>u.codePointAt(0)),n=new TextDecoder("utf8");return i(n.decode(r))}catch(t){return c(String(t))}}function re(e){try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")),r=Uint8Array.from(t,u=>u.codePointAt(0)),n=new TextDecoder("utf8");return i(n.decode(r))}catch(t){return c(String(t))}}function ie(e){try{d(e!==void 0,"undefined cannot be converted to byte array"),d(e!==null,"null cannot be converted to byte array");let t=JSON.stringify(e),r=new TextEncoder;return i(r.encode(t))}catch(t){return c(String(t))}}function se(e){try{d(e.length>0,"empty byte array cannot be converted to value");let t=new TextDecoder().decode(e),r=JSON.parse(t);return i(r)}catch(t){return c(String(t))}}var B=["VP8","VP9","AV1","H264"],T=class{constructor(t){this.codec=t}channels=0;clockRate=9e4;isValid(){return B.includes(this.codec)}isSupported(){if(typeof RTCRtpReceiver>"u"||typeof RTCRtpReceiver.getCapabilities>"u")return null;let t=m(this.getMimeType(),"").toLowerCase(),r=new Set(m(this.getSdpFmtpLine(),"").split(";").map(n=>n.trim().toLowerCase()));return RTCRtpReceiver.getCapabilities("video")?.codecs?.find(n=>{let u=n.mimeType.toLowerCase(),o=new Set((n.sdpFmtpLine??"").split(";").map(a=>a.trim().toLowerCase()));if(t!==u||r.size!==o.size)return!1;for(let a of r)if(!o.has(a))return!1;return!0})??null}getPayloadType(){switch(this.codec){case"VP8":return i(96);case"VP9":return i(98);case"AV1":return i(41);case"H264":return i(102);default:return c("invalid video codec")}}getMimeType(){switch(this.codec){case"VP8":return i("video/VP8");case"VP9":return i("video/VP9");case"AV1":return i("video/AV1");case"H264":return i("video/H264");default:return c("invalid video codec")}}getSdpFmtpLine(){switch(this.codec){case"VP8":return i("");case"VP9":return i("profile-id=2");case"AV1":return i("level-idx=5;profile=0;tier=0");case"H264":return i("level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f");default:return c("invalid video codec")}}};function pe(e,t){for(let r of e)if(t(r))return r}function de(){return typeof AudioContext<"u"&&typeof Worker<"u"}function ge(){return typeof SharedArrayBuffer<"u"}function U(){return/(apple)?webkit\/537\.36/i.test(globalThis.navigator.userAgent)}function fe(){return/electron/i.test(globalThis.navigator.userAgent)}function me(){return/firefox|iceweasel|fxios/i.test(globalThis.navigator.userAgent)}function ye(){return U()?!1:/safari|applewebkit/i.test(globalThis.navigator.userAgent)}function xe(e){return JSON.parse(JSON.stringify(e))}var k=class e{constructor(t){this._Generators=t;this._Futures=t.map(e.addIndex)}_Futures;async next(){let[t,r]=await Promise.race(this._Futures);return this._Futures[r]=e.addIndex(this._Generators[r],r),t}static async addIndex(t,r){return[await t(),r]}};function Re(e,t){return e<=0?Promise.resolve(t):new Promise(r=>setTimeout(()=>r(t),e))}function Te(e,t){return t.aborted?Promise.resolve("aborted"):new Promise(r=>{let n=()=>r("aborted");t.addEventListener("abort",n,{once:!0}),setTimeout(()=>{t.removeEventListener("abort",n),r(void 0)},e)})}function ke(){return new Promise(e=>setTimeout(e,0))}var C=class{_Tasks=[];_Running=!1;_Values;constructor(...t){this._Values=t}enqueue(t){return new Promise((r,n)=>{let u=async()=>{try{let o=await t(...this._Values);r(o)}catch(o){n(o)}};this._Tasks.push(u),this._Running||this.execute()})}async execute(){for(this._Running=!0;;){let t=this._Tasks.shift();if(t===void 0)break;await t()}this._Running=!1}};function Ae(e){let t=e.trim();e.indexOf("://")===-1&&(t=`https://${t}`);try{return i(new URL(t))}catch(r){return c(String(r))}}function Pe(e,t){let r=e.pathname;r.endsWith("/")===!1&&(r+="/");try{return i(new URL(r+t,e))}catch(n){return c(String(n))}}var F=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;function Ve(){return crypto.randomUUID()}function Oe(e){return F.test(e)}function De(e,t){return t in e}function Ee(e){return typeof e=="function"}function Be(e){return typeof e=="object"&&e===null}function Ue(e){return typeof e=="number"}function Fe(e){return typeof e=="object"}function Ne(e){return typeof e=="string"}function Me(e){return typeof e>"u"}function je(e){return e.type==="Failure"}function _e(e){return e.type==="Success"}var{Deno:L}=globalThis,N=typeof L?.noColor=="boolean"?L.noColor:!1,M=!N;function y(e,t){return{open:`\x1B[${e.join(";")}m`,close:`\x1B[${t}m`,regexp:new RegExp(`\\x1b\\[${t}m`,"g")}}function b(e,t){return M?`${t.open}${e.replace(t.regexp,t.open)}${t.close}`:e}function g(e){return b(e,y([0],0))}function x(e){return b(e,y([1],22))}function S(e){return b(e,y([2],22))}var Ge=new RegExp(["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))"].join("|"),"g");var v=(s=>(s[s.Nothing=0]="Nothing",s[s.CRITICAL=1]="CRITICAL",s[s.ERROR=2]="ERROR",s[s.WARN=3]="WARN",s[s.INFO=4]="INFO",s[s.DEBUG=5]="DEBUG",s[s.Everything=6]="Everything",s))(v||{}),_=new Date,h=(o=>(o[o.CRITICAL=1]="CRITICAL",o[o.ERROR=2]="ERROR",o[o.WARN=3]="WARN",o[o.INFO=4]="INFO",o[o.DEBUG=5]="DEBUG",o))(h||{}),O={1:"\u{1F4A5}",2:"\u{1F534}",3:"\u{1F7E1}",4:"\u{1F535}",5:"\u{1F7E3}"},$={5:S,4:g,3:g,2:x,1:x};function Je(e){for(let t of Object.keys(v))if(isNaN(Number(t))!==!1&&t.localeCompare(e,void 0,{sensitivity:"accent"})===0)return v[t]}function G({message:e}){return String(e)}function A(e){return JSON.stringify({timestamp:e.date.toISOString(),level:h[e.level],message:e.message,extra:e.extra})}function P(e){function t(a,s){return[Math.floor(a/s),a%s]}function r(){let a,s=e.date.valueOf()-_.valueOf();[s,a]=t(s,1e3);let[I,D]=t(s,60);return`${I.toString().padStart(4,"0")}:${D.toString().padStart(2,"0")}.${a.toString().padStart(4,"0")}`}function n(){return e.extra===void 0?"":"Deno"in globalThis?" "+Deno.inspect(e.extra,{compact:!1,colors:!0,trailingComma:!0}).trimStart():" "+JSON.stringify(e.extra)}let u=O[e.level],o=e.logger.name!==void 0?`@${e.logger}`:"";return`${g(r())}${o} ${u} ${$[e.level](String(e.message))}${n()}`}function J(e){let t=`[${e.date.toISOString()}]`,r=`[${h[e.level]}]`,n=e.logger.name!==void 0?`[${e.logger.name}] `:"",u=O[e.level];return`${t} ${u} ${r.padEnd(7," ")} ${n}${e.message}`}var W={sparse:G,json:A,pretty:P,structured:J,default:"Deno"in globalThis&&Deno.stdout.isTerminal()?P:A},f=class{formatter;consoleObject;filter;constructor(t=W.default,r=6,n=console){this.filter=r,this.formatter=t,this.consoleObject=n}handle(t){let r=this.formatter(t);switch(t.level){case 2:this.consoleObject.error(r);break;case 3:this.consoleObject.warn(r);break;case 4:this.consoleObject.info(r);break;case 5:this.consoleObject.debug(r);break}}},w=class extends f{handle(t){let r=this.formatter(t),n=t.extra!==void 0?[r,t.extra]:[r];switch(t.level){case 1:case 2:this.consoleObject.error(...n);break;case 3:this.consoleObject.warn(...n);break;case 4:this.consoleObject.info(...n);break;case 5:this.consoleObject.debug(...n);break}}},p=class{#e;sinks;filter;get name(){return this.#e}constructor(t,r=void 0,n=[new f]){this.#e=r,this.sinks=n,this.filter=t}log(t,r,n=void 0){if(this.filter<t)return;let u=V;for(let o of this.sinks)o.filter<t||(u===V&&(u={date:new Date,level:t,logger:this,message:typeof r=="function"?r():r,extra:n}),o.handle(u))}error=this.log.bind(this,2);warn=this.log.bind(this,3);info=this.log.bind(this,4);debug=this.log.bind(this,5)},l=new p(4),We=p.prototype.log.bind(l,2),ze=p.prototype.log.bind(l,3),He=p.prototype.log.bind(l,4),Ze=p.prototype.log.bind(l,5),qe=p.prototype.log.bind(l),V=Symbol();export{Y as APM_DEFAULTS,E as Backend,H as CONNECTION_STATS_INITIAL,f as ConsoleSink,W as Formatter,l as GLOBAL_LOGGER,w as InteractiveConsoleSink,Z as JITTER_STATS_INITIAL,v as LogFilter,h as LogLevel,O as LogSymbols,p as Logger,z as MinDBFS,k as Selector,C as Strand,q as VAD_DEFAULTS,T as VideoCodec,Te as abortableSleep,d as assert,Ze as debug,We as error,Pe as extendUrl,R as fail,c as failure,pe as find,te as fromBase64,re as fromBase64Url,se as fromBytes,Ve as generateUUID,He as info,de as isAudioCapable,U as isBlinkBrowser,fe as isElectronBrowser,je as isFailure,me as isFirefoxBrowser,Ee as isFunction,Be as isNull,Ue as isNumber,Fe as isObject,De as isProperty,ye as isSafariBrowser,ge as isSharedArrayBufferCapable,Ne as isString,_e as isSuccess,Me as isUndefined,qe as log,ke as nextTick,Ae as normalizeUrl,Re as sleep,i as success,ie as toBytes,xe as toRaw,Je as tryParseLogFilter,K as unwrap,m as unwrapOr,Oe as validateUUID,ze as warn};
package/mod.d.ts CHANGED
@@ -1,13 +1,4 @@
1
- export * from './schema/serialization.ts';
2
- export * from './schema/token.ts';
3
- export * from './schema/room.ts';
4
- export * from './schema/peer.ts';
5
- export * from './schema/media.ts';
6
- export * from './schema/message.ts';
7
- export * from './schema/webrtc.ts';
8
- export * from './schema/channels.ts';
9
- export * from './rpc/commands.ts';
10
- export * from './rpc/notifications.ts';
1
+ export * from './plugin/api.ts';
11
2
  export * from './utility/base64.ts';
12
3
  export * from './utility/bytearray.ts';
13
4
  export * from './utility/codec.ts';
@@ -22,4 +13,3 @@ export * from './utility/url.ts';
22
13
  export * from './utility/uuid.ts';
23
14
  export * from './utility/validation.ts';
24
15
  export * from './utility/log.ts';
25
- export * from './plugin/api.ts';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4players/odin-common",
3
- "version": "9.1.0",
3
+ "version": "9.2.0",
4
4
  "description": "A collection of commonly used type definitions and utility functions across ODIN web projects",
5
5
  "author": "Josho Bleicker <josho.bleicker@4players.io> (https://www.4players.io)",
6
6
  "homepage": "https://www.4players.io",
@@ -42,6 +42,6 @@
42
42
  }
43
43
  },
44
44
  "dependencies": {
45
- "zod": "~4.3.0"
45
+ "@zod/zod": "~4.3.0"
46
46
  }
47
47
  }
@@ -1,4 +1,4 @@
1
- import type { ByteArray, JsonValue } from '../schema/serialization.ts';
1
+ import type { ByteArray, JsonValue } from '../api/serialization.ts';
2
2
  import { type Result } from './result.ts';
3
3
  export declare function toBytes(value: JsonValue): Result<ByteArray>;
4
4
  export declare function fromBytes(bytes: ByteArray): Result<JsonValue>;
package/utility/json.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import type { JsonValue } from '../schema/serialization.ts';
1
+ import type { JsonValue } from '../api/serialization.ts';
2
2
  export declare function toRaw<T extends JsonValue>(value: T): JsonValue;
package/utility/log.d.ts CHANGED
@@ -27,18 +27,24 @@ export type LogFormatter = (record: LogRecord) => string;
27
27
  declare function sparseFormat({ message }: LogRecord): string;
28
28
  declare function jsonFormat(record: LogRecord): string;
29
29
  declare function prettyFormat(record: LogRecord): string;
30
+ declare function structuredFormat(record: LogRecord): string;
30
31
  export declare const Formatter: {
31
32
  sparse: typeof sparseFormat;
32
33
  json: typeof jsonFormat;
33
34
  pretty: typeof prettyFormat;
35
+ structured: typeof structuredFormat;
34
36
  default: typeof jsonFormat;
35
37
  };
36
38
  export declare class ConsoleSink implements LogSink {
37
- #private;
39
+ protected formatter: LogFormatter;
40
+ protected consoleObject: ConsoleObject;
38
41
  filter: LogFilter;
39
42
  constructor(formatter?: LogFormatter, filter?: LogFilter, consoleObject?: ConsoleObject);
40
43
  handle(record: LogRecord): void;
41
44
  }
45
+ export declare class InteractiveConsoleSink extends ConsoleSink {
46
+ handle(record: LogRecord): void;
47
+ }
42
48
  export declare class Logger {
43
49
  #private;
44
50
  sinks: LogSink[];
package/rpc/commands.d.ts DELETED
@@ -1,126 +0,0 @@
1
- import { z } from 'zod';
2
- export type Infer<T extends z.ZodType> = z.output<T>;
3
- export type CommandSchema = {
4
- request: z.ZodType;
5
- response: z.ZodType;
6
- };
7
- export type Commands = Record<string, CommandSchema>;
8
- export declare const MainCommandsRpc: {
9
- Hello: {
10
- request: z.ZodObject<{
11
- stream: z.ZodLiteral<"main">;
12
- }, z.core.$strip>;
13
- response: z.ZodNull;
14
- };
15
- JoinRoom: {
16
- request: z.ZodObject<{
17
- token: z.ZodString;
18
- room_id: z.ZodString;
19
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
20
- position: z.ZodUnion<readonly [z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
21
- }, z.core.$strip>;
22
- response: z.ZodObject<{
23
- peer_id: z.ZodNumber;
24
- stream_id: z.ZodOptional<z.ZodNumber>;
25
- token: z.ZodOptional<z.ZodString>;
26
- }, z.core.$strip>;
27
- };
28
- WebRtcUpdate: {
29
- request: z.ZodDiscriminatedUnion<[z.ZodObject<{
30
- kind: z.ZodLiteral<"Sdp">;
31
- type: z.ZodEnum<{
32
- Answer: "Answer";
33
- Offer: "Offer";
34
- }>;
35
- sdp: z.ZodString;
36
- media_map: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodString], null>>;
37
- }, z.core.$strip>, z.ZodObject<{
38
- kind: z.ZodLiteral<"Trickle">;
39
- candidate: z.ZodString;
40
- spd_mid: z.ZodOptional<z.ZodString>;
41
- spd_mline_index: z.ZodOptional<z.ZodNumber>;
42
- username_fragment: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
43
- }, z.core.$strip>, z.ZodObject<{
44
- kind: z.ZodLiteral<"TrickleFinished">;
45
- }, z.core.$strip>], "kind">;
46
- response: z.ZodNull;
47
- };
48
- RequestReconnectToken: {
49
- request: z.ZodObject<{
50
- peer_id: z.ZodOptional<z.ZodNumber>;
51
- }, z.core.$strip>;
52
- response: z.ZodString;
53
- };
54
- Ping: {
55
- request: z.ZodObject<{}, z.core.$strip>;
56
- response: z.ZodNull;
57
- };
58
- };
59
- export type MainCommands = typeof MainCommandsRpc;
60
- export declare const RoomCommandsRpc: {
61
- Hello: {
62
- request: z.ZodObject<{
63
- stream: z.ZodLiteral<"room">;
64
- token: z.ZodString;
65
- room_id: z.ZodString;
66
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
67
- position: z.ZodUnion<readonly [z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
68
- }, z.core.$strip>;
69
- response: z.ZodNull;
70
- };
71
- UpdatePeer: {
72
- request: z.ZodObject<{
73
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
74
- }, z.core.$strip>;
75
- response: z.ZodNull;
76
- };
77
- StartMedia: {
78
- request: z.ZodObject<{
79
- media_id: z.ZodNumber;
80
- properties: z.ZodUnion<readonly [z.ZodObject<{
81
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
82
- uid: z.ZodOptional<z.ZodString>;
83
- customType: z.ZodOptional<z.ZodString>;
84
- }, z.core.$strip>, z.ZodObject<{
85
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
86
- codec: z.ZodOptional<z.ZodString>;
87
- uid: z.ZodOptional<z.ZodString>;
88
- customType: z.ZodOptional<z.ZodString>;
89
- id: z.ZodOptional<z.ZodString>;
90
- }, z.core.$strip>]>;
91
- }, z.core.$strip>;
92
- response: z.ZodNull;
93
- };
94
- StopMedia: {
95
- request: z.ZodObject<{
96
- media_id: z.ZodNumber;
97
- }, z.core.$strip>;
98
- response: z.ZodNull;
99
- };
100
- PauseMedia: {
101
- request: z.ZodObject<{
102
- media_id: z.ZodNumber;
103
- }, z.core.$strip>;
104
- response: z.ZodNull;
105
- };
106
- ResumeMedia: {
107
- request: z.ZodObject<{
108
- media_id: z.ZodNumber;
109
- }, z.core.$strip>;
110
- response: z.ZodNull;
111
- };
112
- SetPeerPosition: {
113
- request: z.ZodObject<{
114
- position: z.ZodUnion<readonly [z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
115
- }, z.core.$strip>;
116
- response: z.ZodNull;
117
- };
118
- SendMessage: {
119
- request: z.ZodObject<{
120
- target_peer_ids: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
121
- message: z.ZodCustom<Uint8Array, Uint8Array>;
122
- }, z.core.$strip>;
123
- response: z.ZodNull;
124
- };
125
- };
126
- export type RoomCommands = typeof RoomCommandsRpc;
@@ -1,268 +0,0 @@
1
- import { z } from 'zod';
2
- export type Notifications = Record<string, z.ZodType>;
3
- export declare const MainNotificationSchema: z.ZodObject<{
4
- name: z.ZodLiteral<"WebRtcUpdate">;
5
- properties: z.ZodDiscriminatedUnion<[z.ZodObject<{
6
- kind: z.ZodLiteral<"Sdp">;
7
- type: z.ZodEnum<{
8
- Answer: "Answer";
9
- Offer: "Offer";
10
- }>;
11
- sdp: z.ZodString;
12
- media_map: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodString], null>>;
13
- }, z.core.$strip>, z.ZodObject<{
14
- kind: z.ZodLiteral<"Trickle">;
15
- candidate: z.ZodString;
16
- spd_mid: z.ZodOptional<z.ZodString>;
17
- spd_mline_index: z.ZodOptional<z.ZodNumber>;
18
- username_fragment: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
19
- }, z.core.$strip>, z.ZodObject<{
20
- kind: z.ZodLiteral<"TrickleFinished">;
21
- }, z.core.$strip>], "kind">;
22
- }, z.core.$strip>;
23
- export type MainNotification = z.infer<typeof MainNotificationSchema>;
24
- export declare const MainNotificationsRpc: {
25
- WebRtcUpdate: z.ZodDiscriminatedUnion<[z.ZodObject<{
26
- kind: z.ZodLiteral<"Sdp">;
27
- type: z.ZodEnum<{
28
- Answer: "Answer";
29
- Offer: "Offer";
30
- }>;
31
- sdp: z.ZodString;
32
- media_map: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodString], null>>;
33
- }, z.core.$strip>, z.ZodObject<{
34
- kind: z.ZodLiteral<"Trickle">;
35
- candidate: z.ZodString;
36
- spd_mid: z.ZodOptional<z.ZodString>;
37
- spd_mline_index: z.ZodOptional<z.ZodNumber>;
38
- username_fragment: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
39
- }, z.core.$strip>, z.ZodObject<{
40
- kind: z.ZodLiteral<"TrickleFinished">;
41
- }, z.core.$strip>], "kind">;
42
- };
43
- export type MainNotifications = typeof MainNotificationsRpc;
44
- export declare const RoomNotificationSchema: z.ZodUnion<readonly [z.ZodObject<{
45
- name: z.ZodLiteral<"RoomStatusChanged">;
46
- properties: z.ZodObject<{
47
- status: z.ZodEnum<{
48
- Joined: "Joined";
49
- Joining: "Joining";
50
- Closed: "Closed";
51
- }>;
52
- message: z.ZodOptional<z.ZodString>;
53
- }, z.core.$strip>;
54
- }, z.core.$strip>, z.ZodObject<{
55
- name: z.ZodLiteral<"RoomUpdated">;
56
- properties: z.ZodObject<{
57
- updates: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
58
- kind: z.ZodLiteral<"Joined">;
59
- room: z.ZodObject<{
60
- id: z.ZodString;
61
- customer: z.ZodString;
62
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
63
- peers: z.ZodArray<z.ZodObject<{
64
- id: z.ZodNumber;
65
- user_id: z.ZodString;
66
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
67
- medias: z.ZodArray<z.ZodObject<{
68
- id: z.ZodNumber;
69
- properties: z.ZodUnion<readonly [z.ZodObject<{
70
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
71
- uid: z.ZodOptional<z.ZodString>;
72
- customType: z.ZodOptional<z.ZodString>;
73
- }, z.core.$strip>, z.ZodObject<{
74
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
75
- codec: z.ZodOptional<z.ZodString>;
76
- uid: z.ZodOptional<z.ZodString>;
77
- customType: z.ZodOptional<z.ZodString>;
78
- id: z.ZodOptional<z.ZodString>;
79
- }, z.core.$strip>]>;
80
- paused: z.ZodBoolean;
81
- }, z.core.$strip>>;
82
- }, z.core.$strip>>;
83
- }, z.core.$strip>;
84
- media_ids: z.ZodArray<z.ZodNumber>;
85
- own_peer_id: z.ZodNumber;
86
- }, z.core.$strip>, z.ZodObject<{
87
- kind: z.ZodLiteral<"Left">;
88
- reason: z.ZodEnum<{
89
- RoomClosing: "RoomClosing";
90
- ServerClosing: "ServerClosing";
91
- PeerKicked: "PeerKicked";
92
- }>;
93
- }, z.core.$strip>, z.ZodObject<{
94
- kind: z.ZodLiteral<"UserDataChanged">;
95
- user_data: z.ZodOptional<z.ZodCustom<Uint8Array, Uint8Array>>;
96
- }, z.core.$strip>, z.ZodObject<{
97
- kind: z.ZodLiteral<"PeerJoined">;
98
- peer: z.ZodObject<{
99
- id: z.ZodNumber;
100
- user_id: z.ZodString;
101
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
102
- medias: z.ZodArray<z.ZodObject<{
103
- id: z.ZodNumber;
104
- properties: z.ZodUnion<readonly [z.ZodObject<{
105
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
106
- uid: z.ZodOptional<z.ZodString>;
107
- customType: z.ZodOptional<z.ZodString>;
108
- }, z.core.$strip>, z.ZodObject<{
109
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
110
- codec: z.ZodOptional<z.ZodString>;
111
- uid: z.ZodOptional<z.ZodString>;
112
- customType: z.ZodOptional<z.ZodString>;
113
- id: z.ZodOptional<z.ZodString>;
114
- }, z.core.$strip>]>;
115
- paused: z.ZodBoolean;
116
- }, z.core.$strip>>;
117
- }, z.core.$strip>;
118
- }, z.core.$strip>, z.ZodObject<{
119
- kind: z.ZodLiteral<"PeerLeft">;
120
- peer_id: z.ZodNumber;
121
- }, z.core.$strip>], "kind">>;
122
- }, z.core.$strip>;
123
- }, z.core.$strip>, z.ZodObject<{
124
- name: z.ZodLiteral<"PeerUpdated">;
125
- properties: z.ZodDiscriminatedUnion<[z.ZodObject<{
126
- kind: z.ZodLiteral<"UserDataChanged">;
127
- peer_id: z.ZodNumber;
128
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
129
- }, z.core.$strip>, z.ZodObject<{
130
- kind: z.ZodLiteral<"MediaStarted">;
131
- peer_id: z.ZodNumber;
132
- media: z.ZodObject<{
133
- id: z.ZodNumber;
134
- properties: z.ZodUnion<readonly [z.ZodObject<{
135
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
136
- uid: z.ZodOptional<z.ZodString>;
137
- customType: z.ZodOptional<z.ZodString>;
138
- }, z.core.$strip>, z.ZodObject<{
139
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
140
- codec: z.ZodOptional<z.ZodString>;
141
- uid: z.ZodOptional<z.ZodString>;
142
- customType: z.ZodOptional<z.ZodString>;
143
- id: z.ZodOptional<z.ZodString>;
144
- }, z.core.$strip>]>;
145
- paused: z.ZodBoolean;
146
- }, z.core.$strip>;
147
- }, z.core.$strip>, z.ZodObject<{
148
- kind: z.ZodLiteral<"MediaStopped">;
149
- peer_id: z.ZodNumber;
150
- media_id: z.ZodNumber;
151
- }, z.core.$strip>], "kind">;
152
- }, z.core.$strip>, z.ZodObject<{
153
- name: z.ZodLiteral<"MessageReceived">;
154
- properties: z.ZodObject<{
155
- sender_peer_id: z.ZodNumber;
156
- message: z.ZodCustom<Uint8Array, Uint8Array>;
157
- }, z.core.$strip>;
158
- }, z.core.$strip>]>;
159
- export type RoomNotification = z.infer<typeof RoomNotificationSchema>;
160
- export declare const RoomNotificationsRpc: {
161
- RoomStatusChanged: z.ZodObject<{
162
- status: z.ZodEnum<{
163
- Joined: "Joined";
164
- Joining: "Joining";
165
- Closed: "Closed";
166
- }>;
167
- message: z.ZodOptional<z.ZodString>;
168
- }, z.core.$strip>;
169
- RoomUpdated: z.ZodObject<{
170
- updates: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
171
- kind: z.ZodLiteral<"Joined">;
172
- room: z.ZodObject<{
173
- id: z.ZodString;
174
- customer: z.ZodString;
175
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
176
- peers: z.ZodArray<z.ZodObject<{
177
- id: z.ZodNumber;
178
- user_id: z.ZodString;
179
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
180
- medias: z.ZodArray<z.ZodObject<{
181
- id: z.ZodNumber;
182
- properties: z.ZodUnion<readonly [z.ZodObject<{
183
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
184
- uid: z.ZodOptional<z.ZodString>;
185
- customType: z.ZodOptional<z.ZodString>;
186
- }, z.core.$strip>, z.ZodObject<{
187
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
188
- codec: z.ZodOptional<z.ZodString>;
189
- uid: z.ZodOptional<z.ZodString>;
190
- customType: z.ZodOptional<z.ZodString>;
191
- id: z.ZodOptional<z.ZodString>;
192
- }, z.core.$strip>]>;
193
- paused: z.ZodBoolean;
194
- }, z.core.$strip>>;
195
- }, z.core.$strip>>;
196
- }, z.core.$strip>;
197
- media_ids: z.ZodArray<z.ZodNumber>;
198
- own_peer_id: z.ZodNumber;
199
- }, z.core.$strip>, z.ZodObject<{
200
- kind: z.ZodLiteral<"Left">;
201
- reason: z.ZodEnum<{
202
- RoomClosing: "RoomClosing";
203
- ServerClosing: "ServerClosing";
204
- PeerKicked: "PeerKicked";
205
- }>;
206
- }, z.core.$strip>, z.ZodObject<{
207
- kind: z.ZodLiteral<"UserDataChanged">;
208
- user_data: z.ZodOptional<z.ZodCustom<Uint8Array, Uint8Array>>;
209
- }, z.core.$strip>, z.ZodObject<{
210
- kind: z.ZodLiteral<"PeerJoined">;
211
- peer: z.ZodObject<{
212
- id: z.ZodNumber;
213
- user_id: z.ZodString;
214
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
215
- medias: z.ZodArray<z.ZodObject<{
216
- id: z.ZodNumber;
217
- properties: z.ZodUnion<readonly [z.ZodObject<{
218
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
219
- uid: z.ZodOptional<z.ZodString>;
220
- customType: z.ZodOptional<z.ZodString>;
221
- }, z.core.$strip>, z.ZodObject<{
222
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
223
- codec: z.ZodOptional<z.ZodString>;
224
- uid: z.ZodOptional<z.ZodString>;
225
- customType: z.ZodOptional<z.ZodString>;
226
- id: z.ZodOptional<z.ZodString>;
227
- }, z.core.$strip>]>;
228
- paused: z.ZodBoolean;
229
- }, z.core.$strip>>;
230
- }, z.core.$strip>;
231
- }, z.core.$strip>, z.ZodObject<{
232
- kind: z.ZodLiteral<"PeerLeft">;
233
- peer_id: z.ZodNumber;
234
- }, z.core.$strip>], "kind">>;
235
- }, z.core.$strip>;
236
- PeerUpdated: z.ZodDiscriminatedUnion<[z.ZodObject<{
237
- kind: z.ZodLiteral<"UserDataChanged">;
238
- peer_id: z.ZodNumber;
239
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
240
- }, z.core.$strip>, z.ZodObject<{
241
- kind: z.ZodLiteral<"MediaStarted">;
242
- peer_id: z.ZodNumber;
243
- media: z.ZodObject<{
244
- id: z.ZodNumber;
245
- properties: z.ZodUnion<readonly [z.ZodObject<{
246
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
247
- uid: z.ZodOptional<z.ZodString>;
248
- customType: z.ZodOptional<z.ZodString>;
249
- }, z.core.$strip>, z.ZodObject<{
250
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
251
- codec: z.ZodOptional<z.ZodString>;
252
- uid: z.ZodOptional<z.ZodString>;
253
- customType: z.ZodOptional<z.ZodString>;
254
- id: z.ZodOptional<z.ZodString>;
255
- }, z.core.$strip>]>;
256
- paused: z.ZodBoolean;
257
- }, z.core.$strip>;
258
- }, z.core.$strip>, z.ZodObject<{
259
- kind: z.ZodLiteral<"MediaStopped">;
260
- peer_id: z.ZodNumber;
261
- media_id: z.ZodNumber;
262
- }, z.core.$strip>], "kind">;
263
- MessageReceived: z.ZodObject<{
264
- sender_peer_id: z.ZodNumber;
265
- message: z.ZodCustom<Uint8Array, Uint8Array>;
266
- }, z.core.$strip>;
267
- };
268
- export type RoomNotifications = typeof RoomNotificationsRpc;
@@ -1,11 +0,0 @@
1
- import * as z from 'zod';
2
- export declare class ChannelSet {
3
- private value;
4
- constructor(value?: bigint);
5
- from(...channels: number[]): ChannelSet;
6
- contains(channel: number): boolean;
7
- insert(channel: number): void;
8
- remove(channel: number): void;
9
- [Symbol.iterator](): Iterator<number>;
10
- }
11
- export declare const ChannelSetSchema: z.ZodPipe<z.ZodBigInt, z.ZodTransform<ChannelSet, bigint>>;
package/schema/media.d.ts DELETED
@@ -1,45 +0,0 @@
1
- import * as z from 'zod';
2
- export declare const MediaIdSchema: z.ZodNumber;
3
- export type MediaId = z.infer<typeof MediaIdSchema>;
4
- export declare const MediaAudioPropertiesSchema: z.ZodObject<{
5
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
6
- uid: z.ZodOptional<z.ZodString>;
7
- customType: z.ZodOptional<z.ZodString>;
8
- }, z.core.$strip>;
9
- export type MediaAudioProperties = z.infer<typeof MediaAudioPropertiesSchema>;
10
- export declare const MediaVideoPropertiesSchema: z.ZodObject<{
11
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
12
- codec: z.ZodOptional<z.ZodString>;
13
- uid: z.ZodOptional<z.ZodString>;
14
- customType: z.ZodOptional<z.ZodString>;
15
- id: z.ZodOptional<z.ZodString>;
16
- }, z.core.$strip>;
17
- export type MediaVideoProperties = z.infer<typeof MediaVideoPropertiesSchema>;
18
- export declare const MediaPropertiesSchema: z.ZodUnion<readonly [z.ZodObject<{
19
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
20
- uid: z.ZodOptional<z.ZodString>;
21
- customType: z.ZodOptional<z.ZodString>;
22
- }, z.core.$strip>, z.ZodObject<{
23
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
24
- codec: z.ZodOptional<z.ZodString>;
25
- uid: z.ZodOptional<z.ZodString>;
26
- customType: z.ZodOptional<z.ZodString>;
27
- id: z.ZodOptional<z.ZodString>;
28
- }, z.core.$strip>]>;
29
- export type MediaProperties = z.infer<typeof MediaPropertiesSchema>;
30
- export declare const MediaSchema: z.ZodObject<{
31
- id: z.ZodNumber;
32
- properties: z.ZodUnion<readonly [z.ZodObject<{
33
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
34
- uid: z.ZodOptional<z.ZodString>;
35
- customType: z.ZodOptional<z.ZodString>;
36
- }, z.core.$strip>, z.ZodObject<{
37
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
38
- codec: z.ZodOptional<z.ZodString>;
39
- uid: z.ZodOptional<z.ZodString>;
40
- customType: z.ZodOptional<z.ZodString>;
41
- id: z.ZodOptional<z.ZodString>;
42
- }, z.core.$strip>]>;
43
- paused: z.ZodBoolean;
44
- }, z.core.$strip>;
45
- export type Media = z.infer<typeof MediaSchema>;
@@ -1,6 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const MessageReceivedSchema: z.ZodObject<{
3
- sender_peer_id: z.ZodNumber;
4
- message: z.ZodCustom<Uint8Array, Uint8Array>;
5
- }, z.core.$strip>;
6
- export type MessageReceived = z.infer<typeof MessageReceivedSchema>;
package/schema/peer.d.ts DELETED
@@ -1,54 +0,0 @@
1
- import * as z from 'zod';
2
- export declare const PeerIdSchema: z.ZodNumber;
3
- export type PeerId = z.infer<typeof PeerIdSchema>;
4
- export declare const PeerPositionSchema: z.ZodUnion<readonly [z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>]>;
5
- export type PeerPosition = z.infer<typeof PeerPositionSchema>;
6
- export declare const PeerSchema: z.ZodObject<{
7
- id: z.ZodNumber;
8
- user_id: z.ZodString;
9
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
10
- medias: z.ZodArray<z.ZodObject<{
11
- id: z.ZodNumber;
12
- properties: z.ZodUnion<readonly [z.ZodObject<{
13
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
14
- uid: z.ZodOptional<z.ZodString>;
15
- customType: z.ZodOptional<z.ZodString>;
16
- }, z.core.$strip>, z.ZodObject<{
17
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
18
- codec: z.ZodOptional<z.ZodString>;
19
- uid: z.ZodOptional<z.ZodString>;
20
- customType: z.ZodOptional<z.ZodString>;
21
- id: z.ZodOptional<z.ZodString>;
22
- }, z.core.$strip>]>;
23
- paused: z.ZodBoolean;
24
- }, z.core.$strip>>;
25
- }, z.core.$strip>;
26
- export type Peer = z.infer<typeof PeerSchema>;
27
- export declare const PeerUpdateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
28
- kind: z.ZodLiteral<"UserDataChanged">;
29
- peer_id: z.ZodNumber;
30
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
31
- }, z.core.$strip>, z.ZodObject<{
32
- kind: z.ZodLiteral<"MediaStarted">;
33
- peer_id: z.ZodNumber;
34
- media: z.ZodObject<{
35
- id: z.ZodNumber;
36
- properties: z.ZodUnion<readonly [z.ZodObject<{
37
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
38
- uid: z.ZodOptional<z.ZodString>;
39
- customType: z.ZodOptional<z.ZodString>;
40
- }, z.core.$strip>, z.ZodObject<{
41
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
42
- codec: z.ZodOptional<z.ZodString>;
43
- uid: z.ZodOptional<z.ZodString>;
44
- customType: z.ZodOptional<z.ZodString>;
45
- id: z.ZodOptional<z.ZodString>;
46
- }, z.core.$strip>]>;
47
- paused: z.ZodBoolean;
48
- }, z.core.$strip>;
49
- }, z.core.$strip>, z.ZodObject<{
50
- kind: z.ZodLiteral<"MediaStopped">;
51
- peer_id: z.ZodNumber;
52
- media_id: z.ZodNumber;
53
- }, z.core.$strip>], "kind">;
54
- export type PeerUpdate = z.infer<typeof PeerUpdateSchema>;
package/schema/room.d.ts DELETED
@@ -1,350 +0,0 @@
1
- import * as z from 'zod';
2
- export declare namespace RoomV1 {
3
- const RoomIdSchema: z.ZodString;
4
- type RoomId = z.infer<typeof RoomIdSchema>;
5
- const RoomSchema: z.ZodObject<{
6
- id: z.ZodString;
7
- customer: z.ZodString;
8
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
9
- peers: z.ZodArray<z.ZodObject<{
10
- id: z.ZodNumber;
11
- user_id: z.ZodString;
12
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
13
- medias: z.ZodArray<z.ZodObject<{
14
- id: z.ZodNumber;
15
- properties: z.ZodUnion<readonly [z.ZodObject<{
16
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
17
- uid: z.ZodOptional<z.ZodString>;
18
- customType: z.ZodOptional<z.ZodString>;
19
- }, z.core.$strip>, z.ZodObject<{
20
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
21
- codec: z.ZodOptional<z.ZodString>;
22
- uid: z.ZodOptional<z.ZodString>;
23
- customType: z.ZodOptional<z.ZodString>;
24
- id: z.ZodOptional<z.ZodString>;
25
- }, z.core.$strip>]>;
26
- paused: z.ZodBoolean;
27
- }, z.core.$strip>>;
28
- }, z.core.$strip>>;
29
- }, z.core.$strip>;
30
- type Room = z.infer<typeof RoomSchema>;
31
- const RoomUpdateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
32
- kind: z.ZodLiteral<"Joined">;
33
- room: z.ZodObject<{
34
- id: z.ZodString;
35
- customer: z.ZodString;
36
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
37
- peers: z.ZodArray<z.ZodObject<{
38
- id: z.ZodNumber;
39
- user_id: z.ZodString;
40
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
41
- medias: z.ZodArray<z.ZodObject<{
42
- id: z.ZodNumber;
43
- properties: z.ZodUnion<readonly [z.ZodObject<{
44
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
45
- uid: z.ZodOptional<z.ZodString>;
46
- customType: z.ZodOptional<z.ZodString>;
47
- }, z.core.$strip>, z.ZodObject<{
48
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
49
- codec: z.ZodOptional<z.ZodString>;
50
- uid: z.ZodOptional<z.ZodString>;
51
- customType: z.ZodOptional<z.ZodString>;
52
- id: z.ZodOptional<z.ZodString>;
53
- }, z.core.$strip>]>;
54
- paused: z.ZodBoolean;
55
- }, z.core.$strip>>;
56
- }, z.core.$strip>>;
57
- }, z.core.$strip>;
58
- media_ids: z.ZodArray<z.ZodNumber>;
59
- own_peer_id: z.ZodNumber;
60
- }, z.core.$strip>, z.ZodObject<{
61
- kind: z.ZodLiteral<"Left">;
62
- reason: z.ZodEnum<{
63
- RoomClosing: "RoomClosing";
64
- ServerClosing: "ServerClosing";
65
- PeerKicked: "PeerKicked";
66
- }>;
67
- }, z.core.$strip>, z.ZodObject<{
68
- kind: z.ZodLiteral<"UserDataChanged">;
69
- user_data: z.ZodOptional<z.ZodCustom<Uint8Array, Uint8Array>>;
70
- }, z.core.$strip>, z.ZodObject<{
71
- kind: z.ZodLiteral<"PeerJoined">;
72
- peer: z.ZodObject<{
73
- id: z.ZodNumber;
74
- user_id: z.ZodString;
75
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
76
- medias: z.ZodArray<z.ZodObject<{
77
- id: z.ZodNumber;
78
- properties: z.ZodUnion<readonly [z.ZodObject<{
79
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
80
- uid: z.ZodOptional<z.ZodString>;
81
- customType: z.ZodOptional<z.ZodString>;
82
- }, z.core.$strip>, z.ZodObject<{
83
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
84
- codec: z.ZodOptional<z.ZodString>;
85
- uid: z.ZodOptional<z.ZodString>;
86
- customType: z.ZodOptional<z.ZodString>;
87
- id: z.ZodOptional<z.ZodString>;
88
- }, z.core.$strip>]>;
89
- paused: z.ZodBoolean;
90
- }, z.core.$strip>>;
91
- }, z.core.$strip>;
92
- }, z.core.$strip>, z.ZodObject<{
93
- kind: z.ZodLiteral<"PeerLeft">;
94
- peer_id: z.ZodNumber;
95
- }, z.core.$strip>], "kind">;
96
- type RoomUpdate = z.infer<typeof RoomUpdateSchema>;
97
- const RoomUpdatesSchema: z.ZodObject<{
98
- updates: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
99
- kind: z.ZodLiteral<"Joined">;
100
- room: z.ZodObject<{
101
- id: z.ZodString;
102
- customer: z.ZodString;
103
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
104
- peers: z.ZodArray<z.ZodObject<{
105
- id: z.ZodNumber;
106
- user_id: z.ZodString;
107
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
108
- medias: z.ZodArray<z.ZodObject<{
109
- id: z.ZodNumber;
110
- properties: z.ZodUnion<readonly [z.ZodObject<{
111
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
112
- uid: z.ZodOptional<z.ZodString>;
113
- customType: z.ZodOptional<z.ZodString>;
114
- }, z.core.$strip>, z.ZodObject<{
115
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
116
- codec: z.ZodOptional<z.ZodString>;
117
- uid: z.ZodOptional<z.ZodString>;
118
- customType: z.ZodOptional<z.ZodString>;
119
- id: z.ZodOptional<z.ZodString>;
120
- }, z.core.$strip>]>;
121
- paused: z.ZodBoolean;
122
- }, z.core.$strip>>;
123
- }, z.core.$strip>>;
124
- }, z.core.$strip>;
125
- media_ids: z.ZodArray<z.ZodNumber>;
126
- own_peer_id: z.ZodNumber;
127
- }, z.core.$strip>, z.ZodObject<{
128
- kind: z.ZodLiteral<"Left">;
129
- reason: z.ZodEnum<{
130
- RoomClosing: "RoomClosing";
131
- ServerClosing: "ServerClosing";
132
- PeerKicked: "PeerKicked";
133
- }>;
134
- }, z.core.$strip>, z.ZodObject<{
135
- kind: z.ZodLiteral<"UserDataChanged">;
136
- user_data: z.ZodOptional<z.ZodCustom<Uint8Array, Uint8Array>>;
137
- }, z.core.$strip>, z.ZodObject<{
138
- kind: z.ZodLiteral<"PeerJoined">;
139
- peer: z.ZodObject<{
140
- id: z.ZodNumber;
141
- user_id: z.ZodString;
142
- user_data: z.ZodCustom<Uint8Array, Uint8Array>;
143
- medias: z.ZodArray<z.ZodObject<{
144
- id: z.ZodNumber;
145
- properties: z.ZodUnion<readonly [z.ZodObject<{
146
- kind: z.ZodOptional<z.ZodLiteral<"audio">>;
147
- uid: z.ZodOptional<z.ZodString>;
148
- customType: z.ZodOptional<z.ZodString>;
149
- }, z.core.$strip>, z.ZodObject<{
150
- kind: z.ZodOptional<z.ZodLiteral<"video">>;
151
- codec: z.ZodOptional<z.ZodString>;
152
- uid: z.ZodOptional<z.ZodString>;
153
- customType: z.ZodOptional<z.ZodString>;
154
- id: z.ZodOptional<z.ZodString>;
155
- }, z.core.$strip>]>;
156
- paused: z.ZodBoolean;
157
- }, z.core.$strip>>;
158
- }, z.core.$strip>;
159
- }, z.core.$strip>, z.ZodObject<{
160
- kind: z.ZodLiteral<"PeerLeft">;
161
- peer_id: z.ZodNumber;
162
- }, z.core.$strip>], "kind">>;
163
- }, z.core.$strip>;
164
- type RoomUpdates = z.infer<typeof RoomUpdatesSchema>;
165
- const RoomStatusSchema: z.ZodEnum<{
166
- Joined: "Joined";
167
- Joining: "Joining";
168
- Closed: "Closed";
169
- }>;
170
- type RoomStatus = z.infer<typeof RoomStatusSchema>;
171
- const RoomStatusChangedSchema: z.ZodObject<{
172
- status: z.ZodEnum<{
173
- Joined: "Joined";
174
- Joining: "Joining";
175
- Closed: "Closed";
176
- }>;
177
- message: z.ZodOptional<z.ZodString>;
178
- }, z.core.$strip>;
179
- type RoomStatusChanged = z.infer<typeof RoomStatusChangedSchema>;
180
- }
181
- export declare namespace RoomV2 {
182
- const ParametersSchema: z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>;
183
- const PeerProperties: z.ZodObject<{
184
- user_data: z.ZodOptional<z.ZodCustom<Uint8Array, Uint8Array>>;
185
- tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
186
- audio_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
187
- video_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
188
- }, z.core.$strip>;
189
- const PingSchema: z.ZodObject<{
190
- Ping: z.ZodObject<{
191
- id: z.ZodNumber;
192
- }, z.core.$strip>;
193
- }, z.core.$strip>;
194
- const ChangeSelfSchema: z.ZodObject<{
195
- ChangeSelf: z.ZodObject<{
196
- user_data: z.ZodOptional<z.ZodCustom<Uint8Array, Uint8Array>>;
197
- audio_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
198
- video_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
199
- }, z.core.$strip>;
200
- }, z.core.$strip>;
201
- const SetAudioMaskSchema: z.ZodObject<{
202
- SetAudioMask: z.ZodObject<{
203
- peer_id: z.ZodNumber;
204
- mask: z.ZodPipe<z.ZodBigInt, z.ZodTransform<import("./channels.ts").ChannelSet, bigint>>;
205
- }, z.core.$strip>;
206
- }, z.core.$strip>;
207
- const SendMessageSchema: z.ZodObject<{
208
- SendMessage: z.ZodObject<{
209
- peer_ids: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
210
- message: z.ZodCustom<Uint8Array, Uint8Array>;
211
- }, z.core.$strip>;
212
- }, z.core.$strip>;
213
- const CallSchema: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
214
- Ping: z.ZodObject<{
215
- id: z.ZodNumber;
216
- }, z.core.$strip>;
217
- }, z.core.$strip>, z.ZodObject<{
218
- ChangeSelf: z.ZodObject<{
219
- user_data: z.ZodOptional<z.ZodCustom<Uint8Array, Uint8Array>>;
220
- audio_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
221
- video_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
222
- }, z.core.$strip>;
223
- }, z.core.$strip>]>, z.ZodObject<{
224
- SetAudioMask: z.ZodObject<{
225
- peer_id: z.ZodNumber;
226
- mask: z.ZodPipe<z.ZodBigInt, z.ZodTransform<import("./channels.ts").ChannelSet, bigint>>;
227
- }, z.core.$strip>;
228
- }, z.core.$strip>]>, z.ZodObject<{
229
- SendMessage: z.ZodObject<{
230
- peer_ids: z.ZodDefault<z.ZodArray<z.ZodNumber>>;
231
- message: z.ZodCustom<Uint8Array, Uint8Array>;
232
- }, z.core.$strip>;
233
- }, z.core.$strip>]>;
234
- type Call = z.infer<typeof CallSchema>;
235
- const PongSchema: z.ZodObject<{
236
- Pong: z.ZodObject<{
237
- id: z.ZodNumber;
238
- }, z.core.$strip>;
239
- }, z.core.$strip>;
240
- const JoinedSchema: z.ZodObject<{
241
- Joined: z.ZodObject<{
242
- own_peer_id: z.ZodNumber;
243
- room_id: z.ZodString;
244
- customer: z.ZodString;
245
- }, z.core.$strip>;
246
- }, z.core.$strip>;
247
- const LeftSchema: z.ZodObject<{
248
- Left: z.ZodObject<{
249
- reason: z.ZodEnum<{
250
- room_closing: "room_closing";
251
- server_closing: "server_closing";
252
- peer_kicked: "peer_kicked";
253
- }>;
254
- }, z.core.$strip>;
255
- }, z.core.$strip>;
256
- const PeerJoinedSchema: z.ZodObject<{
257
- PeerJoined: z.ZodObject<{
258
- user_data: z.ZodOptional<z.ZodCustom<Uint8Array, Uint8Array>>;
259
- tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
260
- audio_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
261
- video_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
262
- peer_id: z.ZodNumber;
263
- user_id: z.ZodString;
264
- }, z.core.$strip>;
265
- }, z.core.$strip>;
266
- const PeerLeftSchema: z.ZodObject<{
267
- PeerLeft: z.ZodObject<{
268
- peer_id: z.ZodNumber;
269
- }, z.core.$strip>;
270
- }, z.core.$strip>;
271
- const PeerChangedSchema: z.ZodObject<{
272
- PeerChanged: z.ZodObject<{
273
- user_data: z.ZodOptional<z.ZodCustom<Uint8Array, Uint8Array>>;
274
- tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
275
- audio_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
276
- video_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
277
- peer_id: z.ZodNumber;
278
- }, z.core.$strip>;
279
- }, z.core.$strip>;
280
- const NewReconnectTokenSchema: z.ZodObject<{
281
- NewReconnectToken: z.ZodObject<{
282
- token: z.ZodString;
283
- }, z.core.$strip>;
284
- }, z.core.$strip>;
285
- const MessageReceivedSchema: z.ZodObject<{
286
- MessageReceived: z.ZodObject<{
287
- sender_peer_id: z.ZodNumber;
288
- message: z.ZodCustom<Uint8Array, Uint8Array>;
289
- }, z.core.$strip>;
290
- }, z.core.$strip>;
291
- const ErrorSchema: z.ZodObject<{
292
- Error: z.ZodObject<{
293
- message: z.ZodCustom<Uint8Array, Uint8Array>;
294
- }, z.core.$strip>;
295
- }, z.core.$strip>;
296
- const EventSchema: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodObject<{
297
- Pong: z.ZodObject<{
298
- id: z.ZodNumber;
299
- }, z.core.$strip>;
300
- }, z.core.$strip>, z.ZodObject<{
301
- Joined: z.ZodObject<{
302
- own_peer_id: z.ZodNumber;
303
- room_id: z.ZodString;
304
- customer: z.ZodString;
305
- }, z.core.$strip>;
306
- }, z.core.$strip>]>, z.ZodObject<{
307
- Left: z.ZodObject<{
308
- reason: z.ZodEnum<{
309
- room_closing: "room_closing";
310
- server_closing: "server_closing";
311
- peer_kicked: "peer_kicked";
312
- }>;
313
- }, z.core.$strip>;
314
- }, z.core.$strip>]>, z.ZodObject<{
315
- PeerJoined: z.ZodObject<{
316
- user_data: z.ZodOptional<z.ZodCustom<Uint8Array, Uint8Array>>;
317
- tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
318
- audio_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
319
- video_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
320
- peer_id: z.ZodNumber;
321
- user_id: z.ZodString;
322
- }, z.core.$strip>;
323
- }, z.core.$strip>]>, z.ZodObject<{
324
- PeerLeft: z.ZodObject<{
325
- peer_id: z.ZodNumber;
326
- }, z.core.$strip>;
327
- }, z.core.$strip>]>, z.ZodObject<{
328
- PeerChanged: z.ZodObject<{
329
- user_data: z.ZodOptional<z.ZodCustom<Uint8Array, Uint8Array>>;
330
- tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
331
- audio_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
332
- video_parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<import("./serialization.ts").JsonValue, unknown, z.core.$ZodTypeInternals<import("./serialization.ts").JsonValue, unknown>>>>;
333
- peer_id: z.ZodNumber;
334
- }, z.core.$strip>;
335
- }, z.core.$strip>]>, z.ZodObject<{
336
- NewReconnectToken: z.ZodObject<{
337
- token: z.ZodString;
338
- }, z.core.$strip>;
339
- }, z.core.$strip>]>, z.ZodObject<{
340
- MessageReceived: z.ZodObject<{
341
- sender_peer_id: z.ZodNumber;
342
- message: z.ZodCustom<Uint8Array, Uint8Array>;
343
- }, z.core.$strip>;
344
- }, z.core.$strip>]>, z.ZodObject<{
345
- Error: z.ZodObject<{
346
- message: z.ZodCustom<Uint8Array, Uint8Array>;
347
- }, z.core.$strip>;
348
- }, z.core.$strip>]>;
349
- type Event = z.infer<typeof EventSchema>;
350
- }
@@ -1,12 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const ByteArraySchema: z.ZodCustom<Uint8Array, Uint8Array>;
3
- export type ByteArray = z.infer<typeof ByteArraySchema>;
4
- declare const LiteralSchema: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>;
5
- type Literal = z.infer<typeof LiteralSchema>;
6
- export type JsonValue = Literal | {
7
- [key: string]: JsonValue;
8
- } | JsonValue[];
9
- export declare const JsonSchema: z.ZodType<JsonValue>;
10
- export declare const MessagePackRpcSchema: z.ZodUnion<readonly [z.ZodTuple<[z.ZodLiteral<0>, z.ZodNumber, z.ZodString, z.ZodUnknown], null>, z.ZodTuple<[z.ZodLiteral<1>, z.ZodNumber, z.ZodNullable<z.ZodString>, z.ZodUnknown], null>, z.ZodTuple<[z.ZodLiteral<2>, z.ZodString, z.ZodUnknown], null>]>;
11
- export type MessagePackRpc = z.infer<typeof MessagePackRpcSchema>;
12
- export {};
package/schema/token.d.ts DELETED
@@ -1,31 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const TokenAudienceSchema: z.ZodEnum<{
3
- sfu: "sfu";
4
- gateway: "gateway";
5
- }>;
6
- export declare const TokenSubjectSchema: z.ZodEnum<{
7
- connect: "connect";
8
- roomclose: "roomclose";
9
- roomupdate: "roomupdate";
10
- roombanclient: "roombanclient";
11
- roomsendmessage: "roomsendmessage";
12
- }>;
13
- export declare const TokenClaimsSchema: z.ZodObject<{
14
- uid: z.ZodString;
15
- cid: z.ZodOptional<z.ZodString>;
16
- rid: z.ZodType<string[], unknown, z.core.$ZodTypeInternals<string[], unknown>>;
17
- nsp: z.ZodOptional<z.ZodString>;
18
- adr: z.ZodOptional<z.ZodString>;
19
- aud: z.ZodOptional<z.ZodType<("sfu" | "gateway")[], unknown, z.core.$ZodTypeInternals<("sfu" | "gateway")[], unknown>>>;
20
- sub: z.ZodOptional<z.ZodType<("connect" | "roomclose" | "roomupdate" | "roombanclient" | "roomsendmessage")[], unknown, z.core.$ZodTypeInternals<("connect" | "roomclose" | "roomupdate" | "roombanclient" | "roomsendmessage")[], unknown>>>;
21
- exp: z.ZodOptional<z.ZodNumber>;
22
- nbf: z.ZodOptional<z.ZodNumber>;
23
- ups: z.ZodOptional<z.ZodString>;
24
- tgs: z.ZodOptional<z.ZodType<string[], unknown, z.core.$ZodTypeInternals<string[], unknown>>>;
25
- tsp: z.ZodOptional<z.ZodNumber>;
26
- internal: z.ZodOptional<z.ZodObject<{
27
- server: z.ZodOptional<z.ZodString>;
28
- }, z.core.$strip>>;
29
- }, z.core.$strip>;
30
- export type TokenClaims = z.infer<typeof TokenClaimsSchema>;
31
- export declare function oneOrMany<T extends z.ZodTypeAny>(type: T): z.ZodType<z.infer<T>[]>;
@@ -1,19 +0,0 @@
1
- import * as z from 'zod';
2
- export declare const WebRtcUpdateSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
- kind: z.ZodLiteral<"Sdp">;
4
- type: z.ZodEnum<{
5
- Answer: "Answer";
6
- Offer: "Offer";
7
- }>;
8
- sdp: z.ZodString;
9
- media_map: z.ZodArray<z.ZodTuple<[z.ZodNumber, z.ZodString], null>>;
10
- }, z.core.$strip>, z.ZodObject<{
11
- kind: z.ZodLiteral<"Trickle">;
12
- candidate: z.ZodString;
13
- spd_mid: z.ZodOptional<z.ZodString>;
14
- spd_mline_index: z.ZodOptional<z.ZodNumber>;
15
- username_fragment: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNull]>>;
16
- }, z.core.$strip>, z.ZodObject<{
17
- kind: z.ZodLiteral<"TrickleFinished">;
18
- }, z.core.$strip>], "kind">;
19
- export type WebRtcUpdate = z.infer<typeof WebRtcUpdateSchema>;